aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-01-27 16:13:08 -0500
committerKen VanDine <ken.vandine@canonical.com>2011-01-27 16:13:08 -0500
commit5338c77428955cf6701b5fa9cad84e135f6522b2 (patch)
tree45b8dd1f84a772c6a031a760abc7592236346779 /src
parent603ecf78d1f2e897ac60ecf585569c8758fe5d1e (diff)
parent759793a2dda77abd227921e119bb329271c36a55 (diff)
downloadayatana-indicator-sound-5338c77428955cf6701b5fa9cad84e135f6522b2.tar.gz
ayatana-indicator-sound-5338c77428955cf6701b5fa9cad84e135f6522b2.tar.bz2
ayatana-indicator-sound-5338c77428955cf6701b5fa9cad84e135f6522b2.zip
releasing version 0.5.7-0ubuntu1
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/Makefile.in79
-rw-r--r--src/common-defs.h25
-rw-r--r--src/dbus-menu-manager.c234
-rw-r--r--src/dbus-menu-manager.h34
-rw-r--r--src/dbus-shared-names.h7
-rw-r--r--src/fetch-file.c56
-rw-r--r--src/freedesktop-interfaces.c37
-rw-r--r--src/gen-sound-service.xml.c31
-rw-r--r--src/indicator-sound.c640
-rw-r--r--src/indicator-sound.h1
-rw-r--r--src/metadata-menu-item.c5
-rw-r--r--src/metadata-widget.c33
-rw-r--r--src/mpris2-controller.c491
-rw-r--r--src/mpris2-controller.vala76
-rw-r--r--src/mpris2-interfaces.c198
-rw-r--r--src/mpris2-interfaces.vala8
-rw-r--r--src/mpris2-watcher.c58
-rw-r--r--src/music-player-bridge.c45
-rw-r--r--src/music-player-bridge.h11
-rw-r--r--src/music-player-bridge.vala4
-rw-r--r--src/mute-menu-item.c144
-rw-r--r--src/mute-menu-item.h59
-rw-r--r--src/player-controller.c160
-rw-r--r--src/player-controller.vala14
-rw-r--r--src/player-item.c122
-rw-r--r--src/playlists-menu-item.c4
-rw-r--r--src/pulse-manager.c56
-rw-r--r--src/pulse-manager.h5
-rw-r--r--src/settings-manager.c56
-rw-r--r--src/slider-menu-item.c51
-rw-r--r--src/slider-menu-item.h8
-rw-r--r--src/sound-service-dbus.c336
-rw-r--r--src/sound-service-dbus.h16
-rw-r--r--src/sound-service.c8
-rw-r--r--src/sound-service.h3
-rw-r--r--src/sound-service.xml31
-rw-r--r--src/sound-state-manager.c387
-rw-r--r--src/sound-state-manager.h66
-rw-r--r--src/title-menu-item.c2
-rw-r--r--src/transport-menu-item.c8
-rw-r--r--src/transport-menu-item.vala3
-rw-r--r--src/transport-widget.c6
-rw-r--r--src/volume-widget.c3
44 files changed, 1869 insertions, 1762 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 32b6928..ed64aeb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,11 +9,13 @@ soundmenulib_LTLIBRARIES = libsoundmenu.la
libsoundmenu_la_SOURCES = \
common-defs.h \
indicator-sound.h \
+ indicator-sound.c \
+ sound-state-manager.c \
+ sound-state-manager.h \
transport-widget.c \
transport-widget.h \
metadata-widget.c \
metadata-widget.h \
- indicator-sound.c \
title-widget.c \
title-widget.h \
volume-widget.c \
@@ -87,15 +89,15 @@ indicator_sound_service_SOURCES = \
common-defs.h \
sound-service.h \
sound-service.c \
- dbus-menu-manager.c \
- dbus-menu-manager.h \
pulse-manager.h \
pulse-manager.c \
sound-service-dbus.h \
sound-service-dbus.c \
slider-menu-item.h \
slider-menu-item.c \
- gen-sound-service.xml.h \
+ mute-menu-item.h \
+ mute-menu-item.c \
+ gen-sound-service.xml.h \
gen-sound-service.xml.c \
$(music_bridge_VALASOURCES:.vala=.c)
diff --git a/src/Makefile.in b/src/Makefile.in
index 67475dd..b470fcf 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -39,10 +39,7 @@ 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)/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__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -75,9 +72,10 @@ am__installdirs = "$(DESTDIR)$(soundmenulibdir)" \
LTLIBRARIES = $(soundmenulib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libsoundmenu_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_libsoundmenu_la_OBJECTS = libsoundmenu_la-transport-widget.lo \
+am_libsoundmenu_la_OBJECTS = libsoundmenu_la-indicator-sound.lo \
+ libsoundmenu_la-sound-state-manager.lo \
+ 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-gen-sound-service.xml.lo
@@ -105,10 +103,10 @@ am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \
indicator_sound_service-fetch-file.$(OBJEXT)
am_indicator_sound_service_OBJECTS = \
indicator_sound_service-sound-service.$(OBJEXT) \
- indicator_sound_service-dbus-menu-manager.$(OBJEXT) \
indicator_sound_service-pulse-manager.$(OBJEXT) \
indicator_sound_service-sound-service-dbus.$(OBJEXT) \
indicator_sound_service-slider-menu-item.$(OBJEXT) \
+ indicator_sound_service-mute-menu-item.$(OBJEXT) \
indicator_sound_service-gen-sound-service.xml.$(OBJEXT) \
$(am__objects_1)
indicator_sound_service_OBJECTS = \
@@ -319,11 +317,13 @@ soundmenulib_LTLIBRARIES = libsoundmenu.la
libsoundmenu_la_SOURCES = \
common-defs.h \
indicator-sound.h \
+ indicator-sound.c \
+ sound-state-manager.c \
+ sound-state-manager.h \
transport-widget.c \
transport-widget.h \
metadata-widget.c \
metadata-widget.h \
- indicator-sound.c \
title-widget.c \
title-widget.h \
volume-widget.c \
@@ -384,14 +384,14 @@ indicator_sound_service_SOURCES = \
common-defs.h \
sound-service.h \
sound-service.c \
- dbus-menu-manager.c \
- dbus-menu-manager.h \
pulse-manager.h \
pulse-manager.c \
sound-service-dbus.h \
sound-service-dbus.c \
slider-menu-item.h \
slider-menu-item.c \
+ mute-menu-item.h \
+ mute-menu-item.c \
gen-sound-service.xml.h \
gen-sound-service.xml.c \
$(music_bridge_VALASOURCES:.vala=.c)
@@ -546,7 +546,6 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@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@
@@ -555,6 +554,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris2-interfaces.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris2-watcher.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-music-player-bridge.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mute-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-player-controller.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-player-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-playlists-menu-item.Po@am__quote@
@@ -568,6 +568,7 @@ distclean-compile:
@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-sound-state-manager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-title-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-transport-widget.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-volume-widget.Plo@am__quote@
@@ -596,6 +597,22 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+libsoundmenu_la-indicator-sound.lo: indicator-sound.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-indicator-sound.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-indicator-sound.Tpo -c -o libsoundmenu_la-indicator-sound.lo `test -f 'indicator-sound.c' || echo '$(srcdir)/'`indicator-sound.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-indicator-sound.Tpo $(DEPDIR)/libsoundmenu_la-indicator-sound.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='indicator-sound.c' object='libsoundmenu_la-indicator-sound.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-indicator-sound.lo `test -f 'indicator-sound.c' || echo '$(srcdir)/'`indicator-sound.c
+
+libsoundmenu_la-sound-state-manager.lo: sound-state-manager.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-sound-state-manager.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-sound-state-manager.Tpo -c -o libsoundmenu_la-sound-state-manager.lo `test -f 'sound-state-manager.c' || echo '$(srcdir)/'`sound-state-manager.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-sound-state-manager.Tpo $(DEPDIR)/libsoundmenu_la-sound-state-manager.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sound-state-manager.c' object='libsoundmenu_la-sound-state-manager.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-sound-state-manager.lo `test -f 'sound-state-manager.c' || echo '$(srcdir)/'`sound-state-manager.c
+
libsoundmenu_la-transport-widget.lo: transport-widget.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-transport-widget.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-transport-widget.Tpo -c -o libsoundmenu_la-transport-widget.lo `test -f 'transport-widget.c' || echo '$(srcdir)/'`transport-widget.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-transport-widget.Tpo $(DEPDIR)/libsoundmenu_la-transport-widget.Plo
@@ -612,14 +629,6 @@ libsoundmenu_la-metadata-widget.lo: metadata-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-metadata-widget.lo `test -f 'metadata-widget.c' || echo '$(srcdir)/'`metadata-widget.c
-libsoundmenu_la-indicator-sound.lo: indicator-sound.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-indicator-sound.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-indicator-sound.Tpo -c -o libsoundmenu_la-indicator-sound.lo `test -f 'indicator-sound.c' || echo '$(srcdir)/'`indicator-sound.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-indicator-sound.Tpo $(DEPDIR)/libsoundmenu_la-indicator-sound.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='indicator-sound.c' object='libsoundmenu_la-indicator-sound.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-indicator-sound.lo `test -f 'indicator-sound.c' || echo '$(srcdir)/'`indicator-sound.c
-
libsoundmenu_la-title-widget.lo: title-widget.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-title-widget.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-title-widget.Tpo -c -o libsoundmenu_la-title-widget.lo `test -f 'title-widget.c' || echo '$(srcdir)/'`title-widget.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-title-widget.Tpo $(DEPDIR)/libsoundmenu_la-title-widget.Plo
@@ -660,22 +669,6 @@ indicator_sound_service-sound-service.obj: sound-service.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-sound-service.obj `if test -f 'sound-service.c'; then $(CYGPATH_W) 'sound-service.c'; else $(CYGPATH_W) '$(srcdir)/sound-service.c'; fi`
-indicator_sound_service-dbus-menu-manager.o: dbus-menu-manager.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-dbus-menu-manager.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-dbus-menu-manager.Tpo -c -o indicator_sound_service-dbus-menu-manager.o `test -f 'dbus-menu-manager.c' || echo '$(srcdir)/'`dbus-menu-manager.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-dbus-menu-manager.Tpo $(DEPDIR)/indicator_sound_service-dbus-menu-manager.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dbus-menu-manager.c' object='indicator_sound_service-dbus-menu-manager.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-dbus-menu-manager.o `test -f 'dbus-menu-manager.c' || echo '$(srcdir)/'`dbus-menu-manager.c
-
-indicator_sound_service-dbus-menu-manager.obj: dbus-menu-manager.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-dbus-menu-manager.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-dbus-menu-manager.Tpo -c -o indicator_sound_service-dbus-menu-manager.obj `if test -f 'dbus-menu-manager.c'; then $(CYGPATH_W) 'dbus-menu-manager.c'; else $(CYGPATH_W) '$(srcdir)/dbus-menu-manager.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-dbus-menu-manager.Tpo $(DEPDIR)/indicator_sound_service-dbus-menu-manager.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dbus-menu-manager.c' object='indicator_sound_service-dbus-menu-manager.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-dbus-menu-manager.obj `if test -f 'dbus-menu-manager.c'; then $(CYGPATH_W) 'dbus-menu-manager.c'; else $(CYGPATH_W) '$(srcdir)/dbus-menu-manager.c'; fi`
-
indicator_sound_service-pulse-manager.o: pulse-manager.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-pulse-manager.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-pulse-manager.Tpo -c -o indicator_sound_service-pulse-manager.o `test -f 'pulse-manager.c' || echo '$(srcdir)/'`pulse-manager.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-pulse-manager.Tpo $(DEPDIR)/indicator_sound_service-pulse-manager.Po
@@ -724,6 +717,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-mute-menu-item.o: mute-menu-item.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-mute-menu-item.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-mute-menu-item.Tpo -c -o indicator_sound_service-mute-menu-item.o `test -f 'mute-menu-item.c' || echo '$(srcdir)/'`mute-menu-item.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mute-menu-item.Tpo $(DEPDIR)/indicator_sound_service-mute-menu-item.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mute-menu-item.c' object='indicator_sound_service-mute-menu-item.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-mute-menu-item.o `test -f 'mute-menu-item.c' || echo '$(srcdir)/'`mute-menu-item.c
+
+indicator_sound_service-mute-menu-item.obj: mute-menu-item.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-mute-menu-item.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-mute-menu-item.Tpo -c -o indicator_sound_service-mute-menu-item.obj `if test -f 'mute-menu-item.c'; then $(CYGPATH_W) 'mute-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/mute-menu-item.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mute-menu-item.Tpo $(DEPDIR)/indicator_sound_service-mute-menu-item.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mute-menu-item.c' object='indicator_sound_service-mute-menu-item.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-mute-menu-item.obj `if test -f 'mute-menu-item.c'; then $(CYGPATH_W) 'mute-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/mute-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
diff --git a/src/common-defs.h b/src/common-defs.h
index 8ec69e8..5458dc5 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -16,13 +16,21 @@ 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 <http://www.gnu.org/licenses/>.
*/
+#ifndef __COMMON_DEFS_H__
+#define __COMMON_DEFS_H__
-/* constants used for signals on the dbus. This file is shared between client and server implementation */
-#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
-#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
-#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
-#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate"
+typedef enum {
+ MUTED,
+ ZERO_LEVEL,
+ LOW_LEVEL,
+ MEDIUM_LEVEL,
+ HIGH_LEVEL,
+ BLOCKED,
+ UNAVAILABLE,
+ AVAILABLE
+}SoundState;
+
#define DBUSMENU_PROPERTY_EMPTY -1
@@ -30,6 +38,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type"
#define DBUSMENU_VOLUME_MENUITEM_LEVEL "x-canonical-ido-volume-level"
+#define DBUSMENU_MUTE_MENUITEM_TYPE "x-canonical-sound-menu-mute-type"
+#define DBUSMENU_MUTE_MENUITEM_VALUE "x-canonical-sound-menu-mute-value"
+
#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"
#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
@@ -51,4 +62,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_PLAYLISTS_MENUITEM_TYPE "x-canonical-sound-menu-player-playlists-type"
#define DBUSMENU_PLAYLISTS_MENUITEM_TITLE "x-canonical-sound-menu-player-playlists-title"
-#define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists" \ No newline at end of file
+#define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists"
+
+#endif
diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c
deleted file mode 100644
index 92bfba5..0000000
--- a/src/dbus-menu-manager.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
-Copyright 2010 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@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
-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 <http://www.gnu.org/licenses/>.
-*/
-
-#include <unistd.h>
-#include <glib/gi18n.h>
-
-#include <libdbusmenu-glib/server.h>
-#include <libdbusmenu-glib/client.h>
-
-#include "dbus-menu-manager.h"
-#include "sound-service-dbus.h"
-#include "pulse-manager.h"
-#include "slider-menu-item.h"
-#include "common-defs.h"
-
-#include "dbus-shared-names.h"
-
-// DBUS items
-static DbusmenuMenuitem *root_menuitem = NULL;
-static DbusmenuMenuitem *mute_all_menuitem = NULL;
-static SliderMenuItem *volume_slider_menuitem = NULL;
-static SoundServiceDbus *dbus_interface = NULL;
-
-// PULSEAUDIO
-static gboolean b_sink_available = FALSE;
-static gboolean b_all_muted = FALSE;
-static gboolean b_pulse_ready = FALSE;
-static gboolean b_startup = TRUE;
-static gdouble volume_percent = 0.0;
-
-static void set_global_mute_from_ui();
-static gboolean idle_routine (gpointer data);
-static void rebuild_sound_menu(DbusmenuMenuitem *root,
- SoundServiceDbus *service);
-static void refresh_menu();
-
-
-/*-------------------------------------------------------------------------*/
-// Public Methods
-/*-------------------------------------------------------------------------*/
-
-/**
-setup:
-**/
-DbusmenuMenuitem* dbus_menu_manager_setup()
-{
- root_menuitem = dbusmenu_menuitem_new();
- g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem));
-
- g_idle_add(idle_routine, root_menuitem);
-
- dbus_interface = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
-
- 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;
-}
-
-void dbus_menu_manager_update_volume(gdouble volume)
-{
- GVariant* new_volume = g_variant_new_double(volume);
- dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_VOLUME_MENUITEM_LEVEL,
- new_volume);
-}
-
-
-/**
-update_pa_state:
-**/
-void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble percent)
-{
- b_sink_available = sink_available;
- b_all_muted = sink_muted;
- b_pulse_ready = pa_state;
- volume_percent = percent;
- g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent);
- // Only rebuild the menu on start up...
- if (b_startup == TRUE) {
- rebuild_sound_menu(root_menuitem, dbus_interface);
- b_startup = FALSE;
- } else {
- refresh_menu();
- }
- // Emit the signals after the menus are setup/torn down
- // preserve ordering !
- sound_service_dbus_update_sink_availability(dbus_interface, sink_available);
- dbus_menu_manager_update_volume(percent);
- sound_service_dbus_update_sink_mute(dbus_interface, sink_muted);
- dbus_menu_manager_update_mute_ui(b_all_muted);
-}
-
-/**
-update_mute_ui:
-'public' method allowing the pa manager to update the mute menu item.
-**/
-void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value)
-{
- b_all_muted = incoming_mute_value;
- dbusmenu_menuitem_property_set(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- b_all_muted == FALSE ? _("Mute") : _("Unmute"));
-}
-
-
-/*-------------------------------------------------------------------------*/
-// Private Methods
-/*-------------------------------------------------------------------------*/
-static void refresh_menu()
-{
- g_debug("in the refresh menu method");
- if (b_sink_available == FALSE || b_pulse_ready == FALSE) {
-
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED,
- FALSE);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- FALSE);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- FALSE);
-
- } else if (b_sink_available == TRUE && b_pulse_ready == TRUE) {
-
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED,
- TRUE);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- TRUE);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_ENABLED,
- TRUE);
- }
-}
-
-
-/**
-idle_routine:
-Something for glip mainloop to do when idle
-**/
-static gboolean idle_routine (gpointer data)
-{
- return FALSE;
-}
-
-
-
-/**
-show_sound_settings_dialog:
-Bring up the gnome volume preferences dialog
-**/
-static void show_sound_settings_dialog (DbusmenuMenuitem *mi, gpointer user_data)
-{
- GError * error = NULL;
- if (!g_spawn_command_line_async("gnome-volume-control --page=applications", &error) &&
- !g_spawn_command_line_async("xfce4-mixer", &error))
- {
- g_warning("Unable to show dialog: %s", error->message);
- g_error_free(error);
- }
-}
-
-/**
-rebuild_sound_menu:
-Build the DBus menu items, mute/unmute, slider, separator and sound preferences 'link'
-**/
-static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service)
-{
- // Mute button
- mute_all_menuitem = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, b_all_muted == FALSE ? _("Mute") : _("Unmute"));
- g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL);
- dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available);
-
- // Slider
- volume_slider_menuitem = slider_menu_item_new(b_sink_available, volume_percent);
- dbusmenu_menuitem_child_append(root, mute_all_menuitem);
- dbusmenu_menuitem_child_append(root, DBUSMENU_MENUITEM(volume_slider_menuitem));
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED,
- b_sink_available && !b_all_muted);
- g_debug("!!!!!!**in the rebuild sound menu - slider active = %i", b_sink_available && !b_all_muted);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_VISIBLE,
- b_sink_available);
- // Separator
- DbusmenuMenuitem *separator = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_append(root, separator);
-
- // Sound preferences dialog
- DbusmenuMenuitem *settings_mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences..."));
-
- //_("Sound Preferences..."));
- dbusmenu_menuitem_child_append(root, settings_mi);
- g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(show_sound_settings_dialog), NULL);
-}
-
-/**
-set_global_mute_from_ui:
-Callback for the dbusmenuitem button
-**/
-static void set_global_mute_from_ui()
-{
- b_all_muted = !b_all_muted;
- toggle_global_mute(b_all_muted);
- dbusmenu_menuitem_property_set(mute_all_menuitem,
- DBUSMENU_MENUITEM_PROP_LABEL,
- b_all_muted == FALSE ? _("Mute") : _("Unmute"));
-}
-
-
diff --git a/src/dbus-menu-manager.h b/src/dbus-menu-manager.h
deleted file mode 100644
index ec2b2e2..0000000
--- a/src/dbus-menu-manager.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __INCLUDE_DBUS_MENU_MANAGER_H__
-#define __INCLUDE_DBUS_MENU_MANAGER_H__
-
-#include <libdbusmenu-glib/menuitem.h>
-
-/*
-This handles the management of the dbusmeneu items.
-Copyright 2010 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@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
-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 <http://www.gnu.org/licenses/>.
-*/
-
-DbusmenuMenuitem* dbus_menu_manager_setup();
-void dbus_menu_manager_teardown();
-void dbus_menu_manager_update_volume(gdouble volume);
-void dbus_menu_manager_update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble current_vol);
-// TODO update pa_state should incorporate the method below !
-void dbus_menu_manager_update_mute_ui(gboolean incoming_mute_value);
-
-#endif
-
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index bdc40cb..346a031 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -23,16 +23,15 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef __DBUS_SHARED_NAMES_H__
-#define __DBUS_SHARED_NAMES_H__ 1
+#define __DBUS_SHARED_NAMES_H__
#define INDICATOR_SOUND_DBUS_NAME "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"
+
+#define INDICATOR_SOUND_SIGNAL_STATE_UPDATE "SoundStateUpdate"
#endif /* __DBUS_SHARED_NAMES_H__ */
diff --git a/src/fetch-file.c b/src/fetch-file.c
index 61a0c02..3a7fc9b 100644
--- a/src/fetch-file.c
+++ b/src/fetch-file.c
@@ -1,4 +1,4 @@
-/* fetch-file.c generated by valac 0.11.3, the Vala compiler
+/* fetch-file.c generated by valac 0.11.5, the Vala compiler
* generated from fetch-file.vala, do not modify */
/*
@@ -86,19 +86,17 @@ struct _FetchFileReadSomethingAsyncData {
FetchFile* self;
gssize size;
guint8* _tmp0_;
+ guint8* buffer;
gint buffer_length1;
gint _buffer_size_;
- guint8* _tmp1_;
- guint8* buffer;
gssize bufsize;
- gboolean _tmp2_;
+ gboolean _tmp1_;
+ gssize _tmp2_;
gssize _tmp3_;
- gssize _tmp4_;
- guint8* _tmp5_;
+ guint8* _tmp4_;
+ guint8* cpybuf;
gint cpybuf_length1;
gint _cpybuf_size_;
- guint8* _tmp6_;
- guint8* cpybuf;
GError * e;
GError * _inner_error_;
};
@@ -190,7 +188,7 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) {
data->_tmp0_ = g_file_read (data->self->priv->file, NULL, &data->_inner_error_);
data->_tmp1_ = data->_tmp0_;
if (data->_inner_error_ != NULL) {
- goto __catch13_g_error;
+ goto __catch14_g_error;
}
data->_tmp2_ = data->_tmp1_;
data->_tmp3_ = NULL;
@@ -200,15 +198,15 @@ static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) {
data->self->priv->stream = data->_tmp4_;
_g_object_unref0 (data->_tmp2_);
g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
- goto __finally13;
- __catch13_g_error:
+ goto __finally14;
+ __catch14_g_error:
{
data->e = data->_inner_error_;
data->_inner_error_ = NULL;
g_signal_emit_by_name (data->self, "failed");
_g_error_free0 (data->e);
}
- __finally13:
+ __finally14:
if (data->_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code);
g_clear_error (&data->_inner_error_);
@@ -271,55 +269,53 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD
data->size = (gssize) 1024;
data->_tmp0_ = NULL;
data->_tmp0_ = g_new0 (guint8, data->size);
- data->_tmp1_ = data->_tmp0_;
+ data->buffer = data->_tmp0_;
data->buffer_length1 = data->size;
- data->_buffer_size_ = data->buffer_length1;
- data->buffer = data->_tmp1_;
+ data->_buffer_size_ = data->size;
data->bufsize = (gssize) 1;
{
- data->_tmp2_ = TRUE;
+ data->_tmp1_ = TRUE;
while (TRUE) {
- if (!data->_tmp2_) {
+ if (!data->_tmp1_) {
if (!(data->bufsize > 0)) {
break;
}
}
- data->_tmp2_ = FALSE;
+ data->_tmp1_ = FALSE;
data->_state_ = 1;
g_input_stream_read_async ((GInputStream*) data->self->priv->stream, data->buffer, (gsize) data->buffer_length1, G_PRIORITY_DEFAULT, NULL, fetch_file_read_something_async_ready, data);
return FALSE;
_state_1:
- data->_tmp3_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_);
- data->_tmp4_ = data->_tmp3_;
+ data->_tmp2_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_);
+ data->_tmp3_ = data->_tmp2_;
if (data->_inner_error_ != NULL) {
- goto __catch14_g_error;
+ goto __catch15_g_error;
}
- data->bufsize = data->_tmp4_;
+ data->bufsize = data->_tmp3_;
if (data->bufsize < 1) {
break;
}
if (data->bufsize != data->size) {
- data->_tmp5_ = NULL;
- data->_tmp5_ = g_new0 (guint8, data->bufsize);
- data->_tmp6_ = data->_tmp5_;
+ data->_tmp4_ = NULL;
+ data->_tmp4_ = g_new0 (guint8, data->bufsize);
+ data->cpybuf = data->_tmp4_;
data->cpybuf_length1 = data->bufsize;
- data->_cpybuf_size_ = data->cpybuf_length1;
- data->cpybuf = data->_tmp6_;
+ data->_cpybuf_size_ = data->bufsize;
memcpy (data->cpybuf, data->buffer, (gsize) data->bufsize);
g_byte_array_append (data->self->priv->data, data->cpybuf, data->cpybuf_length1);
data->cpybuf = (g_free (data->cpybuf), NULL);
} else {
g_byte_array_append (data->self->priv->data, data->buffer, data->buffer_length1);
}
- goto __finally14;
- __catch14_g_error:
+ goto __finally15;
+ __catch15_g_error:
{
data->e = data->_inner_error_;
data->_inner_error_ = NULL;
g_signal_emit_by_name (data->self, "failed");
_g_error_free0 (data->e);
}
- __finally14:
+ __finally15:
if (data->_inner_error_ != NULL) {
data->buffer = (g_free (data->buffer), NULL);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code);
diff --git a/src/freedesktop-interfaces.c b/src/freedesktop-interfaces.c
index 08a2331..d5bac9a 100644
--- a/src/freedesktop-interfaces.c
+++ b/src/freedesktop-interfaces.c
@@ -1,4 +1,4 @@
-/* freedesktop-interfaces.c generated by valac 0.11.3, the Vala compiler
+/* freedesktop-interfaces.c generated by valac 0.11.5, the Vala compiler
* generated from freedesktop-interfaces.vala, do not modify */
/*
@@ -204,7 +204,6 @@ static void free_desktop_object_base_init (FreeDesktopObjectIface * iface) {
if (!initialized) {
initialized = TRUE;
g_signal_new ("name_owner_changed", TYPE_FREE_DESKTOP_OBJECT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- g_type_set_qdata (TYPE_FREE_DESKTOP_OBJECT, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_object_register_object);
}
}
@@ -216,6 +215,9 @@ GType free_desktop_object_get_type (void) {
GType free_desktop_object_type_id;
free_desktop_object_type_id = g_type_register_static (G_TYPE_INTERFACE, "FreeDesktopObject", &g_define_type_info, 0);
g_type_interface_add_prerequisite (free_desktop_object_type_id, G_TYPE_OBJECT);
+ g_type_set_qdata (free_desktop_object_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) free_desktop_object_proxy_get_type);
+ g_type_set_qdata (free_desktop_object_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.DBus");
+ g_type_set_qdata (free_desktop_object_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_object_register_object);
g_once_init_leave (&free_desktop_object_type_id__volatile, free_desktop_object_type_id);
}
return free_desktop_object_type_id__volatile;
@@ -342,13 +344,13 @@ static void free_desktop_object_proxy_free_desktop_object_interface_init (FreeDe
static void _dbus_free_desktop_object_list_names (FreeDesktopObject* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GVariantIter _arguments_iter;
g_variant_iter_init (&_arguments_iter, parameters);
- free_desktop_object_list_names (self, (GAsyncReadyCallback) _dbus_free_desktop_object_list_names_ready, g_object_ref (invocation));
+ free_desktop_object_list_names (self, (GAsyncReadyCallback) _dbus_free_desktop_object_list_names_ready, invocation);
}
static void _dbus_free_desktop_object_list_names_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
@@ -358,10 +360,9 @@ static void _dbus_free_desktop_object_list_names_ready (GObject * source_object,
GVariantBuilder _tmp77_;
int _tmp78_;
invocation = _user_data_;
- error = NULL;
result = free_desktop_object_list_names_finish ((FreeDesktopObject*) source_object, _res_, &result_length1, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -373,7 +374,7 @@ static void _dbus_free_desktop_object_list_names_ready (GObject * source_object,
_tmp76_++;
}
g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp77_));
- result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL);
+ result = (_vala_array_free ( result, result_length1, (GDestroyNotify) g_free), NULL);
_reply = g_variant_builder_end (&_reply_builder);
g_dbus_message_set_body (_reply_message, _reply);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
@@ -389,8 +390,9 @@ static void free_desktop_object_dbus_interface_method_call (GDBusConnection* con
object = data[0];
if (strcmp (method_name, "ListNames") == 0) {
_dbus_free_desktop_object_list_names (object, parameters, invocation);
+ } else {
+ g_object_unref (invocation);
}
- g_object_unref (invocation);
}
@@ -463,7 +465,6 @@ static void free_desktop_introspectable_base_init (FreeDesktopIntrospectableIfac
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
- g_type_set_qdata (TYPE_FREE_DESKTOP_INTROSPECTABLE, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_introspectable_register_object);
}
}
@@ -475,6 +476,9 @@ GType free_desktop_introspectable_get_type (void) {
GType free_desktop_introspectable_type_id;
free_desktop_introspectable_type_id = g_type_register_static (G_TYPE_INTERFACE, "FreeDesktopIntrospectable", &g_define_type_info, 0);
g_type_interface_add_prerequisite (free_desktop_introspectable_type_id, G_TYPE_OBJECT);
+ g_type_set_qdata (free_desktop_introspectable_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) free_desktop_introspectable_proxy_get_type);
+ g_type_set_qdata (free_desktop_introspectable_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.DBus.Introspectable");
+ g_type_set_qdata (free_desktop_introspectable_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_introspectable_register_object);
g_once_init_leave (&free_desktop_introspectable_type_id__volatile, free_desktop_introspectable_type_id);
}
return free_desktop_introspectable_type_id__volatile;
@@ -534,26 +538,26 @@ static void free_desktop_introspectable_proxy_free_desktop_introspectable_interf
static void _dbus_free_desktop_introspectable_Introspect (FreeDesktopIntrospectable* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
- GError* error;
+ GError* error = NULL;
GVariantIter _arguments_iter;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
gchar* result;
- error = NULL;
g_variant_iter_init (&_arguments_iter, parameters);
result = free_desktop_introspectable_Introspect (self, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_reply_builder, g_variant_new_string (result));
- _g_free0 (result);
+ _g_free0 ( result);
_reply = g_variant_builder_end (&_reply_builder);
g_dbus_message_set_body (_reply_message, _reply);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+ g_object_unref (invocation);
g_object_unref (_reply_message);
}
@@ -565,8 +569,9 @@ static void free_desktop_introspectable_dbus_interface_method_call (GDBusConnect
object = data[0];
if (strcmp (method_name, "Introspect") == 0) {
_dbus_free_desktop_introspectable_Introspect (object, parameters, invocation);
+ } else {
+ g_object_unref (invocation);
}
- g_object_unref (invocation);
}
@@ -637,7 +642,6 @@ static void free_desktop_properties_base_init (FreeDesktopPropertiesIface * ifac
if (!initialized) {
initialized = TRUE;
g_signal_new ("properties_changed", TYPE_FREE_DESKTOP_PROPERTIES, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_BOXED_BOXED_INT, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_HASH_TABLE, G_TYPE_STRV, G_TYPE_INT);
- g_type_set_qdata (TYPE_FREE_DESKTOP_PROPERTIES, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_properties_register_object);
}
}
@@ -649,6 +653,9 @@ GType free_desktop_properties_get_type (void) {
GType free_desktop_properties_type_id;
free_desktop_properties_type_id = g_type_register_static (G_TYPE_INTERFACE, "FreeDesktopProperties", &g_define_type_info, 0);
g_type_interface_add_prerequisite (free_desktop_properties_type_id, G_TYPE_OBJECT);
+ g_type_set_qdata (free_desktop_properties_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) free_desktop_properties_proxy_get_type);
+ g_type_set_qdata (free_desktop_properties_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.DBus.Properties");
+ g_type_set_qdata (free_desktop_properties_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) free_desktop_properties_register_object);
g_once_init_leave (&free_desktop_properties_type_id__volatile, free_desktop_properties_type_id);
}
return free_desktop_properties_type_id__volatile;
diff --git a/src/gen-sound-service.xml.c b/src/gen-sound-service.xml.c
index 604c4f3..6d7be97 100644
--- a/src/gen-sound-service.xml.c
+++ b/src/gen-sound-service.xml.c
@@ -2,31 +2,18 @@ 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 name = \"BlacklistMediaPlayer\">\n"
+" <annotation name=\"org.freedesktop.DBus.GLib.CSymbol\" value=\"sound_service_dbus_blacklist_media_player\"/>\n"
+" <arg type='s' name='player_desktop_name' direction=\"in\"/>\n"
+" <arg type='b' name='blacklist' direction=\"in\"/>\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 name = \"GetSoundState\">\n"
+" <annotation name=\"org.freedesktop.DBus.GLib.CSymbol\" value=\"sound_service_dbus_get_sink_state\"/>\n"
+" <arg type='i' name='current_state' 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 name=\"SoundStateUpdate\">\n"
+" <arg name=\"new_state\" type=\"i\" 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/indicator-sound.c b/src/indicator-sound.c
index 3867f27..42560c8 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -1,12 +1,8 @@
/*
-A small wrapper utility to load indicators and put them as menu items
-into the gnome-panel using it's applet interface.
-
Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
- Ted Gould <ted@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
@@ -20,6 +16,7 @@ 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 <http://www.gnu.org/licenses/>.
*/
+
#include <math.h>
#include <glib.h>
#include <glib-object.h>
@@ -40,6 +37,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "gen-sound-service.xml.h"
#include "common-defs.h"
+#include "sound-state-manager.h"
typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate;
@@ -47,7 +45,8 @@ struct _IndicatorSoundPrivate
{
GtkWidget* volume_widget;
GList* transport_widgets_list;
- GDBusProxy *dbus_proxy;
+ GDBusProxy *dbus_proxy;
+ SoundStateManager* state_manager;
};
#define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
@@ -67,18 +66,27 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE);
static GtkLabel * get_label (IndicatorObject * io);
static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
-static void indicator_sound_scroll (IndicatorObject* io, gint delta, IndicatorScrollDirection direction);
+static void indicator_sound_scroll (IndicatorObject* io,
+ gint delta,
+ IndicatorScrollDirection direction);
-//Slider related
-static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
+//key/moust event handlers
static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data);
static gboolean key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data);
-static void style_changed_cb(GtkWidget *widget, gpointer user_data);
-//player widget realisation methods
-static gboolean new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
-static gboolean new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
-static gboolean new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
+//custom widget realisation methods
+static gboolean new_volume_slider_widget (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client);
+static gboolean new_transport_widget (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client);
+static gboolean new_metadata_widget (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client);
+static gboolean new_title_widget (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client);
// DBUS communication
@@ -90,59 +98,6 @@ 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,
- 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);
-
-static const gint STATE_MUTED = 0;
-static const gint STATE_ZERO = 1;
-static const gint STATE_LOW = 2;
-static const gint STATE_MEDIUM = 3;
-static const gint STATE_HIGH = 4;
-static const gint STATE_MUTED_WHILE_INPUT = 5;
-static const gint STATE_SINKS_NONE = 6;
-
-static GHashTable *volume_states = NULL;
-static GtkImage *speaker_image = NULL;
-static gint current_state = 0;
-static gint previous_state = 0;
-
-static gboolean initial_mute ;
-static gboolean device_available;
-
-static GtkIconSize design_team_size;
-static gint blocked_id;
-static gint animation_id;
-
-static GList * blocked_animation_list = NULL;
-static GList * blocked_iter = NULL;
-static void prepare_blocked_animation();
-static gboolean fade_back_to_mute_image();
-static gboolean start_animation();
-static void reset_mute_blocking_animation();
-static void free_the_animation_list();
-
static void
indicator_sound_class_init (IndicatorSoundClass *klass)
@@ -160,7 +115,6 @@ indicator_sound_class_init (IndicatorSoundClass *klass)
io_class->get_image = get_icon;
io_class->get_menu = get_menu;
io_class->scroll = indicator_sound_scroll;
- design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
}
static void
@@ -169,39 +123,29 @@ indicator_sound_init (IndicatorSound *self)
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;
- blocked_id = 0;
- initial_mute = FALSE;
- device_available = TRUE;
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;
+ priv->state_manager = g_object_new (SOUND_TYPE_STATE_MANAGER, NULL);
- g_signal_connect(G_OBJECT(self->service),
- INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
- G_CALLBACK(connection_changed), self);
+ g_signal_connect ( G_OBJECT(self->service),
+ INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
+ G_CALLBACK(connection_changed), self );
}
static void
indicator_sound_dispose (GObject *object)
{
IndicatorSound * self = INDICATOR_SOUND(object);
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
if (self->service != NULL) {
g_object_unref(G_OBJECT(self->service));
self->service = NULL;
}
- g_hash_table_destroy(volume_states);
-
- free_the_animation_list();
-
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (self));
g_list_free ( priv->transport_widgets_list );
@@ -209,7 +153,6 @@ indicator_sound_dispose (GObject *object)
return;
}
-
static void
indicator_sound_finalize (GObject *object)
{
@@ -226,14 +169,9 @@ get_label (IndicatorObject * io)
static GtkImage *
get_icon (IndicatorObject * io)
{
- gchar* current_name = g_hash_table_lookup(volume_states,
- GINT_TO_POINTER(current_state));
- //g_debug("At start-up attempting to set the image to %s",
- // current_name);
- speaker_image = indicator_image_helper(current_name);
- gtk_widget_show(GTK_WIDGET(speaker_image));
-
- return speaker_image;
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+ gtk_widget_show( GTK_WIDGET(sound_state_manager_get_current_icon (priv->state_manager)) );
+ return sound_state_manager_get_current_icon (priv->state_manager);
}
/* Indicator based function to get the menu for the whole
@@ -251,122 +189,15 @@ get_menu (IndicatorObject * io)
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TRANSPORT_MENUITEM_TYPE, new_transport_widget);
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget);
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TITLE_MENUITEM_TYPE, new_title_widget);
- // register Key-press listening on the menu widget as the slider does not allow this.
- g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), io);
- g_signal_connect(menu, "key-release-event", G_CALLBACK(key_release_cb), io);
+ // Note: Not ideal but all key handling needs to be managed here and then
+ // delegated to the appropriate widget.
+ g_signal_connect (menu, "key-press-event", G_CALLBACK(key_press_cb), io);
+ g_signal_connect (menu, "key-release-event", G_CALLBACK(key_release_cb), io);
return GTK_MENU(menu);
}
static void
-free_the_animation_list()
-{
- if (blocked_animation_list != NULL) {
- g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL);
- g_list_free(blocked_animation_list);
- blocked_animation_list = NULL;
- }
-}
-
-static gboolean
-new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
-{
- g_debug("indicator-sound: new_transport_bar() called ");
-
- GtkWidget* bar = NULL;
- IndicatorObject *io = NULL;
-
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
- g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
-
- bar = transport_widget_new(newitem);
- io = g_object_get_data (G_OBJECT (client), "indicator");
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
- priv->transport_widgets_list = g_list_append ( priv->transport_widgets_list, bar );
-
- GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
-
- gtk_widget_show_all(bar);
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent);
-
- return TRUE;
-}
-
-static gboolean
-new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
-{
- g_debug("indicator-sound: new_metadata_widget");
-
- GtkWidget* metadata = NULL;
-
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
- g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
-
- metadata = metadata_widget_new (newitem);
- GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata);
-
- gtk_widget_show_all(metadata);
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_metadata_widget, parent);
-
- return TRUE;
-}
-
-static gboolean
-new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
-{
- 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));
-
- GtkWidget* title = NULL;
-
- title = title_widget_new (newitem);
- GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title);
-
- gtk_widget_show_all(title);
-
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
- newitem,
- menu_title_widget, parent);
- return TRUE;
-}
-
-static gboolean
-new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
-{
- g_debug("indicator-sound: new_volume_slider_widget");
-
- GtkWidget* volume_widget = NULL;
- IndicatorObject *io = NULL;
-
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
- g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
-
- volume_widget = volume_widget_new (newitem);
- io = g_object_get_data (G_OBJECT (client), "indicator");
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
- priv->volume_widget = volume_widget;
-
- GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
-
- g_signal_connect(ido_slider_widget, "style-set", G_CALLBACK(style_changed_cb), NULL);
- gtk_widget_set_sensitive(ido_slider_widget,
- !initial_mute);
- gtk_widget_show_all(ido_slider_widget);
-
-
- GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget);
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
- newitem,
- menu_volume_item,
- parent);
- fetch_state(INDICATOR_SOUND (io));
- return TRUE;
-}
-
-
-static void
connection_changed (IndicatorServiceManager * sm,
gboolean connected,
gpointer user_data)
@@ -377,7 +208,7 @@ connection_changed (IndicatorServiceManager * sm,
GError *error = NULL;
if (connected == FALSE){
- update_state (STATE_SINKS_NONE);
+ sound_state_manager_deal_with_disconnect (priv->state_manager);
return;
//TODO: Gracefully handle disconnection
// do a timeout to wait for reconnection
@@ -388,7 +219,14 @@ 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);
+ g_dbus_proxy_call ( priv->dbus_proxy,
+ "GetSoundState",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)sound_state_manager_get_state_cb,
+ priv->state_manager);
return;
}
@@ -440,336 +278,116 @@ 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);
-}
-
-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));
- }
+ sound_state_manager_connect_to_dbus (priv->state_manager,
+ priv->dbus_proxy);
- 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 )
+static gboolean
+new_transport_widget (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client)
{
- 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);
-}
+ g_debug("indicator-sound: new_transport_bar() called ");
+ GtkWidget* bar = NULL;
+ IndicatorObject *io = NULL;
-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 );
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- if (error != NULL) {
- g_debug("get_sink_mute call failed: %s", error->message);
- g_error_free(error);
- return;
- }
+ bar = transport_widget_new(newitem);
+ io = g_object_get_data (G_OBJECT (client), "indicator");
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+ priv->transport_widgets_list = g_list_append ( priv->transport_widgets_list, bar );
- 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);
-}
+ GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
-/*
-Prepare states Array.
-*/
-void
-prepare_state_machine()
-{
- volume_states = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED), g_strdup("audio-volume-muted-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_ZERO), g_strdup("audio-volume-low-zero-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_LOW), g_strdup("audio-volume-low-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MEDIUM), g_strdup("audio-volume-medium-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_HIGH), g_strdup("audio-volume-high-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT), g_strdup("audio-volume-muted-blocking-panel"));
- g_hash_table_insert(volume_states, GINT_TO_POINTER(STATE_SINKS_NONE), g_strdup("audio-output-none-panel"));
+ gtk_widget_show_all(bar);
+ dbusmenu_gtkclient_newitem_base (DBUSMENU_GTKCLIENT(client),
+ newitem,
+ menu_transport_bar,
+ parent);
+ return TRUE;
}
-/*
-prepare_blocked_animation:
-Prepares the array of images to be used in the blocked animation.
-Only called at startup.
-*/
-static void
-prepare_blocked_animation()
+static gboolean
+new_metadata_widget (DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client)
{
- gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
- gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED));
-
- GtkImage* temp_image = indicator_image_helper(muted_name);
- GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image);
-
- temp_image = indicator_image_helper(blocked_name);
- GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image);
-
- if (mute_buf == NULL || blocked_buf == NULL) {
- //g_debug("Don bother with the animation, the theme aint got the goods !");
- return;
- }
-
- int i;
-
- // sample 51 snapshots - range : 0-256
- for (i = 0; i < 51; i++) {
- gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0,
- gdk_pixbuf_get_width(mute_buf),
- gdk_pixbuf_get_height(mute_buf),
- 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 5));
- blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf));
- }
- g_object_ref_sink(mute_buf);
- g_object_unref(mute_buf);
- g_object_ref_sink(blocked_buf);
- g_object_unref(blocked_buf);
-}
+ g_debug("indicator-sound: new_metadata_widget");
-gint
-get_state()
-{
- return current_state;
-}
+ GtkWidget* metadata = NULL;
-gchar*
-get_state_image_name(gint state)
-{
- return g_hash_table_lookup(volume_states, GINT_TO_POINTER(state));
-}
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
-void
-prepare_for_tests(IndicatorObject *io)
-{
- prepare_state_machine();
- get_icon(io);
-}
+ metadata = metadata_widget_new (newitem);
+ GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata);
-void
-tidy_up_hash()
-{
- g_hash_table_destroy(volume_states);
+ gtk_widget_show_all(metadata);
+ dbusmenu_gtkclient_newitem_base (DBUSMENU_GTKCLIENT(client),
+ newitem, menu_metadata_widget, parent);
+ return TRUE;
}
-static void
-update_state(const gint state)
+static gboolean
+new_title_widget(DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client)
{
- previous_state = current_state;
- current_state = state;
- gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
- indicator_image_helper_update(speaker_image, image_name);
-}
+ 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));
-void
-determine_state_from_volume(gdouble volume_percent)
-{
- if (device_available == FALSE)
- return;
- gint state = previous_state;
- if (volume_percent < 30.0 && volume_percent > 0) {
- state = STATE_LOW;
- } else if (volume_percent < 70.0 && volume_percent >= 30.0) {
- state = STATE_MEDIUM;
- } else if (volume_percent >= 70.0) {
- state = STATE_HIGH;
- } else if (volume_percent == 0.0) {
- state = STATE_ZERO;
- }
- update_state(state);
-}
+ GtkWidget* title = NULL;
+ title = title_widget_new (newitem);
+ GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title);
+
+ gtk_widget_show_all(title);
-static gboolean
-start_animation()
-{
- blocked_iter = blocked_animation_list;
- blocked_id = 0;
- animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL);
- return FALSE;
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
+ newitem,
+ menu_title_widget, parent);
+ return TRUE;
}
static gboolean
-fade_back_to_mute_image()
+new_volume_slider_widget(DbusmenuMenuitem * newitem,
+ DbusmenuMenuitem * parent,
+ DbusmenuClient * client)
{
- if (blocked_iter != NULL) {
- gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data);
- blocked_iter = blocked_iter->next;
- return TRUE;
- } else {
- animation_id = 0;
- //g_debug("exit from animation now\n");
- return FALSE;
- }
-}
-
-static void
-reset_mute_blocking_animation()
-{
- if (animation_id != 0) {
- //g_debug("about to remove the animation_id callback from the mainloop!!**");
- g_source_remove(animation_id);
- animation_id = 0;
- }
- if (blocked_id != 0) {
- //g_debug("about to remove the blocked_id callback from the mainloop!!**");
- g_source_remove(blocked_id);
- blocked_id = 0;
- }
-}
-
-
-
-/*******************************************************************/
-// DBUS Signal reactions
-/*******************************************************************/
-static void g_signal_cb ( GDBusProxy* proxy,
- gchar* sender_name,
- gchar* signal_name,
- GVariant* parameters,
- gpointer user_data)
-{
- IndicatorSound *self = INDICATOR_SOUND(user_data);
- 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);
-
- 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 );
- }
- else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_MUTE_UPDATE) == 0){
- react_to_signal_sink_mute_update ( input, self );
- }
- else if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_SINK_INPUT_WHILE_MUTED) == 0){
- react_to_signal_sink_input_while_muted ( input, self );
- }
-}
+ g_debug("indicator-sound: new_volume_slider_widget");
-static void
-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) {
- gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT));
- indicator_image_helper_update(speaker_image, image_name);
- blocked_id = g_timeout_add_seconds(5, start_animation, NULL);
- }
-}
+ GtkWidget* volume_widget = NULL;
+ IndicatorObject *io = NULL;
-/*
- We can be sure the service won't send a mute signal unless it has changed !
- UNMUTE's force a volume update therefore icon is updated appropriately => no need for unmute handling here.
-*/
-static void
-react_to_signal_sink_mute_update(gboolean mute_value, IndicatorSound* self)
-{
- if (mute_value == TRUE && device_available == TRUE) {
- update_state(STATE_MUTED);
- } else {
- reset_mute_blocking_animation();
- }
- //g_debug("signal caught - sink mute update with mute value: %i", mute_value);
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- 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));
- }
-}
+ volume_widget = volume_widget_new (newitem);
+ io = g_object_get_data (G_OBJECT (client), "indicator");
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+ priv->volume_widget = volume_widget;
+ GtkWidget* ido_slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
-static void
-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);
+ gtk_widget_show_all(ido_slider_widget);
+ // register the style callback on this widget with state manager's style change
+ // handler (needs to remake the blocking animation for each style).
+ g_signal_connect (ido_slider_widget, "style-set",
+ G_CALLBACK(sound_state_manager_style_changed_cb),
+ priv->state_manager);
- determine_state_from_volume (volume_widget_get_current_volume(priv->volume_widget));
- //g_debug("signal caught - sink availability update with value: %i", available_value);
+ GtkMenuItem *menu_volume_item = GTK_MENU_ITEM(ido_slider_widget);
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client),
+ newitem,
+ menu_volume_item,
+ parent);
+ return TRUE;
}
/*******************************************************************/
@@ -833,7 +451,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
break;
}
new_value = CLAMP(new_value, 0, 100);
- if (new_value != current_value && current_state != STATE_MUTED) {
+ if (new_value != current_value && sound_state_manager_get_current_state (priv->state_manager) != MUTED) {
//g_debug("Attempting to set the range from the key listener to %f", new_value);
volume_widget_update(VOLUME_WIDGET(priv->volume_widget), new_value);
}
@@ -930,25 +548,17 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
return digested;
}
-static void
-style_changed_cb(GtkWidget *widget, gpointer user_data)
-{
- //g_debug("Just caught a style change event");
- update_state(current_state);
- reset_mute_blocking_animation();
- update_state(current_state);
- free_the_animation_list();
- prepare_blocked_animation();
-}
static void
-indicator_sound_scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
+indicator_sound_scroll (IndicatorObject *io, gint delta,
+ IndicatorScrollDirection direction)
{
//g_debug("indicator-sound-scroll - current slider value");
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+ SoundState current_state = sound_state_manager_get_current_state (priv->state_manager);
- if (device_available == FALSE || current_state == STATE_MUTED)
+ if (current_state == UNAVAILABLE || current_state == MUTED)
return;
- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);
diff --git a/src/indicator-sound.h b/src/indicator-sound.h
index 9f829bb..ecc38fb 100644
--- a/src/indicator-sound.h
+++ b/src/indicator-sound.h
@@ -26,7 +26,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
#include <libindicator/indicator-service-manager.h>
-#include <libindicator/indicator-image-helper.h>
#define INDICATOR_SOUND_TYPE (indicator_sound_get_type ())
#define INDICATOR_SOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SOUND_TYPE, IndicatorSound))
diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c
index 140cbcf..05d7e84 100644
--- a/src/metadata-menu-item.c
+++ b/src/metadata-menu-item.c
@@ -1,4 +1,4 @@
-/* metadata-menu-item.c generated by valac 0.11.3, the Vala compiler
+/* metadata-menu-item.c generated by valac 0.11.5, the Vala compiler
* generated from metadata-menu-item.vala, do not modify */
/*
@@ -344,14 +344,13 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons
art_file = _tmp0_;
_tmp1_ = g_file_is_native (art_file);
if (_tmp1_ == TRUE) {
- gchar* path;
+ gchar* path = NULL;
gchar* _tmp2_ = NULL;
gchar* _tmp3_;
gchar* _tmp4_ = NULL;
gchar* _tmp5_;
gchar* _tmp6_;
gchar* _tmp7_;
- path = NULL;
_tmp2_ = string_strip (uri);
_tmp3_ = _tmp2_;
_tmp4_ = g_filename_from_uri (_tmp3_, NULL, &_inner_error_);
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 09365d5..a37053b 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -101,8 +101,7 @@ metadata_widget_init (MetadataWidget *self)
// image
priv->album_art = gtk_image_new();
- priv->image_path = g_string_new(dbusmenu_menuitem_property_get(priv->twin_item,
- DBUSMENU_METADATA_MENUITEM_ARTURL));
+ priv->image_path = g_string_new("");
priv->old_image_path = g_string_new("");
g_signal_connect(priv->album_art, "expose-event",
@@ -120,8 +119,7 @@ metadata_widget_init (MetadataWidget *self)
// artist
GtkWidget* artist;
- artist = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item,
- DBUSMENU_METADATA_MENUITEM_ARTIST));
+ artist = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0, (gfloat)0);
gtk_misc_set_padding (GTK_MISC(artist), (gfloat)10, (gfloat)0);
gtk_widget_set_size_request (artist, 140, 15);
@@ -131,8 +129,7 @@ metadata_widget_init (MetadataWidget *self)
// title
GtkWidget* piece;
- piece = gtk_label_new(dbusmenu_menuitem_property_get( priv->twin_item,
- DBUSMENU_METADATA_MENUITEM_TITLE) );
+ piece = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(piece), (gfloat)0, (gfloat)0);
gtk_misc_set_padding (GTK_MISC(piece), (gfloat)10, (gfloat)-5);
gtk_widget_set_size_request (piece, 140, 15);
@@ -142,8 +139,7 @@ metadata_widget_init (MetadataWidget *self)
// container
GtkWidget* container;
- container = gtk_label_new(dbusmenu_menuitem_property_get( priv->twin_item,
- DBUSMENU_METADATA_MENUITEM_ALBUM) );
+ container = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(container), (gfloat)0, (gfloat)0);
gtk_misc_set_padding (GTK_MISC(container), (gfloat)10, (gfloat)0);
gtk_widget_set_size_request (container, 140, 15);
@@ -397,7 +393,6 @@ metadata_widget_button_press_event (GtkWidget *menuitem,
return FALSE;
}
-// TODO: Manage empty/mangled music details <unknown artist> etc.
static void
metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GVariant* value, gpointer userdata)
@@ -480,16 +475,18 @@ metadata_widget_set_twin_item(MetadataWidget* self,
metadata_widget_style_labels( self, GTK_LABEL(priv->artist_label));
g_string_erase(priv->image_path, 0, -1);
- g_string_overwrite( priv->image_path,
- 0,
- dbusmenu_menuitem_property_get( priv->twin_item,
- DBUSMENU_METADATA_MENUITEM_ARTURL ));
+ const gchar *arturl = dbusmenu_menuitem_property_get( priv->twin_item,
+ DBUSMENU_METADATA_MENUITEM_ARTURL );
+ if (arturl != NULL){
+ g_string_overwrite( priv->image_path,
+ 0,
+ arturl);
- // if its a remote image queue a redraw incase the download took too long
- if (g_str_has_prefix (dbusmenu_menuitem_property_get (priv->twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL ),
- g_get_user_cache_dir())){
- gtk_widget_queue_draw(GTK_WIDGET(self));
- }
+ // if its a remote image queue a redraw incase the download took too long
+ if (g_str_has_prefix (arturl, g_get_user_cache_dir())){
+ gtk_widget_queue_draw(GTK_WIDGET(self));
+ }
+ }
}
/**
diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c
index 9e198d7..c953648 100644
--- a/src/mpris2-controller.c
+++ b/src/mpris2-controller.c
@@ -1,4 +1,4 @@
-/* mpris2-controller.c generated by valac 0.11.3, the Vala compiler
+/* mpris2-controller.c generated by valac 0.11.5, the Vala compiler
* generated from mpris2-controller.vala, do not modify */
/*
@@ -129,6 +129,7 @@ typedef struct _TransportMenuitemClass TransportMenuitemClass;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define TRANSPORT_MENUITEM_TYPE_ACTION (transport_menuitem_action_get_type ())
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define TYPE_PLAYLISTS_MENUITEM (playlists_menuitem_get_type ())
#define PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitem))
@@ -139,7 +140,7 @@ typedef struct _TransportMenuitemClass TransportMenuitemClass;
typedef struct _PlaylistsMenuitem PlaylistsMenuitem;
typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass;
-#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+typedef struct _Mpris2ControllerFetchPlaylistsData Mpris2ControllerFetchPlaylistsData;
struct _Mpris2Controller {
GObject parent_instance;
@@ -199,7 +200,8 @@ struct _MprisPlaylistsIface {
GTypeInterface parent_iface;
void (*ActivatePlaylist) (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
void (*ActivatePlaylist_finish) (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
- PlaylistDetails* (*GetPlaylists) (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+ void (*GetPlaylists) (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ PlaylistDetails* (*GetPlaylists_finish) (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
gchar** (*get_Orderings) (MprisPlaylists* self, int* result_length1);
void (*set_Orderings) (MprisPlaylists* self, gchar** value, int value_length1);
guint32 (*get_PlaylistCount) (MprisPlaylists* self);
@@ -252,6 +254,31 @@ typedef enum {
TRANSPORT_MENUITEM_ACTION_NEXT
} TransportMenuitemaction;
+struct _Mpris2ControllerFetchPlaylistsData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ Mpris2Controller* self;
+ PlaylistDetails* current_playlists;
+ gint current_playlists_length1;
+ gint _current_playlists_size_;
+ gint _tmp0_;
+ PlaylistDetails* _tmp1_;
+ PlaylistDetails* _tmp2_;
+ gint _tmp2__length1;
+ gint __tmp2__size_;
+ PlaylistDetails* _tmp3_;
+ GError * e;
+ gpointer _tmp4_;
+ PlayerItem* _tmp5_;
+ PlaylistsMenuitem* playlists_item;
+ gboolean _tmp6_;
+ gboolean* _tmp7_;
+ gboolean* _tmp8_;
+ GError * _inner_error_;
+};
+
static gpointer mpris2_controller_parent_class = NULL;
@@ -311,14 +338,12 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
static gboolean _bool_equal (const gboolean* s1, const gboolean* s2);
static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self);
+void mpris2_controller_fetch_playlists (Mpris2Controller* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void mpris2_controller_fetch_playlists_finish (Mpris2Controller* self, GAsyncResult* _res_);
GHashTable* mpris_player_get_Metadata (MprisPlayer* self);
-static gchar** _variant_get1 (GVariant* value, int* result_length1);
-static gchar** _vala_array_dup1 (gchar** self, int length);
-static GVariant* _variant_new2 (const gchar* value);
-static const gchar* _variant_get3 (GVariant* value);
-static GVariant* _variant_new4 (gint64 value);
+static GVariant* _variant_new1 (const gchar* value);
+static const gchar* _variant_get2 (GVariant* value);
void mpris2_controller_initial_update (Mpris2Controller* self);
-void mpris2_controller_fetch_playlists (Mpris2Controller* self);
GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command);
void mpris_player_PlayPause (MprisPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
@@ -327,19 +352,23 @@ void mpris_player_Previous (MprisPlayer* self, GAsyncReadyCallback _callback_, g
void mpris_player_Previous_finish (MprisPlayer* self, GAsyncResult* _res_, GError** error);
void mpris_player_Next (MprisPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void mpris_player_Next_finish (MprisPlayer* self, GAsyncResult* _res_, GError** error);
+gboolean mpris2_controller_connected (Mpris2Controller* self);
+MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self);
+void mpris2_controller_expose (Mpris2Controller* self);
+void mpris_root_Raise (MprisRoot* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void mpris_root_Raise_finish (MprisRoot* self, GAsyncResult* _res_, GError** error);
+static void mpris2_controller_fetch_playlists_data_free (gpointer _data);
+static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlaylistsData* data);
MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self);
-PlaylistDetails* mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+void mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+PlaylistDetails* mpris_playlists_GetPlaylists_finish (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
+static void mpris2_controller_fetch_playlists_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length);
GType playlists_menuitem_get_type (void) G_GNUC_CONST;
void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1);
static gboolean* _bool_dup (gboolean* self);
-static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length);
void mpris_playlists_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result);
void playlists_menuitem_update_active_playlist (PlaylistsMenuitem* self, PlaylistDetails* detail);
-gboolean mpris2_controller_connected (Mpris2Controller* self);
-MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self);
-void mpris2_controller_expose (Mpris2Controller* self);
-void mpris_root_Raise (MprisRoot* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
-void mpris_root_Raise_finish (MprisRoot* self, GAsyncResult* _res_, GError** error);
void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* path);
void mpris_playlists_ActivatePlaylist (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
void mpris_playlists_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
@@ -410,6 +439,14 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
GVariant* _tmp22_;
GVariant* playlist_v;
gboolean _tmp23_ = FALSE;
+ gconstpointer _tmp25_ = NULL;
+ GVariant* _tmp26_;
+ GVariant* playlist_count_v;
+ gboolean _tmp27_ = FALSE;
+ gconstpointer _tmp29_ = NULL;
+ GVariant* _tmp30_;
+ GVariant* playlist_orderings_v;
+ gboolean _tmp31_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (interface_source != NULL);
g_return_if_fail (changed_properties != NULL);
@@ -497,6 +534,34 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
if (_tmp23_) {
mpris2_controller_fetch_active_playlist (self);
}
+ _tmp25_ = g_hash_table_lookup (changed_properties, "PlaylistCount");
+ _tmp26_ = _g_variant_ref0 ((GVariant*) _tmp25_);
+ playlist_count_v = _tmp26_;
+ if (playlist_count_v != NULL) {
+ gboolean _tmp28_;
+ _tmp27_ = _bool_equal (self->priv->_owner->use_playlists, (_tmp28_ = TRUE, &_tmp28_)) == TRUE;
+ } else {
+ _tmp27_ = FALSE;
+ }
+ if (_tmp27_) {
+ mpris2_controller_fetch_playlists (self, NULL, NULL);
+ mpris2_controller_fetch_active_playlist (self);
+ }
+ _tmp29_ = g_hash_table_lookup (changed_properties, "Orderings");
+ _tmp30_ = _g_variant_ref0 ((GVariant*) _tmp29_);
+ playlist_orderings_v = _tmp30_;
+ if (playlist_orderings_v != NULL) {
+ gboolean _tmp32_;
+ _tmp31_ = _bool_equal (self->priv->_owner->use_playlists, (_tmp32_ = TRUE, &_tmp32_)) == TRUE;
+ } else {
+ _tmp31_ = FALSE;
+ }
+ if (_tmp31_) {
+ mpris2_controller_fetch_playlists (self, NULL, NULL);
+ mpris2_controller_fetch_active_playlist (self);
+ }
+ _g_variant_unref0 (playlist_orderings_v);
+ _g_variant_unref0 (playlist_count_v);
_g_variant_unref0 (playlist_v);
_g_variant_unref0 (meta_v);
_g_variant_unref0 (play_v);
@@ -518,7 +583,7 @@ static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controll
g_return_val_if_fail (self != NULL, FALSE);
_tmp0_ = mpris_player_get_PlaybackStatus (self->priv->_player);
_tmp1_ = _tmp0_;
- g_debug ("mpris2-controller.vala:99: TEST playback status = %s", _tmp1_);
+ g_debug ("mpris2-controller.vala:109: TEST playback status = %s", _tmp1_);
_g_free0 (_tmp1_);
_tmp2_ = mpris_player_get_PlaybackStatus (self->priv->_player);
_tmp3_ = _tmp2_;
@@ -533,58 +598,16 @@ static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controll
}
-static gchar** _variant_get1 (GVariant* value, int* result_length1) {
- gchar** _tmp10_;
- int _tmp10__length;
- int _tmp10__size;
- int _tmp10__length1;
- GVariantIter _tmp11_;
- GVariant* _tmp12_;
- _tmp10_ = g_new (gchar*, 5);
- _tmp10__length = 0;
- _tmp10__size = 4;
- _tmp10__length1 = 0;
- g_variant_iter_init (&_tmp11_, value);
- for (; (_tmp12_ = g_variant_iter_next_value (&_tmp11_)) != NULL; _tmp10__length1++) {
- if (_tmp10__size == _tmp10__length) {
- _tmp10__size = 2 * _tmp10__size;
- _tmp10_ = g_renew (gchar*, _tmp10_, _tmp10__size + 1);
- }
- _tmp10_[_tmp10__length++] = g_variant_dup_string (_tmp12_, NULL);
- g_variant_unref (_tmp12_);
- }
- *result_length1 = _tmp10__length1;
- _tmp10_[_tmp10__length] = NULL;
- return _tmp10_;
-}
-
-
-static gchar** _vala_array_dup1 (gchar** self, int length) {
- gchar** result;
- int i;
- result = g_new0 (gchar*, length + 1);
- for (i = 0; i < length; i++) {
- result[i] = g_strdup (self[i]);
- }
- return result;
-}
-
-
-static GVariant* _variant_new2 (const gchar* value) {
+static GVariant* _variant_new1 (const gchar* value) {
return g_variant_ref_sink (g_variant_new_string (value));
}
-static const gchar* _variant_get3 (GVariant* value) {
+static const gchar* _variant_get2 (GVariant* value) {
return g_variant_dup_string (value, NULL);
}
-static GVariant* _variant_new4 (gint64 value) {
- return g_variant_ref_sink (g_variant_new_int64 (value));
-}
-
-
static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) {
GHashTable* result = NULL;
GHashTable* _tmp0_ = NULL;
@@ -595,12 +618,6 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) {
GVariant* _tmp4_;
GVariant* _tmp5_;
GVariant* artist_v;
- GHashTable* _tmp20_ = NULL;
- GHashTable* _tmp21_;
- gconstpointer _tmp22_ = NULL;
- GVariant* _tmp23_;
- GVariant* _tmp24_;
- GVariant* length_v;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = mpris_player_get_Metadata (self->priv->_player);
changed_updates = _tmp0_;
@@ -613,58 +630,58 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) {
GHashTable* _tmp6_ = NULL;
GHashTable* _tmp7_;
gconstpointer _tmp8_ = NULL;
- gint _tmp9_;
- gchar** _tmp13_;
- gchar** _tmp14_;
- gchar** _tmp15_;
- gint artists_length1;
- gint _artists_size_;
- gchar** _tmp16_;
- gchar** artists;
- gchar* _tmp17_ = NULL;
- gchar* display_artists;
- gchar* _tmp18_;
- gconstpointer _tmp19_ = NULL;
+ GVariant* _tmp9_;
+ GVariant* _tmp10_;
+ GVariant* v_artists;
+ const gchar* _tmp11_ = NULL;
+ gchar* display_artists = NULL;
+ const gchar* _tmp12_ = NULL;
+ gchar* _tmp20_;
+ gconstpointer _tmp21_ = NULL;
_tmp6_ = mpris_player_get_Metadata (self->priv->_player);
_tmp7_ = _tmp6_;
_tmp8_ = g_hash_table_lookup (_tmp7_, "xesam:artist");
- _tmp13_ = (_tmp14_ = _variant_get1 ((GVariant*) _tmp8_, &_tmp9_), (_tmp14_ == NULL) ? ((gpointer) _tmp14_) : _vala_array_dup1 (_tmp14_, _tmp9_));
- _tmp16_ = (_tmp15_ = _tmp13_, _g_hash_table_unref0 (_tmp7_), _tmp15_);
- artists_length1 = _tmp9_;
- _artists_size_ = artists_length1;
- artists = _tmp16_;
- _tmp17_ = g_strjoinv (", ", artists);
- display_artists = _tmp17_;
- _tmp18_ = g_strdup ("xesam:artist");
- g_hash_table_replace (changed_updates, _tmp18_, _variant_new2 (display_artists));
- _tmp19_ = g_hash_table_lookup (changed_updates, "xesam:artist");
- g_debug ("mpris2-controller.vala:113: artist : %s", _variant_get3 ((GVariant*) _tmp19_));
+ _tmp9_ = _g_variant_ref0 ((GVariant*) _tmp8_);
+ v_artists = (_tmp10_ = _tmp9_, _g_hash_table_unref0 (_tmp7_), _tmp10_);
+ _tmp11_ = g_variant_get_type_string (v_artists);
+ g_debug ("mpris2-controller.vala:121: artists is of type %s", _tmp11_);
+ _tmp12_ = g_variant_get_type_string (v_artists);
+ if (g_strcmp0 (_tmp12_, "s") == 0) {
+ const gchar* _tmp13_ = NULL;
+ gchar* _tmp14_;
+ gchar* _tmp15_;
+ g_debug ("mpris2-controller.vala:124: SPOTIFY is that you ?");
+ _tmp13_ = g_variant_get_string (v_artists, NULL);
+ _tmp14_ = g_strdup (_tmp13_);
+ _tmp15_ = _tmp14_;
+ _g_free0 (display_artists);
+ display_artists = _tmp15_;
+ } else {
+ size_t _tmp16_;
+ gchar** _tmp17_ = NULL;
+ gchar** artists;
+ gint artists_length1;
+ gint _artists_size_;
+ gchar* _tmp18_ = NULL;
+ gchar* _tmp19_;
+ _tmp17_ = g_variant_dup_strv (v_artists, &_tmp16_);
+ artists = _tmp17_;
+ artists_length1 = _tmp16_;
+ _artists_size_ = _tmp16_;
+ _tmp18_ = g_strjoinv (", ", artists);
+ _tmp19_ = _tmp18_;
+ _g_free0 (display_artists);
+ display_artists = _tmp19_;
+ artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
+ }
+ _tmp20_ = g_strdup ("xesam:artist");
+ g_hash_table_replace (changed_updates, _tmp20_, _variant_new1 (display_artists));
+ _tmp21_ = g_hash_table_lookup (changed_updates, "xesam:artist");
+ g_debug ("mpris2-controller.vala:132: artist : %s", _variant_get2 ((GVariant*) _tmp21_));
_g_free0 (display_artists);
- artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
- }
- _tmp20_ = mpris_player_get_Metadata (self->priv->_player);
- _tmp21_ = _tmp20_;
- _tmp22_ = g_hash_table_lookup (_tmp21_, "mpris:length");
- _tmp23_ = _g_variant_ref0 ((GVariant*) _tmp22_);
- length_v = (_tmp24_ = _tmp23_, _g_hash_table_unref0 (_tmp21_), _tmp24_);
- if (length_v != NULL) {
- GHashTable* _tmp25_ = NULL;
- GHashTable* _tmp26_;
- gconstpointer _tmp27_ = NULL;
- gint64 _tmp28_;
- gint64 _tmp29_;
- gint64 duration;
- gchar* _tmp30_;
- _tmp25_ = mpris_player_get_Metadata (self->priv->_player);
- _tmp26_ = _tmp25_;
- _tmp27_ = g_hash_table_lookup (_tmp26_, "mpris:length");
- _tmp28_ = g_variant_get_int64 ((GVariant*) _tmp27_);
- duration = (_tmp29_ = _tmp28_, _g_hash_table_unref0 (_tmp26_), _tmp29_);
- _tmp30_ = g_strdup ("mpris:length");
- g_hash_table_replace (changed_updates, _tmp30_, _variant_new4 (duration / 1000000));
+ _g_variant_unref0 (v_artists);
}
result = changed_updates;
- _g_variant_unref0 (length_v);
_g_variant_unref0 (artist_v);
return result;
}
@@ -726,7 +743,7 @@ void mpris2_controller_initial_update (Mpris2Controller* self) {
_g_object_unref0 (_tmp11_);
_g_object_unref0 (_tmp9_);
if (_bool_equal (self->priv->_owner->use_playlists, (_tmp12_ = TRUE, &_tmp12_)) == TRUE) {
- mpris2_controller_fetch_playlists (self);
+ mpris2_controller_fetch_playlists (self, NULL, NULL);
mpris2_controller_fetch_active_playlist (self);
}
_g_hash_table_unref0 (cleaned_metadata);
@@ -735,7 +752,7 @@ void mpris2_controller_initial_update (Mpris2Controller* self) {
void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command) {
g_return_if_fail (self != NULL);
- g_debug ("mpris2-controller.vala:152: transport_event input = %i", (gint) command);
+ g_debug ("mpris2-controller.vala:166: transport_event input = %i", (gint) command);
if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) {
mpris_player_PlayPause (self->priv->_player, NULL, NULL);
} else {
@@ -750,16 +767,65 @@ void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuit
}
-static gboolean* _bool_dup (gboolean* self) {
- gboolean* dup;
- dup = g_new0 (gboolean, 1);
- memcpy (dup, self, sizeof (gboolean));
- return dup;
+gboolean mpris2_controller_connected (Mpris2Controller* self) {
+ gboolean result = FALSE;
+ gboolean _tmp0_ = FALSE;
+ g_return_val_if_fail (self != NULL, FALSE);
+ if (self->priv->_player != NULL) {
+ _tmp0_ = self->priv->_mpris2_root != NULL;
+ } else {
+ _tmp0_ = FALSE;
+ }
+ result = _tmp0_;
+ return result;
}
-static gpointer __bool_dup0 (gpointer self) {
- return self ? _bool_dup (self) : NULL;
+void mpris2_controller_expose (Mpris2Controller* self) {
+ gboolean _tmp0_;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = mpris2_controller_connected (self);
+ if (_tmp0_ == TRUE) {
+ mpris_root_Raise (self->priv->_mpris2_root, NULL, NULL);
+ }
+}
+
+
+static void mpris2_controller_fetch_playlists_data_free (gpointer _data) {
+ Mpris2ControllerFetchPlaylistsData* data;
+ data = _data;
+ _g_object_unref0 (data->self);
+ g_slice_free (Mpris2ControllerFetchPlaylistsData, data);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+void mpris2_controller_fetch_playlists (Mpris2Controller* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ Mpris2ControllerFetchPlaylistsData* _data_;
+ _data_ = g_slice_new0 (Mpris2ControllerFetchPlaylistsData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, mpris2_controller_fetch_playlists);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, mpris2_controller_fetch_playlists_data_free);
+ _data_->self = _g_object_ref0 (self);
+ mpris2_controller_fetch_playlists_co (_data_);
+}
+
+
+void mpris2_controller_fetch_playlists_finish (Mpris2Controller* self, GAsyncResult* _res_) {
+ Mpris2ControllerFetchPlaylistsData* _data_;
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static void mpris2_controller_fetch_playlists_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ Mpris2ControllerFetchPlaylistsData* data;
+ data = _user_data_;
+ data->_source_object_ = source_object;
+ data->_res_ = _res_;
+ mpris2_controller_fetch_playlists_co (data);
}
@@ -774,47 +840,101 @@ static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array
}
-void mpris2_controller_fetch_playlists (Mpris2Controller* self) {
- gint _tmp0_;
- PlaylistDetails* _tmp1_ = NULL;
- gint current_playlists_length1;
- gint _current_playlists_size_;
- PlaylistDetails* _tmp2_;
- PlaylistDetails* current_playlists;
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- _tmp1_ = mpris_playlists_GetPlaylists (self->priv->_playlists, (guint32) 0, (guint32) 10, "Alphabetical", FALSE, &_tmp0_, &_inner_error_);
- _tmp2_ = _tmp1_;
- current_playlists_length1 = _tmp0_;
- _current_playlists_size_ = current_playlists_length1;
- current_playlists = _tmp2_;
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
+static gboolean* _bool_dup (gboolean* self) {
+ gboolean* dup;
+ dup = g_new0 (gboolean, 1);
+ memcpy (dup, self, sizeof (gboolean));
+ return dup;
+}
+
+
+static gpointer __bool_dup0 (gpointer self) {
+ return self ? _bool_dup (self) : NULL;
+}
+
+
+static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlaylistsData* data) {
+ switch (data->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ default:
+ g_assert_not_reached ();
}
- if (current_playlists != NULL) {
- gpointer _tmp3_ = NULL;
- PlayerItem* _tmp4_;
- PlaylistsMenuitem* playlists_item;
- g_debug ("mpris2-controller.vala:171: Size of the playlist array = %i", current_playlists_length1);
- _tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS);
- playlists_item = (_tmp4_ = (PlayerItem*) _tmp3_, IS_PLAYLISTS_MENUITEM (_tmp4_) ? ((PlaylistsMenuitem*) _tmp4_) : NULL);
- playlists_menuitem_update (playlists_item, current_playlists, current_playlists_length1);
- _g_object_unref0 (playlists_item);
+ _state_0:
+ data->current_playlists = NULL;
+ data->current_playlists_length1 = 0;
+ data->_current_playlists_size_ = 0;
+ data->_state_ = 1;
+ mpris_playlists_GetPlaylists (data->self->priv->_playlists, (guint32) 0, (guint32) 10, "Alphabetical", FALSE, mpris2_controller_fetch_playlists_ready, data);
+ return FALSE;
+ _state_1:
+ data->_tmp1_ = NULL;
+ data->_tmp1_ = mpris_playlists_GetPlaylists_finish (data->self->priv->_playlists, data->_res_, &data->_tmp0_, &data->_inner_error_);
+ data->_tmp2_ = data->_tmp1_;
+ data->_tmp2__length1 = data->_tmp0_;
+ data->__tmp2__size_ = data->_tmp0_;
+ if (data->_inner_error_ != NULL) {
+ if (data->_inner_error_->domain == G_IO_ERROR) {
+ goto __catch11_g_io_error;
+ }
+ data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL);
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code);
+ g_clear_error (&data->_inner_error_);
+ return FALSE;
+ }
+ data->_tmp3_ = data->_tmp2_;
+ data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL);
+ data->current_playlists_length1 = data->_tmp2__length1;
+ data->_current_playlists_size_ = data->current_playlists_length1;
+ data->current_playlists = data->_tmp3_;
+ goto __finally11;
+ __catch11_g_io_error:
+ {
+ data->e = data->_inner_error_;
+ data->_inner_error_ = NULL;
+ g_debug ("mpris2-controller.vala:202: Could not fetch playlists because %s", data->e->message);
+ _g_error_free0 (data->e);
+ data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL);
+ if (data->_state_ == 0) {
+ g_simple_async_result_complete_in_idle (data->_async_result);
+ } else {
+ g_simple_async_result_complete (data->_async_result);
+ }
+ g_object_unref (data->_async_result);
+ return FALSE;
+ }
+ __finally11:
+ if (data->_inner_error_ != NULL) {
+ data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL);
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code);
+ g_clear_error (&data->_inner_error_);
+ return FALSE;
+ }
+ if (data->current_playlists != NULL) {
+ g_debug ("mpris2-controller.vala:207: Size of the playlist array = %i", data->current_playlists_length1);
+ data->_tmp4_ = NULL;
+ data->_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) data->self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS);
+ data->playlists_item = (data->_tmp5_ = (PlayerItem*) data->_tmp4_, IS_PLAYLISTS_MENUITEM (data->_tmp5_) ? ((PlaylistsMenuitem*) data->_tmp5_) : NULL);
+ playlists_menuitem_update (data->playlists_item, data->current_playlists, data->current_playlists_length1);
+ _g_object_unref0 (data->playlists_item);
} else {
- gboolean _tmp5_;
- gboolean* _tmp6_;
- gboolean* _tmp7_;
- g_warning ("mpris2-controller.vala:176: Playlists are on but its returning no cur" \
+ g_warning ("mpris2-controller.vala:212: Playlists are on but its returning no cur" \
"rent_playlists");
- _tmp6_ = __bool_dup0 ((_tmp5_ = FALSE, &_tmp5_));
- _tmp7_ = _tmp6_;
- _g_free0 (self->priv->_owner->use_playlists);
- self->priv->_owner->use_playlists = _tmp7_;
+ data->_tmp7_ = __bool_dup0 ((data->_tmp6_ = FALSE, &data->_tmp6_));
+ data->_tmp8_ = data->_tmp7_;
+ _g_free0 (data->self->priv->_owner->use_playlists);
+ data->self->priv->_owner->use_playlists = data->_tmp8_;
+ }
+ data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL);
+ if (data->_state_ == 0) {
+ g_simple_async_result_complete_in_idle (data->_async_result);
+ } else {
+ g_simple_async_result_complete (data->_async_result);
}
- current_playlists = (_vala_PlaylistDetails_array_free (current_playlists, current_playlists_length1), NULL);
- return;
+ g_object_unref (data->_async_result);
+ return FALSE;
}
@@ -831,7 +951,7 @@ static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self) {
mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp0_);
_tmp1_ = _tmp0_;
if ((_tmp2_ = _tmp1_.valid == FALSE, active_playlist_container_destroy (&_tmp1_), _tmp2_)) {
- g_debug ("mpris2-controller.vala:185: We don't have an active playlist");
+ g_debug ("mpris2-controller.vala:220: We don't have an active playlist");
}
_tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS);
playlists_item = (_tmp4_ = (PlayerItem*) _tmp3_, IS_PLAYLISTS_MENUITEM (_tmp4_) ? ((PlaylistsMenuitem*) _tmp4_) : NULL);
@@ -843,45 +963,21 @@ static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self) {
}
-gboolean mpris2_controller_connected (Mpris2Controller* self) {
- gboolean result = FALSE;
- gboolean _tmp0_ = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- if (self->priv->_player != NULL) {
- _tmp0_ = self->priv->_mpris2_root != NULL;
- } else {
- _tmp0_ = FALSE;
- }
- result = _tmp0_;
- return result;
-}
-
-
-void mpris2_controller_expose (Mpris2Controller* self) {
- gboolean _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = mpris2_controller_connected (self);
- if (_tmp0_ == TRUE) {
- mpris_root_Raise (self->priv->_mpris2_root, NULL, NULL);
- }
-}
-
-
void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* path) {
GError * _inner_error_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (path != NULL);
mpris_playlists_ActivatePlaylist (self->priv->_playlists, path, NULL, NULL);
- goto __finally11;
- __catch11_g_io_error:
+ goto __finally12;
+ __catch12_g_io_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- g_debug ("mpris2-controller.vala:210: Could not activate playlist %s because %s", (const gchar*) path, e->message);
+ g_debug ("mpris2-controller.vala:232: Could not activate playlist %s because %s", (const gchar*) path, e->message);
_g_error_free0 (e);
}
- __finally11:
+ __finally12:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -898,11 +994,6 @@ MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self) {
}
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
-}
-
-
static void mpris2_controller_set_mpris2_root (Mpris2Controller* self, MprisRoot* value) {
MprisRoot* _tmp0_;
MprisRoot* _tmp1_;
@@ -1028,7 +1119,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
_tmp3_ = (MprisRoot*) _tmp2_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
- goto __catch12_g_io_error;
+ goto __catch13_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -1042,7 +1133,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
_tmp8_ = (MprisPlayer*) _tmp7_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
- goto __catch12_g_io_error;
+ goto __catch13_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -1062,7 +1153,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
_tmp14_ = (MprisPlaylists*) _tmp13_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
- goto __catch12_g_io_error;
+ goto __catch13_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -1075,7 +1166,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
_tmp17_ = (FreeDesktopProperties*) _tmp16_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
- goto __catch12_g_io_error;
+ goto __catch13_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -1084,8 +1175,8 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
mpris2_controller_set_properties_interface (self, _tmp18_);
_g_object_unref0 (_tmp18_);
g_signal_connect_object (self->priv->_properties_interface, "properties-changed", (GCallback) _mpris2_controller_property_changed_cb_free_desktop_properties_properties_changed, self, 0);
- goto __finally12;
- __catch12_g_io_error:
+ goto __finally13;
+ __catch13_g_io_error:
{
GError * e;
e = _inner_error_;
@@ -1093,7 +1184,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
g_error ("mpris2-controller.vala:58: Problems connecting to the session bus - %s", e->message);
_g_error_free0 (e);
}
- __finally12:
+ __finally13:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index fc61c12..03571e6 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -93,6 +93,16 @@ public class Mpris2Controller : GLib.Object
if ( playlist_v != null && this.owner.use_playlists == true ){
this.fetch_active_playlist();
}
+ Variant? playlist_count_v = changed_properties.lookup("PlaylistCount");
+ if ( playlist_count_v != null && this.owner.use_playlists == true ){
+ this.fetch_playlists.begin();
+ this.fetch_active_playlist();
+ }
+ Variant? playlist_orderings_v = changed_properties.lookup("Orderings");
+ if ( playlist_orderings_v != null && this.owner.use_playlists == true ){
+ this.fetch_playlists.begin();
+ this.fetch_active_playlist();
+ }
}
private bool ensure_correct_playback_status(){
@@ -107,16 +117,20 @@ public class Mpris2Controller : GLib.Object
GLib.HashTable<string, Variant?> changed_updates = this.player.Metadata;
Variant? artist_v = this.player.Metadata.lookup("xesam:artist");
if(artist_v != null){
- string[] artists = (string[])this.player.Metadata.lookup("xesam:artist");
- string display_artists = string.joinv(", ", artists);
+ Variant? v_artists = this.player.Metadata.lookup("xesam:artist");
+ debug("artists is of type %s", v_artists.get_type_string ());
+ string display_artists;
+ if(v_artists.get_type_string() == "s"){
+ debug("SPOTIFY is that you ?");
+ display_artists = v_artists.get_string();
+ }
+ else{
+ string[] artists = v_artists.dup_strv();
+ display_artists = string.joinv(", ", artists);
+ }
changed_updates.replace("xesam:artist", display_artists);
debug("artist : %s", (string)changed_updates.lookup("xesam:artist"));
}
- Variant? length_v = this.player.Metadata.lookup("mpris:length");
- if(length_v != null){
- int64 duration = this.player.Metadata.lookup("mpris:length").get_int64();
- changed_updates.replace("mpris:length", duration/1000000);
- }
return changed_updates;
}
@@ -142,7 +156,7 @@ public class Mpris2Controller : GLib.Object
MetadataMenuitem.attributes_format());
if ( this.owner.use_playlists == true ){
- this.fetch_playlists();
+ this.fetch_playlists.begin();
this.fetch_active_playlist();
}
}
@@ -161,12 +175,34 @@ public class Mpris2Controller : GLib.Object
}
}
- public void fetch_playlists()
+
+ public bool connected()
+ {
+ return (this.player != null && this.mpris2_root != null);
+ }
+
+ public void expose()
{
- PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0,
- 10,
- "Alphabetical",
- false);
+ if(this.connected() == true){
+ this.mpris2_root.Raise.begin();
+ }
+ }
+
+ public async void fetch_playlists()
+ {
+ PlaylistDetails[] current_playlists = null;
+
+ try{
+ current_playlists = yield this.playlists.GetPlaylists (0,
+ 10,
+ "Alphabetical",
+ false);
+ }
+ catch (IOError e){
+ debug("Could not fetch playlists because %s", e.message);
+ return;
+ }
+
if( current_playlists != null ){
debug( "Size of the playlist array = %i", current_playlists.length );
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
@@ -176,7 +212,6 @@ public class Mpris2Controller : GLib.Object
warning(" Playlists are on but its returning no current_playlists" );
this.owner.use_playlists = false;
}
- return;
}
private void fetch_active_playlist()
@@ -188,19 +223,6 @@ public class Mpris2Controller : GLib.Object
playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details );
}
-
- public bool connected()
- {
- return (this.player != null && this.mpris2_root != null);
- }
-
- public void expose()
- {
- if(this.connected() == true){
- this.mpris2_root.Raise.begin();
- }
- }
-
public void activate_playlist (ObjectPath path)
{
try{
diff --git a/src/mpris2-interfaces.c b/src/mpris2-interfaces.c
index 6f18596..90941fa 100644
--- a/src/mpris2-interfaces.c
+++ b/src/mpris2-interfaces.c
@@ -1,4 +1,4 @@
-/* mpris2-interfaces.c generated by valac 0.11.3, the Vala compiler
+/* mpris2-interfaces.c generated by valac 0.11.5, the Vala compiler
* generated from mpris2-interfaces.vala, do not modify */
/*
@@ -119,7 +119,8 @@ struct _MprisPlaylistsIface {
GTypeInterface parent_iface;
void (*ActivatePlaylist) (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
void (*ActivatePlaylist_finish) (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
- PlaylistDetails* (*GetPlaylists) (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+ void (*GetPlaylists) (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ PlaylistDetails* (*GetPlaylists_finish) (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
gchar** (*get_Orderings) (MprisPlaylists* self, int* result_length1);
void (*set_Orderings) (MprisPlaylists* self, gchar** value, int value_length1);
guint32 (*get_PlaylistCount) (MprisPlaylists* self);
@@ -247,7 +248,8 @@ guint mpris_playlists_register_object (void* object, GDBusConnection* connection
GType mpris_playlists_get_type (void) G_GNUC_CONST;
void mpris_playlists_ActivatePlaylist (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
void mpris_playlists_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
-PlaylistDetails* mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+void mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+PlaylistDetails* mpris_playlists_GetPlaylists_finish (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
gchar** mpris_playlists_get_Orderings (MprisPlaylists* self, int* result_length1);
void mpris_playlists_set_Orderings (MprisPlaylists* self, gchar** value, int value_length1);
guint32 mpris_playlists_get_PlaylistCount (MprisPlaylists* self);
@@ -257,7 +259,8 @@ void mpris_playlists_set_ActivePlaylist (MprisPlaylists* self, ActivePlaylistCon
static void mpris_playlists_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters);
static void mpris_playlists_proxy_ActivatePlaylist_async (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void mpris_playlists_proxy_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
-static PlaylistDetails* mpris_playlists_proxy_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+static void mpris_playlists_proxy_GetPlaylists_async (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static PlaylistDetails* mpris_playlists_proxy_GetPlaylists_finish (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
static gchar** mpris_playlists_dbus_proxy_get_Orderings (MprisPlaylists* self, int* result_length1);
static void mpris_playlists_dbus_proxy_set_Orderings (MprisPlaylists* self, gchar** value, int value_length1);
static guint32 mpris_playlists_dbus_proxy_get_PlaylistCount (MprisPlaylists* self);
@@ -267,8 +270,9 @@ static void mpris_playlists_dbus_proxy_set_ActivePlaylist (MprisPlaylists* self,
static void mpris_playlists_proxy_mpris_playlists_interface_init (MprisPlaylistsIface* iface);
static void _dbus_mpris_playlists_ActivatePlaylist (MprisPlaylists* self, GVariant* parameters, GDBusMethodInvocation* invocation);
static void _dbus_mpris_playlists_ActivatePlaylist_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_);
-static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length);
static void _dbus_mpris_playlists_GetPlaylists (MprisPlaylists* self, GVariant* parameters, GDBusMethodInvocation* invocation);
+static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length);
+static void _dbus_mpris_playlists_GetPlaylists_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_);
static void mpris_playlists_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
static GVariant* mpris_playlists_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
static GVariant* _dbus_mpris_playlists_get_Orderings (MprisPlaylists* self);
@@ -413,12 +417,6 @@ static void mpris_root_base_init (MprisRootIface * iface) {
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
- g_object_interface_install_property (iface, g_param_spec_boolean ("HasTracklist", "HasTracklist", "HasTracklist", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_boolean ("CanQuit", "CanQuit", "CanQuit", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_boolean ("CanRaise", "CanRaise", "CanRaise", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_string ("Identity", "Identity", "Identity", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_string ("DesktopEntry", "DesktopEntry", "DesktopEntry", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_type_set_qdata (TYPE_MPRIS_ROOT, g_quark_from_static_string ("vala-dbus-register-object"), (void*) mpris_root_register_object);
}
}
@@ -430,6 +428,9 @@ GType mpris_root_get_type (void) {
GType mpris_root_type_id;
mpris_root_type_id = g_type_register_static (G_TYPE_INTERFACE, "MprisRoot", &g_define_type_info, 0);
g_type_interface_add_prerequisite (mpris_root_type_id, G_TYPE_OBJECT);
+ g_type_set_qdata (mpris_root_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) mpris_root_proxy_get_type);
+ g_type_set_qdata (mpris_root_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.mpris.MediaPlayer2");
+ g_type_set_qdata (mpris_root_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) mpris_root_register_object);
g_once_init_leave (&mpris_root_type_id__volatile, mpris_root_type_id);
}
return mpris_root_type_id__volatile;
@@ -754,21 +755,20 @@ static void mpris_root_proxy_mpris_root_interface_init (MprisRootIface* iface) {
static void _dbus_mpris_root_Quit (MprisRoot* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GVariantIter _arguments_iter;
g_variant_iter_init (&_arguments_iter, parameters);
- mpris_root_Quit (self, (GAsyncReadyCallback) _dbus_mpris_root_Quit_ready, g_object_ref (invocation));
+ mpris_root_Quit (self, (GAsyncReadyCallback) _dbus_mpris_root_Quit_ready, invocation);
}
static void _dbus_mpris_root_Quit_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
invocation = _user_data_;
- error = NULL;
mpris_root_Quit_finish ((MprisRoot*) source_object, _res_, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -784,21 +784,20 @@ static void _dbus_mpris_root_Quit_ready (GObject * source_object, GAsyncResult *
static void _dbus_mpris_root_Raise (MprisRoot* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GVariantIter _arguments_iter;
g_variant_iter_init (&_arguments_iter, parameters);
- mpris_root_Raise (self, (GAsyncReadyCallback) _dbus_mpris_root_Raise_ready, g_object_ref (invocation));
+ mpris_root_Raise (self, (GAsyncReadyCallback) _dbus_mpris_root_Raise_ready, invocation);
}
static void _dbus_mpris_root_Raise_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
invocation = _user_data_;
- error = NULL;
mpris_root_Raise_finish ((MprisRoot*) source_object, _res_, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -820,8 +819,9 @@ static void mpris_root_dbus_interface_method_call (GDBusConnection* connection,
_dbus_mpris_root_Quit (object, parameters, invocation);
} else if (strcmp (method_name, "Raise") == 0) {
_dbus_mpris_root_Raise (object, parameters, invocation);
+ } else {
+ g_object_unref (invocation);
}
- g_object_unref (invocation);
}
@@ -857,7 +857,7 @@ static GVariant* _dbus_mpris_root_get_Identity (MprisRoot* self) {
GVariant* _reply;
result = mpris_root_get_Identity (self);
_reply = g_variant_new_string (result);
- _g_free0 (result);
+ _g_free0 ( result);
return _reply;
}
@@ -867,7 +867,7 @@ static GVariant* _dbus_mpris_root_get_DesktopEntry (MprisRoot* self) {
GVariant* _reply;
result = mpris_root_get_DesktopEntry (self);
_reply = g_variant_new_string (result);
- _g_free0 (result);
+ _g_free0 ( result);
return _reply;
}
@@ -1062,11 +1062,7 @@ static void mpris_player_base_init (MprisPlayerIface * iface) {
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
- g_object_interface_install_property (iface, g_param_spec_boxed ("Metadata", "Metadata", "Metadata", G_TYPE_HASH_TABLE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_int ("Position", "Position", "Position", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_string ("PlaybackStatus", "PlaybackStatus", "PlaybackStatus", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_signal_new ("seeked", TYPE_MPRIS_PLAYER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
- g_type_set_qdata (TYPE_MPRIS_PLAYER, g_quark_from_static_string ("vala-dbus-register-object"), (void*) mpris_player_register_object);
}
}
@@ -1078,6 +1074,9 @@ GType mpris_player_get_type (void) {
GType mpris_player_type_id;
mpris_player_type_id = g_type_register_static (G_TYPE_INTERFACE, "MprisPlayer", &g_define_type_info, 0);
g_type_interface_add_prerequisite (mpris_player_type_id, G_TYPE_OBJECT);
+ g_type_set_qdata (mpris_player_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) mpris_player_proxy_get_type);
+ g_type_set_qdata (mpris_player_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.mpris.MediaPlayer2.Player");
+ g_type_set_qdata (mpris_player_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) mpris_player_register_object);
g_once_init_leave (&mpris_player_type_id__volatile, mpris_player_type_id);
}
return mpris_player_type_id__volatile;
@@ -1370,21 +1369,20 @@ static void mpris_player_proxy_mpris_player_interface_init (MprisPlayerIface* if
static void _dbus_mpris_player_PlayPause (MprisPlayer* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GVariantIter _arguments_iter;
g_variant_iter_init (&_arguments_iter, parameters);
- mpris_player_PlayPause (self, (GAsyncReadyCallback) _dbus_mpris_player_PlayPause_ready, g_object_ref (invocation));
+ mpris_player_PlayPause (self, (GAsyncReadyCallback) _dbus_mpris_player_PlayPause_ready, invocation);
}
static void _dbus_mpris_player_PlayPause_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
invocation = _user_data_;
- error = NULL;
mpris_player_PlayPause_finish ((MprisPlayer*) source_object, _res_, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -1400,21 +1398,20 @@ static void _dbus_mpris_player_PlayPause_ready (GObject * source_object, GAsyncR
static void _dbus_mpris_player_Next (MprisPlayer* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GVariantIter _arguments_iter;
g_variant_iter_init (&_arguments_iter, parameters);
- mpris_player_Next (self, (GAsyncReadyCallback) _dbus_mpris_player_Next_ready, g_object_ref (invocation));
+ mpris_player_Next (self, (GAsyncReadyCallback) _dbus_mpris_player_Next_ready, invocation);
}
static void _dbus_mpris_player_Next_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
invocation = _user_data_;
- error = NULL;
mpris_player_Next_finish ((MprisPlayer*) source_object, _res_, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -1430,21 +1427,20 @@ static void _dbus_mpris_player_Next_ready (GObject * source_object, GAsyncResult
static void _dbus_mpris_player_Previous (MprisPlayer* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GVariantIter _arguments_iter;
g_variant_iter_init (&_arguments_iter, parameters);
- mpris_player_Previous (self, (GAsyncReadyCallback) _dbus_mpris_player_Previous_ready, g_object_ref (invocation));
+ mpris_player_Previous (self, (GAsyncReadyCallback) _dbus_mpris_player_Previous_ready, invocation);
}
static void _dbus_mpris_player_Previous_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
invocation = _user_data_;
- error = NULL;
mpris_player_Previous_finish ((MprisPlayer*) source_object, _res_, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -1468,8 +1464,9 @@ static void mpris_player_dbus_interface_method_call (GDBusConnection* connection
_dbus_mpris_player_Next (object, parameters, invocation);
} else if (strcmp (method_name, "Previous") == 0) {
_dbus_mpris_player_Previous (object, parameters, invocation);
+ } else {
+ g_object_unref (invocation);
}
- g_object_unref (invocation);
}
@@ -1491,7 +1488,7 @@ static GVariant* _dbus_mpris_player_get_Metadata (MprisPlayer* self) {
g_variant_builder_add (&_tmp9_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
}
_reply = g_variant_builder_end (&_tmp9_);
- _g_hash_table_unref0 (result);
+ _g_hash_table_unref0 ( result);
return _reply;
}
@@ -1510,7 +1507,7 @@ static GVariant* _dbus_mpris_player_get_PlaybackStatus (MprisPlayer* self) {
GVariant* _reply;
result = mpris_player_get_PlaybackStatus (self);
_reply = g_variant_new_string (result);
- _g_free0 (result);
+ _g_free0 ( result);
return _reply;
}
@@ -1708,8 +1705,13 @@ void mpris_playlists_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult
}
-PlaylistDetails* mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error) {
- return MPRIS_PLAYLISTS_GET_INTERFACE (self)->GetPlaylists (self, index, max_count, order, reverse_order, result_length1, error);
+void mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ MPRIS_PLAYLISTS_GET_INTERFACE (self)->GetPlaylists (self, index, max_count, order, reverse_order, _callback_, _user_data_);
+}
+
+
+PlaylistDetails* mpris_playlists_GetPlaylists_finish (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error) {
+ return MPRIS_PLAYLISTS_GET_INTERFACE (self)->GetPlaylists_finish (self, _res_, result_length1, error);
}
@@ -1747,10 +1749,6 @@ static void mpris_playlists_base_init (MprisPlaylistsIface * iface) {
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
- g_object_interface_install_property (iface, g_param_spec_boxed ("Orderings", "Orderings", "Orderings", G_TYPE_STRV, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_uint ("PlaylistCount", "PlaylistCount", "PlaylistCount", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_object_interface_install_property (iface, g_param_spec_boxed ("ActivePlaylist", "ActivePlaylist", "ActivePlaylist", TYPE_ACTIVE_PLAYLIST_CONTAINER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
- g_type_set_qdata (TYPE_MPRIS_PLAYLISTS, g_quark_from_static_string ("vala-dbus-register-object"), (void*) mpris_playlists_register_object);
}
}
@@ -1762,6 +1760,9 @@ GType mpris_playlists_get_type (void) {
GType mpris_playlists_type_id;
mpris_playlists_type_id = g_type_register_static (G_TYPE_INTERFACE, "MprisPlaylists", &g_define_type_info, 0);
g_type_interface_add_prerequisite (mpris_playlists_type_id, G_TYPE_OBJECT);
+ g_type_set_qdata (mpris_playlists_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) mpris_playlists_proxy_get_type);
+ g_type_set_qdata (mpris_playlists_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.mpris.MediaPlayer2.Playlists");
+ g_type_set_qdata (mpris_playlists_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) mpris_playlists_register_object);
g_once_init_leave (&mpris_playlists_type_id__volatile, mpris_playlists_type_id);
}
return mpris_playlists_type_id__volatile;
@@ -1811,10 +1812,25 @@ static void mpris_playlists_proxy_ActivatePlaylist_finish (MprisPlaylists* self,
}
-static PlaylistDetails* mpris_playlists_proxy_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error) {
+static void mpris_playlists_proxy_GetPlaylists_async (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_) {
GDBusMessage *_message;
GVariant *_arguments;
GVariantBuilder _arguments_builder;
+ G_IO_ERROR;
+ _message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.mpris.MediaPlayer2.Playlists", "GetPlaylists");
+ g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
+ g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (index));
+ g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (max_count));
+ g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (order));
+ g_variant_builder_add_value (&_arguments_builder, g_variant_new_boolean (reverse_order));
+ _arguments = g_variant_builder_end (&_arguments_builder);
+ g_dbus_message_set_body (_message, _arguments);
+ g_dbus_connection_send_message_with_reply (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, _vala_g_async_ready_callback, g_simple_async_result_new ((GObject *) self, _callback_, _user_data_, NULL));
+ g_object_unref (_message);
+}
+
+
+static PlaylistDetails* mpris_playlists_proxy_GetPlaylists_finish (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error) {
GDBusMessage *_reply_message;
GVariant *_reply;
GVariantIter _reply_iter;
@@ -1827,17 +1843,7 @@ static PlaylistDetails* mpris_playlists_proxy_GetPlaylists (MprisPlaylists* self
int _tmp18__length1;
GVariantIter _tmp19_;
GVariant* _tmp20_;
- G_IO_ERROR;
- _message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.mpris.MediaPlayer2.Playlists", "GetPlaylists");
- g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (index));
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (max_count));
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (order));
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_boolean (reverse_order));
- _arguments = g_variant_builder_end (&_arguments_builder);
- g_dbus_message_set_body (_message, _arguments);
- _reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
- g_object_unref (_message);
+ _reply_message = g_dbus_connection_send_message_with_reply_finish (g_dbus_proxy_get_connection ((GDBusProxy *) self), g_simple_async_result_get_op_res_gpointer ((GSimpleAsyncResult *) _res_), error);
if (!_reply_message) {
return NULL;
}
@@ -2088,7 +2094,8 @@ static void mpris_playlists_dbus_proxy_set_ActivePlaylist (MprisPlaylists* self,
static void mpris_playlists_proxy_mpris_playlists_interface_init (MprisPlaylistsIface* iface) {
iface->ActivatePlaylist = mpris_playlists_proxy_ActivatePlaylist_async;
iface->ActivatePlaylist_finish = mpris_playlists_proxy_ActivatePlaylist_finish;
- iface->GetPlaylists = mpris_playlists_proxy_GetPlaylists;
+ iface->GetPlaylists = mpris_playlists_proxy_GetPlaylists_async;
+ iface->GetPlaylists_finish = mpris_playlists_proxy_GetPlaylists_finish;
iface->get_Orderings = mpris_playlists_dbus_proxy_get_Orderings;
iface->set_Orderings = mpris_playlists_dbus_proxy_set_Orderings;
iface->get_PlaylistCount = mpris_playlists_dbus_proxy_get_PlaylistCount;
@@ -2106,22 +2113,21 @@ static void _dbus_mpris_playlists_ActivatePlaylist (MprisPlaylists* self, GVaria
_tmp43_ = g_variant_iter_next_value (&_arguments_iter);
playlist_id = g_variant_dup_string (_tmp43_, NULL);
g_variant_unref (_tmp43_);
- mpris_playlists_ActivatePlaylist (self, playlist_id, (GAsyncReadyCallback) _dbus_mpris_playlists_ActivatePlaylist_ready, g_object_ref (invocation));
+ mpris_playlists_ActivatePlaylist (self, playlist_id, (GAsyncReadyCallback) _dbus_mpris_playlists_ActivatePlaylist_ready, invocation);
_g_free0 (playlist_id);
}
static void _dbus_mpris_playlists_ActivatePlaylist_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
GDBusMethodInvocation * invocation;
- GError* error;
+ GError* error = NULL;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
invocation = _user_data_;
- error = NULL;
mpris_playlists_ActivatePlaylist_finish ((MprisPlaylists*) source_object, _res_, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -2134,19 +2140,7 @@ static void _dbus_mpris_playlists_ActivatePlaylist_ready (GObject * source_objec
}
-static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length) {
- if (array != NULL) {
- int i;
- for (i = 0; i < array_length; i = i + 1) {
- playlist_details_destroy (&array[i]);
- }
- }
- g_free (array);
-}
-
-
static void _dbus_mpris_playlists_GetPlaylists (MprisPlaylists* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
- GError* error;
GVariantIter _arguments_iter;
guint32 index = 0U;
GVariant* _tmp44_;
@@ -2156,15 +2150,6 @@ static void _dbus_mpris_playlists_GetPlaylists (MprisPlaylists* self, GVariant*
GVariant* _tmp46_;
gboolean reverse_order = FALSE;
GVariant* _tmp47_;
- GDBusMessage* _reply_message;
- GVariant* _reply;
- GVariantBuilder _reply_builder;
- PlaylistDetails* result;
- int result_length1 = 0;
- PlaylistDetails* _tmp48_;
- GVariantBuilder _tmp49_;
- int _tmp50_;
- error = NULL;
g_variant_iter_init (&_arguments_iter, parameters);
_tmp44_ = g_variant_iter_next_value (&_arguments_iter);
index = g_variant_get_uint32 (_tmp44_);
@@ -2178,9 +2163,37 @@ static void _dbus_mpris_playlists_GetPlaylists (MprisPlaylists* self, GVariant*
_tmp47_ = g_variant_iter_next_value (&_arguments_iter);
reverse_order = g_variant_get_boolean (_tmp47_);
g_variant_unref (_tmp47_);
- result = mpris_playlists_GetPlaylists (self, index, max_count, order, reverse_order, &result_length1, &error);
+ mpris_playlists_GetPlaylists (self, index, max_count, order, reverse_order, (GAsyncReadyCallback) _dbus_mpris_playlists_GetPlaylists_ready, invocation);
+ _g_free0 (order);
+}
+
+
+static void _vala_PlaylistDetails_array_free (PlaylistDetails* array, gint array_length) {
+ if (array != NULL) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ playlist_details_destroy (&array[i]);
+ }
+ }
+ g_free (array);
+}
+
+
+static void _dbus_mpris_playlists_GetPlaylists_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) {
+ GDBusMethodInvocation * invocation;
+ GError* error = NULL;
+ GDBusMessage* _reply_message;
+ GVariant* _reply;
+ GVariantBuilder _reply_builder;
+ PlaylistDetails* result;
+ int result_length1 = 0;
+ PlaylistDetails* _tmp48_;
+ GVariantBuilder _tmp49_;
+ int _tmp50_;
+ invocation = _user_data_;
+ result = mpris_playlists_GetPlaylists_finish ((MprisPlaylists*) source_object, _res_, &result_length1, &error);
if (error) {
- g_dbus_method_invocation_return_gerror (g_object_ref (invocation), error);
+ g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
@@ -2197,11 +2210,11 @@ static void _dbus_mpris_playlists_GetPlaylists (MprisPlaylists* self, GVariant*
_tmp48_++;
}
g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp49_));
- result = (_vala_PlaylistDetails_array_free (result, result_length1), NULL);
+ result = (_vala_PlaylistDetails_array_free ( result, result_length1), NULL);
_reply = g_variant_builder_end (&_reply_builder);
g_dbus_message_set_body (_reply_message, _reply);
- _g_free0 (order);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+ g_object_unref (invocation);
g_object_unref (_reply_message);
}
@@ -2215,8 +2228,9 @@ static void mpris_playlists_dbus_interface_method_call (GDBusConnection* connect
_dbus_mpris_playlists_ActivatePlaylist (object, parameters, invocation);
} else if (strcmp (method_name, "GetPlaylists") == 0) {
_dbus_mpris_playlists_GetPlaylists (object, parameters, invocation);
+ } else {
+ g_object_unref (invocation);
}
- g_object_unref (invocation);
}
@@ -2235,7 +2249,7 @@ static GVariant* _dbus_mpris_playlists_get_Orderings (MprisPlaylists* self) {
_tmp52_++;
}
_reply = g_variant_builder_end (&_tmp53_);
- result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL);
+ result = (_vala_array_free ( result, result_length1, (GDestroyNotify) g_free), NULL);
return _reply;
}
@@ -2263,7 +2277,7 @@ static GVariant* _dbus_mpris_playlists_get_ActivePlaylist (MprisPlaylists* self)
g_variant_builder_add_value (&_tmp56_, g_variant_new_string (result.details.icon_path));
g_variant_builder_add_value (&_tmp55_, g_variant_builder_end (&_tmp56_));
_reply = g_variant_builder_end (&_tmp55_);
- active_playlist_container_destroy (&result);
+ active_playlist_container_destroy (& result);
return _reply;
}
diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala
index 9d0b8c9..0a0909f 100644
--- a/src/mpris2-interfaces.vala
+++ b/src/mpris2-interfaces.vala
@@ -68,8 +68,8 @@ public interface MprisPlaylists : Object {
//methods
public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;
- public abstract PlaylistDetails[] GetPlaylists ( uint32 index,
- uint32 max_count,
- string order,
- bool reverse_order ) throws IOError;
+ public abstract async PlaylistDetails[] GetPlaylists ( uint32 index,
+ uint32 max_count,
+ string order,
+ bool reverse_order ) throws IOError;
} \ No newline at end of file
diff --git a/src/mpris2-watcher.c b/src/mpris2-watcher.c
index 0cdefb4..c000e87 100644
--- a/src/mpris2-watcher.c
+++ b/src/mpris2-watcher.c
@@ -1,4 +1,4 @@
-/* mpris2-watcher.c generated by valac 0.11.3, the Vala compiler
+/* mpris2-watcher.c generated by valac 0.11.5, the Vala compiler
* generated from mpris2-watcher.vala, do not modify */
/*
@@ -117,29 +117,28 @@ struct _Mpris2WatcherCheckForActiveClientsData {
GAsyncResult* _res_;
GSimpleAsyncResult* _async_result;
Mpris2Watcher* self;
+ gchar** interfaces;
gint interfaces_length1;
gint _interfaces_size_;
- gchar** interfaces;
gint _tmp0_;
gchar** _tmp1_;
+ gchar** _tmp2_;
gint _tmp2__length1;
gint __tmp2__size_;
gchar** _tmp3_;
- gchar** _tmp2_;
- gchar** _tmp4_;
GError * e;
gchar** address_collection;
int address_collection_length1;
int address_it;
- gchar* _tmp5_;
+ gchar* _tmp4_;
gchar* address;
- gboolean _tmp6_;
- MprisRoot* _tmp7_;
+ gboolean _tmp5_;
+ MprisRoot* _tmp6_;
MprisRoot* mpris2_root;
- gboolean _tmp8_;
+ gboolean _tmp7_;
gboolean use_playlists;
+ gchar* _tmp8_;
gchar* _tmp9_;
- gchar* _tmp10_;
GError * _inner_error_;
};
@@ -253,16 +252,16 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo
}
_state_0:
data->interfaces_length1 = 0;
+ data->_interfaces_size_ = 0;
data->_state_ = 1;
free_desktop_object_list_names (data->self->priv->fdesktop_obj, mpris2_watcher_check_for_active_clients_ready, data);
return FALSE;
_state_1:
data->_tmp1_ = NULL;
data->_tmp1_ = free_desktop_object_list_names_finish (data->self->priv->fdesktop_obj, data->_res_, &data->_tmp0_, &data->_inner_error_);
- data->_tmp3_ = data->_tmp1_;
+ data->_tmp2_ = data->_tmp1_;
data->_tmp2__length1 = data->_tmp0_;
- data->__tmp2__size_ = data->_tmp2__length1;
- data->_tmp2_ = data->_tmp3_;
+ data->__tmp2__size_ = data->_tmp0_;
if (data->_inner_error_ != NULL) {
if (data->_inner_error_->domain == G_IO_ERROR) {
goto __catch7_g_io_error;
@@ -272,11 +271,11 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo
g_clear_error (&data->_inner_error_);
return FALSE;
}
- data->_tmp4_ = data->_tmp2_;
+ data->_tmp3_ = data->_tmp2_;
data->interfaces = (_vala_array_free (data->interfaces, data->interfaces_length1, (GDestroyNotify) g_free), NULL);
data->interfaces_length1 = data->_tmp2__length1;
data->_interfaces_size_ = data->interfaces_length1;
- data->interfaces = data->_tmp4_;
+ data->interfaces = data->_tmp3_;
goto __finally7;
__catch7_g_io_error:
{
@@ -305,14 +304,14 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo
data->address_collection = data->interfaces;
data->address_collection_length1 = data->interfaces_length1;
for (data->address_it = 0; data->address_it < data->interfaces_length1; data->address_it = data->address_it + 1) {
- data->_tmp5_ = g_strdup (data->address_collection[data->address_it]);
- data->address = data->_tmp5_;
+ data->_tmp4_ = g_strdup (data->address_collection[data->address_it]);
+ data->address = data->_tmp4_;
{
- data->_tmp6_ = g_str_has_prefix (data->address, MPRIS_PREFIX);
- if (data->_tmp6_) {
- data->_tmp7_ = NULL;
- data->_tmp7_ = mpris2_watcher_create_mpris_root (data->self, data->address);
- data->mpris2_root = data->_tmp7_;
+ data->_tmp5_ = g_str_has_prefix (data->address, MPRIS_PREFIX);
+ if (data->_tmp5_) {
+ data->_tmp6_ = NULL;
+ data->_tmp6_ = mpris2_watcher_create_mpris_root (data->self, data->address);
+ data->mpris2_root = data->_tmp6_;
if (data->mpris2_root == NULL) {
_g_object_unref0 (data->mpris2_root);
_g_free0 (data->address);
@@ -325,13 +324,13 @@ static gboolean mpris2_watcher_check_for_active_clients_co (Mpris2WatcherCheckFo
g_object_unref (data->_async_result);
return FALSE;
}
- data->_tmp8_ = mpris2_watcher_supports_playlists (data->self, data->address);
- data->use_playlists = data->_tmp8_;
- data->_tmp9_ = NULL;
- data->_tmp9_ = mpris_root_get_DesktopEntry (data->mpris2_root);
- data->_tmp10_ = data->_tmp9_;
- g_signal_emit_by_name (data->self, "client-appeared", data->_tmp10_, data->address, data->use_playlists);
- _g_free0 (data->_tmp10_);
+ data->_tmp7_ = mpris2_watcher_supports_playlists (data->self, data->address);
+ data->use_playlists = data->_tmp7_;
+ data->_tmp8_ = NULL;
+ data->_tmp8_ = mpris_root_get_DesktopEntry (data->mpris2_root);
+ data->_tmp9_ = data->_tmp8_;
+ g_signal_emit_by_name (data->self, "client-appeared", data->_tmp9_, data->address, data->use_playlists);
+ _g_free0 (data->_tmp9_);
_g_object_unref0 (data->mpris2_root);
}
_g_free0 (data->address);
@@ -449,7 +448,7 @@ static MprisRoot* mpris2_watcher_create_mpris_root (Mpris2Watcher* self, const g
static gboolean mpris2_watcher_supports_playlists (Mpris2Watcher* self, const gchar* name) {
gboolean result = FALSE;
- FreeDesktopIntrospectable* introspectable;
+ FreeDesktopIntrospectable* introspectable = NULL;
FreeDesktopIntrospectable* _tmp0_ = NULL;
FreeDesktopIntrospectable* _tmp1_;
FreeDesktopIntrospectable* _tmp2_;
@@ -459,7 +458,6 @@ static gboolean mpris2_watcher_supports_playlists (Mpris2Watcher* self, const gc
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (name != NULL, FALSE);
- introspectable = NULL;
_tmp0_ = g_initable_new (TYPE_FREE_DESKTOP_INTROSPECTABLE_PROXY, NULL, &_inner_error_, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, "g-name", name, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", MPRIS_MEDIA_PLAYER_PATH, "g-interface-name", "org.freedesktop.DBus.Introspectable", NULL);
_tmp1_ = (FreeDesktopIntrospectable*) _tmp0_;
if (_inner_error_ != NULL) {
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c
index 04c2a3e..16f3dfa 100644
--- a/src/music-player-bridge.c
+++ b/src/music-player-bridge.c
@@ -1,4 +1,4 @@
-/* music-player-bridge.c generated by valac 0.11.3, the Vala compiler
+/* music-player-bridge.c generated by valac 0.11.5, the Vala compiler
* generated from music-player-bridge.vala, do not modify */
/*
@@ -634,50 +634,45 @@ static gchar* music_player_bridge_determine_key (gchar* desktop_or_interface) {
gchar* _result_;
gchar** _tmp1_;
gchar** _tmp2_ = NULL;
+ gchar** tokens;
gint tokens_length1;
gint _tokens_size_;
- gchar** _tmp3_;
- gchar** tokens;
- gchar** _tmp6_;
- gchar** _tmp7_ = NULL;
+ gchar** _tmp5_;
+ gchar** _tmp6_ = NULL;
+ gchar** temp;
gint temp_length1;
gint _temp_size_;
- gchar** _tmp8_;
- gchar** temp;
g_return_val_if_fail (desktop_or_interface != NULL, NULL);
_tmp0_ = g_strdup (desktop_or_interface);
_result_ = _tmp0_;
_tmp2_ = _tmp1_ = g_strsplit (desktop_or_interface, ".", 0);
- _tmp3_ = _tmp2_;
+ tokens = _tmp2_;
tokens_length1 = _vala_array_length (_tmp1_);
- _tokens_size_ = tokens_length1;
- tokens = _tmp3_;
+ _tokens_size_ = _vala_array_length (_tmp1_);
if (tokens_length1 > 1) {
+ gchar* _tmp3_;
gchar* _tmp4_;
- gchar* _tmp5_;
- _tmp4_ = g_strdup (tokens[tokens_length1 - 1]);
- _tmp5_ = _tmp4_;
+ _tmp3_ = g_strdup (tokens[tokens_length1 - 1]);
+ _tmp4_ = _tmp3_;
_g_free0 (_result_);
- _result_ = _tmp5_;
+ _result_ = _tmp4_;
}
- _tmp7_ = _tmp6_ = g_strsplit (_result_, "-", 0);
- _tmp8_ = _tmp7_;
- temp_length1 = _vala_array_length (_tmp6_);
- _temp_size_ = temp_length1;
- temp = _tmp8_;
+ _tmp6_ = _tmp5_ = g_strsplit (_result_, "-", 0);
+ temp = _tmp6_;
+ temp_length1 = _vala_array_length (_tmp5_);
+ _temp_size_ = _vala_array_length (_tmp5_);
if (temp_length1 > 1) {
- gchar* _tmp9_;
- gchar* _tmp10_;
- _tmp9_ = g_strdup (temp[0]);
- _tmp10_ = _tmp9_;
+ gchar* _tmp7_;
+ gchar* _tmp8_;
+ _tmp7_ = g_strdup (temp[0]);
+ _tmp8_ = _tmp7_;
_g_free0 (_result_);
- _result_ = _tmp10_;
+ _result_ = _tmp8_;
}
g_debug ("music-player-bridge.vala:205: determine key result = %s", _result_);
result = _result_;
temp = (_vala_array_free (temp, temp_length1, (GDestroyNotify) g_free), NULL);
tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
- _g_free0 (desktop_or_interface);
return result;
}
diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h
index f16836a..b156cfe 100644
--- a/src/music-player-bridge.h
+++ b/src/music-player-bridge.h
@@ -1,4 +1,4 @@
-/* music-player-bridge.h generated by valac 0.11.3, the Vala compiler, do not modify */
+/* music-player-bridge.h generated by valac 0.11.5, the Vala compiler, do not modify */
#ifndef __MUSIC_PLAYER_BRIDGE_H__
@@ -347,7 +347,8 @@ struct _MprisPlaylistsIface {
GTypeInterface parent_iface;
void (*ActivatePlaylist) (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
void (*ActivatePlaylist_finish) (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
- PlaylistDetails* (*GetPlaylists) (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+ void (*GetPlaylists) (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ PlaylistDetails* (*GetPlaylists_finish) (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
gchar** (*get_Orderings) (MprisPlaylists* self, int* result_length1);
void (*set_Orderings) (MprisPlaylists* self, gchar** value, int value_length1);
guint32 (*get_PlaylistCount) (MprisPlaylists* self);
@@ -517,7 +518,8 @@ guint mpris_playlists_register_object (void* object, GDBusConnection* connection
GType mpris_playlists_get_type (void) G_GNUC_CONST;
void mpris_playlists_ActivatePlaylist (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_);
void mpris_playlists_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult* _res_, GError** error);
-PlaylistDetails* mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error);
+void mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, GAsyncReadyCallback _callback_, gpointer _user_data_);
+PlaylistDetails* mpris_playlists_GetPlaylists_finish (MprisPlaylists* self, GAsyncResult* _res_, int* result_length1, GError** error);
gchar** mpris_playlists_get_Orderings (MprisPlaylists* self, int* result_length1);
void mpris_playlists_set_Orderings (MprisPlaylists* self, gchar** value, int value_length1);
guint32 mpris_playlists_get_PlaylistCount (MprisPlaylists* self);
@@ -532,9 +534,10 @@ Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerControll
void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* interface_source, GHashTable* changed_properties, gchar** invalid, int invalid_length1);
void mpris2_controller_initial_update (Mpris2Controller* self);
void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command);
-void mpris2_controller_fetch_playlists (Mpris2Controller* self);
gboolean mpris2_controller_connected (Mpris2Controller* self);
void mpris2_controller_expose (Mpris2Controller* self);
+void mpris2_controller_fetch_playlists (Mpris2Controller* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void mpris2_controller_fetch_playlists_finish (Mpris2Controller* self, GAsyncResult* _res_);
void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* path);
MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self);
MprisPlayer* mpris2_controller_get_player (Mpris2Controller* self);
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 7587684..c167e08 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -141,8 +141,8 @@ public class MusicPlayerBridge : GLib.Object
this.root_menu = menu;
this.try_to_add_inactive_familiar_clients();
this.watcher = new Mpris2Watcher ();
- this.watcher.client_appeared += this.client_has_become_available;
- this.watcher.client_disappeared += this.client_has_vanished;
+ this.watcher.client_appeared.connect (this.client_has_become_available);
+ this.watcher.client_disappeared.connect (this.client_has_vanished);
}
private static AppInfo? create_app_info ( string desktop )
diff --git a/src/mute-menu-item.c b/src/mute-menu-item.c
new file mode 100644
index 0000000..f7f3824
--- /dev/null
+++ b/src/mute-menu-item.c
@@ -0,0 +1,144 @@
+/*
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@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
+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 <http://www.gnu.org/licenses/>.
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gi18n.h>
+
+#include "common-defs.h"
+#include "mute-menu-item.h"
+#include "pulse-manager.h"
+
+typedef struct _MuteMenuItemPrivate MuteMenuItemPrivate;
+
+struct _MuteMenuItemPrivate {
+ DbusmenuMenuitem* button;
+};
+
+#define MUTE_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MUTE_MENU_ITEM_TYPE, MuteMenuItemPrivate))
+
+/* Prototypes */
+static void mute_menu_item_class_init (MuteMenuItemClass *klass);
+static void mute_menu_item_init (MuteMenuItem *self);
+static void mute_menu_item_dispose (GObject *object);
+static void mute_menu_item_finalize (GObject *object);
+static void mute_menu_item_set_global_mute_from_ui (gpointer user_data);
+
+G_DEFINE_TYPE (MuteMenuItem, mute_menu_item, G_TYPE_OBJECT);
+
+static void
+mute_menu_item_class_init (MuteMenuItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (MuteMenuItemPrivate));
+
+ object_class->dispose = mute_menu_item_dispose;
+ object_class->finalize = mute_menu_item_finalize;
+
+ return;
+}
+
+static void
+mute_menu_item_init (MuteMenuItem *self)
+{
+ g_debug("Building new Mute Menu Item");
+ MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE(self);
+ priv->button = dbusmenu_menuitem_new();
+
+ g_signal_connect (G_OBJECT (priv->button),
+ DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK (mute_menu_item_set_global_mute_from_ui),
+ self);
+ return;
+}
+
+static void
+mute_menu_item_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (mute_menu_item_parent_class)->dispose (object);
+ return;
+}
+
+static void
+mute_menu_item_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (mute_menu_item_parent_class)->finalize (object);
+}
+
+static void
+mute_menu_item_set_global_mute_from_ui (gpointer user_data)
+{
+ g_return_if_fail (DBUSMENU_IS_MENUITEM (user_data));
+ DbusmenuMenuitem* button = DBUSMENU_MENUITEM (user_data);
+ gboolean current_value = dbusmenu_menuitem_property_get_bool (button,
+ DBUSMENU_MUTE_MENUITEM_VALUE);
+
+ gboolean new_value = !current_value;
+ // pa manager api - to be refactored
+ toggle_global_mute (new_value);
+}
+
+void
+mute_menu_item_update (MuteMenuItem* item, gboolean value_update)
+{
+ MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
+
+ dbusmenu_menuitem_property_set_bool (priv->button,
+ DBUSMENU_MUTE_MENUITEM_VALUE,
+ value_update);
+ dbusmenu_menuitem_property_set (priv->button,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ value_update == FALSE ? _("Mute") : _("Unmute"));
+}
+
+void
+mute_menu_item_enable (MuteMenuItem* item, gboolean active)
+{
+ MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
+
+ dbusmenu_menuitem_property_set_bool (priv->button,
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ active);
+}
+
+DbusmenuMenuitem*
+mute_menu_item_get_button (MuteMenuItem* item)
+{
+ MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
+ return priv->button;
+}
+
+gboolean
+mute_menu_item_is_muted (MuteMenuItem* item)
+{
+ MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
+ return dbusmenu_menuitem_property_get_bool (priv->button,
+ DBUSMENU_MUTE_MENUITEM_VALUE);
+}
+
+MuteMenuItem*
+mute_menu_item_new (gboolean initial_update, gboolean enabled)
+{
+ MuteMenuItem *self = g_object_new (MUTE_MENU_ITEM_TYPE, NULL);
+ mute_menu_item_update (self, initial_update);
+ mute_menu_item_enable (self, enabled);
+ return self;
+}
diff --git a/src/mute-menu-item.h b/src/mute-menu-item.h
new file mode 100644
index 0000000..81a4b33
--- /dev/null
+++ b/src/mute-menu-item.h
@@ -0,0 +1,59 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@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
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __MUTE_MENU_ITEM_H__
+#define __MUTE_MENU_ITEM_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <libdbusmenu-glib/menuitem.h>
+
+G_BEGIN_DECLS
+
+#define MUTE_MENU_ITEM_TYPE (mute_menu_item_get_type ())
+#define MUTE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MUTE_MENU_ITEM_TYPE, MuteMenuItem))
+#define MUTE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MUTE_MENU_ITEM_TYPE, MuteMenuItemClass))
+#define IS_MUTE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MUTE_MENU_ITEM_TYPE))
+#define IS_MUTE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MUTE_MENU_ITEM_TYPE))
+#define MUTE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MUTE_MENU_ITEM_TYPE, MuteMenuItemClass))
+
+typedef struct _MuteMenuItem MuteMenuItem;
+typedef struct _MuteMenuItemClass MuteMenuItemClass;
+
+struct _MuteMenuItemClass {
+ GObjectClass parent_class;
+};
+
+struct _MuteMenuItem {
+ GObject parent;
+};
+
+GType mute_menu_item_get_type (void);
+
+MuteMenuItem* mute_menu_item_new ();
+
+void mute_menu_item_update (MuteMenuItem* item, gboolean update);
+void mute_menu_item_enable (MuteMenuItem* item, gboolean active);
+gboolean mute_menu_item_is_muted (MuteMenuItem* item);
+
+DbusmenuMenuitem* mute_menu_item_get_button (MuteMenuItem* item);
+
+G_END_DECLS
+
+#endif \ No newline at end of file
diff --git a/src/player-controller.c b/src/player-controller.c
index c4583d9..2aa709f 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -1,4 +1,4 @@
-/* player-controller.c generated by valac 0.11.3, the Vala compiler
+/* player-controller.c generated by valac 0.11.5, the Vala compiler
* generated from player-controller.vala, do not modify */
/*
@@ -226,16 +226,12 @@ GType transport_menuitem_get_type (void) G_GNUC_CONST;
PlaylistsMenuitem* playlists_menuitem_new (PlayerController* parent);
PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerController* parent);
gint player_controller_get_menu_offset (PlayerController* self);
-static gchar* player_controller_format_player_name (gchar* app_info_name);
gboolean mpris2_controller_connected (Mpris2Controller* self);
void mpris2_controller_initial_update (Mpris2Controller* self);
const gchar* player_controller_get_icon_name (PlayerController* self);
static void player_controller_finalize (GObject* obj);
static void _vala_player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_player_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
-static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
-static gint _vala_array_length (gpointer array);
GType player_controller_widget_order_get_type (void) {
@@ -616,130 +612,6 @@ static void player_controller_construct_widgets (PlayerController* self) {
}
-static gchar* string_strip (const gchar* self) {
- gchar* result = NULL;
- gchar* _tmp0_ = NULL;
- gchar* _result_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = g_strdup (self);
- _result_ = _tmp0_;
- g_strstrip (_result_);
- result = _result_;
- return result;
-}
-
-
-static const gchar* string_offset (const gchar* self, glong offset) {
- const gchar* result = NULL;
- g_return_val_if_fail (self != NULL, NULL);
- result = (const gchar*) (((gchar*) self) + offset);
- return result;
-}
-
-
-static gchar* string_slice (const gchar* self, glong start, glong end) {
- gchar* result = NULL;
- gint _tmp0_;
- glong string_length;
- gboolean _tmp1_ = FALSE;
- gboolean _tmp2_ = FALSE;
- const gchar* _tmp3_ = NULL;
- const gchar* start_string;
- const gchar* _tmp4_ = NULL;
- gchar* _tmp5_ = NULL;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = strlen (self);
- string_length = (glong) _tmp0_;
- if (start < 0) {
- start = string_length + start;
- }
- if (end < 0) {
- end = string_length + end;
- }
- if (start >= 0) {
- _tmp1_ = start <= string_length;
- } else {
- _tmp1_ = FALSE;
- }
- g_return_val_if_fail (_tmp1_, NULL);
- if (end >= 0) {
- _tmp2_ = end <= string_length;
- } else {
- _tmp2_ = FALSE;
- }
- g_return_val_if_fail (_tmp2_, NULL);
- g_return_val_if_fail (start <= end, NULL);
- _tmp3_ = string_offset (self, start);
- start_string = _tmp3_;
- _tmp4_ = string_offset (start_string, end - start);
- _tmp5_ = g_strndup (start_string, ((gchar*) _tmp4_) - ((gchar*) start_string));
- result = _tmp5_;
- return result;
-}
-
-
-static gchar* player_controller_format_player_name (gchar* app_info_name) {
- gchar* result = NULL;
- gchar* _tmp0_ = NULL;
- gchar* _tmp1_;
- gchar* _tmp2_ = NULL;
- gchar* _tmp3_;
- gchar* _result_;
- gchar** _tmp4_;
- gchar** _tmp5_ = NULL;
- gint tokens_length1;
- gint _tokens_size_;
- gchar** _tmp6_;
- gchar** tokens;
- gint _tmp9_;
- g_return_val_if_fail (app_info_name != NULL, NULL);
- _tmp0_ = g_utf8_strdown (app_info_name, (gssize) (-1));
- _tmp1_ = _tmp0_;
- _tmp2_ = string_strip (_tmp1_);
- _result_ = (_tmp3_ = _tmp2_, _g_free0 (_tmp1_), _tmp3_);
- _tmp5_ = _tmp4_ = g_strsplit (_result_, " ", 0);
- _tmp6_ = _tmp5_;
- tokens_length1 = _vala_array_length (_tmp4_);
- _tokens_size_ = tokens_length1;
- tokens = _tmp6_;
- if (tokens_length1 > 1) {
- gchar* _tmp7_;
- gchar* _tmp8_;
- _tmp7_ = g_strdup (tokens[0]);
- _tmp8_ = _tmp7_;
- _g_free0 (_result_);
- _result_ = _tmp8_;
- }
- _tmp9_ = strlen (_result_);
- if (_tmp9_ > 1) {
- gchar* _tmp10_ = NULL;
- gchar* _tmp11_;
- gint _tmp12_;
- gchar* _tmp13_ = NULL;
- gchar* _tmp14_;
- gchar* _tmp15_ = NULL;
- gchar* _tmp16_;
- _tmp10_ = g_utf8_strup (_result_, (gssize) 1);
- _tmp11_ = _tmp10_;
- _tmp12_ = strlen (_result_);
- _tmp13_ = string_slice (_result_, (glong) 1, (glong) _tmp12_);
- _tmp14_ = _tmp13_;
- _tmp15_ = g_strconcat (_tmp11_, _tmp14_, NULL);
- _tmp16_ = _tmp15_;
- _g_free0 (_result_);
- _result_ = _tmp16_;
- _g_free0 (_tmp14_);
- _g_free0 (_tmp11_);
- }
- g_debug ("player-controller.vala:202: PlayerController->format_player_name - : %" \
-"s", _result_);
- result = _result_;
- tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
- _g_free0 (app_info_name);
- return result;
-}
-
-
static void player_controller_determine_state (PlayerController* self) {
gboolean _tmp0_;
g_return_if_fail (self != NULL);
@@ -926,34 +798,4 @@ static void _vala_player_controller_set_property (GObject * object, guint proper
}
-static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
- if ((array != NULL) && (destroy_func != NULL)) {
- int i;
- for (i = 0; i < array_length; i = i + 1) {
- if (((gpointer*) array)[i] != NULL) {
- destroy_func (((gpointer*) array)[i]);
- }
- }
- }
-}
-
-
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
- _vala_array_destroy (array, array_length, destroy_func);
- g_free (array);
-}
-
-
-static gint _vala_array_length (gpointer array) {
- int length;
- length = 0;
- if (array) {
- while (((gpointer*) array)[length]) {
- length++;
- }
- }
- return length;
-}
-
-
diff --git a/src/player-controller.vala b/src/player-controller.vala
index adefb65..024b88b 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -189,20 +189,6 @@ public class PlayerController : GLib.Object
}
}
- private static string format_player_name(owned string app_info_name)
- {
- string result = app_info_name.down().strip();
- var tokens = result.split(" ");
- if(tokens.length > 1){
- result = tokens[0];
- }
- if(result.length > 1){
- result = result.up(1).concat(result.slice(1, result.length));
- }
- debug("PlayerController->format_player_name - : %s", result);
- return result;
- }
-
private void determine_state()
{
if(this.mpris_bridge.connected() == true){
diff --git a/src/player-item.c b/src/player-item.c
index 8dcb226..fad8f9f 100644
--- a/src/player-item.c
+++ b/src/player-item.c
@@ -1,4 +1,4 @@
-/* player-item.c generated by valac 0.11.3, the Vala compiler
+/* player-item.c generated by valac 0.11.5, the Vala compiler
* generated from player-item.vala, do not modify */
/*
@@ -177,10 +177,10 @@ static gchar* string_strip (const gchar* self) {
static gboolean string_contains (const gchar* self, const gchar* needle) {
gboolean result = FALSE;
- const gchar* _tmp0_ = NULL;
+ gchar* _tmp0_ = NULL;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (needle != NULL, FALSE);
- _tmp0_ = strstr (self, needle);
+ _tmp0_ = strstr ((gchar*) self, (gchar*) needle);
result = _tmp0_ != NULL;
return result;
}
@@ -208,7 +208,7 @@ static gchar* bool_to_string (gboolean self) {
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes) {
- gboolean _tmp26_;
+ gboolean _tmp25_;
g_return_if_fail (self != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (attributes != NULL);
@@ -229,16 +229,15 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
gchar* property;
gchar** _tmp3_;
gchar** _tmp4_ = NULL;
+ gchar** input_keys;
gint input_keys_length1;
gint _input_keys_size_;
- gchar** _tmp5_;
- gchar** input_keys;
- gchar* _tmp6_;
+ gchar* _tmp5_;
gchar* search_key;
- gconstpointer _tmp7_ = NULL;
- GVariant* _tmp8_;
+ gconstpointer _tmp6_ = NULL;
+ GVariant* _tmp7_;
GVariant* v;
- gboolean _tmp9_;
+ gboolean _tmp8_;
_tmp1_ = gee_iterator_next (_property_it);
if (!_tmp1_) {
break;
@@ -246,33 +245,32 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
_tmp2_ = gee_iterator_get (_property_it);
property = (gchar*) _tmp2_;
_tmp4_ = _tmp3_ = g_strsplit (property, "-", 0);
- _tmp5_ = _tmp4_;
+ input_keys = _tmp4_;
input_keys_length1 = _vala_array_length (_tmp3_);
- _input_keys_size_ = input_keys_length1;
- input_keys = _tmp5_;
- _tmp6_ = g_strdup ((input_keys + (input_keys_length1 - 1))[0]);
- search_key = _tmp6_;
+ _input_keys_size_ = _vala_array_length (_tmp3_);
+ _tmp5_ = g_strdup ((input_keys + (input_keys_length1 - 1))[0]);
+ search_key = _tmp5_;
g_debug ("player-item.vala:62: search key = %s", search_key);
- _tmp7_ = g_hash_table_lookup (data, search_key);
- _tmp8_ = _g_variant_ref0 ((GVariant*) _tmp7_);
- v = _tmp8_;
- _tmp9_ = g_variant_is_of_type (v, G_VARIANT_TYPE_STRING);
- if (_tmp9_) {
- const gchar* _tmp10_ = NULL;
- gchar* _tmp11_ = NULL;
+ _tmp6_ = g_hash_table_lookup (data, search_key);
+ _tmp7_ = _g_variant_ref0 ((GVariant*) _tmp6_);
+ v = _tmp7_;
+ _tmp8_ = g_variant_is_of_type (v, G_VARIANT_TYPE_STRING);
+ if (_tmp8_) {
+ const gchar* _tmp9_ = NULL;
+ gchar* _tmp10_ = NULL;
gchar* update;
- gboolean _tmp12_;
- _tmp10_ = g_variant_get_string (v, NULL);
- _tmp11_ = string_strip (_tmp10_);
- update = _tmp11_;
+ gboolean _tmp11_;
+ _tmp9_ = g_variant_get_string (v, NULL);
+ _tmp10_ = string_strip (_tmp9_);
+ update = _tmp10_;
g_debug ("player-item.vala:67: with value : %s", update);
- _tmp12_ = string_contains (property, "mpris:artUrl");
- if (_tmp12_) {
- PlayerItem* _tmp13_;
- MetadataMenuitem* _tmp14_;
+ _tmp11_ = string_contains (property, "mpris:artUrl");
+ if (_tmp11_) {
+ PlayerItem* _tmp12_;
+ MetadataMenuitem* _tmp13_;
MetadataMenuitem* metadata;
- _tmp14_ = _g_object_ref0 ((_tmp13_ = self, IS_METADATA_MENUITEM (_tmp13_) ? ((MetadataMenuitem*) _tmp13_) : NULL));
- metadata = _tmp14_;
+ _tmp13_ = _g_object_ref0 ((_tmp12_ = self, IS_METADATA_MENUITEM (_tmp12_) ? ((MetadataMenuitem*) _tmp12_) : NULL));
+ metadata = _tmp13_;
metadata_menuitem_fetch_art (metadata, update, property);
_g_object_unref0 (metadata);
_g_free0 (update);
@@ -285,40 +283,40 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, property, update);
_g_free0 (update);
} else {
- gboolean _tmp15_;
- _tmp15_ = g_variant_is_of_type (v, G_VARIANT_TYPE_INT32);
- if (_tmp15_) {
+ gboolean _tmp14_;
+ _tmp14_ = g_variant_is_of_type (v, G_VARIANT_TYPE_INT32);
+ if (_tmp14_) {
+ gint32 _tmp15_;
gint32 _tmp16_;
- gint32 _tmp17_;
+ _tmp15_ = g_variant_get_int32 (v);
+ g_debug ("player-item.vala:78: with value : %i", (gint) _tmp15_);
_tmp16_ = g_variant_get_int32 (v);
- g_debug ("player-item.vala:78: with value : %i", (gint) _tmp16_);
- _tmp17_ = g_variant_get_int32 (v);
- dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, (gint) _tmp17_);
+ dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, (gint) _tmp16_);
} else {
- gboolean _tmp18_;
- _tmp18_ = g_variant_is_of_type (v, G_VARIANT_TYPE_INT64);
- if (_tmp18_) {
+ gboolean _tmp17_;
+ _tmp17_ = g_variant_is_of_type (v, G_VARIANT_TYPE_INT64);
+ if (_tmp17_) {
+ gint64 _tmp18_;
gint64 _tmp19_;
- gint64 _tmp20_;
+ _tmp18_ = g_variant_get_int64 (v);
+ g_debug ("player-item.vala:82: with value : %i", (gint) _tmp18_);
_tmp19_ = g_variant_get_int64 (v);
- g_debug ("player-item.vala:82: with value : %i", (gint) _tmp19_);
- _tmp20_ = g_variant_get_int64 (v);
- dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, (gint) _tmp20_);
+ dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, (gint) _tmp19_);
} else {
- gboolean _tmp21_;
- _tmp21_ = g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN);
- if (_tmp21_) {
- gboolean _tmp22_;
- gchar* _tmp23_ = NULL;
- gchar* _tmp24_;
- gboolean _tmp25_;
- _tmp22_ = g_variant_get_boolean (v);
- _tmp23_ = bool_to_string (_tmp22_);
- _tmp24_ = _tmp23_;
- g_debug ("player-item.vala:86: with value : %s", _tmp24_);
- _g_free0 (_tmp24_);
- _tmp25_ = g_variant_get_boolean (v);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, property, _tmp25_);
+ gboolean _tmp20_;
+ _tmp20_ = g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN);
+ if (_tmp20_) {
+ gboolean _tmp21_;
+ gchar* _tmp22_ = NULL;
+ gchar* _tmp23_;
+ gboolean _tmp24_;
+ _tmp21_ = g_variant_get_boolean (v);
+ _tmp22_ = bool_to_string (_tmp21_);
+ _tmp23_ = _tmp22_;
+ g_debug ("player-item.vala:86: with value : %s", _tmp23_);
+ _g_free0 (_tmp23_);
+ _tmp24_ = g_variant_get_boolean (v);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, property, _tmp24_);
}
}
}
@@ -330,8 +328,8 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
}
_g_object_unref0 (_property_it);
}
- _tmp26_ = player_item_populated (self, attributes);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp26_);
+ _tmp25_ = player_item_populated (self, attributes);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp25_);
}
diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c
index ddbe12a..5a32860 100644
--- a/src/playlists-menu-item.c
+++ b/src/playlists-menu-item.c
@@ -1,4 +1,4 @@
-/* playlists-menu-item.c generated by valac 0.11.3, the Vala compiler
+/* playlists-menu-item.c generated by valac 0.11.5, the Vala compiler
* generated from playlists-menu-item.vala, do not modify */
/*
@@ -231,6 +231,7 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli
if (_tmp2_) {
playlist_details_destroy (&detail);
block1_data_unref (_data1_);
+ _data1_ = NULL;
continue;
}
_tmp3_ = dbusmenu_menuitem_new ();
@@ -245,6 +246,7 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli
dbusmenu_menuitem_child_append (self->root_item, _data1_->menuitem);
playlist_details_destroy (&detail);
block1_data_unref (_data1_);
+ _data1_ = NULL;
}
}
}
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index 4443044..457992b 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -25,7 +25,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <pulse/gccmacro.h>
#include "pulse-manager.h"
-#include "dbus-menu-manager.h"
#define RECONNECT_DELAY 5
@@ -75,7 +74,7 @@ void establish_pulse_activities(SoundServiceDbus *service)
// Establish event callback registration
pa_context_set_state_callback (pulse_context, context_state_callback, NULL);
- dbus_menu_manager_update_pa_state (FALSE, FALSE, FALSE, 0);
+ sound_service_dbus_update_pa_state (dbus_service, FALSE, FALSE, 0);
pa_context_connect (pulse_context, NULL, PA_CONTEXT_NOFAIL, NULL);
}
@@ -184,7 +183,7 @@ static gboolean determine_sink_availability()
return available;
}
-static gboolean default_sink_is_muted()
+gboolean default_sink_is_muted()
{
if (DEFAULT_SINK_INDEX < 0)
return FALSE;
@@ -199,10 +198,12 @@ static void check_sink_input_while_muted_event(gint sink_index)
/* g_debug("SINKINPUTWHILEMUTED SIGNAL EVENT TO BE SENT FROM PA MANAGER - check trace for value");*/
if (default_sink_is_muted(sink_index) == TRUE) {
- sound_service_dbus_sink_input_while_muted (dbus_service, TRUE);
- } else {
- sound_service_dbus_sink_input_while_muted(dbus_service, FALSE);
+ sound_service_dbus_update_sound_state(dbus_service, BLOCKED);
}
+// Why do you need to send a false for a blocked event, it times out after 5 secs anyway
+//} else {
+ // sound_service_dbus_sink_input_while_muted(dbus_service, FALSE);
+ //}
}
static gdouble get_default_sink_volume()
@@ -223,10 +224,8 @@ static void mute_each_sink(gpointer key, gpointer value, gpointer user_data)
if (GPOINTER_TO_INT(user_data) == 1) {
sound_service_dbus_update_sink_mute(dbus_service, TRUE);
} else {
- dbus_menu_manager_update_volume(get_default_sink_volume());
+ sound_service_dbus_update_volume(dbus_service, get_default_sink_volume());
}
-
- /* g_debug("in the pulse manager: mute each sink %i", GPOINTER_TO_INT(user_data));*/
}
void toggle_global_mute(gboolean mute_value)
@@ -309,14 +308,17 @@ static void pulse_sink_info_callback(pa_context *c, const pa_sink_info *sink, in
gboolean device_available = determine_sink_availability();
if (device_available == TRUE) {
- dbus_menu_manager_update_pa_state(TRUE,
- device_available,
- default_sink_is_muted(),
- get_default_sink_volume());
+ sound_service_dbus_update_pa_state( dbus_service,
+ device_available,
+ default_sink_is_muted(),
+ get_default_sink_volume() );
} else {
//Update the indicator to show PA either is not ready or has no available sink
g_warning("Cannot find a suitable default sink ...");
- dbus_menu_manager_update_pa_state(FALSE, device_available, default_sink_is_muted(), get_default_sink_volume());
+ sound_service_dbus_update_pa_state( dbus_service,
+ device_available,
+ default_sink_is_muted(),
+ get_default_sink_volume() );
}
} else {
/* g_debug("About to add an item to our hash");*/
@@ -346,7 +348,10 @@ static void pulse_default_sink_info_callback(pa_context *c, const pa_sink_info *
if (position < 0) {
pa_operation_unref(pa_context_get_sink_info_list(c, pulse_sink_info_callback, NULL));
} else {
- dbus_menu_manager_update_pa_state(TRUE, determine_sink_availability(), default_sink_is_muted(), get_default_sink_volume());
+ sound_service_dbus_update_pa_state(dbus_service,
+ determine_sink_availability(),
+ default_sink_is_muted(),
+ get_default_sink_volume());
}
}
}
@@ -408,18 +413,17 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
pa_volume_t vol = pa_cvolume_max(&s->volume);
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
/* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
- dbus_menu_manager_update_volume(volume_percent);
+ sound_service_dbus_update_volume(dbus_service, volume_percent);
}
if (mute_changed == TRUE) {
/* g_debug("Updating Mute from PA manager with mute = %i", s->mute);*/
sound_service_dbus_update_sink_mute(dbus_service, s->mute);
- dbus_menu_manager_update_mute_ui(s->mute);
if (s->mute == FALSE) {
pa_volume_t vol = pa_cvolume_max(&s->volume);
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
- /* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
- dbus_menu_manager_update_volume(volume_percent);
+ /* g_debug("Updating volume from PA manager with volume = %f", volume_percent);*/
+ sound_service_dbus_update_volume(dbus_service, volume_percent);
}
}
}
@@ -434,7 +438,7 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
value->base_volume = info->base_volume;
g_hash_table_insert(sink_hash, GINT_TO_POINTER(value->index), value);
/* g_debug("pulse-manager:update_sink_info -> After adding a new sink to our hash");*/
- sound_service_dbus_update_sink_availability(dbus_service, TRUE);
+ sound_service_dbus_update_sound_state(dbus_service, AVAILABLE);
}
}
@@ -463,7 +467,7 @@ static void pulse_server_info_callback(pa_context *c,
pa_operation *operation;
if (info == NULL) {
g_warning("No server - get the hell out of here");
- dbus_menu_manager_update_pa_state(FALSE, FALSE, TRUE, 0);
+ sound_service_dbus_update_pa_state(dbus_service, FALSE, TRUE, 0);
pa_server_available = FALSE;
return;
}
@@ -493,7 +497,7 @@ static void subscribed_events_callback(pa_context *c, enum pa_subscription_event
case PA_SUBSCRIPTION_EVENT_SINK:
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
if (index == DEFAULT_SINK_INDEX)
- sound_service_dbus_update_sink_availability(dbus_service, FALSE);
+ sound_service_dbus_update_sound_state(dbus_service, UNAVAILABLE);
/* g_debug("Subscribed_events_callback - removing sink of index %i from our sink hash - keep the cache tidy !", index);*/
g_hash_table_remove(sink_hash, GINT_TO_POINTER(index));
@@ -548,10 +552,10 @@ static void context_state_callback(pa_context *c, void *userdata)
case PA_CONTEXT_FAILED:
g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
pa_server_available = FALSE;
- dbus_menu_manager_update_pa_state(TRUE,
- pa_server_available,
- default_sink_is_muted(),
- get_default_sink_volume());
+ sound_service_dbus_update_pa_state( dbus_service,
+ pa_server_available,
+ default_sink_is_muted(),
+ get_default_sink_volume() );
if (reconnect_idle_id == 0){
reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
diff --git a/src/pulse-manager.h b/src/pulse-manager.h
index fc01f1c..5895aeb 100644
--- a/src/pulse-manager.h
+++ b/src/pulse-manager.h
@@ -1,9 +1,6 @@
#ifndef __INCLUDE_PULSE_MANAGER_H__
#define __INCLUDE_PULSE_MANAGER_H__
/*
-A small wrapper utility to load indicators and put them as menu items
-into the gnome-panel using it's applet interface.
-
Copyright 2010 Canonical Ltd.
Authors:
@@ -43,6 +40,6 @@ void establish_pulse_activities(SoundServiceDbus *service);
void set_sink_volume(gdouble percent);
void toggle_global_mute(gboolean mute_value);
void close_pulse_activites();
-
+gboolean default_sink_is_muted();
#endif
diff --git a/src/settings-manager.c b/src/settings-manager.c
index 0bb50dc..94dc8f9 100644
--- a/src/settings-manager.c
+++ b/src/settings-manager.c
@@ -1,4 +1,4 @@
-/* settings-manager.c generated by valac 0.11.3, the Vala compiler
+/* settings-manager.c generated by valac 0.11.5, the Vala compiler
* generated from settings-manager.vala, do not modify */
/*
@@ -121,31 +121,27 @@ GeeArrayList* settings_manager_fetch_interested (SettingsManager* self) {
GeeArrayList* result = NULL;
gchar** _tmp0_;
gchar** _tmp1_ = NULL;
+ gchar** blacklisted;
gint blacklisted_length1;
gint _blacklisted_size_;
gchar** _tmp2_;
- gchar** blacklisted;
- gchar** _tmp3_;
- gchar** _tmp4_ = NULL;
+ gchar** _tmp3_ = NULL;
+ gchar** interested;
gint interested_length1;
gint _interested_size_;
- gchar** _tmp5_;
- gchar** interested;
- GeeArrayList* _tmp6_ = NULL;
+ GeeArrayList* _tmp4_ = NULL;
GeeArrayList* list;
g_return_val_if_fail (self != NULL, NULL);
_tmp1_ = _tmp0_ = g_settings_get_strv (self->priv->settings, "blacklisted-media-players");
- _tmp2_ = _tmp1_;
+ blacklisted = _tmp1_;
blacklisted_length1 = _vala_array_length (_tmp0_);
- _blacklisted_size_ = blacklisted_length1;
- blacklisted = _tmp2_;
- _tmp4_ = _tmp3_ = g_settings_get_strv (self->priv->settings, "interested-media-players");
- _tmp5_ = _tmp4_;
- interested_length1 = _vala_array_length (_tmp3_);
- _interested_size_ = interested_length1;
- interested = _tmp5_;
- _tmp6_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
- list = _tmp6_;
+ _blacklisted_size_ = _vala_array_length (_tmp0_);
+ _tmp3_ = _tmp2_ = g_settings_get_strv (self->priv->settings, "interested-media-players");
+ interested = _tmp3_;
+ interested_length1 = _vala_array_length (_tmp2_);
+ _interested_size_ = _vala_array_length (_tmp2_);
+ _tmp4_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
+ list = _tmp4_;
{
gchar** s_collection;
int s_collection_length1;
@@ -153,10 +149,10 @@ GeeArrayList* settings_manager_fetch_interested (SettingsManager* self) {
s_collection = interested;
s_collection_length1 = interested_length1;
for (s_it = 0; s_it < interested_length1; s_it = s_it + 1) {
- gchar* _tmp7_;
+ gchar* _tmp5_;
gchar* s;
- _tmp7_ = g_strdup (s_collection[s_it]);
- s = _tmp7_;
+ _tmp5_ = g_strdup (s_collection[s_it]);
+ s = _tmp5_;
{
if (_vala_string_array_contains (blacklisted, blacklisted_length1, s)) {
_g_free0 (s);
@@ -193,18 +189,16 @@ static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* val
void settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name) {
gchar** _tmp0_;
gchar** _tmp1_ = NULL;
+ gchar** already_interested;
gint already_interested_length1;
gint _already_interested_size_;
- gchar** _tmp2_;
- gchar** already_interested;
- gchar* _tmp4_;
+ gchar* _tmp3_;
g_return_if_fail (self != NULL);
g_return_if_fail (app_desktop_name != NULL);
_tmp1_ = _tmp0_ = g_settings_get_strv (self->priv->settings, "interested-media-players");
- _tmp2_ = _tmp1_;
+ already_interested = _tmp1_;
already_interested_length1 = _vala_array_length (_tmp0_);
- _already_interested_size_ = already_interested_length1;
- already_interested = _tmp2_;
+ _already_interested_size_ = _vala_array_length (_tmp0_);
{
gchar** s_collection;
int s_collection_length1;
@@ -212,10 +206,10 @@ void settings_manager_add_interested (SettingsManager* self, const gchar* app_de
s_collection = already_interested;
s_collection_length1 = already_interested_length1;
for (s_it = 0; s_it < already_interested_length1; s_it = s_it + 1) {
- gchar* _tmp3_;
+ gchar* _tmp2_;
gchar* s;
- _tmp3_ = g_strdup (s_collection[s_it]);
- s = _tmp3_;
+ _tmp2_ = g_strdup (s_collection[s_it]);
+ s = _tmp2_;
{
if (g_strcmp0 (s, app_desktop_name) == 0) {
_g_free0 (s);
@@ -226,8 +220,8 @@ void settings_manager_add_interested (SettingsManager* self, const gchar* app_de
}
}
}
- _tmp4_ = g_strdup (app_desktop_name);
- _vala_array_add1 (&already_interested, &already_interested_length1, &_already_interested_size_, _tmp4_);
+ _tmp3_ = g_strdup (app_desktop_name);
+ _vala_array_add1 (&already_interested, &already_interested_length1, &_already_interested_size_, _tmp3_);
g_settings_set_strv (self->priv->settings, "interested-media-players", already_interested);
g_settings_apply (self->priv->settings);
already_interested = (_vala_array_free (already_interested, already_interested_length1, (GDestroyNotify) g_free), NULL);
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 0f2f07b..a20bb00 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -29,7 +29,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate;
struct _SliderMenuItemPrivate {
- gdouble slider_value;
};
#define SLIDER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SLIDER_MENU_ITEM_TYPE, SliderMenuItemPrivate))
@@ -76,45 +75,57 @@ slider_menu_item_finalize (GObject *object)
G_OBJECT_CLASS (slider_menu_item_parent_class)->finalize (object);
}
-
static void
handle_event (DbusmenuMenuitem * mi,
const gchar * name,
GVariant * value,
guint timestamp)
{
- gdouble volume_input = 0;
- /*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);
+ gboolean volume_input = g_variant_get_double(input);
if (value != NULL){
set_sink_volume(volume_input);
+ // TODO -when the ACTIVESINK instance exists this will be handled nicely
+ // PA MANAGER will be refactored first.
+ if (default_sink_is_muted () == TRUE){
+ toggle_global_mute (FALSE);
+ }
}
- g_variant_unref (input);
}
+void slider_menu_item_update (SliderMenuItem* item,
+ gdouble update)
+{
+ // TODO
+ // Check if that variant below will leak !!!
+ GVariant* new_volume = g_variant_new_double(update);
+ dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(item),
+ DBUSMENU_VOLUME_MENUITEM_LEVEL,
+ new_volume);
+}
+void slider_menu_item_enable (SliderMenuItem* item,
+ gboolean active)
+{
+ dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(item),
+ DBUSMENU_MENUITEM_PROP_ENABLED,
+ active );
+}
-SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume)
+SliderMenuItem* slider_menu_item_new (gboolean sinks_available,
+ gdouble start_volume)
{
SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL);
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_VOLUME_MENUITEM_TYPE);
+ dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ DBUSMENU_VOLUME_MENUITEM_TYPE );
+ slider_menu_item_update (self, start_volume);
+ slider_menu_item_enable (self, sinks_available);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available);
- dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, sinks_available);
return self;
-}
-
-
-
-
+} \ No newline at end of file
diff --git a/src/slider-menu-item.h b/src/slider-menu-item.h
index 763944f..51336ae 100644
--- a/src/slider-menu-item.h
+++ b/src/slider-menu-item.h
@@ -45,8 +45,12 @@ struct _SliderMenuItem {
};
GType slider_menu_item_get_type (void);
-// TODO for now the volume percent param is not being used - remove once init mystery is solved
-SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble current_vol);
+
+void slider_menu_item_update(SliderMenuItem* item, gdouble update);
+void slider_menu_item_enable(SliderMenuItem* item, gboolean active);
+
+SliderMenuItem* slider_menu_item_new (gboolean sinks_available,
+ gdouble current_vol);
G_END_DECLS
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 6057a29..a532c0e 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -3,7 +3,6 @@
*
* Authors:
* Conor Curran <conor.curran@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
@@ -23,11 +22,19 @@
#endif
#include <gio/gio.h>
+#include <unistd.h>
+#include <glib/gi18n.h>
#include <libindicator/indicator-service.h>
+#include <libdbusmenu-glib/server.h>
+#include <libdbusmenu-glib/client.h>
+
+#include "sound-service-dbus.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"
+#include "slider-menu-item.h"
+#include "mute-menu-item.h"
#include "pulse-manager.h"
// DBUS methods
@@ -50,14 +57,16 @@ static GDBusInterfaceVTable interface_table = {
typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate;
struct _SoundServiceDbusPrivate {
- GDBusConnection *connection;
- gboolean mute;
- gboolean sink_availability;
+ GDBusConnection* connection;
+ DbusmenuMenuitem* root_menuitem;
+ SliderMenuItem* volume_slider_menuitem;
+ MuteMenuItem* mute_menuitem;
+ SoundState current_sound_state;
};
static GDBusNodeInfo * node_info = NULL;
static GDBusInterfaceInfo * interface_info = NULL;
-
+static gboolean b_startup = TRUE;
#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);
@@ -65,7 +74,18 @@ static void sound_service_dbus_init (SoundServiceDbus *self);
static void sound_service_dbus_dispose (GObject *object);
static void sound_service_dbus_finalize (GObject *object);
-/* GObject Boilerplate */
+static void sound_service_dbus_build_sound_menu ( SoundServiceDbus* root,
+ gboolean mute_update,
+ gboolean availability,
+ gdouble volume );
+static void show_sound_settings_dialog (DbusmenuMenuitem *mi,
+ gpointer user_data);
+static SoundState sound_service_dbus_get_state_from_volume (SoundServiceDbus* self);
+static void sound_service_dbus_determine_state (SoundServiceDbus* self,
+ gboolean availability,
+ gboolean mute,
+ gdouble volume);
+
G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
static void
@@ -108,8 +128,8 @@ sound_service_dbus_init (SoundServiceDbus *self)
SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
priv->connection = NULL;
- priv->mute = FALSE;
- priv->sink_availability = FALSE;
+
+ priv->current_sound_state = UNAVAILABLE;
/* Fetch the session bus */
priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
@@ -134,6 +154,108 @@ sound_service_dbus_init (SoundServiceDbus *self)
}
}
+DbusmenuMenuitem*
+sound_service_dbus_create_root_item (SoundServiceDbus* self)
+{
+ SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
+ priv->root_menuitem = dbusmenu_menuitem_new();
+ g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem));
+ DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH);
+ dbusmenu_server_set_root (server, priv->root_menuitem);
+ g_object_unref (priv->root_menuitem);
+ establish_pulse_activities (self);
+ return priv->root_menuitem;
+}
+
+static void
+sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
+ gboolean mute_update,
+ gboolean availability,
+ gdouble volume )
+{
+ SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
+
+ // Mute button
+ priv->mute_menuitem = mute_menu_item_new ( mute_update, availability);
+ dbusmenu_menuitem_child_append (priv->root_menuitem,
+ mute_menu_item_get_button (priv->mute_menuitem));
+
+ // Slider
+ priv->volume_slider_menuitem = slider_menu_item_new ( availability, volume );
+ dbusmenu_menuitem_child_append (priv->root_menuitem, DBUSMENU_MENUITEM ( priv->volume_slider_menuitem ));
+
+ // Separator
+
+ DbusmenuMenuitem* separator = dbusmenu_menuitem_new();
+
+ dbusmenu_menuitem_property_set( separator,
+ DBUSMENU_MENUITEM_PROP_TYPE,
+ DBUSMENU_CLIENT_TYPES_SEPARATOR);
+ dbusmenu_menuitem_child_append(priv->root_menuitem, separator);
+ g_object_unref (separator);
+
+ // Sound preferences dialog
+ DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new();
+
+ dbusmenu_menuitem_property_set( settings_mi,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Sound Preferences..."));
+ dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi);
+ g_object_unref (settings_mi);
+ g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
+ G_CALLBACK(show_sound_settings_dialog), NULL);
+
+ sound_service_dbus_determine_state (self, availability, mute_update, volume);
+}
+
+/**
+show_sound_settings_dialog:
+Bring up the gnome volume preferences dialog
+**/
+static void
+show_sound_settings_dialog (DbusmenuMenuitem *mi,
+ gpointer user_data)
+{
+ GError * error = NULL;
+ if (!g_spawn_command_line_async("gnome-volume-control --page=applications", &error) &&
+ !g_spawn_command_line_async("xfce4-mixer", &error))
+ {
+ g_warning("Unable to show dialog: %s", error->message);
+ g_error_free(error);
+ }
+}
+
+void
+sound_service_dbus_update_pa_state ( SoundServiceDbus* self,
+ gboolean availability,
+ gboolean mute_update,
+ gdouble volume )
+{
+ g_debug("update pa state with availability of %i, mute value of %i and a volume percent is %f", availability, mute_update, volume);
+ SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
+
+ if (b_startup == TRUE) {
+ sound_service_dbus_build_sound_menu ( self,
+ mute_update,
+ availability,
+ volume );
+ b_startup = FALSE;
+ return;
+ }
+
+ mute_menu_item_update ( priv->mute_menuitem,
+ mute_update );
+ slider_menu_item_update ( priv->volume_slider_menuitem,
+ volume );
+
+ mute_menu_item_enable ( priv->mute_menuitem, availability);
+ slider_menu_item_enable ( priv->volume_slider_menuitem,
+ availability );
+ sound_service_dbus_determine_state (self, availability, mute_update, volume);
+
+}
+
+
static void
sound_service_dbus_dispose (GObject *object)
{
@@ -148,112 +270,142 @@ sound_service_dbus_finalize (GObject *object)
return;
}
-/* 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);
+// UNTIL PA-MANAGER IS REFACTORED AND THE ACTIVESINK CLASS IS CREATED LEAVE
+// THE UI ELEMENTS SEPARATELY HANDLED LIKE THIS.
+void
+sound_service_dbus_update_volume (SoundServiceDbus* self,
+ gdouble volume)
+{
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ slider_menu_item_update (priv->volume_slider_menuitem, volume);
+ sound_service_dbus_update_sound_state (self,
+ sound_service_dbus_get_state_from_volume (self));
}
+void
+sound_service_dbus_update_sink_mute (SoundServiceDbus* self,
+ gboolean mute_update)
+{
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ mute_menu_item_update (priv->mute_menuitem, mute_update);
+ SoundState state = sound_service_dbus_get_state_from_volume (self);
+ if (mute_update == TRUE){
+ state = MUTED;
+ }
+ sound_service_dbus_update_sound_state (self, state);
+}
-/**
-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)
+/*------- State calculators ------------------*/
+static SoundState
+sound_service_dbus_get_state_from_volume (SoundServiceDbus* self)
{
- 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);
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem),
+ DBUSMENU_VOLUME_MENUITEM_LEVEL);
+ gdouble volume_percent = g_variant_get_double (v);
- GError * error = NULL;
+ SoundState state = LOW_LEVEL;
- 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;
+ if (volume_percent < 30.0 && volume_percent > 0) {
+ state = LOW_LEVEL;
+ }
+ else if (volume_percent < 70.0 && volume_percent >= 30.0) {
+ state = MEDIUM_LEVEL;
+ }
+ else if (volume_percent >= 70.0) {
+ state = HIGH_LEVEL;
+ }
+ else if (volume_percent == 0.0) {
+ state = ZERO_LEVEL;
}
+ return state;
}
-void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj,
- gboolean sink_mute)
+static void
+sound_service_dbus_determine_state (SoundServiceDbus* self,
+ gboolean availability,
+ gboolean mute,
+ gdouble volume)
{
- 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("(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;
+ SoundState update;
+ if (availability == FALSE) {
+ update = UNAVAILABLE;
}
+ else if (mute == TRUE) {
+ update = MUTED;
+ }
+ else{
+ update = sound_service_dbus_get_state_from_volume (self);
+ }
+ sound_service_dbus_update_sound_state (self, update);
}
-void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj,
- gboolean sink_availability)
+
+// EMIT STATE SIGNAL
+
+// TODO: this will be a bit messy until the pa_manager is sorted.
+// And we figure out all of the edge cases.
+void
+sound_service_dbus_update_sound_state (SoundServiceDbus* self,
+ SoundState new_state)
{
- 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("(b)", priv->sink_availability);
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ SoundState update = new_state;
+ // Ensure that after it has become available update the state with the current volume level
+ if (new_state == AVAILABLE &&
+ mute_menu_item_is_muted (priv->mute_menuitem) == FALSE){
+ update = sound_service_dbus_get_state_from_volume (self);
+ }
+ if (update != BLOCKED){
+ priv->current_sound_state = update;
+ }
+
+ GVariant* v_output = g_variant_new("(i)", (int)update);
+
GError * error = NULL;
-
+
+ g_debug ("emitting signal with value %i", (int)update);
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 );
+ INDICATOR_SOUND_SIGNAL_STATE_UPDATE,
+ v_output,
+ &error );
if (error != NULL) {
- g_error("Unable to emit signal 'SinkAvailableUpdate' because : %s", error->message);
+ g_error("Unable to emit signal 'sinkinputwhilemuted' because : %s", error->message);
g_error_free(error);
return;
}
}
+//HANDLE DBUS METHOD CALLS
+// TODO we will need to implement the black_list method.
+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, "GetSoundState") == 0) {
+ g_debug("Get state - %i", priv->current_sound_state );
+ retval = g_variant_new ( "(i)", priv->current_sound_state);
+ }
+ else {
+ g_warning("Calling method '%s' on the sound service but it's unknown", method);
+ }
+ g_dbus_method_invocation_return_value (invocation, retval);
+}
+
+
diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h
index 0d1573b..fab3549 100644
--- a/src/sound-service-dbus.h
+++ b/src/sound-service-dbus.h
@@ -3,7 +3,6 @@
*
* Authors:
* Conor Curran <conor.curran@canonical.com>
- * Cody Russell <crussell@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
@@ -23,6 +22,9 @@
#include <glib.h>
#include <glib-object.h>
+#include <libdbusmenu-glib/menuitem.h>
+#include "common-defs.h"
+
G_BEGIN_DECLS
@@ -51,10 +53,14 @@ struct _SoundServiceDbusClass {
GType sound_service_dbus_get_type (void) G_GNUC_CONST;
-// Utility methods to get the SIGNAL messages across into the sound-service-dbus
-void sound_service_dbus_sink_input_while_muted (SoundServiceDbus* obj, gboolean block_value);
-void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute);
-void sound_service_dbus_update_sink_availability(SoundServiceDbus* obj, gboolean sink_availibity);
+DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self);
+void sound_service_dbus_update_sound_state (SoundServiceDbus* self, SoundState new_state);
+void sound_service_dbus_update_sink_mute(SoundServiceDbus* self, gboolean sink_mute);
+void sound_service_dbus_update_volume(SoundServiceDbus* self, gdouble volume);
+void sound_service_dbus_update_pa_state ( SoundServiceDbus* root,
+ gboolean availability,
+ gboolean mute_update,
+ gdouble volume );
G_END_DECLS
diff --git a/src/sound-service.c b/src/sound-service.c
index 98f1881..2cb33d3 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -1,5 +1,4 @@
/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
Copyright 2010 Canonical Ltd.
Authors:
@@ -19,8 +18,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sound-service.h"
-#include "dbus-menu-manager.h"
+
#include "pulse-manager.h"
+#include "sound-service-dbus.h"
#include "music-player-bridge.h"
static GMainLoop *mainloop = NULL;
@@ -64,7 +64,9 @@ main (int argc, char ** argv)
INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
G_CALLBACK(service_shutdown), NULL);
- DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup();
+ SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
+
+ DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service);
MusicPlayerBridge* server = music_player_bridge_new();
music_player_bridge_set_root_menu_item(server, root_menuitem);
diff --git a/src/sound-service.h b/src/sound-service.h
index e95d4c7..7c5d0c3 100644
--- a/src/sound-service.h
+++ b/src/sound-service.h
@@ -2,13 +2,10 @@
#define __INCLUDE_SOUND_SERVICE_H__
/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
- Ted Gould <ted@canonical.com>
- Cody Russell <crussell@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
diff --git a/src/sound-service.xml b/src/sound-service.xml
index a552d52..18e47fc 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -1,31 +1,18 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/com/canonical/indicators/sound">
<interface name="com.canonical.indicators.sound">
- <method name = "GetSinkMute">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_mute"/>
- <arg type='b' name='mute_input' direction="out"/>
+ <method name = "BlacklistMediaPlayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_blacklist_media_player"/>
+ <arg type='s' name='player_desktop_name' direction="in"/>
+ <arg type='b' name='blacklist' direction="in"/>
</method>
-
- <method name = "GetSinkAvailability">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_availability"/>
- <arg type='b' name='availability_input' direction="out"/>
+ <method name = "GetSoundState">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_state"/>
+ <arg type='i' name='current_state' direction="out"/>
</method>
-
-<!-- Will need to hook up another signal which monitors for volume change
-Our respective UI element should listen to this and therefore will be updated with accurate setting-->
-<!-- Triggered when a sink is muted but the input has been sent to that sink -->
- <signal name="SinkInputWhileMuted">
- <arg name="block_value" type="b" direction="out"/>
- </signal>
-
- <signal name="SinkMuteUpdate">
- <arg name="mute_value" type="b" direction="out"/>
+ <signal name="SoundStateUpdate">
+ <arg name="new_state" type="i" direction="out"/>
</signal>
-
- <signal name="SinkAvailableUpdate">
- <arg name="available_value" type="b" direction="out"/>
- </signal>
-
</interface>
</node>
diff --git a/src/sound-state-manager.c b/src/sound-state-manager.c
new file mode 100644
index 0000000..e8865d8
--- /dev/null
+++ b/src/sound-state-manager.c
@@ -0,0 +1,387 @@
+/*
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@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
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#include <libindicator/indicator-image-helper.h>
+#include "sound-state-manager.h"
+#include "dbus-shared-names.h"
+
+typedef struct _SoundStateManagerPrivate SoundStateManagerPrivate;
+
+struct _SoundStateManagerPrivate
+{
+ GDBusProxy* dbus_proxy;
+ GHashTable* volume_states;
+ GList* blocked_animation_list;
+ SoundState current_state;
+ GtkImage* speaker_image;
+};
+
+#define SOUND_STATE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUND_TYPE_STATE_MANAGER, SoundStateManagerPrivate))
+G_DEFINE_TYPE (SoundStateManager, sound_state_manager, G_TYPE_OBJECT);
+
+static GtkIconSize design_team_size;
+static gint blocked_id;
+static gint animation_id;
+static GList* blocked_iter = NULL;
+static gboolean can_animate = FALSE;
+
+static void sound_state_manager_prepare_blocked_animation(SoundStateManager* self);
+static gboolean sound_state_manager_start_animation (gpointer user_data);
+static gboolean sound_state_manager_fade_back_to_mute_image (gpointer user_data);
+static void sound_state_manager_reset_mute_blocking_animation (SoundStateManager* self);
+static void sound_state_manager_free_the_animation_list (SoundStateManager* self);
+static void sound_state_manager_prepare_state_image_names (SoundStateManager* self);
+static void sound_state_signal_cb ( GDBusProxy* proxy,
+ gchar* sender_name,
+ gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data );
+static gboolean sound_state_manager_can_proceed_with_blocking_animation (SoundStateManager* self);
+
+static void
+sound_state_manager_init (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ priv->dbus_proxy = NULL;
+ priv->volume_states = NULL;
+ priv->speaker_image = NULL;
+ priv->blocked_animation_list = NULL;
+
+ sound_state_manager_prepare_state_image_names (self);
+ sound_state_manager_prepare_blocked_animation (self);
+
+ priv->current_state = UNAVAILABLE;
+ priv->speaker_image = indicator_image_helper (g_hash_table_lookup (priv->volume_states,
+ GINT_TO_POINTER(priv->current_state)));
+}
+
+static void
+sound_state_manager_finalize (GObject *object)
+{
+ /* TODO: Add deinitalization code here */
+
+ G_OBJECT_CLASS (sound_state_manager_parent_class)->finalize (object);
+}
+
+static void
+sound_state_manager_dispose (GObject *object)
+{
+ SoundStateManager* self = SOUND_STATE_MANAGER (object);
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ g_hash_table_destroy (priv->volume_states);
+
+ sound_state_manager_free_the_animation_list (self);
+ G_OBJECT_CLASS (sound_state_manager_parent_class)->dispose (object);
+}
+
+
+static void
+sound_state_manager_class_init (SoundStateManagerClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = sound_state_manager_finalize;
+ object_class->dispose = sound_state_manager_dispose;
+
+ g_type_class_add_private (klass, sizeof (SoundStateManagerPrivate));
+
+ design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
+}
+
+/*
+Prepare states versus images names hash.
+*/
+static void
+sound_state_manager_prepare_state_image_names (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+ priv->volume_states = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(MUTED), g_strdup("audio-volume-muted-panel"));
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(ZERO_LEVEL), g_strdup("audio-volume-low-zero-panel"));
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(LOW_LEVEL), g_strdup("audio-volume-low-panel"));
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(MEDIUM_LEVEL), g_strdup("audio-volume-medium-panel"));
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(HIGH_LEVEL), g_strdup("audio-volume-high-panel"));
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(BLOCKED), g_strdup("audio-volume-muted-blocking-panel"));
+ g_hash_table_insert (priv->volume_states, GINT_TO_POINTER(UNAVAILABLE), g_strdup("audio-output-none-panel"));
+}
+
+/*
+prepare_blocked_animation:
+Prepares the array of images to be used in the blocked animation.
+Only called at startup.
+*/
+static void
+sound_state_manager_prepare_blocked_animation (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ gchar* blocked_name = g_hash_table_lookup(priv->volume_states,
+ GINT_TO_POINTER(BLOCKED));
+ gchar* muted_name = g_hash_table_lookup(priv->volume_states,
+ GINT_TO_POINTER(MUTED));
+
+ GtkImage* temp_image = indicator_image_helper(muted_name);
+ GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image);
+
+ temp_image = indicator_image_helper(blocked_name);
+ GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image);
+
+ if (mute_buf == NULL || blocked_buf == NULL) {
+ //g_debug("Don bother with the animation, the theme aint got the goods !");
+ return;
+ }
+
+ int i;
+
+ // sample 51 snapshots - range : 0-256
+ for (i = 0; i < 51; i++) {
+ gdk_pixbuf_composite(mute_buf, blocked_buf, 0, 0,
+ gdk_pixbuf_get_width(mute_buf),
+ gdk_pixbuf_get_height(mute_buf),
+ 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 5));
+ priv->blocked_animation_list = g_list_append(priv->blocked_animation_list,
+ gdk_pixbuf_copy(blocked_buf));
+ }
+ can_animate = TRUE;
+ g_object_ref_sink(mute_buf);
+ g_object_unref(mute_buf);
+ g_object_ref_sink(blocked_buf);
+ g_object_unref(blocked_buf);
+}
+
+
+GtkImage*
+sound_state_manager_get_current_icon (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+ return priv->speaker_image;
+}
+
+SoundState
+sound_state_manager_get_current_state (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+ return priv->current_state;
+}
+
+/**
+ * sound_state_manager_connect_to_dbus:
+ * @returns: void
+ * When ready the indicator-sound calls this method to enable state communication
+ * between the indicator and the service.
+ **/
+void
+sound_state_manager_connect_to_dbus (SoundStateManager* self, GDBusProxy* proxy)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+ priv->dbus_proxy = proxy;
+ g_signal_connect (priv->dbus_proxy, "g-signal",
+ G_CALLBACK (sound_state_signal_cb), self);
+
+ g_dbus_proxy_call ( priv->dbus_proxy,
+ "GetSoundState",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)sound_state_manager_get_state_cb,
+ self);
+}
+
+void
+sound_state_manager_get_state_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ g_return_if_fail (SOUND_IS_STATE_MANAGER (user_data));
+ SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ GVariant *result, *value;
+ GError *error = NULL;
+ result = g_dbus_proxy_call_finish ( priv->dbus_proxy,
+ res,
+ &error );
+
+ if (error != NULL) {
+ g_warning("get_sound_state call failed: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ value = g_variant_get_child_value(result, 0);
+ priv->current_state = (SoundState)g_variant_get_int32(value);
+
+ gchar* image_name = g_hash_table_lookup (priv->volume_states,
+ GINT_TO_POINTER(priv->current_state) );
+ indicator_image_helper_update (priv->speaker_image, image_name);
+
+ g_variant_unref(value);
+ g_variant_unref(result);
+}
+
+void
+sound_state_manager_deal_with_disconnect (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+ priv->current_state = UNAVAILABLE;
+
+ gchar* image_name = g_hash_table_lookup (priv->volume_states,
+ GINT_TO_POINTER(priv->current_state) );
+ indicator_image_helper_update (priv->speaker_image, image_name);
+}
+
+static void
+sound_state_signal_cb ( GDBusProxy* proxy,
+ gchar* sender_name,
+ gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data)
+{
+ //g_debug ( "!!! sound state manager signal_cb" );
+
+ g_return_if_fail (SOUND_IS_STATE_MANAGER (user_data));
+ SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ g_variant_ref (parameters);
+ GVariant *value = g_variant_get_child_value (parameters, 0);
+ gint update = g_variant_get_int32 (value);
+
+ //g_debug ( "!!! signal_cb with value %i", update);
+
+ priv->current_state = (SoundState)update;
+
+ g_variant_unref (parameters);
+
+ if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_STATE_UPDATE) == 0){
+
+ gchar* image_name = g_hash_table_lookup (priv->volume_states,
+ GINT_TO_POINTER(priv->current_state) );
+ if (priv->current_state == BLOCKED &&
+ sound_state_manager_can_proceed_with_blocking_animation (self) == TRUE) {
+ blocked_id = g_timeout_add_seconds (4,
+ sound_state_manager_start_animation,
+ self);
+ indicator_image_helper_update (priv->speaker_image, image_name);
+
+ }
+ else{
+ indicator_image_helper_update (priv->speaker_image, image_name);
+ }
+ }
+ else {
+ g_warning ("sorry don't know what signal this is - %s", signal_name);
+ }
+
+}
+
+void
+sound_state_manager_style_changed_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data)
+{
+ g_debug("Just caught a style change event");
+ g_return_if_fail (SOUND_IS_STATE_MANAGER (user_data));
+ SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
+ sound_state_manager_reset_mute_blocking_animation (self);
+ sound_state_manager_free_the_animation_list (self);
+ sound_state_manager_prepare_blocked_animation (self);
+}
+
+static void
+sound_state_manager_reset_mute_blocking_animation (SoundStateManager* self)
+{
+ if (animation_id != 0) {
+ //g_debug("about to remove the animation_id callback from the mainloop!!**");
+ g_source_remove(animation_id);
+ animation_id = 0;
+ }
+ if (blocked_id != 0) {
+ //g_debug("about to remove the blocked_id callback from the mainloop!!**");
+ g_source_remove(blocked_id);
+ blocked_id = 0;
+ }
+}
+
+static void
+sound_state_manager_free_the_animation_list (SoundStateManager* self)
+{
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ if (priv->blocked_animation_list != NULL) {
+ g_list_foreach (priv->blocked_animation_list, (GFunc)g_object_unref, NULL);
+ g_list_free (priv->blocked_animation_list);
+ priv->blocked_animation_list = NULL;
+ }
+}
+
+
+static gboolean
+sound_state_manager_start_animation (gpointer userdata)
+{
+ g_return_val_if_fail (SOUND_IS_STATE_MANAGER (userdata), FALSE);
+ SoundStateManager* self = SOUND_STATE_MANAGER (userdata);
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
+
+ blocked_iter = priv->blocked_animation_list;
+ blocked_id = 0;
+ animation_id = g_timeout_add (50,
+ sound_state_manager_fade_back_to_mute_image,
+ self);
+ return FALSE;
+}
+
+static gboolean
+sound_state_manager_fade_back_to_mute_image (gpointer user_data)
+{
+ g_return_val_if_fail (SOUND_IS_STATE_MANAGER (user_data), FALSE);
+ SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE (self);
+
+ if (blocked_iter != NULL) {
+ gtk_image_set_from_pixbuf (priv->speaker_image, blocked_iter->data);
+ blocked_iter = blocked_iter->next;
+ return TRUE;
+ } else {
+ animation_id = 0;
+ //g_debug("exit from animation now\n");
+ g_dbus_proxy_call ( priv->dbus_proxy,
+ "GetSoundState",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)sound_state_manager_get_state_cb,
+ self);
+
+ return FALSE;
+ }
+}
+
+
+// Simple static helper to determine if the coast is clear to animate
+static
+gboolean sound_state_manager_can_proceed_with_blocking_animation (SoundStateManager* self)
+{
+ return (can_animate && blocked_id == 0 && animation_id == 0 );
+}
+
diff --git a/src/sound-state-manager.h b/src/sound-state-manager.h
new file mode 100644
index 0000000..d73d5d9
--- /dev/null
+++ b/src/sound-state-manager.h
@@ -0,0 +1,66 @@
+/*
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@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
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SOUND_STATE_MANAGER_H_
+#define _SOUND_STATE_MANAGER_H_
+
+#include <glib.h>
+#include "common-defs.h"
+
+G_BEGIN_DECLS
+
+#define SOUND_TYPE_STATE_MANAGER (sound_state_manager_get_type ())
+#define SOUND_STATE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUND_TYPE_STATE_MANAGER, SoundStateManager))
+#define SOUND_STATE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUND_TYPE_STATE_MANAGER, SoundStateManagerClass))
+#define SOUND_IS_STATE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUND_TYPE_STATE_MANAGER))
+#define SOUND_IS_STATE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUND_TYPE_STATE_MANAGER))
+#define SOUND_STATE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUND_TYPE_STATE_MANAGER, SoundStateManagerClass))
+
+typedef struct _SoundStateManagerClass SoundStateManagerClass;
+typedef struct _SoundStateManager SoundStateManager;
+
+struct _SoundStateManagerClass
+{
+ GObjectClass parent_class;
+};
+
+struct _SoundStateManager
+{
+ GObject parent_instance;
+};
+
+GType sound_state_manager_get_type (void) G_GNUC_CONST;
+
+void sound_state_manager_style_changed_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data);
+GtkImage* sound_state_manager_get_current_icon (SoundStateManager* self);
+SoundState sound_state_manager_get_current_state (SoundStateManager* self);
+void sound_state_manager_connect_to_dbus (SoundStateManager* self,
+ GDBusProxy* proxy);
+void sound_state_manager_deal_with_disconnect (SoundStateManager* self);
+void sound_state_manager_get_state_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data);
+
+
+
+G_END_DECLS
+
+#endif /* _SOUND_STATE_MANAGER_H_ */
diff --git a/src/title-menu-item.c b/src/title-menu-item.c
index b099abe..8696ff4 100644
--- a/src/title-menu-item.c
+++ b/src/title-menu-item.c
@@ -1,4 +1,4 @@
-/* title-menu-item.c generated by valac 0.11.3, the Vala compiler
+/* title-menu-item.c generated by valac 0.11.5, the Vala compiler
* generated from title-menu-item.vala, do not modify */
/*
diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c
index 0b43e70..9bc1eea 100644
--- a/src/transport-menu-item.c
+++ b/src/transport-menu-item.c
@@ -1,4 +1,4 @@
-/* transport-menu-item.c generated by valac 0.11.3, the Vala compiler
+/* transport-menu-item.c generated by valac 0.11.5, the Vala compiler
* generated from transport-menu-item.vala, do not modify */
/*
@@ -184,10 +184,12 @@ TransportMenuitem* transport_menuitem_new (PlayerController* parent) {
void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMenuitemstate update) {
+ gint temp;
g_return_if_fail (self != NULL);
g_debug ("transport-menu-item.vala:45: UPDATING THE TRANSPORT DBUSMENUITEM PLAY " \
"STATE WITH VALUE %i", (gint) update);
- dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, (gint) update);
+ temp = (gint) update;
+ dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, temp);
}
@@ -224,7 +226,7 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const
input = _tmp4_;
_tmp5_ = g_strdup_printf ("%i", input);
_tmp6_ = _tmp5_;
- g_debug ("transport-menu-item.vala:62: transport menu item -> handle_event with " \
+ g_debug ("transport-menu-item.vala:63: transport menu item -> handle_event with " \
"value %s", _tmp6_);
_g_free0 (_tmp6_);
_tmp7_ = player_item_get_owner ((PlayerItem*) self);
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index e93f0bb..b8f55b5 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -44,7 +44,8 @@ public class TransportMenuitem : PlayerItem
{
debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i",
(int)update);
- this.property_set_int(MENUITEM_PLAY_STATE, update);
+ int temp = (int)update;
+ this.property_set_int(MENUITEM_PLAY_STATE, temp);
}
public override void handle_event(string name,
diff --git a/src/transport-widget.c b/src/transport-widget.c
index a276a31..6ddd4bc 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -289,11 +289,7 @@ transport_widget_motion_notify_event (GtkWidget *menuitem,
event);
priv->motion_event = result;
- cairo_t *cr;
- cr = gdk_cairo_create (menuitem->window);
- draw ( menuitem, cr );
- cairo_destroy ( cr );
-
+ gtk_widget_queue_draw (menuitem);
return TRUE;
}
diff --git a/src/volume-widget.c b/src/volume-widget.c
index 38dc9bb..ceebec5 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -137,7 +137,6 @@ 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);
}
}
}
@@ -157,7 +156,6 @@ volume_widget_set_twin_item(VolumeWidget* self,
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
gtk_range_set_value(range, initial_level);
- determine_state_from_volume(initial_level);
}
static gboolean
@@ -169,7 +167,6 @@ volume_widget_change_value_cb (GtkRange *range,
g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
VolumeWidget* mitem = VOLUME_WIDGET(user_data);
volume_widget_update(mitem, new_value);
- determine_state_from_volume(new_value);
return FALSE;
}