From 4622d5ed516ace5bec8485668d00d703abb434e4 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Sat, 11 Feb 2006 06:08:03 +0000 Subject: [PATCH] Replace the Apply/Cancel/OK buttons with a Finish button, using the stock 2006-02-09 Rodney Dawes * gnome-background-properties.glade: Replace the Apply/Cancel/OK buttons with a Finish button, using the stock apply icon * gnome-wp-capplet.c (gnome_wp_props_wp_set): Don't need to check if we are the same image as we were before now (gnome_wp_props_revert): Remove this as it is no longer needed (gnome_wp_props_wp_selected): Call the set function here (gnome_wp_main_quit): Remove the freeing of capplet->old_item (wallpaper_properties_clicked): Only handle GTK_RESPONSE_OK as an action to close the dialog now, as we are instant apply again (gnome_wp_scale_type_changed, gnome_wp_shade_type_changed): (gnome_wp_color_changed): Set the appropriate gconf keys here (gnome_wp_load_stuffs): Remove references to capplet->old_item * gnome-wp-capplet.h (struct _GnomeWPCapplet): Remove old_item object Fixes #327335, #330587 and #329818 Partially fixes #330168 --- capplets/background/ChangeLog | 21 +++ .../gnome-background-properties.glade | 92 ++++++++---- capplets/background/gnome-wp-capplet.c | 139 +++++------------- capplets/background/gnome-wp-capplet.h | 6 - 4 files changed, 123 insertions(+), 135 deletions(-) diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index af04f06a4..2fb714deb 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,24 @@ +2006-02-09 Rodney Dawes + + * gnome-background-properties.glade: Replace the Apply/Cancel/OK + buttons with a Finish button, using the stock apply icon + + * gnome-wp-capplet.c (gnome_wp_props_wp_set): Don't need to check if + we are the same image as we were before now + (gnome_wp_props_revert): Remove this as it is no longer needed + (gnome_wp_props_wp_selected): Call the set function here + (gnome_wp_main_quit): Remove the freeing of capplet->old_item + (wallpaper_properties_clicked): Only handle GTK_RESPONSE_OK as an + action to close the dialog now, as we are instant apply again + (gnome_wp_scale_type_changed, gnome_wp_shade_type_changed): + (gnome_wp_color_changed): Set the appropriate gconf keys here + (gnome_wp_load_stuffs): Remove references to capplet->old_item + + * gnome-wp-capplet.h (struct _GnomeWPCapplet): Remove old_item object + + Fixes #327335, #330587 and #329818 + Partially fixes #330168 + 2006-01-26 Rodney Dawes * gnome-wp-capplet.c (gnome_wp_capplet_scroll_to_item): If we are diff --git a/capplets/background/gnome-background-properties.glade b/capplets/background/gnome-background-properties.glade index fa5b7700e..5fdcb093f 100644 --- a/capplets/background/gnome-background-properties.glade +++ b/capplets/background/gnome-background-properties.glade @@ -47,42 +47,78 @@ - - - True - True - True - gtk-apply - True - GTK_RELIEF_NORMAL - True - -10 - - - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - True True True - gtk-ok - True GTK_RELIEF_NORMAL True -5 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-apply + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Finish + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + diff --git a/capplets/background/gnome-wp-capplet.c b/capplets/background/gnome-wp-capplet.c index c54e1bf17..34ed57155 100644 --- a/capplets/background/gnome-wp-capplet.c +++ b/capplets/background/gnome-wp-capplet.c @@ -278,7 +278,6 @@ static gboolean gnome_wp_props_wp_set (GnomeWPCapplet * capplet) { GnomeWPItem * item; GConfChangeSet * cs; gchar * wpfile; - gboolean retval = FALSE; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (capplet->treeview)); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { @@ -286,79 +285,38 @@ static gboolean gnome_wp_props_wp_set (GnomeWPCapplet * capplet) { item = g_hash_table_lookup (capplet->wphash, wpfile); - if (g_utf8_collate (capplet->old_item->filename, wpfile) != 0) { - cs = gconf_change_set_new (); + 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; + 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; - 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); + 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_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; + 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); + g_free (wpfile); } - 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; + return FALSE; } static void gnome_wp_props_wp_selected (GtkTreeSelection * selection, @@ -389,6 +347,8 @@ static void gnome_wp_props_wp_selected (GtkTreeSelection * selection, } else { gtk_widget_set_sensitive (capplet->rm_button, FALSE); } + + gnome_wp_props_wp_set (capplet); } static void gnome_wp_remove_wp (gchar * key, GnomeWPItem * item, @@ -408,9 +368,7 @@ static void gnome_wp_remove_wp (gchar * key, GnomeWPItem * item, } void gnome_wp_main_quit (GnomeWPCapplet * capplet) { - gnome_wp_item_free (capplet->old_item); - g_hash_table_foreach (capplet->wphash, (GHFunc) gnome_wp_remove_wp, - capplet); + g_hash_table_foreach (capplet->wphash, (GHFunc) gnome_wp_remove_wp, capplet); gnome_wp_xml_save_list (capplet); @@ -429,34 +387,10 @@ 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)) { - /* - This is here because applying the background is about 1.4 seconds - slow, with nautilus managing the desktop on my Radeon 7500 - Without nautilus, this is about 600000 usecs - */ - 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; - } } } @@ -505,6 +439,8 @@ static void gnome_wp_scale_type_changed (GtkOptionMenu * option_menu, 0, pixbuf, -1); g_object_unref (pixbuf); + gconf_client_set_string (capplet->client, WP_OPTIONS_KEY, + item->options, NULL); } static void gnome_wp_shade_type_changed (GtkOptionMenu * option_menu, @@ -550,6 +486,8 @@ static void gnome_wp_shade_type_changed (GtkOptionMenu * option_menu, 0, pixbuf, -1); g_object_unref (pixbuf); + gconf_client_set_string (capplet->client, WP_SHADING_KEY, + item->shade_type, NULL); } static void gnome_wp_color_changed (GnomeWPCapplet * capplet, @@ -591,6 +529,13 @@ static void gnome_wp_color_changed (GnomeWPCapplet * capplet, item->scolor->green >> 8, item->scolor->blue >> 8); + if (update) { + gconf_client_set_string (capplet->client, WP_PCOLOR_KEY, + item->pri_color, NULL); + gconf_client_set_string (capplet->client, WP_SCOLOR_KEY, + item->sec_color, NULL); + } + gnome_wp_shade_type_changed (NULL, capplet); } @@ -654,7 +599,6 @@ static gboolean gnome_wp_load_stuffs (void * data) { 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); @@ -687,10 +631,6 @@ 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); @@ -701,9 +641,6 @@ static gboolean gnome_wp_load_stuffs (void * data) { g_slist_free (capplet->uri_list); } - if (capplet->old_item == NULL && item != NULL) - capplet->old_item = gnome_wp_item_dup (item); - return FALSE; } diff --git a/capplets/background/gnome-wp-capplet.h b/capplets/background/gnome-wp-capplet.h index f2ef256d2..30a005b8d 100644 --- a/capplets/background/gnome-wp-capplet.h +++ b/capplets/background/gnome-wp-capplet.h @@ -71,12 +71,6 @@ struct _GnomeWPCapplet { /* File Chooser Dialog */ GtkWidget * filesel; GtkWidget * image; - - /* - The GnomeWPItem of the wallpaper we were - already set to on startup - */ - GnomeWPItem * old_item; }; typedef enum {