Merge lp:~charlesk/indicator-sound/lp-921065 into lp:indicator-sound/fifth

Proposed by Conor Curran on 2012-03-12
Status: Merged
Approved by: Charles Kerr on 2012-03-12
Approved revision: 304
Merge reported by: Charles Kerr
Merged at revision: not available
Proposed branch: lp:~charlesk/indicator-sound/lp-921065
Merge into: lp:indicator-sound/fifth
Diff against target: 87 lines (+28/-28)
1 file modified
src/volume-widget.c (+28/-28)
To merge this branch: bzr merge lp:~charlesk/indicator-sound/lp-921065
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve on 2012-03-12
Review via email: mp+97058@code.launchpad.net

Description of the change

listen to the ido signals

To post a comment you must log in.
Conor Curran (cjcurran) wrote :

Thanks Charles

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/volume-widget.c'
2--- src/volume-widget.c 2012-02-13 20:08:02 +0000
3+++ src/volume-widget.c 2012-03-12 16:45:57 +0000
4@@ -56,7 +56,8 @@
5 GtkScrollType scroll,
6 gdouble value,
7 gpointer user_data);
8-static gboolean volume_widget_value_changed_cb(GtkRange *range, gpointer user_data);
9+static void volume_widget_primary_clicked(GtkWidget *widget, gpointer user_data);
10+static void volume_widget_secondary_clicked(GtkWidget *widget, gpointer user_data);
11 static void volume_widget_slider_grabbed(GtkWidget *widget, gpointer user_data);
12 static void volume_widget_slider_released(GtkWidget *widget, gpointer user_data);
13 static void volume_widget_parent_changed (GtkWidget *widget, gpointer user_data);
14@@ -93,7 +94,8 @@
15 GtkWidget* volume_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
16
17 g_signal_connect(volume_widget, "change-value", G_CALLBACK(volume_widget_change_value_cb), self);
18- g_signal_connect(volume_widget, "value-changed", G_CALLBACK(volume_widget_value_changed_cb), self);
19+ g_signal_connect(priv->ido_volume_slider, "primary-clicked", G_CALLBACK(volume_widget_primary_clicked), self);
20+ g_signal_connect(priv->ido_volume_slider, "secondary-clicked", G_CALLBACK(volume_widget_secondary_clicked), self);
21 g_signal_connect(priv->ido_volume_slider, "slider-grabbed", G_CALLBACK(volume_widget_slider_grabbed), self);
22 g_signal_connect(priv->ido_volume_slider, "slider-released", G_CALLBACK(volume_widget_slider_released), self);
23
24@@ -213,32 +215,6 @@
25 return FALSE;
26 }
27
28-/*
29- We only want this callback to catch mouse icon press events
30- which set the slider to 0 or 100. Ignore all other events.
31-*/
32-static gboolean
33-volume_widget_value_changed_cb (GtkRange *range, gpointer user_data)
34-{
35-
36- g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
37- VolumeWidget* mitem = VOLUME_WIDGET (user_data);
38- VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
39- GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
40- gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
41-
42- gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item,
43- DBUSMENU_VOLUME_MENUITEM_MUTE));
44- if((current_value == 0 && mute == FALSE) || current_value == 100){
45-/*
46- g_debug ("value changed - actual set %f", current_value);
47-*/
48- volume_widget_update (mitem, current_value, "value-changed");
49- }
50-
51- return FALSE;
52-}
53-
54 void
55 volume_widget_update(VolumeWidget* self, gdouble update, gchar* label)
56 {
57@@ -253,6 +229,30 @@
58 dbusmenu_menuitem_handle_event (priv->twin_item, source, new_volume, 0);
59 }
60
61+static void
62+volume_widget_update_from_scale (VolumeWidget *self)
63+{
64+ g_return_if_fail (IS_VOLUME_WIDGET (self));
65+
66+ VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self);
67+ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
68+ const gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
69+ g_debug ("%s - setting value to %.0f", G_STRFUNC, current_value);
70+ volume_widget_update (self, current_value, "value-changed");
71+}
72+
73+static void
74+volume_widget_primary_clicked (GtkWidget *widget G_GNUC_UNUSED, gpointer user_data)
75+{
76+ volume_widget_update_from_scale (VOLUME_WIDGET(user_data));
77+}
78+
79+static void
80+volume_widget_secondary_clicked(GtkWidget *widget, gpointer user_data)
81+{
82+ volume_widget_update_from_scale (VOLUME_WIDGET(user_data));
83+}
84+
85 GtkWidget*
86 volume_widget_get_ido_slider(VolumeWidget* self)
87 {

Subscribers

People subscribed via source and target branches