minor cleanup and getting rid of unnecessary casts
2007-05-16 Jens Granseuer <jensgr@gmx.net> * appearance-style.c: (prepare_combo), (find_string_in_model), (conv_to_widget_cb), (conv_from_widget_cb), (update_color_buttons_from_string), (color_button_clicked_cb): minor cleanup and getting rid of unnecessary casts svn path=/trunk/; revision=7628
This commit is contained in:
parent
c5b68b203c
commit
dae1952805
2 changed files with 23 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2007-05-16 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
* appearance-style.c: (prepare_combo), (find_string_in_model),
|
||||||
|
(conv_to_widget_cb), (conv_from_widget_cb),
|
||||||
|
(update_color_buttons_from_string), (color_button_clicked_cb):
|
||||||
|
minor cleanup and getting rid of unnecessary casts
|
||||||
|
|
||||||
2007-05-16 Denis Washington <denisw@svn.nome.org>
|
2007-05-16 Denis Washington <denisw@svn.nome.org>
|
||||||
|
|
||||||
* appearance-desktop.c: (desktop_init): Minor code cleanup.
|
* appearance-desktop.c: (desktop_init): Minor code cleanup.
|
||||||
|
|
|
@ -91,16 +91,16 @@ prepare_combo (AppearanceData *data, GtkWidget *combo, enum ThemeType type)
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GList *l, *list = NULL;
|
GList *l, *list = NULL;
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
GnomeThemeElement element = 0;
|
|
||||||
GtkTreeModel *sort_model;
|
GtkTreeModel *sort_model;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GTK_THEMES:
|
case GTK_THEMES:
|
||||||
element = GNOME_THEME_GTK_2;
|
list = gnome_theme_info_find_by_type (GNOME_THEME_GTK_2);
|
||||||
|
break;
|
||||||
|
|
||||||
case METACITY_THEMES:
|
case METACITY_THEMES:
|
||||||
if (!element) element = GNOME_THEME_METACITY;
|
list = gnome_theme_info_find_by_type (GNOME_THEME_METACITY);
|
||||||
list = gnome_theme_info_find_by_type (element);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICON_THEMES:
|
case ICON_THEMES:
|
||||||
|
@ -117,7 +117,6 @@ prepare_combo (AppearanceData *data, GtkWidget *combo, enum ThemeType type)
|
||||||
if (!list)
|
if (!list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
|
||||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||||
|
|
||||||
for (l = list; l; l = g_list_next (l))
|
for (l = list; l; l = g_list_next (l))
|
||||||
|
@ -141,6 +140,8 @@ prepare_combo (AppearanceData *data, GtkWidget *combo, enum ThemeType type)
|
||||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), 0, GTK_SORT_ASCENDING);
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), 0, GTK_SORT_ASCENDING);
|
||||||
|
|
||||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (sort_model));
|
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (sort_model));
|
||||||
|
|
||||||
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
|
||||||
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
|
||||||
|
|
||||||
|
@ -148,8 +149,6 @@ prepare_combo (AppearanceData *data, GtkWidget *combo, enum ThemeType type)
|
||||||
"conv-to-widget-cb", conv_to_widget_cb,
|
"conv-to-widget-cb", conv_to_widget_cb,
|
||||||
"conv-from-widget-cb", conv_from_widget_cb,
|
"conv-from-widget-cb", conv_from_widget_cb,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callbacks */
|
/* Callbacks */
|
||||||
|
@ -181,23 +180,22 @@ find_string_in_model (GtkTreeModel *model, const gchar *value, gint column)
|
||||||
}
|
}
|
||||||
g_free (test);
|
g_free (test);
|
||||||
|
|
||||||
return (found) ? index : -1;
|
return found ? index : -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GConfValue *
|
static GConfValue *
|
||||||
conv_to_widget_cb (GConfPropertyEditor *peditor, GConfValue *value)
|
conv_to_widget_cb (GConfPropertyEditor *peditor, GConfValue *value)
|
||||||
{
|
{
|
||||||
GtkTreeModel *store;
|
GtkTreeModel *store;
|
||||||
GtkWidget *combo;
|
GtkComboBox *combo;
|
||||||
const gchar *curr_value;
|
const gchar *curr_value;
|
||||||
GConfValue *new_value;
|
GConfValue *new_value;
|
||||||
gint index = -1;
|
gint index;
|
||||||
|
|
||||||
/* find value in model */
|
/* find value in model */
|
||||||
curr_value = gconf_value_get_string (value);
|
curr_value = gconf_value_get_string (value);
|
||||||
combo = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
|
combo = GTK_COMBO_BOX (gconf_property_editor_get_ui_control (peditor));
|
||||||
store = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
store = gtk_combo_box_get_model (combo);
|
||||||
|
|
||||||
index = find_string_in_model (store, curr_value, 0);
|
index = find_string_in_model (store, curr_value, 0);
|
||||||
|
|
||||||
|
@ -234,11 +232,11 @@ conv_from_widget_cb (GConfPropertyEditor *peditor, GConfValue *value)
|
||||||
gchar *combo_value = NULL;
|
gchar *combo_value = NULL;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkWidget *combo;
|
GtkComboBox *combo;
|
||||||
|
|
||||||
combo = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
|
combo = GTK_COMBO_BOX (gconf_property_editor_get_ui_control (peditor));
|
||||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
model = gtk_combo_box_get_model (combo);
|
||||||
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
|
gtk_combo_box_get_active_iter (combo, &iter);
|
||||||
gtk_tree_model_get (model, &iter, 0, &combo_value, -1);
|
gtk_tree_model_get (model, &iter, 0, &combo_value, -1);
|
||||||
|
|
||||||
new_value = gconf_value_new (GCONF_VALUE_STRING);
|
new_value = gconf_value_new (GCONF_VALUE_STRING);
|
||||||
|
@ -256,8 +254,7 @@ update_color_buttons_from_string (gchar *color_scheme, AppearanceData *data)
|
||||||
gint i;
|
gint i;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
if (!color_scheme) return;
|
if (!color_scheme || !strcmp (color_scheme, "")) return;
|
||||||
if (!strcmp (color_scheme, "")) return;
|
|
||||||
|
|
||||||
/* The color scheme string consists of name:color pairs, seperated by
|
/* The color scheme string consists of name:color pairs, seperated by
|
||||||
* newlines, so first we split the string up by new line */
|
* newlines, so first we split the string up by new line */
|
||||||
|
@ -366,5 +363,3 @@ color_button_clicked_cb (GtkWidget *colorbutton, AppearanceData *data)
|
||||||
g_free (selected_bg);
|
g_free (selected_bg);
|
||||||
g_free (new_scheme);
|
g_free (new_scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue