summaryrefslogtreecommitdiff
path: root/src/applet-main.c
diff options
context:
space:
mode:
authorMartin Wimpress <[email protected]>2019-10-04 12:41:21 +0100
committerraveit65 <[email protected]>2021-11-20 21:54:30 +0100
commit8f9ca25370357f3b980c30210e1cef1cae8dbb73 (patch)
tree3f45d123db4ab44f799dbd6609fa1752c1adec11 /src/applet-main.c
parent42e8a0e39a1fe48f5a26ba07dcc7d978bf1a93b3 (diff)
downloadmate-indicator-applet-8f9ca25370357f3b980c30210e1cef1cae8dbb73.tar.bz2
mate-indicator-applet-8f9ca25370357f3b980c30210e1cef1cae8dbb73.tar.xz
applet-main.c: Support mouse middle-click.
Close #42 Emit signal "secondary-activate" on middle mouse click.
Diffstat (limited to 'src/applet-main.c')
-rw-r--r--src/applet-main.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/applet-main.c b/src/applet-main.c
index 3710c1f..41c0c66 100644
--- a/src/applet-main.c
+++ b/src/applet-main.c
@@ -304,6 +304,42 @@ entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
return FALSE;
}
+static gboolean
+entry_pressed (GtkWidget *menuitem, GdkEvent *event, gpointer data)
+{
+ g_return_val_if_fail(GTK_IS_MENU_ITEM(menuitem), FALSE);
+
+ if (((GdkEventButton*)event)->button == 2) /* middle button */
+ {
+ gtk_widget_grab_focus(menuitem);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+entry_released (GtkWidget *menuitem, GdkEvent *event, gpointer data)
+{
+ g_return_val_if_fail(GTK_IS_MENU_ITEM(menuitem), FALSE);
+
+ if (((GdkEventButton*)event)->button == 2) /* middle button */
+ {
+ IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
+ IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
+
+ g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
+
+ g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, entry,
+ ((GdkEventButton*)event)->time);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
{
@@ -360,12 +396,16 @@ entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * men
/* Allows indicators to receive mouse scroll event */
gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_SCROLL_MASK);
+ gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_BUTTON_PRESS_MASK);
+ gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_BUTTON_RELEASE_MASK);
g_object_set_data (G_OBJECT (menuitem), "indicator", io);
g_object_set_data (G_OBJECT (menuitem), "box", box);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry);
g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry);
+ g_signal_connect(G_OBJECT(menuitem), "button-press-event", G_CALLBACK(entry_pressed), entry);
+ g_signal_connect(G_OBJECT(menuitem), "button-release-event", G_CALLBACK(entry_released), entry);
if (entry->image != NULL) {
/* Resize to fit panel */