Archive

Posts Tagged ‘dbus’

Hello Remote World!

Some days ago, ross posted in his blog a very interesting example of how to do a RPC with DBus/GObject by using the DBus glib bindings. I’ve taken this example as base for playing with widgets embedded. Basically I’ve created a label to be embedded in a container. The container also will be able to change the text of the label by doing a method invocation.

The xml file that describes the object is as simple as:

 <?xml version="1.0" encoding="UTF-8" ?> <node name="/org/freedesktop/DBus/Tests/Label">   <interface name="org.freedesktop.DBus.Tests.Label">   <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="label"/>     <method name="GetXid">     <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="label_get_xid"/>     <arg type="u" name="xid" direction="out"/>    </method>     <method name="SetText">     <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="label_set_text"/>     <arg type="s" name="text" direction="in"/>    </method>   </interface> </node> 

The method SetText only changes the current text of the label and the implementation is:

 gboolean label_set_text (Label *label, char *text, GError **error) {         gtk_label_set_text (GTK_LABEL (label->label), text); 	gtk_widget_show (label->label);  	return TRUE; } 

The method GetXid is used by the container to obtain the window ID of the label, which is needed to be able to embed it. The code is also very simple:

 gboolean label_get_xid (Label *label, guint32 *xid, GError **error) {         *xid = label->xid;  	return TRUE; } 

The container is a window with an entry and a frame. The frame is the real container of the label, and the entry is used to input the text for changing the label. First of all the container invokes the GetXid method in order to obtain the window ID of the label:

 if (!org_freedesktop_DBus_Tests_Label_get_xid (proxy, &xid, &error)) { 	die ("Call to get_xid failed", error); } 

When the activate signal of the entry is emitted the callback invokes the SetText method of the label:

 static void on_entry_activate (GtkWidget *entry, gpointer gdata) {         DBusGProxy *proxy;         gchar      *text;         GError     *error = NULL;          proxy = (DBusGProxy *) gdata;          text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));          if (!org_freedesktop_DBus_Tests_Label_set_text (proxy, text, &error)) {                 g_free (text);                 die ("Call to set_text failed", error);         }  	g_free (text); } 
Hello Remote World
Hello Remote World

I think it’s a first approach for using DBus instead of bonobo

Categories: GNOME Tags:

The future of GST

February 1st, 2005 No comments

I was talking with garnacho about the future of GST. The problem of the unidirectional communication between backend and frontend is more and more annoying. Garnacho thinks that it’s the moment to modernize GST. I totally agree.

There are two main goals:

  • Use D-BUS for the communication backend – frontend
  • Make a GObject wrapper for a libgst library

Our first task will be to do the perl bindings for D-BUS, because it seems that there are no bindings yet. Then we’ll be able to start working on the backends for providing a D-BUS service.

We’ll be able to do many things that we can’t with the current architecture, like send notifications from the backend to the frontend (for example when a removable network card is detached).

More information: http://live.gnome.org/SystemToolsBackends

I’m desiring to begin! :-)

Categories: GNOME Tags: