diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-01-14 10:53:50 -0600 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-01-14 10:53:50 -0600 |
commit | 500000a82b6785e2bf7732ee87f36c6a44d2767c (patch) | |
tree | fdac470fe96ff3f2f2ee1e70fcf093a8403915db /src | |
parent | 412bffad64182bfae1e2408b89f9488f0da38481 (diff) | |
parent | 991d41fa7c9b5b51942f836ca68265513de6ef8c (diff) | |
download | ayatana-indicator-sound-500000a82b6785e2bf7732ee87f36c6a44d2767c.tar.gz ayatana-indicator-sound-500000a82b6785e2bf7732ee87f36c6a44d2767c.tar.bz2 ayatana-indicator-sound-500000a82b6785e2bf7732ee87f36c6a44d2767c.zip |
Import upstream version 0.5.6
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 59 | ||||
-rw-r--r-- | src/Makefile.in | 98 | ||||
-rw-r--r-- | src/dbus-menu-manager.c | 13 | ||||
-rw-r--r-- | src/dbus-shared-names.h | 10 | ||||
-rw-r--r-- | src/gen-sound-service.xml.c | 33 | ||||
-rw-r--r-- | src/gen-sound-service.xml.h | 1 | ||||
-rw-r--r-- | src/indicator-sound.c | 381 | ||||
-rw-r--r-- | src/metadata-widget.c | 23 | ||||
-rw-r--r-- | src/settings-manager.vala | 4 | ||||
-rw-r--r-- | src/slider-menu-item.c | 26 | ||||
-rw-r--r-- | src/sound-service-client.h | 102 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 225 | ||||
-rw-r--r-- | src/sound-service-dbus.h | 1 | ||||
-rw-r--r-- | src/sound-service-server.h | 122 | ||||
-rw-r--r-- | src/sound-service.list | 2 | ||||
-rw-r--r-- | src/title-menu-item.c | 5 | ||||
-rw-r--r-- | src/title-menu-item.vala | 2 | ||||
-rw-r--r-- | src/title-widget.c | 17 | ||||
-rw-r--r-- | src/transport-menu-item.c | 62 | ||||
-rw-r--r-- | src/transport-menu-item.vala | 21 | ||||
-rw-r--r-- | src/transport-widget.c | 24 | ||||
-rw-r--r-- | src/volume-widget.c | 25 |
22 files changed, 652 insertions, 604 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7fe7e0f..32b6928 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,10 +18,11 @@ libsoundmenu_la_SOURCES = \ title-widget.h \ volume-widget.c \ volume-widget.h \ - dbus-shared-names.h \ - sound-service-client.h + gen-sound-service.xml.h \ + gen-sound-service.xml.c \ + 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 @@ -29,30 +30,14 @@ 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 +# Sound service vala ##################### music_bridge_VALASOURCES = \ music-player-bridge.vala \ @@ -78,7 +63,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 \ @@ -96,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 \ @@ -108,33 +93,47 @@ 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 \ + 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 indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) ######################### -# Extra stuff to package +# Service xml compilation ######################### +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) \ $(music_bridge_VALASOURCES) - + ####################### # Stuff to clean Stuff ####################### 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 \ $(music_bridge_VALASOURCES:.vala=.c) - + CLEANFILES = \ $(BUILT_SOURCES) - diff --git a/src/Makefile.in b/src/Makefile.in index 667d388..67475dd 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -39,7 +39,10 @@ libexec_PROGRAMS = indicator-sound-service$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -76,7 +79,8 @@ am_libsoundmenu_la_OBJECTS = libsoundmenu_la-transport-widget.lo \ libsoundmenu_la-metadata-widget.lo \ libsoundmenu_la-indicator-sound.lo \ libsoundmenu_la-title-widget.lo \ - libsoundmenu_la-volume-widget.lo + libsoundmenu_la-volume-widget.lo \ + libsoundmenu_la-gen-sound-service.xml.lo libsoundmenu_la_OBJECTS = $(am_libsoundmenu_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -105,6 +109,7 @@ am_indicator_sound_service_OBJECTS = \ indicator_sound_service-pulse-manager.$(OBJEXT) \ indicator_sound_service-sound-service-dbus.$(OBJEXT) \ indicator_sound_service-slider-menu-item.$(OBJEXT) \ + indicator_sound_service-gen-sound-service.xml.$(OBJEXT) \ $(am__objects_1) indicator_sound_service_OBJECTS = \ $(am_indicator_sound_service_OBJECTS) @@ -245,7 +250,6 @@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ -SOUNDERVICE_LIBS = @SOUNDERVICE_LIBS@ SOUNDSERVICE_CFLAGS = @SOUNDSERVICE_CFLAGS@ SOUNDSERVICE_LIBS = @SOUNDSERVICE_LIBS@ STRIP = @STRIP@ @@ -324,15 +328,20 @@ libsoundmenu_la_SOURCES = \ title-widget.h \ volume-widget.c \ volume-widget.h \ - dbus-shared-names.h \ - sound-service-client.h + gen-sound-service.xml.h \ + gen-sound-service.xml.c \ + 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 +#################################################################### +# Sound Service +#################################################################### + ##################### -# libsoundmenu vala +# Sound service vala ##################### music_bridge_VALASOURCES = \ music-player-bridge.vala \ @@ -357,7 +366,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 \ @@ -369,7 +378,7 @@ music_bridge_APIFILES = \ ############################### -# libsoundmenu C +# Sound Service C ############################### indicator_sound_service_SOURCES = \ common-defs.h \ @@ -381,20 +390,24 @@ 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 \ + 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 indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) ######################### -# Extra stuff to package +# Service xml compilation ######################### +DBUS_SPECS = \ + sound-service.xml + EXTRA_DIST = \ + $(DBUS_SPECS) \ sound-service.xml \ - sound-service.list \ $(music_bridge_APIFILES) \ $(music_bridge_VALASOURCES) @@ -404,9 +417,9 @@ 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 \ $(music_bridge_VALASOURCES:.vala=.c) CLEANFILES = \ @@ -536,6 +549,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-dbus-menu-manager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-fetch-file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-freedesktop-interfaces.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-metadata-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris2-controller.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris2-interfaces.Po@am__quote@ @@ -551,6 +565,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-title-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-transport-menu-item.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-gen-sound-service.xml.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-indicator-sound.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-metadata-widget.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-title-widget.Plo@am__quote@ @@ -621,6 +636,14 @@ libsoundmenu_la-volume-widget.lo: volume-widget.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-volume-widget.lo `test -f 'volume-widget.c' || echo '$(srcdir)/'`volume-widget.c +libsoundmenu_la-gen-sound-service.xml.lo: gen-sound-service.xml.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-gen-sound-service.xml.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-gen-sound-service.xml.Tpo -c -o libsoundmenu_la-gen-sound-service.xml.lo `test -f 'gen-sound-service.xml.c' || echo '$(srcdir)/'`gen-sound-service.xml.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-gen-sound-service.xml.Tpo $(DEPDIR)/libsoundmenu_la-gen-sound-service.xml.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-sound-service.xml.c' object='libsoundmenu_la-gen-sound-service.xml.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-gen-sound-service.xml.lo `test -f 'gen-sound-service.xml.c' || echo '$(srcdir)/'`gen-sound-service.xml.c + indicator_sound_service-sound-service.o: sound-service.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-sound-service.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-sound-service.Tpo -c -o indicator_sound_service-sound-service.o `test -f 'sound-service.c' || echo '$(srcdir)/'`sound-service.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-sound-service.Tpo $(DEPDIR)/indicator_sound_service-sound-service.Po @@ -701,6 +724,22 @@ indicator_sound_service-slider-menu-item.obj: slider-menu-item.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-slider-menu-item.obj `if test -f 'slider-menu-item.c'; then $(CYGPATH_W) 'slider-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/slider-menu-item.c'; fi` +indicator_sound_service-gen-sound-service.xml.o: gen-sound-service.xml.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-gen-sound-service.xml.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Tpo -c -o indicator_sound_service-gen-sound-service.xml.o `test -f 'gen-sound-service.xml.c' || echo '$(srcdir)/'`gen-sound-service.xml.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Tpo $(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-sound-service.xml.c' object='indicator_sound_service-gen-sound-service.xml.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-gen-sound-service.xml.o `test -f 'gen-sound-service.xml.c' || echo '$(srcdir)/'`gen-sound-service.xml.c + +indicator_sound_service-gen-sound-service.xml.obj: gen-sound-service.xml.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-gen-sound-service.xml.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Tpo -c -o indicator_sound_service-gen-sound-service.xml.obj `if test -f 'gen-sound-service.xml.c'; then $(CYGPATH_W) 'gen-sound-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-sound-service.xml.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Tpo $(DEPDIR)/indicator_sound_service-gen-sound-service.xml.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-sound-service.xml.c' object='indicator_sound_service-gen-sound-service.xml.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-gen-sound-service.xml.obj `if test -f 'gen-sound-service.xml.c'; then $(CYGPATH_W) 'gen-sound-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-sound-service.xml.c'; fi` + indicator_sound_service-music-player-bridge.o: music-player-bridge.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-music-player-bridge.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-music-player-bridge.Tpo -c -o indicator_sound_service-music-player-bridge.o `test -f 'music-player-bridge.c' || echo '$(srcdir)/'`music-player-bridge.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-music-player-bridge.Tpo $(DEPDIR)/indicator_sound_service-music-player-bridge.Po @@ -1128,33 +1167,22 @@ 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 - $(MAINTAINER_VALAFLAGS) music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES) $(AM_V_GEN) $(VALAC) $(music_bridge_VALAFLAGS) $^ touch music_bridge_vala.stamp +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 ";" >> $@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index f92c324..92bfba5 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -21,9 +21,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <unistd.h> #include <glib/gi18n.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-bindings.h> - #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/client.h> @@ -71,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; @@ -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/dbus-shared-names.h b/src/dbus-shared-names.h index 9d1e875..bdc40cb 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -26,9 +26,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #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" +#define INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" + #endif /* __DBUS_SHARED_NAMES_H__ */ diff --git a/src/gen-sound-service.xml.c b/src/gen-sound-service.xml.c new file mode 100644 index 0000000..604c4f3 --- /dev/null +++ b/src/gen-sound-service.xml.c @@ -0,0 +1,33 @@ +const char * _sound_service = +"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" +"<node name=\"/com/canonical/indicators/sound\">\n" +" <interface name=\"com.canonical.indicators.sound\">\n" +" <method name = \"GetSinkMute\">\n" +" <annotation name=\"org.freedesktop.DBus.GLib.CSymbol\" value=\"sound_service_dbus_get_sink_mute\"/>\n" +" <arg type='b' name='mute_input' direction=\"out\"/>\n" +" </method>\n" +"\n" +" <method name = \"GetSinkAvailability\">\n" +" <annotation name=\"org.freedesktop.DBus.GLib.CSymbol\" value=\"sound_service_dbus_get_sink_availability\"/>\n" +" <arg type='b' name='availability_input' direction=\"out\"/>\n" +" </method>\n" +"\n" +"<!-- Will need to hook up another signal which monitors for volume change \n" +"Our respective UI element should listen to this and therefore will be updated with accurate setting-->\n" +"<!-- Triggered when a sink is muted but the input has been sent to that sink -->\n" +" <signal name=\"SinkInputWhileMuted\">\n" +" <arg name=\"block_value\" type=\"b\" direction=\"out\"/>\n" +" </signal>\n" +" \n" +" <signal name=\"SinkMuteUpdate\">\n" +" <arg name=\"mute_value\" type=\"b\" direction=\"out\"/>\n" +" </signal>\n" +"\n" +" <signal name=\"SinkAvailableUpdate\">\n" +" <arg name=\"available_value\" type=\"b\" direction=\"out\"/>\n" +" </signal>\n" +"\n" +" </interface>\n" +"</node>\n" +"\n" +; diff --git a/src/gen-sound-service.xml.h b/src/gen-sound-service.xml.h new file mode 100644 index 0000000..6634bc4 --- /dev/null +++ b/src/gen-sound-service.xml.h @@ -0,0 +1 @@ +extern const char * _sound_service; diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 34f5ed9..3867f27 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -7,7 +7,6 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran <conor.curran@canonical.com> Ted Gould <ted@canonical.com> - Cody Russell <cody.russell@canonical.com> 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 @@ -29,8 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-gtk/menu.h> #include <libido/idoscalemenuitem.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-bindings.h> +#include <gio/gio.h> #include "indicator-sound.h" #include "transport-widget.h" @@ -39,7 +37,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #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 +47,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,13 +81,36 @@ 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 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); + +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, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, + 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 ); /****Volume States 'members' ***/ static void update_state(const gint state); @@ -138,15 +161,15 @@ 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) { 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 +179,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 @@ -219,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); @@ -247,7 +271,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; @@ -271,7 +295,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; @@ -290,11 +314,10 @@ 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; @@ -312,7 +335,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; @@ -337,70 +360,187 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_volume_item, - parent); - fetch_mute_value_from_dbus(); - fetch_sink_availability_from_dbus(INDICATOR_SOUND (io)); + parent); + fetch_state(INDICATOR_SOUND (io)); return TRUE; } 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 (indicator); + GError *error = NULL; + if (connected == FALSE){ + update_state (STATE_SINKS_NONE); + 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 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; + } + + 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_DBUS_INTERFACE); + if (interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_SOUND_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; + } + + 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_PATH, + INDICATOR_SOUND_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( IS_INDICATOR_SOUND(self) ); + + 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(priv->dbus_proxy, "g-signal", + G_CALLBACK(g_signal_cb), self); + + fetch_state (self); +} + +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", + 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; + + 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); + device_available = g_variant_get_boolean(value); + + 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, device_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); } /* @@ -550,69 +690,39 @@ reset_mute_blocking_animation() } + /*******************************************************************/ -//DBus method handlers +// DBUS Signal reactions /*******************************************************************/ -static void -fetch_sink_availability_from_dbus(IndicatorSound* self) +static void g_signal_cb ( GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, + gpointer user_data) { - 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"); - } + IndicatorSound *self = INDICATOR_SOUND(user_data); + g_return_if_fail ( IS_INDICATOR_SOUND(self) ); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(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(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_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 ); } - - 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; + else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE) == 0){ + react_to_signal_sink_mute_update ( input, self ); } - initial_mute = *mute_input; - if (initial_mute == TRUE){ - update_state(STATE_MUTED); + else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED) == 0){ + react_to_signal_sink_input_while_muted ( input, self ); } - g_free(mute_input); - //g_debug("at the indicator start up and the MUTE returned from dbus method is %i", initial_mute); } -/*******************************************************************/ -//DBus signal catchers -/*******************************************************************/ static void -catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) +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) { @@ -627,7 +737,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_to_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self) { if (mute_value == TRUE && device_available == TRUE) { update_state(STATE_MUTED); @@ -635,25 +745,30 @@ catch_signal_sink_mute_update(DBusGProxy *proxy, gboolean mute_value, gpointer u reset_mute_blocking_animation(); } //g_debug("signal caught - sink mute update with mute value: %i", mute_value); - g_return_if_fail(IS_INDICATOR_SOUND(userdata)); - IndicatorSound* indicator = INDICATOR_SOUND(userdata); - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); if(priv->volume_widget == NULL){ return; } 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)); + } } static void -catch_signal_sink_availability_update(DBusGProxy *proxy, gboolean available_value, gpointer userdata) +react_to_signal_sink_availability_update(gboolean available_value, IndicatorSound* self) { 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); } @@ -724,7 +839,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 ) { @@ -779,7 +894,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/metadata-widget.c b/src/metadata-widget.c index 191e134..09365d5 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,38 +400,37 @@ metadata_widget_button_press_event (GtkWidget *menuitem, // TODO: Manage empty/mangled music details <unknown artist> 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)); - 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)); } 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/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); } diff --git a/src/sound-service-client.h b/src/sound-service-client.h deleted file mode 100644 index 5d95f44..0000000 --- a/src/sound-service-client.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Generated by dbus-binding-tool; do not edit! */ - -#include <glib.h> -#include <dbus/dbus-glib.h> - -G_BEGIN_DECLS - -#ifndef _DBUS_GLIB_ASYNC_DATA_FREE -#define _DBUS_GLIB_ASYNC_DATA_FREE -static -#ifdef G_HAVE_INLINE -inline -#endif -void -_dbus_glib_async_data_free (gpointer stuff) -{ - g_slice_free (DBusGAsyncData, stuff); -} -#endif - -#ifndef DBUS_GLIB_CLIENT_WRAPPERS_com_canonical_indicators_sound -#define DBUS_GLIB_CLIENT_WRAPPERS_com_canonical_indicators_sound - -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -com_canonical_indicators_sound_get_sink_mute (DBusGProxy *proxy, gboolean* OUT_mute_input, GError **error) - -{ - return dbus_g_proxy_call (proxy, "GetSinkMute", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_mute_input, G_TYPE_INVALID); -} - -typedef void (*com_canonical_indicators_sound_get_sink_mute_reply) (DBusGProxy *proxy, gboolean OUT_mute_input, GError *error, gpointer userdata); - -static void -com_canonical_indicators_sound_get_sink_mute_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - gboolean OUT_mute_input; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_mute_input, G_TYPE_INVALID); - (*(com_canonical_indicators_sound_get_sink_mute_reply)data->cb) (proxy, OUT_mute_input, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -com_canonical_indicators_sound_get_sink_mute_async (DBusGProxy *proxy, com_canonical_indicators_sound_get_sink_mute_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "GetSinkMute", com_canonical_indicators_sound_get_sink_mute_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); -} -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -com_canonical_indicators_sound_get_sink_availability (DBusGProxy *proxy, gboolean* OUT_availability_input, GError **error) - -{ - return dbus_g_proxy_call (proxy, "GetSinkAvailability", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_availability_input, G_TYPE_INVALID); -} - -typedef void (*com_canonical_indicators_sound_get_sink_availability_reply) (DBusGProxy *proxy, gboolean OUT_availability_input, GError *error, gpointer userdata); - -static void -com_canonical_indicators_sound_get_sink_availability_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - gboolean OUT_availability_input; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_availability_input, G_TYPE_INVALID); - (*(com_canonical_indicators_sound_get_sink_availability_reply)data->cb) (proxy, OUT_availability_input, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -com_canonical_indicators_sound_get_sink_availability_async (DBusGProxy *proxy, com_canonical_indicators_sound_get_sink_availability_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "GetSinkAvailability", com_canonical_indicators_sound_get_sink_availability_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID); -} -#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_com_canonical_indicators_sound */ - -G_END_DECLS diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 0760247..6057a29 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -3,7 +3,7 @@ * * Authors: * Conor Curran <conor.curran@canonical.com> - * Cody Russell <crussell@canonical.com> + * Ted Gould <ted.gould@canonical.com> * * 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,36 +22,41 @@ #include "config.h" #endif -#include <dbus/dbus-glib.h> +#include <gio/gio.h> +#include <libindicator/indicator-service.h> +#include "gen-sound-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); + +static GDBusInterfaceVTable interface_table = { + method_call: bus_method_call, + get_property: NULL, /* No properties */ + set_property: NULL /* No properties */ +}; -#include "sound-service-server.h" typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate; struct _SoundServiceDbusPrivate { - DBusGConnection *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 guint signals[LAST_SIGNAL] = { 0 }; +static GDBusNodeInfo * node_info = NULL; +static GDBusInterfaceInfo * interface_info = NULL; #define SOUND_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbusPrivate)) @@ -74,31 +79,26 @@ 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(_sound_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_DBUS_INTERFACE); + + if (interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); + } + } } static void @@ -112,7 +112,7 @@ 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 (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); @@ -120,12 +120,20 @@ sound_service_dbus_init (SoundServiceDbus *self) 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_PATH, + interface_info, + &interface_table, + self, + 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 +148,111 @@ 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) +{ + 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 ( "(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 ( "(b)", 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("(b)", block_value); + + GError * error = NULL; + + g_dbus_connection_emit_signal( priv->connection, + NULL, + INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, + INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED, + 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; - g_signal_emit(obj, - signals[SINK_MUTE_UPDATE], - 0, - priv->mute); + GVariant* v_output = g_variant_new("(b)", sink_mute); + GError * error = NULL; + g_dbus_connection_emit_signal( priv->connection, + NULL, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, + INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE, + 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; - - g_signal_emit(obj, - signals[SINK_AVAILABLE_UPDATE], - 0, - priv->sink_availability); + + GVariant* v_output = g_variant_new("(b)", priv->sink_availability); + GError * error = NULL; + + g_dbus_connection_emit_signal( priv->connection, + NULL, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, + INDICATOR_SOUND_DBUS_INTERFACE, + INDICATOR_SOUND_SIGNAL_SINK_AVAILABLE_UPDATE, + 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/sound-service-server.h b/src/sound-service-server.h deleted file mode 100644 index 0e4481e..0000000 --- a/src/sound-service-server.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Generated by dbus-binding-tool; do not edit! */ - - -#ifndef __dbus_glib_marshal__sound_service_server_MARSHAL_H__ -#define __dbus_glib_marshal__sound_service_server_MARSHAL_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#ifdef G_ENABLE_DEBUG -#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) -#define g_marshal_value_peek_char(v) g_value_get_char (v) -#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) -#define g_marshal_value_peek_int(v) g_value_get_int (v) -#define g_marshal_value_peek_uint(v) g_value_get_uint (v) -#define g_marshal_value_peek_long(v) g_value_get_long (v) -#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) -#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) -#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) -#define g_marshal_value_peek_enum(v) g_value_get_enum (v) -#define g_marshal_value_peek_flags(v) g_value_get_flags (v) -#define g_marshal_value_peek_float(v) g_value_get_float (v) -#define g_marshal_value_peek_double(v) g_value_get_double (v) -#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) -#define g_marshal_value_peek_param(v) g_value_get_param (v) -#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) -#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) -#define g_marshal_value_peek_object(v) g_value_get_object (v) -#define g_marshal_value_peek_variant(v) g_value_get_variant (v) -#else /* !G_ENABLE_DEBUG */ -/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. - * Do not access GValues directly in your code. Instead, use the - * g_value_get_*() functions - */ -#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int -#define g_marshal_value_peek_char(v) (v)->data[0].v_int -#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint -#define g_marshal_value_peek_int(v) (v)->data[0].v_int -#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint -#define g_marshal_value_peek_long(v) (v)->data[0].v_long -#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 -#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 -#define g_marshal_value_peek_enum(v) (v)->data[0].v_long -#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_float(v) (v)->data[0].v_float -#define g_marshal_value_peek_double(v) (v)->data[0].v_double -#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer -#endif /* !G_ENABLE_DEBUG */ - - -/* BOOLEAN:POINTER,POINTER */ -extern void dbus_glib_marshal__sound_service_server_BOOLEAN__POINTER_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -void -dbus_glib_marshal__sound_service_server_BOOLEAN__POINTER_POINTER (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) -{ - typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer data2); - register GMarshalFunc_BOOLEAN__POINTER_POINTER callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - gboolean v_return; - - g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 3); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback); - - v_return = callback (data1, - g_marshal_value_peek_pointer (param_values + 1), - g_marshal_value_peek_pointer (param_values + 2), - data2); - - g_value_set_boolean (return_value, v_return); -} - -G_END_DECLS - -#endif /* __dbus_glib_marshal__sound_service_server_MARSHAL_H__ */ - -#include <dbus/dbus-glib.h> -static const DBusGMethodInfo dbus_glib__sound_service_server_methods[] = { - { (GCallback) sound_service_dbus_get_sink_mute, dbus_glib_marshal__sound_service_server_BOOLEAN__POINTER_POINTER, 0 }, - { (GCallback) sound_service_dbus_get_sink_availability, dbus_glib_marshal__sound_service_server_BOOLEAN__POINTER_POINTER, 65 }, -}; - -const DBusGObjectInfo dbus_glib__sound_service_server_object_info = { 1, - dbus_glib__sound_service_server_methods, - 2, -"com.canonical.indicators.sound\0GetSinkMute\0S\0mute_input\0O\0F\0N\0b\0\0com.canonical.indicators.sound\0GetSinkAvailability\0S\0availability_input\0O\0F\0N\0b\0\0\0", -"com.canonical.indicators.sound\0SinkInputWhileMuted\0com.canonical.indicators.sound\0SinkMuteUpdate\0com.canonical.indicators.sound\0SinkAvailableUpdate\0\0", -"\0" -}; - diff --git a/src/sound-service.list b/src/sound-service.list deleted file mode 100644 index ee376e9..0000000 --- a/src/sound-service.list +++ /dev/null @@ -1,2 +0,0 @@ -VOID:INT,BOOLEAN - diff --git a/src/title-menu-item.c b/src/title-menu-item.c index d8130a0..b099abe 100644 --- a/src/title-menu-item.c +++ b/src/title-menu-item.c @@ -131,7 +131,7 @@ TitleMenuitem* title_menuitem_new (PlayerController* parent); TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent); GAppInfo* player_controller_get_app_info (PlayerController* self); const gchar* player_controller_get_icon_name (PlayerController* self); -static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GValue* input_value, guint timestamp); +static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp); PlayerController* player_item_get_owner (PlayerItem* self); GType mpris2_controller_get_type (void) G_GNUC_CONST; GType player_controller_state_get_type (void) G_GNUC_CONST; @@ -163,11 +163,12 @@ TitleMenuitem* title_menuitem_new (PlayerController* parent) { } -static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GValue* input_value, guint timestamp) { +static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp) { TitleMenuitem * self; PlayerController* _tmp0_ = NULL; self = (TitleMenuitem*) base; g_return_if_fail (name != NULL); + g_return_if_fail (input_value != NULL); _tmp0_ = player_item_get_owner ((PlayerItem*) self); if (_tmp0_->current_state == PLAYER_CONTROLLER_STATE_OFFLINE) { PlayerController* _tmp1_ = NULL; 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/title-widget.c b/src/title-widget.c index 08b4b81..675c59f 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, @@ -138,24 +138,23 @@ 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; } 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); 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.c b/src/transport-menu-item.c index 9abef7b..0b43e70 100644 --- a/src/transport-menu-item.c +++ b/src/transport-menu-item.c @@ -29,7 +29,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <common-defs.h> #include <stdlib.h> #include <string.h> -#include <gio/gio.h> #include <gee.h> @@ -68,6 +67,7 @@ typedef struct _TransportMenuitemPrivate TransportMenuitemPrivate; typedef struct _PlayerController PlayerController; typedef struct _PlayerControllerClass PlayerControllerClass; +#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) #define _g_free0(var) (var = (g_free (var), NULL)) typedef struct _PlayerControllerPrivate PlayerControllerPrivate; @@ -138,9 +138,8 @@ GType player_controller_get_type (void) G_GNUC_CONST; TransportMenuitem* transport_menuitem_new (PlayerController* parent); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent); void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMenuitemstate update); -static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GValue* input_value, guint timestamp); +static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp); PlayerController* player_item_get_owner (PlayerItem* self); -GAppInfo* player_controller_get_app_info (PlayerController* self); GType mpris2_controller_get_type (void) G_GNUC_CONST; void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command); GeeHashSet* transport_menuitem_attributes_format (void); @@ -192,30 +191,45 @@ void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMen } -static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GValue* input_value, guint timestamp) { +static gpointer _g_variant_ref0 (gpointer self) { + return self ? g_variant_ref (self) : NULL; +} + + +static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp) { TransportMenuitem * self; - gint _tmp0_; - gint input; - gchar* _tmp1_ = NULL; - gchar* _tmp2_; - PlayerController* _tmp3_ = NULL; - GAppInfo* _tmp4_ = NULL; - const gchar* _tmp5_ = NULL; - PlayerController* _tmp6_ = NULL; + GVariant* _tmp0_; + GVariant* v; + gboolean _tmp1_; + gint32 _tmp4_; + gint32 input; + gchar* _tmp5_ = NULL; + gchar* _tmp6_; + PlayerController* _tmp7_ = NULL; self = (TransportMenuitem*) base; g_return_if_fail (name != NULL); - _tmp0_ = g_value_get_int (input_value); - input = _tmp0_; - _tmp1_ = g_strdup_printf ("%i", input); - _tmp2_ = _tmp1_; - g_debug ("transport-menu-item.vala:53: handle_event with value %s", _tmp2_); - _g_free0 (_tmp2_); - _tmp3_ = player_item_get_owner ((PlayerItem*) self); - _tmp4_ = player_controller_get_app_info (_tmp3_); - _tmp5_ = g_app_info_get_name (_tmp4_); - g_debug ("transport-menu-item.vala:54: transport owner name = %s", _tmp5_); - _tmp6_ = player_item_get_owner ((PlayerItem*) self); - mpris2_controller_transport_update (_tmp6_->mpris_bridge, (TransportMenuitemaction) input); + g_return_if_fail (input_value != NULL); + _tmp0_ = _g_variant_ref0 (input_value); + v = _tmp0_; + _tmp1_ = g_variant_is_of_type (input_value, G_VARIANT_TYPE_VARIANT); + if (_tmp1_) { + GVariant* _tmp2_ = NULL; + GVariant* _tmp3_; + _tmp2_ = g_variant_get_variant (input_value); + _tmp3_ = _tmp2_; + _g_variant_unref0 (v); + v = _tmp3_; + } + _tmp4_ = g_variant_get_int32 (v); + input = _tmp4_; + _tmp5_ = g_strdup_printf ("%i", input); + _tmp6_ = _tmp5_; + g_debug ("transport-menu-item.vala:62: transport menu item -> handle_event with " \ +"value %s", _tmp6_); + _g_free0 (_tmp6_); + _tmp7_ = player_item_get_owner ((PlayerItem*) self); + mpris2_controller_transport_update (_tmp7_->mpris_bridge, (TransportMenuitemaction) input); + _g_variant_unref0 (v); } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 0e4e6ee..e93f0bb 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,11 +47,20 @@ 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(); - 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); } diff --git a/src/transport-widget.c b/src/transport-widget.c index d7f4b75..a276a31 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, @@ -761,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; @@ -1700,7 +1698,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 +1706,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..38dc9bb 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -28,6 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "volume-widget.h" #include "common-defs.h" #include <libido/idoscalemenuitem.h> +#include "indicator-sound.h" typedef struct _VolumeWidgetPrivate VolumeWidgetPrivate; @@ -48,7 +49,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 +123,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,10 +134,10 @@ 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); + determine_state_from_volume(update); } } } @@ -150,8 +151,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 +196,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 +245,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; } |