Adding Dbus support to Gedit

At this moment, when you start a second Gedit process , it opens a new tab in your current Gedit window instead of creating a new one. This behaviour has been added from scratch in Gedit using the so called bacon-message, developed by them.

Today I’ve started working on the replacement of bacon-message stuff of Gedit with Dbus.  I started by creating a GObject that contains all the Dbus related behaviour.

My first problem was that I needed to know if the current Gedit process is a server (first Gedit  process in the user session) or a client (not  the first). To solve this issue I had to check the result of the org_freedesktop_DBus_request_name function (which tries to register the Dbus service name). The tricky part was to find the set of result #defines and examine their behaviour depending on the flags you use when requesting the name.
Once I’ve solved this issue, it was not too dificult to finish this Dbus object, and at this moment I have tested Dbus setup inside Gedit and it seems to be working fine :).

Next time I’ll start replacing bacon-message stuff in gedit.c main with my brand new Dbus stuff. Let’s see how it works 🙂

Getting started with Dbus

Hackfest time at Igalia :), Sergio and me spent some time trying to get started with Dbus programming. We begun with a brief look at the Dbus Tutorial, which was an excellent place to start. However, we got stuck with some minor issues, like the need to manually start the session bus daemon using the dbus-launch program and the need to set a couple of environment variables in order to let our program connect to the bus.

Once we solved the above problems, we spent some more time before it worked properly, because we lacked one step when exporting an object using Dbus, which is to register the service name. This is done by using the org_freedesktop_DBus_request_name function.

Solved the above, all worked fine!. Next step will be to analyze how to substitute bacon-mesage-connection in Gedit with Dbus, but this will be another story ;).