bonobo-conf rewrite.

2001-07-19  Richard Hestilow  <hestilow@ximian.com>

	* bonobo-conf rewrite.
This commit is contained in:
Richard Hestilow 2001-07-19 21:05:43 +00:00 committed by Rachel Hestilow
parent 5da79712e0
commit 801e66b748
9 changed files with 676 additions and 728 deletions

View file

@ -0,0 +1,20 @@
<oaf_info>
<oaf_server iid="OAFIID:Bonobo_Control_Capplet_background_properties_Factory" type="exe" location="background-properties-capplet">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/ObjectFactory:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Background properties capplet factory"/>
</oaf_server>
<oaf_server iid="OAFIID:Bonobo_Control_Capplet_background_properties" type="factory"
location="OAFIID:Bonobo_Control_Capplet_background_properties_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/PropertyControl:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Background properties capplet"/>
</oaf_server>
</oaf_info>

View file

@ -1,3 +1,7 @@
2001-07-19 Richard Hestilow <hestilow@ximian.com>
* bonobo-conf rewrite.
2001-07-19 Bradford Hovinen <hovinen@ximian.com>
* Makefile.am: Remove SUBDIRS

View file

@ -1,16 +1,20 @@
cappletname = background
cappletgroup =
bin_PROGRAMS = background-properties
bin_PROGRAMS = background-properties-capplet
background_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
background_properties_SOURCES = \
background_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS)
background_properties_capplet_SOURCES = \
main.c\
prefs-widget.c prefs-widget.h \
preferences.c preferences.h \
applier.c applier.h
pixmap_DATA =
defaultsdir= $(datadir)/control-center/defaults
defaults_DATA = background-properties.xml
oafdir = $(datadir)/oaf
oaf_DATA = Bonobo_Control_Capplet_background_properties.oaf
##
## You should not need to modify anything below this line
##

View file

@ -36,6 +36,7 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <unistd.h>
#include <bonobo.h>
#include "applier.h"
@ -44,10 +45,13 @@
#define MONITOR_CONTENTS_WIDTH 157
#define MONITOR_CONTENTS_HEIGHT 111
static GtkWidget *preview_widget;
#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 = NULL;
static gboolean gdk_pixbuf_xlib_inited = FALSE;
typedef struct _Renderer Renderer;
typedef struct _ApplierPreferences ApplierPreferences;
enum {
ARG_0,
@ -55,8 +59,8 @@ enum {
struct _ApplierPrivate
{
Preferences *root_prefs;
Preferences *preview_prefs;
ApplierPreferences *root_prefs;
ApplierPreferences *preview_prefs;
GdkPixbuf *wallpaper_pixbuf;
gchar *wallpaper_filename;
@ -72,7 +76,7 @@ struct _Renderer
gboolean is_root;
gboolean is_set;
Preferences *prefs;
ApplierPreferences *prefs;
gint x; /* Geometry relative to pixmap */
gint y;
@ -100,6 +104,34 @@ 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);
@ -113,8 +145,8 @@ static void applier_get_arg (GtkObject *object,
guint arg_id);
static void run_render_pipeline (Renderer *renderer,
Preferences *old_prefs,
Preferences *new_prefs,
ApplierPreferences *old_prefs,
ApplierPreferences *new_prefs,
GdkPixbuf *wallpaper_pixbuf);
static void draw_disabled_message (GtkWidget *widget);
@ -122,7 +154,7 @@ static Renderer *renderer_new (gboolean is_root);
static void renderer_destroy (Renderer *renderer);
static void renderer_set_prefs (Renderer *renderer,
Preferences *prefs);
ApplierPreferences *prefs);
static void renderer_set_wallpaper (Renderer *renderer,
GdkPixbuf *wallpaper_pixbuf);
@ -153,14 +185,23 @@ static void tile_composite (GdkPixbuf *dest, GdkPixbuf *src,
gint alpha_value);
static gboolean render_gradient_p (Renderer *renderer,
Preferences *prefs);
static gboolean render_small_pixmap_p (Preferences *prefs);
ApplierPreferences *prefs);
static gboolean render_small_pixmap_p (ApplierPreferences *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);
guint
applier_get_type (void)
{
@ -210,6 +251,7 @@ applier_class_init (ApplierClass *class)
parent_class =
GTK_OBJECT_CLASS (gtk_type_class (gtk_object_get_type ()));
g_print ("Entering class_init\n");
if (!gdk_pixbuf_xlib_inited) {
gdk_pixbuf_xlib_inited = TRUE;
@ -281,11 +323,9 @@ applier_destroy (GtkObject *object)
renderer_destroy (applier->private->root_renderer);
if (applier->private->root_prefs != NULL)
gtk_object_unref
(GTK_OBJECT (applier->private->root_prefs));
applier_preferences_unref (applier->private->root_prefs);
if (applier->private->preview_prefs != NULL)
gtk_object_unref
(GTK_OBJECT (applier->private->preview_prefs));
applier_preferences_unref (applier->private->preview_prefs);
if (applier->private->wallpaper_pixbuf != NULL)
gdk_pixbuf_unref (applier->private->wallpaper_pixbuf);
@ -298,27 +338,23 @@ applier_destroy (GtkObject *object)
}
void
applier_apply_prefs (Applier *applier, Preferences *prefs,
gboolean do_root, gboolean do_preview)
applier_apply_prefs (Applier *applier, Bonobo_PropertyBag pb, Bonobo_ConfigDatabase db, CORBA_Environment *ev, gboolean do_root, gboolean do_preview)
{
Preferences *new_prefs;
ApplierPreferences *prefs;
g_return_if_fail (applier != NULL);
g_return_if_fail (IS_APPLIER (applier));
g_return_if_fail (prefs != NULL);
g_return_if_fail (IS_PREFERENCES (prefs));
g_return_if_fail (pb != NULL);
if (do_root && applier->private->nautilus_running) {
set_root_pixmap (-1);
do_root = FALSE;
}
if (!prefs->enabled) {
draw_disabled_message (applier_class_get_preview_widget ());
return;
}
new_prefs = PREFERENCES (preferences_clone (prefs));
if (pb != CORBA_OBJECT_NIL)
prefs = applier_preferences_pb_new (pb, ev);
else
prefs = applier_preferences_db_new (db, ev);
if (((prefs->wallpaper_filename ||
applier->private->wallpaper_filename) &&
@ -351,11 +387,11 @@ applier_apply_prefs (Applier *applier, Preferences *prefs,
if (!applier->private->wallpaper_pixbuf) {
g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."),
prefs->wallpaper_filename);
new_prefs->wallpaper_enabled = FALSE;
prefs->wallpaper_enabled = FALSE;
}
}
else if (applier->private->wallpaper_pixbuf == NULL) {
new_prefs->wallpaper_enabled = FALSE;
prefs->wallpaper_enabled = FALSE;
}
if (do_preview) {
@ -365,15 +401,14 @@ applier_apply_prefs (Applier *applier, Preferences *prefs,
run_render_pipeline (applier->private->preview_renderer,
applier->private->preview_prefs,
new_prefs,
prefs,
applier->private->wallpaper_pixbuf);
if (applier->private->preview_prefs != NULL)
gtk_object_unref (GTK_OBJECT
(applier->private->preview_prefs));
applier_preferences_unref (applier->private->preview_prefs);
applier->private->preview_prefs = new_prefs;
gtk_object_ref (GTK_OBJECT (new_prefs));
applier->private->preview_prefs = prefs;
applier_preferences_ref (prefs);
if (preview_widget != NULL)
gtk_widget_queue_draw (preview_widget);
@ -387,18 +422,16 @@ applier_apply_prefs (Applier *applier, Preferences *prefs,
run_render_pipeline (applier->private->root_renderer,
applier->private->root_prefs,
new_prefs,
prefs,
applier->private->wallpaper_pixbuf);
if (applier->private->root_prefs != NULL)
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 (applier->private->root_prefs);
applier->private->root_prefs = prefs;
applier_preferences_ref (prefs);
}
gtk_object_unref (GTK_OBJECT (new_prefs));
applier_preferences_unref (prefs);
}
GtkWidget *
@ -483,6 +516,16 @@ applier_class_get_preview_widget (void)
return preview_widget;
}
void
applier_class_destroy_preview_widget (void)
{
if (!preview_widget)
return;
if (GTK_IS_WIDGET (preview_widget))
gtk_widget_destroy (preview_widget);
preview_widget = NULL;
}
static void
draw_disabled_message (GtkWidget *widget)
{
@ -530,8 +573,8 @@ draw_disabled_message (GtkWidget *widget)
static void
run_render_pipeline (Renderer *renderer,
Preferences *old_prefs,
Preferences *new_prefs,
ApplierPreferences *old_prefs,
ApplierPreferences *new_prefs,
GdkPixbuf *wallpaper_pixbuf)
{
gboolean bg_formed = FALSE;
@ -539,9 +582,7 @@ run_render_pipeline (Renderer *renderer,
gboolean opt_old_prefs, opt_new_prefs;
g_return_if_fail (renderer != NULL);
g_return_if_fail (old_prefs == NULL || IS_PREFERENCES (old_prefs));
g_return_if_fail (new_prefs != NULL);
g_return_if_fail (IS_PREFERENCES (new_prefs));
renderer_set_prefs (renderer, new_prefs);
@ -646,18 +687,17 @@ renderer_destroy (Renderer *renderer)
}
static void
renderer_set_prefs (Renderer *renderer, Preferences *prefs)
renderer_set_prefs (Renderer *renderer, ApplierPreferences *prefs)
{
g_return_if_fail (renderer != NULL);
g_return_if_fail (prefs == NULL || IS_PREFERENCES (prefs));
if (renderer->prefs)
gtk_object_unref (GTK_OBJECT (renderer->prefs));
applier_preferences_unref (renderer->prefs);
renderer->prefs = prefs;
if (prefs)
gtk_object_ref (GTK_OBJECT (prefs));
applier_preferences_ref (prefs);
}
static void
@ -714,6 +754,7 @@ renderer_render_background (Renderer *renderer)
(GdkPixbufDestroyNotify)
g_free,
NULL);
PDEBUG (renderer->pixbuf);
}
}
@ -741,6 +782,8 @@ renderer_render_wallpaper (Renderer *renderer)
&renderer->wwidth, &renderer->wheight,
&renderer->srcx, &renderer->srcy);
renderer->pwidth = MAX (renderer->pwidth, renderer->wwidth);
if (renderer->prefs->wallpaper_type == WPTYPE_TILED &&
renderer->wwidth != renderer->pwidth &&
renderer->wheight != renderer->pheight)
@ -822,6 +865,7 @@ renderer_render_wallpaper (Renderer *renderer)
GDK_INTERP_BILINEAR,
alpha_value, 65536,
colorv, colorv);
PDEBUG (renderer->pixbuf);
}
}
else if (renderer->wwidth != renderer->pwidth ||
@ -832,7 +876,7 @@ renderer_render_wallpaper (Renderer *renderer)
(gdouble) renderer->pwidth;
scaley = (gdouble) renderer->wheight /
(gdouble) renderer->pheight;
g_print ("%i %i:\n", gdk_pixbuf_get_width (renderer->pixbuf), gdk_pixbuf_get_height (renderer->pixbuf));
gdk_pixbuf_scale
(renderer->wallpaper_pixbuf,
renderer->pixbuf,
@ -855,10 +899,12 @@ renderer_render_wallpaper (Renderer *renderer)
renderer->wwidth,
renderer->wheight,
GDK_INTERP_BILINEAR);
PDEBUG (renderer->pixbuf);
} else {
renderer->pixbuf =
renderer->prescaled_pixbuf;
gdk_pixbuf_ref (renderer->pixbuf);
PDEBUG (renderer->pixbuf);
}
}
} else {
@ -874,6 +920,7 @@ renderer_render_wallpaper (Renderer *renderer)
gdk_pixbuf_unref (renderer->pixbuf);
renderer->pixbuf = renderer->wallpaper_pixbuf;
PDEBUG (renderer->pixbuf);
gdk_pixbuf_ref (renderer->pixbuf);
}
@ -891,7 +938,6 @@ renderer_create_pixmap (Renderer *renderer)
g_return_if_fail (renderer != NULL);
g_return_if_fail (renderer->prefs != NULL);
g_return_if_fail (IS_PREFERENCES (renderer->prefs));
if (renderer->is_root) {
if (renderer->prefs->gradient_enabled &&
@ -1088,8 +1134,7 @@ get_geometry (wallpaper_type_t wallpaper_type, GdkPixbuf *pixbuf,
if (vwidth < gdk_pixbuf_get_width (pixbuf) &&
wallpaper_type == WPTYPE_CENTERED)
{
*srcx = (gdk_pixbuf_get_width (pixbuf) - vwidth) *
factor / 2;
*srcx = (gdk_pixbuf_get_width (pixbuf) - vwidth) / 2;
*rwidth = dwidth;
}
else
@ -1107,8 +1152,7 @@ get_geometry (wallpaper_type_t wallpaper_type, GdkPixbuf *pixbuf,
if (vheight < gdk_pixbuf_get_height (pixbuf) &&
wallpaper_type == WPTYPE_CENTERED)
{
*srcy = (gdk_pixbuf_get_height (pixbuf) - vheight) *
factor / 2;
*srcy = (gdk_pixbuf_get_height (pixbuf) - vheight) / 2;
*rheight = dheight;
}
else
@ -1207,7 +1251,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, Preferences *prefs)
render_gradient_p (Renderer *renderer, ApplierPreferences *prefs)
{
return prefs->gradient_enabled &&
!(prefs->wallpaper_enabled &&
@ -1221,7 +1265,7 @@ render_gradient_p (Renderer *renderer, Preferences *prefs)
/* Return TRUE if we can optimize the rendering by using a small thin pixmap */
static gboolean
render_small_pixmap_p (Preferences *prefs)
render_small_pixmap_p (ApplierPreferences *prefs)
{
return prefs->gradient_enabled && !prefs->wallpaper_enabled;
}
@ -1373,3 +1417,121 @@ 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;
}

View file

@ -29,7 +29,7 @@
#include <X11/Xlib.h>
#include <pthread.h>
#include "preferences.h"
#include <bonobo-conf/bonobo-config-database.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,9 +56,14 @@ guint applier_get_type (void);
GtkObject *applier_new (void);
void applier_destroy (GtkObject *object);
void applier_apply_prefs (Applier *applier, Preferences *prefs,
gboolean do_root, gboolean do_preview);
void applier_apply_prefs (Applier *applier,
Bonobo_PropertyBag pb,
Bonobo_ConfigDatabase db,
CORBA_Environment *ev,
gboolean do_root,
gboolean do_preview);
GtkWidget *applier_class_get_preview_widget (void);
void applier_class_destroy_preview_widget (void);
#endif /* __APPLIER_H */

View file

@ -2,8 +2,8 @@
<GTK-Interface>
<project>
<name>New-background-properties</name>
<program_name>new-background-properties</program_name>
<name>new-background-capplet-mockup</name>
<program_name>new-background-capplet-mockup</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
@ -15,7 +15,7 @@
<widget>
<class>GtkWindow</class>
<name>window1</name>
<title>window2</title>
<title>window1</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
@ -24,527 +24,358 @@
<auto_shrink>False</auto_shrink>
<widget>
<class>GtkTable</class>
<class>GtkVBox</class>
<name>prefs_widget</name>
<rows>3</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<widget>
<class>GtkCheckButton</class>
<name>disable_toggle</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>disable_toggled_cb</handler>
<last_modification_time>Wed, 06 Sep 2000 00:15:45 GMT</last_modification_time>
</signal>
<label>Use GNOME for setting background</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkFrame</class>
<name>color_frame</name>
<label>Colors</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkTable</class>
<name>table4</name>
<border_width>4</border_width>
<rows>3</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>4</row_spacing>
<column_spacing>4</column_spacing>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Effect</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label6</name>
<label>Primary color</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>color2_label</name>
<label>Right or bottom color</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GnomeColorPicker</class>
<name>color1_select</name>
<can_focus>True</can_focus>
<signal>
<name>color_set</name>
<handler>color1_select_color_set_cb</handler>
<last_modification_time>Sat, 09 Dec 2000 01:18:26 GMT</last_modification_time>
</signal>
<dither>True</dither>
<use_alpha>False</use_alpha>
<title>Pick a color</title>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GnomeColorPicker</class>
<name>color2_select</name>
<can_focus>True</can_focus>
<signal>
<name>color_set</name>
<handler>color2_select_color_set_cb</handler>
<last_modification_time>Sat, 09 Dec 2000 01:18:35 GMT</last_modification_time>
</signal>
<dither>True</dither>
<use_alpha>False</use_alpha>
<title>Pick a color</title>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>color_option</name>
<can_focus>True</can_focus>
<items>Solid Color
Vertical Gradient
Horizontal Gradient
</items>
<initial_choice>1</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>wallpaper_frame</name>
<label>Wallpaper</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkTable</class>
<name>table3</name>
<border_width>4</border_width>
<rows>4</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>4</row_spacing>
<column_spacing>4</column_spacing>
<widget>
<class>GtkLabel</class>
<name>label3</name>
<label>File</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label4</name>
<label>Display Style</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>wp_effect_option</name>
<can_focus>True</can_focus>
<items>Tiled
Centered
Scaled (keep aspect ratio)
Stretched (change aspect ratio)
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>browse_button</name>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>browse_button_cb</handler>
<last_modification_time>Fri, 08 Dec 2000 21:55:52 GMT</last_modification_time>
</signal>
<label>Browse...</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>wp_file_option</name>
<width>66</width>
<can_focus>True</can_focus>
<items>(None)
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>adjust_opacity_toggle</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>adjust_opacity_toggled_cb</handler>
<last_modification_time>Thu, 21 Dec 2000 19:54:21 GMT</last_modification_time>
</signal>
<label>Adjust wallpaper's transparency</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<spacing>0</spacing>
<widget>
<class>GtkHBox</class>
<name>opacity_box</name>
<name>hbox3</name>
<homogeneous>False</homogeneous>
<spacing>4</spacing>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>label8</name>
<label>More Transparent</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>opacity_adjust</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>0</value>
<lower>0</lower>
<upper>256</upper>
<step>2.56</step>
<page>25.6</page>
<page_size>25.6</page_size>
<class>GtkVBox</class>
<name>preview_holder</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label9</name>
<label>More Opaque</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>monitor_frame</name>
<width>210</width>
<height>170</height>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_NONE</shadow_type>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame4</name>
<label>Background colors</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox4</name>
<border_width>3</border_width>
<homogeneous>False</homogeneous>
<spacing>3</spacing>
<widget>
<class>GtkLabel</class>
<name>label19</name>
<label>Style:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>color_option</name>
<can_focus>True</can_focus>
<items>Solid color
Horizontal gradient
Vertical gradient
</items>
<initial_choice>0</initial_choice>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GnomeColorPicker</class>
<name>colorpicker1</name>
<can_focus>True</can_focus>
<dither>True</dither>
<use_alpha>False</use_alpha>
<title>Pick a color</title>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GnomeColorPicker</class>
<name>colorpicker2</name>
<can_focus>True</can_focus>
<dither>True</dither>
<use_alpha>False</use_alpha>
<title>Pick a color</title>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame3</name>
<label>Background picture</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkTable</class>
<name>table1</name>
<border_width>3</border_width>
<rows>2</rows>
<columns>5</columns>
<homogeneous>False</homogeneous>
<row_spacing>3</row_spacing>
<column_spacing>3</column_spacing>
<widget>
<class>GtkLabel</class>
<name>label14</name>
<label>Image:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label15</name>
<label>Style:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkAlignment</class>
<name>alignment1</name>
<xalign>7.45058e-09</xalign>
<yalign>0.5</yalign>
<xscale>0</xscale>
<yscale>1</yscale>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkOptionMenu</class>
<name>image_option</name>
<can_focus>True</can_focus>
<items>Tiled
Centered
Scaled (keep aspect ratio)
Stretched
</items>
<initial_choice>0</initial_choice>
</widget>
</widget>
<widget>
<class>GnomeFileEntry</class>
<name>image_fileentry</name>
<max_saved>10</max_saved>
<directory>False</directory>
<modal>False</modal>
<child>
<left_attach>1</left_attach>
<right_attach>5</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name>
<name>entry1</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label16</name>
<label>Opacity (percent):</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkAlignment</class>
<name>alignment2</name>
<xalign>7.45058e-09</xalign>
<yalign>0.5</yalign>
<xscale>0.5</xscale>
<yscale>1</yscale>
<child>
<left_attach>3</left_attach>
<right_attach>4</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
<widget>
<class>GtkSpinButton</class>
<name>opacity_spin</name>
<can_focus>True</can_focus>
<climb_rate>1</climb_rate>
<digits>0</digits>
<numeric>True</numeric>
<update_policy>GTK_UPDATE_ALWAYS</update_policy>
<snap>False</snap>
<wrap>False</wrap>
<value>100</value>
<lower>0</lower>
<upper>10000</upper>
<step>1</step>
<page>10</page>
<page_size>10</page_size>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>label18</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>4</left_attach>
<right_attach>5</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>

View file

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<bonobo-config>
<section path="main">
<entry name="color1" type="color" value="#000000"/>
<entry name="color2" type="color" value="#ffffff"/>
<entry name="orientation" type="ulong" value="0"/>
<entry name="wallpaper_type" type="ulong" value="0"/>
<entry name="wallpaper_filename" type="string" value=""/>
<entry name="opacity" type="long" value="100"/>
</section>
</bonobo-config>

View file

@ -1,10 +1,10 @@
/* -*- mode: c; style: linux -*- */
/* main.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
* Copyright (C) 2000-2001 Ximian, Inc.
*
* 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)
@ -25,289 +25,208 @@
# include <config.h>
#endif
#include <gtk/gtk.h>
#include <gnome.h>
#include <libgnomeui/gnome-window-icon.h>
#include <tree.h>
#include <parser.h>
#include <fcntl.h>
#include <bonobo.h>
#include <glade/glade.h>
#include <gtk/gtksignal.h>
#include "capplet-util.h"
#include "applier.h"
#include <capplet-widget.h>
#ifdef HAVE_XIMIAN_ARCHIVER
# include <ximian-archiver/archive.h>
# include <ximian-archiver/location.h>
#endif /* HAVE_XIMIAN_ARCHIVER */
#include "preferences.h"
#include "prefs-widget.h"
static Preferences *prefs;
static Preferences *old_prefs;
static PrefsWidget *prefs_widget;
static guint ok_handler_id;
static guint cancel_handler_id;
#ifdef HAVE_XIMIAN_ARCHIVER
static Archive *archive;
static gboolean outside_location;
static Applier *applier;
static void
store_archive_data (void)
apply_settings (Bonobo_ConfigDatabase db)
{
Location *location;
xmlDocPtr xml_doc;
CORBA_Environment ev;
if (capplet_get_location () == NULL)
location = archive_get_current_location (archive);
CORBA_exception_init (&ev);
applier_apply_prefs (applier, CORBA_OBJECT_NIL, db, &ev, TRUE, FALSE);
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;
}
static void
copy_color_from_legacy (Bonobo_ConfigDatabase db,
const gchar *key, const gchar *legacy_key)
{
gboolean def;
gchar *val_string;
g_return_if_fail (key != NULL);
g_return_if_fail (legacy_key != NULL);
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
get_legacy_settings (Bonobo_ConfigDatabase db)
{
gboolean val_boolean, def;
gchar *val_string;
int val_ulong, val_long;
COPY_FROM_LEGACY (string, "/main/wallpaper_filename", string, "/Background/Default/wallpaper=none");
COPY_FROM_LEGACY (ulong, "/main/wallpaper_type", int, "/Background/Default/wallpaperAlign=0");
copy_color_from_legacy (db, "/main/color1", "/Background/Default/color1");
copy_color_from_legacy (db, "/main/color2", "/Background/Default/color2");
/* Code to deal with new enum - messy */
val_ulong = -1;
val_string = gnome_config_get_string_with_default ("/Background/Default/simple=solid", &def);
if (!def)
{
if (!strcmp (val_string, "solid"))
val_ulong = 0;
else
location = archive_get_location (archive,
capplet_get_location ());
xml_doc = preferences_write_xml (prefs);
location_store_xml (location, "background-properties-capplet",
xml_doc, STORE_MASK_PREVIOUS);
xmlFreeDoc (xml_doc);
archive_close (archive);
}
#endif /* HAVE_XIMIAN_ARCHIVER */
static void
ok_cb (GtkWidget *widget)
{
#ifdef HAVE_XIMIAN_ARCHIVER
if (!outside_location) {
preferences_save (prefs);
preferences_apply_now (prefs);
{
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");
}
}
#else /* !HAVE_XIMIAN_ARCHIVER */
preferences_save (prefs);
preferences_apply_now (prefs);
#endif /* HAVE_XIMIAN_ARCHIVER */
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id);
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id);
gtk_object_destroy (GTK_OBJECT (prefs_widget));
#ifdef HAVE_XIMIAN_ARCHIVER
store_archive_data ();
#endif /* HAVE_XIMIAN_ARCHIVER */
g_free (val_string);
if (val_ulong != -1)
bonobo_config_set_ulong (db, "/main/orientation", val_ulong, 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");
}
}
static void
cancel_cb (GtkWidget *widget)
property_change_cb (BonoboListener *listener,
char *event_name,
CORBA_any *any,
CORBA_Environment *ev,
Bonobo_PropertyBag pb)
{
#ifdef HAVE_XIMIAN_ARCHIVER
if (!outside_location) {
preferences_save (old_prefs);
preferences_apply_now (old_prefs);
}
#else /* !HAVE_XIMIAN_ARCHIVER */
preferences_save (prefs);
preferences_apply_now (prefs);
#endif /* HAVE_XIMIAN_ARCHIVER */
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id);
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id);
gtk_object_destroy (GTK_OBJECT (prefs_widget));
applier_apply_prefs (applier, pb, CORBA_OBJECT_NIL, ev, FALSE, TRUE);
}
static void
setup_capplet_widget (void)
realize_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
{
preferences_freeze (prefs);
CORBA_Environment ev;
prefs_widget = PREFS_WIDGET (prefs_widget_new (prefs));
ok_handler_id =
gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok",
GTK_SIGNAL_FUNC (ok_cb), NULL);
cancel_handler_id =
gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel",
GTK_SIGNAL_FUNC (cancel_cb), NULL);
gtk_widget_show_all (GTK_WIDGET (prefs_widget));
preferences_thaw (prefs);
CORBA_exception_init (&ev);
applier_apply_prefs (applier, bag, CORBA_OBJECT_NIL, &ev, FALSE, TRUE);
CORBA_exception_free (&ev);
}
#ifdef HAVE_XIMIAN_ARCHIVER
#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
do_get_xml (void)
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
{
Preferences *prefs;
xmlDocPtr doc;
BonoboPEditor *ed;
GladeXML *dialog;
prefs = PREFERENCES (preferences_new ());
preferences_load (prefs);
doc = preferences_write_xml (prefs);
xmlDocDump (stdout, doc);
gtk_object_destroy (GTK_OBJECT (prefs));
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("color_option")));
bonobo_peditor_set_property (ed, bag, "orientation", TC_ulong, NULL);
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_construct (0, WID ("image_option")));
bonobo_peditor_set_property (ed, bag, "wallpaper_type", TC_ulong, NULL);
CUSTOM_CREATE_PEDITOR (int_range, long, "opacity", "opacity_spin");
bonobo_event_source_client_add_listener (bag, property_change_cb,
NULL, NULL, bag);
gtk_signal_connect_after (GTK_OBJECT (applier_class_get_preview_widget ()), "realize", realize_cb, bag);
}
static void
do_set_xml (gboolean apply_settings)
static GtkWidget*
create_dialog (void)
{
xmlDocPtr doc;
char buffer[16384];
GString *doc_str;
int t = 0;
GtkWidget *holder;
GtkWidget *widget;
GladeXML *dialog;
fflush (stdin);
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/background-properties.glade", "prefs_widget");
widget = glade_xml_get_widget (dialog, "prefs_widget");
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
fcntl (fileno (stdin), F_SETFL, 0);
applier = APPLIER (applier_new ());
doc_str = g_string_new ("");
/* Minor GUI addition */
holder = WID ("preview_holder");
gtk_box_pack_start (GTK_BOX (holder),
applier_class_get_preview_widget (),
TRUE, TRUE, 0);
gtk_widget_show_all (holder);
while ((t = read (fileno (stdin), buffer, sizeof (buffer) - 1)) != 0) {
buffer[t] = '\0';
g_string_append (doc_str, buffer);
}
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
GTK_SIGNAL_FUNC (gtk_object_destroy),
GTK_OBJECT (dialog));
if (doc_str->len > 0) {
doc = xmlParseDoc (doc_str->str);
g_string_free (doc_str, TRUE);
if (doc != NULL) {
prefs = preferences_read_xml (doc);
if (prefs != NULL) {
if (apply_settings) {
preferences_save (prefs);
preferences_apply_now (prefs);
}
return;
}
else if (prefs != NULL) {
return;
}
xmlFreeDoc (doc);
}
} else {
g_critical ("No data to apply");
}
return;
}
#endif /* HAVE_XIMIAN_ARCHIVER */
static void
do_restore_from_defaults (void)
{
prefs = PREFERENCES (preferences_new ());
preferences_save (prefs);
preferences_apply_now (prefs);
return widget;
}
int
main (int argc, char **argv)
{
GnomeClient *client;
GnomeClientFlags flags;
gint token, res;
gchar *restart_args[3];
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
glade_gnome_init ();
res = gnome_capplet_init ("background-properties-capplet",
VERSION, argc, argv, NULL,
0, NULL);
if (res < 0) {
g_error ("Could not initialize the capplet.");
}
else if (res == 3) {
#ifdef HAVE_XIMIAN_ARCHIVER
do_get_xml ();
#endif /* HAVE_XIMIAN_ARCHIVER */
return 0;
}
else if (res == 4) {
#ifdef HAVE_XIMIAN_ARCHIVER
do_set_xml (TRUE);
#endif /* HAVE_XIMIAN_ARCHIVER */
return 0;
}
else if (res == 5) {
do_restore_from_defaults ();
return 0;
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);
if (flags & GNOME_CLIENT_IS_CONNECTED) {
token = gnome_startup_acquire_token
("GNOME_BACKGROUND_PROPERTIES",
gnome_client_get_id (client));
if (token) {
gnome_client_set_priority (client, 20);
gnome_client_set_restart_style (client,
GNOME_RESTART_ANYWAY);
restart_args[0] = argv[0];
restart_args[1] = "--init-session-settings";
restart_args[2] = NULL;
gnome_client_set_restart_command (client, 2,
restart_args);
} else {
gnome_client_set_restart_style (client,
GNOME_RESTART_NEVER);
}
} else {
token = 1;
}
capplet_init (argc, argv, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
gnome_window_icon_set_default_from_file
(GNOMECC_ICONS_DIR"/gnome-ccbackground.png");
#ifdef HAVE_XIMIAN_ARCHIVER
archive = ARCHIVE (archive_load (FALSE));
if (capplet_get_location () != NULL &&
strcmp (capplet_get_location (),
archive_get_current_location_id (archive)))
{
outside_location = TRUE;
do_set_xml (FALSE);
if (prefs == NULL) return -1;
preferences_freeze (prefs);
} else {
outside_location = FALSE;
prefs = PREFERENCES (preferences_new ());
preferences_load (prefs);
}
if (!outside_location && (token || res == 1)) {
preferences_apply_now (prefs);
}
#else /* !HAVE_XIMIAN_ARCHIVER */
prefs = PREFERENCES (preferences_new ());
preferences_load (prefs);
if (token || res == 1)
preferences_apply_now (prefs);
#endif /* HAVE_XIMIAN_ARCHIVER */
if (!res) {
old_prefs = PREFERENCES (preferences_clone (prefs));
setup_capplet_widget ();
capplet_gtk_main ();
}
return 0;
}

View file

@ -35,15 +35,6 @@
typedef struct _Preferences Preferences;
typedef struct _PreferencesClass PreferencesClass;
typedef enum _orientation_t {
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;