diff --git a/comp/src/gb.dbus.trayicon/.component b/comp/src/gb.dbus.trayicon/.component index e67be7ce3..cf2bbfe43 100644 --- a/comp/src/gb.dbus.trayicon/.component +++ b/comp/src/gb.dbus.trayicon/.component @@ -1,6 +1,6 @@ [Component] Key=gb.dbus.trayicon -Version=3.14.90 +Version=3.15.90 State=2 Hidden=True Needs=ImageIO diff --git a/comp/src/gb.dbus.trayicon/.project b/comp/src/gb.dbus.trayicon/.project index 4e01b2798..e341f1e2b 100644 --- a/comp/src/gb.dbus.trayicon/.project +++ b/comp/src/gb.dbus.trayicon/.project @@ -1,7 +1,7 @@ # Gambas Project File 3.0 Title=Tray icons using the new DBus protocol Startup=Main -Version=3.14.90 +Version=3.15.90 VersionFile=1 Component=gb.image Component=gb.gui diff --git a/comp/src/gb.dbus.trayicon/.src/DBusStatusIconMenu.class b/comp/src/gb.dbus.trayicon/.src/DBusStatusIconMenu.class index 6fc6da287..9f8890a99 100644 --- a/comp/src/gb.dbus.trayicon/.src/DBusStatusIconMenu.class +++ b/comp/src/gb.dbus.trayicon/.src/DBusStatusIconMenu.class @@ -13,7 +13,9 @@ Property Read com_canonical_dbusmenu_IconThemePath As String[] Static Private ALL_PROPS As String[] = ["type", "label", "enabled", "visible", "toggle-type", "toggle-state", "icon-data", "shortcut", "children-display"] Private $aProp As New Collection[] +Private $sProp As String Private $iRevision As Integer +Private $hProp As File Private Function com_canonical_dbusmenu_Version_Read() As _DBusUInt @@ -129,10 +131,13 @@ Private Sub UpdateMenuRec(hMenu As Menu, Optional bChild As Boolean) As Integer Dim aChild As Integer[] Dim aShortcut As String[] Dim sShortcut As String + Dim sPicture As String iId = $aProp.Count cProp["id"] = iId + Write #$hProp, iId As Integer cProp["menu"] = hMenu + Write #$hProp, Object.Address(hMenu) As Pointer 'If iId > 0 Then @@ -149,14 +154,20 @@ Private Sub UpdateMenuRec(hMenu As Menu, Optional bChild As Boolean) As Integer Endif sText = Replace(sText, "&&", "&") cProp["label"] = sText + Write #$hProp, hMenu.Text As String If Not hMenu.Enabled Then cProp["enabled"] = False + Write #$hProp, hMenu.Enabled As Boolean + If bChild And If Not hMenu.Visible Then cProp["visible"] = False + Write #$hProp, hMenu.Visible As Boolean If hMenu.Picture Then sTemp = File.SetExt(Temp$("icon"), "png") hMenu.Picture.Save(sTemp) - cProp["icon-data"] = Byte[].FromString(File.Load(sTemp)) + sPicture = File.Load(sTemp) + cProp["icon-data"] = Byte[].FromString(sPicture) + Write #$hProp, sPicture As String Kill sTemp Endif @@ -167,20 +178,23 @@ Private Sub UpdateMenuRec(hMenu As Menu, Optional bChild As Boolean) As Integer cProp["toggle-type"] = "checkmark" cProp["toggle-state"] = If(hMenu.Value, 1, 0) Endif + Write #$hProp, hMenu.Radio As Boolean + Write #$hProp, hMenu.Toggle Or hMenu.Checked As Boolean ' shortcut sShortcut = hMenu.Shortcut If sShortcut Then - sShortcut = Replace(sShortcut, "Ctrl+", "Control+") aShortcut = Split(sShortcut, "+") cProp["shortcut"] = [aShortcut] Endif + Write #$hProp, hMenu.Shortcut As String 'Endif If hMenu.Children.Count Then cProp["children-display"] = "submenu" + Write #$hProp, hMenu.Children.Count As Integer $aProp.Add(cProp) @@ -198,12 +212,25 @@ Private Sub UpdateMenuRec(hMenu As Menu, Optional bChild As Boolean) As Integer End -Public Sub _UpdateMenu(hMenu As Menu) +Public Sub _UpdateMenu(hMenu As Menu) As Boolean - Inc $iRevision - $aProp.Clear + Dim sProp As String + Dim aProp As Collection[] + + aProp = $aProp + $aProp = New Collection[] + $hProp = Open String For Write UpdateMenuRec(hMenu) + sProp = Close #$hProp + $hProp = Null + If sProp = $sProp Then + $aProp = aProp + Return True + Endif + + $sProp = sProp + Inc $iRevision If DBus.IsRegistered(Me) Then DBus.Raise(Me, "com.canonical.dbusmenu.LayoutUpdated", [_DBusUInt($iRevision), 0]) End diff --git a/comp/src/gb.dbus.trayicon/.src/TrayIcon.class b/comp/src/gb.dbus.trayicon/.src/TrayIcon.class index 7b4ce3c47..039e04870 100644 --- a/comp/src/gb.dbus.trayicon/.src/TrayIcon.class +++ b/comp/src/gb.dbus.trayicon/.src/TrayIcon.class @@ -219,9 +219,9 @@ Private Function PopupMenu_Read() As String End -Private Sub UpdateMenu() +Private Sub UpdateMenu() As Boolean - $hMenu._UpdateMenu(GetMenu()) + Return $hMenu._UpdateMenu(GetMenu()) End @@ -299,8 +299,7 @@ End Public Sub _AboutToShow(hMenu As Menu) As Boolean Object.Raise(hMenu, "Show") - UpdateMenu - Return True + Return Not UpdateMenu() End