Re: [Gambas-user] More DBus queries - signals

2017-08-20 Thread Tony Morehen

I see nothing amiss in your code.

This is the code I use for a DbusObject.  It is used to control a 
desktop menu application.  Note the event declaration.  DbusObject is 
missing, but implicit to the class.  I raise the event the same way you do:


  DBus.Raise(hDbusObj, 
"org.ajmconsulting.gbmenu.App.StartupNotification", [$key, pid])


$key is a AppName.desktop file, pid is the id/handle of the process just 
launched.


' Gambas class file
' hDbusObj


Inherits DBusObject
Private ClientCount As Integer = -1

Event org_ajmconsulting_gbmenu_App_StartupNotification(sName As String, 
pid As Integer)


Public Function org_ajmconsulting_gbmenu_App_show() As Boolean

  FMain.Show
  '   Debug "show"
  Desktop.ActiveWindow = FMain.Id
  Return FMain.Visible

End

Public Function org_ajmconsulting_gbmenu_App_showAt(Optional X As 
Integer, Y As Integer, Gravity As String) As Boolean

  '   Debug "showat", X, Y, Gravity

  If X < 10 Then X = 0
  Select Case String.LCase(Gravity)
Case "northwest"
  FMain.x = X
  FMain.y = Y
Case "west"
  FMain.x = X
  FMain.y = Y - FMain.Height / 2
Case "southwest"
  FMain.x = X
  FMain.y = Y - FMain.Height
Case "north"
  FMain.x = X - FMain.Width / 2
  FMain.y = Y
Case "center", "centre"
  FMain.x = X - FMain.Width / 2
  FMain.y = Y - FMain.Height / 2
Case "south"
  FMain.x = X - FMain.Width / 2
  FMain.y = Y - FMain.Height
Case "northeast"
  FMain.x = X - FMain.Width
  FMain.y = Y
Case "east"
  FMain.x = X - FMain.Width
  FMain.y = Y - FMain.Height / 2
Case "southeast"
  FMain.x = X - FMain.Width
  FMain.y = Y - FMain.Height
  End Select
  Return org_ajmconsulting_gbmenu_App_show()

End

Public Function org_ajmconsulting_gbmenu_App_showToggle() As Boolean

  '   Debug "showtoggle"
  If FMain.Visible Then
Return org_ajmconsulting_gbmenu_App_hide()
  Else
Return org_ajmconsulting_gbmenu_App_show()
  Endif

End

Public Function org_ajmconsulting_gbmenu_App_showPreferences() As Boolean

  FSetup.Run
  '   Debug "setup"
  Return True

End

Public Function org_ajmconsulting_gbmenu_App_showCentered() As Boolean
  '   Debug "showCentered"

  FMain.X = (Screen.W - FMain.W) / 2
  FMain.Y = (Screen.H - FMain.H) / 2
  Return org_ajmconsulting_gbmenu_App_show()

End

Public Function org_ajmconsulting_gbmenu_App_hide() As Boolean
  '   Debug "hide"

  FMain.Visible = False
  Return Not FMain.Visible

End

Public Function org_ajmconsulting_gbmenu_App_isShowing() As Boolean
  '   Debug "isShowing"

  Return FMain.Visible

End

Public Function org_ajmconsulting_gbmenu_App_addClient() As Integer
  '   Debug "addClient"

  Inc ClientCount
  Return ClientCount

End

Public Function org_ajmconsulting_gbmenu_App_removeClient(arg1 As 
Integer) As Boolean

  '   Debug "removeClient", arg1

  Return True

End

Public Function org_ajmconsulting_gbmenu_App_getDesktopFilePath(arg1 As 
String) As String

  '   Debug "removeClient", arg1

  Return FMain.$DesktopFiles[arg1].Location

End

Public Function org_ajmconsulting_gbmenu_App_getIconPath(arg1 As 
String[], sz As Integer) As String

  '   Debug "removeClient", arg1

  Return Icons.GetIconPath(arg1, sz)

End


On 2017-08-20 10:38 AM, adamn...@gmail.com wrote:

The wiki @ http://gambaswiki.org/wiki/doc/dbus#t9 says
"...
The name of the event must be the normalized name of the interface, followed by 
an underscore and the normalized name of the signal.
The signal is emitted to the D-Bus bus by using the DBusApplication.Raise 
method.
..."

for the last few days I've been raising DBus signals simply by calling 
something like:

   Event Message(text As String, origin As String)
...
   DBus.Raise(Me, "Message", [msg.Text, "Self"])

 being a DBusObject child object
<"Message"> being the signal name as registered on the bus
 being the text parameter for the event as it is known inside the 
gambas code
<"Self"> being the origin parameter

This seems to be working fine. Am I doing something unsupported that is likely 
to disappear?

tia
b




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] More DBus queries - signals

2017-08-20 Thread adamn...@gmail.com
The wiki @ http://gambaswiki.org/wiki/doc/dbus#t9 says 
"...
The name of the event must be the normalized name of the interface, followed by 
an underscore and the normalized name of the signal.
The signal is emitted to the D-Bus bus by using the DBusApplication.Raise 
method.
..."

for the last few days I've been raising DBus signals simply by calling 
something like:

  Event Message(text As String, origin As String)
...
  DBus.Raise(Me, "Message", [msg.Text, "Self"])

 being a DBusObject child object
<"Message"> being the signal name as registered on the bus
 being the text parameter for the event as it is known inside the 
gambas code
<"Self"> being the origin parameter

This seems to be working fine. Am I doing something unsupported that is likely 
to disappear?

tia
b
-- 
B Bruen 

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user