summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodney Dawes <dobey@novell.com>2005-07-10 20:58:26 +0000
committerRodney Dawes <dobey@src.gnome.org>2005-07-10 20:58:26 +0000
commit4bd29c3fa62c9a022c32a70a429c3b8a074d1438 (patch)
tree06422b2cb6b881d7602255ecbf38d6e76cecc18d
parentb37ed46f1375031192f9606377dab2f2e169d52f (diff)
downloadgnome-control-center-4bd29c3fa62c9a022c32a70a429c3b8a074d1438.tar.gz
Update to use GtkIconTheme rather than GnomeIconTheme Based on patch from
2005-07-10 Rodney Dawes <dobey@novell.com> * gnome-wp-capplet.[ch]: (gnome_wp_icon_theme_changed): (wallpaper_properties_init): Update to use GtkIconTheme rather than GnomeIconTheme Based on patch from Jan de Groot Fixes #171677 2005-07-10 Rodney Dawes <dobey@novell.com> * gnome-wp-info.c (gnome_wp_info_new): Fix some memory leaks by using a separate variable to store the escaped path, and md5sum * gnome-wp-item.c (gnome_wp_item_get_thumbnail): Fix a couple of memory leaks by using a separate variable to store the escaped path Don't unref the pixbuf from the thumbnail generation, and then try to load it again after saving
-rw-r--r--capplets/background/ChangeLog20
-rw-r--r--capplets/background/gnome-wp-capplet.c130
-rw-r--r--capplets/background/gnome-wp-capplet.h2
-rw-r--r--capplets/background/gnome-wp-info.c17
-rw-r--r--capplets/background/gnome-wp-item.c11
5 files changed, 106 insertions, 74 deletions
diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog
index c611d863f..b52ccdf9b 100644
--- a/capplets/background/ChangeLog
+++ b/capplets/background/ChangeLog
@@ -1,3 +1,23 @@
+2005-07-10 Rodney Dawes <dobey@novell.com>
+
+ * gnome-wp-capplet.[ch]:
+ (gnome_wp_icon_theme_changed):
+ (wallpaper_properties_init):
+ Update to use GtkIconTheme rather than GnomeIconTheme
+ Based on patch from Jan de Groot
+
+ Fixes #171677
+
+2005-07-10 Rodney Dawes <dobey@novell.com>
+
+ * gnome-wp-info.c (gnome_wp_info_new): Fix some memory leaks by using
+ a separate variable to store the escaped path, and md5sum
+
+ * gnome-wp-item.c (gnome_wp_item_get_thumbnail): Fix a couple of
+ memory leaks by using a separate variable to store the escaped path
+ Don't unref the pixbuf from the thumbnail generation, and then try
+ to load it again after saving
+
2005-02-26 Rodney Dawes <dobey@novell.com>
* *.[ch]: Update Copyright to include current year
diff --git a/capplets/background/gnome-wp-capplet.c b/capplets/background/gnome-wp-capplet.c
index 0ba5e4dbb..90467d188 100644
--- a/capplets/background/gnome-wp-capplet.c
+++ b/capplets/background/gnome-wp-capplet.c
@@ -802,69 +802,61 @@ static void gnome_wp_delay_changed (GConfClient * client, guint id,
capplet->delay = gconf_value_get_int (entry->value);
}
-static void gnome_wp_icon_theme_changed (GnomeIconTheme * theme,
+static void gnome_wp_icon_theme_changed (GtkIconTheme * theme,
GnomeWPCapplet * capplet) {
GdkPixbuf * pixbuf;
- gchar * icofile;
+ GtkIconInfo * icon_info = NULL;
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"gnome-settings-background",
- 48, NULL, NULL);
- if (icofile != NULL) {
- pixbuf = gdk_pixbuf_new_from_file (icofile, NULL);
+ 48, 0);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
gtk_window_set_icon (GTK_WINDOW (capplet->window), NULL);
- gtk_window_set_default_icon_from_file (icofile, NULL);
+ gtk_window_set_default_icon (pixbuf);
g_object_unref (pixbuf);
}
- g_free (icofile);
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-center",
- 16, NULL, NULL);
- if (icofile != NULL) {
- GdkPixbuf * pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file (icofile, NULL);
+ 16, 0);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
gtk_image_set_from_pixbuf (GTK_IMAGE (capplet->citem), pixbuf);
g_object_unref (pixbuf);
}
- g_free (icofile);
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-fill",
- 16, NULL, NULL);
- if (icofile != NULL) {
- GdkPixbuf * pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file (icofile, NULL);
+ 16, 0);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
gtk_image_set_from_pixbuf (GTK_IMAGE (capplet->fitem), pixbuf);
g_object_unref (pixbuf);
}
- g_free (icofile);
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-scale",
- 16, NULL, NULL);
- if (icofile != NULL) {
- GdkPixbuf * pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file (icofile, NULL);
+ 16, 0);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
gtk_image_set_from_pixbuf (GTK_IMAGE (capplet->sitem), pixbuf);
g_object_unref (pixbuf);
}
- g_free (icofile);
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-tile",
- 16, NULL, NULL);
- if (icofile != NULL) {
- GdkPixbuf * pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file (icofile, NULL);
+ 16, 0);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
gtk_image_set_from_pixbuf (GTK_IMAGE (capplet->witem), pixbuf);
g_object_unref (pixbuf);
}
- g_free (icofile);
}
static GladeXML * gnome_wp_create_dialog (void) {
@@ -936,8 +928,8 @@ static void wallpaper_properties_init (poptContext ctx) {
GtkTreeSelection * selection;
GdkPixbuf * pixbuf;
GdkCursor * cursor;
- gchar * icofile;
const gchar ** args;
+ GtkIconInfo * icon_info = NULL;
gtk_rc_parse_string ("style \"wp-tree-defaults\" {\n"
" GtkTreeView::horizontal-separator = 6\n"
@@ -994,8 +986,7 @@ static void wallpaper_properties_init (poptContext ctx) {
gnome_wp_item_free);
capplet->thumbs = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
- capplet->theme = gnome_icon_theme_new ();
- gnome_icon_theme_set_allow_svg (capplet->theme, TRUE);
+ capplet->theme = gtk_icon_theme_get_default ();
g_signal_connect (G_OBJECT (capplet->theme), "changed",
G_CALLBACK (gnome_wp_icon_theme_changed), capplet);
@@ -1003,16 +994,16 @@ static void wallpaper_properties_init (poptContext ctx) {
dialog = gnome_wp_create_dialog ();
capplet->window = glade_xml_get_widget (dialog,"gnome_wp_properties");
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"gnome-settings-background",
- 48, NULL, NULL);
- if (icofile != NULL) {
- pixbuf = gdk_pixbuf_new_from_file (icofile, NULL);
- gtk_window_set_default_icon_from_file (icofile, NULL);
+ 48, 0);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+ gtk_window_set_default_icon (pixbuf);
gtk_window_set_icon (GTK_WINDOW (capplet->window), pixbuf);
g_object_unref (pixbuf);
}
- g_free (icofile);
gtk_widget_realize (capplet->window);
@@ -1060,22 +1051,25 @@ static void wallpaper_properties_init (poptContext ctx) {
capplet->wp_opts = glade_xml_get_widget (dialog,"style_menu");
menu = gtk_menu_new ();
+
mitem = gtk_menu_item_new ();
set_accessible_name (mitem, _("Centered"));
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-center",
- 16, NULL, NULL);
+ 16, 0);
mbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (mitem), mbox);
gtk_widget_show (mbox);
- if (icofile != NULL) {
- capplet->citem = gtk_image_new_from_file (icofile);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+ capplet->citem = gtk_image_new_from_pixbuf (pixbuf);
gtk_box_pack_start (GTK_BOX (mbox), capplet->citem, FALSE, FALSE, 0);
gtk_widget_show (capplet->citem);
+ g_object_unref (pixbuf);
}
- g_free (icofile);
label = gtk_label_new (_("Centered"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
@@ -1086,19 +1080,21 @@ static void wallpaper_properties_init (poptContext ctx) {
mitem = gtk_menu_item_new ();
set_accessible_name (mitem, _("Fill Screen"));
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-fill",
- 16, NULL, NULL);
+ 16, 0);
mbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (mitem), mbox);
gtk_widget_show (mbox);
- if (icofile != NULL) {
- capplet->fitem = gtk_image_new_from_file (icofile);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+ capplet->fitem = gtk_image_new_from_pixbuf (pixbuf);
gtk_box_pack_start (GTK_BOX (mbox), capplet->fitem, FALSE, FALSE, 0);
gtk_widget_show (capplet->fitem);
+ g_object_unref (pixbuf);
}
- g_free (icofile);
label = gtk_label_new (_("Fill Screen"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
@@ -1109,19 +1105,21 @@ static void wallpaper_properties_init (poptContext ctx) {
mitem = gtk_menu_item_new ();
set_accessible_name (mitem, _("Scaled"));
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-scale",
- 16, NULL, NULL);
+ 16, 0);
mbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (mitem), mbox);
gtk_widget_show (mbox);
- if (icofile != NULL) {
- capplet->sitem = gtk_image_new_from_file (icofile);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+ capplet->sitem = gtk_image_new_from_pixbuf (pixbuf);
gtk_box_pack_start (GTK_BOX (mbox), capplet->sitem, FALSE, FALSE, 0);
gtk_widget_show (capplet->sitem);
+ g_object_unref (pixbuf);
}
- g_free (icofile);
label = gtk_label_new (_("Scaled"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
@@ -1132,19 +1130,21 @@ static void wallpaper_properties_init (poptContext ctx) {
mitem = gtk_menu_item_new ();
set_accessible_name (mitem, _("Tiled"));
- icofile = gnome_icon_theme_lookup_icon (capplet->theme,
+ icon_info = gtk_icon_theme_lookup_icon (capplet->theme,
"stock_wallpaper-tile",
- 16, NULL, NULL);
+ 16, 0);
mbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (mitem), mbox);
gtk_widget_show (mbox);
- if (icofile != NULL) {
- capplet->witem = gtk_image_new_from_file (icofile);
+ if (icon_info != NULL) {
+ pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+ gtk_icon_info_free (icon_info);
+ capplet->witem = gtk_image_new_from_pixbuf (pixbuf);
gtk_box_pack_start (GTK_BOX (mbox), capplet->witem, FALSE, FALSE, 0);
gtk_widget_show (capplet->witem);
+ g_object_unref (pixbuf);
}
- g_free (icofile);
label = gtk_label_new (_("Tiled"));
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
diff --git a/capplets/background/gnome-wp-capplet.h b/capplets/background/gnome-wp-capplet.h
index 872cf56bd..01fb41d18 100644
--- a/capplets/background/gnome-wp-capplet.h
+++ b/capplets/background/gnome-wp-capplet.h
@@ -74,7 +74,7 @@ struct _GnomeWPCapplet {
/* Thumbnailing and Icon Theme stuff */
GnomeThumbnailFactory * thumbs;
- GnomeIconTheme * theme;
+ GtkIconTheme * theme;
/* Hash Table of Wallpapers */
GHashTable * wphash;
diff --git a/capplets/background/gnome-wp-info.c b/capplets/background/gnome-wp-info.c
index 4da9643a7..edf9f39dc 100644
--- a/capplets/background/gnome-wp-info.c
+++ b/capplets/background/gnome-wp-info.c
@@ -27,24 +27,32 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
GnomeWPInfo * new;
GnomeVFSFileInfo * info;
GnomeVFSResult result;
+ gchar * escaped_path;
info = gnome_vfs_file_info_new ();
- result = gnome_vfs_get_file_info (gnome_vfs_escape_path_string (uri), info,
+ escaped_path = gnome_vfs_escape_path_string (uri);
+
+ result = gnome_vfs_get_file_info (escaped_path, info,
GNOME_VFS_FILE_INFO_DEFAULT |
GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
if (info == NULL || info->mime_type == NULL || result != GNOME_VFS_OK) {
if (!strcmp (uri, "(none)")) {
+ gchar * md5sum;
+
new = g_new0 (GnomeWPInfo, 1);
new->mime_type = g_strdup ("image/x-no-data");
new->uri = g_strdup (uri);
+ md5sum = gnome_thumbnail_md5 (escaped_path);
+
new->thumburi = g_strconcat (g_get_home_dir (),
"/.thumbnails/normal/",
- gnome_thumbnail_md5 (gnome_vfs_escape_path_string (uri)),
+ md5sum,
".png",
NULL);
+ g_free (md5sum);
new->name = g_strdup (_("No Wallpaper"));
@@ -58,12 +66,12 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
new->uri = g_strdup (uri);
new->thumburi = gnome_thumbnail_factory_lookup (thumbs,
- gnome_vfs_escape_path_string (new->uri),
+ escaped_path,
info->mtime);
if (new->thumburi == NULL) {
new->thumburi = g_strconcat (g_get_home_dir (),
"/.thumbnails/normal/",
- gnome_thumbnail_md5 (gnome_vfs_escape_path_string (uri)),
+ escaped_path,
".png",
NULL);
}
@@ -73,6 +81,7 @@ GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
new->size = info->size;
new->mtime = info->mtime;
}
+ g_free (escaped_path);
gnome_vfs_file_info_unref (info);
return new;
diff --git a/capplets/background/gnome-wp-item.c b/capplets/background/gnome-wp-item.c
index cbb00bdd0..128c11d08 100644
--- a/capplets/background/gnome-wp-item.c
+++ b/capplets/background/gnome-wp-item.c
@@ -205,14 +205,17 @@ GdkPixbuf * gnome_wp_item_get_thumbnail (GnomeWPItem * item,
} else if (!strcmp (item->filename, "(none)")) {
return bgpixbuf;
} else {
+ gchar * escaped_path;
+
+ escaped_path = gnome_vfs_escape_path_string (item->filename);
+
pixbuf = gnome_thumbnail_factory_generate_thumbnail (thumbs,
- gnome_vfs_escape_path_string (item->filename),
+ escaped_path,
item->fileinfo->mime_type);
gnome_thumbnail_factory_save_thumbnail (thumbs, pixbuf,
- gnome_vfs_escape_path_string (item->filename),
+ escaped_path,
item->fileinfo->mtime);
- g_object_unref (pixbuf);
- pixbuf = gdk_pixbuf_new_from_file (item->fileinfo->thumburi, NULL);
+ g_free (escaped_path);
}
if (pixbuf != NULL) {