Add a Revert button to the color schemes tab
2007-01-19 Thomas Wood <thos@gnome.org> * gnome-theme-details.c: (update_color_scheme_tab), (gnome_theme_details_update_from_gconf): * gnome-theme-manager.c: (gtk_theme_key_changed): * theme-properties.glade: Add a Revert button to the color schemes tab svn path=/trunk/; revision=7156
This commit is contained in:
parent
35dff218e8
commit
2748e5206c
4 changed files with 60 additions and 81 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-01-19 Thomas Wood <thos@gnome.org>
|
||||||
|
|
||||||
|
* gnome-theme-details.c: (update_color_scheme_tab),
|
||||||
|
(gnome_theme_details_update_from_gconf):
|
||||||
|
* gnome-theme-manager.c: (gtk_theme_key_changed):
|
||||||
|
* theme-properties.glade:
|
||||||
|
|
||||||
|
Add a Revert button to the color schemes tab
|
||||||
|
|
||||||
2007-01-19 Thomas Wood <thos@gnome.org>
|
2007-01-19 Thomas Wood <thos@gnome.org>
|
||||||
|
|
||||||
* gnome-theme-details.c: (update_color_scheme_tab), (color_select),
|
* gnome-theme-details.c: (update_color_scheme_tab), (color_select),
|
||||||
|
|
|
@ -49,7 +49,7 @@ static void load_theme_names (GtkTreeView *tree_view,
|
||||||
static char *path_to_theme_id (const char *path);
|
static char *path_to_theme_id (const char *path);
|
||||||
static void update_color_buttons_from_string (gchar *color_scheme);
|
static void update_color_buttons_from_string (gchar *color_scheme);
|
||||||
|
|
||||||
void toggle_color_scheme_key (GtkWidget *checkbutton, gpointer *data);
|
void revert_color_scheme_key (GtkWidget *checkbutton, gpointer *data);
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
path_to_theme_id (const char *path)
|
path_to_theme_id (const char *path)
|
||||||
|
@ -227,20 +227,14 @@ update_color_scheme_tab ()
|
||||||
bg_s = (g_slist_find_custom (symbolic_colors, "selected_bg_color", g_str_equal) != NULL);
|
bg_s = (g_slist_find_custom (symbolic_colors, "selected_bg_color", g_str_equal) != NULL);
|
||||||
|
|
||||||
enable_colors = (fg && bg && base && text && fg_s && bg_s);
|
enable_colors = (fg && bg && base && text && fg_s && bg_s);
|
||||||
gtk_widget_set_sensitive (WID ("enable_custom_colors_checkbutton"), enable_colors);
|
|
||||||
|
gtk_widget_set_sensitive (WID ("color_scheme_table"), enable_colors);
|
||||||
|
gtk_widget_set_sensitive (WID ("color_scheme_revert_button"), enable_colors);
|
||||||
|
|
||||||
if (enable_colors)
|
if (enable_colors)
|
||||||
{
|
|
||||||
gboolean enable_color_schemes;
|
|
||||||
enable_color_schemes = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("enable_custom_colors_checkbutton")));
|
|
||||||
gtk_widget_set_sensitive (WID ("color_scheme_table"), enable_color_schemes);
|
|
||||||
gtk_widget_hide (WID ("color_scheme_message_hbox"));
|
gtk_widget_hide (WID ("color_scheme_message_hbox"));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gtk_widget_show (WID ("color_scheme_message_hbox"));
|
gtk_widget_show (WID ("color_scheme_message_hbox"));
|
||||||
gtk_widget_set_sensitive (WID ("color_scheme_table"), FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
g_free (theme_name);
|
g_free (theme_name);
|
||||||
|
@ -256,6 +250,8 @@ gtk_theme_selection_changed (GtkTreeSelection *selection,
|
||||||
|
|
||||||
update_gconf_key_from_selection (selection, GTK_THEME_KEY);
|
update_gconf_key_from_selection (selection, GTK_THEME_KEY);
|
||||||
gtk_theme_update_remove_button(selection, WID("control_remove_button"), THEME_GTK);
|
gtk_theme_update_remove_button(selection, WID("control_remove_button"), THEME_GTK);
|
||||||
|
|
||||||
|
update_color_scheme_tab ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -549,38 +545,18 @@ color_select (GtkWidget *colorbutton, GladeXML *dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggle_color_scheme_key (GtkWidget *checkbutton, gpointer *data)
|
revert_color_scheme_key (GtkWidget *checkbutton, gpointer *data)
|
||||||
{
|
{
|
||||||
GConfClient *client = NULL;
|
GConfClient *client = NULL;
|
||||||
gboolean use_custom_colors;
|
|
||||||
GladeXML *dialog;
|
GladeXML *dialog;
|
||||||
GtkSettings *settings;
|
|
||||||
gchar *color_scheme = NULL;
|
|
||||||
|
|
||||||
dialog = gnome_theme_manager_get_theme_dialog ();
|
dialog = gnome_theme_manager_get_theme_dialog ();
|
||||||
use_custom_colors = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton));
|
|
||||||
|
|
||||||
gtk_widget_set_sensitive (WID ("color_scheme_table"), use_custom_colors);
|
client = gconf_client_get_default ();
|
||||||
|
gconf_client_set_string (client, COLOR_SCHEME_KEY, "", NULL);
|
||||||
|
g_object_unref (G_OBJECT (client));
|
||||||
|
|
||||||
if (!use_custom_colors)
|
gnome_theme_details_update_from_gconf ();
|
||||||
{
|
|
||||||
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
|
|
||||||
theme_notebook_changed_page (GtkWidget *widget, GladeXML *dialog)
|
|
||||||
{
|
|
||||||
update_color_scheme_tab ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -588,7 +564,7 @@ gnome_theme_details_init (void)
|
||||||
{
|
{
|
||||||
GtkWidget *parent, *widget;
|
GtkWidget *parent, *widget;
|
||||||
GladeXML *dialog;
|
GladeXML *dialog;
|
||||||
gchar *color_scheme;
|
gchar *theme;
|
||||||
|
|
||||||
if (theme_details_initted)
|
if (theme_details_initted)
|
||||||
return;
|
return;
|
||||||
|
@ -639,13 +615,11 @@ gnome_theme_details_init (void)
|
||||||
widget = WID ("selected_bg_colorbutton");
|
widget = WID ("selected_bg_colorbutton");
|
||||||
g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog);
|
g_signal_connect (G_OBJECT (widget), "color_set", G_CALLBACK (color_select), dialog);
|
||||||
|
|
||||||
widget = WID ("enable_custom_colors_checkbutton");
|
widget = WID ("color_scheme_revert_button");
|
||||||
g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (toggle_color_scheme_key), parent);
|
g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (revert_color_scheme_key), parent);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (WID ("theme_notebook")), "switch-page", G_CALLBACK (theme_notebook_changed_page), dialog);
|
g_object_get (G_OBJECT (gtk_settings_get_default()), "gtk-color-scheme", &theme, NULL);
|
||||||
|
update_color_buttons_from_string (theme);
|
||||||
g_object_get (G_OBJECT (gtk_settings_get_default()), "gtk-color-scheme", &color_scheme, NULL);
|
|
||||||
update_color_buttons_from_string (color_scheme);
|
|
||||||
|
|
||||||
/* general signals */
|
/* general signals */
|
||||||
g_signal_connect (G_OBJECT (parent), "response", G_CALLBACK (cb_dialog_response), NULL);
|
g_signal_connect (G_OBJECT (parent), "response", G_CALLBACK (cb_dialog_response), NULL);
|
||||||
|
@ -940,6 +914,7 @@ update_color_buttons_from_string (gchar *color_scheme)
|
||||||
widget = WID ("selected_bg_colorbutton");
|
widget = WID ("selected_bg_colorbutton");
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[5]);
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[5]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -947,11 +922,10 @@ gnome_theme_details_update_from_gconf (void)
|
||||||
{
|
{
|
||||||
GConfClient *client;
|
GConfClient *client;
|
||||||
GladeXML *dialog;
|
GladeXML *dialog;
|
||||||
GtkWidget *tree_view, *widget;
|
GtkWidget *tree_view;
|
||||||
gchar *theme = NULL;
|
gchar *theme = NULL;
|
||||||
GnomeWindowManager *window_manager = NULL;
|
GnomeWindowManager *window_manager = NULL;
|
||||||
GnomeWMSettings wm_settings;
|
GnomeWMSettings wm_settings;
|
||||||
gboolean use_custom_colors = FALSE;
|
|
||||||
|
|
||||||
gnome_theme_details_init ();
|
gnome_theme_details_init ();
|
||||||
|
|
||||||
|
@ -978,23 +952,15 @@ gnome_theme_details_update_from_gconf (void)
|
||||||
update_list_something (tree_view, theme);
|
update_list_something (tree_view, theme);
|
||||||
g_free (theme);
|
g_free (theme);
|
||||||
|
|
||||||
|
/* update colour scheme tab */
|
||||||
/* color preferences */
|
|
||||||
|
|
||||||
theme = gconf_client_get_string (client, COLOR_SCHEME_KEY, NULL);
|
theme = gconf_client_get_string (client, COLOR_SCHEME_KEY, NULL);
|
||||||
if (theme)
|
/* if gconf string is not present, we need to look in gtk settings for a value */
|
||||||
{
|
if (theme == NULL || strcmp (theme, ""))
|
||||||
use_custom_colors = strcmp ("", theme);
|
g_object_get (G_OBJECT (gtk_settings_get_default()), "gtk-color-scheme", &theme, NULL);
|
||||||
update_color_buttons_from_string (theme);
|
update_color_buttons_from_string (theme);
|
||||||
g_free (theme);
|
g_free (theme);
|
||||||
}
|
|
||||||
|
|
||||||
widget = WID ("enable_custom_colors_checkbutton");
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), use_custom_colors);
|
|
||||||
|
|
||||||
widget = WID ("color_scheme_table");
|
|
||||||
gtk_widget_set_sensitive (widget, use_custom_colors);
|
|
||||||
|
|
||||||
|
update_color_scheme_tab ();
|
||||||
|
|
||||||
g_object_unref (client);
|
g_object_unref (client);
|
||||||
}
|
}
|
||||||
|
|
|
@ -979,9 +979,7 @@ gtk_theme_key_changed (GConfClient *client,
|
||||||
GConfEntry *entry,
|
GConfEntry *entry,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
// if (strcmp (entry->key, GTK_THEME_KEY))
|
/* this is called when the gtk theme name or gtk color scheme changes */
|
||||||
// return;
|
|
||||||
|
|
||||||
update_settings_from_gconf ();
|
update_settings_from_gconf ();
|
||||||
gnome_theme_details_update_from_gconf ();
|
gnome_theme_details_update_from_gconf ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1188,25 +1188,6 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkCheckButton" id="enable_custom_colors_checkbutton">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">_Enable custom colors</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="active">False</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">6</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="color_scheme_table">
|
<widget class="GtkTable" id="color_scheme_table">
|
||||||
<property name="border_width">12</property>
|
<property name="border_width">12</property>
|
||||||
|
@ -1468,6 +1449,31 @@
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||||
|
<property name="spacing">0</property>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="color_scheme_revert_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_default">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label">gtk-revert-to-saved</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
|
<property name="focus_on_click">True</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="padding">0</property>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="tab_expand">False</property>
|
<property name="tab_expand">False</property>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue