Total reorganization
2001-09-21 Bradford Hovinen <hovinen@ximian.com> * applier.c: Total reorganization 2001-09-17 Bradford Hovinen <hovinen@ximian.com> * preferences.c (preferences_save): Move from applier.c:output_compat_prefs; it really belongs here (preferences_class_init): Don't construct an applier here * background-properties-capplet.c (setup_dialog): Create a new applier for every dialog (create_dialog): Create applier locally, just for this one widget (apply_settings): Create applier locally and destroy on exit (main): Remove call to gnome_window_set_...
This commit is contained in:
parent
b90a84da60
commit
ee3356381a
6 changed files with 878 additions and 824 deletions
|
@ -1,5 +1,13 @@
|
|||
2001-09-21 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* applier.c: Total reorganization
|
||||
|
||||
2001-09-17 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* preferences.c (preferences_save): Move from
|
||||
applier.c:output_compat_prefs; it really belongs here
|
||||
(preferences_class_init): Don't construct an applier here
|
||||
|
||||
* background-properties-capplet.c (setup_dialog): Create a new
|
||||
applier for every dialog
|
||||
(create_dialog): Create applier locally, just for this one widget
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -41,10 +41,14 @@ typedef struct _ApplierClass ApplierClass;
|
|||
|
||||
typedef struct _ApplierPrivate ApplierPrivate;
|
||||
|
||||
typedef enum _ApplierType {
|
||||
APPLIER_ROOT, APPLIER_PREVIEW
|
||||
} ApplierType;
|
||||
|
||||
struct _Applier
|
||||
{
|
||||
GtkObject object;
|
||||
ApplierPrivate *private;
|
||||
ApplierPrivate *p;
|
||||
};
|
||||
|
||||
struct _ApplierClass
|
||||
|
@ -54,14 +58,13 @@ struct _ApplierClass
|
|||
|
||||
guint applier_get_type (void);
|
||||
|
||||
GtkObject *applier_new (void);
|
||||
GtkObject *applier_new (ApplierType type);
|
||||
|
||||
void applier_apply_prefs (Applier *applier,
|
||||
const Preferences *prefs,
|
||||
gboolean do_root,
|
||||
gboolean do_preview);
|
||||
const Preferences *prefs);
|
||||
|
||||
gboolean applier_render_color_p (Applier *applier);
|
||||
gboolean applier_render_color_p (const Applier *applier,
|
||||
const Preferences *prefs);
|
||||
|
||||
GtkWidget *applier_get_preview_widget (Applier *applier);
|
||||
GdkPixbuf *applier_get_wallpaper_pixbuf (Applier *applier);
|
||||
|
|
|
@ -57,7 +57,7 @@ apply_settings (Bonobo_ConfigDatabase db)
|
|||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
applier = APPLIER (applier_new ());
|
||||
applier = APPLIER (applier_new (APPLIER_ROOT));
|
||||
|
||||
/* Hackity hackty */
|
||||
if (background_image != NULL) {
|
||||
|
@ -70,7 +70,7 @@ apply_settings (Bonobo_ConfigDatabase db)
|
|||
if (BONOBO_EX (&ev) || prefs == NULL) {
|
||||
g_critical ("Could not retrieve configuration from database (%s)", ev._repo_id);
|
||||
} else {
|
||||
applier_apply_prefs (applier, PREFERENCES (prefs), TRUE, FALSE);
|
||||
applier_apply_prefs (applier, PREFERENCES (prefs));
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
}
|
||||
|
||||
|
@ -216,13 +216,13 @@ property_change_cb (BonoboListener *listener,
|
|||
|
||||
preferences_apply_event (prefs, event_name, any);
|
||||
applier = gtk_object_get_data (GTK_OBJECT (WID ("prefs_widget")), "applier");
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
applier_apply_prefs (applier, prefs);
|
||||
|
||||
if (!strcmp (event_name, "Bonobo/Property:change:wallpaper_type")
|
||||
|| !strcmp (event_name, "Bonobo/Property:change:wallpaper_filename")
|
||||
|| !strcmp (event_name, "Bonobo/Property:change:wallpaper_enabled"))
|
||||
gtk_widget_set_sensitive
|
||||
(WID ("color_frame"), applier_render_color_p (applier));
|
||||
(WID ("color_frame"), applier_render_color_p (applier, prefs));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -240,9 +240,9 @@ real_realize_cb (Preferences *prefs)
|
|||
dialog = gtk_object_get_data (GTK_OBJECT (prefs), "glade-data");
|
||||
applier = gtk_object_get_data (GTK_OBJECT (WID ("prefs_widget")), "applier");
|
||||
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
applier_apply_prefs (applier, prefs);
|
||||
|
||||
gtk_widget_set_sensitive (WID ("color_frame"), applier_render_color_p (applier));
|
||||
gtk_widget_set_sensitive (WID ("color_frame"), applier_render_color_p (applier, prefs));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|||
applier = gtk_object_get_data (GTK_OBJECT (widget), "applier");
|
||||
|
||||
if (GTK_WIDGET_REALIZED (applier_get_preview_widget (applier)))
|
||||
applier_apply_prefs (applier, PREFERENCES (prefs), FALSE, TRUE);
|
||||
applier_apply_prefs (applier, PREFERENCES (prefs));
|
||||
else
|
||||
gtk_signal_connect_after (GTK_OBJECT (applier_get_preview_widget (applier)), "realize", realize_cb, prefs);
|
||||
|
||||
|
@ -332,7 +332,7 @@ create_dialog (void)
|
|||
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||
|
||||
applier = APPLIER (applier_new ());
|
||||
applier = APPLIER (applier_new (APPLIER_PREVIEW));
|
||||
gtk_object_set_data (GTK_OBJECT (widget), "applier", applier);
|
||||
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy", GTK_SIGNAL_FUNC (gtk_object_destroy), GTK_OBJECT (applier));
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <bonobo.h>
|
||||
|
||||
#include "preferences.h"
|
||||
#include "applier.h"
|
||||
|
||||
/* Convenience macro to abort if there is an exception set */
|
||||
|
||||
|
@ -59,7 +58,6 @@ static c_type local_bonobo_config_get_##name (Bonobo_ConfigDatabase db, \
|
|||
}
|
||||
|
||||
static GtkObjectClass *parent_class;
|
||||
static Applier *applier = NULL;
|
||||
|
||||
static void preferences_init (Preferences *prefs);
|
||||
static void preferences_class_init (PreferencesClass *class);
|
||||
|
@ -137,9 +135,6 @@ preferences_class_init (PreferencesClass *class)
|
|||
|
||||
parent_class =
|
||||
GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ()));
|
||||
|
||||
if (applier == NULL)
|
||||
applier = APPLIER (applier_new ());
|
||||
}
|
||||
|
||||
GtkObject *
|
||||
|
@ -400,6 +395,50 @@ preferences_apply_event (Preferences *prefs,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* preferences_save:
|
||||
* @prefs:
|
||||
*
|
||||
* Save a preferences structure using the legacy gnome_config API
|
||||
**/
|
||||
|
||||
void
|
||||
preferences_save (const Preferences *prefs)
|
||||
{
|
||||
static const gint wallpaper_types[] = { 0, 1, 3, 2 };
|
||||
gchar *color;
|
||||
|
||||
gnome_config_pop_prefix ();
|
||||
gnome_config_set_bool ("/Background/Default/Enabled", prefs->enabled);
|
||||
gnome_config_set_string ("/Background/Default/wallpaper",
|
||||
(prefs->wallpaper_filename) ? prefs->wallpaper_filename : "none");
|
||||
gnome_config_set_int ("/Background/Default/wallpaperAlign", wallpaper_types[prefs->wallpaper_type]);
|
||||
|
||||
color = g_strdup_printf ("#%02x%02x%02x",
|
||||
prefs->color1->red >> 8,
|
||||
prefs->color1->green >> 8,
|
||||
prefs->color1->blue >> 8);
|
||||
gnome_config_set_string ("/Background/Default/color1", color);
|
||||
g_free (color);
|
||||
|
||||
color = g_strdup_printf ("#%02x%02x%02x",
|
||||
prefs->color2->red >> 8,
|
||||
prefs->color2->green >> 8,
|
||||
prefs->color2->blue >> 8);
|
||||
gnome_config_set_string ("/Background/Default/color2", color);
|
||||
g_free (color);
|
||||
|
||||
gnome_config_set_string ("/Background/Default/simple",
|
||||
(prefs->gradient_enabled) ? "gradient" : "solid");
|
||||
gnome_config_set_string ("/Background/Default/gradient",
|
||||
(prefs->orientation == ORIENTATION_VERT) ? "vertical" : "horizontal");
|
||||
|
||||
gnome_config_set_bool ("/Background/Default/adjustOpacity", prefs->adjust_opacity);
|
||||
gnome_config_set_int ("/Background/Default/opacity", prefs->opacity);
|
||||
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
static GdkColor *
|
||||
read_color_from_string (const gchar *string)
|
||||
{
|
||||
|
|
|
@ -45,8 +45,8 @@ typedef enum _orientation_t {
|
|||
} orientation_t;
|
||||
|
||||
typedef enum _wallpaper_type_t {
|
||||
WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED_ASPECT,
|
||||
WPTYPE_SCALED, WPTYPE_EMBOSSED
|
||||
WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED,
|
||||
WPTYPE_STRETCHED, WPTYPE_EMBOSSED
|
||||
} wallpaper_type_t;
|
||||
|
||||
struct _Preferences
|
||||
|
@ -85,9 +85,6 @@ guint preferences_get_type (void);
|
|||
GtkObject *preferences_new (void);
|
||||
GtkObject *preferences_clone (const Preferences *prefs);
|
||||
|
||||
gboolean preferences_need_color_opts (Preferences *prefs,
|
||||
GdkPixbuf *wallpaper_pixbuf);
|
||||
|
||||
GtkObject *preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb,
|
||||
CORBA_Environment *ev);
|
||||
GtkObject *preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db,
|
||||
|
@ -103,4 +100,6 @@ void preferences_apply_event (Preferences *prefs,
|
|||
const gchar *event_name,
|
||||
const CORBA_any *value);
|
||||
|
||||
void preferences_save (const Preferences *prefs);
|
||||
|
||||
#endif /* __PREFERENCES_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue