diff options
Diffstat (limited to 'src/sound-service.c')
-rw-r--r-- | src/sound-service.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/sound-service.c b/src/sound-service.c index d5c4eae..62f6bc6 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -74,7 +74,6 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service mute_all_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute")); g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL); - //TODO: If no valid sinks are found grey out the item(s) dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available); // Slider @@ -92,25 +91,29 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_sound_settings_dialog), NULL); } -/* 'public' method allowing the server to update the mute UI*/ + +/** +update_mute_ui: +'public' method allowing the server to update the mute UI +**/ void update_mute_ui(gboolean incoming_mute_value) { b_all_muted = incoming_mute_value; - dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute")); + dbusmenu_menuitem_property_set(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _(b_all_muted == FALSE ? "Mute All" : "Unmute")); } - +/** +set_global_mute_from_ui: +Callback for the dbusmenuitem button +**/ static void set_global_mute_from_ui() { b_all_muted = !b_all_muted; toggle_global_mute(b_all_muted); - dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute")); - -/* GValue value = {0};*/ -/* g_value_init(&value, G_TYPE_DOUBLE);*/ -/* g_value_set_double(&value, 99.0);*/ -/* // Testing*/ -/* g_debug("BUGGY volume update");*/ -/* dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME, &value);*/ + dbusmenu_menuitem_property_set(mute_all_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _(b_all_muted == FALSE ? "Mute All" : "Unmute")); } @@ -137,7 +140,12 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m b_pulse_ready = pa_state; volume_percent = percent; g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent); - rebuild_sound_menu(root_menuitem, dbus_interface); + sound_service_dbus_update_sink_volume(dbus_interface, percent); + sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); + + // Only rebuild the menu on start up... + if(volume_slider_menuitem == NULL) + rebuild_sound_menu(root_menuitem, dbus_interface); } @@ -169,13 +177,6 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root_menuitem); establish_pulse_activities(dbus_interface); -/* // THIS DOES NOT WORK FROM HERE*/ -/* GValue value = {0};*/ -/* g_value_init(&value, G_TYPE_DOUBLE);*/ -/* g_value_set_double(&value, volume_percent * 100);*/ -/* g_debug("About to send over the volume slider initial value %f", (volume_percent * 100));*/ -/* dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME, &value);*/ - // Run the loop mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); |