aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-02-08 21:32:10 +0000
committerConor Curran <conor.curran@canonical.com>2010-02-08 21:32:10 +0000
commit1ae774f7367f91f40f94a845c525ddedf1ddbba5 (patch)
treed117c393b073d8511a4268c11e92b7c8286fd22b /src
parentbf02109517f8e770373e13fc78cdda3019d77f04 (diff)
downloadayatana-indicator-sound-1ae774f7367f91f40f94a845c525ddedf1ddbba5.tar.gz
ayatana-indicator-sound-1ae774f7367f91f40f94a845c525ddedf1ddbba5.tar.bz2
ayatana-indicator-sound-1ae774f7367f91f40f94a845c525ddedf1ddbba5.zip
listener fixed
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c12
-rw-r--r--src/pulse-manager.c18
2 files changed, 17 insertions, 13 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 73a8a23..588b2d6 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -82,7 +82,7 @@ static gdouble input_value_from_across_the_dbus = 0.0;
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);
-static gboolean slider_value_changed_event_cb(GtkRange *range, gpointer user_data);
+static gboolean slider_value_changed_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data);
/*static void change_speaker_image(gdouble volume_percent);*/
/*static void prepare_state_machine();*/
@@ -319,7 +319,7 @@ static gboolean new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * p
g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(slider_prop_change_cb), volume_slider);
GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
- g_signal_connect(slider, "value-changed", G_CALLBACK(slider_value_changed_event_cb), newitem);
+ g_signal_connect(slider, "change-value", G_CALLBACK(slider_value_changed_event_cb), newitem);
gtk_widget_show_all(volume_slider);
return TRUE;
}
@@ -341,16 +341,16 @@ static void slider_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue *
return;
}
-static gboolean slider_value_changed_event_cb(GtkRange *range, gpointer user_data)
+static gboolean slider_value_changed_event_cb(GtkRange *range, GtkScrollType scroll_type, gdouble input_value, gpointer user_data)
{
/* #if(slider_value != input_value_from_across_the_dbus)*/
/* #{ */
DbusmenuMenuitem *item = (DbusmenuMenuitem*)user_data;
+ gdouble clamped_input = CLAMP(input_value, 0, 100);
GValue value = {0};
- gdouble input = gtk_range_get_value(range);
- g_debug("CALLBACK for the range - input received = %f", input);
+ g_debug("User input Event listener for the range - input received = %f", clamped_input);
g_value_init(&value, G_TYPE_DOUBLE);
- g_value_set_double(&value, input);
+ g_value_set_double(&value, clamped_input);
dbusmenu_menuitem_handle_event (item, "slider_change", &value, 0);
/* change_speaker_image(slider_value);*/
/* }*/
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 0a35d92..169c0df 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -44,7 +44,8 @@ void set_sink_volume(gdouble percent)
g_debug("and an actual volume of %f", (gdouble)new_volume);
pa_cvolume dev_vol;
sink_info *s = g_hash_table_lookup(sink_hash, GINT_TO_POINTER(DEFAULT_SINK_INDEX));
- pa_cvolume_set(&dev_vol, s->volume.channels, new_volume);
+ pa_cvolume_set(&dev_vol, s->volume.channels, new_volume);
+ // TODO - really this needs to be set in the success callback - if call fails then the ui will not be updated indefinitely!
pa_operation_unref(pa_context_set_sink_volume_by_index(pulse_context, DEFAULT_SINK_INDEX, &dev_vol, NULL, NULL));
}
@@ -194,15 +195,13 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in
DEFAULT_SINK_INDEX = (DEFAULT_SINK_INDEX < 0) ? 0 : DEFAULT_SINK_INDEX;
test_hash();
update_pa_state(TRUE, device_available, default_sink_is_muted(), get_default_sink_volume());
- g_debug("default sink index : %d", DEFAULT_SINK_INDEX);
-
+ 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
g_warning("Cannot find a suitable default sink ...");
update_pa_state(FALSE, device_available, TRUE, 0);
}
-
}
else{
g_debug("About to add an item to our hash");
@@ -285,8 +284,8 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
/* g_debug("Are the volumes the same %i", equal); */
s->volume = info->volume;
s->base_volume = info->base_volume;
- s->channel_map = info->channel_map;
- if(DEFAULT_SINK_INDEX == s->index/* && update_ui_vol == TRUE*/)
+ s->channel_map = info->channel_map;
+ if(DEFAULT_SINK_INDEX == s->index)
{
//update the UI
pa_volume_t vol = pa_cvolume_avg(&s->volume);
@@ -297,6 +296,11 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
sound_service_dbus_update_sink_volume(dbus_service, pa_sw_volume_to_linear(vol) * 100);
update_mute_ui(s->mute);
}
+ else{
+ // Reset the ui flag
+ // TODO: there must be a nicer way to do this - I suspect this pattern could introduce race conditions !!!
+ g_debug("SKIPPED UPDATING UI BECAUSE THE UI_NEEDS_UPDATE WAS FALSE!");
+ }
}
else
{
@@ -343,7 +347,7 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event
switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
case PA_SUBSCRIPTION_EVENT_SINK:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- //TODO handle the remove event
+ //TODO handle the remove event => if its our default sink - grey out the ui with update_pa_state
} else {
pa_operation_unref(pa_context_get_sink_info_by_index(c, index, update_sink_info, userdata));
}