aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-02-26 14:40:28 +0000
committerConor Curran <conor.curran@canonical.com>2010-02-26 14:40:28 +0000
commit8ab71867cb6d028ade4e72ee6efeb563fba07c9a (patch)
tree9c0bd797c82c39f859ee189ba4706d5971c6751a
parent11f1982a7b23d55be2306ab6da80879d2f9d8e03 (diff)
downloadayatana-indicator-sound-8ab71867cb6d028ade4e72ee6efeb563fba07c9a.tar.gz
ayatana-indicator-sound-8ab71867cb6d028ade4e72ee6efeb563fba07c9a.tar.bz2
ayatana-indicator-sound-8ab71867cb6d028ade4e72ee6efeb563fba07c9a.zip
new sink inserts are now cached in our hash
-rw-r--r--src/pulse-manager.c20
-rw-r--r--src/sound-service.c17
2 files changed, 24 insertions, 13 deletions
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 4436561..d5377bf 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -397,12 +397,20 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
}
else
{
- // TODO ADD new sink - part of big refactor
- g_debug("attempting to add new sink with name %s", info->name);
- //sink_info *s;
- //s = g_new0(sink_info, 1);
- //update the sinks hash with new sink.
- }
+ sink_info *value;
+ value = g_new0(sink_info, 1);
+ value->index = value->device_index = info->index;
+ value->name = g_strdup(info->name);
+ value->description = g_strdup(info->description);
+ value->icon_name = g_strdup(pa_proplist_gets(info->proplist, PA_PROP_DEVICE_ICON_NAME));
+ value->active_port = (info->active_port != NULL);
+ value->mute = !!info->mute;
+ value->volume = info->volume;
+ value->base_volume = info->base_volume;
+ value->channel_map = info->channel_map;
+ g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value);
+ g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");
+ }
}
diff --git a/src/sound-service.c b/src/sound-service.c
index e3153e9..af1f1e9 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -67,11 +67,11 @@ static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data
}
}
/**
-Build the DBus menu items. For now Mute all/Unmute is the only available option
+rebuild_sound_menu:
+Build the DBus menu items, mute/unmute, slider, separator and sound preferences 'link'
**/
static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service)
{
- g_debug("rebuilding the sound menu - should i be doing this - it only should happen once !");
// 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"));
@@ -82,14 +82,12 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent);
dbusmenu_menuitem_child_append(root, mute_all_menuitem);
dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem));
- // Enable/Disable, show/hide slider depending on sink availability
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
DBUSMENU_MENUITEM_PROP_ENABLED,
- b_sink_available);
+ b_sink_available);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- b_sink_available);
-
+ DBUSMENU_MENUITEM_PROP_VISIBLE,
+ b_sink_available);
// Separator
DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
@@ -168,6 +166,7 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m
static void refresh_menu()
{
+ g_debug("in the refresh menu method");
if(b_sink_available == FALSE || b_pulse_ready == FALSE)
{
@@ -183,6 +182,10 @@ static void refresh_menu()
}
else if(b_sink_available == TRUE && b_pulse_ready == TRUE){
+
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ TRUE);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
DBUSMENU_MENUITEM_PROP_VISIBLE,
TRUE);