From 7bbf1f995318dfc2a270e56db473042064964b81 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Fri, 28 Apr 2006 19:03:07 +0000 Subject: [PATCH] - Added option to save current background when saving a custom theme. 2006-04-28 Thomas Wood * gnome-theme-save.c: (write_theme_to_disk), (save_theme_to_disk), (save_dialog_response): * theme-properties.glade: - Added option to save current background when saving a custom theme. Fixes bug 330302 - Saved themes should remember wallpaper. - Also implements some of the UI changes for the save dialog, suggested in bug 100622 --- capplets/theme-switcher/ChangeLog | 11 + capplets/theme-switcher/gnome-theme-save.c | 25 +- .../theme-switcher/theme-properties.glade | 298 ++++++++---------- 3 files changed, 159 insertions(+), 175 deletions(-) diff --git a/capplets/theme-switcher/ChangeLog b/capplets/theme-switcher/ChangeLog index acb02ffbd..61d352c7b 100644 --- a/capplets/theme-switcher/ChangeLog +++ b/capplets/theme-switcher/ChangeLog @@ -1,3 +1,14 @@ +2006-04-28 Thomas Wood + + * gnome-theme-save.c: (write_theme_to_disk), (save_theme_to_disk), + (save_dialog_response): + * theme-properties.glade: + + - Added option to save current background when saving a custom theme. + Fixes bug 330302 - Saved themes should remember wallpaper. + - Also implements some of the UI changes for the save dialog, suggested + in bug 100622 + 2006-04-27 Thomas Wood * gnome-theme-save.c: (str_remove_slash), diff --git a/capplets/theme-switcher/gnome-theme-save.c b/capplets/theme-switcher/gnome-theme-save.c index b3879cf90..325edf430 100644 --- a/capplets/theme-switcher/gnome-theme-save.c +++ b/capplets/theme-switcher/gnome-theme-save.c @@ -3,6 +3,7 @@ #include "gnome-theme-manager.h" #include "capplet-util.h" #include +#include #include "gnome-theme-save-data.c" @@ -163,6 +164,7 @@ static gboolean write_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info, const gchar *theme_name, const gchar *theme_description, + gboolean save_background, GError **error) { gchar *dir, *theme_name_dir; @@ -170,7 +172,8 @@ write_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info, GnomeVFSURI *target_uri; GnomeVFSHandle *handle = NULL; GnomeVFSFileSize bytes_written; - gchar *str; + gchar *str, *current_background; + GConfClient *client; theme_name_dir = str_remove_slash (theme_name); dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL); @@ -201,6 +204,19 @@ write_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info, gnome_vfs_write (handle, str, strlen (str), &bytes_written); g_free (str); + if (save_background) + { + client = gconf_client_get_default (); + current_background = gconf_client_get_string (client, BACKGROUND_KEY, NULL); + str = g_strdup_printf ("BackgroundImage=%s\n", current_background); + + gnome_vfs_write (handle, str, strlen (str), &bytes_written); + + g_object_unref (client); + g_free (current_background); + g_free (str); + } + gnome_vfs_close (handle); @@ -215,6 +231,7 @@ static gboolean save_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info, const gchar *theme_name, const gchar *theme_description, + gboolean save_background, GError **error) { if (! check_theme_name (theme_name, error)) @@ -223,7 +240,7 @@ save_theme_to_disk (GnomeThemeMetaInfo *meta_theme_info, if (! setup_directory_structure (theme_name, error)) return FALSE; - if (! write_theme_to_disk (meta_theme_info, theme_name, theme_description, error)) + if (! write_theme_to_disk (meta_theme_info, theme_name, theme_description, save_background, error)) return FALSE; return TRUE; @@ -248,6 +265,7 @@ save_dialog_response (GtkWidget *save_dialog, GtkTextIter start_iter; GtkTextIter end_iter; gchar *buffer_text; + gboolean save_background; dialog = gnome_theme_manager_get_theme_dialog (); entry = WID ("save_dialog_entry"); @@ -261,7 +279,8 @@ save_dialog_response (GtkWidget *save_dialog, theme_description = escape_string_and_dup (buffer_text); g_free (buffer_text); meta_theme_info = (GnomeThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog), "meta-theme-info"); - if (! save_theme_to_disk (meta_theme_info, theme_name, theme_description, &error)) + save_background = gtk_toggle_button_get_active (/*GTK_TOGGLE_BUTTON*/ (WID ("save_background_checkbutton"))); + if (! save_theme_to_disk (meta_theme_info, theme_name, theme_description, save_background, &error)) { goto out; } diff --git a/capplets/theme-switcher/theme-properties.glade b/capplets/theme-switcher/theme-properties.glade index fed90a390..e68176b3a 100644 --- a/capplets/theme-switcher/theme-properties.glade +++ b/capplets/theme-switcher/theme-properties.glade @@ -1549,7 +1549,7 @@ - 5 + 6 Save Theme GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -1611,196 +1611,150 @@ - - 5 + + 6 True + 3 + 2 False - 12 + 6 + 12 - + True - gtk-dialog-question - 6 - 0 - 0 - 0 - 0 + True + True + True + 0 + + True + * + True - 0 - False - True + 1 + 2 + 0 + 1 + - + True - False - 6 + _Name: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + save_dialog_entry + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + fill + + + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True - <span size="larger" weight="bold">Save Theme to Disk</span> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + True + True + False + False + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + - - 0 - False - False - - - - - - True - 2 - 2 - False - 6 - 12 - - - - True - True - True - True - 0 - - True - * - True - - - 1 - 2 - 0 - 1 - - - - - - - True - _Theme name: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - save_dialog_entry - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - fill - fill - - - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 1 - 2 - 1 - 2 - - - - - - True - Short _description: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 0 - scrolledwindow1 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 1 - 2 - fill - fill - - - - - 0 - True - True - - 0 - True - True + 1 + 2 + 1 + 2 + + + + + + True + _Description: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + scrolledwindow1 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + fill + + + + + + True + True + Save _Background Image + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 2 + 3 + fill +