Merge lp:~cjcurran/indicator-sound/notifications-moved-service-side into lp:indicator-sound/fourth

Proposed by Conor Curran
Status: Rejected
Rejected by: Ted Gould
Proposed branch: lp:~cjcurran/indicator-sound/notifications-moved-service-side
Merge into: lp:indicator-sound/fourth
Diff against target: 261 lines (+30/-86)
7 files modified
configure.ac (+2/-4)
src/device.c (+14/-2)
src/device.h (+1/-0)
src/indicator-sound.c (+1/-3)
src/slider-menu-item.c (+12/-2)
src/sound-state-manager.c (+0/-73)
src/sound-state-manager.h (+0/-2)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/notifications-moved-service-side
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+67141@code.launchpad.net

Description of the change

This moves the notification code service side, so as on a scroll the service triggers the notification and not the indicator.

Two benefits here:
1. The notifications are only triggered on a volume update confirmation from the pulse server. Before it was triggering the scroll on the GTK scroll event irregardless of whether the volume was updated or not. This breaks the MVC GUI pattern therefore no good.
2. Libnotify dependency is now on the service and not on the indicator in keeping with Ted's initial concept for how the indicator should be light.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

I need to do some other work around this to actually send the notification.
Its in some other branch, I'll find it. Either way this should go in.

Revision history for this message
Ted Gould (ted) wrote :

It'd be nice to land both branches in the same release so that there isn't a feature regression. No issue in this change itself though.

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

Ill push this back till after we get the Oneiric release sorted.

Unmerged revisions

249. By Conor Curran

no whitespace in the handle event name please

248. By Conor Curran

