aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/indicator-sound.c18
-rw-r--r--src/pulse-manager.c29
-rw-r--r--src/sound-service.c29
3 files changed, 33 insertions, 43 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index f9e98ed..9c73df4 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -82,6 +82,7 @@ static GtkMenu * get_menu (IndicatorObject * io);
static GtkWidget *volume_slider = NULL;
static gboolean new_slider_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkWidget *widget);
+// Alternative callback mechanism, may use this again once ido is updated.
/*static gboolean user_change_value_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data);*/
static gboolean value_changed_event_cb(GtkRange *range, gpointer user_data);
static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data);
@@ -99,7 +100,6 @@ static void fetch_mute_value_from_dbus();
static void prepare_state_machine();
static void determine_state_from_volume(gdouble volume_percent);
static void update_state(const gint state);
-/*static void revert_state();*/
static const gint STATE_MUTED = 0;
static const gint STATE_ZERO = 1;
static const gint STATE_LOW = 2;
@@ -265,9 +265,10 @@ static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value
//UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.
if(mute_value == TRUE)
{
- g_debug("signal caught - sink mute update - MUTE");
update_state(STATE_MUTED);
}
+ g_debug("signal caught - sink mute update with mute value: %i", mute_value);
+ gtk_widget_set_sensitive(volume_slider, !mute_value);
}
@@ -377,8 +378,9 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p
// register slider changes listening on the range
GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
-/* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */
g_signal_connect(slider, "value-changed", G_CALLBACK(value_changed_event_cb), newitem);
+ // alternative callback mechanism which i could use again at some point.
+/* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */
// Set images on the ido
primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider);
@@ -430,8 +432,6 @@ key_press_cb:
static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
{
-/* if(event->length > 0)*/
-/* g_debug("The key event's string is '%s'\n", event->string);*/
GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
GtkRange* range = (GtkRange*)slider;
gdouble current_value = gtk_range_get_value(range);
@@ -443,41 +443,33 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat
case GDK_Right:
if(event->state & GDK_CONTROL_MASK)
{
-/* g_debug("right key was pressed with ctrl- volume set to 100"); */
new_value = 100;
}
else
{
-/* g_debug("right key was pressed - normal 5 percent increase"); */
new_value = current_value + five_percent;
}
break;
case GDK_Left:
if(event->state & GDK_CONTROL_MASK)
{
-/* g_debug("left key was pressed with ctrl- volume set to 0"); */
new_value = 0;
}
else
{
-/* g_debug("left key was pressed - normal 5 percent decrease"); */
new_value = current_value - five_percent;
}
break;
case GDK_plus:
-/* g_debug("Plus key was pressed");*/
new_value = current_value + five_percent;
break;
case GDK_minus:
-/* g_debug("minus key was pressed");*/
new_value = current_value - five_percent;
break;
default:
break;
}
-/* g_debug("new range value without being clamped = %f", new_value); */
-
new_value = CLAMP(new_value, 0, 100);
if(new_value != current_value)
{
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 8fa47eb..52f9cba 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -92,16 +92,6 @@ static void destroy_sink_info(void *value)
g_free(sink);
}
-/*static void test_hash(){*/
-/* guint size = 0;*/
-/* size = g_hash_table_size(sink_hash);*/
-/* g_debug("Size of hash = %i", size);*/
-/* sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX)); */
-/* g_debug("The name of our sink is %s", s->name); */
-/* g_debug("and the max volume is %f", (gdouble)s->base_volume); */
-
-/*}*/
-
/*
Controllers & Utilities
*/
@@ -256,9 +246,6 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in
if(device_available == TRUE)
{
update_pa_state(TRUE, device_available, default_sink_is_muted(), get_default_sink_volume());
- //sound_service_dbus_update_sink_volume(dbus_service, get_default_sink_volume());
- //sound_service_dbus_update_sink_mute(dbus_service, default_sink_is_muted());
- //g_debug("default sink index : %d", DEFAULT_SINK_INDEX);
}
else{
//Update the indicator to show PA either is not ready or has no available sink
@@ -346,8 +333,8 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
s->description = g_strdup(info->description);
s->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME));
s->active_port = (info->active_port != NULL);
- s->mute = !!info->mute;
gboolean mute_changed = s->mute != !!info->mute;
+ s->mute = !!info->mute;
gboolean volume_changed = (pa_cvolume_equal(&info->volume, &s->volume) == 0);
s->volume = info->volume;
s->base_volume = info->base_volume;
@@ -362,9 +349,19 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
g_debug("Updating volume from PA manager with volume = %f", volume_percent);
sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
}
- if (mute_changed == TRUE)
+
+ if (mute_changed == TRUE)
+ {
+ g_debug("Updating Mute from PA manager with mute = %i", s->mute);
sound_service_dbus_update_sink_mute(dbus_service, s->mute);
- update_mute_ui(s->mute);
+ update_mute_ui(s->mute);
+ if(s->mute == FALSE){
+ pa_volume_t vol = pa_cvolume_avg(&s->volume);
+ gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
+ g_debug("Updating volume from PA manager with volume = %f", volume_percent);
+ sound_service_dbus_update_sink_volume(dbus_service, volume_percent);
+ }
+ }
}
}
else
diff --git a/src/sound-service.c b/src/sound-service.c
index c66ec78..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,20 +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_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_ENABLED, b_all_muted);
+ 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"));
- //dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_MENUITEM_PROP_ENABLED, b_all_muted);
+ dbusmenu_menuitem_property_set(mute_all_menuitem,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _(b_all_muted == FALSE ? "Mute All" : "Unmute"));
}
@@ -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 - race condition ?!?*/
-/* 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);