GObject signals
Sadrul Habib Chowdhury
imadil at gmail.com
Tue Jun 24 17:26:30 EDT 2008
Hello everyone.
There was some work done in i.p.gobjectification branch this weekend. One
of the issue that has crept up is regarding the signals. With the current
purple signal system, the signals are 'per module'. For example, whenever
an account goes online, a 'signed-on' signal is emitted. If a callback is
interested in only a particular account, it has to perform a check in the
callback to make sure it performs any operation on the account of its
interest, because the callback will be triggered when *any* account goes
online. With the gobject signals, this becomes simpler, since it has
per-object signals. So, if the callback is interested in only one
account, it connects to the 'signed-on' signal for that account, and the
callback is not triggered when some other account goes online.
However, there are a lot of places where the callback doesn't care about
any particular object. Rather, it needs to be triggered for some event on
*any* object in a module. For example, the statusbox in the buddylist
needs to be updated when *any* account changes status. Doing this is
pretty simple in the current purple signal system. However, with the
gobject signals, as far as I understand, this is not as simple. The
statusbox has to connect to the 'signed-on' signal for every account. Not
only that, it has to make sure that whenever a new account is added, it
connects to the 'signed-on' signal for that account too. This is rather
tedious, and we really need to have a better way of facilitating such
'per module' events.
(You can take a look at 5ddd94fb6809d2acabfe23720c14ae24b37a9fd9, for
reference).
A very simple solution would be to have a PurpleModule object for each
module (e.g. PurpleModuleAccount etc.). This will replace the current
usage of 'handle'. So, if something is interested in an event on any
object from a module, it connects to the corresponding signal for that
module (instead of connecting to the signal on an object). With this fix,
every event will trigger two signals, one on the object, and one on the
module. The callbacks can connect to whichever one it wants to. Does this
sound like a good solution? (If you are following the .gobjectification
branch, you may have noticed that there's a PurpleAccountManager object,
which can act as the PurpleModuleAccount)
Or can someone suggest a better/simpler way of handling this?
PS: I will be happy to clarify anything I may have explained incoherently
(language is not my strongest point!).
Sadrul
More information about the Devel
mailing list