diff --git a/capplets/theme-switcher/ChangeLog b/capplets/theme-switcher/ChangeLog index 222412452..f3b69fe81 100644 --- a/capplets/theme-switcher/ChangeLog +++ b/capplets/theme-switcher/ChangeLog @@ -1,3 +1,22 @@ +2006-11-13 Thomas Wood + + (gnome_theme_installer_run): Open transfer dialog with transient + parent set + + * gnome-theme-details.c: (remove_theme), (color_select), + (toggle_color_scheme_key), (gnome_theme_details_init), + (update_color_buttons_from_string), + (gnome_theme_details_update_from_gconf): + * gnome-theme-installer.c: (gnome_theme_install_from_uri), + * gnome-theme-installer.h: + * gnome-theme-manager.c: (free_all), + (gnome_theme_manager_drag_data_received_cb), (main): + * gnome-theme-manager.h: + * gnome-theme-save.c: (save_dialog_response): + * theme-properties.glade: + + - Add a colours tab to change gtk-color-scheme setting + 2006-10-27 Thomas Wood * gnome-theme-installer.c: (transfer_done_cb): Hopefully fix bug diff --git a/capplets/theme-switcher/gnome-theme-details.c b/capplets/theme-switcher/gnome-theme-details.c index 0ad3bb257..64ebb1a16 100644 --- a/capplets/theme-switcher/gnome-theme-details.c +++ b/capplets/theme-switcher/gnome-theme-details.c @@ -46,6 +46,7 @@ static void load_theme_names (GtkTreeView *tree_view, GList *theme_list, const gchar *default_theme); static char *path_to_theme_id (const char *path); +static void update_color_buttons_from_string (gchar *color_scheme); static char * @@ -433,7 +434,7 @@ remove_theme(GtkWidget *button, gpointer data) GTK_BUTTONS_OK_CANCEL, _("Theme deleted succesfully. Please select another theme.")); gtk_list_store_remove (GTK_LIST_STORE(model), &iter); - gtk_dialog_run (info_dialog); + gtk_dialog_run (GTK_DIALOG (info_dialog)); } else { info_dialog = gtk_message_dialog_new (NULL, @@ -441,7 +442,7 @@ remove_theme(GtkWidget *button, gpointer data) GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Theme can not be deleted")); - gtk_dialog_run (info_dialog); + gtk_dialog_run (GTK_DIALOG (info_dialog)); } gtk_widget_destroy (info_dialog); gnome_vfs_uri_list_free (uri_list); @@ -451,6 +452,80 @@ remove_theme(GtkWidget *button, gpointer data) } } +void +color_select (GtkWidget *colorbutton, gpointer dialog) +{ + GConfClient *client = NULL; + gchar *new_scheme; + GdkColor colors[6]; + gchar *bg, *fg, *text, *base, *selected_fg, *selected_bg; + GtkWidget *widget; + + widget = WID ("fg_colorbutton"); + gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &colors[0]); + widget = WID ("bg_colorbutton"); + gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &colors[1]); + widget = WID ("text_colorbutton"); + gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &colors[2]); + widget = WID ("base_colorbutton"); + gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &colors[3]); + widget = WID ("selected_fg_colorbutton"); + gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &colors[4]); + widget = WID ("selected_bg_colorbutton"); + gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &colors[5]); + + + fg = g_strdup_printf ("fg_color:#%.4x%.4x%.4x\n", colors[0].red, colors[0].green, colors[0].blue); + bg = g_strdup_printf ("bg_color:#%.4x%.4x%.4x\n", colors[1].red, colors[1].green, colors[1].blue); + text = g_strdup_printf ("text_color:#%.4x%.4x%.4x\n", colors[2].red, colors[2].green, colors[2].blue); + base = g_strdup_printf ("base_color:#%.4x%.4x%.4x\n", colors[3].red, colors[3].green, colors[3].blue); + selected_fg = g_strdup_printf ("selected_fg_color:#%.4x%.4x%.4x\n", colors[4].red, colors[4].green, colors[4].blue); + selected_bg = g_strdup_printf ("selected_bg_color:#%.4x%.4x%.4x", colors[5].red, colors[5].green, colors[5].blue); + + new_scheme = g_strconcat (fg, bg, text, base, selected_fg, selected_bg, NULL); + + client = gconf_client_get_default (); + + /* Currently we assume this has only been called when one of the colours has + * actually changed, so we don't check the original key first + */ + gconf_client_set_string (client, COLOR_SCHEME_KEY, new_scheme, NULL); + + g_object_unref (G_OBJECT (client)); + free_all (fg, bg, text, base, selected_fg, selected_bg, new_scheme, NULL); +} + +void +toggle_color_scheme_key (GtkWidget *checkbutton, gpointer *data) +{ + GConfClient *client = NULL; + gboolean use_theme_colors; + GladeXML *dialog; + GtkWidget *widget; + GtkSettings *settings; + gchar *color_scheme = NULL; + + dialog = gnome_theme_manager_get_theme_dialog (); + use_theme_colors = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)); + + widget = WID ("color_scheme_table"); + gtk_widget_set_sensitive (widget, !use_theme_colors); + + if (use_theme_colors) + { + client = gconf_client_get_default (); + gconf_client_set_string (client, COLOR_SCHEME_KEY, "", NULL); + g_object_unref (G_OBJECT (client)); + } + else + { + settings = gtk_settings_get_default (); + g_object_get (G_OBJECT (settings), "gtk-color-scheme", &color_scheme, NULL); + update_color_buttons_from_string (color_scheme); + g_free (color_scheme); + } +} + void gnome_theme_details_init (void) { @@ -492,6 +567,27 @@ gnome_theme_details_init (void) widget = WID ("icon_install_button"); g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (gnome_theme_installer_run_cb), parent); + /* color preferences */ + widget = WID ("fg_colorbutton"); + g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog); + widget = WID ("bg_colorbutton"); + g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog); + widget = WID ("text_colorbutton"); + g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog); + widget = WID ("base_colorbutton"); + g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog); + widget = WID ("selected_fg_colorbutton"); + g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog); + widget = WID ("selected_bg_colorbutton"); + g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog); + + widget = WID ("use_theme_colors_checkbutton"); + g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (toggle_color_scheme_key), parent); + + gchar *color_scheme; + g_object_get (G_OBJECT (gtk_settings_get_default()), "gtk-color-scheme", &color_scheme, NULL); + update_color_buttons_from_string (color_scheme); + g_signal_connect (G_OBJECT (parent), "response", G_CALLBACK (cb_dialog_response), NULL); g_signal_connect (G_OBJECT (parent), "delete-event", G_CALLBACK (gtk_true), NULL); @@ -717,15 +813,86 @@ update_list_something (GtkWidget *tree_view, const gchar *theme) } } +void +update_color_buttons_from_string (gchar *color_scheme) +{ + GdkColor color_scheme_colors[6]; + gchar **color_scheme_strings, **color_scheme_pair, *current_string; + gint i; + GtkWidget *widget; + GladeXML *dialog; + + if (!color_scheme) return; + if (!strcmp (color_scheme, "")) return; + + dialog = gnome_theme_manager_get_theme_dialog (); + + /* The color scheme string consists of name:color pairs, seperated by + * newlines, so first we split the string up by new line */ + + color_scheme_strings = g_strsplit (color_scheme, "\n", 0); + + /* loop through the name:color pairs, and save the colour if we recognise the name */ + i = 0; + while ((current_string = color_scheme_strings[i++])) + { + color_scheme_pair = g_strsplit (current_string, ":", 0); + + if (color_scheme_pair[0] == NULL) + continue; + + g_strstrip (color_scheme_pair[0]); + g_strstrip (color_scheme_pair[1]); + + + if (!strcmp ("fg_color", color_scheme_pair[0])) + gdk_color_parse (color_scheme_pair[1], &color_scheme_colors[0]); + else if (!strcmp ("bg_color", color_scheme_pair[0])) + gdk_color_parse (color_scheme_pair[1], &color_scheme_colors[1]); + else if (!strcmp ("text_color", color_scheme_pair[0])) + gdk_color_parse (color_scheme_pair[1], &color_scheme_colors[2]); + else if (!strcmp ("base_color", color_scheme_pair[0])) + gdk_color_parse (color_scheme_pair[1], &color_scheme_colors[3]); + else if (!strcmp ("selected_fg_color", color_scheme_pair[0])) + gdk_color_parse (color_scheme_pair[1], &color_scheme_colors[4]); + else if (!strcmp ("selected_bg_color", color_scheme_pair[0])) + gdk_color_parse (color_scheme_pair[1], &color_scheme_colors[5]); + + g_strfreev (color_scheme_pair); + } + + g_strfreev (color_scheme_strings); + + /* not sure whether we need to do this, but it can't hurt */ + for (i = 0; i < 6; i++) + gdk_colormap_alloc_color (gdk_colormap_get_system (), &color_scheme_colors[i], FALSE, TRUE); + + /* now set all the buttons to the correct settings */ + widget = WID ("fg_colorbutton"); + gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[0]); + widget = WID ("bg_colorbutton"); + gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[1]); + widget = WID ("text_colorbutton"); + gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[2]); + widget = WID ("base_colorbutton"); + gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[3]); + widget = WID ("selected_fg_colorbutton"); + gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[4]); + widget = WID ("selected_bg_colorbutton"); + gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[5]); + +} + void gnome_theme_details_update_from_gconf (void) { GConfClient *client; GladeXML *dialog; - GtkWidget *tree_view; - gchar *theme; + GtkWidget *tree_view, *widget; + gchar *theme = NULL; GnomeWindowManager *window_manager = NULL; GnomeWMSettings wm_settings; + gboolean use_theme_colors = TRUE; gnome_theme_details_init (); @@ -750,6 +917,25 @@ gnome_theme_details_update_from_gconf (void) tree_view = WID ("icon_theme_treeview"); theme = gconf_client_get_string (client, ICON_THEME_KEY, NULL); update_list_something (tree_view, theme); - g_object_unref (client); g_free (theme); + + + /* color preferences */ + + theme = gconf_client_get_string (client, COLOR_SCHEME_KEY, NULL); + if (theme) + { + use_theme_colors = !strcmp ("", theme); + update_color_buttons_from_string (theme); + g_free (theme); + } + + widget = WID ("use_theme_colors_checkbutton"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), use_theme_colors); + + widget = WID ("color_scheme_table"); + gtk_widget_set_sensitive (widget, !use_theme_colors); + + + g_object_unref (client); } diff --git a/capplets/theme-switcher/gnome-theme-installer.c b/capplets/theme-switcher/gnome-theme-installer.c index 4b169556b..fc3b57516 100644 --- a/capplets/theme-switcher/gnome-theme-installer.c +++ b/capplets/theme-switcher/gnome-theme-installer.c @@ -511,7 +511,7 @@ transfer_done_cb (GtkWidget *dlg, gchar *path) } void -gnome_theme_install_from_uri (gchar * theme_filename) +gnome_theme_install_from_uri (gchar * theme_filename, GtkWindow *parent) { GtkWidget *dlg; gchar *filename, *path, *base; @@ -627,7 +627,7 @@ gnome_theme_install_from_uri (gchar * theme_filename) target = g_list_append (NULL, gnome_vfs_uri_new (path)); - dlg = file_transfer_dialog_new (); + dlg = file_transfer_dialog_new_with_parent (parent); file_transfer_dialog_wrap_async_xfer (FILE_TRANSFER_DIALOG (dlg), src, target, GNOME_VFS_XFER_RECURSIVE, @@ -676,7 +676,7 @@ gnome_theme_installer_run (GtkWindow *parent, gchar *filename) if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { filename_selected = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - gnome_theme_install_from_uri (filename_selected); + gnome_theme_install_from_uri (filename_selected, parent); g_free (filename_selected); } diff --git a/capplets/theme-switcher/gnome-theme-installer.h b/capplets/theme-switcher/gnome-theme-installer.h index fdd31f5a8..448d541aa 100644 --- a/capplets/theme-switcher/gnome-theme-installer.h +++ b/capplets/theme-switcher/gnome-theme-installer.h @@ -24,7 +24,7 @@ #include -void gnome_theme_install_from_uri (gchar * filename); +void gnome_theme_install_from_uri (gchar * filename, GtkWindow *parent); void gnome_theme_installer_run (GtkWindow *parent, gchar *filename); void gnome_theme_installer_run_cb (GtkWidget *button, GtkWindow *parent_window); diff --git a/capplets/theme-switcher/gnome-theme-manager.c b/capplets/theme-switcher/gnome-theme-manager.c index 7652fad17..38e48e22c 100644 --- a/capplets/theme-switcher/gnome-theme-manager.c +++ b/capplets/theme-switcher/gnome-theme-manager.c @@ -117,6 +117,17 @@ typedef struct { gboolean cancelled; } PixbufAsyncData; +void free_all (gpointer a, ...) +{ + va_list list; + gpointer tmp; + va_start (list, a); + while ((tmp = va_arg (list, gpointer))) + g_free(tmp); + va_end (list); +} + + static void pixbuf_async_func (GdkPixbuf *pixbuf, gpointer data) @@ -1531,6 +1542,7 @@ gnome_theme_manager_drag_data_received_cb (GtkWidget *widget, GdkDragContext *co { GList *uris; gchar *filename = NULL; + GtkWidget *toplevel; if (!(info == TARGET_URI_LIST || info == TARGET_NS_URL)) return; @@ -1550,8 +1562,10 @@ gnome_theme_manager_drag_data_received_cb (GtkWidget *widget, GdkDragContext *co gnome_vfs_uri_list_unref (uris); } - - gnome_theme_install_from_uri (filename); + toplevel = gtk_widget_get_toplevel (widget); + if (!GTK_WIDGET_TOPLEVEL (toplevel)) + toplevel = NULL; + gnome_theme_install_from_uri (filename, GTK_WINDOW (toplevel)); g_free (filename); } @@ -1620,7 +1634,7 @@ main (int argc, char *argv[]) NULL); if (install_filename != NULL) - gnome_theme_install_from_uri (install_filename); + gnome_theme_install_from_uri (install_filename, NULL); g_free (install_filename); gtk_theme_default_name = get_default_string_from_key (GTK_THEME_KEY); diff --git a/capplets/theme-switcher/gnome-theme-manager.h b/capplets/theme-switcher/gnome-theme-manager.h index 44c57c7ee..205971830 100644 --- a/capplets/theme-switcher/gnome-theme-manager.h +++ b/capplets/theme-switcher/gnome-theme-manager.h @@ -12,6 +12,7 @@ #define MONOSPACE_FONT_KEY "/desktop/gnome/interface/monospace_font_name" #define BACKGROUND_KEY "/desktop/gnome/background/picture_filename" #define LOCKDOWN_KEY "/desktop/gnome/lockdown/disable_theme_settings" +#define COLOR_SCHEME_KEY "/desktop/gnome/interface/gtk_color_scheme" #define METACITY_THEME_DIR "/apps/metacity/general" #define METACITY_THEME_KEY METACITY_THEME_DIR "/theme" @@ -80,6 +81,6 @@ void gnome_theme_manager_drag_data_received_cb (GtkWidget *widge gpointer data); - +void free_all (gpointer, ...); #endif /* __GNOME_THEME_MANAGER_H__ */ diff --git a/capplets/theme-switcher/gnome-theme-save.c b/capplets/theme-switcher/gnome-theme-save.c index 325edf430..f27de7e0d 100644 --- a/capplets/theme-switcher/gnome-theme-save.c +++ b/capplets/theme-switcher/gnome-theme-save.c @@ -279,7 +279,7 @@ 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"); - save_background = gtk_toggle_button_get_active (/*GTK_TOGGLE_BUTTON*/ (WID ("save_background_checkbutton"))); + 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 498bd464a..2a12a0148 100644 --- a/capplets/theme-switcher/theme-properties.glade +++ b/capplets/theme-switcher/theme-properties.glade @@ -898,6 +898,7 @@ True + True GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_SHADOW_IN @@ -1125,6 +1126,334 @@ + + + 12 + True + False + 0 + + + + True + True + Use colors from the current theme + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 12 + True + 4 + 3 + False + 12 + 12 + + + + True + Text + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Background + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + Input + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Selection + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + False + True + + + 2 + 3 + 1 + 2 + + + + + + + + True + True + False + True + + + 1 + 2 + 3 + 4 + + + + + + + + True + True + False + True + + + 2 + 3 + 3 + 4 + + + + + + + + True + True + False + True + + + 2 + 3 + 2 + 3 + + + + + + + + True + True + False + True + + + 1 + 2 + 2 + 3 + + + + + + + + True + True + False + True + + + 1 + 2 + 1 + 2 + + + + + + + + True + Normal + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + + 0 + True + True + + + + + False + True + + + + + + True + Colours + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + 12