diff options
| author | Victor Kareh <[email protected]> | 2025-09-19 18:21:23 -0400 |
|---|---|---|
| committer | Victor Kareh <[email protected]> | 2025-10-30 17:19:55 -0400 |
| commit | f5978eff3e761124ec54219b84bcff9d6b25b7bc (patch) | |
| tree | 0c98845e31323dc6405c4f044f8cfa18cc1700c1 | |
| parent | a9341a107e8dfd336fb481d98659ec1399bf1442 (diff) | |
| download | mate-panel-f5978eff3e761124ec54219b84bcff9d6b25b7bc.tar.bz2 mate-panel-f5978eff3e761124ec54219b84bcff9d6b25b7bc.tar.xz | |
libmate-panel-applet: Register 'Activate' DBus method
This in turn emits an 'activate' signal that any applet can connect to
and perform whatever action it means to activate in that applet.
This allows users to control certain applet functionalities through
DBus, like registering new keybindings, or integrating them with other
software.
| -rw-r--r-- | libmate-panel-applet/mate-panel-applet.c | 28 | ||||
| -rw-r--r-- | libmate-panel-applet/mate-panel-applet.h | 4 |
2 files changed, 32 insertions, 0 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 897f1726..a4118165 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -94,6 +94,7 @@ enum { CHANGE_SIZE, CHANGE_BACKGROUND, MOVE_FOCUS_OUT_OF_APPLET, + ACTIVATE, LAST_SIGNAL }; @@ -2150,6 +2151,19 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) 1, GTK_TYPE_DIRECTION_TYPE); + mate_panel_applet_signals [ACTIVATE] = + g_signal_new ("activate", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MatePanelAppletClass, activate), + g_signal_accumulator_true_handled, + NULL, + NULL, + G_TYPE_BOOLEAN, + 2, + G_TYPE_STRING, + G_TYPE_UINT); + binding_set = gtk_binding_set_by_class (gobject_class); add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); @@ -2213,6 +2227,15 @@ method_call_cb (GDBusConnection *connection, gdk_event_free (event); g_dbus_method_invocation_return_value (invocation, NULL); + } else if (g_strcmp0 (method_name, "Activate") == 0) { + const gchar *action; + guint32 timestamp; + gboolean success = FALSE; + + g_variant_get (parameters, "(&su)", &action, ×tamp); + + g_signal_emit_by_name (applet, "activate", action, timestamp, &success); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", success)); } } @@ -2303,6 +2326,11 @@ static const gchar introspection_xml[] = "<arg name='button' type='u' direction='in'/>" "<arg name='time' type='u' direction='in'/>" "</method>" + "<method name='Activate'>" + "<arg name='action' type='s' direction='in'/>" + "<arg name='timestamp' type='u' direction='in'/>" + "<arg name='success' type='b' direction='out'/>" + "</method>" "<property name='PrefsPath' type='s' access='readwrite'/>" "<property name='Orient' type='u' access='readwrite' />" "<property name='Size' type='u' access='readwrite'/>" diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h index 9cc48ae8..5c8550dc 100644 --- a/libmate-panel-applet/mate-panel-applet.h +++ b/libmate-panel-applet/mate-panel-applet.h @@ -78,6 +78,10 @@ struct _MatePanelAppletClass { void (*move_focus_out_of_applet) (MatePanelApplet *frame, GtkDirectionType direction); + + gboolean (*activate) (MatePanelApplet *applet, + const gchar *action, + guint32 timestamp); }; GtkWidget* mate_panel_applet_new (void); |
