aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-sound.c
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-12-01 14:33:32 -0500
committerKen VanDine <ken.vandine@canonical.com>2011-12-01 14:33:32 -0500
commitc157f744805b87d39eb49ee162645d9af25b05b5 (patch)
tree9a1adac71b0b94de8a72d20fd39c821efe6b87c3 /src/indicator-sound.c
parent6c40e13a44770e9bda393e5b0b1ebefa6b8077d5 (diff)
parent048fe88d783124358184248e33100caf9d6af82d (diff)
downloadayatana-indicator-sound-c157f744805b87d39eb49ee162645d9af25b05b5.tar.gz
ayatana-indicator-sound-c157f744805b87d39eb49ee162645d9af25b05b5.tar.bz2
ayatana-indicator-sound-c157f744805b87d39eb49ee162645d9af25b05b5.zip
Import upstream version 0.8.0.0
Diffstat (limited to 'src/indicator-sound.c')
-rw-r--r--src/indicator-sound.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 7c72900..b953449 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -54,6 +54,7 @@ struct _IndicatorSoundPrivate
GList* transport_widgets_list;
GDBusProxy *dbus_proxy;
SoundStateManager* state_manager;
+ gchar *accessible_desc;
};
#define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
@@ -74,6 +75,7 @@ static GtkLabel * get_label (IndicatorObject * io);
static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
static const gchar * get_accessible_desc (IndicatorObject * io);
+static const gchar * get_name_hint (IndicatorObject * io);
static void indicator_sound_scroll (IndicatorObject * io,
IndicatorObjectEntry * entry, gint delta,
IndicatorScrollDirection direction);
@@ -133,6 +135,7 @@ indicator_sound_class_init (IndicatorSoundClass *klass)
io_class->get_image = get_icon;
io_class->get_menu = get_menu;
io_class->get_accessible_desc = get_accessible_desc;
+ io_class->get_name_hint = get_name_hint;
io_class->entry_scrolled = indicator_sound_scroll;
io_class->secondary_activate = indicator_sound_middle_click;
}
@@ -152,6 +155,7 @@ indicator_sound_init (IndicatorSound *self)
GList* t_list = NULL;
priv->transport_widgets_list = t_list;
priv->state_manager = g_object_new (SOUND_TYPE_STATE_MANAGER, NULL);
+ priv->accessible_desc = NULL;
g_signal_connect ( G_OBJECT(self->service),
INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
@@ -168,17 +172,23 @@ indicator_sound_dispose (GObject *object)
g_object_unref(G_OBJECT(self->service));
self->service = NULL;
}
- g_list_free ( priv->transport_widgets_list );
+ g_list_free (priv->transport_widgets_list);
G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object);
- return;
}
static void
indicator_sound_finalize (GObject *object)
{
+ IndicatorSound * self = INDICATOR_SOUND(object);
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+
+ if (priv->accessible_desc) {
+ g_free (priv->accessible_desc);
+ priv->accessible_desc = NULL;
+ }
+
G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object);
- return;
}
static GtkLabel *
@@ -233,14 +243,13 @@ static const gchar *
get_accessible_desc (IndicatorObject * io)
{
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
-
- if (priv->volume_widget != NULL){
- return g_strdup_printf(_("Volume (%'.0f%%)"), volume_widget_get_current_volume(priv->volume_widget));
- }
-
- return NULL;
+ return priv->accessible_desc;
}
+static const gchar *get_name_hint (IndicatorObject * io)
+{
+ return PACKAGE_NAME;
+}
static void
connection_changed (IndicatorServiceManager * sm,
@@ -410,6 +419,9 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem,
}
volume_widget = volume_widget_new (newitem, io);
priv->volume_widget = volume_widget;
+ // Don't forget to set the accessible desc.
+ update_accessible_desc (io);
+
GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
@@ -718,14 +730,15 @@ indicator_sound_scroll (IndicatorObject * io, IndicatorObjectEntry * entry,
//g_debug("indicator-sound-scroll - update slider with value %f", value);
volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value, "scroll updates");
- sound_state_manager_show_notification (priv->state_manager, value);
+ if (!gtk_widget_get_mapped(GTK_WIDGET (entry->menu)))
+ sound_state_manager_show_notification (priv->state_manager, value);
}
static void
indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry,
guint time, gpointer data)
{
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
g_return_if_fail (priv);
mute_widget_toggle(priv->mute_widget);
@@ -734,9 +747,22 @@ indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry
void
update_accessible_desc (IndicatorObject * io)
{
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
GList *entries = indicator_object_get_entries(io);
IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
- entry->accessible_desc = get_accessible_desc(io);
+
+ gchar *old_desc = priv->accessible_desc;
+
+ if (priv->volume_widget) {
+ priv->accessible_desc = g_strdup_printf(_("Volume (%'.0f%%)"),
+ volume_widget_get_current_volume (priv->volume_widget));
+ }
+ else {
+ priv->accessible_desc = NULL;
+ }
+
+ entry->accessible_desc = priv->accessible_desc;
+ g_free (old_desc);
g_signal_emit(G_OBJECT(io),
INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID,
0,