[GB.DBUS]

* NEW: A class inheriting DBusVariant can be used a DBus method return 
  value.
* BUG: unregistering an object correctly removes it from the children list
  of its parent.
* NEW: DBus.SplitSignature has been renamed as DBus._SplitSignature.

[GB.DBUS.TRAYICON]
* BUG: Correctly unregister KDE-style trayicons.


git-svn-id: svn://localhost/gambas/trunk@7167 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2015-07-02 22:26:05 +00:00
parent 7403b03a0b
commit 47fd153ba0
5 changed files with 33 additions and 15 deletions

View File

@ -62,7 +62,7 @@ Public Sub com_canonical_dbusmenu_GetGroupProperties(IdList As Integer[], Proper
Next
hResult = New _DBusMenuProperties
hResult.Value = [aResult]
hResult.Value = aResult
Return hResult
End
@ -134,7 +134,7 @@ Private Sub UpdateMenuRec(hMenu As Menu) As Integer
cProp["id"] = iId
cProp["menu"] = hMenu
If iId > 0 Then
'If iId > 0 Then
sText = hMenu.Text
If Not sText Then cProp["type"] = "separator"
@ -178,7 +178,7 @@ Private Sub UpdateMenuRec(hMenu As Menu) As Integer
cProp["shortcut"] = [aShortcut]
Endif
Endif
'Endif
If hMenu.Children.Count Then cProp["children-display"] = "submenu"
@ -200,15 +200,11 @@ End
Public Sub _UpdateMenu(hMenu As Menu)
Dim hRevision As _DBusUInt
Inc $iRevision
$aProp.Clear
UpdateMenuRec(hMenu)
hRevision = New _DBusUInt
hRevision.Value = $iRevision
DBus.Raise(Me, "com.canonical.dbusmenu.LayoutUpdated", [hRevision, 0])
DBus.Raise(Me, "com.canonical.dbusmenu.LayoutUpdated", [_DBusUInt($iRevision), 0])
End

View File

@ -108,7 +108,8 @@ Public Sub Hide()
If $bAppIndicator Then
DBus[sService].Raise($hObject, "org.kde.StatusNotifierItem.NewStatus", ["Passive"])
Else
Else
DBus[sService].Unregister($hMenu)
DBus[sService].Unregister($hObject)
Endif

View File

@ -1,6 +1,6 @@
' Gambas class file
Export
Inherits DBusValues
Inherits DBusVariant
Public Const Signature As String = "a(ia{sv})"

View File

@ -67,7 +67,7 @@ GB_DESC CDBusDesc[] =
GB_CONSTANT("Signal", "i", DBUS_MESSAGE_TYPE_SIGNAL),
GB_CONSTANT("Error", "i", DBUS_MESSAGE_TYPE_ERROR),
GB_STATIC_METHOD("SplitSignature", "String[]", DBus_SplitSignature, "(Signature)s"),
GB_STATIC_METHOD("_SplitSignature", "String[]", DBus_SplitSignature, "(Signature)s"),
GB_END_DECLARE
};

View File

@ -81,6 +81,20 @@ Public Sub _AddChild(sChild As String)
End
Public Sub _RemoveChild(sChild As String)
Dim iPos As Integer
If Not $aChildren Then Return
iPos = $aChildren.Find(sChild)
If iPos >= 0 Then
$aChildren.Remove(iPos)
If $aChildren.Count = 0 Then $aChildren = Null
Endif
End
Public Sub _Register(hConnection As DBusConnection, sFullPath As String, Optional aInterface As String[])
Dim hParent As DBusObject
@ -163,17 +177,22 @@ Public Sub _Unregister(hConnection As DBusConnection)
Endif
If $aChildren Then
For Each sChild In $aChildren
For Each sChild In $aChildren.Copy()
hChild = _ObjectCache[$sFullPath &/ sChild]
hChild._Unregister(hConnection)
Next
$aChildren = Null
Endif
hParent = _ObjectCache[File.Dir($sFullPath)]
If hParent Then hParent._RemoveChild(File.Name($sFullPath))
$hObserver = Null
_ObjectCache[$sFullPath] = Null
$sFullPath = ""
$sPath = ""
If _ObjectCache.Count = 0 Then
DBus._UnregisterApplication(hConnection)
$sName = ""
@ -368,7 +387,7 @@ Public Sub _Introspect() As String
If sType Then
If bMulti Then
aType = DBus.SplitSignature(sType)
aType = DBus._SplitSignature(sType)
For I = 0 To aType.Max
sDesc &= " <arg name=\"value" & CStr(I + 1) & "\" type=\"" & aType[I] & "\" direction=\"out\"/>\n"
Next
@ -496,7 +515,7 @@ Private Sub GetAllProperties()
Catch
If DBus.Debug Then Error "gb.dbus: org.freedesktop.Properties.GetAll: error: "; Error.Text
If DBus.Debug Then Error "gb.dbus: org.freedesktop.Properties.GetAll: error: "; Error.Text;; Error.Backtrace.Join(" ")
$hObserver.Error(Error.Text)
End
@ -584,6 +603,9 @@ Public Sub DBusObserver_Message()
If TypeOf(vVal) = gb.Object And If vVal Is DBusValues Then
sType = vVal.Signature
$hObserver.Reply(sType, vVal.Value)
Else If TypeOf(vVal) = gb.Object And If vVal Is DBusVariant Then
sType = vVal.Signature
$hObserver.Reply(sType, [vVal.Value])
Else
sType = ConvType(sType)
If Not sType Then sType = "v"
@ -596,7 +618,6 @@ Public Sub DBusObserver_Message()
Catch
'Debug Error.Text
If DBus.Debug Then Error "gb.dbus: "; sInterface; "."; sMethod; ": error: "; Error.Text;; Error.Backtrace.Join(" ")
$hObserver.Error(Error.Text)