From eb2b172425b40278b52181923680c05ba67f842a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Thu, 2 Jul 2015 23:05:52 +0000 Subject: [PATCH] [GB.DBUS.TRAYICON] * NEW: Add TrayIcon MiddleClick event. [GB.QT4] * NEW: Add TrayIcon MiddleClick event. [GB.QT5] * NEW: Add TrayIcon MiddleClick event. [GB.GTK] * NEW: Add TrayIcon MiddleClick event. [GB.GTK3] * NEW: Add TrayIcon MiddleClick event. git-svn-id: svn://localhost/gambas/trunk@7169 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- comp/src/gb.dbus.trayicon/.src/DBusStatusIcon.class | 4 ++-- comp/src/gb.dbus.trayicon/.src/FTest.class | 6 ++++++ comp/src/gb.dbus.trayicon/.src/TrayIcon.class | 7 +++++++ gb.gtk/src/CTrayIcon.cpp | 9 +++++++-- gb.gtk/src/gtrayicon.cpp | 4 ++-- gb.gtk/src/gtrayicon.h | 2 +- gb.qt4/src/ctrayicon.cpp | 6 ++++++ 7 files changed, 31 insertions(+), 7 deletions(-) diff --git a/comp/src/gb.dbus.trayicon/.src/DBusStatusIcon.class b/comp/src/gb.dbus.trayicon/.src/DBusStatusIcon.class index 8fe8d120a..752cbb0a3 100644 --- a/comp/src/gb.dbus.trayicon/.src/DBusStatusIcon.class +++ b/comp/src/gb.dbus.trayicon/.src/DBusStatusIcon.class @@ -213,13 +213,13 @@ End Public Sub org_kde_StatusNotifierItem_SecondaryActivate((X) As Integer, (Y) As Integer) - Debug + GetParent()._MiddleClick() End Public Sub org_kde_StatusNotifierItem_XAyatanaSecondaryActivate((Foo) As Integer) - Debug + GetParent()._MiddleClick() End diff --git a/comp/src/gb.dbus.trayicon/.src/FTest.class b/comp/src/gb.dbus.trayicon/.src/FTest.class index e71a7f0a9..e0c18742b 100644 --- a/comp/src/gb.dbus.trayicon/.src/FTest.class +++ b/comp/src/gb.dbus.trayicon/.src/FTest.class @@ -48,3 +48,9 @@ Public Sub Menu5_Click() Debug End + +Public Sub TrayIcon1_MiddleClick() + + Debug + +End diff --git a/comp/src/gb.dbus.trayicon/.src/TrayIcon.class b/comp/src/gb.dbus.trayicon/.src/TrayIcon.class index 6a5e4cee8..fc1c8106d 100644 --- a/comp/src/gb.dbus.trayicon/.src/TrayIcon.class +++ b/comp/src/gb.dbus.trayicon/.src/TrayIcon.class @@ -11,6 +11,7 @@ Public Const _DefaultEvent As String = "Click" Public Enum Horizontal, Vertical Event Click +Event MiddleClick Event Scroll(Delta As Float, Orientation As Integer) Property Name As String @@ -288,3 +289,9 @@ Public Sub _AboutToShow(hMenu As Menu) As Boolean Return True End + +Public Sub _MiddleClick() + + Raise MiddleClick + +End diff --git a/gb.gtk/src/CTrayIcon.cpp b/gb.gtk/src/CTrayIcon.cpp index ae0b4d455..43fbed176 100644 --- a/gb.gtk/src/CTrayIcon.cpp +++ b/gb.gtk/src/CTrayIcon.cpp @@ -34,6 +34,7 @@ #include "gmouse.h" DECLARE_EVENT(EVENT_Click); +DECLARE_EVENT(EVENT_MiddleClick); DECLARE_EVENT(EVENT_Scroll); static void cb_destroy(gTrayIcon *sender) @@ -43,9 +44,12 @@ static void cb_destroy(gTrayIcon *sender) GB.Unref(POINTER(&_object)); } -static void cb_click(gTrayIcon *sender) +static void cb_click(gTrayIcon *sender, int button) { - GB.Raise(sender->hFree, EVENT_Click, 0); + if (button == 1) + GB.Raise(sender->hFree, EVENT_Click, 0); + else if (button == 2) + GB.Raise(sender->hFree, EVENT_MiddleClick, 0); } static void cb_menu(gTrayIcon *sender) @@ -321,6 +325,7 @@ GB_DESC TrayIconDesc[] = GB_PROPERTY("Tag", "v", TrayIcon_Tag), GB_EVENT("Click", NULL, NULL, &EVENT_Click), + GB_EVENT("MiddleClick", NULL, NULL, &EVENT_MiddleClick), GB_EVENT("Scroll", NULL, "(Delta)f(Orientation)i", &EVENT_Scroll), GB_METHOD("_unknown", "v", TrayIcon_unknown, "."), diff --git a/gb.gtk/src/gtrayicon.cpp b/gb.gtk/src/gtrayicon.cpp index 60f10c700..a362d8bba 100644 --- a/gb.gtk/src/gtrayicon.cpp +++ b/gb.gtk/src/gtrayicon.cpp @@ -62,8 +62,8 @@ static gboolean cb_button_press(GtkStatusIcon *plug, GdkEventButton *event, gTra { gMouse::validate(); gMouse::setMouse((int)event->x, (int)event->y, (int)event->x_root, (int)event->y_root, event->button, event->state); - if (event->type == GDK_BUTTON_PRESS && event->button == 1) - data->onClick(data); + if (event->type == GDK_BUTTON_PRESS) + data->onClick(data, event->button); /*else if (event->type == GDK_2BUTTON_PRESS) data->onDoubleClick(data);*/ gMouse::invalidate(); diff --git a/gb.gtk/src/gtrayicon.h b/gb.gtk/src/gtrayicon.h index 72fe026fe..61b527322 100644 --- a/gb.gtk/src/gtrayicon.h +++ b/gb.gtk/src/gtrayicon.h @@ -52,7 +52,7 @@ public: int loopLevel() { return _loopLevel; } //"Events" - void (*onClick)(gTrayIcon *sender); + void (*onClick)(gTrayIcon *sender, int button); void (*onScroll)(gTrayIcon *sender); void (*onMenu)(gTrayIcon *sender); void (*onDestroy)(gTrayIcon *sender); diff --git a/gb.qt4/src/ctrayicon.cpp b/gb.qt4/src/ctrayicon.cpp index 173264a16..eade2847b 100644 --- a/gb.qt4/src/ctrayicon.cpp +++ b/gb.qt4/src/ctrayicon.cpp @@ -33,6 +33,7 @@ #include "ctrayicon.h" DECLARE_EVENT(EVENT_Click); +DECLARE_EVENT(EVENT_MiddleClick); DECLARE_EVENT(EVENT_Scroll); static QList _list; @@ -372,6 +373,10 @@ void TrayIconManager::activated(QSystemTrayIcon::ActivationReason reason) GB.Raise(THIS, EVENT_Click, 0); break; + case QSystemTrayIcon::MiddleClick: + GB.Raise(THIS, EVENT_MiddleClick, 0); + break; + default: break; } @@ -439,6 +444,7 @@ GB_DESC TrayIconDesc[] = GB_PROPERTY("Tag", "v", TrayIcon_Tag), GB_EVENT("Click", NULL, NULL, &EVENT_Click), + GB_EVENT("MiddleClick", NULL, NULL, &EVENT_MiddleClick), GB_EVENT("Scroll", NULL, "(Delta)f(Orientation)i", &EVENT_Scroll), GB_METHOD("_unknown", "v", TrayIcon_unknown, "."),