aboutsummaryrefslogtreecommitdiff
path: root/src/sound-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sound-service.c')
-rw-r--r--src/sound-service.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/sound-service.c b/src/sound-service.c
index 76975cd..4f76dd1 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -5,7 +5,6 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
Ted Gould <ted@canonical.com>
- Christoph Korn <c_korn@gmx.de>
Cody Russell <crussell@canonical.com>
This program is free software: you can redistribute it and/or modify it
@@ -40,7 +39,7 @@ static gboolean b_all_muted = FALSE;
static gboolean b_pulse_ready = FALSE;
static gdouble volume_percent = 0.0;
-static void set_global_mute();
+static void set_global_mute_from_ui();
static gboolean idle_routine (gpointer data);
static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service);
@@ -74,7 +73,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
// Mute button
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), NULL);
+ 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);
@@ -93,8 +92,14 @@ 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*/
+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"));
+}
-static void set_global_mute()
+static void set_global_mute_from_ui()
{
b_all_muted = !b_all_muted;
toggle_global_mute(b_all_muted);
@@ -102,8 +107,9 @@ static void set_global_mute()
/* GValue value = {0};*/
/* g_value_init(&value, G_TYPE_DOUBLE);*/
-/* g_value_set_double(&value, 100.0);*/
+/* 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);*/
}
@@ -116,9 +122,9 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
-
- g_debug("Service shutdown - but commented out for right now");
- close_pulse_activites();
+ g_debug("Service shutdown !");
+ // TODO: uncomment for release !!
+ close_pulse_activites();
g_main_loop_quit(mainloop);
}
return;
@@ -132,11 +138,6 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m
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);
- g_debug("About to send over the volume slider");
- GValue value = {0};
- g_value_init(&value, G_TYPE_DOUBLE);
- g_value_set_double(&value, volume_percent * 100);
- dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME, &value);
}
@@ -168,6 +169,13 @@ 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);