diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-02-17 18:54:58 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-02-17 18:54:58 +0000 |
commit | 4bebcafef41b3dbc6b4f3f3e2f6382d82390335f (patch) | |
tree | ebb69bda73b2d4be8a11efbd9f0f59b3c3a24a3d /src | |
parent | 6ad2bc640794ad3d78c401e4e9391169446db619 (diff) | |
download | ayatana-indicator-sound-4bebcafef41b3dbc6b4f3f3e2f6382d82390335f.tar.gz ayatana-indicator-sound-4bebcafef41b3dbc6b4f3f3e2f6382d82390335f.tar.bz2 ayatana-indicator-sound-4bebcafef41b3dbc6b4f3f3e2f6382d82390335f.zip |
getting there
Diffstat (limited to 'src')
-rw-r--r-- | src/active-sink.c | 2 | ||||
-rw-r--r-- | src/common-defs.h | 2 | ||||
-rw-r--r-- | src/indicator-sound.c | 32 | ||||
-rw-r--r-- | src/music-player-bridge.vala | 8 | ||||
-rw-r--r-- | src/player-item.vala | 3 | ||||
-rw-r--r-- | src/pulseaudio-mgr.c | 8 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 2 | ||||
-rw-r--r-- | src/voip-input-menu-item.c | 35 | ||||
-rw-r--r-- | src/voip-input-widget.c | 15 |
9 files changed, 70 insertions, 37 deletions
diff --git a/src/active-sink.c b/src/active-sink.c index 4cf8dc0..d97419b 100644 --- a/src/active-sink.c +++ b/src/active-sink.c @@ -237,7 +237,7 @@ active_sink_get_state_from_volume (ActiveSink* self) return state; } -static pa_cvolume +pa_cvolume active_sink_construct_mono_volume (const pa_cvolume* vol) { pa_cvolume new_volume; diff --git a/src/common-defs.h b/src/common-defs.h index 1a6e435..a0c097c 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -31,7 +31,7 @@ typedef enum { AVAILABLE }SoundState; - +#define DEVICE_NOT_ACTIVE -1 #define DBUSMENU_PROPERTY_EMPTY -1 /* DBUS Custom Items */ diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 138c5ac..ef803e4 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -32,12 +32,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "metadata-widget.h" #include "title-widget.h" #include "volume-widget.h" - +#include "voip-input-widget.h" #include "dbus-shared-names.h" +#include "sound-state-manager.h" #include "gen-sound-service.xml.h" #include "common-defs.h" -#include "sound-state-manager.h" typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate; @@ -410,6 +410,15 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, parent); return TRUE; } +/** + * new_voip_slider_widget + * Create the voip menu item widget, must of the time this widget will be hidden. + * @param newitem + * @param parent + * @param client + * @param user_data + * @return + */ static gboolean new_voip_slider_widget (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, @@ -417,34 +426,35 @@ new_voip_slider_widget (DbusmenuMenuitem * newitem, gpointer user_data) { g_debug("indicator-sound: new_voip_slider_widget"); -/* GtkWidget* voip_widget = NULL; - IndicatorObject *io = NULL; - + //IndicatorObject *io = NULL; g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - volume_widget = volume_widget_new (newitem); - io = g_object_get_data (G_OBJECT (client), "indicator"); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); - priv->volume_widget = volume_widget; + voip_widget = voip_input_widget_new (newitem); +/* + / io = g_object_get_data (G_OBJECT (client), "indicator"); +*/ + //IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); + //priv->volume_widget = volume_widget; - GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); + GtkWidget* ido_slider_widget = voip_input_widget_get_ido_slider(VOIP_INPUT_WIDGET(voip_widget)); gtk_widget_show_all(ido_slider_widget); // register the style callback on this widget with state manager's style change // handler (needs to remake the blocking animation for each style). +/* g_signal_connect (ido_slider_widget, "style-set", G_CALLBACK(sound_state_manager_style_changed_cb), priv->state_manager); +*/ GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_item, parent); -*/ return TRUE; } diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index c6c9913..b5932fa 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -23,11 +23,13 @@ using GLib; public class MusicPlayerBridge : GLib.Object { + const int DEVICE_ITEMS_COUNT = 3; + private SettingsManager settings_manager; private Dbusmenu.Menuitem root_menu; private HashMap<string, PlayerController> registered_clients; private Mpris2Watcher watcher; - + public MusicPlayerBridge() { } @@ -79,10 +81,10 @@ public class MusicPlayerBridge : GLib.Object private int calculate_menu_position() { if(this.registered_clients.size == 0){ - return 2; + return DEVICE_ITEMS_COUNT; } else{ - return (2 + (this.registered_clients.size * PlayerController.WIDGET_QUANTITY)); + return (DEVICE_ITEMS_COUNT + (this.registered_clients.size * PlayerController.WIDGET_QUANTITY)); } } diff --git a/src/player-item.vala b/src/player-item.vala index e146d4a..9d07bf7 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -94,9 +94,8 @@ public class PlayerItem : Dbusmenu.Menuitem { foreach(string prop in attrs){ //debug("populated ? - prop: %s", prop); - int value_int = property_get_int(prop); if(property_get_int(prop) != EMPTY){ - //debug("populated - prop %s and value %i", prop, value_int); + //debug("populated - prop %s and value %i", prop, property_get_int(prop)); return true; } } diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index 05b2c8e..211933b 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -201,6 +201,7 @@ pm_subscribed_events_callback (pa_context *c, } break; case PA_SUBSCRIPTION_EVENT_SOURCE: + g_debug ("Looks like source event of some description"); // We don't care about any other sink other than the active one. if (index != active_sink_get_source_index (sink)) return; @@ -420,23 +421,23 @@ pm_sink_input_info_callback (pa_context *c, } // Check if this is Voip sink input gint result = pa_proplist_contains (info->proplist, PA_PROP_MEDIA_ROLE); + ActiveSink* a_sink = ACTIVE_SINK (userdata); + if (result == 1){ g_debug ("Sink input info has media role property"); const char* value = pa_proplist_gets (info->proplist, PA_PROP_MEDIA_ROLE); g_debug ("prop role = %s", value); if (g_strcmp0 (value, "phone") == 0) { g_debug ("And yes its a VOIP app ..."); + active_sink_activate_voip_item (a_sink); // TODO to start with we will assume our source is the same as what this 'client' // is pointing at. This should probably be more intelligent : // query for the list of source output info's and going on the name of the client // from the sink input ensure our voip item is using the right source. - } - //g_free (value); } // And finally check for the mute blocking state - ActiveSink* a_sink = ACTIVE_SINK (userdata); if (active_sink_get_index (a_sink) == info->sink){ active_sink_determine_blocking_state (a_sink); } @@ -534,6 +535,7 @@ pm_update_source_info_callback (pa_context *c, g_warning ("Default sink info callback - our user data is not what we think it should be"); return; } + g_debug ("Got a source update for %s , index %i", info->name, info->index); active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); } }
\ No newline at end of file diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 1acaebb..9be39c7 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -163,6 +163,8 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); // Mute button + // TODO this additions should be fixed position, i.e. add via position and not just append + // be explicit as it is fixed. dbusmenu_menuitem_child_append (priv->root_menuitem, mute_item); dbusmenu_menuitem_child_append (priv->root_menuitem, slider_item); g_debug ("just about to add the slider %i", DBUSMENU_IS_MENUITEM(slider_item)); diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c index e904503..203fed4 100644 --- a/src/voip-input-menu-item.c +++ b/src/voip-input-menu-item.c @@ -46,6 +46,10 @@ static void voip_input_menu_item_dispose (GObject *object); static void voip_input_menu_item_finalize (GObject *object); static void handle_event (DbusmenuMenuitem * mi, const gchar * name, GVariant * value, guint timestamp); +// This method should really be shared between this and the volume slider obj +// perfectly static - wait until the device mgr wrapper is properly sorted and +// then consolidate +static pa_cvolume voip_input_menu_item_construct_mono_volume (const pa_cvolume* vol); G_DEFINE_TYPE (VoipInputMenuItem, voip_input_menu_item, DBUSMENU_TYPE_MENUITEM); @@ -75,7 +79,7 @@ voip_input_menu_item_init (VoipInputMenuItem *self) DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE ); - priv->index = -1; + priv->index = DEVICE_NOT_ACTIVE; } static void @@ -114,26 +118,39 @@ handle_event (DbusmenuMenuitem * mi, } } +static pa_cvolume +voip_input_menu_item_construct_mono_volume (const pa_cvolume* vol) +{ + pa_cvolume new_volume; + pa_cvolume_init(&new_volume); + new_volume.channels = 1; + pa_volume_t max_vol = pa_cvolume_max(vol); + pa_cvolume_set(&new_volume, 1, max_vol); + return new_volume; +} + void voip_input_menu_item_update (VoipInputMenuItem* item, const pa_source_info* source) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); // only overwrite the constants of each source if the device has changed - if (priv->index != source->index){ + if (priv->index == DEVICE_NOT_ACTIVE){ priv->base_volume = source->base_volume; priv->volume_steps = source->n_volume_steps; priv->channel_map = source->channel_map; + priv->index = source->index; } - priv->volume = source->volume; + priv->volume = voip_input_menu_item_construct_mono_volume (&source->volume); priv->mute = source->mute; -/* + + pa_volume_t vol = pa_cvolume_max (&source->volume); + gdouble update = ((gdouble) vol * 100) / PA_VOLUME_NORM; + GVariant* new_volume = g_variant_new_double(update); dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(item), DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL, new_volume); -*/ - } gboolean @@ -155,6 +172,7 @@ voip_input_menu_item_deactivate (VoipInputMenuItem* item) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); priv->index = -1; + voip_input_menu_item_enable (item, FALSE); } void @@ -162,9 +180,8 @@ voip_input_menu_item_enable (VoipInputMenuItem* item, gboolean active) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (item); - if (priv->index != -1){ - if (active == TRUE) - g_warning ("Tried to enable the VOIP menuitem but we don't have an active source"); + if (priv->index == -1 && active == TRUE) { + g_warning ("Tried to enable the VOIP menuitem but we don't have an active source ??"); active = FALSE; } dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(item), diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c index 4933d7b..5ce7601 100644 --- a/src/voip-input-widget.c +++ b/src/voip-input-widget.c @@ -130,7 +130,7 @@ voip_input_widget_property_update( DbusmenuMenuitem* item, gchar* property, VoipInputWidget* mitem = VOIP_INPUT_WIDGET(userdata); VoipInputWidgetPrivate * priv = VOIP_INPUT_WIDGET_GET_PRIVATE(mitem); //g_debug("scrub-widget::property_update for prop %s", property); - if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){ + if(g_ascii_strcasecmp(DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL, property) == 0){ if(priv->grabbed == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider); GtkRange *range = (GtkRange*)slider; @@ -142,8 +142,8 @@ voip_input_widget_property_update( DbusmenuMenuitem* item, gchar* property, } static void -voip_input_widget_set_twin_item(VoipInputWidget* self, - DbusmenuMenuitem* twin_item) +voip_input_widget_set_twin_item (VoipInputWidget* self, + DbusmenuMenuitem* twin_item) { VoipInputWidgetPrivate * priv = VOIP_INPUT_WIDGET_GET_PRIVATE(self); priv->twin_item = twin_item; @@ -151,7 +151,7 @@ voip_input_widget_set_twin_item(VoipInputWidget* self, g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(voip_input_widget_property_update), self); gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item, - DBUSMENU_VOLUME_MENUITEM_LEVEL)); + DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL)); //g_debug("voip_input_widget_set_twin_item initial level = %f", initial_level); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider); GtkRange *range = (GtkRange*)slider; @@ -160,9 +160,9 @@ voip_input_widget_set_twin_item(VoipInputWidget* self, static gboolean voip_input_widget_change_value_cb (GtkRange *range, - GtkScrollType scroll, - gdouble new_value, - gpointer user_data) + GtkScrollType scroll, + gdouble new_value, + gpointer user_data) { g_return_val_if_fail (IS_VOIP_INPUT_WIDGET (user_data), FALSE); VoipInputWidget* mitem = VOIP_INPUT_WIDGET(user_data); @@ -170,6 +170,7 @@ voip_input_widget_change_value_cb (GtkRange *range, return FALSE; } + /* We only want this callback to catch mouse icon press events which set the slider to 0 or 100. Ignore all other events. |