Merge lp:~bratsche/indicator-sound/scroll into lp:indicator-sound/0.1

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bratsche/indicator-sound/scroll
Merge into: lp:indicator-sound/0.1
Diff against target: 139 lines (+40/-12)
1 file modified
src/indicator-sound.c (+40/-12)
To merge this branch: bzr merge lp:~bratsche/indicator-sound/scroll
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+21533@code.launchpad.net
To post a comment you must log in.
lp:~bratsche/indicator-sound/scroll updated
52. By Cody Russell

Remove some debugging output.

Revision history for this message
Conor Curran (cjcurran) wrote :

looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-sound.c'
2--- src/indicator-sound.c 2010-03-15 13:42:17 +0000
3+++ src/indicator-sound.c 2010-03-17 06:25:41 +0000
4@@ -7,6 +7,7 @@
5 Authors:
6 Conor Curran <conor.curran@canonical.com>
7 Ted Gould <ted@canonical.com>
8+ Cody Russell <cody.russell@canonical.com>
9
10 This program is free software: you can redistribute it and/or modify it
11 under the terms of the GNU General Public License version 3, as published
12@@ -60,6 +61,7 @@
13 //GObject instance struct
14 struct _IndicatorSound {
15 IndicatorObject parent;
16+ GtkWidget *slider;
17 IndicatorServiceManager *service;
18 };
19 // GObject Boiler plate
20@@ -77,7 +79,8 @@
21 //GTK+ items
22 static GtkLabel * get_label (IndicatorObject * io);
23 static GtkImage * get_icon (IndicatorObject * io);
24-static GtkMenu * get_menu (IndicatorObject * io);
25+static GtkMenu * get_menu (IndicatorObject * io);
26+static void scroll (IndicatorObject*io, gint delta, IndicatorScrollDirection direction);
27
28 //Slider related
29 static GtkWidget *volume_slider = NULL;
30@@ -140,9 +143,10 @@
31 IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass);
32 io_class->get_label = get_label;
33 io_class->get_image = get_icon;
34- io_class->get_menu = get_menu;
35+ io_class->get_menu = get_menu;
36+ io_class->scroll = scroll;
37
38- design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
39+ design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
40
41 return;
42 }
43@@ -172,7 +176,7 @@
44 self->service = NULL;
45 }
46 g_hash_table_destroy(volume_states);
47-
48+
49 if(blocked_animation_list != NULL){
50 g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL);
51 g_list_free(blocked_animation_list);
52@@ -212,7 +216,10 @@
53 get_menu (IndicatorObject * io)
54 {
55 DbusmenuGtkMenu *menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT);
56- DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu);
57+ DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu);
58+
59+ g_object_set_data (G_OBJECT (client),
60+ "indicator", io);
61 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item);
62
63 // register Key-press listening on the menu widget as the slider does not allow this.
64@@ -235,9 +242,13 @@
65 **/
66 static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
67 {
68+ IndicatorObject *io = NULL;
69+
70 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
71 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
72
73+ io = g_object_get_data (G_OBJECT (client), "indicator");
74+
75 volume_slider = ido_scale_menu_item_new_with_range ("Volume", initial_volume_percent, 0, 100, 0.5);
76 g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL);
77
78@@ -252,6 +263,8 @@
79 // register slider changes listening on the range
80 GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
81
82+ INDICATOR_SOUND (io)->slider = slider;
83+
84 g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem);
85 g_signal_connect(volume_slider, "slider-grabbed", G_CALLBACK(slider_grabbed), NULL);
86 g_signal_connect(volume_slider, "slider-released", G_CALLBACK(slider_released), NULL);
87@@ -343,18 +356,18 @@
88 {
89 gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
90 gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED));
91-
92- GtkImage* temp_image = indicator_image_helper(muted_name);
93- GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image);
94-
95- temp_image = indicator_image_helper(blocked_name);
96+
97+ GtkImage* temp_image = indicator_image_helper(muted_name);
98+ GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image);
99+
100+ temp_image = indicator_image_helper(blocked_name);
101 GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image);
102
103 int i;
104
105 if(mute_buf == NULL || blocked_buf == NULL){
106 g_debug("Don bother with the animation, the theme aint got the goods");
107- return;
108+ return;
109 }
110
111 // sample 22 snapshots - range : 0-256
112@@ -495,7 +508,7 @@
113
114 blocked_iter = blocked_animation_list;
115 animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL);
116- }
117+ }
118 }
119
120 static gboolean fade_back_to_mute_image()
121@@ -655,3 +668,18 @@
122 }
123
124
125+static void
126+scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
127+{
128+ IndicatorSound *sound = INDICATOR_SOUND (io);
129+ GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (sound->slider));
130+ gdouble value = gtk_range_get_value (GTK_RANGE (sound->slider));
131+
132+ if (direction == INDICATOR_OBJECT_SCROLL_UP)
133+ value += adj->step_increment;
134+ else
135+ value -= adj->step_increment;
136+
137+ gtk_range_set_value (GTK_RANGE (sound->slider),
138+ value);
139+}

Subscribers

People subscribed via source and target branches