From f0a452b3f7b7c3ca369ed412fa1b1d35a12e572d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sede=F1o?= Date: Sun, 20 Jun 2004 11:02:04 +0000 Subject: [PATCH] (http://bugzilla.gnome.org/show_bug.cgi?id=143958) Revert option added. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2004-06-20 David Sedeņo (http://bugzilla.gnome.org/show_bug.cgi?id=143958) * gnome-theme-manager.c, theme-properties.glade: Revert option added. Two now gboolean global var: 'themes_loaded' to check if its the first time that has cold meta_theme_selection_changed. 'rervert' to known in the same function if the selection has change because a revert. (meta_theme_selection_changed): If it's the same time, save the initial theme in initial_meta_theme_info. If the selection has change because a revert click, set the sensitive of the revert button to false. (revert_theme_clicked): callback for the revert button clicked signal. Set the initial_meta_theme and set sensitive to FALSE. (setup_dialog): Added the revert button to the gtk_size_group, connect the clicked callback and set sensitive initially to FALSE. --- capplets/theme-switcher/ChangeLog | 16 ++++ capplets/theme-switcher/gnome-theme-manager.c | 60 +++++++++++++- .../theme-switcher/theme-properties.glade | 82 +++++++++++++++++-- 3 files changed, 148 insertions(+), 10 deletions(-) diff --git a/capplets/theme-switcher/ChangeLog b/capplets/theme-switcher/ChangeLog index c26b7a862..a1cc0517b 100644 --- a/capplets/theme-switcher/ChangeLog +++ b/capplets/theme-switcher/ChangeLog @@ -1,3 +1,19 @@ +2004-06-20 David Sedeņo + + (http://bugzilla.gnome.org/show_bug.cgi?id=143958) + * gnome-theme-manager.c, theme-properties.glade: Revert option added. + Two now gboolean global var: 'themes_loaded' to check if its the first + time that has cold meta_theme_selection_changed. 'rervert' to known + in the same function if the selection has change because a revert. + (meta_theme_selection_changed): If it's the same time, save the + initial theme in initial_meta_theme_info. If the selection has change + because a revert click, set the sensitive of the revert button + to false. + (revert_theme_clicked): callback for the revert button clicked signal. + Set the initial_meta_theme and set sensitive to FALSE. + (setup_dialog): Added the revert button to the gtk_size_group, connect + the clicked callback and set sensitive initially to FALSE. + 2004-05-27 Padraig O'Briain * theme-properties.glade: Set accessible name for GtkTreeViews diff --git a/capplets/theme-switcher/gnome-theme-manager.c b/capplets/theme-switcher/gnome-theme-manager.c index 70cff3d08..e5f8a4174 100644 --- a/capplets/theme-switcher/gnome-theme-manager.c +++ b/capplets/theme-switcher/gnome-theme-manager.c @@ -62,6 +62,8 @@ static gboolean reload_themes; static gboolean initial_meta_theme_set = FALSE; static GdkPixbuf *default_image = NULL; static GdkPixbuf *broken_image = NULL; +static gboolean themes_loaded = FALSE; +static gboolean reverted = FALSE; static GnomeThemeMetaInfo custom_meta_theme_info; static GnomeThemeMetaInfo initial_meta_theme_info; @@ -534,7 +536,13 @@ meta_theme_selection_changed (GtkTreeSelection *selection, GtkTreeIter iter; gchar *meta_theme_name; GtkTreeModel *model; - + gchar *current_gtk_theme; + gchar *current_window_theme; + gchar *current_icon_theme; + GConfClient *client; + GnomeWindowManager *window_manager; + GnomeWMSettings wm_settings; + if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, @@ -561,8 +569,35 @@ meta_theme_selection_changed (GtkTreeSelection *selection, if (setting_model) return; - if (meta_theme_info) + if (meta_theme_info) gnome_meta_theme_set (meta_theme_info); + + if (!themes_loaded) { + client = gconf_client_get_default (); + + /* Get the settings */ + current_gtk_theme = gconf_client_get_string (client, GTK_THEME_KEY, NULL); + current_icon_theme = gconf_client_get_string (client, ICON_THEME_KEY, NULL); + window_manager = gnome_wm_manager_get_current (gdk_display_get_default_screen (gdk_display_get_default ())); + wm_settings.flags = GNOME_WM_SETTING_THEME; + if (window_manager) { + gnome_window_manager_get_settings (window_manager, &wm_settings); + current_window_theme = g_strdup (wm_settings.theme); + } else + current_window_theme = g_strdup (""); + + initial_meta_theme_info.name = g_strdup ("__Initial Theme__"); + initial_meta_theme_info.gtk_theme_name = g_strdup (current_gtk_theme); + initial_meta_theme_info.metacity_theme_name = g_strdup (current_window_theme); + initial_meta_theme_info.icon_theme_name = g_strdup (current_icon_theme); + themes_loaded = TRUE; + } else { + if (!reverted) { + gtk_widget_set_sensitive(WID("meta_theme_revert_button"),TRUE); + } else { + reverted = FALSE; + } + } } /* This function will adjust the list to reflect the current theme @@ -1080,8 +1115,20 @@ apply_font_clicked (GtkWidget *button, gconf_client_set_string (client, FONT_KEY, meta_theme_info->application_font, NULL); } } - - + +static void +revert_theme_clicked (GtkWidget *button, + gpointer data) +{ + GladeXML *dialog; + + gnome_meta_theme_set(&initial_meta_theme_info); + + dialog = gnome_theme_manager_get_theme_dialog (); + gtk_widget_set_sensitive(WID("meta_theme_revert_button"), FALSE); + reverted = TRUE; +} + static void setup_dialog (GladeXML *dialog) { @@ -1107,14 +1154,19 @@ setup_dialog (GladeXML *dialog) gtk_size_group_add_widget (size_group, WID ("meta_theme_background1_button")); gtk_size_group_add_widget (size_group, WID ("meta_theme_font2_button")); gtk_size_group_add_widget (size_group, WID ("meta_theme_background2_button")); + gtk_size_group_add_widget (size_group, WID ("meta_theme_revert_button")); g_object_unref (size_group); + gtk_widget_set_sensitive(WID("meta_theme_revert_button"),FALSE); + g_signal_connect (G_OBJECT (WID ("meta_theme_install_button")), "clicked", G_CALLBACK (gnome_meta_theme_installer_run_cb), parent); g_signal_connect (G_OBJECT (WID ("meta_theme_details_button")), "clicked", gnome_theme_details_show, NULL); g_signal_connect (G_OBJECT (WID ("meta_theme_font1_button")), "clicked", G_CALLBACK (apply_font_clicked), dialog); + g_signal_connect (G_OBJECT (WID ("meta_theme_revert_button")), "clicked", G_CALLBACK (revert_theme_clicked),NULL); + setup_meta_tree_view (GTK_TREE_VIEW (WID ("meta_theme_treeview")), (GCallback) meta_theme_selection_changed, dialog); diff --git a/capplets/theme-switcher/theme-properties.glade b/capplets/theme-switcher/theme-properties.glade index fc7b52b12..7815bafae 100644 --- a/capplets/theme-switcher/theme-properties.glade +++ b/capplets/theme-switcher/theme-properties.glade @@ -313,6 +313,76 @@ False + + + + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-undo + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Revert + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + 0 @@ -704,9 +774,9 @@ False False True - + theme selection tree - + @@ -981,9 +1051,9 @@ False False True - + theme selection tree - + @@ -1258,9 +1328,9 @@ False False True - + theme selection tree - +