added to reload icons if gtk theme changes switch correctly both shell

2005-10-25  Carlos Garnacho Parro  <carlosg@gnome.org>

        * control-center-categories.[ch] (control_center_reload_icons): added
        to reload icons if gtk theme changes
        * gnomecc-canvas.c: switch correctly both shell background and icons
        in case of theme change. Plugged a memleak on finalize
This commit is contained in:
Carlos Garnacho Parro 2005-11-02 14:03:45 +00:00 committed by Carlos Garnacho
parent d0e079b4e9
commit 4cf092327b
4 changed files with 52 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2005-10-25 Carlos Garnacho Parro <carlosg@gnome.org>
* control-center-categories.[ch] (control_center_reload_icons): added
to reload icons if gtk theme changes
* gnomecc-canvas.c: switch correctly both shell background and icons
in case of theme change. Plugged a memleak on finalize
2005-10-24 Carlos Garnacho Parro <carlosg@gnome.org>
* gnomecc-canvas.c: calculate item widths instead of forcing them to

View file

@ -124,7 +124,8 @@ control_center_entry_new (ControlCenterCategory *category,
retval->title = g_strdup (gmenu_tree_entry_get_name (menu_entry));
retval->comment = g_strdup (gmenu_tree_entry_get_comment (menu_entry));
retval->desktop_entry = g_strdup (gmenu_tree_entry_get_desktop_file_path (menu_entry));
retval->icon_pixbuf = load_icon (gmenu_tree_entry_get_icon (menu_entry));
retval->icon = g_strdup (gmenu_tree_entry_get_icon (menu_entry));
retval->icon_pixbuf = load_icon (retval->icon);
return retval;
}
@ -332,3 +333,24 @@ control_center_information_free (ControlCenterInformation *information)
g_free (information);
}
void
control_center_reload_icons (ControlCenterInformation *information)
{
int i, j;
int n_cat, n_entries;
ControlCenterEntry *entry;
n_cat = information->n_categories;
for (i = 0; i < n_cat; i++) {
n_entries = information->categories[i]->n_entries;
for (j = 0; j < n_entries; j++) {
entry = information->categories[i]->entries[j];
gdk_pixbuf_unref (entry->icon_pixbuf);
entry->icon_pixbuf = load_icon (entry->icon);
}
}
}

View file

@ -44,6 +44,7 @@ struct ControlCenterEntry {
char *comment;
char *desktop_entry;
char *icon;
GdkPixbuf *icon_pixbuf;
gpointer user_data;
@ -67,6 +68,7 @@ struct ControlCenterInformation {
ControlCenterInformation *control_center_get_information (void);
void control_center_information_free (ControlCenterInformation *information);
void control_center_reload_icons (ControlCenterInformation *information);
G_END_DECLS

View file

@ -171,11 +171,9 @@ static void
gnomecc_canvas_init (GnomeccCanvas *canvas)
{
GnomeccCanvasPrivate *priv;
GtkWidget *widget;
g_return_if_fail (GNOMECC_IS_CANVAS (canvas));
widget = GTK_WIDGET (canvas);
priv = GNOMECC_CANVAS_GET_PRIVATE (canvas);
priv->max_width = 300;
@ -190,10 +188,7 @@ gnomecc_canvas_init (GnomeccCanvas *canvas)
priv->accessible_children = g_hash_table_new (g_int_hash, g_int_equal);
gtk_widget_modify_bg (GTK_WIDGET (canvas), GTK_STATE_NORMAL,
&widget->style->base[GTK_STATE_NORMAL]);
gtk_widget_show_all (widget);
gtk_widget_show_all (GTK_WIDGET (canvas));
}
static gboolean
@ -695,12 +690,11 @@ build_canvas (GnomeccCanvas *canvas)
gnome_canvas_pixbuf_get_type (),
"pixbuf", pixbuf,
NULL);
g_object_unref (pixbuf);
ei->highlight_pixbuf = gnome_canvas_item_new (ei->group,
gnome_canvas_pixbuf_get_type (),
"pixbuf", highlight_pixbuf,
NULL);
g_object_unref (highlight_pixbuf);
} else {
ei->pixbuf = NULL;
ei->highlight_pixbuf = NULL;
@ -764,6 +758,12 @@ gnomecc_canvas_get_property (GObject *object,
static void
gnomecc_canvas_finalize (GObject *object)
{
GnomeccCanvasPrivate *priv;
priv = GNOMECC_CANVAS_GET_PRIVATE (object);
g_hash_table_destroy (priv->accessible_children);
if (G_OBJECT_CLASS (gnomecc_canvas_parent_class)->finalize)
(* G_OBJECT_CLASS (gnomecc_canvas_parent_class)->finalize) (object);
}
@ -958,6 +958,9 @@ set_style (GnomeccCanvas *canvas, gboolean font_changed)
priv = GNOMECC_CANVAS_GET_PRIVATE (canvas);
widget->style->bg[GTK_STATE_NORMAL] = widget->style->base[GTK_STATE_NORMAL];
control_center_reload_icons (priv->info);
for (i = 0; i < priv->info->n_categories; i++) {
CategoryInfo *catinfo = priv->info->categories[i]->user_data;
@ -980,6 +983,15 @@ set_style (GnomeccCanvas *canvas, gboolean font_changed)
for (j = 0; j < priv->info->categories[i]->n_entries; j++) {
ControlCenterEntry *entry = priv->info->categories[i]->entries[j];
EntryInfo *entryinfo = entry->user_data;
g_object_set (entryinfo->pixbuf,
"pixbuf", entry->icon_pixbuf,
NULL);
g_object_set (entryinfo->highlight_pixbuf,
"pixbuf", create_spotlight_pixbuf (entry->icon_pixbuf),
NULL);
if (font_changed && entryinfo->text)
g_object_set (entryinfo->text,
"font", NULL,