Merge lp:~cjcurran/indicator-sound/keyboard-ui-controls into lp:indicator-sound/0.1
- keyboard-ui-controls
- Merge into trunk
Proposed by
Conor Curran
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | not available | ||||||||||||
Proposed branch: | lp:~cjcurran/indicator-sound/keyboard-ui-controls | ||||||||||||
Merge into: | lp:indicator-sound/0.1 | ||||||||||||
Diff against target: |
312 lines (+125/-49) 4 files modified
src/indicator-sound.c (+112/-29) src/pulse-manager.c (+10/-17) src/sound-service-dbus.c (+1/-1) src/sound-service.c (+2/-2) |
||||||||||||
To merge this branch: | bzr merge lp:~cjcurran/indicator-sound/keyboard-ui-controls | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Barth | Approve | ||
Review via email: mp+19430@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote : | # |
Revision history for this message
David Barth (dbarth) wrote : | # |
LGTM, improvements and simplifications. Caution with the GtkRange cast.
+1
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-02-15 15:23:54 +0000 | |||
3 | +++ src/indicator-sound.c 2010-02-16 18:00:37 +0000 | |||
4 | @@ -20,10 +20,11 @@ | |||
5 | 20 | You should have received a copy of the GNU General Public License along | 20 | You should have received a copy of the GNU General Public License along |
6 | 21 | with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | with this program. If not, see <http://www.gnu.org/licenses/>. |
7 | 22 | */ | 22 | */ |
9 | 23 | 23 | #include <math.h> | |
10 | 24 | #include <glib.h> | 24 | #include <glib.h> |
11 | 25 | #include <glib-object.h> | 25 | #include <glib-object.h> |
12 | 26 | #include <gtk/gtk.h> | 26 | #include <gtk/gtk.h> |
13 | 27 | #include <gdk/gdkkeysyms.h> | ||
14 | 27 | #include <libdbusmenu-gtk/menu.h> | 28 | #include <libdbusmenu-gtk/menu.h> |
15 | 28 | #include <libido/idoscalemenuitem.h> | 29 | #include <libido/idoscalemenuitem.h> |
16 | 29 | 30 | ||
17 | @@ -83,6 +84,7 @@ | |||
18 | 83 | static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); | 84 | static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget); |
19 | 84 | static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data); | 85 | static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data); |
20 | 85 | static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); | 86 | static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data); |
21 | 87 | static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); | ||
22 | 86 | 88 | ||
23 | 87 | // DBUS communication | 89 | // DBUS communication |
24 | 88 | static DBusGProxy *sound_dbus_proxy = NULL; | 90 | static DBusGProxy *sound_dbus_proxy = NULL; |
25 | @@ -162,14 +164,13 @@ | |||
26 | 162 | { | 164 | { |
27 | 163 | // TODO we need three more images | 165 | // TODO we need three more images |
28 | 164 | volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); | 166 | volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); |
37 | 165 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted")); | 167 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel")); |
38 | 166 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup(/*"audio-volume-zero"*/"audio-volume-muted")); | 168 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-zero-panel")); |
39 | 167 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low")); | 169 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel")); |
40 | 168 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium")); | 170 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel")); |
41 | 169 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high")); | 171 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel")); |
42 | 170 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup(/*"audio-volume-muted-blocking"*/"audio-volume-muted")); | 172 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel")); |
43 | 171 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup(/*"audio-output-none"*/"audio-volume-muted")); | 173 | g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel")); |
36 | 172 | //test_images_hash(); | ||
44 | 173 | } | 174 | } |
45 | 174 | 175 | ||
46 | 175 | static void | 176 | static void |
47 | @@ -257,10 +258,20 @@ | |||
48 | 257 | 258 | ||
49 | 258 | static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) | 259 | static void catch_signal_sink_volume_update(DBusGProxy *proxy, gdouble volume_percent, gpointer userdata) |
50 | 259 | { | 260 | { |
51 | 260 | g_debug("signal caught - update sink volume with value : %f", volume_percent); | ||
52 | 261 | GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); | 261 | GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); |
53 | 262 | GtkRange *range = (GtkRange*)slider; | 262 | GtkRange *range = (GtkRange*)slider; |
55 | 263 | gtk_range_set_value(range, volume_percent); | 263 | |
56 | 264 | // DEBUG | ||
57 | 265 | gdouble current_value = gtk_range_get_value(range); | ||
58 | 266 | g_debug("SIGNAL- update sink volume - current_value : %f and new value : %f", current_value, volume_percent); | ||
59 | 267 | |||
60 | 268 | // Don't like this solution - too fuzzy | ||
61 | 269 | // Need the ability to detect if the slider is grabbed | ||
62 | 270 | if(floor(current_value) != floor(volume_percent)) | ||
63 | 271 | { | ||
64 | 272 | g_debug("Going to update slider value"); | ||
65 | 273 | gtk_range_set_value(range, volume_percent); | ||
66 | 274 | } | ||
67 | 264 | determine_state_from_volume(volume_percent); | 275 | determine_state_from_volume(volume_percent); |
68 | 265 | } | 276 | } |
69 | 266 | 277 | ||
70 | @@ -315,11 +326,11 @@ | |||
71 | 315 | 326 | ||
72 | 316 | static void update_state(const gint state) | 327 | static void update_state(const gint state) |
73 | 317 | { | 328 | { |
75 | 318 | g_debug("update state beginning - previous_state = %i", previous_state); | 329 | /* g_debug("update state beginning - previous_state = %i", previous_state);*/ |
76 | 319 | 330 | ||
77 | 320 | previous_state = current_state; | 331 | previous_state = current_state; |
78 | 321 | 332 | ||
80 | 322 | g_debug("update state 3rd line - previous_state = %i", previous_state); | 333 | /* g_debug("update state 3rd line - previous_state = %i", previous_state);*/ |
81 | 323 | 334 | ||
82 | 324 | current_state = state; | 335 | current_state = state; |
83 | 325 | gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); | 336 | gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state)); |
84 | @@ -338,7 +349,7 @@ | |||
85 | 338 | 349 | ||
86 | 339 | static void determine_state_from_volume(gdouble volume_percent) | 350 | static void determine_state_from_volume(gdouble volume_percent) |
87 | 340 | { | 351 | { |
89 | 341 | g_debug("determine_state_from_volume - previous_state = %i", previous_state); | 352 | /* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/ |
90 | 342 | gint state = previous_state; | 353 | gint state = previous_state; |
91 | 343 | if (volume_percent < 30.0 && volume_percent > 0){ | 354 | if (volume_percent < 30.0 && volume_percent > 0){ |
92 | 344 | state = STATE_LOW; | 355 | state = STATE_LOW; |
93 | @@ -366,6 +377,9 @@ | |||
94 | 366 | DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); | 377 | DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); |
95 | 367 | dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); | 378 | dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_SLIDER_MENUITEM_TYPE, new_slider_item); |
96 | 368 | 379 | ||
97 | 380 | // register Key-press listening on the widget | ||
98 | 381 | g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), NULL); | ||
99 | 382 | |||
100 | 369 | return GTK_MENU(menu); | 383 | return GTK_MENU(menu); |
101 | 370 | } | 384 | } |
102 | 371 | 385 | ||
103 | @@ -378,22 +392,23 @@ | |||
104 | 378 | g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); | 392 | g_object_set(volume_slider, "reverse-scroll-events", TRUE, NULL); |
105 | 379 | 393 | ||
106 | 380 | GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); | 394 | GtkMenuItem *menu_volume_slider = GTK_MENU_ITEM(volume_slider); |
107 | 395 | |||
108 | 381 | dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); | 396 | dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_slider, parent); |
109 | 382 | g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider); | 397 | g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider); |
110 | 383 | 398 | ||
111 | 399 | // register slider changes listening on the range | ||
112 | 384 | GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); | 400 | GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); |
113 | 385 | g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); | 401 | g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); |
114 | 386 | g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); | 402 | g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem); |
115 | 387 | 403 | ||
116 | 404 | // Set images on the ido | ||
117 | 388 | primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); | 405 | primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider); |
118 | 389 | gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); | 406 | gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU); |
119 | 390 | GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); | 407 | GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider); |
120 | 391 | gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU); | 408 | gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU); |
121 | 392 | 409 | ||
122 | 393 | /* GtkRange* range = (GtkRange*)slider; */ | ||
123 | 394 | /* gtk_range_set_value(range, initial_volume_percent); */ | ||
124 | 395 | |||
125 | 396 | gtk_widget_show_all(volume_slider); | 410 | gtk_widget_show_all(volume_slider); |
126 | 411 | |||
127 | 397 | return TRUE; | 412 | return TRUE; |
128 | 398 | } | 413 | } |
129 | 399 | 414 | ||
130 | @@ -417,18 +432,86 @@ | |||
131 | 417 | static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) | 432 | static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data) |
132 | 418 | { | 433 | { |
133 | 419 | gdouble current_value = gtk_range_get_value(range); | 434 | gdouble current_value = gtk_range_get_value(range); |
146 | 420 | if(current_value == 0 || current_value == 100) | 435 | /* if(current_value == 0 || current_value == 100)*/ |
147 | 421 | { | 436 | /* {*/ |
148 | 422 | DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; | 437 | DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; |
149 | 423 | GValue value = {0}; | 438 | GValue value = {0}; |
150 | 424 | g_value_init(&value, G_TYPE_DOUBLE); | 439 | g_value_init(&value, G_TYPE_DOUBLE); |
151 | 425 | g_value_set_double(&value, current_value); | 440 | g_value_set_double(&value, current_value); |
152 | 426 | g_debug("Value changed listener - = %f", current_value); | 441 | g_debug("Value changed callback - = %f", current_value); |
153 | 427 | dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); | 442 | dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0); |
154 | 428 | } | 443 | /* }*/ |
155 | 429 | return FALSE; | 444 | return FALSE; |
156 | 430 | } | 445 | } |
157 | 431 | 446 | ||
158 | 447 | /** | ||
159 | 448 | key_press_cb: | ||
160 | 449 | **/ | ||
161 | 450 | static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) | ||
162 | 451 | { | ||
163 | 452 | |||
164 | 453 | if(event->length > 0) | ||
165 | 454 | g_debug("The key event's string is '%s'\n", event->string); | ||
166 | 455 | |||
167 | 456 | GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider); | ||
168 | 457 | GtkRange* range = (GtkRange*)slider; | ||
169 | 458 | gdouble current_value = gtk_range_get_value(range); | ||
170 | 459 | gdouble new_value = current_value; | ||
171 | 460 | const gdouble five_percent = 5; | ||
172 | 461 | |||
173 | 462 | switch(event->keyval) | ||
174 | 463 | { | ||
175 | 464 | case GDK_Right: | ||
176 | 465 | if(event->state & GDK_CONTROL_MASK) | ||
177 | 466 | { | ||
178 | 467 | /* g_debug("right key was pressed with ctrl- volume set to 100"); */ | ||
179 | 468 | new_value = 100; | ||
180 | 469 | } | ||
181 | 470 | else | ||
182 | 471 | { | ||
183 | 472 | /* g_debug("right key was pressed - normal 5 percent increase"); */ | ||
184 | 473 | new_value = current_value + five_percent; | ||
185 | 474 | } | ||
186 | 475 | break; | ||
187 | 476 | case GDK_Left: | ||
188 | 477 | if(event->state & GDK_CONTROL_MASK) | ||
189 | 478 | { | ||
190 | 479 | /* g_debug("left key was pressed with ctrl- volume set to 0"); */ | ||
191 | 480 | new_value = 0; | ||
192 | 481 | } | ||
193 | 482 | else | ||
194 | 483 | { | ||
195 | 484 | /* g_debug("left key was pressed - normal 5 percent decrease"); */ | ||
196 | 485 | new_value = current_value - five_percent; | ||
197 | 486 | } | ||
198 | 487 | break; | ||
199 | 488 | case GDK_plus: | ||
200 | 489 | /* g_debug("Plus key was pressed");*/ | ||
201 | 490 | new_value = current_value + five_percent; | ||
202 | 491 | break; | ||
203 | 492 | case GDK_minus: | ||
204 | 493 | /* g_debug("minus key was pressed");*/ | ||
205 | 494 | new_value = current_value - five_percent; | ||
206 | 495 | break; | ||
207 | 496 | default: | ||
208 | 497 | break; | ||
209 | 498 | } | ||
210 | 499 | |||
211 | 500 | /* g_debug("new range value without being clamped = %f", new_value); */ | ||
212 | 501 | |||
213 | 502 | new_value = CLAMP(new_value, 0, 100); | ||
214 | 503 | if(new_value != current_value) | ||
215 | 504 | { | ||
216 | 505 | g_debug("Attempting to set the range to %f", new_value); | ||
217 | 506 | gtk_range_set_value(range, new_value); | ||
218 | 507 | } | ||
219 | 508 | return FALSE; | ||
220 | 509 | } | ||
221 | 510 | |||
222 | 511 | /** | ||
223 | 512 | This callback should only be called when the user actually drags the slider. | ||
224 | 513 | Turned off for now in favour of the non descriminating call back. | ||
225 | 514 | **/ | ||
226 | 432 | static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data) | 515 | static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data) |
227 | 433 | { | 516 | { |
228 | 434 | DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; | 517 | DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data; |
229 | 435 | 518 | ||
230 | === modified file 'src/pulse-manager.c' | |||
231 | --- src/pulse-manager.c 2010-02-15 12:42:08 +0000 | |||
232 | +++ src/pulse-manager.c 2010-02-16 18:00:37 +0000 | |||
233 | @@ -189,18 +189,15 @@ | |||
234 | 189 | g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink"); | 189 | g_warning("We have no default sink !!! - returning after not attempting to set any volume of any sink"); |
235 | 190 | return; | 190 | return; |
236 | 191 | } | 191 | } |
245 | 192 | gdouble linear_input = (gdouble)(percent); | 192 | |
246 | 193 | linear_input /= 100.0; | 193 | sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); |
247 | 194 | g_debug("linear double input = %f", linear_input); | 194 | |
248 | 195 | pa_volume_t new_volume = pa_sw_volume_from_linear(linear_input); | 195 | pa_volume_t new_volume = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); |
249 | 196 | // Use this to achieve more accurate scaling using the base volume (in the sink struct already!) | 196 | g_debug("new_volume double check :%f", pa_sw_volume_to_linear(new_volume)); |
250 | 197 | //pa_volume_t new_volume = (pa_volume_t) ((GPOINTER_TO_INT(linear_input) * s->base_volume) / 100); | 197 | g_debug("new volume calculated :%f", (gdouble)new_volume); |
243 | 198 | g_debug("about to try to set the sw volume to a linear volume of %f", pa_sw_volume_to_linear(new_volume)); | ||
244 | 199 | g_debug("and an actual volume of %f", (gdouble)new_volume); | ||
251 | 200 | pa_cvolume dev_vol; | 198 | pa_cvolume dev_vol; |
252 | 201 | sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); | ||
253 | 202 | pa_cvolume_set(&dev_vol, s->volume.channels, new_volume); | 199 | pa_cvolume_set(&dev_vol, s->volume.channels, new_volume); |
255 | 203 | 200 | // TODO why don't you update the sink_info here with the appropriate pa_cvolume (&dev_vol) | |
256 | 204 | pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL)); | 201 | pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL)); |
257 | 205 | } | 202 | } |
258 | 206 | 203 | ||
259 | @@ -321,7 +318,6 @@ | |||
260 | 321 | if(position >= 0) // => index is within the keys of the hash. | 318 | if(position >= 0) // => index is within the keys of the hash. |
261 | 322 | { | 319 | { |
262 | 323 | sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index)); | 320 | sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(info->index)); |
263 | 324 | //g_debug("attempting to update sink with name %s", s->name); | ||
264 | 325 | s->name = g_strdup(info->name); | 321 | s->name = g_strdup(info->name); |
265 | 326 | s->description = g_strdup(info->description); | 322 | s->description = g_strdup(info->description); |
266 | 327 | s->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME)); | 323 | s->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME)); |
267 | @@ -336,14 +332,11 @@ | |||
268 | 336 | { | 332 | { |
269 | 337 | //update the UI | 333 | //update the UI |
270 | 338 | pa_volume_t vol = pa_cvolume_avg(&s->volume); | 334 | pa_volume_t vol = pa_cvolume_avg(&s->volume); |
276 | 339 | // Use the base of the device to ensure maximum acceptable levels on the hardware | 335 | gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; |
277 | 340 | gdouble volume_percent = (vol/s->base_volume) * 100; | 336 | g_debug("Updating volume from PA manager with volume = %f", volume_percent); |
278 | 341 | g_debug("When using base volume => volume = %f", volume_percent); | 337 | sound_service_dbus_update_sink_volume(dbus_service, volume_percent); |
274 | 342 | g_debug("about to update ui with linear volume of %f", pa_sw_volume_to_linear(vol)); | ||
275 | 343 | sound_service_dbus_update_sink_volume(dbus_service, pa_sw_volume_to_linear(vol)); | ||
279 | 344 | if (mute_changed == TRUE) | 338 | if (mute_changed == TRUE) |
280 | 345 | sound_service_dbus_update_sink_mute(dbus_service, s->mute); | 339 | sound_service_dbus_update_sink_mute(dbus_service, s->mute); |
281 | 346 | |||
282 | 347 | update_mute_ui(s->mute); | 340 | update_mute_ui(s->mute); |
283 | 348 | } | 341 | } |
284 | 349 | } | 342 | } |
285 | 350 | 343 | ||
286 | === modified file 'src/sound-service-dbus.c' | |||
287 | --- src/sound-service-dbus.c 2010-02-10 12:45:23 +0000 | |||
288 | +++ src/sound-service-dbus.c 2010-02-16 18:00:37 +0000 | |||
289 | @@ -194,7 +194,7 @@ | |||
290 | 194 | void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume) | 194 | void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume) |
291 | 195 | { | 195 | { |
292 | 196 | SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); | 196 | SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); |
294 | 197 | priv->volume_percent = sink_volume * 100; | 197 | priv->volume_percent = sink_volume; |
295 | 198 | 198 | ||
296 | 199 | g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent); | 199 | g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent); |
297 | 200 | g_signal_emit(obj, | 200 | g_signal_emit(obj, |
298 | 201 | 201 | ||
299 | === modified file 'src/sound-service.c' | |||
300 | --- src/sound-service.c 2010-02-10 18:12:23 +0000 | |||
301 | +++ src/sound-service.c 2010-02-16 18:00:37 +0000 | |||
302 | @@ -124,8 +124,8 @@ | |||
303 | 124 | if (mainloop != NULL) { | 124 | if (mainloop != NULL) { |
304 | 125 | g_debug("Service shutdown !"); | 125 | g_debug("Service shutdown !"); |
305 | 126 | // TODO: uncomment for release !! | 126 | // TODO: uncomment for release !! |
308 | 127 | close_pulse_activites(); | 127 | /* close_pulse_activites();*/ |
309 | 128 | g_main_loop_quit(mainloop); | 128 | /* g_main_loop_quit(mainloop);*/ |
310 | 129 | } | 129 | } |
311 | 130 | return; | 130 | return; |
312 | 131 | } | 131 | } |
In this branch:
Keyboard controls of the sound menu.
- +/- 5% inc/dec
- Arrow left/right 5% inc/dec
- Ctlr left arrow - volume 0
- Ctlr right arrow - Max vol
New slider.
volume control far smoother - proper use of the API for the current UI spec.
New icons now being pulled in.