Remove all bonobo-conf stuff.
2001-07-26 Richard Hestilow <hestilow@ximian.com> * applier.c: Remove all bonobo-conf stuff. * preferences.[ch]: New functions preferences_new_from_bonobo_pbag and preferences_new_from_bonobo_db.
This commit is contained in:
parent
cf7a5fe568
commit
dae9cccc0e
7 changed files with 207 additions and 246 deletions
|
@ -1,3 +1,10 @@
|
|||
2001-07-26 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* applier.c: Remove all bonobo-conf stuff.
|
||||
|
||||
* preferences.[ch]: New functions preferences_new_from_bonobo_pbag
|
||||
and preferences_new_from_bonobo_db.
|
||||
|
||||
2001-07-26 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* background-properties.glade: Tweak borders and padding
|
||||
|
|
|
@ -6,6 +6,7 @@ background_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
|||
|
||||
bonobo_sources = \
|
||||
background-properties-capplet.c \
|
||||
preferences.c preferences.h \
|
||||
applier.c applier.h
|
||||
|
||||
legacy_sources = \
|
||||
|
@ -17,9 +18,11 @@ legacy_sources = \
|
|||
if BONOBO_CONF_ENABLE
|
||||
DESKTOP_EXEC_LINE = gnomecc --run-capplet background-properties
|
||||
background_properties_capplet_SOURCES = $(bonobo_sources)
|
||||
BONOBO_CONF_DEFINE=-DBONOBO_CONF_ENABLE
|
||||
else
|
||||
DESKTOP_EXEC_LINE = background-properties-capplet
|
||||
background_properties_capplet_SOURCES = $(legacy_sources)
|
||||
BONOBO_CONF_DEFINE=
|
||||
endif
|
||||
|
||||
pixmap_DATA =
|
||||
|
@ -50,7 +53,7 @@ install-data-local:
|
|||
install-data-am: install-data-local
|
||||
####@###GNOMECC_CAPPLETS_DESKTOP_IN_RULE@
|
||||
|
||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) $(BONOBO_CONF_DEFINE)
|
||||
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
||||
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in $(bonobo_sources) $(legacy_sources)
|
||||
iconsdir = $(GNOMECC_ICONS_DIR)
|
||||
|
|
|
@ -47,10 +47,10 @@
|
|||
|
||||
#define PDEBUG(pix) (g_print ("file %s: line %d (%s): Setting pixbuf to %i %i\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, gdk_pixbuf_get_width (pix), gdk_pixbuf_get_height (pix)))
|
||||
|
||||
static GtkWidget *preview_widget;
|
||||
static gboolean gdk_pixbuf_xlib_inited = FALSE;
|
||||
|
||||
typedef struct _Renderer Renderer;
|
||||
typedef struct _ApplierPreferences ApplierPreferences;
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
|
@ -59,9 +59,8 @@ enum {
|
|||
struct _ApplierPrivate
|
||||
{
|
||||
GtkWidget *preview_widget;
|
||||
|
||||
ApplierPreferences *root_prefs;
|
||||
ApplierPreferences *preview_prefs;
|
||||
Preferences *root_prefs;
|
||||
Preferences *preview_prefs;
|
||||
|
||||
GdkPixbuf *wallpaper_pixbuf;
|
||||
gchar *wallpaper_filename;
|
||||
|
@ -78,7 +77,7 @@ struct _Renderer
|
|||
gboolean is_set;
|
||||
|
||||
Applier *applier;
|
||||
ApplierPreferences *prefs;
|
||||
Preferences *prefs;
|
||||
|
||||
gint x; /* Geometry relative to pixmap */
|
||||
gint y;
|
||||
|
@ -106,34 +105,6 @@ struct _Renderer
|
|||
Pixmap pixmap;
|
||||
};
|
||||
|
||||
typedef enum _orientation_t {
|
||||
ORIENTATION_SOLID, ORIENTATION_HORIZ, ORIENTATION_VERT
|
||||
} orientation_t;
|
||||
|
||||
typedef enum _wallpaper_type_t {
|
||||
WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED_ASPECT,
|
||||
WPTYPE_SCALED, WPTYPE_EMBOSSED
|
||||
} wallpaper_type_t;
|
||||
|
||||
|
||||
struct _ApplierPreferences
|
||||
{
|
||||
int ref_count;
|
||||
|
||||
gboolean gradient_enabled;
|
||||
gboolean wallpaper_enabled;
|
||||
orientation_t orientation;
|
||||
wallpaper_type_t wallpaper_type;
|
||||
|
||||
GdkColor *color1;
|
||||
GdkColor *color2;
|
||||
|
||||
gchar *wallpaper_filename;
|
||||
|
||||
gboolean adjust_opacity;
|
||||
gint opacity;
|
||||
};
|
||||
|
||||
static GtkObjectClass *parent_class;
|
||||
|
||||
static void applier_init (Applier *prefs);
|
||||
|
@ -147,8 +118,8 @@ static void applier_get_arg (GtkObject *object,
|
|||
guint arg_id);
|
||||
|
||||
static void run_render_pipeline (Renderer *renderer,
|
||||
ApplierPreferences *old_prefs,
|
||||
ApplierPreferences *new_prefs,
|
||||
Preferences *old_prefs,
|
||||
Preferences *new_prefs,
|
||||
GdkPixbuf *wallpaper_pixbuf);
|
||||
static void draw_disabled_message (GtkWidget *widget);
|
||||
|
||||
|
@ -156,7 +127,7 @@ static Renderer *renderer_new (Applier *applier, gboolean is_root);
|
|||
static void renderer_destroy (Renderer *renderer);
|
||||
|
||||
static void renderer_set_prefs (Renderer *renderer,
|
||||
ApplierPreferences *prefs);
|
||||
Preferences *prefs);
|
||||
static void renderer_set_wallpaper (Renderer *renderer,
|
||||
GdkPixbuf *wallpaper_pixbuf);
|
||||
|
||||
|
@ -187,23 +158,15 @@ static void tile_composite (GdkPixbuf *dest, GdkPixbuf *src,
|
|||
gint alpha_value);
|
||||
|
||||
static gboolean render_gradient_p (Renderer *renderer,
|
||||
ApplierPreferences *prefs);
|
||||
static gboolean render_small_pixmap_p (ApplierPreferences *prefs);
|
||||
Preferences *prefs);
|
||||
static gboolean render_small_pixmap_p (Preferences *prefs);
|
||||
|
||||
static Pixmap make_root_pixmap (gint width, gint height);
|
||||
static void set_root_pixmap (Pixmap pixmap);
|
||||
|
||||
static gboolean is_nautilus_running (void);
|
||||
|
||||
/* preferences stuff -- easier than making an object */
|
||||
static ApplierPreferences* applier_preferences_pb_new (Bonobo_PropertyBag pb, CORBA_Environment *ev);
|
||||
static ApplierPreferences* applier_preferences_db_new (Bonobo_ConfigDatabase db, CORBA_Environment *ev);
|
||||
static void applier_preferences_ref (ApplierPreferences *prefs);
|
||||
static void applier_preferences_unref (ApplierPreferences *prefs);
|
||||
static void applier_preferences_free (ApplierPreferences *prefs);
|
||||
|
||||
static GdkColor* bonobo_color_to_gdk (Bonobo_Config_Color *color);
|
||||
static void output_compat_prefs (ApplierPreferences *prefs);
|
||||
static void output_compat_prefs (Preferences *prefs);
|
||||
|
||||
guint
|
||||
applier_get_type (void)
|
||||
|
@ -325,9 +288,9 @@ applier_destroy (GtkObject *object)
|
|||
renderer_destroy (applier->private->root_renderer);
|
||||
|
||||
if (applier->private->root_prefs != NULL)
|
||||
applier_preferences_unref (applier->private->root_prefs);
|
||||
gtk_object_unref (GTK_OBJECT (applier->private->root_prefs));
|
||||
if (applier->private->preview_prefs != NULL)
|
||||
applier_preferences_unref (applier->private->preview_prefs);
|
||||
gtk_object_unref (GTK_OBJECT (applier->private->preview_prefs));
|
||||
|
||||
if (applier->private->wallpaper_pixbuf != NULL)
|
||||
gdk_pixbuf_unref (applier->private->wallpaper_pixbuf);
|
||||
|
@ -340,9 +303,10 @@ applier_destroy (GtkObject *object)
|
|||
}
|
||||
|
||||
void
|
||||
applier_apply_prefs (Applier *applier, Bonobo_PropertyBag pb, Bonobo_ConfigDatabase db, CORBA_Environment *ev, gboolean do_root, gboolean do_preview)
|
||||
applier_apply_prefs (Applier *applier, Preferences *prefs,
|
||||
gboolean do_root, gboolean do_preview)
|
||||
{
|
||||
ApplierPreferences *prefs;
|
||||
Preferences *new_prefs;
|
||||
|
||||
g_return_if_fail (applier != NULL);
|
||||
g_return_if_fail (IS_APPLIER (applier));
|
||||
|
@ -351,10 +315,12 @@ applier_apply_prefs (Applier *applier, Bonobo_PropertyBag pb, Bonobo_ConfigDatab
|
|||
set_root_pixmap (-1);
|
||||
}
|
||||
|
||||
if (pb != CORBA_OBJECT_NIL)
|
||||
prefs = applier_preferences_pb_new (pb, ev);
|
||||
else
|
||||
prefs = applier_preferences_db_new (db, ev);
|
||||
if (!prefs->enabled) {
|
||||
draw_disabled_message (applier_class_get_preview_widget ());
|
||||
return;
|
||||
}
|
||||
|
||||
new_prefs = PREFERENCES (preferences_clone (prefs));
|
||||
|
||||
if (((prefs->wallpaper_filename ||
|
||||
applier->private->wallpaper_filename) &&
|
||||
|
@ -387,11 +353,11 @@ applier_apply_prefs (Applier *applier, Bonobo_PropertyBag pb, Bonobo_ConfigDatab
|
|||
if (!applier->private->wallpaper_pixbuf) {
|
||||
g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."),
|
||||
prefs->wallpaper_filename);
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
new_prefs->wallpaper_enabled = FALSE;
|
||||
}
|
||||
}
|
||||
else if (applier->private->wallpaper_pixbuf == NULL) {
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
new_prefs->wallpaper_enabled = FALSE;
|
||||
}
|
||||
|
||||
if (do_preview) {
|
||||
|
@ -401,14 +367,15 @@ applier_apply_prefs (Applier *applier, Bonobo_PropertyBag pb, Bonobo_ConfigDatab
|
|||
|
||||
run_render_pipeline (applier->private->preview_renderer,
|
||||
applier->private->preview_prefs,
|
||||
prefs,
|
||||
new_prefs,
|
||||
applier->private->wallpaper_pixbuf);
|
||||
|
||||
if (applier->private->preview_prefs != NULL)
|
||||
applier_preferences_unref (applier->private->preview_prefs);
|
||||
gtk_object_unref (GTK_OBJECT
|
||||
(applier->private->preview_prefs));
|
||||
|
||||
applier->private->preview_prefs = prefs;
|
||||
applier_preferences_ref (prefs);
|
||||
applier->private->preview_prefs = new_prefs;
|
||||
gtk_object_ref (GTK_OBJECT (new_prefs));
|
||||
|
||||
if (applier->private->preview_widget != NULL)
|
||||
gtk_widget_queue_draw (applier->private->preview_widget);
|
||||
|
@ -423,22 +390,24 @@ applier_apply_prefs (Applier *applier, Bonobo_PropertyBag pb, Bonobo_ConfigDatab
|
|||
if (!applier->private->nautilus_running)
|
||||
run_render_pipeline (applier->private->root_renderer,
|
||||
applier->private->root_prefs,
|
||||
prefs,
|
||||
new_prefs,
|
||||
applier->private->wallpaper_pixbuf);
|
||||
|
||||
output_compat_prefs (prefs);
|
||||
|
||||
if (applier->private->root_prefs != NULL)
|
||||
applier_preferences_unref (applier->private->root_prefs);
|
||||
applier->private->root_prefs = prefs;
|
||||
applier_preferences_ref (prefs);
|
||||
gtk_object_unref (GTK_OBJECT
|
||||
(applier->private->root_prefs));
|
||||
|
||||
applier->private->root_prefs = new_prefs;
|
||||
gtk_object_ref (GTK_OBJECT (new_prefs));
|
||||
}
|
||||
|
||||
applier_preferences_unref (prefs);
|
||||
gtk_object_unref (GTK_OBJECT (new_prefs));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
applier_get_preview_widget (Applier *applier)
|
||||
applier_class_get_preview_widget (void)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixmap *pixmap;
|
||||
|
@ -449,7 +418,7 @@ applier_get_preview_widget (Applier *applier)
|
|||
gchar *filename;
|
||||
GdkGC *gc;
|
||||
|
||||
if (applier->private->preview_widget != NULL) return applier->private->preview_widget;
|
||||
if (preview_widget != NULL) return preview_widget;
|
||||
|
||||
filename = gnome_pixmap_file ("monitor.png");
|
||||
visual = gdk_window_get_visual (GDK_ROOT_PARENT ());
|
||||
|
@ -508,27 +477,15 @@ applier_get_preview_widget (Applier *applier)
|
|||
mask = NULL;
|
||||
}
|
||||
|
||||
applier->private->preview_widget = gtk_pixmap_new (pixmap, mask);
|
||||
gtk_widget_show (applier->private->preview_widget);
|
||||
preview_widget = gtk_pixmap_new (pixmap, mask);
|
||||
gtk_widget_show (preview_widget);
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
g_free (filename);
|
||||
|
||||
gtk_widget_pop_visual ();
|
||||
gtk_widget_pop_colormap ();
|
||||
|
||||
return applier->private->preview_widget;
|
||||
}
|
||||
|
||||
void
|
||||
applier_destroy_preview_widget (Applier *applier)
|
||||
{
|
||||
if (applier->private->preview_widget == NULL)
|
||||
return;
|
||||
|
||||
if (GTK_IS_WIDGET (applier->private->preview_widget))
|
||||
gtk_widget_destroy (applier->private->preview_widget);
|
||||
|
||||
applier->private->preview_widget = NULL;
|
||||
return preview_widget;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -578,8 +535,8 @@ draw_disabled_message (GtkWidget *widget)
|
|||
|
||||
static void
|
||||
run_render_pipeline (Renderer *renderer,
|
||||
ApplierPreferences *old_prefs,
|
||||
ApplierPreferences *new_prefs,
|
||||
Preferences *old_prefs,
|
||||
Preferences *new_prefs,
|
||||
GdkPixbuf *wallpaper_pixbuf)
|
||||
{
|
||||
gboolean bg_formed = FALSE;
|
||||
|
@ -693,17 +650,17 @@ renderer_destroy (Renderer *renderer)
|
|||
}
|
||||
|
||||
static void
|
||||
renderer_set_prefs (Renderer *renderer, ApplierPreferences *prefs)
|
||||
renderer_set_prefs (Renderer *renderer, Preferences *prefs)
|
||||
{
|
||||
g_return_if_fail (renderer != NULL);
|
||||
|
||||
if (renderer->prefs)
|
||||
applier_preferences_unref (renderer->prefs);
|
||||
gtk_object_unref (GTK_OBJECT (renderer->prefs));
|
||||
|
||||
renderer->prefs = prefs;
|
||||
|
||||
if (prefs)
|
||||
applier_preferences_ref (prefs);
|
||||
gtk_object_ref (GTK_OBJECT (prefs));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -884,10 +841,9 @@ renderer_render_wallpaper (Renderer *renderer)
|
|||
(renderer->wallpaper_pixbuf,
|
||||
renderer->pixbuf,
|
||||
renderer->wx, renderer->wy,
|
||||
MIN (renderer->wwidth, renderer->width),
|
||||
MIN (renderer->wheight, renderer->height),
|
||||
renderer->wx - renderer->srcx,
|
||||
renderer->wy - renderer->srcy,
|
||||
renderer->wwidth,
|
||||
renderer->wheight,
|
||||
renderer->wx, renderer->wy,
|
||||
scalex, scaley,
|
||||
GDK_INTERP_BILINEAR);
|
||||
} else {
|
||||
|
@ -1254,7 +1210,7 @@ render_tiled_image (Pixmap pixmap, GC xgc, GdkPixbuf *pixbuf,
|
|||
/* Return TRUE if the gradient should be rendered, false otherwise */
|
||||
|
||||
static gboolean
|
||||
render_gradient_p (Renderer *renderer, ApplierPreferences *prefs)
|
||||
render_gradient_p (Renderer *renderer, Preferences *prefs)
|
||||
{
|
||||
return prefs->gradient_enabled &&
|
||||
!(prefs->wallpaper_enabled &&
|
||||
|
@ -1268,7 +1224,7 @@ render_gradient_p (Renderer *renderer, ApplierPreferences *prefs)
|
|||
/* Return TRUE if we can optimize the rendering by using a small thin pixmap */
|
||||
|
||||
static gboolean
|
||||
render_small_pixmap_p (ApplierPreferences *prefs)
|
||||
render_small_pixmap_p (Preferences *prefs)
|
||||
{
|
||||
return prefs->gradient_enabled && !prefs->wallpaper_enabled;
|
||||
}
|
||||
|
@ -1421,126 +1377,9 @@ is_nautilus_running (void)
|
|||
return running;
|
||||
}
|
||||
|
||||
static gulong
|
||||
pb_get_value_ulong (Bonobo_PropertyBag bag, const gchar *prop)
|
||||
{
|
||||
BonoboArg *arg;
|
||||
gulong val;
|
||||
|
||||
arg = bonobo_property_bag_client_get_value_any (bag, prop, NULL);
|
||||
val = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_unsigned_long, NULL);
|
||||
bonobo_arg_release (arg);
|
||||
return val;
|
||||
}
|
||||
|
||||
#define PB_GET_VALUE(v) (bonobo_property_bag_client_get_value_any (pb, (v), NULL))
|
||||
|
||||
/* Probably has CORBA memory leaks */
|
||||
static ApplierPreferences*
|
||||
applier_preferences_pb_new (Bonobo_PropertyBag pb, CORBA_Environment *ev)
|
||||
{
|
||||
ApplierPreferences *prefs = g_new0 (ApplierPreferences, 1);
|
||||
|
||||
prefs->orientation = pb_get_value_ulong (pb, "orientation");
|
||||
if (prefs->orientation != ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = TRUE;
|
||||
|
||||
prefs->wallpaper_type = pb_get_value_ulong (pb, "wallpaper_type");
|
||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(PB_GET_VALUE ("wallpaper_filename"))->_value));
|
||||
if (prefs->wallpaper_filename && strcmp (prefs->wallpaper_filename, "") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
|
||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(PB_GET_VALUE ("color1"))->_value);
|
||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(PB_GET_VALUE ("color2"))->_value);
|
||||
|
||||
prefs->opacity = BONOBO_ARG_GET_LONG (PB_GET_VALUE ("opacity"));
|
||||
if (prefs->opacity != 100)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
|
||||
prefs->ref_count = 1;
|
||||
|
||||
return prefs;
|
||||
}
|
||||
|
||||
#define DB_GET_VALUE(v) (bonobo_config_get_value (db, (v), NULL, NULL))
|
||||
|
||||
static ApplierPreferences*
|
||||
applier_preferences_db_new (Bonobo_ConfigDatabase db, CORBA_Environment *ev)
|
||||
{
|
||||
ApplierPreferences *prefs = g_new0 (ApplierPreferences, 1);
|
||||
|
||||
prefs->orientation = bonobo_config_get_ulong (db, "/main/orientation", NULL);
|
||||
if (prefs->orientation != ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = TRUE;
|
||||
|
||||
prefs->wallpaper_type = bonobo_config_get_ulong (db, "/main/wallpaper_type", NULL);
|
||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(DB_GET_VALUE ("/main/wallpaper_filename"))->_value));
|
||||
if (prefs->wallpaper_filename && strcmp (prefs->wallpaper_filename, "") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
|
||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(DB_GET_VALUE ("/main/color1"))->_value);
|
||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(DB_GET_VALUE ("/main/color2"))->_value);
|
||||
|
||||
prefs->opacity = BONOBO_ARG_GET_LONG (DB_GET_VALUE ("/main/opacity"));
|
||||
if (prefs->opacity != 100)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
|
||||
prefs->ref_count = 1;
|
||||
|
||||
return prefs;
|
||||
}
|
||||
|
||||
static void
|
||||
applier_preferences_ref (ApplierPreferences *prefs)
|
||||
{
|
||||
g_return_if_fail (prefs != NULL);
|
||||
|
||||
prefs->ref_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
applier_preferences_unref (ApplierPreferences *prefs)
|
||||
{
|
||||
g_return_if_fail (prefs != NULL);
|
||||
|
||||
prefs->ref_count--;
|
||||
if (prefs->ref_count < 1)
|
||||
applier_preferences_free (prefs);
|
||||
}
|
||||
|
||||
static void
|
||||
applier_preferences_free (ApplierPreferences *prefs)
|
||||
{
|
||||
g_return_if_fail (prefs != NULL);
|
||||
|
||||
if (prefs->wallpaper_filename)
|
||||
g_free (prefs->wallpaper_filename);
|
||||
|
||||
if (prefs->color1)
|
||||
g_free (prefs->color1);
|
||||
if (prefs->color2)
|
||||
g_free (prefs->color2);
|
||||
|
||||
g_free (prefs);
|
||||
}
|
||||
|
||||
static GdkColor*
|
||||
bonobo_color_to_gdk (Bonobo_Config_Color *color)
|
||||
{
|
||||
GdkColor *ret;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
ret = g_new0 (GdkColor, 1);
|
||||
ret->red = color->r * 65535;
|
||||
ret->green = color->g * 65535;
|
||||
ret->blue = color->b * 65535;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
output_compat_prefs (ApplierPreferences *prefs)
|
||||
output_compat_prefs (Preferences *prefs)
|
||||
{
|
||||
gchar *color;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <bonobo-conf/bonobo-config-database.h>
|
||||
#include "preferences.h"
|
||||
|
||||
#define APPLIER(obj) GTK_CHECK_CAST (obj, applier_get_type (), Applier)
|
||||
#define APPLIER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, applier_get_type (), ApplierClass)
|
||||
|
@ -56,14 +56,9 @@ guint applier_get_type (void);
|
|||
GtkObject *applier_new (void);
|
||||
void applier_destroy (GtkObject *object);
|
||||
|
||||
void applier_apply_prefs (Applier *applier,
|
||||
Bonobo_PropertyBag pb,
|
||||
Bonobo_ConfigDatabase db,
|
||||
CORBA_Environment *ev,
|
||||
gboolean do_root,
|
||||
gboolean do_preview);
|
||||
void applier_apply_prefs (Applier *applier, Preferences *prefs,
|
||||
gboolean do_root, gboolean do_preview);
|
||||
|
||||
GtkWidget *applier_get_preview_widget (Applier *applier);
|
||||
void applier_destroy_preview_widget (Applier *applier);
|
||||
GtkWidget *applier_class_get_preview_widget (void);
|
||||
|
||||
#endif /* __APPLIER_H */
|
||||
|
|
|
@ -53,6 +53,7 @@ const struct poptOption options [] = {
|
|||
static void
|
||||
apply_settings (Bonobo_ConfigDatabase db)
|
||||
{
|
||||
Preferences *prefs;
|
||||
CORBA_Environment ev;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
@ -66,7 +67,10 @@ apply_settings (Bonobo_ConfigDatabase db)
|
|||
Bonobo_ConfigDatabase_sync (db, &ev);
|
||||
}
|
||||
|
||||
applier_apply_prefs (applier, CORBA_OBJECT_NIL, db, &ev, TRUE, FALSE);
|
||||
prefs = PREFERENCES (preferences_new_from_bonobo_db (db, &ev));
|
||||
applier_apply_prefs (applier, prefs, TRUE, FALSE);
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
|
@ -184,23 +188,25 @@ property_change_cb (BonoboListener *listener,
|
|||
char *event_name,
|
||||
CORBA_any *any,
|
||||
CORBA_Environment *ev,
|
||||
Applier *applier)
|
||||
Bonobo_PropertyBag pb)
|
||||
{
|
||||
Bonobo_PropertyBag pb;
|
||||
Preferences *prefs;
|
||||
|
||||
pb = gtk_object_get_data (GTK_OBJECT (applier), "property-bag");
|
||||
applier_apply_prefs (applier, pb, CORBA_OBJECT_NIL, ev, FALSE, TRUE);
|
||||
prefs = PREFERENCES (preferences_new_from_bonobo_pbag (pb, ev));
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
}
|
||||
|
||||
static void
|
||||
realize_cb (GtkWidget *widget, Applier *applier)
|
||||
realize_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||
{
|
||||
CORBA_Environment ev;
|
||||
Bonobo_PropertyBag bag;
|
||||
|
||||
Preferences *prefs;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
bag = gtk_object_get_data (GTK_OBJECT (applier), "property-bag");
|
||||
applier_apply_prefs (applier, bag, CORBA_OBJECT_NIL, &ev, FALSE, TRUE);
|
||||
prefs = PREFERENCES (preferences_new_from_bonobo_pbag (bag, &ev));
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
|
@ -215,31 +221,25 @@ realize_cb (GtkWidget *widget, Applier *applier)
|
|||
static void
|
||||
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||
{
|
||||
BonoboPEditor *ed;
|
||||
GladeXML *dialog;
|
||||
Applier *applier;
|
||||
|
||||
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
||||
ed = BONOBO_PEDITOR (bonobo_peditor_option_menu_construct (WID ("color_option")));
|
||||
bonobo_peditor_set_property (ed, bag, "orientation", TC_ulong, NULL);
|
||||
CUSTOM_CREATE_PEDITOR (option_menu, ulong, "orientation", "color_option");
|
||||
|
||||
CUSTOM_CREATE_PEDITOR (color, Bonobo_Config_Color, "color1", "colorpicker1");
|
||||
CUSTOM_CREATE_PEDITOR (color, Bonobo_Config_Color, "color2", "colorpicker2");
|
||||
CUSTOM_CREATE_PEDITOR (filename, Bonobo_Config_FileName, "wallpaper_filename", "image_fileentry");
|
||||
|
||||
ed = BONOBO_PEDITOR (bonobo_peditor_option_menu_construct (WID ("image_option")));
|
||||
bonobo_peditor_set_property (ed, bag, "wallpaper_type", TC_ulong, NULL);
|
||||
CUSTOM_CREATE_PEDITOR (option_menu, ulong, "wallpaper_type", "image_option");
|
||||
CUSTOM_CREATE_PEDITOR (int_range, long, "opacity", "opacity_spin");
|
||||
|
||||
CUSTOM_CREATE_PEDITOR (int_range, long, "opacity", "opacity_spin");
|
||||
gtk_widget_hide (WID ("opacity_spin"));
|
||||
gtk_widget_hide (WID ("opacity_label"));
|
||||
|
||||
applier = gtk_object_get_data (GTK_OBJECT (widget), "applier");
|
||||
gtk_object_set_data (GTK_OBJECT (applier), "property-bag", bag);
|
||||
bonobo_event_source_client_add_listener (bag, (BonoboListenerCallbackFn) property_change_cb,
|
||||
NULL, NULL, applier);
|
||||
bonobo_event_source_client_add_listener (bag, property_change_cb,
|
||||
NULL, NULL, bag);
|
||||
|
||||
gtk_signal_connect_after (GTK_OBJECT (applier_get_preview_widget (applier)), "realize", realize_cb, applier);
|
||||
gtk_signal_connect_after (GTK_OBJECT (applier_class_get_preview_widget ()), "realize", realize_cb, bag);
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
|
@ -254,12 +254,11 @@ create_dialog (void)
|
|||
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||
|
||||
applier = APPLIER (applier_new ());
|
||||
gtk_object_set_data (GTK_OBJECT (widget), "applier", applier);
|
||||
|
||||
/* Minor GUI addition */
|
||||
holder = WID ("preview_holder");
|
||||
gtk_box_pack_start (GTK_BOX (holder),
|
||||
applier_get_preview_widget (applier),
|
||||
applier_class_get_preview_widget (),
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show_all (holder);
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ static Applier *applier = NULL;
|
|||
static void preferences_init (Preferences *prefs);
|
||||
static void preferences_class_init (PreferencesClass *class);
|
||||
|
||||
#ifdef BONOBO_CONF_ENABLE
|
||||
#include <bonobo.h>
|
||||
#else
|
||||
static gint xml_read_int (xmlNodePtr node);
|
||||
static xmlNodePtr xml_write_int (gchar *name,
|
||||
gint number);
|
||||
|
@ -48,6 +51,7 @@ static xmlNodePtr xml_write_bool (gchar *name,
|
|||
gboolean value);
|
||||
|
||||
static gint apply_timeout_cb (Preferences *prefs);
|
||||
#endif
|
||||
|
||||
static GdkColor *read_color_from_string (gchar *string);
|
||||
|
||||
|
@ -171,6 +175,98 @@ preferences_destroy (GtkObject *object)
|
|||
parent_class->destroy (object);
|
||||
}
|
||||
|
||||
#ifdef BONOBO_CONF_ENABLE
|
||||
static GdkColor*
|
||||
bonobo_color_to_gdk (Bonobo_Config_Color *color)
|
||||
{
|
||||
GdkColor *ret;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
ret = g_new0 (GdkColor, 1);
|
||||
ret->red = color->r * 65535;
|
||||
ret->green = color->g * 65535;
|
||||
ret->blue = color->b * 65535;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gulong
|
||||
pb_get_value_ulong (Bonobo_PropertyBag bag, const gchar *prop)
|
||||
{
|
||||
BonoboArg *arg;
|
||||
gulong val;
|
||||
|
||||
arg = bonobo_property_bag_client_get_value_any (bag, prop, NULL);
|
||||
val = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_unsigned_long, NULL);
|
||||
bonobo_arg_release (arg);
|
||||
return val;
|
||||
}
|
||||
|
||||
#define PB_GET_VALUE(v) (bonobo_property_bag_client_get_value_any (pb, (v), NULL))
|
||||
|
||||
/* Probably has CORBA memory leaks */
|
||||
GtkObject*
|
||||
preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb, CORBA_Environment *ev)
|
||||
{
|
||||
Preferences *prefs;
|
||||
|
||||
g_return_val_if_fail (pb != CORBA_OBJECT_NIL, NULL);
|
||||
g_return_val_if_fail (ev != NULL, NULL);
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
|
||||
prefs->orientation = pb_get_value_ulong (pb, "orientation");
|
||||
if (prefs->orientation != ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = TRUE;
|
||||
|
||||
prefs->wallpaper_type = pb_get_value_ulong (pb, "wallpaper_type");
|
||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(PB_GET_VALUE ("wallpaper_filename"))->_value));
|
||||
if (prefs->wallpaper_filename && strcmp (prefs->wallpaper_filename, "") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
|
||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(PB_GET_VALUE ("color1"))->_value);
|
||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(PB_GET_VALUE ("color2"))->_value);
|
||||
|
||||
prefs->opacity = BONOBO_ARG_GET_LONG (PB_GET_VALUE ("opacity"));
|
||||
if (prefs->opacity != 100)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
|
||||
return GTK_OBJECT (prefs);
|
||||
}
|
||||
|
||||
#define DB_GET_VALUE(v) (bonobo_config_get_value (db, (v), NULL, NULL))
|
||||
|
||||
GtkObject*
|
||||
preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db, CORBA_Environment *ev)
|
||||
{
|
||||
Preferences *prefs;
|
||||
|
||||
g_return_val_if_fail (db != CORBA_OBJECT_NIL, NULL);
|
||||
g_return_val_if_fail (ev != NULL, NULL);
|
||||
|
||||
prefs = PREFERENCES (preferences_new ());
|
||||
|
||||
prefs->orientation = bonobo_config_get_ulong (db, "/main/orientation", NULL);
|
||||
|
||||
if (prefs->orientation != ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = TRUE;
|
||||
|
||||
prefs->wallpaper_type = bonobo_config_get_ulong (db, "/main/wallpaper_type", NULL);
|
||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(DB_GET_VALUE ("/main/wallpaper_filename"))->_value));
|
||||
if (prefs->wallpaper_filename && strcmp (prefs->wallpaper_filename, "") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
|
||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(DB_GET_VALUE ("/main/color1"))->_value);
|
||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)(DB_GET_VALUE ("/main/color2"))->_value);
|
||||
|
||||
prefs->opacity = BONOBO_ARG_GET_LONG (DB_GET_VALUE ("/main/opacity"));
|
||||
if (prefs->opacity != 100)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
|
||||
return GTK_OBJECT (prefs);
|
||||
}
|
||||
#else
|
||||
void
|
||||
preferences_load (Preferences *prefs)
|
||||
{
|
||||
|
@ -568,6 +664,7 @@ apply_timeout_cb (Preferences *prefs)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GdkColor *
|
||||
read_color_from_string (gchar *string)
|
||||
|
|
|
@ -26,7 +26,11 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef BONOBO_CONF_ENABLE
|
||||
#include <bonobo-conf/bonobo-config-database.h>
|
||||
#else
|
||||
#include <tree.h>
|
||||
#endif
|
||||
|
||||
#define PREFERENCES(obj) GTK_CHECK_CAST (obj, preferences_get_type (), Preferences)
|
||||
#define PREFERENCES_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, preferences_get_type (), PreferencesClass)
|
||||
|
@ -35,6 +39,15 @@
|
|||
typedef struct _Preferences Preferences;
|
||||
typedef struct _PreferencesClass PreferencesClass;
|
||||
|
||||
typedef enum _orientation_t {
|
||||
ORIENTATION_SOLID, ORIENTATION_HORIZ, ORIENTATION_VERT
|
||||
} orientation_t;
|
||||
|
||||
typedef enum _wallpaper_type_t {
|
||||
WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED_ASPECT,
|
||||
WPTYPE_SCALED, WPTYPE_EMBOSSED
|
||||
} wallpaper_type_t;
|
||||
|
||||
struct _Preferences
|
||||
{
|
||||
GtkObject object;
|
||||
|
@ -70,8 +83,15 @@ guint preferences_get_type (void);
|
|||
|
||||
GtkObject *preferences_new (void);
|
||||
GtkObject *preferences_clone (Preferences *prefs);
|
||||
|
||||
void preferences_destroy (GtkObject *object);
|
||||
|
||||
#ifdef BONOBO_CONF_ENABLE
|
||||
GtkObject *preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb,
|
||||
CORBA_Environment *ev);
|
||||
GtkObject *preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db,
|
||||
CORBA_Environment *ev);
|
||||
#else
|
||||
void preferences_load (Preferences *prefs);
|
||||
void preferences_save (Preferences *prefs);
|
||||
void preferences_changed (Preferences *prefs);
|
||||
|
@ -83,5 +103,6 @@ void preferences_thaw (Preferences *prefs);
|
|||
|
||||
Preferences *preferences_read_xml (xmlDocPtr xml_doc);
|
||||
xmlDocPtr preferences_write_xml (Preferences *prefs);
|
||||
#endif /* BONOBO_CONF_ENABLE */
|
||||
|
||||
#endif /* __PREFERENCES_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue