Redid UI a bit to add new enabled checkbox.
2001-09-07 Richard Hestilow <hestilow@ximian.com> * background-properties.glade: Redid UI a bit to add new enabled checkbox. * background-properties.xml: Add default for "wallpaper_enabled". * preferences.[ch]: New function preferences_need_color_opts. (preferences_load_from_bonobo_db): Load wallpaper_enabled from bonobo-conf. (preferences_load_from_bonobo_pbag): Ditto. * applier.[ch]: New function applier_get_wallpaper_pixbuf (needed by preferences_need_color_opts, else pixbuf gets created twice). * background-properties-capplet.c (real_realize_cb): Set color frame sensitivity based on preferences_need_color_opts. (property_change_cb): Ditto. (setup_dialog): Add peditor/guard for wallpaper_enabled. Also, set glade object data on the preferences structure as well.
This commit is contained in:
parent
fee5ad7111
commit
f29d4a9502
8 changed files with 212 additions and 90 deletions
|
@ -1,3 +1,25 @@
|
|||
2001-09-07 Richard Hestilow <hestilow@ximian.com>
|
||||
|
||||
* background-properties.glade: Redid UI a bit to add new enabled
|
||||
checkbox.
|
||||
|
||||
* background-properties.xml: Add default for "wallpaper_enabled".
|
||||
|
||||
* preferences.[ch]: New function preferences_need_color_opts.
|
||||
(preferences_load_from_bonobo_db): Load wallpaper_enabled from
|
||||
bonobo-conf.
|
||||
(preferences_load_from_bonobo_pbag): Ditto.
|
||||
|
||||
* applier.[ch]: New function applier_get_wallpaper_pixbuf
|
||||
(needed by preferences_need_color_opts, else pixbuf gets created
|
||||
twice).
|
||||
|
||||
* background-properties-capplet.c (real_realize_cb): Set
|
||||
color frame sensitivity based on preferences_need_color_opts.
|
||||
(property_change_cb): Ditto.
|
||||
(setup_dialog): Add peditor/guard for wallpaper_enabled. Also,
|
||||
set glade object data on the preferences structure as well.
|
||||
|
||||
2001-08-28 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* background-properties-capplet.c (get_legacy_settings): Retrieve
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkprivate.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf-xlib.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
@ -1414,3 +1413,11 @@ output_compat_prefs (const Preferences *prefs)
|
|||
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
applier_get_wallpaper_pixbuf (Applier *applier)
|
||||
{
|
||||
g_return_val_if_fail (applier != NULL, NULL);
|
||||
|
||||
return applier->private->wallpaper_pixbuf;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define __APPLIER_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <pthread.h>
|
||||
|
@ -61,4 +62,6 @@ void applier_apply_prefs (Applier *applier, const Preferences *prefs,
|
|||
|
||||
GtkWidget *applier_get_preview_widget (Applier *applier);
|
||||
|
||||
GdkPixbuf *applier_get_wallpaper_pixbuf (Applier *applier);
|
||||
|
||||
#endif /* __APPLIER_H */
|
||||
|
|
|
@ -192,27 +192,52 @@ property_change_cb (BonoboListener *listener,
|
|||
CORBA_Environment *ev,
|
||||
Preferences *prefs)
|
||||
{
|
||||
GladeXML *dialog;
|
||||
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (IS_PREFERENCES (prefs));
|
||||
|
||||
if (GTK_OBJECT_DESTROYED (prefs))
|
||||
return;
|
||||
|
||||
|
||||
dialog = gtk_object_get_data (GTK_OBJECT (prefs), "glade-data");
|
||||
|
||||
preferences_apply_event (prefs, event_name, any);
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
|
||||
if (!strcmp (event_name, "Bonobo/Property:change:wallpaper_type")
|
||||
|| !strcmp (event_name, "Bonobo/Property:change:wallpaper_filename")
|
||||
|| !strcmp (event_name, "Bonobo/Property:change:wallpaper_enabled"))
|
||||
{
|
||||
gtk_widget_set_sensitive (
|
||||
WID ("color_frame"),
|
||||
preferences_need_color_opts (
|
||||
prefs,
|
||||
applier_get_wallpaper_pixbuf (applier)));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_realize_cb (Preferences *prefs)
|
||||
{
|
||||
GladeXML *dialog;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, TRUE);
|
||||
g_return_val_if_fail (IS_PREFERENCES (prefs), TRUE);
|
||||
|
||||
if (GTK_OBJECT_DESTROYED (prefs))
|
||||
return FALSE;
|
||||
|
||||
dialog = gtk_object_get_data (GTK_OBJECT (prefs), "glade-data");
|
||||
|
||||
applier_apply_prefs (applier, prefs, FALSE, TRUE);
|
||||
|
||||
gtk_widget_set_sensitive (
|
||||
WID ("color_frame"),
|
||||
preferences_need_color_opts (
|
||||
prefs,
|
||||
applier_get_wallpaper_pixbuf (applier)));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -242,6 +267,7 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|||
GladeXML *dialog;
|
||||
Applier *applier;
|
||||
GtkObject *prefs;
|
||||
|
||||
CORBA_Environment ev;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
@ -256,6 +282,10 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|||
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");
|
||||
|
||||
/* Disable opacity controls */
|
||||
gtk_widget_hide (WID ("opacity_spin"));
|
||||
gtk_widget_hide (WID ("opacity_label"));
|
||||
|
@ -263,6 +293,7 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|||
bonobo_property_bag_client_set_value_gboolean (bag, "enabled", TRUE, NULL);
|
||||
|
||||
prefs = preferences_new_from_bonobo_pbag (bag, &ev);
|
||||
gtk_object_set_data (GTK_OBJECT (prefs), "glade-data", dialog);
|
||||
bonobo_event_source_client_add_listener (bag, (BonoboListenerCallbackFn) property_change_cb,
|
||||
NULL, NULL, prefs);
|
||||
|
||||
|
@ -296,7 +327,9 @@ create_dialog (void)
|
|||
TRUE, TRUE, 0);
|
||||
gtk_widget_show_all (holder);
|
||||
|
||||
#if 0
|
||||
gnome_entry_append_history (GNOME_ENTRY (gnome_file_entry_gnome_entry (GNOME_FILE_ENTRY (WID ("image_fileentry")))), 0, "(none)");
|
||||
#endif
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
||||
|
|
|
@ -59,91 +59,22 @@
|
|||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>frame4</name>
|
||||
<border_width>4</border_width>
|
||||
<label>Background colors</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>picture_enabled_check</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Use a picture for the background</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox4</name>
|
||||
<border_width>10</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>8</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>
|
||||
<name>picture_frame</name>
|
||||
<border_width>4</border_width>
|
||||
<label>Background picture</label>
|
||||
<label_xalign>0</label_xalign>
|
||||
|
@ -378,6 +309,89 @@ Stretched
|
|||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkFrame</class>
|
||||
<name>color_frame</name>
|
||||
<border_width>4</border_width>
|
||||
<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>10</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>8</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>
|
||||
</widget>
|
||||
|
||||
|
|
|
@ -65,5 +65,6 @@
|
|||
</entry>
|
||||
<entry name="opacity" type="long" value="100"/>
|
||||
<entry name="enabled" type="boolean" value="true"/>
|
||||
<entry name="wallpaper_enabled" type="boolean" value="true"/>
|
||||
</section>
|
||||
</bonobo-config>
|
||||
|
|
|
@ -236,12 +236,7 @@ preferences_load_from_bonobo_pbag (Preferences *prefs,
|
|||
prefs->wallpaper_type = bonobo_property_bag_client_get_value_gulong (pb, "wallpaper_type", ev);
|
||||
prefs->wallpaper_filename = g_strdup (*((CORBA_char **)(PB_GET_VALUE ("wallpaper_filename"))->_value));
|
||||
|
||||
if (prefs->wallpaper_filename != NULL &&
|
||||
strcmp (prefs->wallpaper_filename, "") != 0 &&
|
||||
strcmp (prefs->wallpaper_filename, "(none)") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
else
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
prefs->wallpaper_enabled = bonobo_property_bag_client_get_value_gboolean (pb, "wallpaper_enabled", ev);
|
||||
|
||||
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);
|
||||
|
@ -294,13 +289,9 @@ preferences_load_from_bonobo_db (Preferences *prefs,
|
|||
|
||||
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 &&
|
||||
strcmp (prefs->wallpaper_filename, "(none)") != 0)
|
||||
prefs->wallpaper_enabled = TRUE;
|
||||
else
|
||||
prefs->wallpaper_enabled = FALSE;
|
||||
|
||||
prefs->wallpaper_enabled = BONOBO_ARG_GET_BOOLEAN (DB_GET_VALUE ("/main/wallpaper_enabled"));
|
||||
|
||||
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);
|
||||
|
||||
|
@ -362,6 +353,9 @@ preferences_apply_event (Preferences *prefs,
|
|||
prefs->gradient_enabled = FALSE;
|
||||
else
|
||||
prefs->gradient_enabled = TRUE;
|
||||
}
|
||||
else if (!strcmp (name, "wallpaper_enabled")) {
|
||||
prefs->wallpaper_enabled = BONOBO_ARG_GET_BOOLEAN (value);
|
||||
} else {
|
||||
g_warning ("%s: Unknown property: %s", __FUNCTION__, name);
|
||||
}
|
||||
|
@ -785,3 +779,47 @@ read_color_from_string (gchar *string)
|
|||
|
||||
return color;
|
||||
}
|
||||
|
||||
/* It'd be nice if we could just get the pixbuf the applier uses, for
|
||||
* efficiency's sake */
|
||||
gboolean
|
||||
preferences_need_color_opts (Preferences *prefs, GdkPixbuf *wallpaper_pixbuf)
|
||||
{
|
||||
int s_width, s_height;
|
||||
int p_width, p_height;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, TRUE);
|
||||
|
||||
if (!(prefs->wallpaper_enabled && prefs->wallpaper_filename))
|
||||
return TRUE;
|
||||
|
||||
if (!wallpaper_pixbuf)
|
||||
return TRUE;
|
||||
|
||||
p_width = gdk_pixbuf_get_width (wallpaper_pixbuf);
|
||||
p_height = gdk_pixbuf_get_height (wallpaper_pixbuf);
|
||||
|
||||
s_width = gdk_screen_width ();
|
||||
s_height = gdk_screen_height ();
|
||||
|
||||
switch (prefs->wallpaper_type)
|
||||
{
|
||||
case WPTYPE_CENTERED:
|
||||
if (p_width >= s_width && p_height >= s_height)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
break;
|
||||
case WPTYPE_SCALED_ASPECT:
|
||||
if (s_width == p_width && s_height == p_height)
|
||||
return FALSE;
|
||||
else if (((double) s_width / (double) s_height)
|
||||
== ((double) p_width / (double) p_height))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define __PREFERENCES_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#ifdef BONOBO_CONF_ENABLE
|
||||
#include <bonobo-conf/bonobo-config-database.h>
|
||||
|
@ -86,6 +87,9 @@ GtkObject *preferences_clone (const Preferences *prefs);
|
|||
|
||||
void preferences_destroy (GtkObject *object);
|
||||
|
||||
gboolean preferences_need_color_opts (Preferences *prefs,
|
||||
GdkPixbuf *wallpaper_pixbuf);
|
||||
|
||||
#ifdef BONOBO_CONF_ENABLE
|
||||
|
||||
GtkObject *preferences_new_from_bonobo_pbag (Bonobo_PropertyBag pb,
|
||||
|
|
Loading…
Add table
Reference in a new issue