aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2011-01-23 14:10:10 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2011-01-23 14:10:10 +0100
commit411333bed0e020e1725e3dd48afdc57e41fd1b93 (patch)
tree08ecdf8ce580377f54f5cee036ecf25966bc2b73 /src
parent9eef471b5d0f8cbfa298e607c2ddf8300623a06d (diff)
downloadayatana-indicator-sound-411333bed0e020e1725e3dd48afdc57e41fd1b93.tar.gz
ayatana-indicator-sound-411333bed0e020e1725e3dd48afdc57e41fd1b93.tar.bz2
ayatana-indicator-sound-411333bed0e020e1725e3dd48afdc57e41fd1b93.zip
use update_state_from_volume instead of determine_state_from_volume
And make determine_state_from_volume return the state for the selected value
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c23
-rw-r--r--src/indicator-sound.h2
-rw-r--r--src/volume-widget.c6
3 files changed, 20 insertions, 11 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 3867f27..d1bcc33 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -115,6 +115,7 @@ static void get_sink_availability_cb ( GObject *object,
/****Volume States 'members' ***/
static void update_state(const gint state);
+static const gint STATE_INVALID = -1;
static const gint STATE_MUTED = 0;
static const gint STATE_ZERO = 1;
static const gint STATE_LOW = 2;
@@ -452,7 +453,7 @@ static void fetch_state (IndicatorSound* self)
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
if(priv->volume_widget != NULL){
- determine_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
+ update_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
}
g_dbus_proxy_call ( priv->dbus_proxy,
@@ -631,12 +632,11 @@ update_state(const gint state)
indicator_image_helper_update(speaker_image, image_name);
}
-
-void
+static gint
determine_state_from_volume(gdouble volume_percent)
{
if (device_available == FALSE)
- return;
+ return STATE_INVALID;
gint state = previous_state;
if (volume_percent < 30.0 && volume_percent > 0) {
state = STATE_LOW;
@@ -647,9 +647,18 @@ determine_state_from_volume(gdouble volume_percent)
} else if (volume_percent == 0.0) {
state = STATE_ZERO;
}
- update_state(state);
+ return state;
}
+void
+update_state_from_volume(gdouble volume_percent)
+{
+ gint state = determine_state_from_volume(volume_percent);
+ if (state == STATE_INVALID)
+ return;
+
+ update_state(state);
+}
static gboolean
start_animation()
@@ -753,7 +762,7 @@ react_to_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self)
GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
gtk_widget_set_sensitive(slider_widget, !mute_value);
if(mute_value == FALSE){
- determine_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
+ update_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
}
}
@@ -768,7 +777,7 @@ react_to_signal_sink_availability_update(gboolean available_value, IndicatorSoun
}
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
- determine_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
+ update_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
//g_debug("signal caught - sink availability update with value: %i", available_value);
}
diff --git a/src/indicator-sound.h b/src/indicator-sound.h
index 9f829bb..7bf69b6 100644
--- a/src/indicator-sound.h
+++ b/src/indicator-sound.h
@@ -53,7 +53,7 @@ struct _IndicatorSound {
GType indicator_sound_get_type (void);
void prepare_state_machine();
-extern void determine_state_from_volume(gdouble volume_percent);
+extern void update_state_from_volume(gdouble volume_percent);
gint get_state();
gchar* get_state_image_name(gint state);
void prepare_for_tests(IndicatorObject * io);
diff --git a/src/volume-widget.c b/src/volume-widget.c
index 38dc9bb..9fa1395 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -137,7 +137,7 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
gdouble update = g_variant_get_double (value);
//g_debug("volume-widget - update level with value %f", update);
gtk_range_set_value(range, update);
- determine_state_from_volume(update);
+ update_state_from_volume(update);
}
}
}
@@ -157,7 +157,7 @@ volume_widget_set_twin_item(VolumeWidget* self,
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
gtk_range_set_value(range, initial_level);
- determine_state_from_volume(initial_level);
+ update_state_from_volume(initial_level);
}
static gboolean
@@ -169,7 +169,7 @@ volume_widget_change_value_cb (GtkRange *range,
g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
VolumeWidget* mitem = VOLUME_WIDGET(user_data);
volume_widget_update(mitem, new_value);
- determine_state_from_volume(new_value);
+ update_state_from_volume(new_value);
return FALSE;
}