From defe86fcfd6def730466cbdcfb818b85a20f4d30 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Fri, 4 May 2012 10:03:00 +0300 Subject: [PATCH] Add optional support for custom file icon emblems (Bug #5469) Adds support to display multiple custom emblems for file icons on the desktop. Regular file icons will display whether it's a symlink or the file is read-only in addition to any emblems the user sets in Thunar. This requires an optional dependency on libtdb to read the metadata for the user set emblems. --- README | 1 + configure.ac.in | 10 ++ po/POTFILES.in | 1 + src/Makefile.am | 13 +- src/main.c | 7 + src/xfdesktop-file-icon-manager.c | 10 +- src/xfdesktop-file-icon.c | 77 ++++++++++ src/xfdesktop-file-icon.h | 13 ++ src/xfdesktop-file-utils.c | 143 +++++++++++++----- src/xfdesktop-file-utils.h | 4 +- src/xfdesktop-metafile.c | 296 +++++++++++++++++++++++++++++++++++++ src/xfdesktop-metafile.h | 62 ++++++++ src/xfdesktop-regular-file-icon.c | 141 +++++++++--------- src/xfdesktop-special-file-icon.c | 90 ++++++----- src/xfdesktop-volume-icon.c | 54 ++++--- 15 files changed, 748 insertions(+), 174 deletions(-) create mode 100644 src/xfdesktop-metafile.c create mode 100644 src/xfdesktop-metafile.h diff --git a/README b/README index 987d7b1..fe8794c 100644 --- a/README +++ b/README @@ -27,6 +27,7 @@ MINIMUM REQUIREMENTS * thunar 1.2 (optional; required for file icons) * dbus-glib 0.34 (optional; required for file icons) * tumbler 1.6 (optional; enables thumbnail previews for file icons) +* libtdb 1.0 (optional; enables emblems on file icons) HIDDEN CUSTOMISATIONS diff --git a/configure.ac.in b/configure.ac.in index 3df4929..7fa6d0b 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -25,6 +25,7 @@ m4_define([dbus_minimum_version], [0.84]) m4_define([wnck_minimum_version], [2.30]) m4_define([intltool_minimum_version], [0.31]) m4_define([xfconf_minimum_version], [4.8.0]) +m4_define([libtdb_minimum_version], [1.0.0]) dnl init autoconf AC_INIT([xfdesktop], [xfdesktop_version], [http://bugzilla.xfce.org/]) @@ -147,6 +148,10 @@ XDT_CHECK_OPTIONAL_PACKAGE([THUNARX], [thunarx-2], [thunar_minimum_version], [thunarx], [Thunar's extension mechanism, to add external features to the desktop icon implementation]) +XDT_CHECK_OPTIONAL_PACKAGE([LIBTDB], [tdb], [libtdb_minimum_version], + [tdb], + [libtdb - Trivial Database, to add emblems to desktop icons]) + dnl LIBEXO is required if file icons are enabled XDT_CHECK_PACKAGE([LIBEXO], [exo-1], [exo_minimum_version]) @@ -210,6 +215,11 @@ echo "Build Configuration:" echo "* Build desktop menu module: $build_desktop_menu" echo "* Build support for desktop icons: $enable_desktop_icons" echo " Include support for file/launcher icons: $enable_file_icons" +if test x"$LIBTDB_FOUND" = x"yes"; then +echo " Include support for icon emblems: yes" +else +echo " Include support for icon emblems: no" +fi if test x"$GIO_UNIX_FOUND" = x"yes"; then echo "* Special treatment for mount points on UNIX: yes" else diff --git a/po/POTFILES.in b/po/POTFILES.in index 123841e..a3c9c3b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -21,6 +21,7 @@ src/xfdesktop-file-utils.c src/xfdesktop-icon.c src/xfdesktop-icon-view.c src/xfdesktop-icon-view-manager.c +src/xfdesktop-metafile.c src/xfdesktop-notify.c src/xfdesktop-regular-file-icon.c src/xfdesktop-special-file-icon.c diff --git a/src/Makefile.am b/src/Makefile.am index adeac0b..f0a3c71 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,9 +12,16 @@ xfdesktop_notify_sources = \ xfdesktop-notify.h endif +if HAVE_LIBTDB +xfdesktop_tdb_sources = \ + xfdesktop-metafile.c \ + xfdesktop-metafile.h +endif + xfdesktop_SOURCES = \ $(xfdesktop_built_sources) \ $(xfdesktop_notify_sources) \ + $(xfdesktop_tdb_sources) \ main.c \ menu.c \ menu.h \ @@ -79,7 +86,8 @@ xfdesktop_CFLAGS = \ $(LIBXFCE4UI_CFLAGS) \ $(LIBXFCE4SMCLIENT_PRIVATE_CFLAGS) \ $(LIBWNCK_CFLAGS) \ - $(XFCONF_CFLAGS) + $(XFCONF_CFLAGS) \ + $(LIBTDB_CFLAGS) xfdesktop_LDFLAGS = \ -export-dynamic @@ -99,7 +107,8 @@ xfdesktop_LDADD += \ $(LIBXFCE4UI_LIBS) \ $(LIBXFCE4SMCLIENT_PRIVATE_LIBS) \ $(LIBWNCK_LIBS) \ - $(XFCONF_LIBS) + $(XFCONF_LIBS) \ + $(LIBTDB_LIBS) if BUILD_DESKTOP_MENU diff --git a/src/main.c b/src/main.c index 76b275b..695e595 100644 --- a/src/main.c +++ b/src/main.c @@ -303,6 +303,13 @@ main(int argc, char **argv) _("disabled") #endif ); + g_print(_(" Custom Icon Emblems: %s\n"), +#ifdef HAVE_LIBTDB + _("enabled") +#else + _("disabled") +#endif + ); return 0; } else if(opt_reload) diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c index 72b6d09..6664f85 100644 --- a/src/xfdesktop-file-icon-manager.c +++ b/src/xfdesktop-file-icon-manager.c @@ -1927,13 +1927,15 @@ xfdesktop_file_icon_manager_add_icon(XfdesktopFileIconManager *fmanager, gboolean do_add = FALSE; const gchar *name; GFile *file; + gchar *path = NULL; file = xfdesktop_file_icon_peek_file(icon); - if(fmanager->priv->show_thumbnails && g_file_get_path(file) != NULL) { - xfdesktop_thumbnailer_queue_thumbnail(fmanager->priv->thumbnailer, - g_file_get_path(file)); - } + if(file != NULL) + path = g_file_get_path(file); + + if(fmanager->priv->show_thumbnails && path != NULL) + xfdesktop_thumbnailer_queue_thumbnail(fmanager->priv->thumbnailer, path); name = xfdesktop_icon_peek_label(XFDESKTOP_ICON(icon)); diff --git a/src/xfdesktop-file-icon.c b/src/xfdesktop-file-icon.c index 1088e99..5d2f32e 100644 --- a/src/xfdesktop-file-icon.c +++ b/src/xfdesktop-file-icon.c @@ -53,11 +53,20 @@ xfdesktop_file_icon_class_init(XfdesktopFileIconClass *klass) static void xfdesktop_file_icon_init(XfdesktopFileIcon *icon) { + icon->gicon = NULL; + +#ifdef HAVE_LIBTDB + icon->metafile = xfdesktop_metafile_get_default(); +#endif } static void xfdesktop_file_icon_finalize(GObject *obj) { + XfdesktopFileIcon *icon = XFDESKTOP_FILE_ICON(obj); + + xfdesktop_file_icon_invalidate_icon(icon); + G_OBJECT_CLASS(xfdesktop_file_icon_parent_class)->finalize(obj); } @@ -178,3 +187,71 @@ xfdesktop_file_icon_can_delete_file(XfdesktopFileIcon *icon) else return FALSE; } + +void +xfdesktop_file_icon_add_emblems(XfdesktopFileIcon *icon) +{ + GIcon *emblemed_icon = NULL; +#ifdef HAVE_LIBTDB + const gchar *emblem_string; + gchar **emblem_names = NULL; +#endif + + g_return_if_fail(XFDESKTOP_IS_FILE_ICON(icon)); + + /* This should still work even if user created emblems aren't supported */ + if(G_IS_ICON(icon->gicon)) { + emblemed_icon = g_emblemed_icon_new(icon->gicon, NULL); + } else + return; + +#ifdef HAVE_LIBTDB + + /* If there's no metafile we can't add user emblems, but we can return + * it so that dynamic emblems can be added. */ + if(!XFDESKTOP_IS_METAFILE(icon->metafile)) { + xfdesktop_file_icon_invalidate_icon(icon); + icon->gicon = emblemed_icon; + return; + } + + /* Get the list of emblems */ + emblem_string = xfdesktop_metafile_fetch(icon->metafile, + xfdesktop_file_icon_peek_file(icon), + XFDESKTOP_METAFILE_KEY_EMBLEMS, + ""); + + /* if we have a list of emblems ; is the separator between them */ + if(emblem_string != NULL && *emblem_string != '\0') + emblem_names = g_strsplit(emblem_string, ";", -1); + + if(emblem_names != NULL) { + /* for each item in the list create an icon, pack it into an emblem, + * and attach it to our icon. */ + for(; *emblem_names != NULL; ++emblem_names) { + GIcon *themed_icon = g_themed_icon_new(*emblem_names); + GEmblem *emblem = g_emblem_new(themed_icon); + + g_emblemed_icon_add_emblem(G_EMBLEMED_ICON(emblemed_icon), emblem); + + g_object_unref(emblem); + g_object_unref(themed_icon); + } + } + +#endif + + xfdesktop_file_icon_invalidate_icon(icon); + icon->gicon = emblemed_icon; +} + +void +xfdesktop_file_icon_invalidate_icon(XfdesktopFileIcon *icon) +{ + g_return_if_fail(XFDESKTOP_IS_FILE_ICON(icon)); + + if(G_IS_ICON(icon->gicon)) { + g_object_unref(icon->gicon); + icon->gicon = NULL; + } +} diff --git a/src/xfdesktop-file-icon.h b/src/xfdesktop-file-icon.h index 4ca703f..5644635 100644 --- a/src/xfdesktop-file-icon.h +++ b/src/xfdesktop-file-icon.h @@ -27,6 +27,10 @@ #include "xfdesktop-icon.h" +#ifdef HAVE_LIBTDB +#include +#endif + G_BEGIN_DECLS #define XFDESKTOP_TYPE_FILE_ICON (xfdesktop_file_icon_get_type()) @@ -40,6 +44,11 @@ typedef struct _XfdesktopFileIconClass XfdesktopFileIconClass; struct _XfdesktopFileIcon { XfdesktopIcon parent; + GIcon *gicon; + +#ifdef HAVE_LIBTDB + XfdesktopMetafile *metafile; +#endif }; struct _XfdesktopFileIconClass @@ -68,6 +77,10 @@ gboolean xfdesktop_file_icon_can_rename_file(XfdesktopFileIcon *icon); gboolean xfdesktop_file_icon_can_delete_file(XfdesktopFileIcon *icon); +void xfdesktop_file_icon_add_emblems(XfdesktopFileIcon *icon); + +void xfdesktop_file_icon_invalidate_icon(XfdesktopFileIcon *icon); + G_END_DECLS #endif /* __XFDESKTOP_FILE_ICON_H__ */ diff --git a/src/xfdesktop-file-utils.c b/src/xfdesktop-file-utils.c index 2670bbd..158b0da 100644 --- a/src/xfdesktop-file-utils.c +++ b/src/xfdesktop-file-utils.c @@ -491,12 +491,19 @@ GdkPixbuf * xfdesktop_file_utils_get_icon(const gchar *custom_icon_name, GIcon *icon, gint size, - const GdkPixbuf *emblem, guint opacity) { GtkIconTheme *itheme = gtk_icon_theme_get_default(); GdkPixbuf *pix_theme = NULL, *pix = NULL; + GIcon *base_icon = NULL; + /* Extract the base icon if available */ + if(G_IS_EMBLEMED_ICON(icon)) + base_icon = g_emblemed_icon_get_icon(G_EMBLEMED_ICON(icon)); + else + base_icon = icon; + + /* If a custom icon name was set, try to use it */ if(custom_icon_name) { pix_theme = gtk_icon_theme_load_icon(itheme, custom_icon_name, size, ITHEME_FLAGS, NULL); @@ -504,17 +511,17 @@ xfdesktop_file_utils_get_icon(const gchar *custom_icon_name, pix_theme = gdk_pixbuf_new_from_file_at_size(custom_icon_name, size, size, NULL); } - if(!pix_theme && icon) { - if(G_IS_THEMED_ICON(icon)) { + if(!pix_theme && base_icon) { + if(G_IS_THEMED_ICON(base_icon) || G_IS_FILE_ICON(base_icon)) { GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon(itheme, - icon, size, + base_icon, size, ITHEME_FLAGS); if(icon_info) { pix_theme = gtk_icon_info_load_icon(icon_info, NULL); gtk_icon_info_free(icon_info); } - } else if(G_IS_LOADABLE_ICON(icon)) { - GInputStream *stream = g_loadable_icon_load(G_LOADABLE_ICON(icon), + } else if(G_IS_LOADABLE_ICON(base_icon)) { + GInputStream *stream = g_loadable_icon_load(G_LOADABLE_ICON(base_icon), size, NULL, NULL, NULL); if(stream) { pix = gdk_pixbuf_new_from_stream(stream, NULL, NULL); @@ -540,35 +547,9 @@ xfdesktop_file_utils_get_icon(const gchar *custom_icon_name, return NULL; } - if(emblem) { - gint emblem_pix_size = gdk_pixbuf_get_width(emblem); - gint dest_size = size - emblem_pix_size; - - /* if we're using the fallback icon, we don't want to draw an emblem on - * it, since other icons might use it without the emblem */ - if(G_UNLIKELY(pix == xfdesktop_fallback_icon)) { - GdkPixbuf *tmp = gdk_pixbuf_copy(pix); - g_object_unref(G_OBJECT(pix)); - pix = tmp; - } - - if(dest_size < 0) - g_critical("xfdesktop_file_utils_get_file_icon(): (dest_size > 0) failed"); - else { - DBG("calling gdk_pixbuf_composite(%p, %p, %d, %d, %d, %d, %.1f, %.1f, %.1f, %.1f, %d, %d)", - emblem, pix, - dest_size, dest_size, - emblem_pix_size, emblem_pix_size, - (gdouble)dest_size, (gdouble)dest_size, - 1.0, 1.0, GDK_INTERP_BILINEAR, 255); - - gdk_pixbuf_composite(emblem, pix, - dest_size, dest_size, - emblem_pix_size, emblem_pix_size, - dest_size, dest_size, - 1.0, 1.0, GDK_INTERP_BILINEAR, 255); - } - } + /* Add the emblems */ + if(G_IS_EMBLEMED_ICON(icon)) + xfdesktop_file_utils_add_emblems(pix, g_emblemed_icon_get_emblems(G_EMBLEMED_ICON(icon))); if(opacity != 100) { GdkPixbuf *tmp = exo_gdk_pixbuf_lucent(pix, opacity); @@ -580,6 +561,98 @@ xfdesktop_file_utils_get_icon(const gchar *custom_icon_name, } void +xfdesktop_file_utils_add_emblems(GdkPixbuf *pix, + GList *emblems) +{ + GdkPixbuf *emblem_pix; + gint max_emblems; + gint pix_width, pix_height; + gint emblem_size; + gint dest_x, dest_y, dest_width, dest_height; + gint position; + GList *iter; + GtkIconTheme *itheme = gtk_icon_theme_get_default(); + + g_return_if_fail(pix != NULL); + + pix_width = gdk_pixbuf_get_width(pix); + pix_height = gdk_pixbuf_get_height(pix); + + emblem_size = MIN(pix_width, pix_height) / 3; + + /* render up to four emblems for sizes from 48 onwards, else up to 2 emblems */ + max_emblems = (pix_height < 48 && pix_width < 48) ? 2 : 4; + + for(iter = emblems, position = 0; iter != NULL && position < max_emblems; iter = iter->next) { + /* extract them icon from the emblem and load it */ + GIcon *emblem = g_emblem_get_icon(iter->data); + GtkIconInfo *icon_info = gtk_icon_theme_lookup_by_gicon(itheme, + emblem, + emblem_size, + ITHEME_FLAGS); + if(icon_info) { + emblem_pix = gtk_icon_info_load_icon(icon_info, NULL); + gtk_icon_info_free(icon_info); + } + + if(emblem_pix) { + if(gdk_pixbuf_get_width(emblem_pix) != emblem_size + || gdk_pixbuf_get_height(emblem_pix) != emblem_size) + { + GdkPixbuf *tmp = gdk_pixbuf_scale_simple(emblem_pix, + emblem_size, + emblem_size, + GDK_INTERP_BILINEAR); + g_object_unref(emblem_pix); + emblem_pix = tmp; + } + + dest_width = pix_width - emblem_size; + dest_height = pix_height - emblem_size; + + switch(position) { + case 0: /* bottom right */ + dest_x = dest_width; + dest_y = dest_height; + break; + case 1: /* bottom left */ + dest_x = 0; + dest_y = dest_height; + break; + case 2: /* upper right */ + dest_x = dest_width; + dest_y = 0; + break; + case 3: /* upper left */ + dest_x = dest_y = 0; + break; + default: + g_warning("Invalid emblem position in xfdesktop_file_utils_add_emblems"); + } + + DBG("calling gdk_pixbuf_composite(%p, %p, %d, %d, %d, %d, %d, %d, %.1f, %.1f, %d, %d) pixbuf w: %d h: %d", + emblem_pix, pix, + dest_x, dest_y, + emblem_size, emblem_size, + dest_x, dest_y, + 1.0, 1.0, GDK_INTERP_BILINEAR, 255, pix_width, pix_height); + + /* Add the emblem */ + gdk_pixbuf_composite(emblem_pix, pix, + dest_x, dest_y, + emblem_size, emblem_size, + dest_x, dest_y, + 1.0, 1.0, GDK_INTERP_BILINEAR, 255); + + g_object_unref(emblem_pix); + emblem_pix = NULL; + + position++; + } + } +} + +void xfdesktop_file_utils_set_window_cursor(GtkWindow *window, GdkCursorType cursor_type) { diff --git a/src/xfdesktop-file-utils.h b/src/xfdesktop-file-utils.h index a44e53f..9721a76 100644 --- a/src/xfdesktop-file-utils.h +++ b/src/xfdesktop-file-utils.h @@ -53,9 +53,11 @@ GdkPixbuf *xfdesktop_file_utils_get_fallback_icon(gint size); GdkPixbuf *xfdesktop_file_utils_get_icon(const gchar *custom_icon_name, GIcon *icon, gint size, - const GdkPixbuf *emblem, guint opacity); +void xfdesktop_file_utils_add_emblems(GdkPixbuf *pix, + GList *emblems); + void xfdesktop_file_utils_set_window_cursor(GtkWindow *window, GdkCursorType cursor_type); diff --git a/src/xfdesktop-metafile.c b/src/xfdesktop-metafile.c new file mode 100644 index 0000000..630aeb0 --- /dev/null +++ b/src/xfdesktop-metafile.c @@ -0,0 +1,296 @@ +/* + * Xfdesktop - xfce4's desktop manager + * + * Copyright(c) 2006 Brian Tarricone, + * Copyright(c) 2010-2011 Jannis Pohlmann, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * xfdesktop-metafile is based on thunar-metafile code from Thunar + * Copyright (c) 2005-2006 Benedikt Meurer + * Copyright (c) 2009-2011 Jannis Pohlmann + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_MEMORY_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#include + +#include + +#include + +#include + +static void xfdesktop_metafile_class_init(XfdesktopMetafileClass *klass); + +static void xfdesktop_metafile_init(XfdesktopMetafile *metafile); + +static void xfdesktop_metafile_finalize(GObject *object); + +static TDB_DATA xfdesktop_metafile_read(XfdesktopMetafile *metafile, + TDB_DATA data); + +struct _XfdesktopMetafileClass +{ + GObjectClass __parent__; +}; + +struct _XfdesktopMetafile +{ + GObject __parent__; + + TDB_CONTEXT *context; + TDB_DATA data; +}; + +static GObjectClass *xfdesktop_metafile_parent_class; + +GType +xfdesktop_metafile_get_type(void) +{ + static GType type = G_TYPE_INVALID; + + if(type == G_TYPE_INVALID) + { + static const GTypeInfo info = + { + sizeof (XfdesktopMetafileClass), + NULL, + NULL, + (GClassInitFunc) xfdesktop_metafile_class_init, + NULL, + NULL, + sizeof (XfdesktopMetafile), + 0, + (GInstanceInitFunc) xfdesktop_metafile_init, + NULL, + }; + + type = g_type_register_static (G_TYPE_OBJECT, I_("XfdesktopMetafile"), &info, 0); + } + + return type; +} + +static void +xfdesktop_metafile_class_init(XfdesktopMetafileClass *klass) +{ + GObjectClass *gobject_class; + + xfdesktop_metafile_parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + gobject_class->finalize = xfdesktop_metafile_finalize; +} + +static void +xfdesktop_metafile_init(XfdesktopMetafile *metafile) +{ + gchar *path; + + /* determine the path to the metafile database */ + path = xfce_resource_lookup(XFCE_RESOURCE_CACHE, "Thunar/metafile.tdb"); + if(path == NULL) { + metafile->context = NULL; + return; + } + + /* try to open the metafile database file */ + metafile->context = tdb_open(path, 0, TDB_DEFAULT, O_RDONLY, 0); + if(metafile->context == NULL) + g_warning("Failed to open metafile database in %s: %s.", path, g_strerror(errno)); + + g_free(path); +} + +static void +xfdesktop_metafile_finalize(GObject *object) +{ + XfdesktopMetafile *metafile = XFDESKTOP_METAFILE(object); + + if(metafile->context != NULL) + tdb_close(metafile->context); + + if(metafile->data.dptr != NULL) + free(metafile->data.dptr); + + (*G_OBJECT_CLASS(xfdesktop_metafile_parent_class)->finalize) (object); +} + +static TDB_DATA +xfdesktop_metafile_read(XfdesktopMetafile *metafile, + TDB_DATA data) +{ + /* perform the fetch operation on the database */ + data = tdb_fetch(metafile->context, data); + if(data.dptr != NULL) { + /* validate the result */ + if(data.dsize < sizeof(guint32) + || (data.dsize % sizeof(guint32)) != 0 + || data.dptr[data.dsize - 1] != '\0') + { + free(data.dptr); + data.dptr = NULL; + data.dsize = 0; + } + } + + return data; +} + +/** + * xfdesktop_metafile_get_default: + * + * Returns a reference to the default #XfdesktopMetafile + * instance. There can be only one #XfdesktopMetafile + * instance at any time. + * + * The caller is responsible to free the returned + * object using g_object_unref() when no longer + * needed. + * + * Return value: a reference to the default #XfdesktopMetafile + * instance. + **/ +XfdesktopMetafile* +xfdesktop_metafile_get_default(void) +{ + static XfdesktopMetafile *metafile = NULL; + + if(metafile == NULL) { + /* allocate a new metafile instance. */ + metafile = g_object_new(XFDESKTOP_TYPE_METAFILE, NULL); + g_object_add_weak_pointer(G_OBJECT(metafile), (gpointer)&metafile); + } else { + /* take a reference for the caller */ + g_object_ref(G_OBJECT(metafile)); + } + + return metafile; +} + +/** + * xfdesktop_metafile_fetch: + * @metafile : a #XfdesktopMetafile. + * @file : a #Gfile. + * @key : a #XfdesktopMetafileKey. + * @default_value : the default value for @key, + * which may be %NULL. + * + * Fetches the value for @key on @path in + * @metafile. Returns a pointer to the + * value if found, or the default value + * if the @key is explicitly not set for + * @path in @metafile, as specified in + * @default_value. + * + * The returned string is owned by @metafile + * and is only valid until the next call to + * xfdesktop_metafile_fetch(), so you might need + * to take a copy of the value if you need to + * keep for a longer period. + * + * Return value: the value for @key on @path + * in @metafile or the default + * value for @key, as specified + * by @default_value. + **/ +const gchar* +xfdesktop_metafile_fetch(XfdesktopMetafile *metafile, + GFile *file, + XfdesktopMetafileKey key, + const gchar *default_value) +{ + const guchar *dend; + const guchar *dp; + TDB_DATA key_data; + gssize key_size; + gchar *key_path = NULL; + + if(file == NULL) + return NULL; + + g_return_val_if_fail(XFDESKTOP_IS_METAFILE(metafile), NULL); + g_return_val_if_fail(G_IS_FILE(file), NULL); + g_return_val_if_fail(key < XFDESKTOP_METAFILE_N_KEYS, NULL); + + /* check if the database handle is available */ + if(metafile->context == NULL) + goto use_default_value; + + /* determine the string representation of the path (using the URI for non-local paths) */ + key_path = g_file_get_uri(file); + key_size = strlen(key_path); + + if(key_size <= 0) + goto use_default_value; + + /* generate the key data */ + key_data.dptr = (unsigned char*)key_path; + key_data.dsize = key_size; + + /* release any earlier result data */ + if(metafile->data.dptr != NULL) + free(metafile->data.dptr); + + /* perform the fetch operation on the database */ + metafile->data = xfdesktop_metafile_read (metafile, key_data); + if(metafile->data.dptr == NULL) + goto use_default_value; + + /* lookup the value for the given key */ + dp = (const guchar *)metafile->data.dptr; + dend = dp + metafile->data.dsize; + for(;;) + { + /* check if we have a match */ + if(*dp == (guint)key) { + g_free(key_path); + return (const gchar *)(dp + 1); + } + + /* lookup the next entry */ + do { + /* skip another 4 bytes */ + dp += sizeof(guint32); + if(dp == dend) + goto use_default_value; + } + while(*(dp - 1) != '\0'); + } + + /* use the default value */ + use_default_value: + g_free(key_path); + return default_value; +} diff --git a/src/xfdesktop-metafile.h b/src/xfdesktop-metafile.h new file mode 100644 index 0000000..6f7eac7 --- /dev/null +++ b/src/xfdesktop-metafile.h @@ -0,0 +1,62 @@ +/* + * xfdesktop - xfce4's desktop manager + * + * Copyright(c) 2006 Brian Tarricone, + * Copyright(c) 2010-2011 Jannis Pohlmann, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * xfdesktop-metafile is based on thunar-metafile code from Thunar + * Copyright (c) 2005-2006 Benedikt Meurer + * Copyright (c) 2009-2011 Jannis Pohlmann + */ + +#ifndef __XFDESKTOP_METAFILE_H__ +#define __XFDESKTOP_METAFILE_H__ + +#include + +G_BEGIN_DECLS; + +#define XFDESKTOP_TYPE_METAFILE (xfdesktop_metafile_get_type()) +#define XFDESKTOP_METAFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFDESKTOP_TYPE_METAFILE, XfdesktopMetafile)) +#define XFDESKTOP_IS_METAFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDESKTOP_TYPE_METAFILE)) +#define XFDESKTOP_METAFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XFDESKTOP_TYPE_METAFILE, XfdesktopMetafileClass)) + +typedef struct _XfdesktopMetafile XfdesktopMetafile; +typedef struct _XfdesktopMetafileClass XfdesktopMetafileClass; + +/** + * XfdesktopMetafileKey: + * @XFDESKTOP_METAFILE_KEY_EMBLEMS : + **/ +typedef enum +{ + XFDESKTOP_METAFILE_KEY_EMBLEMS, + XFDESKTOP_METAFILE_N_KEYS, +} XfdesktopMetafileKey; + +GType xfdesktop_metafile_get_type(void) G_GNUC_CONST; + +XfdesktopMetafile *xfdesktop_metafile_get_default(void); + +const gchar *xfdesktop_metafile_fetch(XfdesktopMetafile *metafile, + GFile *file, + XfdesktopMetafileKey key, + const gchar *default_value); + +G_END_DECLS; + +#endif /* __XFDESKTOP_METAFILE_H__ */ diff --git a/src/xfdesktop-regular-file-icon.c b/src/xfdesktop-regular-file-icon.c index ff5d074..dc8a95e 100644 --- a/src/xfdesktop-regular-file-icon.c +++ b/src/xfdesktop-regular-file-icon.c @@ -55,10 +55,13 @@ #include "xfdesktop-regular-file-icon.h" #define EMBLEM_SYMLINK "emblem-symbolic-link" +#define EMBLEM_READONLY "emblem-readonly" + struct _XfdesktopRegularFileIconPrivate { GdkPixbuf *pix; + gchar *icon_name; gchar *display_name; gchar *tooltip; guint pix_opacity; @@ -98,7 +101,6 @@ static void xfdesktop_regular_file_icon_tfi_init(ThunarxFileInfoIface *iface); static inline void xfdesktop_regular_file_icon_invalidate_pixbuf(XfdesktopRegularFileIcon *icon); - #ifdef HAVE_THUNARX G_DEFINE_TYPE_EXTENDED(XfdesktopRegularFileIcon, xfdesktop_regular_file_icon, XFDESKTOP_TYPE_FILE_ICON, 0, @@ -148,6 +150,7 @@ xfdesktop_regular_file_icon_init(XfdesktopRegularFileIcon *icon) XfdesktopRegularFileIconPrivate); icon->priv->pix_opacity = 100; icon->priv->display_name = NULL; + icon->priv->icon_name = NULL; } static void @@ -178,7 +181,10 @@ xfdesktop_regular_file_icon_finalize(GObject *obj) if(icon->priv->thumbnail_file) g_object_unref(icon->priv->thumbnail_file); - + + if(icon->priv->icon_name) + g_free(icon->priv->icon_name); + G_OBJECT_CLASS(xfdesktop_regular_file_icon_parent_class)->finalize(obj); } @@ -223,6 +229,8 @@ xfdesktop_regular_file_icon_delete_thumbnail_file(XfdesktopIcon *icon) file_icon->priv->thumbnail_file = NULL; } + xfdesktop_file_icon_invalidate_icon(XFDESKTOP_FILE_ICON(icon)); + xfdesktop_regular_file_icon_invalidate_pixbuf(file_icon); xfdesktop_icon_pixbuf_changed(XFDESKTOP_ICON(icon)); } @@ -242,6 +250,8 @@ xfdesktop_regular_file_icon_set_thumbnail_file(XfdesktopIcon *icon, GFile *file) file_icon->priv->thumbnail_file = file; + xfdesktop_file_icon_invalidate_icon(XFDESKTOP_FILE_ICON(icon)); + xfdesktop_regular_file_icon_invalidate_pixbuf(file_icon); xfdesktop_icon_pixbuf_changed(XFDESKTOP_ICON(icon)); } @@ -250,34 +260,29 @@ static GdkPixbuf * xfdesktop_regular_file_icon_peek_pixbuf(XfdesktopIcon *icon, gint size) { - XfdesktopRegularFileIcon *file_icon = XFDESKTOP_REGULAR_FILE_ICON(icon); - gchar *icon_name = NULL; - GdkPixbuf *emblem_pix = NULL; - - if(size != file_icon->priv->cur_pix_size) - xfdesktop_regular_file_icon_invalidate_pixbuf(file_icon); + XfdesktopRegularFileIcon *regular_icon = XFDESKTOP_REGULAR_FILE_ICON(icon); + XfdesktopFileIcon *file_icon = XFDESKTOP_FILE_ICON(icon); - if(!file_icon->priv->pix) { - GIcon *gicon = NULL; + if(size != regular_icon->priv->cur_pix_size) + xfdesktop_regular_file_icon_invalidate_pixbuf(regular_icon); - /* create a GFile for the $HOME/.thumbnails/ directory */ - gchar *thumbnail_dir_path = g_build_filename(xfce_get_homedir(), - ".thumbnails", NULL); - GFile *thumbnail_dir = g_file_new_for_path(thumbnail_dir_path); + /* Still valid */ + if(regular_icon->priv->pix != NULL) + return regular_icon->priv->pix; - if(g_file_has_prefix(file_icon->priv->file, thumbnail_dir)) { - /* use the filename as custom icon name for thumbnails */ - icon_name = g_file_get_path(file_icon->priv->file); + if(!G_IS_ICON(file_icon->gicon)) { + /* Ensure the previous icon_name gets cleared out */ + if(regular_icon->priv->icon_name) { + g_free(regular_icon->priv->icon_name); + regular_icon->priv->icon_name = NULL; + } - /* release thumbnail path */ - g_object_unref(thumbnail_dir); - g_free(thumbnail_dir_path); - } else if(xfdesktop_file_utils_is_desktop_file(file_icon->priv->file_info)) { + if(xfdesktop_file_utils_is_desktop_file(regular_icon->priv->file_info)) { gchar *contents; gsize length; /* try to load the file into memory */ - if(g_file_load_contents(file_icon->priv->file, NULL, &contents, &length, + if(g_file_load_contents(regular_icon->priv->file, NULL, &contents, &length, NULL, NULL)) { /* allocate a new key file */ @@ -286,7 +291,7 @@ xfdesktop_regular_file_icon_peek_pixbuf(XfdesktopIcon *icon, /* try to parse the key file from the contents of the file */ if (g_key_file_load_from_data(key_file, contents, length, 0, NULL)) { /* try to determine the custom icon name */ - icon_name = g_key_file_get_string(key_file, + regular_icon->priv->icon_name = g_key_file_get_string(key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL); @@ -298,68 +303,56 @@ xfdesktop_regular_file_icon_peek_pixbuf(XfdesktopIcon *icon, } } else { /* If we have a thumbnail then they are enabled, use it. */ - if(file_icon->priv->thumbnail_file) + if(regular_icon->priv->thumbnail_file) { - file_icon->priv->pix = gdk_pixbuf_new_from_file_at_size(g_file_get_path(file_icon->priv->thumbnail_file), - size, size, - NULL); + file_icon->gicon = g_file_icon_new(regular_icon->priv->thumbnail_file); + } + else + { + file_icon->gicon = g_file_info_get_icon(regular_icon->priv->file_info); + if(G_IS_ICON(file_icon->gicon)) + g_object_ref(file_icon->gicon); } } - /* load the symlink emblem if necessary */ - if(g_file_info_get_attribute_boolean(file_icon->priv->file_info, - G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK)) + /* Add any user set emblems */ + xfdesktop_file_icon_add_emblems(file_icon); + + /* load the read only emblem if necessary */ + if(!g_file_info_get_attribute_boolean(regular_icon->priv->file_info, + G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) { - GtkIconTheme *itheme = gtk_icon_theme_get_default(); - gint sym_pix_size = size * 2 / 3; - - emblem_pix = gtk_icon_theme_load_icon(itheme, EMBLEM_SYMLINK, - sym_pix_size, ITHEME_FLAGS, - NULL); - if(emblem_pix) { - if(gdk_pixbuf_get_width(emblem_pix) != sym_pix_size - || gdk_pixbuf_get_height(emblem_pix) != sym_pix_size) - { - GdkPixbuf *tmp = gdk_pixbuf_scale_simple(emblem_pix, - sym_pix_size, - sym_pix_size, - GDK_INTERP_BILINEAR); - g_object_unref(emblem_pix); - emblem_pix = tmp; - } - } + GIcon *themed_icon = g_themed_icon_new(EMBLEM_READONLY); + GEmblem *emblem = g_emblem_new(themed_icon); + + g_emblemed_icon_add_emblem(G_EMBLEMED_ICON(file_icon->gicon), emblem); + + g_object_unref(emblem); + g_object_unref(themed_icon); } - if(file_icon->priv->file_info) - gicon = g_file_info_get_icon(file_icon->priv->file_info); + /* load the symlink emblem if necessary */ + if(g_file_info_get_attribute_boolean(regular_icon->priv->file_info, + G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK)) + { + GIcon *themed_icon = g_themed_icon_new(EMBLEM_SYMLINK); + GEmblem *emblem = g_emblem_new(themed_icon); - if(file_icon->priv->pix) { - if(emblem_pix) { - gint emblem_pix_size = gdk_pixbuf_get_width(emblem_pix); - gint dest_size = size - emblem_pix_size; + g_emblemed_icon_add_emblem(G_EMBLEMED_ICON(file_icon->gicon), emblem); - /* We have to add the emblem */ - gdk_pixbuf_composite(emblem_pix, file_icon->priv->pix, - dest_size, dest_size, - emblem_pix_size, emblem_pix_size, - dest_size, dest_size, - 1.0, 1.0, GDK_INTERP_BILINEAR, 255); - } - } else { - file_icon->priv->pix = xfdesktop_file_utils_get_icon(icon_name, gicon, - size, emblem_pix, - file_icon->priv->pix_opacity); + g_object_unref(emblem); + g_object_unref(themed_icon); } - - file_icon->priv->cur_pix_size = size; - - if(emblem_pix) - g_object_unref(emblem_pix); - - g_free(icon_name); } + + regular_icon->priv->pix = xfdesktop_file_utils_get_icon(regular_icon->priv->icon_name, + file_icon->gicon, + size, + regular_icon->priv->pix_opacity); + + regular_icon->priv->cur_pix_size = size; - return file_icon->priv->pix; + return regular_icon->priv->pix; } static G_CONST_RETURN gchar * @@ -690,6 +683,7 @@ xfdesktop_regular_file_icon_update_file_info(XfdesktopFileIcon *icon, regular_file_icon->priv->tooltip = NULL; /* not really easy to check if this changed or not, so just invalidate it */ + xfdesktop_file_icon_invalidate_icon(XFDESKTOP_FILE_ICON(icon)); xfdesktop_regular_file_icon_invalidate_pixbuf(regular_file_icon); xfdesktop_icon_pixbuf_changed(XFDESKTOP_ICON(icon)); } @@ -752,3 +746,4 @@ xfdesktop_regular_file_icon_set_pixbuf_opacity(XfdesktopRegularFileIcon *icon, xfdesktop_regular_file_icon_invalidate_pixbuf(icon); xfdesktop_icon_pixbuf_changed(XFDESKTOP_ICON(icon)); } + diff --git a/src/xfdesktop-special-file-icon.c b/src/xfdesktop-special-file-icon.c index db4b7bc..e7bac1e 100644 --- a/src/xfdesktop-special-file-icon.c +++ b/src/xfdesktop-special-file-icon.c @@ -56,6 +56,7 @@ struct _XfdesktopSpecialFileIconPrivate { XfdesktopSpecialFileIconType type; GdkPixbuf *pix; + gchar *icon_name; gchar *tooltip; gint cur_pix_size; GFileMonitor *monitor; @@ -99,7 +100,6 @@ static void xfdesktop_special_file_icon_tfi_init(ThunarxFileInfoIface *iface); static inline void xfdesktop_special_file_icon_invalidate_pixbuf(XfdesktopSpecialFileIcon *icon); - #ifdef HAVE_THUNARX G_DEFINE_TYPE_EXTENDED(XfdesktopSpecialFileIcon, xfdesktop_special_file_icon, XFDESKTOP_TYPE_FILE_ICON, 0, @@ -145,6 +145,7 @@ xfdesktop_special_file_icon_init(XfdesktopSpecialFileIcon *icon) icon->priv = G_TYPE_INSTANCE_GET_PRIVATE(icon, XFDESKTOP_TYPE_SPECIAL_FILE_ICON, XfdesktopSpecialFileIconPrivate); + icon->priv->icon_name = NULL; } static void @@ -174,7 +175,10 @@ xfdesktop_special_file_icon_finalize(GObject *obj) if(icon->priv->tooltip) g_free(icon->priv->tooltip); - + + if(icon->priv->icon_name) + g_free(icon->priv->icon_name); + G_OBJECT_CLASS(xfdesktop_special_file_icon_parent_class)->finalize(obj); } @@ -219,46 +223,58 @@ static GdkPixbuf * xfdesktop_special_file_icon_peek_pixbuf(XfdesktopIcon *icon, gint size) { - XfdesktopSpecialFileIcon *file_icon = XFDESKTOP_SPECIAL_FILE_ICON(icon); - GIcon *gicon = NULL; - const gchar *custom_icon_name = NULL; + XfdesktopSpecialFileIcon *special_icon = XFDESKTOP_SPECIAL_FILE_ICON(icon); + XfdesktopFileIcon *file_icon = XFDESKTOP_FILE_ICON(icon); GFile *parent = NULL; - if(size != file_icon->priv->cur_pix_size) - xfdesktop_special_file_icon_invalidate_pixbuf(file_icon); - - /* Already have a good icon */ - if(file_icon->priv->pix != NULL) - return file_icon->priv->pix; - - /* use a custom icon name for the local filesystem root */ - parent = g_file_get_parent(file_icon->priv->file); - if(!parent && g_file_has_uri_scheme(file_icon->priv->file, "file")) - custom_icon_name = "drive-harddisk"; - if(parent) - g_object_unref(parent); - - /* use a custom icon for the trash, based on it having files - * the user can delete */ - if(file_icon->priv->type == XFDESKTOP_SPECIAL_FILE_ICON_TRASH) { - if(file_icon->priv->trash_item_count == 0) - custom_icon_name = "user-trash"; - else - custom_icon_name = "user-trash-full"; - } + if(size != special_icon->priv->cur_pix_size) + xfdesktop_special_file_icon_invalidate_pixbuf(special_icon); + + /* Still valid */ + if(special_icon->priv->pix != NULL) + return special_icon->priv->pix; + + if(!G_IS_ICON(file_icon->gicon)) { + /* Ensure the previous icon_name gets cleared out */ + if(special_icon->priv->icon_name) { + g_free(special_icon->priv->icon_name); + special_icon->priv->icon_name = NULL; + } + + /* use a custom icon name for the local filesystem root */ + parent = g_file_get_parent(special_icon->priv->file); + if(!parent && g_file_has_uri_scheme(special_icon->priv->file, "file")) + special_icon->priv->icon_name = g_strdup("drive-harddisk"); + if(parent) + g_object_unref(parent); + + /* use a custom icon for the trash, based on it having files + * the user can delete */ + if(special_icon->priv->type == XFDESKTOP_SPECIAL_FILE_ICON_TRASH) { + if(special_icon->priv->trash_item_count == 0) + special_icon->priv->icon_name = g_strdup("user-trash"); + else + special_icon->priv->icon_name = g_strdup("user-trash-full"); + } - if(file_icon->priv->file_info) - gicon = g_file_info_get_icon(file_icon->priv->file_info); + if(special_icon->priv->file_info) + file_icon->gicon = g_file_info_get_icon(special_icon->priv->file_info); - file_icon->priv->pix = xfdesktop_file_utils_get_icon(custom_icon_name, - gicon, - size, - NULL, - 100); + if(G_IS_ICON(file_icon->gicon)) + g_object_ref(file_icon->gicon); - file_icon->priv->cur_pix_size = size; + /* Add any user set emblems */ + xfdesktop_file_icon_add_emblems(file_icon); + } + + special_icon->priv->pix = xfdesktop_file_utils_get_icon(special_icon->priv->icon_name, + file_icon->gicon, + size, + 100); + + special_icon->priv->cur_pix_size = size; - return file_icon->priv->pix; + return special_icon->priv->pix; } static G_CONST_RETURN gchar * @@ -598,6 +614,7 @@ xfdesktop_special_file_icon_changed(GFileMonitor *monitor, special_file_icon->priv->tooltip = NULL; /* update the icon */ + xfdesktop_file_icon_invalidate_icon(XFDESKTOP_FILE_ICON(special_file_icon)); xfdesktop_special_file_icon_invalidate_pixbuf(special_file_icon); xfdesktop_icon_pixbuf_changed(XFDESKTOP_ICON(special_file_icon)); } @@ -723,3 +740,4 @@ xfdesktop_special_file_icon_get_icon_type(XfdesktopSpecialFileIcon *icon) g_return_val_if_fail(XFDESKTOP_IS_SPECIAL_FILE_ICON(icon), -1); return icon->priv->type; } + diff --git a/src/xfdesktop-volume-icon.c b/src/xfdesktop-volume-icon.c index 734409b..8c3e609 100644 --- a/src/xfdesktop-volume-icon.c +++ b/src/xfdesktop-volume-icon.c @@ -104,7 +104,6 @@ static void xfdesktop_volume_icon_tfi_init(ThunarxFileInfoIface *iface); static inline void xfdesktop_volume_icon_invalidate_pixbuf(XfdesktopVolumeIcon *icon); - #ifdef HAVE_THUNARX G_DEFINE_TYPE_EXTENDED(XfdesktopVolumeIcon, xfdesktop_volume_icon, XFDESKTOP_TYPE_FILE_ICON, 0, @@ -195,7 +194,7 @@ xfdesktop_volume_icon_finalize(GObject *obj) if(icon->priv->tooltip) g_free(icon->priv->tooltip); - + G_OBJECT_CLASS(xfdesktop_volume_icon_parent_class)->finalize(obj); } @@ -255,37 +254,44 @@ static GdkPixbuf * xfdesktop_volume_icon_peek_pixbuf(XfdesktopIcon *icon, gint size) { - XfdesktopVolumeIcon *file_icon = XFDESKTOP_VOLUME_ICON(icon); + XfdesktopVolumeIcon *volume_icon = XFDESKTOP_VOLUME_ICON(icon); + XfdesktopFileIcon *file_icon = XFDESKTOP_FILE_ICON(icon); + gint opacity = 100; g_return_val_if_fail(XFDESKTOP_IS_VOLUME_ICON(icon), NULL); - if(size != file_icon->priv->cur_pix_size) - xfdesktop_volume_icon_invalidate_pixbuf(file_icon); - - if(!file_icon->priv->pix) { - GIcon *gicon = NULL; + if(size != volume_icon->priv->cur_pix_size) + xfdesktop_volume_icon_invalidate_pixbuf(volume_icon); - if(file_icon->priv->volume) - gicon = g_volume_get_icon(file_icon->priv->volume); + /* Still valid */ + if(volume_icon->priv->pix != NULL) + return volume_icon->priv->pix; - file_icon->priv->pix = xfdesktop_file_utils_get_icon(NULL, gicon, size, - NULL, 100); + if(!G_IS_ICON(file_icon->gicon)) { + /* icon changed, get a new one and keep a ref to it */ + if(volume_icon->priv->volume) { + file_icon->gicon = g_volume_get_icon(volume_icon->priv->volume); - /* If the volume isn't mounted show it as semi-transparent */ - if(!xfdesktop_volume_icon_is_mounted(icon)) { - GdkPixbuf *temp; - temp = exo_gdk_pixbuf_lucent(file_icon->priv->pix, 50); + if(G_IS_ICON(file_icon->gicon)) + g_object_ref(file_icon->gicon); - if(temp != NULL) { - g_object_unref(G_OBJECT(file_icon->priv->pix)); - file_icon->priv->pix = temp; - } + /* Add any user set emblems */ + xfdesktop_file_icon_add_emblems(file_icon); } - - file_icon->priv->cur_pix_size = size; } + + /* If the volume isn't mounted show it as semi-transparent */ + if(!xfdesktop_volume_icon_is_mounted(icon)) + opacity = 50; + + volume_icon->priv->pix = xfdesktop_file_utils_get_icon(NULL, + file_icon->gicon, + size, + opacity); + + volume_icon->priv->cur_pix_size = size; - return file_icon->priv->pix; + return volume_icon->priv->pix; } G_CONST_RETURN gchar * @@ -804,6 +810,7 @@ xfdesktop_volume_icon_update_file_info(XfdesktopFileIcon *icon, } /* not really easy to check if this changed or not, so just invalidate it */ + xfdesktop_file_icon_invalidate_icon(XFDESKTOP_FILE_ICON(icon)); xfdesktop_volume_icon_invalidate_pixbuf(volume_icon); xfdesktop_icon_pixbuf_changed(XFDESKTOP_ICON(icon)); } @@ -1005,3 +1012,4 @@ xfdesktop_volume_icon_peek_volume(XfdesktopVolumeIcon *icon) g_return_val_if_fail(XFDESKTOP_IS_VOLUME_ICON(icon), NULL); return icon->priv->volume; } + -- 1.7.9.5