[Xfce4-commits] [apps/xfdashboard] 05/10: Improve sharing cached image contents between images created for icon-names or file-name directly (via xfdashboard_image_content_new_for_icon_name()) or GIcons derived from GFileIcon or GThemedIcon (via xfdashboard_image_content_new_for_gicon()).

noreply at xfce.org noreply at xfce.org
Wed Jan 6 16:31:39 CET 2016


This is an automated email from the git hooks/post-receive script.

nomad pushed a commit to branch master
in repository apps/xfdashboard.

commit 1a789e6d3e9d1e4d8cff2f24074ca025e4e1b410
Author: Stephan Haller <nomad at froevel.de>
Date:   Wed Jan 6 14:24:37 2016 +0100

    Improve sharing cached image contents between images created for icon-names or file-name directly (via xfdashboard_image_content_new_for_icon_name()) or GIcons derived from GFileIcon or GThemedIcon (via xfdashboard_image_content_new_for_gicon()).
---
 xfdashboard/image-content.c |   62 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 56 insertions(+), 6 deletions(-)

diff --git a/xfdashboard/image-content.c b/xfdashboard/image-content.c
index 0d1bca6..c355e9d 100644
--- a/xfdashboard/image-content.c
+++ b/xfdashboard/image-content.c
@@ -1296,8 +1296,8 @@ void xfdashboard_image_content_init(XfdashboardImageContent *self)
  */
 ClutterContent* xfdashboard_image_content_new_for_icon_name(const gchar *inIconName, gint inSize)
 {
-	ClutterImage		*image;
-	gchar				*key;
+	ClutterImage			*image;
+	gchar					*key;
 
 	g_return_val_if_fail(inIconName!=NULL, NULL);
 	g_return_val_if_fail(inSize>0, NULL);
@@ -1333,12 +1333,62 @@ ClutterContent* xfdashboard_image_content_new_for_icon_name(const gchar *inIconN
  */
 ClutterContent* xfdashboard_image_content_new_for_gicon(GIcon *inIcon, gint inSize)
 {
-	ClutterImage		*image;
-	gchar				*key;
+	ClutterImage			*image;
+	gchar					*key;
 
 	g_return_val_if_fail(G_IS_ICON(inIcon), NULL);
 	g_return_val_if_fail(inSize>0, NULL);
 
+	image=NULL;
+
+	/* If GIcon is a file icon get filename and redirect to create function for
+	 * icon-names/file-names to share images created with this function. If we
+	 * have problems in getting the filename fallthrough to default behaviour.
+	 */
+	if(G_IS_FILE_ICON(inIcon))
+	{
+		GFile				*iconFile;
+		gchar				*iconFilename;
+
+		/* Get file object of icon*/
+		iconFile=g_file_icon_get_file(G_FILE_ICON(inIcon));
+		if(iconFile)
+		{
+			iconFilename=g_file_get_path(iconFile);
+			if(iconFilename)
+			{
+				/* Redirect to create function for icon-names/file-names */
+				image=CLUTTER_IMAGE(xfdashboard_image_content_new_for_icon_name(iconFilename, inSize));
+
+				/* Release allocated resources */
+				g_free(iconFilename);
+
+				/* Return image */
+				return(CLUTTER_CONTENT(image));
+			}
+		}
+	}
+
+	/* If GIcon is a themed icon with exactly one name associated, get name
+	 * and redirect to create function for icon-names/file-names to share
+	 * images created with this function. If we have problems in getting
+	 * the icon-name fallthrough to default behaviour.
+	 */
+	if(G_IS_THEMED_ICON(inIcon))
+	{
+		const gchar* const	*iconNames;
+
+		iconNames=g_themed_icon_get_names(G_THEMED_ICON(inIcon));
+		if(g_strv_length((gchar**)iconNames)==1)
+		{
+			/* Redirect to create function for icon-names/file-names */
+			image=CLUTTER_IMAGE(xfdashboard_image_content_new_for_icon_name(*iconNames, inSize));
+
+			/* Return image */
+			return(CLUTTER_CONTENT(image));
+		}
+	}
+
 	/* Check if we have a cache image for icon otherwise create image instance */
 	key=g_strdup_printf("gicon:%s-%u,%d", G_OBJECT_TYPE_NAME(inIcon), g_icon_hash(inIcon), inSize);
 	if(!key)
@@ -1371,8 +1421,8 @@ ClutterContent* xfdashboard_image_content_new_for_gicon(GIcon *inIcon, gint inSi
  */
 ClutterContent* xfdashboard_image_content_new_for_pixbuf(GdkPixbuf *inPixbuf)
 {
-	ClutterContent		*image;
-	GError				*error;
+	ClutterContent			*image;
+	GError					*error;
 
 	g_return_val_if_fail(GDK_IS_PIXBUF(inPixbuf), NULL);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list