From e26d41560bacf9f84846a754b356acc91582fb42 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 28 Jan 2014 11:10:14 +0100 Subject: pulse: Middle click on applet toggles mute state Closes #20 https://github.com/mate-desktop/mate-media/issues/20 --- mate-volume-control/src/gvc-stream-status-icon.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mate-volume-control/src/gvc-stream-status-icon.c b/mate-volume-control/src/gvc-stream-status-icon.c index ce13a83..dcf483d 100644 --- a/mate-volume-control/src/gvc-stream-status-icon.c +++ b/mate-volume-control/src/gvc-stream-status-icon.c @@ -217,6 +217,22 @@ on_status_icon_activate (GtkStatusIcon *status_icon, popup_dock (icon, GDK_CURRENT_TIME); } +static gboolean +on_status_icon_button_press (GtkStatusIcon *status_icon, + GdkEventButton *event, + GvcStreamStatusIcon *icon) +{ + /* middle click acts as mute/unmute */ + if (event->button == 2) { + gboolean is_muted; + is_muted = gvc_mixer_stream_get_is_muted (icon->priv->mixer_stream); + gvc_mixer_stream_set_is_muted (icon->priv->mixer_stream, !is_muted); + gvc_mixer_stream_change_is_muted (icon->priv->mixer_stream, !is_muted); + return TRUE; + } + return FALSE; +} + static void on_menu_mute_toggled (GtkMenuItem *item, GvcStreamStatusIcon *icon) @@ -790,6 +806,10 @@ gvc_stream_status_icon_init (GvcStreamStatusIcon *icon) "activate", G_CALLBACK (on_status_icon_activate), icon); + g_signal_connect (icon, + "button-press-event", + G_CALLBACK (on_status_icon_button_press), + icon); g_signal_connect (icon, "popup-menu", G_CALLBACK (on_status_icon_popup_menu), -- cgit v1.2.1