From 34cc781067306d2c3f78f1ffd92c8fff734257f2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sun, 9 Jan 2011 18:23:36 +0000 Subject: first steps ... --- configure.ac | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 1297120..62220a5 100644 --- a/configure.ac +++ b/configure.ac @@ -29,17 +29,17 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) GTK_REQUIRED_VERSION=2.12 INDICATOR_REQUIRED_VERSION=0.3.6 -DBUSMENUGTK_REQUIRED_VERSION=0.2.2 +DBUSMENUGTK_REQUIRED_VERSION=0.3.9 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 INDICATOR_DISPLAY_OBJECTS=0.1.11 INDICATE_REQUIRED_VERSION=0.4.1 -DBUSMENUGLIB_REQUIRED_VERSION=0.3.1 +DBUSMENUGLIB_REQUIRED_VERSION=0.3.9 GIO_2_0_REQUIRED_VERSION=2.25.13 PKG_CHECK_MODULES(APPLET,gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS) AC_SUBST(APPLET_CFLAGS) @@ -51,7 +51,7 @@ PKG_CHECK_MODULES(PULSEAUDIO, libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VE AC_SUBST(PULSEAUDIO_CFLAGS) AC_SUBST(PULSEAUDIO_LIBS) -PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION +PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION gee-1.0 -- cgit v1.2.3 From e102f3b357c8ee39efde7406d7abfed5c0d16998 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 12:57:35 +0000 Subject: porting in progress --- configure.ac | 2 +- src/Makefile.am | 43 ++++---- src/settings-manager.vala | 4 +- src/sound-service-dbus.c | 233 ++++++++++++++++++++++++++++++------------- src/sound-service-dbus.h | 1 + src/title-menu-item.vala | 2 +- src/transport-menu-item.vala | 8 +- 7 files changed, 191 insertions(+), 102 deletions(-) diff --git a/configure.ac b/configure.ac index 62220a5..9a08077 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ INDICATE_REQUIRED_VERSION=0.4.1 DBUSMENUGLIB_REQUIRED_VERSION=0.3.9 GIO_2_0_REQUIRED_VERSION=2.25.13 -PKG_CHECK_MODULES(APPLET,gtk+-2.0 >= $GTK_REQUIRED_VERSION +PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS) diff --git a/src/Makefile.am b/src/Makefile.am index 7fe7e0f..8303183 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,8 +18,7 @@ libsoundmenu_la_SOURCES = \ title-widget.h \ volume-widget.c \ volume-widget.h \ - dbus-shared-names.h \ - sound-service-client.h + dbus-shared-names.h libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) @@ -29,27 +28,11 @@ checkxml: $(srcdir)/sound-service.xml @xmllint -valid -noout $< @echo $< checks out ok -sound-service-client.h: $(srcdir)/sound-service.xml - dbus-binding-tool \ - --prefix=_sound_service_client \ - --mode=glib-client \ - --output=sound-service-client.h \ - $(srcdir)/sound-service.xml - #################################################################### # Sound Service #################################################################### -################# -# dbus interface -################# -sound-service-server.h: $(srcdir)/sound-service.xml - dbus-binding-tool \ - --prefix=_sound_service_server \ - --mode=glib-server \ - --output=sound-service-server.h \ - $(srcdir)/sound-service.xml ##################### # libsoundmenu vala @@ -78,7 +61,7 @@ music_bridge_VALAFLAGS = \ --vapidir=./ \ --thread \ --pkg gee-1.0 \ - --pkg Dbusmenu-Glib-0.2 \ + --pkg Dbusmenu-Glib-0.4 \ --pkg common-defs \ --pkg gio-2.0 \ --pkg gio-unix-2.0 \ @@ -108,7 +91,6 @@ indicator_sound_service_SOURCES = \ pulse-manager.c \ sound-service-dbus.h \ sound-service-dbus.c \ - sound-service-server.h \ slider-menu-item.h \ slider-menu-item.c \ $(music_bridge_VALASOURCES:.vala=.c) @@ -117,9 +99,24 @@ indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(G indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) ######################### -# Extra stuff to package +# Service xml compilation ######################### -EXTRA_DIST = \ +DBUS_SPECS = \ + sound-service.xml + +gen-%.xml.h: %.xml + @echo "Building $@ from $<" + @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@ + +gen-%.xml.c: %.xml + @echo "Building $@ from $<" + @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@ + @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ + @echo ";" >> $@ + + +EXTRA_DIST += \ + $(DBUS_SPECS) sound-service.xml \ sound-service.list \ $(music_bridge_APIFILES) \ @@ -133,6 +130,8 @@ BUILT_SOURCES = \ sound-service-client.h \ sound-service-server.h \ $(music_bridge_APIFILES) \ + gen-indicator-service.xml.h \ + gen-indicator-service.xml.c \ $(music_bridge_VALASOURCES:.vala=.c) CLEANFILES = \ diff --git a/src/settings-manager.vala b/src/settings-manager.vala index 57b4487..380e442 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -55,7 +55,7 @@ public class SettingsManager : GLib.Object public void add_interested(string app_desktop_name) { var already_interested = this.settings.get_strv ("interested-media-players"); - foreach ( var s in already_interested){ + foreach (var s in already_interested){ if ( s == app_desktop_name ) return; } already_interested += (app_desktop_name); @@ -68,4 +68,4 @@ public class SettingsManager : GLib.Object { this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players")); } -} \ No newline at end of file +} diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 0760247..c574705 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -3,7 +3,7 @@ * * Authors: * Conor Curran - * Cody Russell + * Ted Gould * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -22,22 +22,28 @@ #include "config.h" #endif -#include +#include +#include "gen-indicator-service.xml.h" #include "dbus-shared-names.h" #include "sound-service-dbus.h" #include "common-defs.h" #include "pulse-manager.h" // DBUS methods -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 bus_method_call (GDBusConnection * connection, + const gchar * sender, + const gchar * path, + const gchar * interface, + const gchar * method, + GVariant * params, + GDBusMethodInvocation * invocation, + gpointer user_data); -#include "sound-service-server.h" typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; struct _SoundServiceDbusPrivate { - DBusGConnection *connection; + GDBusConnection *connection; gboolean mute; gboolean sink_availability; }; @@ -50,6 +56,8 @@ enum { LAST_SIGNAL }; +static GDBusNodeInfo * node_info = NULL; +static GDBusInterfaceInfo * interface_info = NULL; static guint signals[LAST_SIGNAL] = { 0 }; @@ -74,31 +82,50 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) object_class->finalize = sound_service_dbus_finalize; g_assert(klass != NULL); - dbus_g_object_type_install_info(SOUND_SERVICE_DBUS_TYPE, - &dbus_glib__sound_service_server_object_info); - - signals[SINK_INPUT_WHILE_MUTED] = g_signal_new("sink-input-while-muted", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - signals[SINK_AVAILABLE_UPDATE] = g_signal_new("sink-available-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + dbus_g_object_type_install_info (SOUND_SERVICE_DBUS_TYPE, + &dbus_glib__sound_service_server_object_info); + + signals[SINK_INPUT_WHILE_MUTED] = g_signal_new ("sink-input-while-muted", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + signals[SINK_MUTE_UPDATE] = g_signal_new ("sink-mute-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + signals[SINK_AVAILABLE_UPDATE] = g_signal_new ("sink-available-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + if (node_info == NULL) { + GError * error = NULL; + + node_info = g_dbus_node_info_new_for_xml(_indicator_service, &error); + if (error != NULL) { + g_error("Unable to parse Indicator Service Interface description: %s", + error->message); + g_error_free(error); + } + } + + if (interface_info == NULL) { + interface_info = g_dbus_node_info_lookup_interface (node_info, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE); + + if (interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "'"); + } + } } static void @@ -112,20 +139,29 @@ sound_service_dbus_init (SoundServiceDbus *self) priv->sink_availability = FALSE; /* Fetch the session bus */ - priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + priv->connection = g_bus_get_sync (DBUS_BUS_SESSION, NULL, &error); if (error != NULL) { - g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); + g_error("sound-service-dbus:Unable to connect to the session bus when + creating indicator sound service : %s", error->message); g_error_free(error); return; } /* register the service on it */ - dbus_g_connection_register_g_object(priv->connection, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT, - G_OBJECT(self)); + g_dbus_connection_register_object (priv->connection, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT, + interface_info, + NULL, + NULL, + NULL, + &error); + if (error != NULL) { + g_error("Unable to register the object to DBus: %s", error->message); + g_error_free(error); + return; + } } - static void sound_service_dbus_dispose (GObject *object) { @@ -140,60 +176,113 @@ sound_service_dbus_finalize (GObject *object) return; } - -static gboolean sound_service_dbus_get_sink_mute (SoundServiceDbus *self, gboolean *mute_input, GError** gerror) -{ - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink mute - sound service dbus!, about to send over mute_value of %i", priv->mute); - *mute_input = priv->mute; - return TRUE; +/* A method has been called from our dbus inteface. Figure out what it + is and dispatch it. */ +static void +bus_method_call (GDBusConnection * connection, + const gchar * sender, + const gchar * path, + const gchar * interface, + const gchar * method, + GVariant * params, + GDBusMethodInvocation * invocation, + gpointer user_data) +{ + IndicatorService * service = INDICATOR_SERVICE(user_data); + GVariant * retval = NULL; + + if (g_strcmp0(method, "GetSinkMute") == 0) { + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); + g_debug("Get sink mute - sound service dbus!, + about to send over mute_value of %i", priv->mute); + retval = g_variant_new_boolean (priv->mute); + } + else if (g_strcmp0(method, "GetSinkAvailability") == 0) { + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); + g_debug("Get sink availability - sound service dbus!, + about to send over availability_value of %i", priv->sink_availability); + retval = g_variant_new_boolean (priv->sink_availability); + } + else { + g_warning("Calling method '%s' on the sound service but it's unknown", method); + } + g_dbus_method_invocation_return_value(invocation, retval); } -static gboolean sound_service_dbus_get_sink_availability (SoundServiceDbus *self, gboolean *availability_input, GError** gerror) -{ - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability); - *availability_input = priv->sink_availability; - return TRUE; -} /** SIGNALS Utility methods to emit signals from the service into the ether. **/ -void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gboolean block_value) +void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, + gboolean block_value) { - /* g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value);*/ - g_signal_emit(obj, - signals[SINK_INPUT_WHILE_MUTED], - 0, - block_value); + g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", + block_value); + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); + GVariant* v_output = g_variant_new_boolean (block_value); + + GError * error = NULL; + + g_dbus_connection_emit_signal( priv->connection, + INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + "SinkInputWhileMuted", + v_output, + &error ); + if (error != NULL) { + g_error("Unable to emit signal 'sinkinputwhilemuted' because : %s", error->message); + g_error_free(error); + return; + } } -void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute) +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);*/ - + g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute); SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->mute = sink_mute; + GVariant* v_output = g_variant_new_boolean (sink_mute); - g_signal_emit(obj, - signals[SINK_MUTE_UPDATE], - 0, - priv->mute); + GError * error = NULL; + + g_dbus_connection_emit_signal( priv->connection, + INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + "SinkMuteUpdate", + v_output, + &error ); + if (error != NULL) { + g_error("Unable to emit signal 'sinkmuteupdate' because : %s", error->message); + g_error_free(error); + return; + } } -void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availability) +void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, + gboolean sink_availability) { /* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/ - + g_debug("Emitting signal: SinkAvailableUpdate, with %i", sink_availability); SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - priv->sink_availability = sink_availability; + GVariant* v_output = g_variant_new_boolean (sink_availability); + + GError * error = NULL; - g_signal_emit(obj, - signals[SINK_AVAILABLE_UPDATE], - 0, - priv->sink_availability); + g_dbus_connection_emit_signal( priv->connection, + INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + "SinkAvailableUpdate", + v_output, + &error ); + if (error != NULL) { + g_error("Unable to emit signal 'SinkAvailableUpdate' because : %s", error->message); + g_error_free(error); + return; + } } diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index b6e8193..0d1573b 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -48,6 +48,7 @@ struct _SoundServiceDbus { struct _SoundServiceDbusClass { GObjectClass parent_class; }; + GType sound_service_dbus_get_type (void) G_GNUC_CONST; // Utility methods to get the SIGNAL messages across into the sound-service-dbus diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index 0b99ae3..6ed24d8 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -31,7 +31,7 @@ public class TitleMenuitem : PlayerItem this.property_set_bool(MENUITEM_RUNNING, false); } - public override void handle_event(string name, GLib.Value input_value, uint timestamp) + public override void handle_event(string name, Variant input_value, uint timestamp) { if(this.owner.current_state == PlayerController.state.OFFLINE) { diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 0e4e6ee..55ee3b3 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -36,8 +36,8 @@ public class TransportMenuitem : PlayerItem public TransportMenuitem(PlayerController parent) { - Object(item_type: MENUITEM_TYPE, owner: parent); - this.property_set_int(MENUITEM_PLAY_STATE, 1); + Object(item_type: MENUITEM_TYPE, owner: parent); + this.property_set_int(MENUITEM_PLAY_STATE, 1); } public void change_play_state(state update) @@ -47,9 +47,9 @@ public class TransportMenuitem : PlayerItem this.property_set_int(MENUITEM_PLAY_STATE, update); } - public override void handle_event(string name, GLib.Value input_value, uint timestamp) + public override void handle_event(string name, Variant input_value, uint timestamp) { - int input = input_value.get_int(); + int input = input_value.get_int32(); debug("handle_event with value %s", input.to_string()); debug("transport owner name = %s", this.owner.app_info.get_name()); this.owner.mpris_bridge.transport_update((action)input); -- cgit v1.2.3 From 6bf8f172ef969f5d0a5fa2a2da1497b8b84c42bb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 13:12:39 +0000 Subject: autofoo fixes --- src/Makefile.am | 14 ++++++-------- src/sound-service-dbus.c | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8303183..b45da22 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -115,13 +115,12 @@ gen-%.xml.c: %.xml @echo ";" >> $@ -EXTRA_DIST += \ - $(DBUS_SPECS) +EXTRA_DIST = \ + $(DBUS_SPECS) \ sound-service.xml \ - sound-service.list \ $(music_bridge_APIFILES) \ $(music_bridge_VALASOURCES) - + ####################### # Stuff to clean Stuff ####################### @@ -130,10 +129,9 @@ BUILT_SOURCES = \ sound-service-client.h \ sound-service-server.h \ $(music_bridge_APIFILES) \ - gen-indicator-service.xml.h \ - gen-indicator-service.xml.c \ + gen-sound-service.xml.h \ + gen-sound-service.xml.c \ $(music_bridge_VALASOURCES:.vala=.c) - + CLEANFILES = \ $(BUILT_SOURCES) - diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index c574705..319e72a 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -23,7 +23,7 @@ #endif #include -#include "gen-indicator-service.xml.h" +#include "gen-sound-service.xml.h" #include "dbus-shared-names.h" #include "sound-service-dbus.h" #include "common-defs.h" -- cgit v1.2.3 From 5f7a9d979b49674604160ce4baac403c79832470 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 17:54:06 +0000 Subject: lots of refactoring and the rest --- src/dbus-shared-names.h | 4 ++ src/indicator-sound.c | 182 ++++++++++++++++++++++++++++++----------------- src/sound-service-dbus.c | 66 +++++------------ 3 files changed, 137 insertions(+), 115 deletions(-) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 9d1e875..1e117cf 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -30,5 +30,9 @@ with this program. If not, see . #define INDICATOR_SOUND_SERVICE_DBUS_OBJECT "/com/canonical/indicators/sound/service" #define INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "com.canonical.indicators.sound" #define INDICATOR_SOUND_DBUS_VERSION 0 +#define INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted" +#define INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate" +#define INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" + #endif /* __DBUS_SHARED_NAMES_H__ */ diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 34f5ed9..53bb366 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -29,8 +29,7 @@ with this program. If not, see . #include #include -#include -#include +#include #include "indicator-sound.h" #include "transport-widget.h" @@ -39,7 +38,8 @@ with this program. If not, see . #include "volume-widget.h" #include "dbus-shared-names.h" -#include "sound-service-client.h" + +#include "gen-sound-service-xml.h" #include "common-defs.h" typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate; @@ -48,6 +48,7 @@ struct _IndicatorSoundPrivate { GtkWidget* volume_widget; GList* transport_widgets_list; + GDBusProxy *dbus_proxy; }; #define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate)) @@ -81,8 +82,20 @@ static gboolean new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); // DBUS communication -static DBusGProxy *sound_dbus_proxy = NULL; -static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); + +static GDBusNodeInfo *node_info = NULL; +static GDBusInterfaceInfo *interface_info = NULL; + +static void connection_changed (IndicatorServiceManager * sm, + gboolean connected, + gpointer userdata); + +static void g_signal_cb ( GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) + static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata); static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata); static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata); @@ -146,7 +159,8 @@ static void indicator_sound_init (IndicatorSound *self) { self->service = NULL; - self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); + self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_VERSION); prepare_state_machine(); prepare_blocked_animation(); animation_id = 0; @@ -156,13 +170,13 @@ indicator_sound_init (IndicatorSound *self) IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); priv->volume_widget = NULL; + priv->dbus_proxy = NULL; GList* t_list = NULL; priv->transport_widgets_list = t_list; g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); - return; } static void @@ -290,11 +304,11 @@ new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - //g_debug("indicator-sound: new_title_widget"); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - //g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME)); + //g_debug ("%s (\"%s\")", __func__, + //dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME)); GtkWidget* title = NULL; @@ -345,64 +359,81 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, static void -connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) -{ - if (connected) { - gboolean service_restart = FALSE; - if (sound_dbus_proxy != NULL) { - g_object_unref (sound_dbus_proxy); - sound_dbus_proxy = NULL; - service_restart = TRUE; - } - GError * error = NULL; - - DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - - sound_dbus_proxy = dbus_g_proxy_new_for_name_owner(sbus, - INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, - &error); +connection_changed (IndicatorServiceManager * sm, + gboolean connected, + gpointer user_data) +{ + IndicatorSound* indicator = INDICATOR_SOUND(user_data); + g_return_if_fail ( IS_INDICATOR_SOUND (indicator) ); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + if (connected == FALSE){ + return; + //TODO: Gracefully handle disconnection + // do a timeout to wait for reconnection + // for 5 seconds and then if no connection message + // is received put the state at 'sink not available' + } + // If we connection is back on and the proxy is not null + // we don't need to anything gdbus takes care of the rest - bless. + if (priv->dbus_proxy!= NULL){ + return; + } + + if ( node_info == NULL ){ + node_info = g_dbus_node_info_new_for_xml ( _sound_service, + &error ); if (error != NULL) { - g_warning("Unable to get status proxy: %s", error->message); + g_warning( "Failed to get create interface info from xml: %s", + error->message ); g_error_free(error); + return; } - //g_debug("about to connect to the signals"); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), user_data, NULL); - dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_AVAILABLE_UPDATE, G_CALLBACK(catch_signal_sink_availability_update), NULL, NULL); - - if( service_restart == TRUE){ - fetch_mute_value_from_dbus(); - // Ensure UI is in sync with service again. - IndicatorSound* indicator = INDICATOR_SOUND(user_data); - fetch_sink_availability_from_dbus(indicator); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); - if(priv->volume_widget != NULL){ - determine_state_from_volume (volume_widget_get_current_volume(priv->volume_widget)); - } + } + + if (interface_info == NULL) { + interface_info = g_dbus_node_info_lookup_interface (node_info, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE); + if (interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "'"); } - } - else{ - g_warning("Indicator has been disconnected from the service -> SHOCK HORROR"); - IndicatorSound* indicator = INDICATOR_SOUND(user_data); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); - - if(priv->volume_widget != NULL){ - g_warning("indicator still has a slider, service must have crashed"); - volume_widget_tidy_up(priv->volume_widget); - g_object_unref(G_OBJECT(priv->volume_widget)); - priv->volume_widget = NULL; - } - device_available = FALSE; - update_state(STATE_SINKS_NONE); } + + g_dbus_proxy_new_for_bus( G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + interface_info, + INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + NULL, + create_connection_to_service, + indicator ); } +static void create_connection_to_service (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + IndicatorSound *self = INDICATOR_SOUND(user_data); + GError *error = NULL; + + g_return_if_fail(self != NULL); + + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + + priv->dbus_proxy = g_dbus_proxy_new_finish(res, &error); + + if (error != NULL) { + g_warning("Failed to get dbus proxy: %s", error->message); + g_error_free(error); + return; + } + + g_signal_connect(self->dbus_proxy, "g-signal", G_CALLBACK(g_signal), self); + +} + + /* Prepare states Array. */ @@ -609,10 +640,32 @@ fetch_mute_value_from_dbus() } /*******************************************************************/ -//DBus signal catchers +// Signal reactions /*******************************************************************/ +static void g_signal_cb ( GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + IndicatorSound *self = INDICATOR_SOUND(user_data); + GError *error = NULL; + gboolean input = g_variant_get_boolean (parameters); + g_return_if_fail ( IS_INDICATOR_SOUND(self) ); + + if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE) == 0){ + react_signal_sink_availability_update ( input, self ); + } + else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE) == 0){ + react_signal_sink_mute_update ( input, self ); + } + else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED) == 0){ + react_signal_sink_input_while_muted ( input, self ); + } +} + static void -catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) +react_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self) { //g_debug("signal caught - sink input while muted with value %i", block_value); if (block_value == 1 && blocked_id == 0 && animation_id == 0 && blocked_animation_list != NULL) { @@ -627,7 +680,7 @@ catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gp UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here. */ static void -catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata) +react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self) { if (mute_value == TRUE && device_available == TRUE) { update_state(STATE_MUTED); @@ -636,8 +689,7 @@ catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer u } //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); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); if(priv->volume_widget == NULL){ return; @@ -648,7 +700,7 @@ catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer u static void -catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata) +react_signal_sink_availability_update(gboolean available_value, IndicatorSound* self) { device_available = available_value; if (device_available == FALSE) { diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 319e72a..987ce7c 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -43,24 +43,14 @@ static void bus_method_call (GDBusConnection * connection, typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; struct _SoundServiceDbusPrivate { - GDBusConnection *connection; - gboolean mute; - gboolean sink_availability; -}; - -/* Signals */ -enum { - SINK_INPUT_WHILE_MUTED, - SINK_MUTE_UPDATE, - SINK_AVAILABLE_UPDATE, - LAST_SIGNAL + GDBusConnection *connection; + gboolean mute; + gboolean sink_availability; }; static GDBusNodeInfo * node_info = NULL; static GDBusInterfaceInfo * interface_info = NULL; -static guint signals[LAST_SIGNAL] = { 0 }; - #define SOUND_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbusPrivate)) static void sound_service_dbus_class_init (SoundServiceDbusClass *klass); @@ -82,41 +72,17 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) object_class->finalize = sound_service_dbus_finalize; g_assert(klass != NULL); - dbus_g_object_type_install_info (SOUND_SERVICE_DBUS_TYPE, - &dbus_glib__sound_service_server_object_info); - - signals[SINK_INPUT_WHILE_MUTED] = g_signal_new ("sink-input-while-muted", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - signals[SINK_MUTE_UPDATE] = g_signal_new ("sink-mute-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - signals[SINK_AVAILABLE_UPDATE] = g_signal_new ("sink-available-update", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - if (node_info == NULL) { - GError * error = NULL; - - node_info = g_dbus_node_info_new_for_xml(_indicator_service, &error); - if (error != NULL) { - g_error("Unable to parse Indicator Service Interface description: %s", + + if (node_info == NULL) { + GError * error = NULL; + + node_info = g_dbus_node_info_new_for_xml(_sound_service, &error); + if (error != NULL) { + g_error("Unable to parse Indicator Service Interface description: %s", error->message); - g_error_free(error); - } - } + g_error_free(error); + } + } if (interface_info == NULL) { interface_info = g_dbus_node_info_lookup_interface (node_info, @@ -228,7 +194,7 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT, INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, - "SinkInputWhileMuted", + INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED, v_output, &error ); if (error != NULL) { @@ -251,7 +217,7 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT, INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, - "SinkMuteUpdate", + INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE, v_output, &error ); if (error != NULL) { @@ -275,7 +241,7 @@ void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT, INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, - "SinkAvailableUpdate", + INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE, v_output, &error ); if (error != NULL) { -- cgit v1.2.3 From 82425f25064d97b0feb2c0c5cdc839558bf5f51f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 20:25:36 +0000 Subject: getting there --- configure.ac | 2 +- src/Makefile.am | 2 - src/indicator-sound.c | 213 ++++++++++++++++++++++++++++++------------------- src/title-widget.c | 11 ++- src/transport-widget.c | 20 ++--- src/volume-widget.c | 22 +++-- 6 files changed, 155 insertions(+), 115 deletions(-) diff --git a/configure.ac b/configure.ac index 9a08077..a6522ed 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) ########################### GTK_REQUIRED_VERSION=2.12 -INDICATOR_REQUIRED_VERSION=0.3.6 +INDICATOR_REQUIRED_VERSION=0.3.15 DBUSMENUGTK_REQUIRED_VERSION=0.3.9 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 diff --git a/src/Makefile.am b/src/Makefile.am index b45da22..0443029 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -126,8 +126,6 @@ EXTRA_DIST = \ ####################### BUILT_SOURCES = \ music_bridge_vala.stamp \ - sound-service-client.h \ - sound-service-server.h \ $(music_bridge_APIFILES) \ gen-sound-service.xml.h \ gen-sound-service.xml.c \ diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 53bb366..992dfdd 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -39,7 +39,7 @@ with this program. If not, see . #include "dbus-shared-names.h" -#include "gen-sound-service-xml.h" +#include "gen-sound-service.xml.h" #include "common-defs.h" typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate; @@ -85,22 +85,35 @@ static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * static GDBusNodeInfo *node_info = NULL; static GDBusInterfaceInfo *interface_info = NULL; - +static void create_connection_to_service (GObject *source_object, + GAsyncResult *res, + gpointer user_data); static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); - static void g_signal_cb ( GDBusProxy *proxy, const gchar *sender_name, const gchar *signal_name, GVariant *parameters, - gpointer user_data) + gpointer user_data); + +static void react_to_signal_sink_input_while_muted (gboolean value, + IndicatorSound* self); +static void react_to_signal_sink_mute_update (gboolean value, + IndicatorSound* self); +static void react_to_signal_sink_availability_update (gboolean value, + IndicatorSound* self); +static void fetch_state ( IndicatorSound* self ); + +static void get_sink_mute_cb ( GObject *object, + GAsyncResult *res, + gpointer user_data ); + +static void get_sink_availability_cb ( GObject *object, + GAsyncResult *res, + gpointer user_data ); + -static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean value, gpointer userdata); -static void catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer userdata); -static void catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata); -static void fetch_mute_value_from_dbus(); -static void fetch_sink_availability_from_dbus(IndicatorSound* self); /****Volume States 'members' ***/ static void update_state(const gint state); @@ -352,8 +365,7 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, newitem, menu_volume_item, parent); - fetch_mute_value_from_dbus(); - fetch_sink_availability_from_dbus(INDICATOR_SOUND (io)); + fetch_state(INDICATOR_SOUND (io)); return TRUE; } @@ -365,7 +377,8 @@ connection_changed (IndicatorServiceManager * sm, { IndicatorSound* indicator = INDICATOR_SOUND(user_data); g_return_if_fail ( IS_INDICATOR_SOUND (indicator) ); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE (indicator); + GError *error = NULL; if (connected == FALSE){ return; @@ -374,9 +387,11 @@ connection_changed (IndicatorServiceManager * sm, // for 5 seconds and then if no connection message // is received put the state at 'sink not available' } - // If we connection is back on and the proxy is not null - // we don't need to anything gdbus takes care of the rest - bless. - if (priv->dbus_proxy!= NULL){ + // If the proxy is not null and connected is true => its a reconnect, + // we don't need to anything, gdbus takes care of the rest - bless. + // just fetch the state. + if (priv->dbus_proxy != NULL){ + fetch_state (indicator); return; } @@ -417,7 +432,7 @@ static void create_connection_to_service (GObject *source_object, IndicatorSound *self = INDICATOR_SOUND(user_data); GError *error = NULL; - g_return_if_fail(self != NULL); + g_return_if_fail( IS_INDICATOR_SOUND(self) ); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); @@ -428,12 +443,104 @@ static void create_connection_to_service (GObject *source_object, g_error_free(error); return; } + + g_signal_connect(priv->dbus_proxy, "g-signal", G_CALLBACK(g_signal_cb), self); + fetch_state (self); +} - g_signal_connect(self->dbus_proxy, "g-signal", G_CALLBACK(g_signal), self); +static void fetch_state (IndicatorSound* self) +{ + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + + g_dbus_proxy_call ( priv->dbus_proxy, + "GetSinkMute", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + (GAsyncReadyCallback)get_sink_mute_cb, + self); + + g_dbus_proxy_call ( priv->dbus_proxy, + "GetSinkAvailability", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + (GAsyncReadyCallback)get_sink_availability_cb, + self); +} + +static void get_sink_availability_cb ( GObject *object, + GAsyncResult *res, + gpointer user_data ) +{ + IndicatorSound* self = INDICATOR_SOUND(user_data); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + GVariant *result, *value; + GError *error = NULL; + gboolean is_available; + + result = g_dbus_proxy_call_finish ( priv->dbus_proxy, + res, + &error ); + + if (error != NULL) { + g_debug("get_sink_availability call failed: %s", error->message); + g_error_free(error); + return; + } + + value = g_variant_get_child_value(result, 0); + is_available = g_variant_get_boolean(value); + + if (is_available == FALSE) { + update_state(STATE_SINKS_NONE); + } + + if(priv->volume_widget != NULL){ + GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); + gtk_widget_set_sensitive(slider_widget, is_available); + } + + g_variant_unref(value); + g_variant_unref(result); } +static void get_sink_mute_cb ( GObject *object, + GAsyncResult *res, + gpointer user_data) +{ + IndicatorSound* self = INDICATOR_SOUND(user_data); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + + GVariant *result, *value; + GError *error = NULL; + gboolean is_muted; + + result = g_dbus_proxy_call_finish ( priv->dbus_proxy, + res, + &error ); + + if (error != NULL) { + g_debug("get_sink_mute call failed: %s", error->message); + g_error_free(error); + return; + } + + value = g_variant_get_child_value(result, 0); + is_muted = g_variant_get_boolean(value); + + if ( is_muted == TRUE ){ + update_state(STATE_MUTED); + } + + g_variant_unref(value); + g_variant_unref(result); +} + /* Prepare states Array. */ @@ -581,66 +688,9 @@ reset_mute_blocking_animation() } -/*******************************************************************/ -//DBus method handlers -/*******************************************************************/ -static void -fetch_sink_availability_from_dbus(IndicatorSound* self) -{ - g_return_if_fail(IS_INDICATOR_SOUND(self)); - - GError * error = NULL; - gboolean * available_input; - available_input = g_new0(gboolean, 1); - com_canonical_indicators_sound_get_sink_availability(sound_dbus_proxy, available_input, &error); - if (error != NULL) { - g_warning("Unable to fetch AVAILABILITY at indicator start up: %s", error->message); - g_error_free(error); - g_free(available_input); - return; - } - - device_available = *available_input; - if (device_available == FALSE) { - update_state(STATE_SINKS_NONE); - //g_debug("NO DEVICE AVAILABLE"); - } - - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); - - if(priv->volume_widget != NULL){ - 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 ->%i", device_available); -} - - -static void -fetch_mute_value_from_dbus() -{ - GError * error = NULL; - gboolean *mute_input; - mute_input = g_new0(gboolean, 1); - com_canonical_indicators_sound_get_sink_mute(sound_dbus_proxy, mute_input, &error); - if (error != NULL) { - g_warning("Unable to fetch MUTE at indicator start up: %s", error->message); - g_error_free(error); - g_free(mute_input); - return; - } - initial_mute = *mute_input; - if (initial_mute == TRUE){ - update_state(STATE_MUTED); - } - g_free(mute_input); - //g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); -} /*******************************************************************/ -// Signal reactions +// DBUS Signal reactions /*******************************************************************/ static void g_signal_cb ( GDBusProxy *proxy, const gchar *sender_name, @@ -654,18 +704,18 @@ static void g_signal_cb ( GDBusProxy *proxy, g_return_if_fail ( IS_INDICATOR_SOUND(self) ); if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE) == 0){ - react_signal_sink_availability_update ( input, self ); + react_to_signal_sink_availability_update ( input, self ); } else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE) == 0){ - react_signal_sink_mute_update ( input, self ); + react_to_signal_sink_mute_update ( input, self ); } else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED) == 0){ - react_signal_sink_input_while_muted ( input, self ); + react_to_signal_sink_input_while_muted ( input, self ); } } static void -react_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self) +react_to_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self) { //g_debug("signal caught - sink input while muted with value %i", block_value); if (block_value == 1 && blocked_id == 0 && animation_id == 0 && blocked_animation_list != NULL) { @@ -680,7 +730,7 @@ react_signal_sink_input_while_muted(gboolean block_value, IndicatorSound* self) UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here. */ static void -react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self) +react_to_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self) { if (mute_value == TRUE && device_available == TRUE) { update_state(STATE_MUTED); @@ -688,7 +738,6 @@ react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self) 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)); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); if(priv->volume_widget == NULL){ @@ -700,7 +749,7 @@ react_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self) static void -react_signal_sink_availability_update(gboolean available_value, IndicatorSound* self) +react_to_signal_sink_availability_update(gboolean available_value, IndicatorSound* self) { device_available = available_value; if (device_available == FALSE) { diff --git a/src/title-widget.c b/src/title-widget.c index 08b4b81..1318ce1 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -138,12 +138,11 @@ title_widget_button_press_event (GtkWidget *menuitem, //g_debug("TitleWidget::menu_press_event"); TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem); - GValue value = {0}; - g_value_init(&value, G_TYPE_BOOLEAN); - - g_value_set_boolean(&value, TRUE); - dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0); - + GVariant* new_title_event = g_variant_new_boolean(TRUE); + dbusmenu_menuitem_handle_event (priv->twin_item, + "Title menu event", + new_title_event, + 0); return FALSE; } diff --git a/src/transport-widget.c b/src/transport-widget.c index d7f4b75..9b45734 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -112,8 +112,8 @@ static gboolean transport_widget_leave_notify_event (GtkWidget *menuitem GdkEventCrossing *event); static void transport_widget_property_update ( DbusmenuMenuitem* item, gchar * property, - GValue * value, - gpointer userdata ); + GVariant * value, + gpointer userdata ); static void transport_widget_menu_hidden ( GtkWidget *menu, TransportWidget *transport); static void transport_widget_notify ( GObject *item, @@ -344,13 +344,11 @@ transport_widget_button_release_event (GtkWidget *menuitem, TransportWidgetEvent result = transport_widget_determine_button_event ( transport, event ); if(result != TRANSPORT_NADA){ - GValue value = {0}; - g_value_init(&value, G_TYPE_INT); //g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result); - g_value_set_int(&value, (int)result); + GVariant* new_transport_state = g_variant_new_int32 ((int)result); dbusmenu_menuitem_handle_event ( priv->twin_item, "Transport state change", - &value, + new_transport_state, 0 ); } transport_widget_react_to_button_release ( transport, @@ -402,13 +400,11 @@ transport_widget_react_to_key_release_event ( TransportWidget* transport, { if(transport_event != TRANSPORT_NADA){ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); - GValue value = {0}; - g_value_init(&value, G_TYPE_INT); //g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result); - g_value_set_int(&value, (int)transport_event); + GVariant* new_transport_event = g_variant_new_int32((int)transport_event); dbusmenu_menuitem_handle_event ( priv->twin_item, "Transport state change", - &value, + new_transport_event, 0 ); } transport_widget_react_to_button_release ( transport, @@ -1700,7 +1696,7 @@ transport_widget_set_twin_item(TransportWidget* self, **/ static void transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) + GVariant* value, gpointer userdata) { //g_debug("transport_widget_update_state - with property %s", property); TransportWidget* bar = (TransportWidget*)userdata; @@ -1708,7 +1704,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0) { - int update_value = g_value_get_int(value); + int update_value = g_variant_get_int32(value); //g_debug("transport_widget_update_state - with value %i", update_value); transport_widget_toggle_play_pause(bar, (TransportWidgetState)update_value); } diff --git a/src/volume-widget.c b/src/volume-widget.c index c37f9c7..6fd4632 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -48,7 +48,7 @@ static void volume_widget_finalize (GObject *object); 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); + GVariant* value, gpointer userdata ); static gboolean volume_widget_change_value_cb (GtkRange *range, GtkScrollType scroll, @@ -122,8 +122,8 @@ volume_widget_finalize (GObject *object) } static void -volume_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) +volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, + GVariant* value, gpointer userdata) { g_return_if_fail (IS_VOLUME_WIDGET (userdata)); VolumeWidget* mitem = VOLUME_WIDGET(userdata); @@ -133,7 +133,7 @@ volume_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(priv->grabbed == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; - gdouble update = g_value_get_double (value); + 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); @@ -150,8 +150,8 @@ volume_widget_set_twin_item(VolumeWidget* self, g_object_ref(priv->twin_item); 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)); + gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item, + DBUSMENU_VOLUME_MENUITEM_LEVEL)); //g_debug("volume_widget_set_twin_item initial level = %f", initial_level); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; @@ -195,11 +195,9 @@ void volume_widget_update(VolumeWidget* self, gdouble update) { VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self); - GValue value = {0}; - g_value_init(&value, G_TYPE_DOUBLE); gdouble clamped = CLAMP(update, 0, 100); - g_value_set_double(&value, clamped); - dbusmenu_menuitem_handle_event (priv->twin_item, "update", &value, 0); + GVariant* new_volume = g_variant_new_double(clamped); + dbusmenu_menuitem_handle_event (priv->twin_item, "update", new_volume, 0); } GtkWidget* @@ -246,8 +244,8 @@ volume_widget_get_current_volume ( GtkWidget *widget ) { VolumeWidget* mitem = VOLUME_WIDGET(widget); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); - gdouble vol = g_value_get_double ( dbusmenu_menuitem_property_get_value( priv->twin_item, - DBUSMENU_VOLUME_MENUITEM_LEVEL)); + gdouble vol = g_variant_get_double( dbusmenu_menuitem_property_get_variant( priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_LEVEL)); return vol; } -- cgit v1.2.3 From 19172db0350957626b6c235bfff9e85d39fa97d4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 20:50:22 +0000 Subject: configure ac fixes --- configure.ac | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index a6522ed..8654f02 100644 --- a/configure.ac +++ b/configure.ac @@ -39,7 +39,7 @@ GIO_2_0_REQUIRED_VERSION=2.25.13 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS) AC_SUBST(APPLET_CFLAGS) @@ -53,13 +53,12 @@ AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0 + indicate >= $INDICATE_REQUIRED_VERSION + gee-1.0 gio-unix-2.0 libxml-2.0) - AC_SUBST(SOUNDSERVICE_CFLAGS) -AC_SUBST(SOUNDERVICE_LIBS) +AC_SUBST(SOUNDSERVICE_LIBS) AC_PATH_PROG(GCONFTOOL, gconftool-2) dnl Specify the gconf configuration source, -- cgit v1.2.3 From b3a4d53a7f9433c1bd13ae89697ea06a8ce44e50 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 20:52:39 +0000 Subject: ignore sorted by ted --- .bzrignore | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.bzrignore b/.bzrignore index 5b399c8..8468f00 100644 --- a/.bzrignore +++ b/.bzrignore @@ -50,3 +50,29 @@ src/libsoundmenu_la-indicator-sound.lo src/libsoundmenu_la-sound-service-marshal.lo ruby_dbus_scripts/dbus_monitor.rb +.anjuta +.anjuta_sym_db.db +TODO.tasks +make_output.txt +swap-over.anjuta +src/fetch-file.c +src/freedesktop-interfaces.c +src/gen-sound-service.xml.c +src/gen-sound-service.xml.h +src/libsoundmenu_la-metadata-widget.lo +src/libsoundmenu_la-title-widget.lo +src/libsoundmenu_la-transport-widget.lo +src/libsoundmenu_la-volume-widget.lo +src/metadata-menu-item.c +src/mpris2-controller.c +src/mpris2-interfaces.c +src/mpris2-watcher.c +src/music-player-bridge.c +src/music-player-bridge.h +src/music_bridge_vala.stamp +src/player-controller.c +src/player-item.c +src/playlists-menu-item.c +src/settings-manager.c +src/title-menu-item.c +src/transport-menu-item.c -- cgit v1.2.3 From 9452f0262c608fc1ee6509078b3538f68b5f0993 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 10 Jan 2011 16:47:20 -0600 Subject: now building --- configure.ac | 2 -- src/Makefile.am | 2 ++ src/dbus-menu-manager.c | 11 ++++------- src/sound-service-dbus.c | 17 +++++++---------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 8654f02..aeeb41f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,6 @@ DBUSMENUGTK_REQUIRED_VERSION=0.3.9 POLKIT_REQUIRED_VERSION=0.92 PULSE_AUDIO_REQUIRED_VERSION=0.9.19 INDICATOR_DISPLAY_OBJECTS=0.1.11 -INDICATE_REQUIRED_VERSION=0.4.1 DBUSMENUGLIB_REQUIRED_VERSION=0.3.9 GIO_2_0_REQUIRED_VERSION=2.25.13 @@ -53,7 +52,6 @@ AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - indicate >= $INDICATE_REQUIRED_VERSION gee-1.0 gio-unix-2.0 libxml-2.0) diff --git a/src/Makefile.am b/src/Makefile.am index 0443029..99a00c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,6 +93,8 @@ indicator_sound_service_SOURCES = \ sound-service-dbus.c \ slider-menu-item.h \ slider-menu-item.c \ + gen-sound-service.xml.h \ + gen-sound-service.xml.c \ $(music_bridge_VALASOURCES:.vala=.c) indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index f92c324..e51db0d 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -21,9 +21,6 @@ with this program. If not, see . #include #include -#include -#include - #include #include @@ -79,10 +76,10 @@ DbusmenuMenuitem* dbus_menu_manager_setup() void dbus_menu_manager_update_volume(gdouble volume) { - GValue value = {0}; - g_value_init(&value, G_TYPE_DOUBLE); - g_value_set_double(&value, volume); - dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_VOLUME_MENUITEM_LEVEL, &value); + GVariant* new_volume = g_variant_new_double(volume); + dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(volume_slider_menuitem), + DBUSMENU_VOLUME_MENUITEM_LEVEL, + new_volume); } diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 987ce7c..8e0f31a 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -23,6 +23,7 @@ #endif #include +#include #include "gen-sound-service.xml.h" #include "dbus-shared-names.h" #include "sound-service-dbus.h" @@ -105,11 +106,10 @@ sound_service_dbus_init (SoundServiceDbus *self) priv->sink_availability = FALSE; /* Fetch the session bus */ - priv->connection = g_bus_get_sync (DBUS_BUS_SESSION, NULL, &error); + priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (error != NULL) { - g_error("sound-service-dbus:Unable to connect to the session bus when - creating indicator sound service : %s", error->message); + g_error("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message); g_error_free(error); return; } @@ -154,19 +154,16 @@ bus_method_call (GDBusConnection * connection, GDBusMethodInvocation * invocation, gpointer user_data) { - IndicatorService * service = INDICATOR_SERVICE(user_data); + IndicatorService* service = INDICATOR_SERVICE(user_data); GVariant * retval = NULL; + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (service); if (g_strcmp0(method, "GetSinkMute") == 0) { - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink mute - sound service dbus!, - about to send over mute_value of %i", priv->mute); + g_debug("Get sink mute - sound service dbus!,about to send over mute_value of %i", priv->mute); retval = g_variant_new_boolean (priv->mute); } else if (g_strcmp0(method, "GetSinkAvailability") == 0) { - SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self); - g_debug("Get sink availability - sound service dbus!, - about to send over availability_value of %i", priv->sink_availability); + g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability); retval = g_variant_new_boolean (priv->sink_availability); } else { -- cgit v1.2.3 From 590a3ad4a7bf384a7023365c85e127a42cd4b5b2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 03:57:41 -0600 Subject: more warnings sorted --- src/Makefile.am | 2 +- src/indicator-sound.c | 14 +++++++++----- src/sound-service-dbus.c | 20 +++++++++++++------- src/sound-service.c | 4 ++-- src/transport-widget.c | 4 +++- src/volume-widget.c | 3 ++- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 99a00c0..22f88d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,7 @@ libsoundmenu_la_SOURCES = \ volume-widget.h \ dbus-shared-names.h -libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\" +libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" libsoundmenu_la_LIBADD = $(APPLET_LIBS) libsoundmenu_la_LDFLAGS = -module -avoid-version diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 992dfdd..9d108d8 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -152,6 +152,8 @@ indicator_sound_class_init (IndicatorSoundClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + g_debug(" !!!!!!!!!!!!!!!!! here 0"); + object_class->dispose = indicator_sound_dispose; object_class->finalize = indicator_sound_finalize; @@ -164,16 +166,17 @@ indicator_sound_class_init (IndicatorSoundClass *klass) io_class->get_menu = get_menu; io_class->scroll = indicator_sound_scroll; design_team_size = gtk_icon_size_register("design-team-size", 22, 22); - - return; } static void indicator_sound_init (IndicatorSound *self) { + g_debug(" !!!!!!!!!!!!!!!!! here 0"); + self->service = NULL; self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); + prepare_state_machine(); prepare_blocked_animation(); animation_id = 0; @@ -186,6 +189,8 @@ indicator_sound_init (IndicatorSound *self) priv->dbus_proxy = NULL; GList* t_list = NULL; priv->transport_widgets_list = t_list; + + g_debug(" !!!!!!!!!!!!!!!!! here 1"); g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, @@ -699,7 +704,6 @@ static void g_signal_cb ( GDBusProxy *proxy, gpointer user_data) { IndicatorSound *self = INDICATOR_SOUND(user_data); - GError *error = NULL; gboolean input = g_variant_get_boolean (parameters); g_return_if_fail ( IS_INDICATOR_SOUND(self) ); @@ -825,7 +829,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) } } else if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { - TransportWidget* transport_widget; + TransportWidget* transport_widget = NULL; GList* elem; for ( elem = priv->transport_widgets_list; elem; elem = elem->next ) { @@ -880,7 +884,7 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) menuitem = GTK_MENU_SHELL (widget)->active_menu_item; if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { - TransportWidget* transport_widget; + TransportWidget* transport_widget = NULL; GList* elem; for(elem = priv->transport_widgets_list; elem; elem = elem->next) { diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 8e0f31a..223c1d9 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -40,6 +40,12 @@ static void bus_method_call (GDBusConnection * connection, GDBusMethodInvocation * invocation, gpointer user_data); +static GDBusInterfaceVTable interface_table = { + method_call: bus_method_call, + get_property: NULL, /* No properties */ + set_property: NULL /* No properties */ +}; + typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; @@ -85,14 +91,14 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) } } - if (interface_info == NULL) { - interface_info = g_dbus_node_info_lookup_interface (node_info, + if (interface_info == NULL) { + interface_info = g_dbus_node_info_lookup_interface (node_info, INDICATOR_SOUND_SERVICE_DBUS_INTERFACE); - if (interface_info == NULL) { - g_error("Unable to find interface '" INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "'"); - } - } + if (interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "'"); + } + } } static void @@ -117,7 +123,7 @@ sound_service_dbus_init (SoundServiceDbus *self) g_dbus_connection_register_object (priv->connection, INDICATOR_SOUND_SERVICE_DBUS_OBJECT, interface_info, - NULL, + &interface_table, NULL, NULL, &error); diff --git a/src/sound-service.c b/src/sound-service.c index 98f1881..defcb94 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) { if (mainloop != NULL) { g_debug("Service shutdown !"); - close_pulse_activites(); - g_main_loop_quit(mainloop); + //close_pulse_activites(); + //g_main_loop_quit(mainloop); } return; } diff --git a/src/transport-widget.c b/src/transport-widget.c index 9b45734..a276a31 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -757,7 +757,9 @@ _color_rgb_to_hls (gdouble *r, gdouble red; gdouble green; gdouble blue; - gdouble h, l, s; + gdouble h = 0; + gdouble l; + gdouble s; gdouble delta; red = *r; diff --git a/src/volume-widget.c b/src/volume-widget.c index 6fd4632..38dc9bb 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -28,6 +28,7 @@ with this program. If not, see . #include "volume-widget.h" #include "common-defs.h" #include +#include "indicator-sound.h" typedef struct _VolumeWidgetPrivate VolumeWidgetPrivate; @@ -136,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); + determine_state_from_volume(update); } } } -- cgit v1.2.3 From 293f1f77d2fa67a2eb77fdacb10d5b4bf5e82663 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 04:08:47 -0600 Subject: handle disconnection gracefully --- .bzrignore | 5 +++++ src/indicator-sound.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.bzrignore b/.bzrignore index 8468f00..5e59c90 100644 --- a/.bzrignore +++ b/.bzrignore @@ -76,3 +76,8 @@ src/playlists-menu-item.c src/settings-manager.c src/title-menu-item.c src/transport-menu-item.c +modified: +src/indicator-sound.c +data/com.canonical.indicators.sound.gschema.valid +tests/libmockpulse.la +tests/libmockpulse_la-mockpulse.lo diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 9d108d8..1ca3447 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -7,7 +7,6 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran Ted Gould - Cody Russell This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -386,6 +385,7 @@ connection_changed (IndicatorServiceManager * sm, GError *error = NULL; if (connected == FALSE){ + update_state (STATE_SINKS_NONE); return; //TODO: Gracefully handle disconnection // do a timeout to wait for reconnection @@ -396,7 +396,7 @@ connection_changed (IndicatorServiceManager * sm, // we don't need to anything, gdbus takes care of the rest - bless. // just fetch the state. if (priv->dbus_proxy != NULL){ - fetch_state (indicator); + fetch_state (indicator); return; } -- cgit v1.2.3 From 81b77951c81a3086f7c4e5849cfd061e3dcb8ef3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 04:41:33 -0600 Subject: silly me --- src/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 22f88d7..32b6928 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,8 @@ libsoundmenu_la_SOURCES = \ title-widget.h \ volume-widget.c \ volume-widget.h \ + gen-sound-service.xml.h \ + gen-sound-service.xml.c \ dbus-shared-names.h libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\" @@ -35,7 +37,7 @@ checkxml: $(srcdir)/sound-service.xml ##################### -# libsoundmenu vala +# Sound service vala ##################### music_bridge_VALASOURCES = \ music-player-bridge.vala \ @@ -79,7 +81,7 @@ music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES) touch music_bridge_vala.stamp ############################### -# libsoundmenu C +# Sound Service C ############################### indicator_sound_service_SOURCES = \ common-defs.h \ -- cgit v1.2.3 From 7440e8668c7d018e8ef85aea08ee5924da813d9d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 04:42:06 -0600 Subject: more ignores --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 5e59c90..6b177b5 100644 --- a/.bzrignore +++ b/.bzrignore @@ -81,3 +81,4 @@ src/indicator-sound.c data/com.canonical.indicators.sound.gschema.valid tests/libmockpulse.la tests/libmockpulse_la-mockpulse.lo +src/libsoundmenu_la-gen-sound-service.xml.lo -- cgit v1.2.3 From f5858b0a17a43bd46fcd2351a160a6ec74171cc6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 05:51:06 -0600 Subject: signals being sent correctly --- src/indicator-sound.c | 8 +++++--- src/sound-service-dbus.c | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 1ca3447..ed35d7a 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -112,8 +112,6 @@ static void get_sink_availability_cb ( GObject *object, GAsyncResult *res, gpointer user_data ); - - /****Volume States 'members' ***/ static void update_state(const gint state); @@ -704,8 +702,12 @@ static void g_signal_cb ( GDBusProxy *proxy, gpointer user_data) { IndicatorSound *self = INDICATOR_SOUND(user_data); - gboolean input = g_variant_get_boolean (parameters); g_return_if_fail ( IS_INDICATOR_SOUND(self) ); + + g_variant_ref (parameters); + GVariant *value = g_variant_get_child_value (parameters, 0); + gboolean input = g_variant_get_boolean (value); + g_variant_unref (parameters); if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE) == 0){ react_to_signal_sink_availability_update ( input, self ); diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 223c1d9..d9db2b6 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -124,7 +124,7 @@ sound_service_dbus_init (SoundServiceDbus *self) INDICATOR_SOUND_SERVICE_DBUS_OBJECT, interface_info, &interface_table, - NULL, + self, NULL, &error); if (error != NULL) { @@ -158,19 +158,20 @@ bus_method_call (GDBusConnection * connection, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, - gpointer user_data) + gpointer user_data) { - IndicatorService* service = INDICATOR_SERVICE(user_data); + SoundServiceDbus* service = SOUND_SERVICE_DBUS(user_data); + g_return_if_fail ( IS_SOUND_SERVICE_DBUS(service) ); GVariant * retval = NULL; SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (service); if (g_strcmp0(method, "GetSinkMute") == 0) { g_debug("Get sink mute - sound service dbus!,about to send over mute_value of %i", priv->mute); - retval = g_variant_new_boolean (priv->mute); + retval = g_variant_new ( "(b)", priv->mute); } else if (g_strcmp0(method, "GetSinkAvailability") == 0) { g_debug("Get sink availability - sound service dbus!, about to send over availability_value of %i", priv->sink_availability); - retval = g_variant_new_boolean (priv->sink_availability); + retval = g_variant_new ( "(b)", priv->sink_availability); } else { g_warning("Calling method '%s' on the sound service but it's unknown", method); @@ -189,7 +190,7 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with block_value: %i", block_value); SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - GVariant* v_output = g_variant_new_boolean (block_value); + GVariant* v_output = g_variant_new("(b)", block_value); GError * error = NULL; @@ -212,10 +213,10 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, { g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute); SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - GVariant* v_output = g_variant_new_boolean (sink_mute); + priv->mute = sink_mute; + GVariant* v_output = g_variant_new("(b)", sink_mute); GError * error = NULL; - g_dbus_connection_emit_signal( priv->connection, INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT, @@ -233,13 +234,13 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availability) { - /* g_debug("Emitting signal: SINK_AVAILABILITY_UPDATE, with value %i", sink_availability);*/ g_debug("Emitting signal: SinkAvailableUpdate, with %i", sink_availability); SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (obj); - GVariant* v_output = g_variant_new_boolean (sink_availability); - + priv->sink_availability = sink_availability; + + GVariant* v_output = g_variant_new("(b)", priv->sink_availability); GError * error = NULL; - + g_dbus_connection_emit_signal( priv->connection, INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT, -- cgit v1.2.3 From d973ef42b4bf03d7c4eecb3eb9230c98853686c4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 07:04:17 -0600 Subject: more fixes --- src/indicator-sound.c | 19 +++++++------------ src/slider-menu-item.c | 26 ++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index ed35d7a..adccfdd 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -149,8 +149,6 @@ indicator_sound_class_init (IndicatorSoundClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_debug(" !!!!!!!!!!!!!!!!! here 0"); - object_class->dispose = indicator_sound_dispose; object_class->finalize = indicator_sound_finalize; @@ -168,8 +166,6 @@ indicator_sound_class_init (IndicatorSoundClass *klass) static void indicator_sound_init (IndicatorSound *self) { - g_debug(" !!!!!!!!!!!!!!!!! here 0"); - self->service = NULL; self->service = indicator_service_manager_new_version(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_VERSION); @@ -187,8 +183,6 @@ indicator_sound_init (IndicatorSound *self) GList* t_list = NULL; priv->transport_widgets_list = t_list; - g_debug(" !!!!!!!!!!!!!!!!! here 1"); - g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_changed), self); @@ -276,7 +270,7 @@ free_the_animation_list() static gboolean new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - //g_debug("indicator-sound: new_transport_bar() called "); + g_debug("indicator-sound: new_transport_bar() called "); GtkWidget* bar = NULL; IndicatorObject *io = NULL; @@ -300,7 +294,7 @@ new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbus static gboolean new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - //g_debug("indicator-sound: new_metadata_widget"); + g_debug("indicator-sound: new_metadata_widget"); GtkWidget* metadata = NULL; @@ -322,8 +316,7 @@ new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - //g_debug ("%s (\"%s\")", __func__, - //dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME)); + g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME)); GtkWidget* title = NULL; @@ -341,7 +334,7 @@ new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - //g_debug("indicator-sound: new_volume_slider_widget"); + g_debug("indicator-sound: new_volume_slider_widget"); GtkWidget* volume_widget = NULL; IndicatorObject *io = NULL; @@ -708,7 +701,9 @@ static void g_signal_cb ( GDBusProxy *proxy, GVariant *value = g_variant_get_child_value (parameters, 0); gboolean input = g_variant_get_boolean (value); g_variant_unref (parameters); - + + g_debug ( "!!! signal_cb with value %i", input); + if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE) == 0){ react_to_signal_sink_availability_update ( input, self ); } diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index d0d2050..0f2f07b 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -39,7 +39,8 @@ static void slider_menu_item_class_init (SliderMenuItemClass *klass); static void slider_menu_item_init (SliderMenuItem *self); static void slider_menu_item_dispose (GObject *object); static void slider_menu_item_finalize (GObject *object); -static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); +static void handle_event (DbusmenuMenuitem * mi, const gchar * name, + GVariant * value, guint timestamp); G_DEFINE_TYPE (SliderMenuItem, slider_menu_item, DBUSMENU_TYPE_MENUITEM); @@ -77,12 +78,29 @@ slider_menu_item_finalize (GObject *object) static void -handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) +handle_event (DbusmenuMenuitem * mi, + const gchar * name, + GVariant * value, + guint timestamp) { gdouble volume_input = 0; - volume_input = g_value_get_double(value); - if (value != NULL) + /*g_debug ( "handle-event in the slider at the backend, input is of type %s", + g_variant_get_type_string(value));*/ + + GVariant* input = NULL; + input = value; + g_variant_ref (input); + + // Please note: Subject to change in future DBusmenu revisions + if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT) == TRUE) { + input = g_variant_get_variant(value); + } + + volume_input = g_variant_get_double(input); + if (value != NULL){ set_sink_volume(volume_input); + } + g_variant_unref (input); } -- cgit v1.2.3 From 1885dcd754d4fec1882087050a789b99f7442573 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 07:13:13 -0600 Subject: tidy up plus moved to gvariant for the property update on the indicator widgets --- src/metadata-widget.c | 4 +- src/scrub-widget.c | 376 -------------------------------------------------- src/scrub-widget.h | 53 ------- src/title-widget.c | 4 +- 4 files changed, 4 insertions(+), 433 deletions(-) delete mode 100644 src/scrub-widget.c delete mode 100644 src/scrub-widget.h diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 191e134..20c1841 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -61,7 +61,7 @@ static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, // Dbusmenuitem properties update callback static void metadata_widget_property_update (DbusmenuMenuitem* item, gchar* property, - GValue* value, + GVariant* value, gpointer userdata); static void metadata_widget_style_labels ( MetadataWidget* self, GtkLabel* label); @@ -400,7 +400,7 @@ metadata_widget_button_press_event (GtkWidget *menuitem, // TODO: Manage empty/mangled music details etc. static void metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) + GVariant* value, gpointer userdata) { g_return_if_fail (IS_METADATA_WIDGET (userdata)); diff --git a/src/scrub-widget.c b/src/scrub-widget.c deleted file mode 100644 index edc65de..0000000 --- a/src/scrub-widget.c +++ /dev/null @@ -1,376 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "scrub-widget.h" -#include "common-defs.h" -#include -#include - -typedef struct _ScrubWidgetPrivate ScrubWidgetPrivate; - -struct _ScrubWidgetPrivate -{ - DbusmenuMenuitem* twin_item; - GtkWidget* ido_scrub_bar; - IdoTimeline* time_line; - gboolean scrubbing; -}; - -#define SCRUB_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SCRUB_WIDGET_TYPE, ScrubWidgetPrivate)) - -/* Prototypes */ -static void scrub_widget_class_init (ScrubWidgetClass *klass); -static void scrub_widget_init (ScrubWidget *self); -static void scrub_widget_dispose (GObject *object); -static void scrub_widget_finalize (GObject *object); -static void scrub_widget_property_update( DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata); -static void scrub_widget_set_twin_item( ScrubWidget* self, - DbusmenuMenuitem* twin_item); -static gchar* scrub_widget_format_time(gint time); -static void scrub_widget_set_ido_position(ScrubWidget* self, - gint position, - gint duration); -static gboolean scrub_widget_change_value_cb (GtkRange *range, - GtkScrollType scroll, - gdouble value, - gpointer user_data); - -static void scrub_widget_timeline_frame_cb(IdoTimeline *timeline, - gdouble progress, - gpointer userdata); -static void scrub_widget_timeline_started_cb(IdoTimeline *timeline, - gpointer userdata); -static void scrub_widget_timeline_finished_cb(IdoTimeline *timeline, - gpointer userdata); -static gdouble scrub_widget_calculate_progress(ScrubWidget* widget); -static void scrub_widget_check_play_state(ScrubWidget* self); -static void scrub_widget_slider_grabbed(GtkWidget *widget, gpointer user_data); -static void scrub_widget_slider_released(GtkWidget *widget, gpointer user_data); - - - -G_DEFINE_TYPE (ScrubWidget, scrub_widget, G_TYPE_OBJECT); - -static void -scrub_widget_class_init (ScrubWidgetClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (ScrubWidgetPrivate)); - - gobject_class->dispose = scrub_widget_dispose; - gobject_class->finalize = scrub_widget_finalize; -} - -static void -scrub_widget_init (ScrubWidget *self) -{ - g_debug("ScrubWidget::scrub_widget_init"); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); - - priv->ido_scrub_bar = ido_scale_menu_item_new_with_range ("Scrub", IDO_RANGE_STYLE_SMALL, 0, 0, 100, 1); - priv->time_line = ido_timeline_new(0); - - ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), IDO_SCALE_MENU_ITEM_STYLE_LABEL); - - g_object_set(priv->ido_scrub_bar, "reverse-scroll-events", TRUE, NULL); - priv->scrubbing = FALSE; - - gtk_widget_set_size_request(GTK_WIDGET(priv->ido_scrub_bar), 100, 25); - - // register slider changes listening on the range - GtkWidget* scrub_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); - g_signal_connect(scrub_widget, "change-value", G_CALLBACK(scrub_widget_change_value_cb), self); - g_signal_connect(priv->time_line, "frame", G_CALLBACK(scrub_widget_timeline_frame_cb), self); - g_signal_connect(priv->time_line, "started", G_CALLBACK(scrub_widget_timeline_started_cb), self); - g_signal_connect(priv->time_line, "finished", G_CALLBACK(scrub_widget_timeline_finished_cb), self); - g_signal_connect(priv->ido_scrub_bar, "slider-grabbed", G_CALLBACK(scrub_widget_slider_grabbed), self); - g_signal_connect(priv->ido_scrub_bar, "slider-released", G_CALLBACK(scrub_widget_slider_released), self); - -} - -static void -scrub_widget_dispose (GObject *object) -{ - G_OBJECT_CLASS (scrub_widget_parent_class)->dispose (object); -} - -static void -scrub_widget_finalize (GObject *object) -{ - G_OBJECT_CLASS (scrub_widget_parent_class)->finalize (object); -} - -static void -scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) -{ - g_debug("scrub-widget::property_update"); - - g_return_if_fail (IS_SCRUB_WIDGET (userdata)); - ScrubWidget* mitem = SCRUB_WIDGET(userdata); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - - if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_DURATION, property) == 0){ - g_debug("scrub-widget::update length = %i", g_value_get_int(value)); - - ido_scale_menu_item_set_secondary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), - scrub_widget_format_time(g_value_get_int(value))); - - ido_timeline_set_duration(priv->time_line, g_value_get_int(value) * 1000); - ido_timeline_rewind(priv->time_line); - scrub_widget_check_play_state(mitem); - //g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line)); - //g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line)); - - scrub_widget_set_ido_position(mitem, - dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_POSITION)/1000, - dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_DURATION)); - } - else if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_POSITION, property) == 0){ - g_debug("scrub-widget::update position = %i", g_value_get_int(value)); - ido_timeline_pause(priv->time_line); - ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), - scrub_widget_format_time(g_value_get_int(value)/1000)); - - g_debug("scrub-widget::update progress = %f", scrub_widget_calculate_progress(mitem)*100); - - ido_timeline_set_progress(priv->time_line, scrub_widget_calculate_progress(mitem)); - scrub_widget_set_ido_position(mitem, g_value_get_int(value)/1000, - dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_DURATION)); - - scrub_widget_check_play_state(mitem); - } - else if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_PLAY_STATE, property) == 0){ - scrub_widget_check_play_state(mitem); - } -} - -static void -scrub_widget_check_play_state(ScrubWidget* self) -{ - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); - gint play_state = dbusmenu_menuitem_property_get_int(priv->twin_item, - DBUSMENU_SCRUB_MENUITEM_PLAY_STATE); - g_debug("play-state = %i", play_state); - if(play_state == 0){ - g_debug("START TIMELINE"); - ido_timeline_start(priv->time_line); - } - else{ - g_debug("PAUSE TIMELINE"); - ido_timeline_pause(priv->time_line); - } -} - -static void -scrub_widget_set_twin_item(ScrubWidget* self, - DbusmenuMenuitem* twin_item) -{ - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); - priv->twin_item = twin_item; - - g_signal_connect(G_OBJECT(twin_item), "property-changed", - G_CALLBACK(scrub_widget_property_update), self); - - gchar* left_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item, - DBUSMENU_SCRUB_MENUITEM_POSITION)/1000); - gchar* right_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item, - DBUSMENU_SCRUB_MENUITEM_DURATION)); - scrub_widget_set_ido_position(self, - dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_POSITION)/1000, - dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_DURATION)); - - ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), left_text); - ido_scale_menu_item_set_secondary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), right_text); - g_free(left_text); - g_free(right_text); -} - -static gboolean -scrub_widget_change_value_cb (GtkRange *range, - GtkScrollType scroll, - gdouble new_value, - gpointer user_data) -{ - g_return_val_if_fail (IS_SCRUB_WIDGET (user_data), FALSE); - ScrubWidget* mitem = SCRUB_WIDGET(user_data); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - - // Don't bother when the slider is grabbed - if(priv->scrubbing == TRUE) - return FALSE; - - GValue value = {0}; - g_value_init(&value, G_TYPE_DOUBLE); - gdouble clamped = CLAMP(new_value, 0, 100); - g_value_set_double(&value, clamped); - dbusmenu_menuitem_handle_event (priv->twin_item, "scrubbing", &value, 0); - return TRUE; -} - -GtkWidget* -scrub_widget_get_ido_bar(ScrubWidget* self) -{ - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); - return priv->ido_scrub_bar; -} - -static gchar* -scrub_widget_format_time(gint time) -{ -// Assuming its in seconds for now ... - gchar* prefix = "-"; - gchar* seconds_prefix = "-"; - - if(time != DBUSMENU_PROPERTY_EMPTY){ - gint minutes = time/60; - gint seconds = time % 60; - prefix="0"; - seconds_prefix="0"; - if(minutes > 9) - prefix=""; - if(seconds > 9) - seconds_prefix=""; - return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds); - - } - else{ - return g_strdup_printf("%s-:%s-", prefix, seconds_prefix); - } -} - -static void -scrub_widget_set_ido_position(ScrubWidget* self, - gint position, - gint duration) -{ - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(self); - gdouble ido_position = position/(gdouble)duration * 100.0; - g_debug("scrub_widget_set_ido_position - pos: %i, duration: %i, ido_pos: %f", position, duration, ido_position); - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); - GtkRange *range = (GtkRange*)slider; - if(duration == 0) - ido_position = 0.0; - gtk_range_set_value(range, ido_position); -} - -static gdouble -scrub_widget_calculate_progress(ScrubWidget* widget) -{ - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(widget); - gint position = dbusmenu_menuitem_property_get_int(priv->twin_item, - DBUSMENU_SCRUB_MENUITEM_POSITION)/1000; - gint duration = dbusmenu_menuitem_property_get_int(priv->twin_item, - DBUSMENU_SCRUB_MENUITEM_DURATION); - gdouble ido_position = position/(gdouble)duration; - g_debug("scrub_widget_calculate_progress %f", ido_position); - - return ido_position; -} - - -static void -scrub_widget_timeline_frame_cb( IdoTimeline *timeline, - gdouble progress, - gpointer user_data) -{ - - //g_debug("Timeline CB : %f", progress); - g_return_if_fail (IS_SCRUB_WIDGET (user_data)); - ScrubWidget* mitem = SCRUB_WIDGET(user_data); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - if(priv->scrubbing == TRUE) - { - g_debug("don't update the slider or timeline, slider is being scrubbed"); - return; - } - gint position = progress * dbusmenu_menuitem_property_get_int(priv->twin_item, - DBUSMENU_SCRUB_MENUITEM_DURATION); - gchar* left_text = scrub_widget_format_time(position); - ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), left_text); - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); - GtkRange *range = (GtkRange*)slider; - gtk_range_set_value(range, progress * 100); - /*g_debug("position in seconds %i and in words %s", position, left_text); - g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line)); - g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line)); - */ - //g_debug("timeline-update - progress = %f", progress); - g_free(left_text); -} - - -static void -scrub_widget_slider_released(GtkWidget *widget, gpointer user_data) -{ - ScrubWidget* mitem = SCRUB_WIDGET(user_data); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - priv->scrubbing = FALSE; - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar); - gdouble new_value = gtk_range_get_value(GTK_RANGE(slider)); - g_debug("okay set the scrub position with %f", new_value); - GValue value = {0}; - g_value_init(&value, G_TYPE_DOUBLE); - gdouble clamped = CLAMP(new_value, 0, 100); - g_value_set_double(&value, clamped); - dbusmenu_menuitem_handle_event (priv->twin_item, "scrubbing", &value, 0); -} - -static void -scrub_widget_slider_grabbed(GtkWidget *widget, gpointer user_data) -{ - ScrubWidget* mitem = SCRUB_WIDGET(user_data); - ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem); - priv->scrubbing = TRUE; -} - -static void -scrub_widget_timeline_started_cb( IdoTimeline *timeline, - gpointer user_data) -{ - g_debug("Timeline Started!"); -} - -static void -scrub_widget_timeline_finished_cb(IdoTimeline *timeline, - gpointer user_data) -{ - g_debug("Timeline Finished!"); -} - -/** - * scrub_widget_new: - * @returns: a new #ScrubWidget. - **/ -GtkWidget* -scrub_widget_new(DbusmenuMenuitem *item) -{ - GtkWidget* widget = g_object_new(SCRUB_WIDGET_TYPE, NULL); - scrub_widget_set_twin_item((ScrubWidget*)widget, item); - return widget; -} - - diff --git a/src/scrub-widget.h b/src/scrub-widget.h deleted file mode 100644 index cf6cc5e..0000000 --- a/src/scrub-widget.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ -#ifndef __SCRUB_WIDGET_H__ -#define __SCRUB_WIDGET_H__ - -#include -#include -#include - -G_BEGIN_DECLS - -#define SCRUB_WIDGET_TYPE (scrub_widget_get_type ()) -#define SCRUB_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRUB_WIDGET_TYPE, ScrubWidget)) -#define SCRUB_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRUB_WIDGET_TYPE, ScrubWidgetClass)) -#define IS_SCRUB_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRUB_WIDGET_TYPE)) -#define IS_SCRUB_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRUB_WIDGET_TYPE)) -#define SCRUB_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRUB_WIDGET_TYPE, ScrubWidgetClass)) - -typedef struct _ScrubWidget ScrubWidget; -typedef struct _ScrubWidgetClass ScrubWidgetClass; - -struct _ScrubWidgetClass { - GObjectClass parent_class; -}; - -struct _ScrubWidget { - GObject parent; -}; - -GType scrub_widget_get_type (void) G_GNUC_CONST; -GtkWidget* scrub_widget_new(DbusmenuMenuitem* twin_item); -GtkWidget* scrub_widget_get_ido_bar(ScrubWidget* self); - -G_END_DECLS - -#endif - diff --git a/src/title-widget.c b/src/title-widget.c index 1318ce1..bbb5e6d 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -49,7 +49,7 @@ static gboolean title_widget_button_press_event (GtkWidget *menuitem, // Dbusmenuitem properties update callback static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata); + GVariant* value, gpointer userdata); static void title_widget_set_twin_item( TitleWidget* self, DbusmenuMenuitem* twin_item); static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, @@ -148,7 +148,7 @@ title_widget_button_press_event (GtkWidget *menuitem, static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GValue* value, gpointer userdata) + GVariant* value, gpointer userdata) { g_return_if_fail (IS_TITLE_WIDGET (userdata)); TitleWidget* mitem = TITLE_WIDGET(userdata); -- cgit v1.2.3 From 4f18accfeba38149b17f2c92a6b1520f14100e50 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 07:22:38 -0600 Subject: more gvariant changes --- src/metadata-widget.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 20c1841..09365d5 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -404,34 +404,33 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, { g_return_if_fail (IS_METADATA_WIDGET (userdata)); - if(g_value_get_int(value) == DBUSMENU_PROPERTY_EMPTY){ + if(g_variant_is_of_type(value, G_VARIANT_TYPE_INT32) == TRUE && + g_variant_get_int32(value) == DBUSMENU_PROPERTY_EMPTY){ //g_debug("Metadata widget: property update - reset"); - GValue new_value = {0}; - g_value_init(&new_value, G_TYPE_STRING); - g_value_set_string(&new_value, g_strdup("")); - value = &new_value; + GVariant* new_value = g_variant_new_string (""); + value = new_value; } MetadataWidget* mitem = METADATA_WIDGET(userdata); MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem); if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTIST, property) == 0){ - gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(priv->artist_label), g_variant_get_string(value, NULL)); metadata_widget_style_labels(mitem, GTK_LABEL(priv->artist_label)); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TITLE, property) == 0){ - gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(priv->piece_label), g_variant_get_string(value, NULL)); metadata_widget_style_labels(mitem, GTK_LABEL(priv->piece_label)); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ALBUM, property) == 0){ - gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(priv->container_label), g_variant_get_string(value, NULL)); metadata_widget_style_labels(mitem, GTK_LABEL(priv->container_label)); } else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){ g_string_erase(priv->image_path, 0, -1); - g_string_overwrite(priv->image_path, 0, g_value_get_string (value)); + g_string_overwrite(priv->image_path, 0, g_variant_get_string (value, NULL)); // if its a remote image queue a redraw incase the download took too long - if (g_str_has_prefix(g_value_get_string (value), g_get_user_cache_dir())){ + if (g_str_has_prefix(g_variant_get_string (value, NULL), g_get_user_cache_dir())){ //g_debug("the image update is a download so redraw"); gtk_widget_queue_draw(GTK_WIDGET(mitem)); } -- cgit v1.2.3 From 765d17777a49c1742371216b46b2992ff7dfc191 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 09:13:20 -0600 Subject: working nicely --- src/title-widget.c | 2 +- src/transport-menu-item.vala | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/title-widget.c b/src/title-widget.c index bbb5e6d..675c59f 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -154,7 +154,7 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, TitleWidget* mitem = TITLE_WIDGET(userdata); if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), - g_value_get_string(value)); + g_variant_get_string(value, NULL)); } else if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_ICON, property) == 0){ title_widget_set_icon (mitem); diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 55ee3b3..e93f0bb 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -47,11 +47,20 @@ public class TransportMenuitem : PlayerItem this.property_set_int(MENUITEM_PLAY_STATE, update); } - public override void handle_event(string name, Variant input_value, uint timestamp) + public override void handle_event(string name, + Variant input_value, + uint timestamp) { - int input = input_value.get_int32(); - debug("handle_event with value %s", input.to_string()); - debug("transport owner name = %s", this.owner.app_info.get_name()); + /*debug ( "Handle event in transport menu item - input variant is of type %s", + input_value.get_type_string() );*/ + Variant v = input_value; + if ( input_value.is_of_type ( VariantType.VARIANT) ){ + v = input_value.get_variant(); + } + + int32 input = v.get_int32(); + debug("transport menu item -> handle_event with value %s", input.to_string()); + //debug("transport owner name = %s", this.owner.app_info.get_name()); this.owner.mpris_bridge.transport_update((action)input); } -- cgit v1.2.3 From cf13be5b4436b802488e1980bb89aa87997cd90e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 10:30:56 -0600 Subject: refactored signal names --- src/dbus-menu-manager.c | 2 +- src/dbus-shared-names.h | 6 +++--- src/indicator-sound.c | 35 ++++++++++++++++++++--------------- src/sound-service-dbus.c | 20 ++++++++++---------- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index e51db0d..92bfba5 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -68,7 +68,7 @@ DbusmenuMenuitem* dbus_menu_manager_setup() dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); - DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_DBUS_OBJECT); + DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); dbusmenu_server_set_root(server, root_menuitem); establish_pulse_activities(dbus_interface); return root_menuitem; diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 1e117cf..bdc40cb 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -26,9 +26,9 @@ with this program. If not, see . #define __DBUS_SHARED_NAMES_H__ 1 #define INDICATOR_SOUND_DBUS_NAME "com.canonical.indicators.sound" -#define INDICATOR_SOUND_DBUS_OBJECT "/com/canonical/indicators/sound/menu" -#define INDICATOR_SOUND_SERVICE_DBUS_OBJECT "/com/canonical/indicators/sound/service" -#define INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "com.canonical.indicators.sound" +#define INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH "/com/canonical/indicators/sound/menu" +#define INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH "/com/canonical/indicators/sound/service" +#define INDICATOR_SOUND_DBUS_INTERFACE "com.canonical.indicators.sound" #define INDICATOR_SOUND_DBUS_VERSION 0 #define INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted" #define INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate" diff --git a/src/indicator-sound.c b/src/indicator-sound.c index adccfdd..6512830 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -90,10 +90,10 @@ static void create_connection_to_service (GObject *source_object, static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); -static void g_signal_cb ( GDBusProxy *proxy, - const gchar *sender_name, - const gchar *signal_name, - GVariant *parameters, +static void g_signal_cb ( GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, gpointer user_data); static void react_to_signal_sink_input_while_muted (gboolean value, @@ -242,7 +242,8 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - DbusmenuGtkMenu* menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, INDICATOR_SOUND_DBUS_OBJECT); + DbusmenuGtkMenu* menu = dbusmenu_gtkmenu_new(INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(menu); g_object_set_data (G_OBJECT (client), "indicator", io); @@ -404,9 +405,9 @@ connection_changed (IndicatorServiceManager * sm, if (interface_info == NULL) { interface_info = g_dbus_node_info_lookup_interface (node_info, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE); + INDICATOR_SOUND_DBUS_INTERFACE); if (interface_info == NULL) { - g_error("Unable to find interface '" INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "'"); + g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); } } @@ -414,8 +415,8 @@ connection_changed (IndicatorServiceManager * sm, G_DBUS_PROXY_FLAGS_NONE, interface_info, INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, NULL, create_connection_to_service, indicator ); @@ -439,8 +440,12 @@ static void create_connection_to_service (GObject *source_object, g_error_free(error); return; } - - g_signal_connect(priv->dbus_proxy, "g-signal", G_CALLBACK(g_signal_cb), self); + + g_debug ( "about to connect to g-signal "); + g_signal_connect(priv->dbus_proxy, "g-signal", + G_CALLBACK(g_signal_cb), self); + g_debug ( "after attempting to connect to g-signal "); + fetch_state (self); } @@ -688,10 +693,10 @@ reset_mute_blocking_animation() /*******************************************************************/ // DBUS Signal reactions /*******************************************************************/ -static void g_signal_cb ( GDBusProxy *proxy, - const gchar *sender_name, - const gchar *signal_name, - GVariant *parameters, +static void g_signal_cb ( GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, gpointer user_data) { IndicatorSound *self = INDICATOR_SOUND(user_data); diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index d9db2b6..9490df8 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -93,10 +93,10 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) if (interface_info == NULL) { interface_info = g_dbus_node_info_lookup_interface (node_info, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE); + INDICATOR_SOUND_DBUS_INTERFACE); if (interface_info == NULL) { - g_error("Unable to find interface '" INDICATOR_SOUND_SERVICE_DBUS_INTERFACE "'"); + g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); } } } @@ -121,7 +121,7 @@ sound_service_dbus_init (SoundServiceDbus *self) } /* register the service on it */ g_dbus_connection_register_object (priv->connection, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, interface_info, &interface_table, self, @@ -195,9 +195,9 @@ void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, GError * error = NULL; g_dbus_connection_emit_signal( priv->connection, - INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_DBUS_OBJECT, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + NULL, + INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED, v_output, &error ); @@ -219,8 +219,8 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, GError * error = NULL; g_dbus_connection_emit_signal( priv->connection, INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_DBUS_OBJECT, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE, v_output, &error ); @@ -243,8 +243,8 @@ void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, g_dbus_connection_emit_signal( priv->connection, INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_DBUS_OBJECT, - INDICATOR_SOUND_SERVICE_DBUS_INTERFACE, + INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE, v_output, &error ); -- cgit v1.2.3 From ecb6cb2056263d3c9066c1ace0e4c9d54186e142 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 10:54:13 -0600 Subject: sink available flag set --- src/indicator-sound.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 6512830..ab69b14 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -481,7 +481,6 @@ static void get_sink_availability_cb ( GObject *object, GVariant *result, *value; GError *error = NULL; - gboolean is_available; result = g_dbus_proxy_call_finish ( priv->dbus_proxy, res, @@ -494,15 +493,15 @@ static void get_sink_availability_cb ( GObject *object, } value = g_variant_get_child_value(result, 0); - is_available = g_variant_get_boolean(value); + device_available = g_variant_get_boolean(value); - if (is_available == FALSE) { + if (device_available == FALSE) { update_state(STATE_SINKS_NONE); } if(priv->volume_widget != NULL){ - GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); - gtk_widget_set_sensitive(slider_widget, is_available); + GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); + gtk_widget_set_sensitive(slider_widget, device_available); } g_variant_unref(value); -- cgit v1.2.3 From 8b9210008dbb036bd6885417a418552690642ad7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 11:18:26 -0600 Subject: change over complete for now, big refactor of indicator sound needed --- src/indicator-sound.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/indicator-sound.c b/src/indicator-sound.c index ab69b14..cdcc723 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -360,8 +360,8 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_item, - parent); - fetch_state(INDICATOR_SOUND (io)); + parent); + fetch_state(INDICATOR_SOUND (io)); return TRUE; } @@ -451,7 +451,11 @@ static void create_connection_to_service (GObject *source_object, 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)); + } g_dbus_proxy_call ( priv->dbus_proxy, "GetSinkMute", @@ -470,6 +474,7 @@ static void fetch_state (IndicatorSound* self) NULL, (GAsyncReadyCallback)get_sink_availability_cb, self); + } static void get_sink_availability_cb ( GObject *object, @@ -750,6 +755,9 @@ 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)); + } } @@ -759,7 +767,11 @@ react_to_signal_sink_availability_update(gboolean available_value, IndicatorSoun device_available = available_value; if (device_available == FALSE) { update_state(STATE_SINKS_NONE); + return; } + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + + determine_state_from_volume (volume_widget_get_current_volume(priv->volume_widget)); //g_debug("signal caught - sink availability update with value: %i", available_value); } -- cgit v1.2.3 From 259057b02fe5c6b777a438331defa2dda628dfd2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 11 Jan 2011 11:32:58 -0600 Subject: tidied the service --- src/sound-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound-service.c b/src/sound-service.c index defcb94..98f1881 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) { if (mainloop != NULL) { g_debug("Service shutdown !"); - //close_pulse_activites(); - //g_main_loop_quit(mainloop); + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3