gvfs r1839 - in trunk: . monitor/proxy



Author: matthiasc
Date: Mon Jul 28 16:09:47 2008
New Revision: 1839
URL: http://svn.gnome.org/viewvc/gvfs?rev=1839&view=rev

Log:
Support sending GEmblemedIcon over dbus


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/monitor/proxy/gproxyvolumemonitor.c
   trunk/monitor/proxy/gvfsproxyvolumemonitordaemon.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Mon Jul 28 16:09:47 2008
@@ -45,7 +45,7 @@
 DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
 
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.17.4 gthread-2.0 gobject-2.0 gmodule-no-export-2.0 gio-unix-2.0 gio-2.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.17.5 gthread-2.0 gobject-2.0 gmodule-no-export-2.0 gio-unix-2.0 gio-2.0)
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 

Modified: trunk/monitor/proxy/gproxyvolumemonitor.c
==============================================================================
--- trunk/monitor/proxy/gproxyvolumemonitor.c	(original)
+++ trunk/monitor/proxy/gproxyvolumemonitor.c	Mon Jul 28 16:09:47 2008
@@ -841,36 +841,19 @@
   return hash_table;
 }
 
-GIcon *
-_g_icon_new_from_serialized_data (const char *gicon_data)
+static GIcon *
+_g_icon_new_from_tokens (char **tokens, int num_tokens)
 {
-  char **tokens;
   GIcon *icon;
-  guint num_tokens;
-
-  g_return_val_if_fail (gicon_data != NULL, NULL);
-
+  
   icon = NULL;
-
-  tokens = g_strsplit (gicon_data, " ", 0);
-  num_tokens = g_strv_length (tokens);
-
-  if (num_tokens < 2)
-    {
-      g_warning ("malformed GIcon data \"%s\"", gicon_data);
-      goto out;
-    }
-
   if (strcmp (tokens[0], "GFileIcon") == 0)
     {
       GFile *file;
       char *unescaped_uri;
 
       if (num_tokens != 2)
-        {
-          g_warning ("malformed GFileIcon gicon_data \"%s\"", gicon_data);
-          goto out;
-        }
+        goto out;
 
       unescaped_uri = g_uri_unescape_string (tokens[1], NULL);
       file = g_file_new_for_uri (unescaped_uri);
@@ -882,7 +865,6 @@
     {
       int n;
 
-      icon = NULL;
       for (n = 1; n < num_tokens; n++)
         {
           char *unescaped_name;
@@ -895,12 +877,59 @@
           g_free (unescaped_name);
         }
     }
-  else
+  else if (strcmp (tokens[0], "GEmblemedIcon") == 0)
     {
-      g_warning ("cannot parse gicon_data \"%s\"; please add support", gicon_data);
+       int n, m;
+       GIcon *base;
+       GIcon *emblem;
+     
+       n = atoi (tokens[1]);
+       if (num_tokens < n + 2)
+         goto out;
+       m = atoi (tokens[n+2]);
+       if (num_tokens < n + m + 3)
+         goto out;
+       
+       base = _g_icon_new_from_tokens (tokens + 2, n);
+       if (base == NULL)
+         goto out;
+       emblem = _g_icon_new_from_tokens (tokens + n + 3, m);
+       if (emblem == NULL)
+         {
+           g_object_unref (base);
+           goto out;
+         }
+       icon = g_emblemed_icon_new (base, emblem);
+       g_object_unref (base);
+       g_object_unref (emblem);
     }
 
  out:
+   return icon;
+}
+
+GIcon *
+_g_icon_new_from_serialized_data (const char *gicon_data)
+{
+  char **tokens;
+  GIcon *icon;
+  gint num_tokens;
+
+  g_return_val_if_fail (gicon_data != NULL, NULL);
+
+  icon = NULL;
+
+  tokens = g_strsplit (gicon_data, " ", 0);
+
+  if (g_strv_length (tokens) >= 3)
+    {
+      num_tokens = atoi (tokens[0]);
+      icon = _g_icon_new_from_tokens (tokens + 1, num_tokens);
+    }
+
+  if (icon == NULL)
+    g_warning ("malformed GIcon data \"%s\"", gicon_data);
+
   g_strfreev (tokens);
   return icon;
 }

Modified: trunk/monitor/proxy/gvfsproxyvolumemonitordaemon.c
==============================================================================
--- trunk/monitor/proxy/gvfsproxyvolumemonitordaemon.c	(original)
+++ trunk/monitor/proxy/gvfsproxyvolumemonitordaemon.c	Mon Jul 28 16:09:47 2008
@@ -56,9 +56,8 @@
       uri = g_file_get_uri (file);
       escaped_uri = g_uri_escape_string (uri, NULL, TRUE);
 
-      ret = g_strdup_printf ("GFileIcon %s", escaped_uri);
+      ret = g_strdup_printf ("2 GFileIcon %s", escaped_uri);
 
-      g_object_unref (file);
       g_free (uri);
       g_free (escaped_uri);
     }
@@ -73,7 +72,8 @@
                     "names", &names,
                     NULL);
 
-      s = g_string_new ("GThemedIcon");
+      s = g_string_new (0); 
+      g_string_append_printf (s, "%d GThemedIcon", g_strv_length (names) + 1);
 
       if (names != NULL)
         {
@@ -91,6 +91,20 @@
 
       g_strfreev (names);
     }
+  else if (G_IS_EMBLEMED_ICON (icon))
+    {
+      char *base;
+      char *emblem;
+      int n;
+
+      base = _g_icon_serialize (g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon)));
+      emblem = _g_icon_serialize (g_emblemed_icon_get_emblem (G_EMBLEMED_ICON (icon)));
+
+      n = atoi (base) + atoi (emblem) + 3;
+      ret = g_strdup_printf ("%d GEmblemedIcon %s %s", n, base, emblem);
+      g_free (base);
+      g_free (emblem);
+    }
   else
     {
       ret = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]