[Gambas-user] gb.dbus and signals
Fabien Bodard
gambas.fr at ...626...
Fri Jun 26 19:03:26 CEST 2015
Le 26 juin 2015 13:36, "Benoît Minisini" <gambas at ...1...> a
écrit :
>
> Hi,
>
> In revision #7146 I have added to the gb.dbus component the ability to
> raise signals.
>
> How does it work?
>
> All events defined in your DBusObject become DBus signals.
>
> The name of the event must be the name of the interface where all dots
> are replaced by underscore, followed by an underscore and the name of
> the signal. If the event is for the default interface, just the signal
> name is enough.
>
> Don't forget to add the interface name when calling the Register() method.
>
> To actually raise the signal on a specific bus, you don't use the RAISE
> instruction, but the DBus.Session.Raise() or the DBus.System.Raise()
method.
>
> That method takes 3 arguments :
> - The DBus object.
> - The signal name, which is the event name where "_" are replaced by ".".
> - An optional array of signal arguments.
>
> Signal arguments and event signature must match, otherwise I don't know
> what happens. :-)
>
> A little dummy example:
>
> --8<-------------------------------------------------------------------
>
> ' Gambas class file
>
> Inherits DBusObject
>
> Event org_freedesktop_StatusNotifierItem_IconChanged
> Event org_freedesktop_StatusNotifierItem_NewStatus(sStatus As String)
>
> Property Read org_freedesktop_StatusNotifierItem_Category As String
>
> Public Sub org_freedesktop_StatusNotifierItem_Activate(X As Integer, Y
> As Integer)
>
> End
>
> Private Function org_freedesktop_StatusNotifierItem_Category_Read() As
> String
>
> End
>
> ...
>
> Public Sub Main()
>
> DBus.Session.Register(hObject, "/StatusNotifierItem",
> ["org.freedesktop.StatusNotifierItem"])
> ' This is needed at the moment so that the current application is
> visible under different names
> DBus.Session._RequestName("org.freedesktop.StatusNotifierItem-" &
> CStr(Application.Handle) & "-1", True)
>
> DBus.Session.Raise(hObject,
> "org.freedesktop.StatusNotifierItem.IconChanged")
> DBus.Session.Raise(hObject,
> "org.freedesktop.StatusNotifierItem.NewStatus", ["Chuck!"])
>
> Wait 1
>
> DBus.Session.Unregister(hObject)
>
> End
>
> --8<-------------------------------------------------------------------
>
> I'm currently creating a gb.form.statusicon component that will allow to
> use the new system tray protocol (but not the old one!)
>
Cool 😊
> Regards,
>
> --
> Benoît Minisini
>
>
------------------------------------------------------------------------------
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download now
> http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list