[Xfce4-commits] r29789 - in libexo/trunk: . docs/reference/tmpl exo

Jannis Pohlmann jannis at xfce.org
Mon Apr 13 04:22:25 CEST 2009


Author: jannis
Date: 2009-04-13 02:22:25 +0000 (Mon, 13 Apr 2009)
New Revision: 29789

Modified:
   libexo/trunk/ChangeLog
   libexo/trunk/configure.in.in
   libexo/trunk/docs/reference/tmpl/exo-cell-renderer-icon.sgml
   libexo/trunk/exo/Makefile.am
   libexo/trunk/exo/exo-cell-renderer-icon.c
Log:
	* configure.in.in, docs/reference/tmpl/exo-cell-renderer-icon.sgml,
	  exo/Makefile.am, exo/exo-cell-renderer-icon.c: Add GIO to the
	  dependencies and bump GLib to 2.16, GTK+ to 2.14. Add "gicon"
	  property to ExoCellRendererIcon. It benefits from the same SVG
	  speedup as the icon property.

Modified: libexo/trunk/ChangeLog
===================================================================
--- libexo/trunk/ChangeLog	2009-04-12 23:59:06 UTC (rev 29788)
+++ libexo/trunk/ChangeLog	2009-04-13 02:22:25 UTC (rev 29789)
@@ -1,3 +1,11 @@
+2009-04-13	Jannis Pohlmann <jannis at xfce.org>
+
+	* configure.in.in, docs/reference/tmpl/exo-cell-renderer-icon.sgml,
+	  exo/Makefile.am, exo/exo-cell-renderer-icon.c: Add GIO to the 
+	  dependencies and bump GLib to 2.16, GTK+ to 2.14. Add "gicon" 
+	  property to ExoCellRendererIcon. It benefits from the same SVG 
+	  speedup as the icon property.
+
 2009-04-12  Stephan Arts <stephan at xfce.org>
 
 	* == Released 0.3.101 ==

Modified: libexo/trunk/configure.in.in
===================================================================
--- libexo/trunk/configure.in.in	2009-04-12 23:59:06 UTC (rev 29788)
+++ libexo/trunk/configure.in.in	2009-04-13 02:22:25 UTC (rev 29789)
@@ -15,7 +15,7 @@
 m4_define([libexo_version_micro], [101])
 m4_define([libexo_version_nano], [])
 m4_define([libexo_version_build], [r at REVISION@])
-m4_define([libexo_version_tag], [])
+m4_define([libexo_version_tag], [svn])
 m4_define([libexo_version], [libexo_version_major().libexo_version_minor().libexo_version_micro()ifelse(libexo_version_nano(), [], [], [.libexo_version_nano()])ifelse(libexo_version_tag(), [svn], [libexo_version_tag()-libexo_version_build()], [libexo_version_tag()])])
 
 dnl ********************************************
@@ -146,9 +146,10 @@
 dnl ***********************************
 dnl *** Check for required packages ***
 dnl ***********************************
-XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.6.4])
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.4])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
+XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.16.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.2.2])
 
 dnl **************************************

Modified: libexo/trunk/docs/reference/tmpl/exo-cell-renderer-icon.sgml
===================================================================
--- libexo/trunk/docs/reference/tmpl/exo-cell-renderer-icon.sgml	2009-04-12 23:59:06 UTC (rev 29788)
+++ libexo/trunk/docs/reference/tmpl/exo-cell-renderer-icon.sgml	2009-04-13 02:22:25 UTC (rev 29789)
@@ -37,6 +37,11 @@
 
 </para>
 
+<!-- ##### ARG ExoCellRendererIcon:gicon ##### -->
+<para>
+
+</para>
+
 <!-- ##### ARG ExoCellRendererIcon:icon ##### -->
 <para>
 

Modified: libexo/trunk/exo/Makefile.am
===================================================================
--- libexo/trunk/exo/Makefile.am	2009-04-12 23:59:06 UTC (rev 29788)
+++ libexo/trunk/exo/Makefile.am	2009-04-13 02:22:25 UTC (rev 29789)
@@ -96,6 +96,7 @@
 	exo-xsession-client.c
 
 libexo_0_3_la_CFLAGS =							\
+	$(GIO_CFLAGS)							\
 	$(GTK_CFLAGS)							\
 	$(LIBXFCE4UTIL_CFLAGS)
 
@@ -106,6 +107,7 @@
 	-no-undefined
 
 libexo_0_3_la_LIBADD =							\
+	$(GIO_LIBS)							\
 	$(GTK_LIBS)							\
 	$(LIBXFCE4UTIL_LIBS)
 

Modified: libexo/trunk/exo/exo-cell-renderer-icon.c
===================================================================
--- libexo/trunk/exo/exo-cell-renderer-icon.c	2009-04-12 23:59:06 UTC (rev 29788)
+++ libexo/trunk/exo/exo-cell-renderer-icon.c	2009-04-13 02:22:25 UTC (rev 29789)
@@ -1,6 +1,7 @@
 /* $Id$ */
 /*-
  * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>.
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -22,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <gio/gio.h>
+
 #include <exo/exo-cell-renderer-icon.h>
 #include <exo/exo-gdk-pixbuf-extensions.h>
 #include <exo/exo-private.h>
@@ -40,6 +43,7 @@
   PROP_0,
   PROP_FOLLOW_STATE,
   PROP_ICON,
+  PROP_GICON,
   PROP_SIZE,
 };
 
@@ -77,6 +81,7 @@
   guint  follow_state : 1;
   guint  icon_static : 1;
   gchar *icon;
+  GIcon *gicon;
   gint   size;
 };
 
@@ -170,6 +175,25 @@
                                                         EXO_PARAM_READWRITE));
 
   /**
+   * ExoCellRendererIcon:gicon:
+   *
+   * The #GIcon to render. May also be %NULL in which case no icon will be 
+   * rendered for the cell.
+   *
+   * Currently only #GThemedIcon<!---->s are supported which are loaded 
+   * using the current icon theme.
+   *
+   * Since: 0.4.0
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_GICON,
+                                   g_param_spec_object ("gicon",
+                                                        _("GIcon"),
+                                                        _("The GIcon to render."),
+                                                        G_TYPE_ICON,
+                                                        EXO_PARAM_READWRITE));
+
+  /**
    * ExoCellRendererIcon:size:
    *
    * The size in pixel at which to render the icon. This is also the fixed
@@ -203,6 +227,10 @@
   if (!priv->icon_static)
     g_free (priv->icon);
 
+  /* free the GICon */
+  if (priv->gicon != NULL)
+    g_object_unref (priv->gicon);
+
   (*G_OBJECT_CLASS (exo_cell_renderer_icon_parent_class)->finalize) (object);
 }
 
