diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-08-04 11:32:25 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-08-04 11:32:25 +0100 |
commit | 7beb889ea4838851ac5baeaecb30634855f43459 (patch) | |
tree | a071e3ccec7dc0548bf5994594a02ac6b6379854 /src | |
parent | fe354978ea13a5d3d8cbfc8f8ec2b3ab20170cf5 (diff) | |
download | ayatana-indicator-sound-7beb889ea4838851ac5baeaecb30634855f43459.tar.gz ayatana-indicator-sound-7beb889ea4838851ac5baeaecb30634855f43459.tar.bz2 ayatana-indicator-sound-7beb889ea4838851ac5baeaecb30634855f43459.zip |
refactor complete
Diffstat (limited to 'src')
-rw-r--r-- | src/dbus-menu-manager.c | 2 | ||||
-rw-r--r-- | src/indicator-sound.c | 28 | ||||
-rw-r--r-- | src/indicator-sound.h | 2 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 46 | ||||
-rw-r--r-- | src/sound-service-dbus.h | 1 | ||||
-rw-r--r-- | src/sound-service.xml | 14 | ||||
-rw-r--r-- | src/volume-widget.c | 15 |
7 files changed, 24 insertions, 84 deletions
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index d7d12b2..5b97a0d 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -105,7 +105,7 @@ void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_availabl // Emit the signals after the menus are setup/torn down // preserve ordering ! sound_service_dbus_update_sink_availability(dbus_interface, sink_available); - sound_service_dbus_update_sink_volume(dbus_interface, percent); + dbus_menu_manager_update_volume(percent); sound_service_dbus_update_sink_mute(dbus_interface, sink_muted); dbus_menu_manager_update_mute_ui(b_all_muted); } diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 599d969..4f449c1 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -335,26 +335,26 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, 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); - GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(volume_widget)); - + 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; - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)ido_slider_widget); - g_signal_connect(slider, "style-set", G_CALLBACK(style_changed_cb), NULL); - - gtk_widget_show_all(ido_slider_widget); + GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); + + g_signal_connect(ido_slider_widget, "style-set", G_CALLBACK(style_changed_cb), NULL); gtk_widget_set_sensitive(ido_slider_widget, !initial_mute); + gtk_widget_show_all(ido_slider_widget); + GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_item, parent); - fetch_mute_value_from_dbus(); + + fetch_mute_value_from_dbus(); fetch_sink_availability_from_dbus(INDICATOR_SOUND (io)); return TRUE; @@ -579,11 +579,8 @@ fetch_sink_availability_from_dbus(IndicatorSound* self) } IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); - GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); - - g_debug("past it"); - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget); - gtk_widget_set_sensitive(slider, device_available); + GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); + gtk_widget_set_sensitive(slider_widget, device_available); g_free(available_input); g_debug("IndicatorSound::fetch_sink_availability_from_dbus -> AVAILABILTY returned from dbus method is %i", device_available); @@ -637,16 +634,15 @@ catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer u reset_mute_blocking_animation(); } g_debug("signal caught - sink mute update with mute value: %i", mute_value); - g_return_if_fail(IS_INDICATOR_SOUND(userdata)); IndicatorSound* indicator = INDICATOR_SOUND(userdata); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); + if(priv->volume_widget == NULL){ return; } GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); - GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget); - gtk_widget_set_sensitive(slider, !mute_value); + gtk_widget_set_sensitive(slider_widget, !mute_value); } diff --git a/src/indicator-sound.h b/src/indicator-sound.h index cf1535b..251295c 100644 --- a/src/indicator-sound.h +++ b/src/indicator-sound.h @@ -49,7 +49,7 @@ struct _IndicatorSound { GType indicator_sound_get_type (void); void prepare_state_machine(); -void determine_state_from_volume(gdouble volume_percent); +extern void determine_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/sound-service-dbus.c b/src/sound-service-dbus.c index 85945d0..d553285 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -29,10 +29,8 @@ #include "pulse-manager.h" // DBUS methods -static gboolean sound_service_dbus_get_sink_volume(SoundServiceDbus* service, gdouble* volume_percent_input, GError** gerror); static gboolean sound_service_dbus_get_sink_mute(SoundServiceDbus* service, gboolean* mute_input, GError** gerror); static gboolean sound_service_dbus_get_sink_availability(SoundServiceDbus* service, gboolean* availability_input, GError** gerror); -static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror); #include "sound-service-server.h" @@ -40,7 +38,6 @@ typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; struct _SoundServiceDbusPrivate { DBusGConnection *connection; - gdouble volume_percent; gboolean mute; gboolean sink_availability; }; @@ -49,7 +46,6 @@ struct _SoundServiceDbusPrivate { /* Signals */ enum { SINK_INPUT_WHILE_MUTED, - SINK_VOLUME_UPDATE, SINK_MUTE_UPDATE, SINK_AVAILABLE_UPDATE, LAST_SIGNAL @@ -65,7 +61,6 @@ static void sound_service_dbus_init (SoundServiceDbus *self); static void sound_service_dbus_dispose (GObject *object); static void sound_service_dbus_finalize (GObject *object); - /* GObject Boilerplate */ G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT); @@ -91,14 +86,6 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - signals[SINK_VOLUME_UPDATE] = g_signal_new("sink-volume-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__DOUBLE, - G_TYPE_NONE, 1, G_TYPE_DOUBLE); - signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -113,9 +100,6 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - - } static void @@ -125,7 +109,6 @@ sound_service_dbus_init (SoundServiceDbus *self) SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); priv->connection = NULL; - priv->volume_percent = 0; priv->mute = FALSE; priv->sink_availability = FALSE; @@ -159,23 +142,6 @@ sound_service_dbus_finalize (GObject *object) } -/** -DBUS Method Callbacks -**/ -static void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror) -{ - g_debug("in the set sink volume method in the sound service dbus!, with volume_percent of %i", volume_percent); - set_sink_volume(volume_percent); -} - -static gboolean sound_service_dbus_get_sink_volume (SoundServiceDbus *self, gdouble *volume_percent_input, GError** gerror) -{ - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink volume method in the sound service dbus!, about to send over volume percent of %f", priv->volume_percent); - *volume_percent_input = priv->volume_percent; - return TRUE; -} - static gboolean sound_service_dbus_get_sink_mute (SoundServiceDbus *self, gboolean *mute_input, GError** gerror) { SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); @@ -205,18 +171,6 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean block_value); } -void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume) -{ - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->volume_percent = sink_volume; - - /* g_debug("Emitting signal: SINK_VOLUME_UPDATE, with sink_volme %f", priv->volume_percent);*/ - g_signal_emit(obj, - signals[SINK_VOLUME_UPDATE], - 0, - priv->volume_percent); -} - void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute) { /* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/ diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index 72556ad..b6e8193 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -52,7 +52,6 @@ GType sound_service_dbus_get_type (void) G_GNUC_CONST; // Utility methods to get the SIGNAL messages across into the sound-service-dbus void sound_service_dbus_sink_input_while_muted (SoundServiceDbus* obj, gboolean block_value); -void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_volume); void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute); void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availibity); diff --git a/src/sound-service.xml b/src/sound-service.xml index 12ed03e..ee19ceb 100644 --- a/src/sound-service.xml +++ b/src/sound-service.xml @@ -1,16 +1,6 @@ <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node name="/org/ayatana/indicator/sound"> <interface name="org.ayatana.indicator.sound"> - <method name = "SetSinkVolume"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_set_sink_volume"/> - <arg type='u' name='volume_percent' direction="in"/> - </method> - - <method name = "GetSinkVolume"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_volume"/> - <arg type='d' name='volume_percent_input' direction="out"/> - </method> - <method name = "GetSinkMute"> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_mute"/> <arg type='b' name='mute_input' direction="out"/> @@ -28,10 +18,6 @@ Our respective UI element should listen to this and therefore will be updated wi <arg name="block_value" type="b" direction="out"/> </signal> - <signal name="SinkVolumeUpdate"> - <arg name="volume_percent" type="u" direction="out"/> - </signal> - <signal name="SinkMuteUpdate"> <arg name="mute_value" type="b" direction="out"/> </signal> diff --git a/src/volume-widget.c b/src/volume-widget.c index 77c2b25..24fb46d 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -44,7 +44,7 @@ static void volume_widget_class_init (VolumeWidgetClass *klass); static void volume_widget_init (VolumeWidget *self); static void volume_widget_dispose (GObject *object); static void volume_widget_finalize (GObject *object); -static void volume_widget_set_twin_item( VolumeWidget* self, +static void volume_widget_set_twin_item( VolumeWidget* self, DbusmenuMenuitem* twin_item); static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GValue* value, gpointer userdata); @@ -52,9 +52,7 @@ static gboolean volume_widget_change_value_cb (GtkRange *range, GtkScrollType scroll, gdouble value, gpointer user_data); -static gboolean volume_widget_value_changed_cb(GtkRange *range, - gpointer user_data); - +static gboolean volume_widget_value_changed_cb(GtkRange *range, gpointer user_data); static void volume_widget_slider_grabbed(GtkWidget *widget, gpointer user_data); static void volume_widget_slider_released(GtkWidget *widget, gpointer user_data); static void volume_widget_parent_changed (GtkWidget *widget, gpointer user_data); @@ -149,6 +147,14 @@ volume_widget_set_twin_item(VolumeWidget* self, g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(volume_widget_property_update), self); + gdouble initial_level = g_value_get_double (dbusmenu_menuitem_property_get_value(twin_item, + DBUSMENU_VOLUME_MENUITEM_LEVEL)); + g_debug("volume_widget_set_twin_item initial level = %f", initial_level); + //volume_widget_update(self, initial_level); + 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); } static gboolean @@ -159,7 +165,6 @@ volume_widget_change_value_cb (GtkRange *range, { g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); - VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); volume_widget_update(mitem, new_value); determine_state_from_volume(new_value); return FALSE; |