[Xfce4-commits] r29962 - in xfconf/trunk: . xfconf

Brian Tarricone kelnos at xfce.org
Fri May 15 06:06:02 CEST 2009


Author: kelnos
Date: 2009-05-15 04:06:01 +0000 (Fri, 15 May 2009)
New Revision: 29962

Modified:
   xfconf/trunk/NEWS
   xfconf/trunk/xfconf/Makefile.am
   xfconf/trunk/xfconf/xfconf-binding.c
Log:
hopefully speed up app start time (for apps that do a decent number of
property bindings) by making the initial property fetch async

Modified: xfconf/trunk/NEWS
===================================================================
--- xfconf/trunk/NEWS	2009-05-15 01:00:30 UTC (rev 29961)
+++ xfconf/trunk/NEWS	2009-05-15 04:06:01 UTC (rev 29962)
@@ -1,3 +1,10 @@
+Xfce 4.6.2
+==========
+
+  * Speed up startup of many apps that use bindings by retrieving the
+    initial value of the binding asynchronously.
+
+
 Xfce 4.6.1
 ==========
 

Modified: xfconf/trunk/xfconf/Makefile.am
===================================================================
--- xfconf/trunk/xfconf/Makefile.am	2009-05-15 01:00:30 UTC (rev 29961)
+++ xfconf/trunk/xfconf/Makefile.am	2009-05-15 04:06:01 UTC (rev 29962)
@@ -52,6 +52,9 @@
 
 xfconf-dbus-bindings.h: $(top_srcdir)/common/xfconf-dbus.xml Makefile
 	dbus-binding-tool --mode=glib-client $< > $@
+	sed -i -e 's/^\([[:space:]]\+GValue[[:space:]]\+[^=]\)\+;$/\1 = { 0, };/' $@
+# the above line fixes a bug in dbus-binding-tool's output
+# dbus-binding-tool doesn't initialise GValues to { 0, } properly
 
 if HAVE_GNUC_VISIBILITY
 TESTS = abicheck.sh

Modified: xfconf/trunk/xfconf/xfconf-binding.c
===================================================================
--- xfconf/trunk/xfconf/xfconf-binding.c	2009-05-15 01:00:30 UTC (rev 29961)
+++ xfconf/trunk/xfconf/xfconf-binding.c	2009-05-15 04:06:01 UTC (rev 29962)
@@ -31,6 +31,7 @@
 #include "xfconf-private.h"
 #include "xfconf-alias.h"
 #include "xfconf-common-private.h"
+#include "xfconf-dbus-bindings.h"
 
 typedef struct
 {
@@ -43,6 +44,9 @@
     GObject *object;
     gchar *object_property;
     GType object_property_type;
+
+    /* async call to get initial value */
+    DBusGProxyCall *call;
 } XfconfGBinding;
 
 typedef struct
@@ -76,6 +80,9 @@
     if(G_UNLIKELY(!binding))
         return;
 
+    if(G_UNLIKELY(binding->call))
+        dbus_g_proxy_cancel_call(_xfconf_get_dbus_g_proxy(), binding->call);
+
     if(binding->object) {
         g_signal_handlers_disconnect_by_func(G_OBJECT(binding->object),
                                              G_CALLBACK(xfconf_g_binding_object_property_changed),
@@ -282,6 +289,31 @@
     g_value_unset(&dst_val);
 }
 
+static void
+xfconf_g_binding_initial_value_received(DBusGProxy *proxy,
+                                        GValue value,
+                                        GError *error,
+                                        gpointer user_data)
+{
+    XfconfGBinding *binding = user_data;
+
+    binding->call = NULL;
+
+    if(error) {
+        g_warning("Initial query for property \"%s\" failed: %s",
+                  binding->xfconf_property, error->message);
+        g_error_free(error);
+        return;
+    }
+
+    xfconf_g_binding_channel_property_changed(binding->channel,
+                                              binding->xfconf_property,
+                                              &value,
+                                              binding);
+    g_value_unset(&value);
+}
+
+
 static XfconfGBinding *
 xfconf_g_binding_init(XfconfChannel *channel,
                       const gchar *xfconf_property,
@@ -291,9 +323,8 @@
                       GType object_property_type)
 {
     XfconfGBinding *binding;
-    gchar buf[1024];
+    gchar buf[1024], *channel_name = NULL;
     GSList *bindings;
-    GValue value = { 0, };
 
     binding = g_slice_new0(XfconfGBinding);
     binding->channel = channel;
@@ -340,11 +371,13 @@
                                bindings, (GDestroyNotify)g_slist_free);
     }
 
-    if(xfconf_channel_get_property(channel, xfconf_property, &value)) {
-        xfconf_g_binding_channel_property_changed(channel, xfconf_property,
-                                                  &value, binding);
-        g_value_unset(&value);
-    }
+    g_object_get(G_OBJECT(channel), "channel-name", &channel_name, NULL);
+    binding->call = xfconf_client_get_property_async(_xfconf_get_dbus_g_proxy(),
+                                                     channel_name,
+                                                     xfconf_property,
+                                                     xfconf_g_binding_initial_value_received,
+                                                     binding);
+    g_free(channel_name);
 
     binding->id = ++__last_binding_id;
     if(G_UNLIKELY(binding->id == 0)) {




More information about the Xfce4-commits mailing list