@@ -226,6 +254,10 @@
       g_value_set_string (value, priv->icon);
       break;
 
+    case PROP_GICON:
+      g_value_set_object (value, priv->gicon);
+      break;
+
     case PROP_SIZE:
       g_value_set_int (value, priv->size);
       break;
@@ -264,6 +296,12 @@
         priv->icon = g_strdup (priv->icon);
       break;
 
+    case PROP_GICON:
+      if (priv->gicon != NULL)
+        g_object_unref (priv->gicon);
+      priv->gicon = g_value_dup_object (value);
+      break;
+
     case PROP_SIZE:
       priv->size = g_value_get_int (value);
       break;
@@ -340,42 +378,54 @@
   GdkPixbuf                        *icon;
   GdkPixbuf                        *temp;
   GError                           *err = NULL;
-  gchar                            *display_name;
+  gchar                            *display_name = NULL;
   gint                             *icon_sizes;
   gint                              icon_size;
   gint                              n;
 
   /* verify that we have an icon */
-  if (G_UNLIKELY (priv->icon == NULL))
+  if (G_UNLIKELY (priv->icon == NULL && priv->gicon == NULL))
     return;
 
   /* icon may be either an image file or a named icon */
-  if (g_path_is_absolute (priv->icon))
+  if (priv->icon != NULL && g_path_is_absolute (priv->icon))
     {
       /* load the icon via the thumbnail database */
       icon = _exo_thumbnail_get_for_file (priv->icon, (priv->size > 128) ? EXO_THUMBNAIL_SIZE_LARGE : EXO_THUMBNAIL_SIZE_NORMAL, &err);
     }
-  else
+  else if (priv->icon != NULL || priv->gicon != NULL)
     {
       /* determine the best icon size (GtkIconTheme is somewhat messy scaling up small icons) */
       icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
-      icon_sizes = gtk_icon_theme_get_icon_sizes (icon_theme, priv->icon);
-      for (icon_size = -1, n = 0; icon_sizes[n] != 0; ++n)
+
+      if (priv->icon != NULL)
         {
-          /* we can use any size if scalable, because we load the file directly */
-          if (icon_sizes[n] == -1)
+          icon_sizes = gtk_icon_theme_get_icon_sizes (icon_theme, priv->icon);
+          for (icon_size = -1, n = 0; icon_sizes[n] != 0; ++n)
+            {
+              /* we can use any size if scalable, because we load the file directly */
+              if (icon_sizes[n] == -1)
+                icon_size = priv->size;
+              else if (icon_sizes[n] > icon_size && icon_sizes[n] <= priv->size)
+                icon_size = icon_sizes[n];
+            }
+          g_free (icon_sizes);
+
+          /* if we don't know any icon sizes at all, the icon is probably not present */
+          if (G_UNLIKELY (icon_size < 0))
             icon_size = priv->size;
-          else if (icon_sizes[n] > icon_size && icon_sizes[n] <= priv->size)
-            icon_size = icon_sizes[n];
+
+          /* lookup the icon in the icon theme */
+          icon_info = gtk_icon_theme_lookup_icon (icon_theme, priv->icon, icon_size, 0);
         }
-      g_free (icon_sizes);
+      else if (priv->gicon != NULL)
+        {
+          icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme,
+                                                      priv->gicon, 
+                                                      priv->size, 
+                                                      GTK_ICON_LOOKUP_USE_BUILTIN);
+        }
 
-      /* if we don't know any icon sizes at all, the icon is probably not present */
-      if (G_UNLIKELY (icon_size < 0))
-        icon_size = priv->size;
-
-      /* lookup the icon in the icon theme */
-      icon_info = gtk_icon_theme_lookup_icon (icon_theme, priv->icon, icon_size, 0);
       if (G_UNLIKELY (icon_info == NULL))
         return;
 
@@ -401,9 +451,23 @@
   if (G_UNLIKELY (icon == NULL))
     {
       /* better let the user know whats going on, might be surprising otherwise */
-      display_name = g_filename_display_name (priv->icon);
-      g_warning ("Failed to load \"%s\": %s", display_name, err->message);
-      g_free (display_name);
+      if (G_LIKELY (priv->icon != NULL))
+        {
+          display_name = g_filename_display_name (priv->icon);
+        }
+      else if (G_UNLIKELY (priv->gicon != NULL 
+                           && g_object_class_find_property (G_OBJECT_GET_CLASS (priv->gicon),
+                                                            "name")))
+        {
+          g_object_get (priv->gicon, "name", &display_name, NULL);
+        }
+
+      if (display_name != NULL)
+        {
+          g_warning ("Failed to load \"%s\": %s", display_name, err->message);
+          g_free (display_name);
+        }
+
       g_error_free (err);
       return;
     }




More information about the Xfce4-commits mailing list