simplify (check_color_schemes_enabled): fix check for available symbolic
2007-08-07 Jens Granseuer <jensgr@gmx.net> * appearance-style.c: (update_color_buttons_from_string): simplify (check_color_schemes_enabled): fix check for available symbolic colors and make buttons for unsupported colors insensitive (bug #464081) (color_button_clicked_cb), (style_init): simplify * data/appearance.glade: name the color buttons exactly like their respective color so we don't need to keep two arrays around svn path=/trunk/; revision=7968
This commit is contained in:
parent
9bc42be5e1
commit
197bc958af
3 changed files with 54 additions and 60 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2007-08-07 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
* appearance-style.c: (update_color_buttons_from_string): simplify
|
||||||
|
(check_color_schemes_enabled): fix check for available symbolic colors
|
||||||
|
and make buttons for unsupported colors insensitive (bug #464081)
|
||||||
|
(color_button_clicked_cb), (style_init): simplify
|
||||||
|
|
||||||
|
* data/appearance.glade: name the color buttons exactly like their
|
||||||
|
respective color so we don't need to keep two arrays around
|
||||||
|
|
||||||
2007-08-05 Jens Granseuer <jensgr@gmx.net>
|
2007-08-05 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
* appearance-themes.c: (themes_init): reinstate select-after-realize;
|
* appearance-themes.c: (themes_init): reinstate select-after-realize;
|
||||||
|
|
|
@ -32,6 +32,13 @@ typedef void (* ThumbnailGenFunc) (void *type,
|
||||||
AppearanceData *data,
|
AppearanceData *data,
|
||||||
GDestroyNotify *destroy);
|
GDestroyNotify *destroy);
|
||||||
|
|
||||||
|
static const gchar *symbolic_names[NUM_SYMBOLIC_COLORS] = {
|
||||||
|
"fg_color", "bg_color",
|
||||||
|
"text_color", "base_color",
|
||||||
|
"selected_fg_color", "selected_bg_color",
|
||||||
|
"tooltip_fg_color", "tooltip_bg_color"
|
||||||
|
};
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
find_string_in_model (GtkTreeModel *model, const gchar *value, gint column)
|
find_string_in_model (GtkTreeModel *model, const gchar *value, gint column)
|
||||||
{
|
{
|
||||||
|
@ -161,29 +168,18 @@ cursor_theme_sort_func (GtkTreeModel *model,
|
||||||
static void
|
static void
|
||||||
update_color_buttons_from_string (const gchar *color_scheme, AppearanceData *data)
|
update_color_buttons_from_string (const gchar *color_scheme, AppearanceData *data)
|
||||||
{
|
{
|
||||||
GdkColor color_scheme_colors[8];
|
GdkColor colors[NUM_SYMBOLIC_COLORS];
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
gint i;
|
||||||
|
|
||||||
if (!gnome_theme_color_scheme_parse (color_scheme, color_scheme_colors))
|
if (!gnome_theme_color_scheme_parse (color_scheme, colors))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* now set all the buttons to the correct settings */
|
/* now set all the buttons to the correct settings */
|
||||||
widget = glade_xml_get_widget (data->xml, "fg_colorbutton");
|
for (i = 0; i < NUM_SYMBOLIC_COLORS; ++i) {
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[0]);
|
widget = glade_xml_get_widget (data->xml, symbolic_names[i]);
|
||||||
widget = glade_xml_get_widget (data->xml, "bg_colorbutton");
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &colors[i]);
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[1]);
|
}
|
||||||
widget = glade_xml_get_widget (data->xml, "text_colorbutton");
|
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[2]);
|
|
||||||
widget = glade_xml_get_widget (data->xml, "base_colorbutton");
|
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[3]);
|
|
||||||
widget = glade_xml_get_widget (data->xml, "selected_fg_colorbutton");
|
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[4]);
|
|
||||||
widget = glade_xml_get_widget (data->xml, "selected_bg_colorbutton");
|
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[5]);
|
|
||||||
widget = glade_xml_get_widget (data->xml, "tooltip_fg_colorbutton");
|
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[6]);
|
|
||||||
widget = glade_xml_get_widget (data->xml, "tooltip_bg_colorbutton");
|
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), &color_scheme_colors[7]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -218,7 +214,8 @@ check_color_schemes_enabled (GtkSettings *settings,
|
||||||
gchar *theme = NULL;
|
gchar *theme = NULL;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
GSList *symbolic_colors = NULL;
|
GSList *symbolic_colors = NULL;
|
||||||
gboolean fg, bg, base, text, fg_s, bg_s, enable_colors;
|
gboolean enable_colors = FALSE;
|
||||||
|
gint i;
|
||||||
|
|
||||||
g_object_get (G_OBJECT (settings), "gtk-theme-name", &theme, NULL);
|
g_object_get (G_OBJECT (settings), "gtk-theme-name", &theme, NULL);
|
||||||
filename = gtkrc_find_named (theme);
|
filename = gtkrc_find_named (theme);
|
||||||
|
@ -227,17 +224,18 @@ check_color_schemes_enabled (GtkSettings *settings,
|
||||||
gtkrc_get_details (filename, NULL, &symbolic_colors);
|
gtkrc_get_details (filename, NULL, &symbolic_colors);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
fg = (g_slist_find_custom (symbolic_colors, "fg_color", g_str_equal) != NULL);
|
for (i = 0; i < NUM_SYMBOLIC_COLORS; ++i) {
|
||||||
bg = (g_slist_find_custom (symbolic_colors, "bg_color", g_str_equal) != NULL);
|
gboolean found;
|
||||||
base = (g_slist_find_custom (symbolic_colors, "base_color", g_str_equal) != NULL);
|
|
||||||
text = (g_slist_find_custom (symbolic_colors, "text_color", g_str_equal) != NULL);
|
found = (g_slist_find_custom (symbolic_colors, symbolic_names[i], (GCompareFunc) strcmp) != NULL);
|
||||||
fg_s = (g_slist_find_custom (symbolic_colors, "selected_fg_color", g_str_equal) != NULL);
|
gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, symbolic_names[i]), found);
|
||||||
bg_s = (g_slist_find_custom (symbolic_colors, "selected_bg_color", g_str_equal) != NULL);
|
|
||||||
|
enable_colors |= found;
|
||||||
|
}
|
||||||
|
|
||||||
g_slist_foreach (symbolic_colors, (GFunc) g_free, NULL);
|
g_slist_foreach (symbolic_colors, (GFunc) g_free, NULL);
|
||||||
g_slist_free (symbolic_colors);
|
g_slist_free (symbolic_colors);
|
||||||
|
|
||||||
enable_colors = (fg && bg && base && text && fg_s && bg_s);
|
|
||||||
|
|
||||||
gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "color_scheme_table"), enable_colors);
|
gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "color_scheme_table"), enable_colors);
|
||||||
gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "color_scheme_defaults_button"), enable_colors);
|
gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "color_scheme_defaults_button"), enable_colors);
|
||||||
|
|
||||||
|
@ -250,28 +248,18 @@ check_color_schemes_enabled (GtkSettings *settings,
|
||||||
static void
|
static void
|
||||||
color_button_clicked_cb (GtkWidget *colorbutton, AppearanceData *data)
|
color_button_clicked_cb (GtkWidget *colorbutton, AppearanceData *data)
|
||||||
{
|
{
|
||||||
const gchar *widgets[NUM_SYMBOLIC_COLORS] = {
|
|
||||||
"fg_colorbutton", "bg_colorbutton",
|
|
||||||
"text_colorbutton", "base_colorbutton",
|
|
||||||
"selected_fg_colorbutton", "selected_bg_colorbutton",
|
|
||||||
"tooltip_fg_colorbutton", "tooltip_bg_colorbutton" };
|
|
||||||
const gchar *labels[NUM_SYMBOLIC_COLORS] = {
|
|
||||||
"fg_color", "bg_color",
|
|
||||||
"text_color", "base_color",
|
|
||||||
"selected_fg_color", "selected_bg_color",
|
|
||||||
"tooltip_fg_color", "tooltip_bg_color" };
|
|
||||||
gint i;
|
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GdkColor color;
|
GdkColor color;
|
||||||
GString *scheme = g_string_new (NULL);
|
GString *scheme = g_string_new (NULL);
|
||||||
gchar *colstr;
|
gchar *colstr;
|
||||||
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < NUM_SYMBOLIC_COLORS; ++i) {
|
for (i = 0; i < NUM_SYMBOLIC_COLORS; ++i) {
|
||||||
widget = glade_xml_get_widget (data->xml, widgets[i]);
|
widget = glade_xml_get_widget (data->xml, symbolic_names[i]);
|
||||||
gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &color);
|
gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &color);
|
||||||
|
|
||||||
colstr = gdk_color_to_string (&color);
|
colstr = gdk_color_to_string (&color);
|
||||||
g_string_append_printf (scheme, "%s:%s\n", labels[i], colstr);
|
g_string_append_printf (scheme, "%s:%s\n", symbolic_names[i], colstr);
|
||||||
g_free (colstr);
|
g_free (colstr);
|
||||||
}
|
}
|
||||||
/* remove the last newline */
|
/* remove the last newline */
|
||||||
|
@ -869,6 +857,7 @@ style_init (AppearanceData *data)
|
||||||
GtkWidget *w;
|
GtkWidget *w;
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
gchar *label;
|
gchar *label;
|
||||||
|
gint i;
|
||||||
|
|
||||||
data->gtk_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/gtk-theme-thumbnailing.png", NULL);
|
data->gtk_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/gtk-theme-thumbnailing.png", NULL);
|
||||||
data->window_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/window-theme-thumbnailing.png", NULL);
|
data->window_theme_icon = gdk_pixbuf_new_from_file (GNOMECC_PIXMAP_DIR "/window-theme-thumbnailing.png", NULL);
|
||||||
|
@ -920,14 +909,9 @@ style_init (AppearanceData *data)
|
||||||
|
|
||||||
/* connect signals */
|
/* connect signals */
|
||||||
/* color buttons */
|
/* color buttons */
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "fg_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
for (i = 0; i < NUM_SYMBOLIC_COLORS; ++i)
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "bg_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, symbolic_names[i])), "color-set", (GCallback) color_button_clicked_cb, data);
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "text_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "base_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "selected_fg_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "selected_bg_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "tooltip_fg_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "tooltip_bg_colorbutton")), "color-set", (GCallback) color_button_clicked_cb, data);
|
|
||||||
/* revert button */
|
/* revert button */
|
||||||
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "color_scheme_defaults_button")), "clicked", (GCallback) color_scheme_defaults_button_clicked_cb, data);
|
g_signal_connect (G_OBJECT (glade_xml_get_widget (data->xml, "color_scheme_defaults_button")), "clicked", (GCallback) color_scheme_defaults_button_clicked_cb, data);
|
||||||
/* delete buttons */
|
/* delete buttons */
|
||||||
|
|
|
@ -2008,7 +2008,7 @@ Text only</property>
|
||||||
<property name="column_spacing">12</property>
|
<property name="column_spacing">12</property>
|
||||||
<property name="row_spacing">12</property>
|
<property name="row_spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="tooltip_fg_colorbutton">
|
<widget class="GtkColorButton" id="tooltip_fg_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
|
@ -2023,7 +2023,7 @@ Text only</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="tooltip_bg_colorbutton">
|
<widget class="GtkColorButton" id="tooltip_bg_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
|
@ -2044,7 +2044,7 @@ Text only</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="label" translatable="yes">_Tooltips:</property>
|
<property name="label" translatable="yes">_Tooltips:</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="mnemonic_widget">tooltip_bg_colorbutton</property>
|
<property name="mnemonic_widget">tooltip_bg_color</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">4</property>
|
<property name="top_attach">4</property>
|
||||||
|
@ -2055,7 +2055,7 @@ Text only</property>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="selected_fg_colorbutton">
|
<widget class="GtkColorButton" id="selected_fg_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2069,7 +2069,7 @@ Text only</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="text_colorbutton">
|
<widget class="GtkColorButton" id="text_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2083,7 +2083,7 @@ Text only</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="fg_colorbutton">
|
<widget class="GtkColorButton" id="fg_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2102,7 +2102,7 @@ Text only</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="label" translatable="yes">_Selected items:</property>
|
<property name="label" translatable="yes">_Selected items:</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="mnemonic_widget">selected_bg_colorbutton</property>
|
<property name="mnemonic_widget">selected_bg_color</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">3</property>
|
<property name="top_attach">3</property>
|
||||||
|
@ -2110,7 +2110,7 @@ Text only</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="selected_bg_colorbutton">
|
<widget class="GtkColorButton" id="selected_bg_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2124,7 +2124,7 @@ Text only</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="base_colorbutton">
|
<widget class="GtkColorButton" id="base_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2138,7 +2138,7 @@ Text only</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkColorButton" id="bg_colorbutton">
|
<widget class="GtkColorButton" id="bg_color">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2157,7 +2157,7 @@ Text only</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="label" translatable="yes">_Input boxes:</property>
|
<property name="label" translatable="yes">_Input boxes:</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="mnemonic_widget">base_colorbutton</property>
|
<property name="mnemonic_widget">base_color</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">2</property>
|
<property name="top_attach">2</property>
|
||||||
|
@ -2170,7 +2170,7 @@ Text only</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<property name="label" translatable="yes">_Windows:</property>
|
<property name="label" translatable="yes">_Windows:</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="mnemonic_widget">bg_colorbutton</property>
|
<property name="mnemonic_widget">bg_color</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue