GNOME 2.0 port. Changes too numerous to mention.
This commit is contained in:
parent
ce9f91ffcf
commit
467b92037d
6 changed files with 279 additions and 683 deletions
|
@ -24,7 +24,7 @@ oaf_DATA = Bonobo_Control_Capplet_background_properties.oaf
|
|||
##
|
||||
## You should not need to modify anything below this line
|
||||
##
|
||||
@XML_I18N_MERGE_DESKTOP_RULE@
|
||||
@INTLTOOL_DESKTOP_RULE@
|
||||
|
||||
$(bin_SCRIPTS): $(top_srcdir)/capplets/common/wrapper-script.in
|
||||
sed -e "s#@BINDIR@#$(bindir)#" -e "s#@CAPPLET_NAME@#$(cappletname)-properties#" < $< > $@
|
||||
|
|
|
@ -43,11 +43,9 @@
|
|||
#define MONITOR_CONTENTS_WIDTH 157
|
||||
#define MONITOR_CONTENTS_HEIGHT 111
|
||||
|
||||
static gboolean gdk_pixbuf_xlib_inited = FALSE;
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_TYPE
|
||||
PROP_0,
|
||||
PROP_TYPE
|
||||
};
|
||||
|
||||
struct _ApplierPrivate
|
||||
|
@ -107,20 +105,24 @@ struct _ApplierPrivate
|
|||
* pixmap */
|
||||
};
|
||||
|
||||
static GtkObjectClass *parent_class;
|
||||
static GObjectClass *parent_class;
|
||||
|
||||
static void applier_init (Applier *prefs);
|
||||
static void applier_class_init (ApplierClass *class);
|
||||
static void applier_init (Applier *prefs,
|
||||
ApplierClass *class);
|
||||
static void applier_class_init (ApplierClass *class);
|
||||
static void applier_base_init (ApplierClass *class);
|
||||
|
||||
static void applier_set_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void applier_get_arg (GtkObject *object,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void applier_set_prop (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void applier_get_prop (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void applier_destroy (GtkObject *object);
|
||||
static void applier_finalize (GtkObject *object);
|
||||
static void applier_dispose (GObject *object);
|
||||
static void applier_finalize (GObject *object);
|
||||
|
||||
static void run_render_pipeline (Applier *applier,
|
||||
const Preferences *prefs);
|
||||
|
@ -177,26 +179,30 @@ applier_get_type (void)
|
|||
static guint applier_type = 0;
|
||||
|
||||
if (!applier_type) {
|
||||
GtkTypeInfo applier_info = {
|
||||
"Applier",
|
||||
sizeof (Applier),
|
||||
static GTypeInfo applier_info = {
|
||||
sizeof (ApplierClass),
|
||||
(GtkClassInitFunc) applier_class_init,
|
||||
(GtkObjectInitFunc) applier_init,
|
||||
(GtkArgSetFunc) NULL,
|
||||
(GtkArgGetFunc) NULL
|
||||
(GBaseInitFunc) applier_base_init,
|
||||
NULL, /* GBaseFinalizeFunc */
|
||||
(GClassInitFunc) applier_class_init,
|
||||
NULL, /* GClassFinalizeFunc */
|
||||
NULL, /* user-supplied data */
|
||||
sizeof (Applier),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) applier_init,
|
||||
NULL
|
||||
};
|
||||
|
||||
applier_type =
|
||||
gtk_type_unique (gtk_object_get_type (),
|
||||
&applier_info);
|
||||
g_type_register_static (G_TYPE_OBJECT,
|
||||
"Applier",
|
||||
&applier_info, 0);
|
||||
}
|
||||
|
||||
return applier_type;
|
||||
}
|
||||
|
||||
static void
|
||||
applier_init (Applier *applier)
|
||||
applier_init (Applier *applier, ApplierClass *class)
|
||||
{
|
||||
applier->p = g_new0 (ApplierPrivate, 1);
|
||||
applier->p->last_prefs = NULL;
|
||||
|
@ -208,34 +214,34 @@ applier_init (Applier *applier)
|
|||
static void
|
||||
applier_class_init (ApplierClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GObjectClass *object_class;
|
||||
GdkVisual *visual;
|
||||
|
||||
gtk_object_add_arg_type ("Applier::type",
|
||||
GTK_TYPE_POINTER,
|
||||
GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT_ONLY,
|
||||
ARG_TYPE);
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TYPE,
|
||||
g_param_spec_int ("type",
|
||||
_("Type"),
|
||||
_("Type of applier: APPLIER_ROOT for root window or APPLIER_PREVIEW for preview"),
|
||||
0, 1, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (class);
|
||||
object_class->destroy = applier_destroy;
|
||||
object_class = G_OBJECT_CLASS (class);
|
||||
object_class->dispose = applier_dispose;
|
||||
object_class->finalize = applier_finalize;
|
||||
object_class->set_arg = applier_set_arg;
|
||||
object_class->get_arg = applier_get_arg;
|
||||
object_class->set_property = applier_set_prop;
|
||||
object_class->get_property = applier_get_prop;
|
||||
|
||||
parent_class =
|
||||
GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ()));
|
||||
|
||||
if (!gdk_pixbuf_xlib_inited) {
|
||||
gdk_pixbuf_xlib_inited = TRUE;
|
||||
|
||||
visual = gdk_window_get_visual (GDK_ROOT_PARENT ());
|
||||
|
||||
gdk_pixbuf_xlib_init_with_depth (GDK_DISPLAY (), gdk_screen, visual->depth);
|
||||
}
|
||||
G_OBJECT_CLASS (g_type_class_ref (G_TYPE_OBJECT));
|
||||
}
|
||||
|
||||
static void
|
||||
applier_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
applier_base_init (ApplierClass *class)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
applier_set_prop (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
Applier *applier;
|
||||
|
||||
|
@ -244,9 +250,9 @@ applier_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
|||
|
||||
applier = APPLIER (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_TYPE:
|
||||
applier->p->type = GTK_VALUE_INT (*arg);
|
||||
switch (prop_id) {
|
||||
case PROP_TYPE:
|
||||
applier->p->type = g_value_get_int (value);
|
||||
|
||||
switch (applier->p->type) {
|
||||
case APPLIER_ROOT:
|
||||
|
@ -273,13 +279,13 @@ applier_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
|||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Bad argument set");
|
||||
g_warning ("Bad property set");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
applier_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
applier_get_prop (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
Applier *applier;
|
||||
|
||||
|
@ -288,19 +294,19 @@ applier_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
|||
|
||||
applier = APPLIER (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_TYPE:
|
||||
GTK_VALUE_INT (*arg) = applier->p->type;
|
||||
switch (prop_id) {
|
||||
case PROP_TYPE:
|
||||
g_value_set_int (value, applier->p->type);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Bad argument get");
|
||||
g_warning ("Bad property get");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
applier_destroy (GtkObject *object)
|
||||
applier_dispose (GObject *object)
|
||||
{
|
||||
Applier *applier;
|
||||
|
||||
|
@ -312,16 +318,16 @@ applier_destroy (GtkObject *object)
|
|||
g_assert (applier->p->pixbuf == NULL);
|
||||
|
||||
if (applier->p->last_prefs != NULL)
|
||||
gtk_object_destroy (GTK_OBJECT (applier->p->last_prefs));
|
||||
g_object_unref (G_OBJECT (applier->p->last_prefs));
|
||||
|
||||
if (applier->p->wallpaper_pixbuf != NULL)
|
||||
gdk_pixbuf_unref (applier->p->wallpaper_pixbuf);
|
||||
|
||||
parent_class->destroy (object);
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
applier_finalize (GtkObject *object)
|
||||
applier_finalize (GObject *object)
|
||||
{
|
||||
Applier *applier;
|
||||
|
||||
|
@ -335,14 +341,14 @@ applier_finalize (GtkObject *object)
|
|||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
GtkObject *
|
||||
GObject *
|
||||
applier_new (ApplierType type)
|
||||
{
|
||||
GtkObject *object;
|
||||
GObject *object;
|
||||
|
||||
object = gtk_object_new (applier_get_type (),
|
||||
"type", type,
|
||||
NULL);
|
||||
object = g_object_new (applier_get_type (),
|
||||
"type", type,
|
||||
NULL);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -373,7 +379,7 @@ applier_apply_prefs (Applier *applier,
|
|||
g_return_if_fail (prefs->wallpaper_filename != NULL);
|
||||
|
||||
applier->p->wallpaper_pixbuf =
|
||||
gdk_pixbuf_new_from_file (prefs->wallpaper_filename);
|
||||
gdk_pixbuf_new_from_file (prefs->wallpaper_filename, NULL);
|
||||
|
||||
if (applier->p->wallpaper_pixbuf == NULL)
|
||||
g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."),
|
||||
|
@ -393,8 +399,6 @@ applier_apply_prefs (Applier *applier,
|
|||
|
||||
if (applier->p->type == APPLIER_PREVIEW && applier->p->preview_widget != NULL)
|
||||
gtk_widget_queue_draw (applier->p->preview_widget);
|
||||
else if (applier->p->type == APPLIER_ROOT)
|
||||
preferences_save (prefs);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -412,11 +416,10 @@ GtkWidget *
|
|||
applier_get_preview_widget (Applier *applier)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap *pixmap, *pixmap1;
|
||||
GdkBitmap *mask;
|
||||
GdkVisual *visual;
|
||||
GdkColormap *colormap;
|
||||
Pixmap xpixmap, xmask;
|
||||
gchar *filename;
|
||||
GdkGC *gc;
|
||||
|
||||
|
@ -436,55 +439,22 @@ applier_get_preview_widget (Applier *applier)
|
|||
gtk_widget_push_visual (visual);
|
||||
gtk_widget_push_colormap (colormap);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename);
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
||||
|
||||
if (pixbuf == NULL) return NULL;
|
||||
|
||||
gdk_pixbuf_xlib_render_pixmap_and_mask (pixbuf, &xpixmap, &xmask, 1);
|
||||
pixmap = gdk_pixmap_new (GDK_ROOT_PARENT (),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
visual->depth);
|
||||
|
||||
if (xpixmap) {
|
||||
pixmap = gdk_pixmap_new (GDK_ROOT_PARENT (),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
visual->depth);
|
||||
|
||||
gc = gdk_gc_new (GDK_ROOT_PARENT ());
|
||||
|
||||
XCopyArea (GDK_DISPLAY (), xpixmap,
|
||||
GDK_WINDOW_XWINDOW (pixmap),
|
||||
GDK_GC_XGC (gc), 0, 0,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
0, 0);
|
||||
|
||||
XFreePixmap (GDK_DISPLAY (), xpixmap);
|
||||
|
||||
gdk_gc_destroy (gc);
|
||||
} else {
|
||||
pixmap = NULL;
|
||||
}
|
||||
|
||||
if (xmask) {
|
||||
mask = gdk_pixmap_new (GDK_ROOT_PARENT (),
|
||||
gdk_pixbuf_render_to_drawable (pixbuf, pixmap, gc,
|
||||
0, 0, 0, 0,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
1);
|
||||
GDK_RGB_DITHER_MAX, 0, 0);
|
||||
|
||||
gc = gdk_gc_new (mask);
|
||||
|
||||
XCopyArea (GDK_DISPLAY (), xmask,
|
||||
GDK_WINDOW_XWINDOW (mask),
|
||||
GDK_GC_XGC (gc), 0, 0,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
0, 0);
|
||||
|
||||
XFreePixmap (GDK_DISPLAY (), xmask);
|
||||
|
||||
gdk_gc_destroy (gc);
|
||||
} else {
|
||||
mask = NULL;
|
||||
}
|
||||
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap1, &mask, 0);
|
||||
|
||||
applier->p->preview_widget = gtk_pixmap_new (pixmap, mask);
|
||||
gtk_widget_show (applier->p->preview_widget);
|
||||
|
@ -494,6 +464,8 @@ applier_get_preview_widget (Applier *applier)
|
|||
gtk_widget_pop_visual ();
|
||||
gtk_widget_pop_colormap ();
|
||||
|
||||
gdk_pixmap_unref (pixmap1);
|
||||
|
||||
return applier->p->preview_widget;
|
||||
}
|
||||
|
||||
|
@ -509,13 +481,14 @@ applier_get_wallpaper_pixbuf (Applier *applier)
|
|||
static void
|
||||
draw_disabled_message (GtkWidget *widget)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor color;
|
||||
GdkFont *font;
|
||||
GdkGC *gc;
|
||||
gint x, y, w, h;
|
||||
gint height, width;
|
||||
const char *disabled_string = _("Disabled");
|
||||
GdkPixmap *pixmap;
|
||||
GdkColor color;
|
||||
PangoLayout *layout;
|
||||
PangoRectangle extents;
|
||||
GdkGC *gc;
|
||||
gint x, y, w, h;
|
||||
gint height, width;
|
||||
const char *disabled_string = _("Disabled");
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_PIXMAP (widget));
|
||||
|
@ -536,19 +509,20 @@ draw_disabled_message (GtkWidget *widget)
|
|||
gdk_gc_set_foreground (gc, &color);
|
||||
gdk_draw_rectangle (pixmap, gc, TRUE, x, y, w, h);
|
||||
|
||||
font = widget->style->font;
|
||||
width = gdk_string_width (font, disabled_string);
|
||||
height = gdk_string_height (font, disabled_string);
|
||||
layout = gtk_widget_create_pango_layout (widget, disabled_string);
|
||||
pango_layout_get_pixel_extents (layout, &extents, NULL);
|
||||
|
||||
gdk_color_white (gtk_widget_get_colormap (widget), &color);
|
||||
gdk_gc_set_foreground (gc, &color);
|
||||
gdk_draw_string (pixmap, font, gc,
|
||||
x + (w - width) / 2, y + (h - height) / 2 +
|
||||
height / 2,
|
||||
disabled_string);
|
||||
|
||||
gdk_draw_layout (widget->window,
|
||||
gc,
|
||||
x + (w - extents.width) / 2,
|
||||
y + (h - extents.height) / 2 + extents.height / 2,
|
||||
layout);
|
||||
|
||||
gdk_gc_unref (gc);
|
||||
gtk_widget_queue_draw (widget);
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1300,7 +1274,7 @@ make_root_pixmap (gint width, gint height)
|
|||
Display *display;
|
||||
Pixmap xpixmap;
|
||||
|
||||
display = XOpenDisplay (gdk_display_name);
|
||||
display = XOpenDisplay (g_getenv ("DISPLAY"));
|
||||
XSetCloseDownMode (display, RetainPermanent);
|
||||
|
||||
xpixmap = XCreatePixmap (display,
|
||||
|
@ -1323,7 +1297,7 @@ make_root_pixmap (gint width, gint height)
|
|||
static void
|
||||
set_root_pixmap (GdkPixmap *pixmap)
|
||||
{
|
||||
GdkAtom type;
|
||||
Atom type;
|
||||
gulong nitems, bytes_after;
|
||||
gint format;
|
||||
guchar *data_esetroot;
|
||||
|
@ -1334,7 +1308,7 @@ set_root_pixmap (GdkPixmap *pixmap)
|
|||
XGrabServer (GDK_DISPLAY ());
|
||||
|
||||
XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
gdk_atom_intern ("ESETROOT_PMAP_ID", FALSE),
|
||||
XInternAtom (GDK_DISPLAY (), "ESETROOT_PMAP_ID", False),
|
||||
0L, 1L, False, XA_PIXMAP,
|
||||
&type, &format, &nitems, &bytes_after,
|
||||
&data_esetroot);
|
||||
|
@ -1356,11 +1330,11 @@ set_root_pixmap (GdkPixmap *pixmap)
|
|||
|
||||
if (pixmap != NULL && pixmap != (GdkPixmap *) -1) {
|
||||
XChangeProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
gdk_atom_intern ("ESETROOT_PMAP_ID", FALSE),
|
||||
XInternAtom (GDK_DISPLAY (), "ESETROOT_PMAP_ID", FALSE),
|
||||
XA_PIXMAP, 32, PropModeReplace,
|
||||
(guchar *) &pixmap_id, 1);
|
||||
XChangeProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
gdk_atom_intern ("_XROOTPMAP_ID", FALSE),
|
||||
XInternAtom (GDK_DISPLAY (), "_XROOTPMAP_ID", FALSE),
|
||||
XA_PIXMAP, 32, PropModeReplace,
|
||||
(guchar *) &pixmap_id, 1);
|
||||
|
||||
|
@ -1368,9 +1342,9 @@ set_root_pixmap (GdkPixmap *pixmap)
|
|||
pixmap_id);
|
||||
} else if (pixmap == NULL) {
|
||||
XDeleteProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
gdk_atom_intern ("ESETROOT_PMAP_ID", FALSE));
|
||||
XInternAtom (GDK_DISPLAY (), "ESETROOT_PMAP_ID", FALSE));
|
||||
XDeleteProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
gdk_atom_intern ("_XROOTPMAP_ID", FALSE));
|
||||
XInternAtom (GDK_DISPLAY (), "_XROOTPMAP_ID", FALSE));
|
||||
}
|
||||
|
||||
XClearWindow (GDK_DISPLAY (), GDK_ROOT_WINDOW ());
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
|
||||
#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)
|
||||
#define IS_APPLIER(obj) GTK_CHECK_TYPE (obj, applier_get_type ())
|
||||
#define APPLIER(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, applier_get_type (), Applier)
|
||||
#define APPLIER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, applier_get_type (), ApplierClass)
|
||||
#define IS_APPLIER(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, applier_get_type ())
|
||||
|
||||
typedef struct _Applier Applier;
|
||||
typedef struct _ApplierClass ApplierClass;
|
||||
|
@ -47,18 +47,18 @@ typedef enum _ApplierType {
|
|||
|
||||
struct _Applier
|
||||
{
|
||||
GtkObject object;
|
||||
GObject object;
|
||||
ApplierPrivate *p;
|
||||
};
|
||||
|
||||
struct _ApplierClass
|
||||
{
|
||||
GtkObjectClass klass;
|
||||
GObjectClass klass;
|
||||
};
|
||||
|
||||
guint applier_get_type (void);
|
||||
|
||||
GtkObject *applier_new (ApplierType type);
|
||||
GObject *applier_new (ApplierType type);
|
||||
|
||||
void applier_apply_prefs (Applier *applier,
|
||||
const Preferences *prefs);
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
/* main.c
|
||||
* Copyright (C) 2000-2001 Ximian, Inc.
|
||||
*
|
||||
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
||||
* Written by: Bradford Hovinen <hovinen@ximian.com>,
|
||||
* Richard Hestilow <hestilow@ximian.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
|
@ -27,200 +28,111 @@
|
|||
|
||||
#include <gnome.h>
|
||||
#include <bonobo.h>
|
||||
#include <bonobo/bonobo-property-bag-client.h>
|
||||
#include <gconf/gconf.h>
|
||||
#include <glade/glade.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
#include "capplet-util.h"
|
||||
#include "gconf-property-editor.h"
|
||||
#include "applier.h"
|
||||
|
||||
static void
|
||||
bonobo_config_set_filename (Bonobo_ConfigDatabase db,
|
||||
const char *key,
|
||||
const char *value,
|
||||
CORBA_Environment *opt_ev);
|
||||
|
||||
/* Popt option for compat reasons */
|
||||
static gchar *background_image = NULL;
|
||||
|
||||
const struct poptOption options [] = {
|
||||
{ "background-image", 'b', POPT_ARG_STRING, &background_image, 0,
|
||||
N_("Set background image."), N_("IMAGE-FILE") },
|
||||
{NULL, '\0', 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
apply_settings (Bonobo_ConfigDatabase db)
|
||||
apply_settings ()
|
||||
{
|
||||
GtkObject *prefs;
|
||||
GObject *prefs;
|
||||
Applier *applier;
|
||||
CORBA_Environment ev;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
applier = APPLIER (applier_new (APPLIER_ROOT));
|
||||
|
||||
/* Hackity hackty */
|
||||
if (background_image != NULL) {
|
||||
bonobo_config_set_filename (db, "/main/wallpaper_filename", background_image, NULL);
|
||||
Bonobo_ConfigDatabase_sync (db, &ev);
|
||||
}
|
||||
prefs = preferences_new ();
|
||||
preferences_load (PREFERENCES (prefs));
|
||||
|
||||
prefs = preferences_new_from_bonobo_db (db, &ev);
|
||||
applier_apply_prefs (applier, PREFERENCES (prefs));
|
||||
g_object_unref (G_OBJECT (prefs));
|
||||
|
||||
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));
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
}
|
||||
|
||||
gtk_object_destroy (GTK_OBJECT (applier));
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
static CORBA_any*
|
||||
gdk_color_to_bonobo (const gchar *colorstr)
|
||||
{
|
||||
GdkColor tmp;
|
||||
CORBA_Environment ev;
|
||||
DynamicAny_DynAny dyn;
|
||||
CORBA_any *any;
|
||||
|
||||
g_return_val_if_fail (colorstr != NULL, NULL);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
gdk_color_parse (colorstr, &tmp);
|
||||
|
||||
dyn = CORBA_ORB_create_dyn_struct (bonobo_orb (),
|
||||
TC_Bonobo_Config_Color, &ev);
|
||||
|
||||
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.red)/65535, &ev);
|
||||
DynamicAny_DynAny_next (dyn, &ev);
|
||||
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.green)/65535, &ev);
|
||||
DynamicAny_DynAny_next (dyn, &ev);
|
||||
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.blue)/65535, &ev);
|
||||
DynamicAny_DynAny_next (dyn, &ev);
|
||||
DynamicAny_DynAny_insert_double (dyn, 0, &ev);
|
||||
|
||||
any = DynamicAny_DynAny_to_any (dyn, &ev);
|
||||
|
||||
CORBA_Object_release ((CORBA_Object) dyn, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return any;
|
||||
g_object_unref (G_OBJECT (applier));
|
||||
}
|
||||
|
||||
static void
|
||||
copy_color_from_legacy (Bonobo_ConfigDatabase db,
|
||||
const gchar *key, const gchar *legacy_key)
|
||||
get_legacy_settings (void)
|
||||
{
|
||||
int val_int;
|
||||
char *val_string;
|
||||
gboolean val_boolean;
|
||||
gboolean def;
|
||||
gchar *val_string;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
g_return_if_fail (legacy_key != NULL);
|
||||
gchar *val_filename;
|
||||
|
||||
val_string = gnome_config_get_string_with_default (legacy_key, &def);
|
||||
|
||||
if (!def)
|
||||
{
|
||||
CORBA_any *color = gdk_color_to_bonobo (val_string);
|
||||
bonobo_config_set_value (db, key, color, NULL);
|
||||
bonobo_arg_release (color);
|
||||
}
|
||||
|
||||
g_free (val_string);
|
||||
}
|
||||
|
||||
static void
|
||||
bonobo_config_set_filename (Bonobo_ConfigDatabase db,
|
||||
const char *key,
|
||||
const char *value,
|
||||
CORBA_Environment *opt_ev)
|
||||
{
|
||||
CORBA_any *any;
|
||||
|
||||
any = bonobo_arg_new (TC_Bonobo_Config_FileName);
|
||||
*((CORBA_char **)(any->_value)) = CORBA_string_dup ((value)?(value):"");
|
||||
bonobo_config_set_value (db, key, any, opt_ev);
|
||||
bonobo_arg_release (any);
|
||||
}
|
||||
|
||||
static void
|
||||
get_legacy_settings (Bonobo_ConfigDatabase db)
|
||||
{
|
||||
gboolean val_boolean, def;
|
||||
gchar *val_string, *val_filename;
|
||||
int val_ulong = -1, val_long = -1;
|
||||
GConfEngine *engine;
|
||||
|
||||
static const int wallpaper_types[] = { 0, 1, 3, 2 };
|
||||
|
||||
COPY_FROM_LEGACY (boolean, "/main/enabled", bool, "/Background/Default/Enabled=true");
|
||||
COPY_FROM_LEGACY (filename, "/main/wallpaper_filename", string, "/Background/Default/wallpaper=(none)");
|
||||
engine = gconf_engine_get_default ();
|
||||
|
||||
gconf_engine_set_bool (engine, "/background-properties/enabled",
|
||||
gnome_config_get_bool ("/Background/Default/Enabled=true"), NULL);
|
||||
|
||||
val_filename = gnome_config_get_string ("/Background/Default/wallpaper=(none)");
|
||||
gconf_engine_set_string (engine, "/background-properties/wallpaper-filename",
|
||||
val_filename, NULL);
|
||||
|
||||
if (val_filename != NULL && strcmp (val_filename, "(none)"))
|
||||
bonobo_config_set_boolean (db, "/main/wallpaper_enabled", TRUE, NULL);
|
||||
gconf_engine_set_bool (engine, "/background-properties/wallpaper-enabled", TRUE, NULL);
|
||||
else
|
||||
bonobo_config_set_boolean (db, "/main/wallpaper_enabled", FALSE, NULL);
|
||||
gconf_engine_set_bool (engine, "/background-properties/wallpaper-enabled", FALSE, NULL);
|
||||
|
||||
val_ulong = gnome_config_get_int ("/Background/Default/wallpaperAlign=0");
|
||||
bonobo_config_set_ulong (db, "/main/wallpaper_type", wallpaper_types[val_ulong], NULL);
|
||||
g_free (val_filename);
|
||||
|
||||
copy_color_from_legacy (db, "/main/color1", "/Background/Default/color1");
|
||||
copy_color_from_legacy (db, "/main/color2", "/Background/Default/color2");
|
||||
gconf_engine_set_int (engine, "/background-properties/wallpaper-type",
|
||||
gnome_config_get_int ("/Background/Default/wallpaperAlign=0"), NULL);
|
||||
|
||||
gconf_engine_set_string (engine, "/background-properties/color1",
|
||||
gnome_config_get_string ("/Background/Default/color1"), NULL);
|
||||
gconf_engine_set_string (engine, "/background-properties/color2",
|
||||
gnome_config_get_string ("/Background/Default/color2"), NULL);
|
||||
|
||||
/* Code to deal with new enum - messy */
|
||||
val_ulong = -1;
|
||||
val_int = -1;
|
||||
val_string = gnome_config_get_string_with_default ("/Background/Default/simple=solid", &def);
|
||||
if (!def) {
|
||||
if (!strcmp (val_string, "solid")) {
|
||||
val_ulong = ORIENTATION_SOLID;
|
||||
val_int = ORIENTATION_SOLID;
|
||||
} else {
|
||||
g_free (val_string);
|
||||
val_string = gnome_config_get_string_with_default ("/Background/Default/gradient=vertical", &def);
|
||||
if (!def)
|
||||
val_ulong = (!strcmp (val_string, "vertical")) ? ORIENTATION_VERT : ORIENTATION_HORIZ;
|
||||
val_int = (!strcmp (val_string, "vertical")) ? ORIENTATION_VERT : ORIENTATION_HORIZ;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (val_string);
|
||||
|
||||
if (val_ulong != -1)
|
||||
bonobo_config_set_ulong (db, "/main/orientation", val_ulong, NULL);
|
||||
if (val_int != -1)
|
||||
gconf_engine_set_int (engine, "/background-properties/orientation", val_int, NULL);
|
||||
|
||||
val_boolean = gnome_config_get_bool_with_default ("/Background/Default/adjustOpacity=true", &def);
|
||||
|
||||
if (!def && val_boolean)
|
||||
COPY_FROM_LEGACY (long, "/main/opacity", int, "/Background/Default/opacity=100");
|
||||
gconf_engine_set_int (engine, "/background-properties/opacity",
|
||||
gnome_config_get_int ("/Background/Default/opacity=100"), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
property_change_cb (BonoboListener *listener,
|
||||
char *event_name,
|
||||
CORBA_any *any,
|
||||
CORBA_Environment *ev,
|
||||
Preferences *prefs)
|
||||
property_change_cb (GConfEngine *engine,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
Applier *applier)
|
||||
{
|
||||
GladeXML *dialog;
|
||||
Applier *applier;
|
||||
Preferences *prefs;
|
||||
|
||||
/* FIXME: How do we get the preferences? */
|
||||
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
dialog = g_object_get_data (G_OBJECT (prefs), "glade-data");
|
||||
|
||||
if (GTK_OBJECT_DESTROYED (prefs))
|
||||
return;
|
||||
|
||||
dialog = gtk_object_get_data (GTK_OBJECT (prefs), "glade-data");
|
||||
|
||||
preferences_apply_event (prefs, event_name, any);
|
||||
applier = gtk_object_get_data (GTK_OBJECT (WID ("prefs_widget")), "applier");
|
||||
preferences_merge_entry (prefs, entry);
|
||||
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"))
|
||||
if (!strcmp (entry->key, "/background-properties/wallpaper_type")
|
||||
|| !strcmp (entry->key, "/background-properties/wallpaper_filename")
|
||||
|| !strcmp (entry->key, "/background-properties/wallpaper_enabled"))
|
||||
gtk_widget_set_sensitive
|
||||
(WID ("color_frame"), applier_render_color_p (applier, prefs));
|
||||
}
|
||||
|
@ -234,11 +146,11 @@ real_realize_cb (Preferences *prefs)
|
|||
g_return_val_if_fail (prefs != NULL, TRUE);
|
||||
g_return_val_if_fail (IS_PREFERENCES (prefs), TRUE);
|
||||
|
||||
if (GTK_OBJECT_DESTROYED (prefs))
|
||||
if (G_OBJECT (prefs)->ref_count == 0)
|
||||
return FALSE;
|
||||
|
||||
dialog = gtk_object_get_data (GTK_OBJECT (prefs), "glade-data");
|
||||
applier = gtk_object_get_data (GTK_OBJECT (WID ("prefs_widget")), "applier");
|
||||
dialog = g_object_get_data (G_OBJECT (prefs), "glade-data");
|
||||
applier = g_object_get_data (G_OBJECT (WID ("prefs_widget")), "applier");
|
||||
|
||||
applier_apply_prefs (applier, prefs);
|
||||
|
||||
|
@ -260,65 +172,56 @@ realize_cb (GtkWidget *widget, Preferences *prefs)
|
|||
gtk_timeout_add (100, (GtkFunction) realize_2_cb, prefs);
|
||||
}
|
||||
|
||||
#define CUSTOM_CREATE_PEDITOR(type, corba_type, key, widget) \
|
||||
{ \
|
||||
BonoboPEditor *ed = BONOBO_PEDITOR \
|
||||
(bonobo_peditor_##type##_construct (WID (widget))); \
|
||||
bonobo_peditor_set_property (ed, bag, key, TC_##corba_type, NULL); \
|
||||
}
|
||||
|
||||
static void
|
||||
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||
setup_dialog (GtkWidget *widget, GConfChangeSet *changeset)
|
||||
{
|
||||
GladeXML *dialog;
|
||||
Applier *applier;
|
||||
GtkObject *prefs;
|
||||
GObject *prefs;
|
||||
GConfEngine *engine;
|
||||
GObject *peditor;
|
||||
|
||||
CORBA_Environment ev;
|
||||
dialog = g_object_get_data (G_OBJECT (widget), "glade-data");
|
||||
peditor = gconf_peditor_new_select_menu (changeset, "/background-properties/orientation", WID ("color_option"));
|
||||
peditor = gconf_peditor_new_color (changeset, "/background-properties/color1", WID ("colorpicker1"));
|
||||
peditor = gconf_peditor_new_color (changeset, "/background-properties/color2", WID ("colorpicker2"));
|
||||
peditor = gconf_peditor_new_filename (changeset, "/background-properties/wallpaper-filename", WID ("image_fileentry"));
|
||||
peditor = gconf_peditor_new_select_menu (changeset, "/background-properties/wallpaper-type", WID ("image_option"));
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
#if 0
|
||||
gconf_peditor_new_int_spin (changeset, "/background-properties/opacity", WID ("opacity_spin"));
|
||||
#endif
|
||||
|
||||
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
||||
CUSTOM_CREATE_PEDITOR (option_menu, ulong, "orientation", "color_option");
|
||||
peditor = gconf_peditor_new_boolean
|
||||
(changeset, "/background-properties/wallpaper-enabled", WID ("picture_enabled_check"));
|
||||
|
||||
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");
|
||||
|
||||
CUSTOM_CREATE_PEDITOR (option_menu, ulong, "wallpaper_type", "image_option");
|
||||
CUSTOM_CREATE_PEDITOR (int_range, long, "opacity", "opacity_spin");
|
||||
|
||||
CREATE_PEDITOR (boolean, "wallpaper_enabled", "picture_enabled_check");
|
||||
|
||||
bonobo_peditor_set_guard (WID ("picture_frame"), bag, "wallpaper_enabled");
|
||||
|
||||
#if 0
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("picture_frame"),
|
||||
"/background-properties/wallpaper-enabled");
|
||||
#endif
|
||||
|
||||
/* Disable opacity controls */
|
||||
gtk_widget_hide (WID ("opacity_spin"));
|
||||
gtk_widget_hide (WID ("opacity_label"));
|
||||
|
||||
bonobo_property_bag_client_set_value_gboolean (bag, "enabled", TRUE, NULL);
|
||||
engine = gconf_engine_get_default ();
|
||||
gconf_engine_set_bool (engine, "enabled", TRUE, NULL);
|
||||
|
||||
prefs = preferences_new_from_bonobo_pbag (bag, &ev);
|
||||
prefs = preferences_new ();
|
||||
preferences_load (PREFERENCES (prefs));
|
||||
|
||||
if (BONOBO_EX (&ev) || prefs == NULL)
|
||||
g_error ("Could not retrieve configuration from property bag (%s)", ev._repo_id);
|
||||
g_object_set_data (prefs, "glade-data", dialog);
|
||||
|
||||
gtk_object_set_data (prefs, "glade-data", dialog);
|
||||
|
||||
bonobo_event_source_client_add_listener (bag, (BonoboListenerCallbackFn) property_change_cb,
|
||||
NULL, NULL, prefs);
|
||||
|
||||
applier = gtk_object_get_data (GTK_OBJECT (widget), "applier");
|
||||
applier = g_object_get_data (G_OBJECT (widget), "applier");
|
||||
|
||||
if (GTK_WIDGET_REALIZED (applier_get_preview_widget (applier)))
|
||||
applier_apply_prefs (applier, PREFERENCES (prefs));
|
||||
else
|
||||
gtk_signal_connect_after (GTK_OBJECT (applier_get_preview_widget (applier)), "realize", realize_cb, prefs);
|
||||
g_signal_connect_after (G_OBJECT (applier_get_preview_widget (applier)), "realize",
|
||||
(GCallback) realize_cb, prefs);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_object_destroy), prefs);
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
g_signal_connect_swapped (G_OBJECT (widget), "destroy",
|
||||
(GCallback) g_object_unref, prefs);
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
|
@ -329,20 +232,21 @@ create_dialog (void)
|
|||
GladeXML *dialog;
|
||||
Applier *applier;
|
||||
|
||||
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/background-properties.glade", "prefs_widget");
|
||||
/* FIXME: What the hell is domain? */
|
||||
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/background-properties.glade", "prefs_widget", NULL);
|
||||
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||
g_object_set_data (G_OBJECT (widget), "glade-data", dialog);
|
||||
|
||||
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));
|
||||
g_object_set_data (G_OBJECT (widget), "applier", applier);
|
||||
g_signal_connect_swapped (G_OBJECT (widget), "destroy", (GCallback) g_object_unref, G_OBJECT (applier));
|
||||
|
||||
/* Minor GUI addition */
|
||||
holder = WID ("preview_holder");
|
||||
gtk_box_pack_start (GTK_BOX (holder), applier_get_preview_widget (applier), TRUE, TRUE, 0);
|
||||
gtk_widget_show_all (holder);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy", GTK_SIGNAL_FUNC (gtk_object_destroy), GTK_OBJECT (dialog));
|
||||
g_signal_connect_swapped (G_OBJECT (widget), "destroy", (GCallback) g_object_unref, G_OBJECT (dialog));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
@ -350,12 +254,9 @@ create_dialog (void)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const gchar* legacy_files[] = { "Background", NULL };
|
||||
glade_init ();
|
||||
|
||||
glade_gnome_init ();
|
||||
gnomelib_register_popt_table (options, "background options");
|
||||
|
||||
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
||||
capplet_init (argc, argv, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -28,89 +28,47 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <gnome.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
|
||||
#include <bonobo.h>
|
||||
|
||||
#include "preferences.h"
|
||||
|
||||
/* Note that there is a really bad bug in Bonobo */
|
||||
static GObjectClass *parent_class;
|
||||
|
||||
#undef BONOBO_RET_EX
|
||||
#define BONOBO_RET_EX(ev) \
|
||||
G_STMT_START{ \
|
||||
if (BONOBO_EX (ev)) \
|
||||
return; \
|
||||
}G_STMT_END
|
||||
|
||||
/* Copied from bonobo-conf bonobo-config-database.c
|
||||
*
|
||||
* Note to Dietmar: You should include these functions in
|
||||
* bonobo-config-database.c
|
||||
*/
|
||||
|
||||
#define MAKE_GET_SIMPLE(c_type, default, name, corba_tc, extract_fn) \
|
||||
static c_type local_bonobo_config_get_##name (Bonobo_ConfigDatabase db, \
|
||||
const char *key, \
|
||||
CORBA_Environment *opt_ev) \
|
||||
{ \
|
||||
CORBA_any *value; \
|
||||
c_type retval; \
|
||||
if (!(value = bonobo_config_get_value (db, key, corba_tc, opt_ev))) \
|
||||
return default; \
|
||||
retval = extract_fn; \
|
||||
CORBA_free (value); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
static GtkObjectClass *parent_class;
|
||||
|
||||
static void preferences_init (Preferences *prefs);
|
||||
static void preferences_init (Preferences *prefs,
|
||||
PreferencesClass *class);
|
||||
static void preferences_class_init (PreferencesClass *class);
|
||||
|
||||
static void preferences_destroy (GtkObject *object);
|
||||
static void preferences_finalize (GObject *object);
|
||||
|
||||
static GdkColor *read_color_from_string (const gchar *string);
|
||||
static GdkColor *bonobo_color_to_gdk (const Bonobo_Config_Color *color);
|
||||
|
||||
static gulong local_bonobo_property_bag_client_get_value_gulong (Bonobo_PropertyBag pb,
|
||||
const gchar *propname,
|
||||
CORBA_Environment *ev);
|
||||
static GdkColor *local_bonobo_property_bag_client_get_value_color (Bonobo_PropertyBag pb,
|
||||
const gchar *propname,
|
||||
CORBA_Environment *ev);
|
||||
static gchar *local_bonobo_property_bag_client_get_value_filename (Bonobo_PropertyBag pb,
|
||||
const gchar *propname,
|
||||
CORBA_Environment *ev);
|
||||
|
||||
MAKE_GET_SIMPLE (gchar *, NULL, filename, TC_Bonobo_Config_FileName, g_strdup (((CORBA_char **) value->_value)[0]))
|
||||
MAKE_GET_SIMPLE (GdkColor *, NULL, color, TC_Bonobo_Config_Color, bonobo_color_to_gdk ((Bonobo_Config_Color *) value->_value))
|
||||
|
||||
guint
|
||||
GType
|
||||
preferences_get_type (void)
|
||||
{
|
||||
static guint preferences_type = 0;
|
||||
static GType preferences_type = 0;
|
||||
|
||||
if (!preferences_type) {
|
||||
GtkTypeInfo preferences_info = {
|
||||
"Preferences",
|
||||
sizeof (Preferences),
|
||||
GTypeInfo preferences_info = {
|
||||
sizeof (PreferencesClass),
|
||||
(GtkClassInitFunc) preferences_class_init,
|
||||
(GtkObjectInitFunc) preferences_init,
|
||||
(GtkArgSetFunc) NULL,
|
||||
(GtkArgGetFunc) NULL
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) preferences_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (Preferences),
|
||||
0,
|
||||
(GInstanceInitFunc) preferences_init,
|
||||
};
|
||||
|
||||
preferences_type =
|
||||
gtk_type_unique (gtk_object_get_type (),
|
||||
&preferences_info);
|
||||
g_type_register_static (G_TYPE_OBJECT, "Preferences", &preferences_info, 0);
|
||||
}
|
||||
|
||||
return preferences_type;
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_init (Preferences *prefs)
|
||||
preferences_init (Preferences *prefs, PreferencesClass *class)
|
||||
{
|
||||
prefs->frozen = FALSE;
|
||||
|
||||
|
@ -133,30 +91,30 @@ preferences_init (Preferences *prefs)
|
|||
static void
|
||||
preferences_class_init (PreferencesClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass *) class;
|
||||
object_class->destroy = preferences_destroy;
|
||||
object_class = (GObjectClass *) class;
|
||||
object_class->finalize = preferences_finalize;
|
||||
|
||||
parent_class =
|
||||
GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ()));
|
||||
G_OBJECT_CLASS (g_type_class_ref (G_TYPE_OBJECT));
|
||||
}
|
||||
|
||||
GtkObject *
|
||||
GObject *
|
||||
preferences_new (void)
|
||||
{
|
||||
GtkObject *object;
|
||||
GObject *object;
|
||||
|
||||
object = gtk_type_new (preferences_get_type ());
|
||||
object = g_object_new (preferences_get_type (), NULL);
|
||||
PREFERENCES (object)->enabled = TRUE;
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
GtkObject *
|
||||
GObject *
|
||||
preferences_clone (const Preferences *prefs)
|
||||
{
|
||||
GtkObject *object;
|
||||
GObject *object;
|
||||
Preferences *new_prefs;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, NULL);
|
||||
|
@ -188,7 +146,7 @@ preferences_clone (const Preferences *prefs)
|
|||
}
|
||||
|
||||
static void
|
||||
preferences_destroy (GtkObject *object)
|
||||
preferences_finalize (GObject *object)
|
||||
{
|
||||
Preferences *prefs;
|
||||
|
||||
|
@ -200,67 +158,31 @@ preferences_destroy (GtkObject *object)
|
|||
g_free (prefs->wallpaper_filename);
|
||||
g_free (prefs->wallpaper_sel_path);
|
||||
|
||||
parent_class->destroy (object);
|
||||
}
|
||||
|
||||
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 ());
|
||||
preferences_load_from_bonobo_pbag (prefs, pb, ev);
|
||||
|
||||
if (BONOBO_EX (ev)) {
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GTK_OBJECT (prefs);
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
void
|
||||
preferences_load_from_bonobo_pbag (Preferences *prefs,
|
||||
Bonobo_PropertyBag pb,
|
||||
CORBA_Environment *ev)
|
||||
preferences_load (Preferences *prefs)
|
||||
{
|
||||
GConfEngine *engine;
|
||||
GError *error;
|
||||
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
g_return_if_fail (pb != CORBA_OBJECT_NIL);
|
||||
g_return_if_fail (ev != NULL);
|
||||
|
||||
prefs->enabled = bonobo_property_bag_client_get_value_gboolean (pb, "enabled", ev);
|
||||
engine = gconf_engine_get_default ();
|
||||
|
||||
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/PropertyBag/NotFound:1.0")) {
|
||||
prefs->enabled = TRUE;
|
||||
CORBA_exception_init (ev);
|
||||
} else {
|
||||
BONOBO_RET_EX (ev);
|
||||
}
|
||||
|
||||
prefs->wallpaper_type = local_bonobo_property_bag_client_get_value_gulong (pb, "wallpaper_type", ev); BONOBO_RET_EX (ev);
|
||||
prefs->wallpaper_filename = local_bonobo_property_bag_client_get_value_filename (pb, "wallpaper_filename", ev); BONOBO_RET_EX (ev);
|
||||
|
||||
prefs->wallpaper_enabled = bonobo_property_bag_client_get_value_gboolean (pb, "wallpaper_enabled", ev);
|
||||
|
||||
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/PropertyBag/NotFound:1.0")) {
|
||||
prefs->wallpaper_enabled = (prefs->wallpaper_filename != NULL && strcmp (prefs->wallpaper_filename, "(none)"));
|
||||
CORBA_exception_init (ev);
|
||||
} else {
|
||||
BONOBO_RET_EX (ev);
|
||||
}
|
||||
|
||||
prefs->color1 = local_bonobo_property_bag_client_get_value_color (pb, "color1", ev); BONOBO_RET_EX (ev);
|
||||
prefs->color2 = local_bonobo_property_bag_client_get_value_color (pb, "color2", ev); BONOBO_RET_EX (ev);
|
||||
|
||||
prefs->opacity = bonobo_property_bag_client_get_value_glong (pb, "opacity", ev); BONOBO_RET_EX (ev);
|
||||
prefs->enabled = gconf_engine_get_bool (engine, "/background-properties/enabled", &error);
|
||||
prefs->wallpaper_type = gconf_engine_get_int (engine, "/background-properties/wallpaper-type", &error);
|
||||
prefs->wallpaper_filename = gconf_engine_get_string (engine, "/background-properties/wallpaper-filename", &error);
|
||||
prefs->wallpaper_enabled = gconf_engine_get_bool (engine, "/background-properties/wallpaper-enabled", &error);
|
||||
prefs->color1 = read_color_from_string (gconf_engine_get_string (engine, "/background-properties/color1", &error));
|
||||
prefs->color2 = read_color_from_string (gconf_engine_get_string (engine, "/background-properties/color2", &error));
|
||||
prefs->opacity = gconf_engine_get_int (engine, "/background-properties/opacity", &error);
|
||||
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
|
||||
prefs->orientation = local_bonobo_property_bag_client_get_value_gulong (pb, "orientation", ev); BONOBO_RET_EX (ev);
|
||||
prefs->orientation = gconf_engine_get_int (engine, "/background-properties/orientation", &error);
|
||||
|
||||
if (prefs->orientation == ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = FALSE;
|
||||
|
@ -268,103 +190,26 @@ preferences_load_from_bonobo_pbag (Preferences *prefs,
|
|||
prefs->gradient_enabled = TRUE;
|
||||
}
|
||||
|
||||
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 ());
|
||||
preferences_load_from_bonobo_db (prefs, db, ev);
|
||||
|
||||
if (BONOBO_EX (ev)) {
|
||||
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GTK_OBJECT (prefs);
|
||||
}
|
||||
|
||||
void
|
||||
preferences_load_from_bonobo_db (Preferences *prefs,
|
||||
Bonobo_ConfigDatabase db,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
g_return_if_fail (db != CORBA_OBJECT_NIL);
|
||||
g_return_if_fail (ev != NULL);
|
||||
|
||||
prefs->enabled = bonobo_config_get_boolean (db, "/main/enabled", ev);
|
||||
|
||||
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/ConfigDatabase/NotFound:1.0")) {
|
||||
prefs->enabled = TRUE;
|
||||
CORBA_exception_init (ev);
|
||||
} else {
|
||||
BONOBO_RET_EX (ev);
|
||||
}
|
||||
|
||||
prefs->orientation = bonobo_config_get_ulong (db, "/main/orientation", ev); BONOBO_RET_EX (ev);
|
||||
|
||||
if (prefs->orientation != ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = TRUE;
|
||||
else
|
||||
prefs->gradient_enabled = FALSE;
|
||||
|
||||
prefs->wallpaper_type = bonobo_config_get_ulong (db, "/main/wallpaper_type", ev); BONOBO_RET_EX (ev);
|
||||
prefs->wallpaper_filename = local_bonobo_config_get_filename (db, "/main/wallpaper_filename", ev); BONOBO_RET_EX (ev);
|
||||
|
||||
prefs->wallpaper_enabled = bonobo_config_get_boolean (db, "/main/wallpaper_enabled", ev);
|
||||
|
||||
if (BONOBO_EX (ev) && !strcmp (ev->_repo_id, "IDL:Bonobo/ConfigDatabase/NotFound:1.0")) {
|
||||
prefs->wallpaper_enabled = (prefs->wallpaper_filename != NULL && strcmp (prefs->wallpaper_filename, "(none)"));
|
||||
CORBA_exception_init (ev);
|
||||
} else {
|
||||
BONOBO_RET_EX (ev);
|
||||
}
|
||||
|
||||
prefs->color1 = local_bonobo_config_get_color (db, "/main/color1", ev); BONOBO_RET_EX (ev);
|
||||
prefs->color2 = local_bonobo_config_get_color (db, "/main/color2", ev); BONOBO_RET_EX (ev);
|
||||
|
||||
prefs->opacity = bonobo_config_get_long (db, "/main/opacity", ev); BONOBO_RET_EX (ev);
|
||||
|
||||
if (prefs->opacity >= 100 || prefs->opacity < 0)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
}
|
||||
|
||||
/* Parse the event name given (the event being notification of a property having
|
||||
* changed and apply that change to the preferences structure. Eliminates the
|
||||
* need to reload the structure entirely on every event notification
|
||||
*/
|
||||
|
||||
void
|
||||
preferences_apply_event (Preferences *prefs,
|
||||
const gchar *event_name,
|
||||
const CORBA_any *value)
|
||||
preferences_merge_entry (Preferences *prefs,
|
||||
const GConfEntry *entry)
|
||||
{
|
||||
const gchar *name;
|
||||
const GConfValue *value = gconf_entry_get_value (entry);
|
||||
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
g_return_if_fail (event_name != NULL);
|
||||
|
||||
if (strncmp (event_name, "Bonobo/Property:change:", strlen ("Bonobo/Property:change:")))
|
||||
return;
|
||||
|
||||
name = event_name + strlen ("Bonobo/Property:change:");
|
||||
|
||||
if (!strcmp (name, "wallpaper_type")) {
|
||||
prefs->wallpaper_type = BONOBO_ARG_GET_GENERAL (value, TC_ulong, CORBA_long, NULL);
|
||||
if (!strcmp (entry->key, "/background-properties/wallpaper_type")) {
|
||||
prefs->wallpaper_type = gconf_value_get_int (value);
|
||||
}
|
||||
else if (!strcmp (name, "wallpaper_filename")) {
|
||||
if (!bonobo_arg_type_is_equal (value->_type, TC_Bonobo_Config_FileName, NULL)) {
|
||||
g_warning ("Filename property not of filename type");
|
||||
return;
|
||||
}
|
||||
|
||||
prefs->wallpaper_filename = g_strdup (*((char **)value->_value));
|
||||
else if (!strcmp (entry->key, "/background-properties/wallpaper_filename")) {
|
||||
prefs->wallpaper_filename = g_strdup (gconf_value_get_string (value));
|
||||
|
||||
if (prefs->wallpaper_filename != NULL &&
|
||||
strcmp (prefs->wallpaper_filename, "") != 0 &&
|
||||
|
@ -373,77 +218,33 @@ preferences_apply_event (Preferences *prefs,
|
|||
else
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
}
|
||||
else if (!strcmp (name, "color1")) {
|
||||
prefs->color1 = bonobo_color_to_gdk ((Bonobo_Config_Color *)value->_value);
|
||||
else if (!strcmp (entry->key, "/background-properties/color1")) {
|
||||
prefs->color1 = read_color_from_string (gconf_value_get_string (value));
|
||||
}
|
||||
else if (!strcmp (name, "color2")) {
|
||||
prefs->color2 = bonobo_color_to_gdk ((Bonobo_Config_Color *)value->_value);
|
||||
else if (!strcmp (entry->key, "/background-properties/color2")) {
|
||||
prefs->color2 = read_color_from_string (gconf_value_get_string (value));
|
||||
}
|
||||
else if (!strcmp (name, "opacity")) {
|
||||
prefs->opacity = BONOBO_ARG_GET_LONG (value);
|
||||
else if (!strcmp (entry->key, "/background-properties/opacity")) {
|
||||
prefs->opacity = gconf_value_get_int (value);
|
||||
|
||||
if (prefs->opacity >= 100)
|
||||
prefs->adjust_opacity = FALSE;
|
||||
}
|
||||
else if (!strcmp (name, "orientation")) {
|
||||
prefs->orientation = BONOBO_ARG_GET_GENERAL (value, TC_ulong, CORBA_long, NULL);
|
||||
else if (!strcmp (entry->key, "/background-properties/orientation")) {
|
||||
prefs->orientation = gconf_value_get_int (value);
|
||||
|
||||
if (prefs->orientation == ORIENTATION_SOLID)
|
||||
prefs->gradient_enabled = FALSE;
|
||||
else
|
||||
prefs->gradient_enabled = TRUE;
|
||||
}
|
||||
else if (!strcmp (name, "wallpaper_enabled")) {
|
||||
prefs->wallpaper_enabled = BONOBO_ARG_GET_BOOLEAN (value);
|
||||
else if (!strcmp (entry->key, "/background-properties/wallpaper_enabled")) {
|
||||
prefs->wallpaper_enabled = gconf_value_get_bool (value);
|
||||
} else {
|
||||
g_warning ("%s: Unknown property: %s", __FUNCTION__, name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
|
@ -456,70 +257,7 @@ read_color_from_string (const gchar *string)
|
|||
rgb = ((color->red >> 8) << 16) ||
|
||||
((color->green >> 8) << 8) ||
|
||||
(color->blue >> 8);
|
||||
color->pixel = xlib_rgb_xpixel_from_rgb (rgb);
|
||||
color->pixel = gdk_rgb_xpixel_from_rgb (rgb);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static GdkColor *
|
||||
bonobo_color_to_gdk (const 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
|
||||
local_bonobo_property_bag_client_get_value_gulong (Bonobo_PropertyBag pb,
|
||||
const gchar *propname,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
BonoboArg *arg;
|
||||
gulong retval;
|
||||
|
||||
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
||||
if (BONOBO_EX (ev)) return 0;
|
||||
retval = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_long, ev);
|
||||
bonobo_arg_release (arg);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GdkColor *
|
||||
local_bonobo_property_bag_client_get_value_color (Bonobo_PropertyBag pb,
|
||||
const gchar *propname,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
BonoboArg *arg;
|
||||
GdkColor *retval;
|
||||
|
||||
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
||||
if (BONOBO_EX (ev)) return 0;
|
||||
retval = bonobo_color_to_gdk ((Bonobo_Config_Color *) arg->_value);
|
||||
bonobo_arg_release (arg);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
local_bonobo_property_bag_client_get_value_filename (Bonobo_PropertyBag pb,
|
||||
const gchar *propname,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
BonoboArg *arg;
|
||||
gchar *retval;
|
||||
|
||||
arg = bonobo_property_bag_client_get_value_any (pb, propname, ev);
|
||||
if (BONOBO_EX (ev)) return 0;
|
||||
retval = g_strdup (((CORBA_char **) arg->_value)[0]);
|
||||
bonobo_arg_release (arg);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -24,18 +24,13 @@
|
|||
#ifndef __PREFERENCES_H
|
||||
#define __PREFERENCES_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib-object.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gconf/gconf.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)
|
||||
#define IS_PREFERENCES(obj) GTK_CHECK_TYPE (obj, preferences_get_type ())
|
||||
#define PREFERENCES(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, preferences_get_type (), Preferences)
|
||||
#define PREFERENCES_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, preferences_get_type (), PreferencesClass)
|
||||
#define IS_PREFERENCES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, preferences_get_type ())
|
||||
|
||||
typedef struct _Preferences Preferences;
|
||||
typedef struct _PreferencesClass PreferencesClass;
|
||||
|
@ -51,7 +46,7 @@ typedef enum _wallpaper_type_t {
|
|||
|
||||
struct _Preferences
|
||||
{
|
||||
GtkObject object;
|
||||
GObject object;
|
||||
|
||||
gint frozen;
|
||||
gboolean auto_apply;
|
||||
|
@ -77,29 +72,17 @@ struct _Preferences
|
|||
|
||||
struct _PreferencesClass
|
||||
{
|
||||
GtkObjectClass klass;
|
||||
GObjectClass klass;
|
||||
};
|
||||
|
||||
guint preferences_get_type (void);
|
||||
GType preferences_get_type (void);
|
||||
|
||||
GtkObject *preferences_new (void);
|
||||
GtkObject *preferences_clone (const Preferences *prefs);
|
||||
GObject *preferences_new (void);
|
||||
GObject *preferences_clone (const Preferences *prefs);
|
||||
|
||||
GtkObject *preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb,
|
||||
CORBA_Environment *ev);
|
||||
GtkObject *preferences_new_from_bonobo_db (Bonobo_ConfigDatabase db,
|
||||
CORBA_Environment *ev);
|
||||
void preferences_load_from_bonobo_pbag (Preferences *prefs,
|
||||
Bonobo_ConfigDatabase db,
|
||||
CORBA_Environment *ev);
|
||||
void preferences_load_from_bonobo_db (Preferences *prefs,
|
||||
Bonobo_ConfigDatabase db,
|
||||
CORBA_Environment *ev);
|
||||
void preferences_load (Preferences *prefs);
|
||||
|
||||
void preferences_apply_event (Preferences *prefs,
|
||||
const gchar *event_name,
|
||||
const CORBA_any *value);
|
||||
|
||||
void preferences_save (const Preferences *prefs);
|
||||
void preferences_merge_entry (Preferences *prefs,
|
||||
const GConfEntry *entry);
|
||||
|
||||
#endif /* __PREFERENCES_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue