Add an Apply button
2006-01-26 Rodney Dawes <dobey@novell.com> * gnome-background-properties.glade: Add an Apply button * gnome-wp-capplet.[ch]: Replace old_filename with an old_item struct (gnome_wp_props_wp_set): Set the filename key to empty string when setting the background to "No Wallpaper" (gnome_wp_props_revert): New method to revert changes in the dialog when the Cancel button is clicked (gnome_wp_main_quit): Free the old_item structure (wallpaper_properties_clicked): Handle the Apply button Handle closing the dialog for OK separately from Cancel/delete_event Revert the settings when Cancel or wm "x" or ESC are clicked (gnome_wp_load_stuffs): Set the old_item to the currently selected background setting, whether it be an image or "No Wallpaper" * gnome-wp-info.c (gnome_wp_info_dup): If info is NULL, just return NULL rather than trying to access members of an empty struct * gnome-wp-item.[ch] (gnome_wp_item_dup): New method to create a duplicate and newly allocated GnomeWPItem structure Fixes #327335
This commit is contained in:
parent
cbc6eb679e
commit
f69be2bd96
7 changed files with 144 additions and 8 deletions
|
@ -1,3 +1,27 @@
|
|||
2006-01-26 Rodney Dawes <dobey@novell.com>
|
||||
|
||||
* gnome-background-properties.glade: Add an Apply button
|
||||
|
||||
* gnome-wp-capplet.[ch]: Replace old_filename with an old_item struct
|
||||
(gnome_wp_props_wp_set): Set the filename key to empty string when
|
||||
setting the background to "No Wallpaper"
|
||||
(gnome_wp_props_revert): New method to revert changes in the dialog
|
||||
when the Cancel button is clicked
|
||||
(gnome_wp_main_quit): Free the old_item structure
|
||||
(wallpaper_properties_clicked): Handle the Apply button
|
||||
Handle closing the dialog for OK separately from Cancel/delete_event
|
||||
Revert the settings when Cancel or wm "x" or ESC are clicked
|
||||
(gnome_wp_load_stuffs): Set the old_item to the currently selected
|
||||
background setting, whether it be an image or "No Wallpaper"
|
||||
|
||||
* gnome-wp-info.c (gnome_wp_info_dup): If info is NULL, just return
|
||||
NULL rather than trying to access members of an empty struct
|
||||
|
||||
* gnome-wp-item.[ch] (gnome_wp_item_dup): New method to create a
|
||||
duplicate and newly allocated GnomeWPItem structure
|
||||
|
||||
Fixes #327335
|
||||
|
||||
2006-01-14 Rodney Dawes <dobey@novell.com>
|
||||
|
||||
* gnome-background-properties.glade: Set the visibility of the second
|
||||
|
|
|
@ -49,6 +49,19 @@
|
|||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-apply</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-10</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -61,7 +74,7 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="button2">
|
||||
<widget class="GtkButton" id="button3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
|
|
@ -284,11 +284,12 @@ static gboolean gnome_wp_props_wp_set (GnomeWPCapplet * capplet) {
|
|||
|
||||
item = g_hash_table_lookup (capplet->wphash, wpfile);
|
||||
|
||||
if (g_utf8_collate (capplet->old_filename, wpfile) != 0) {
|
||||
if (g_utf8_collate (capplet->old_item->filename, wpfile) != 0) {
|
||||
cs = gconf_change_set_new ();
|
||||
|
||||
if (!strcmp (item->filename, "(none)")) {
|
||||
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, "none");
|
||||
gconf_change_set_set_string (cs, WP_FILE_KEY, "");
|
||||
} else {
|
||||
gchar * uri;
|
||||
|
||||
|
@ -319,6 +320,45 @@ static gboolean gnome_wp_props_wp_set (GnomeWPCapplet * capplet) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
static gboolean gnome_wp_props_revert (GnomeWPCapplet * capplet) {
|
||||
GnomeWPItem * item;
|
||||
GConfChangeSet * cs;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
item = capplet->old_item;
|
||||
|
||||
cs = gconf_change_set_new ();
|
||||
|
||||
if (!strcmp (item->filename, "(none)")) {
|
||||
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, "none");
|
||||
} else {
|
||||
gchar * uri;
|
||||
|
||||
if (g_utf8_validate (item->filename, -1, NULL))
|
||||
uri = g_strdup (item->filename);
|
||||
else
|
||||
uri = g_filename_to_utf8 (item->filename, -1, NULL, NULL, NULL);
|
||||
|
||||
gconf_change_set_set_string (cs, WP_FILE_KEY, uri);
|
||||
g_free (uri);
|
||||
|
||||
gconf_change_set_set_string (cs, WP_OPTIONS_KEY, item->options);
|
||||
}
|
||||
|
||||
gconf_change_set_set_string (cs, WP_SHADING_KEY, item->shade_type);
|
||||
|
||||
gconf_change_set_set_string (cs, WP_PCOLOR_KEY, item->pri_color);
|
||||
gconf_change_set_set_string (cs, WP_SCOLOR_KEY, item->sec_color);
|
||||
|
||||
gconf_client_commit_change_set (capplet->client, cs, TRUE, NULL);
|
||||
|
||||
gconf_change_set_unref (cs);
|
||||
|
||||
retval = TRUE;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void gnome_wp_props_wp_selected (GtkTreeSelection * selection,
|
||||
GnomeWPCapplet * capplet) {
|
||||
GtkTreeIter iter;
|
||||
|
@ -366,7 +406,7 @@ static void gnome_wp_remove_wp (gchar * key, GnomeWPItem * item,
|
|||
}
|
||||
|
||||
void gnome_wp_main_quit (GnomeWPCapplet * capplet) {
|
||||
g_free (capplet->old_filename);
|
||||
gnome_wp_item_free (capplet->old_item);
|
||||
g_hash_table_foreach (capplet->wphash, (GHFunc) gnome_wp_remove_wp,
|
||||
capplet);
|
||||
|
||||
|
@ -387,6 +427,9 @@ static void wallpaper_properties_clicked (GtkWidget * dialog,
|
|||
wp_properties_help (GTK_WINDOW (dialog),
|
||||
"user-guide.xml", "goscustdesk-7");
|
||||
break;
|
||||
case GTK_RESPONSE_APPLY:
|
||||
gnome_wp_props_wp_set (capplet);
|
||||
break;
|
||||
case GTK_RESPONSE_OK:
|
||||
if (gnome_wp_props_wp_set (capplet)) {
|
||||
/*
|
||||
|
@ -396,8 +439,18 @@ static void wallpaper_properties_clicked (GtkWidget * dialog,
|
|||
*/
|
||||
usleep (1400000);
|
||||
}
|
||||
gtk_widget_destroy (dialog);
|
||||
gnome_wp_main_quit (capplet);
|
||||
break;
|
||||
case GTK_RESPONSE_DELETE_EVENT:
|
||||
case GTK_RESPONSE_CANCEL: {
|
||||
if (gnome_wp_props_revert (capplet)) {
|
||||
/*
|
||||
Reverting the preferences will also have the same slowness as
|
||||
applying them and quitting, so we need a timeout here as well
|
||||
*/
|
||||
usleep (1400000);
|
||||
}
|
||||
gtk_widget_destroy (dialog);
|
||||
gnome_wp_main_quit (capplet);
|
||||
break;
|
||||
|
@ -595,11 +648,11 @@ static gboolean gnome_wp_load_stuffs (void * data) {
|
|||
else
|
||||
imagepath = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
|
||||
|
||||
capplet->old_filename = g_strdup (uri);
|
||||
g_free (uri);
|
||||
|
||||
item = g_hash_table_lookup (capplet->wphash, imagepath);
|
||||
if (item != NULL && strcmp (style, "none") != 0) {
|
||||
capplet->old_item = gnome_wp_item_dup (item);
|
||||
if (item->deleted == TRUE) {
|
||||
item->deleted = FALSE;
|
||||
wp_props_load_wallpaper (item->filename, item, capplet);
|
||||
|
@ -632,6 +685,10 @@ static gboolean gnome_wp_load_stuffs (void * data) {
|
|||
|
||||
if (!strcmp (style, "none")) {
|
||||
gnome_wp_capplet_scroll_to_item (capplet, item);
|
||||
if (capplet->old_item)
|
||||
gnome_wp_item_free (capplet->old_item);
|
||||
|
||||
capplet->old_item = gnome_wp_item_dup (item);
|
||||
}
|
||||
}
|
||||
g_free (imagepath);
|
||||
|
|
|
@ -73,11 +73,10 @@ struct _GnomeWPCapplet {
|
|||
GtkWidget * image;
|
||||
|
||||
/*
|
||||
This is here to compare against when OK is pressed so that we can avoid
|
||||
the 1.4 second timeout for Nautilus to actually give visual feedback,
|
||||
when the filename didn't change
|
||||
The GnomeWPItem of the wallpaper we were
|
||||
already set to on startup
|
||||
*/
|
||||
gchar * old_filename;
|
||||
GnomeWPItem * old_item;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -96,6 +96,10 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
|
|||
GnomeWPInfo * gnome_wp_info_dup (const GnomeWPInfo * info) {
|
||||
GnomeWPInfo * new;
|
||||
|
||||
if (info == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new = g_new0 (GnomeWPInfo, 1);
|
||||
|
||||
new->uri = g_strdup (info->uri);
|
||||
|
|
|
@ -109,6 +109,44 @@ void gnome_wp_item_free (GnomeWPItem * item) {
|
|||
item = NULL;
|
||||
}
|
||||
|
||||
GnomeWPItem * gnome_wp_item_dup (GnomeWPItem * item) {
|
||||
GnomeWPItem * new_item;
|
||||
GdkColor color1, color2;
|
||||
|
||||
if (item == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_item = g_new0 (GnomeWPItem, 1);
|
||||
|
||||
new_item->name = g_strdup (item->name);
|
||||
new_item->filename = g_strdup (item->filename);
|
||||
new_item->description = g_strdup (item->description);
|
||||
new_item->imguri = g_strdup (item->imguri);
|
||||
new_item->options = g_strdup (item->options);
|
||||
new_item->shade_type = g_strdup (item->shade_type);
|
||||
|
||||
new_item->pri_color = g_strdup (item->pri_color);
|
||||
new_item->sec_color = g_strdup (item->sec_color);
|
||||
|
||||
gdk_color_parse (item->pri_color, &color1);
|
||||
gdk_color_parse (item->sec_color, &color2);
|
||||
|
||||
item->pcolor = gdk_color_copy (&color1);
|
||||
item->scolor = gdk_color_copy (&color2);
|
||||
|
||||
new_item->fileinfo = gnome_wp_info_dup (item->fileinfo);
|
||||
new_item->uriinfo = gnome_wp_info_dup (item->uriinfo);
|
||||
|
||||
new_item->rowref = gtk_tree_row_reference_copy (item->rowref);
|
||||
|
||||
new_item->deleted = item->deleted;
|
||||
new_item->width = item->width;
|
||||
new_item->height = item->height;
|
||||
|
||||
return new_item;
|
||||
}
|
||||
|
||||
static void collect_save_options (GdkPixbuf * pixbuf,
|
||||
gchar *** keys,
|
||||
gchar *** vals,
|
||||
|
|
|
@ -62,6 +62,7 @@ GnomeWPItem * gnome_wp_item_new (const gchar * filename,
|
|||
GHashTable * wallpapers,
|
||||
GnomeThumbnailFactory * thumbnails);
|
||||
void gnome_wp_item_free (GnomeWPItem * item);
|
||||
GnomeWPItem * gnome_wp_item_dup (GnomeWPItem * item);
|
||||
GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
|
||||
GnomeThumbnailFactory * thumbs);
|
||||
void gnome_wp_item_update_description (GnomeWPItem * item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue