Merge lp:~charlesk/ido/lp-898611 into lp:ido/0.3

Proposed by Charles Kerr on 2012-03-13
Status: Merged
Approved by: Lars Karlitski on 2012-03-13
Approved revision: 104
Merged at revision: 104
Proposed branch: lp:~charlesk/ido/lp-898611
Merge into: lp:ido/0.3
Diff against target: 37 lines (+20/-0)
1 file modified
src/idoscalemenuitem.c (+20/-0)
To merge this branch: bzr merge lp:~charlesk/ido/lp-898611
Reviewer Review Type Date Requested Status
Lars Karlitski (community) 2012-03-13 Approve on 2012-03-13
Review via email: mp+97140@code.launchpad.net

Description of the change

The commit message in r104 says it all:

Alter mouse button 2 clicks to behave like mouse button 2 clicks for lp bug #898611.

This solution was taken from gvc-channel-bar.c in gnome-control-center. The idea of cribbing from g-c-c came from Christian Giordano in duplicate lp bug #932919 where he suggested "using the same behavior the volume slider has in the Sound System Settings."

To post a comment you must log in.
Lars Karlitski (larsu) wrote :

For the sake of consistency, I'd recommend not doing this kind of change in applications, but in gtk+ itself.

Approving anyway because this fixes a specific bug and changing gtk+ requires more thought. Also, the comment clearly states that this is a hack ;)

I've filed bug #953757 so that we don't lose track of the issue.

Good Work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/idoscalemenuitem.c'
2--- src/idoscalemenuitem.c 2012-03-10 06:04:36 +0000
3+++ src/idoscalemenuitem.c 2012-03-13 04:34:18 +0000
4@@ -217,6 +217,21 @@
5 priv->toggle_size = toggle_size;
6 }
7
8+static gboolean
9+on_scale_button_press_or_release_event (GtkWidget * widget G_GNUC_UNUSED,
10+ GdkEventButton * event,
11+ gpointer unused G_GNUC_UNUSED)
12+{
13+ /* HACK: we want the behaviour you get with the middle button, so we
14+ * mangle the event. clicking with other buttons moves the slider in
15+ * step increments, clicking with the middle button moves the slider to
16+ * the location of the click. */
17+ if (event->button == 1)
18+ event->button = 2;
19+
20+ return FALSE;
21+}
22+
23 static void
24 ido_scale_menu_item_constructed (GObject *object)
25 {
26@@ -235,6 +250,11 @@
27 priv->scale = ido_range_new (adj, range_style);
28 g_object_ref (priv->scale);
29 gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE);
30+ g_signal_connect (G_OBJECT (priv->scale), "button-press-event",
31+ G_CALLBACK (on_scale_button_press_or_release_event), NULL);
32+ g_signal_connect (G_OBJECT (priv->scale), "button-release-event",
33+ G_CALLBACK (on_scale_button_press_or_release_event), NULL);
34+
35
36 #ifdef USE_GTK3
37 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

Subscribers

People subscribed via source and target branches