summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2026-06-10 09:38:58 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2026-06-10 09:38:58 +0200
commitc45150eaccef46e26ce130f25c74a3da53581c44 (patch)
tree2b2333754983b565d7683d098d78655ef7158587 /src
parent31e8bb083b307e1cc96af4874a94707727bd1e79 (diff)
parent90ce95a6ba93f4f4b2e777041b77e4e7e7e65284 (diff)
downloadlibayatana-appindicator-c45150eaccef46e26ce130f25c74a3da53581c44.tar.gz
libayatana-appindicator-c45150eaccef46e26ce130f25c74a3da53581c44.tar.bz2
libayatana-appindicator-c45150eaccef46e26ce130f25c74a3da53581c44.zip
Merge branch 'mikhailnov-activate-signal'
Attributes GH PR #4: https://github.com/AyatanaIndicators/libayatana-appindicator/pull/4
Diffstat (limited to 'src')
-rw-r--r--src/app-indicator.c36
-rw-r--r--src/app-indicator.h7
-rw-r--r--src/notification-item.xml4
3 files changed, 46 insertions, 1 deletions
diff --git a/src/app-indicator.c b/src/app-indicator.c
index 833cb90..8f714fe 100644
--- a/src/app-indicator.c
+++ b/src/app-indicator.c
@@ -120,6 +120,7 @@ enum {
CONNECTION_CHANGED,
NEW_ICON_THEME_PATH,
SCROLL_EVENT,
+ ACTIVATE_EVENT,
LAST_SIGNAL
};
@@ -625,6 +626,23 @@ app_indicator_class_init (AppIndicatorClass *klass)
_application_service_marshal_VOID__INT_UINT,
G_TYPE_NONE, 2, G_TYPE_INT, GDK_TYPE_SCROLL_DIRECTION);
+ /**
+ * AppIndicator::activate:
+ * @arg0: The #AppIndicator object
+ * @arg1: The x coordinate of the activation
+ * @arg2: The y coordinate of the activation
+ *
+ * Signaled when the #AppIndicator receives a primary activation event
+ * (e.g. left-click on the tray icon).
+ */
+ signals[ACTIVATE_EVENT] = g_signal_new (APP_INDICATOR_SIGNAL_ACTIVATE_EVENT,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (AppIndicatorClass, activate_event),
+ NULL, NULL,
+ _application_service_marshal_VOID__INT_INT,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
+
/* DBus interfaces */
if (item_node_info == NULL) {
GError * error = NULL;
@@ -1192,7 +1210,23 @@ bus_method_call (GDBusConnection * connection, const gchar * sender,
AppIndicatorPrivate * priv = app_indicator_get_instance_private(app);
GVariant * retval = NULL;
- if (g_strcmp0(method, "Scroll") == 0) {
+ if (g_strcmp0(method, "Activate") == 0) {
+ gint x, y;
+ g_variant_get(params, "(ii)", &x, &y);
+
+ if (g_signal_has_handler_pending(app, signals[ACTIVATE_EVENT], 0, FALSE)) {
+ g_signal_emit(app, signals[ACTIVATE_EVENT], 0, x, y);
+ g_dbus_method_invocation_return_value(invocation, retval);
+ } else {
+ /* No handler connected — return error so the panel falls back
+ * to showing the context menu for backward compatibility. */
+ g_dbus_method_invocation_return_error(invocation,
+ G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD,
+ "No handler for Activate");
+ }
+ return;
+
+ } else if (g_strcmp0(method, "Scroll") == 0) {
GdkScrollDirection direction;
gint delta;
const gchar *orientation;
diff --git a/src/app-indicator.h b/src/app-indicator.h
index 059bdbd..7002d35 100644
--- a/src/app-indicator.h
+++ b/src/app-indicator.h
@@ -119,6 +119,7 @@ G_BEGIN_DECLS
#define APP_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed"
#define APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH "new-icon-theme-path"
#define APP_INDICATOR_SIGNAL_SCROLL_EVENT "scroll-event"
+#define APP_INDICATOR_SIGNAL_ACTIVATE_EVENT "activate"
/**
* AppIndicatorCategory:
@@ -169,6 +170,7 @@ typedef struct _AppIndicatorClass AppIndicatorClass;
* @new_label: Slot for #AppIndicator::new-label.
* @connection_changed: Slot for #AppIndicator::connection-changed.
* @scroll_event: Slot for #AppIndicator::scroll-event
+ * @activate_event: Slot for #AppIndicator::activate
* @app_indicator_reserved_ats: Reserved for future use.
* @fallback: Function that gets called to make a #GtkStatusIcon when
* there is no Application Indicator area available.
@@ -214,6 +216,11 @@ struct _AppIndicatorClass {
GdkScrollDirection direction,
gpointer user_data);
+ void (* activate_event) (AppIndicator * indicator,
+ gint x,
+ gint y,
+ gpointer user_data);
+
void (*app_indicator_reserved_ats)(void);
/* Overridable Functions */
diff --git a/src/notification-item.xml b/src/notification-item.xml
index c93afd7..a223ea4 100644
--- a/src/notification-item.xml
+++ b/src/notification-item.xml
@@ -20,6 +20,10 @@
<property name="XAyatanaOrderingIndex" type="u" access="read" />
<!-- Methods -->
+ <method name="Activate">
+ <arg type="i" name="x" direction="in" />
+ <arg type="i" name="y" direction="in" />
+ </method>
<method name="Scroll">
<arg type="i" name="delta" direction="in" />
<arg type="s" name="orientation" direction="in" />