stripped the notification stuff from the indicator and put in place the flag to determine when to send notifications from the device object

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2011-06-28 13:50:44 +0000
3+++ configure.ac 2011-07-07 09:28:32 +0000
4@@ -52,15 +52,13 @@
5 [PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK3_REQUIRED_VERSION
6 indicator3 >= $INDICATOR_REQUIRED_VERSION
7 dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
8- libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS
9- libnotify >= $LIBNOTIFY_REQUIRED_VERSION)
10+ libido3-0.1 >= $INDICATOR_DISPLAY_OBJECTS)
11 ],
12 [test "x$with_gtk" = x2],
13 [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
14 indicator >= $INDICATOR_REQUIRED_VERSION
15 dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION
16- libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS
17- libnotify >= $LIBNOTIFY_REQUIRED_VERSION)
18+ libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS)
19 ],
20 [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])]
21 )
22
23=== modified file 'src/device.c'
24--- src/device.c 2011-05-18 09:45:49 +0000
25+++ src/device.c 2011-07-07 09:28:32 +0000
26@@ -34,6 +34,7 @@
27 VoipInputMenuItem* voip_input_menu_item;
28 SoundState current_sound_state;
29 SoundServiceDbus* service;
30+ gboolean scroll_update;
31 };
32
33 #define DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEVICE_TYPE, DevicePrivate))
34@@ -69,7 +70,8 @@
35 priv->voip_input_menu_item = NULL;
36 priv->current_sound_state = UNAVAILABLE;
37 priv->service = NULL;
38-
39+ priv->scroll_update = FALSE;
40+
41 // Init our menu items.
42 priv->mute_menuitem = g_object_new (MUTE_MENU_ITEM_TYPE, NULL);
43 priv->voip_input_menu_item = g_object_new (VOIP_INPUT_MENU_ITEM_TYPE, NULL);;
44@@ -107,12 +109,22 @@
45 }
46
47 void
48+device_set_scroll_update (Device* self, gboolean update)
49+{
50+ DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
51+ priv->scroll_update = update;
52+}
53+
54+void
55 device_sink_update (Device* self,
56 const pa_sink_info* update)
57 {
58 DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
59 slider_menu_item_update (priv->volume_slider_menuitem, update);
60-
61+ if (priv->scroll_update == TRUE ){
62+ g_debug ("Send out a notification !!");
63+ priv->scroll_update = FALSE;
64+ }
65 SoundState state = device_get_state_from_volume (self);
66 if (priv->current_sound_state != state){
67 priv->current_sound_state = state;
68
69=== modified file 'src/device.h'
70--- src/device.h 2011-03-24 15:22:30 +0000
71+++ src/device.h 2011-07-07 09:28:32 +0000
72@@ -65,6 +65,7 @@
73 void device_sink_deactivated (Device* self);
74 void device_update_mute (Device* self, gboolean mute_update);
75 void device_ensure_sink_is_unmuted (Device* self);
76+void device_set_scroll_update (Device* self, gboolean scroll_update);
77
78 // source and sinkinput/client related for VOIP functionality
79 void device_update_voip_input_source (Device* sink, const pa_source_info* update);
80
81=== modified file 'src/indicator-sound.c'
82--- src/indicator-sound.c 2011-06-22 19:19:49 +0000
83+++ src/indicator-sound.c 2011-07-07 09:28:32 +0000
84@@ -672,9 +672,7 @@
85 value -= gtk_adjustment_get_step_increment (adj);
86 }
87 //g_debug("indicator-sound-scroll - update slider with value %f", value);
88- volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value, "scroll updates");
89-
90- sound_state_manager_show_notification (priv->state_manager, value);
91+ volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value, "scroll-updates");
92 }
93
94 void
95
96=== modified file 'src/slider-menu-item.c'
97--- src/slider-menu-item.c 2011-03-22 19:53:19 +0000
98+++ src/slider-menu-item.c 2011-07-07 09:28:32 +0000
99@@ -111,7 +111,17 @@
100 volume_input,
101 name);
102 */
103-
104+ /**
105+ We want to send notifications only when we get a scroll update
106+ We also only want these notifications to be sent when the server confirms the
107+ update => MVC
108+ **/
109+ g_debug ("Name handle on the handle event %s", name);
110+ if (g_ascii_strncasecmp("scroll-updates", name, 14) == 0)
111+ {
112+ device_set_scroll_update (priv->a_sink, TRUE);
113+ }
114+
115 slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input);
116 device_ensure_sink_is_unmuted (priv->a_sink);
117 }
118@@ -158,7 +168,7 @@
119 pa_cvolume_set(&new_volume, 1, new_volume_value);
120
121 SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
122-
123+
124 pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value);
125 pm_update_volume (priv->index, new_volume);
126 }
127
128=== modified file 'src/sound-state-manager.c'
129--- src/sound-state-manager.c 2011-04-05 03:14:19 +0000
130+++ src/sound-state-manager.c 2011-07-07 09:28:32 +0000
131@@ -18,7 +18,6 @@
132 */
133
134 #include <libindicator/indicator-image-helper.h>
135-#include <libnotify/notify.h>
136
137 #include "config.h"
138
139@@ -35,7 +34,6 @@
140 GList* blocked_animation_list;
141 SoundState current_state;
142 GtkImage* speaker_image;
143- NotifyNotification* notification;
144 GSettings *settings_manager;
145 };
146
147@@ -48,9 +46,6 @@
148 static GList* blocked_iter = NULL;
149 static gboolean can_animate = FALSE;
150
151-//Notifications
152-static void sound_state_manager_notification_init (SoundStateManager* self);
153-
154 //Animation/State related
155 static void sound_state_manager_prepare_blocked_animation (SoundStateManager* self);
156 static gboolean sound_state_manager_start_animation (gpointer user_data);
157@@ -75,12 +70,9 @@
158 priv->volume_states = NULL;
159 priv->speaker_image = NULL;
160 priv->blocked_animation_list = NULL;
161- priv->notification = NULL;
162 priv->settings_manager = NULL;
163
164 priv->settings_manager = g_settings_new("com.canonical.indicators.sound");
165-
166- sound_state_manager_notification_init (self);
167
168 sound_state_manager_prepare_state_image_names (self);
169 sound_state_manager_prepare_blocked_animation (self);
170@@ -108,10 +100,6 @@
171
172 sound_state_manager_free_the_animation_list (self);
173
174- if (priv->notification) {
175- notify_uninit();
176- }
177-
178 g_object_unref(priv->settings_manager);
179
180 G_OBJECT_CLASS (sound_state_manager_parent_class)->dispose (object);
181@@ -131,67 +119,6 @@
182 design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
183 }
184
185-static void
186-sound_state_manager_notification_init (SoundStateManager* self)
187-{
188- SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
189-
190- if (!notify_init(PACKAGE_NAME))
191- return;
192-
193- GList* caps = notify_get_server_caps();
194- gboolean has_notify_osd = FALSE;
195-
196- if (caps) {
197- if (g_list_find_custom(caps, "x-canonical-private-synchronous",
198- (GCompareFunc) g_strcmp0)) {
199- has_notify_osd = TRUE;
200- }
201- g_list_foreach(caps, (GFunc) g_free, NULL);
202- g_list_free(caps);
203- }
204-
205- if (has_notify_osd) {
206- priv->notification = notify_notification_new(PACKAGE_NAME, NULL, NULL);
207- notify_notification_set_hint_string(priv->notification,
208- "x-canonical-private-synchronous", PACKAGE_NAME);
209- }
210-}
211-
212-void
213-sound_state_manager_show_notification (SoundStateManager *self,
214- double value)
215-{
216- SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
217-
218- if (priv->notification == NULL ||
219- g_settings_get_boolean (priv->settings_manager, "show-notify-osd-on-scroll") == FALSE){
220- return;
221- }
222-
223- char *icon;
224- const int notify_value = CLAMP((int)value, -1, 101);
225-
226- SoundState state = sound_state_get_from_volume ((int)value);
227-
228- if (state == ZERO_LEVEL) {
229- // Not available for all the themes
230- icon = "notification-audio-volume-off";
231- } else if (state == LOW_LEVEL) {
232- icon = "notification-audio-volume-low";
233- } else if (state == MEDIUM_LEVEL) {
234- icon = "notification-audio-volume-medium";
235- } else if (state == HIGH_LEVEL) {
236- icon = "notification-audio-volume-high";
237- } else {
238- icon = "notification-audio-volume-muted";
239- }
240-
241- notify_notification_update(priv->notification, PACKAGE_NAME, NULL, icon);
242- notify_notification_set_hint_int32(priv->notification, "value", notify_value);
243- notify_notification_show(priv->notification, NULL);
244-}
245-
246
247 /*
248 Prepare states versus images names hash.
249
250=== modified file 'src/sound-state-manager.h'
251--- src/sound-state-manager.h 2011-02-11 15:21:00 +0000
252+++ src/sound-state-manager.h 2011-07-07 09:28:32 +0000
253@@ -58,8 +58,6 @@
254 void sound_state_manager_get_state_cb (GObject *object,
255 GAsyncResult *res,
256 gpointer user_data);
257-void sound_state_manager_show_notification (SoundStateManager *self,
258- double value);
259
260
261 G_END_DECLS

Subscribers

People subscribed via source and target branches