diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-08-10 08:51:49 -0400 |
---|---|---|
committer | Bazaar Package Importer <james.westby@ubuntu.com> | 2011-08-10 08:51:49 -0400 |
commit | 6c6092155258cfdefe7611ddedbc80c1a566ceb2 (patch) | |
tree | 141baab5d51df44b83127a38107e6b15077f02a5 /src | |
parent | 99a07d06dbf69ea43f505b942be718a920ce5d0d (diff) | |
parent | 5701be1eed72f84cec4dff6f7c3674c1870696b9 (diff) | |
download | ayatana-indicator-sound-6c6092155258cfdefe7611ddedbc80c1a566ceb2.tar.gz ayatana-indicator-sound-6c6092155258cfdefe7611ddedbc80c1a566ceb2.tar.bz2 ayatana-indicator-sound-6c6092155258cfdefe7611ddedbc80c1a566ceb2.zip |
* New upstream release.
- Don't allow starting programs via the greeter indicators (LP: #811853)
- support libunity's Track and Player specific items (LP: #824050)
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 11 | ||||
-rw-r--r-- | src/Makefile.in | 115 | ||||
-rw-r--r-- | src/common-defs.h | 2 | ||||
-rw-r--r-- | src/gen-sound-service.xml.c | 11 | ||||
-rw-r--r-- | src/metadata-menu-item.c | 1 | ||||
-rw-r--r-- | src/mpris2-controller.c | 3 | ||||
-rw-r--r-- | src/mpris2-watcher.vala | 2 | ||||
-rw-r--r-- | src/music-player-bridge.c | 71 | ||||
-rw-r--r-- | src/music-player-bridge.h | 38 | ||||
-rw-r--r-- | src/music-player-bridge.vala | 27 | ||||
-rw-r--r-- | src/player-controller.c | 104 | ||||
-rw-r--r-- | src/player-controller.vala | 43 | ||||
-rw-r--r-- | src/playlists-menu-item.c | 3 | ||||
-rw-r--r-- | src/playlists-menu-item.vala | 1 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 100 | ||||
-rw-r--r-- | src/sound-service-dbus.h | 2 | ||||
-rw-r--r-- | src/sound-service-marshal.c | 89 | ||||
-rw-r--r-- | src/sound-service-marshal.h | 20 | ||||
-rw-r--r-- | src/sound-service-marshal.list | 2 | ||||
-rw-r--r-- | src/sound-service.c | 64 | ||||
-rw-r--r-- | src/sound-service.xml | 11 | ||||
-rw-r--r-- | src/specific-items-manager.c | 481 | ||||
-rw-r--r-- | src/specific-items-manager.vala | 107 | ||||
-rw-r--r-- | src/transport-menu-item.c | 1 |
24 files changed, 1215 insertions, 94 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 60c7249..2381429 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,7 @@ libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicat libsoundmenu_la_LIBADD = $(APPLET_LIBS) libsoundmenu_la_LDFLAGS = -module -avoid-version + checkxml: $(srcdir)/sound-service.xml @xmllint -valid -noout $< @echo $< checks out ok @@ -41,6 +42,9 @@ checkxml: $(srcdir)/sound-service.xml # Sound Service #################################################################### +glib_marshal_list = sound-service-marshal.list +glib_marshal_prefix = _sound_service_marshal + ##################### # Sound service vala @@ -48,6 +52,7 @@ checkxml: $(srcdir)/sound-service.xml music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ + specific-items-manager.vala \ metadata-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ @@ -107,6 +112,8 @@ indicator_sound_service_SOURCES = \ mute-menu-item.c \ gen-sound-service.xml.h \ gen-sound-service.xml.c \ + sound-service-marshal.c \ + sound-service-marshal.h \ $(music_bridge_VALASOURCES:.vala=.c) indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall @@ -147,3 +154,7 @@ BUILT_SOURCES = \ CLEANFILES = \ $(BUILT_SOURCES) + +DISTCLEANFILES = + +include $(top_srcdir)/Makefile.am.marshal diff --git a/src/Makefile.in b/src/Makefile.in index e478cd2..3accc56 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -15,6 +15,22 @@ @SET_MAKE@ +# Rules for generating marshal files using glib-genmarshal +# +# Define: +# glib_marshal_list = marshal list file +# glib_marshal_prefix = prefix for marshal functions +# +# before including Makefile.am.marshal. You will also need to have +# the following targets already defined: +# +# CLEANFILES +# DISTCLEANFILES +# BUILT_SOURCES +# EXTRA_DIST +# +# Author: Emmanuele Bassi <ebassi@linux.intel.com> + VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ @@ -36,13 +52,11 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ libexec_PROGRAMS = indicator-sound-service$(EXEEXT) +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.am.marshal 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 @@ -95,6 +109,7 @@ libsoundmenu_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ PROGRAMS = $(libexec_PROGRAMS) am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \ indicator_sound_service-transport-menu-item.$(OBJEXT) \ + indicator_sound_service-specific-items-manager.$(OBJEXT) \ indicator_sound_service-metadata-menu-item.$(OBJEXT) \ indicator_sound_service-player-controller.$(OBJEXT) \ indicator_sound_service-mpris2-interfaces.$(OBJEXT) \ @@ -115,6 +130,7 @@ am_indicator_sound_service_OBJECTS = \ indicator_sound_service-voip-input-menu-item.$(OBJEXT) \ indicator_sound_service-mute-menu-item.$(OBJEXT) \ indicator_sound_service-gen-sound-service.xml.$(OBJEXT) \ + indicator_sound_service-sound-service-marshal.$(OBJEXT) \ $(am__objects_1) indicator_sound_service_OBJECTS = \ $(am_indicator_sound_service_OBJECTS) @@ -196,6 +212,7 @@ GCONF_SCHEMA_CONFIG_SOURCE = @GCONF_SCHEMA_CONFIG_SOURCE@ GCONF_SCHEMA_FILE_DIR = @GCONF_SCHEMA_FILE_DIR@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GLIB_COMPILE_SCHEMAS = @GLIB_COMPILE_SCHEMAS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GNOMELOCALEDIR = @GNOMELOCALEDIR@ @@ -352,6 +369,8 @@ libsoundmenu_la_LDFLAGS = -module -avoid-version #################################################################### # Sound Service #################################################################### +glib_marshal_list = sound-service-marshal.list +glib_marshal_prefix = _sound_service_marshal ##################### # Sound service vala @@ -359,6 +378,7 @@ libsoundmenu_la_LDFLAGS = -module -avoid-version music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ + specific-items-manager.vala \ metadata-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ @@ -413,6 +433,8 @@ indicator_sound_service_SOURCES = \ mute-menu-item.c \ gen-sound-service.xml.h \ gen-sound-service.xml.c \ + sound-service-marshal.c \ + sound-service-marshal.h \ $(music_bridge_VALASOURCES:.vala=.c) indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall @@ -424,32 +446,25 @@ indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_ DBUS_SPECS = \ sound-service.xml -EXTRA_DIST = \ - $(DBUS_SPECS) \ - sound-service.xml \ - $(music_bridge_APIFILES) \ - $(music_bridge_VALASOURCES) - +EXTRA_DIST = $(DBUS_SPECS) sound-service.xml $(music_bridge_APIFILES) \ + $(music_bridge_VALASOURCES) $(glib_marshal_list) ####################### # Stuff to clean Stuff ####################### -BUILT_SOURCES = \ - music_bridge_vala.stamp \ - $(music_bridge_APIFILES) \ - gen-sound-service.xml.h \ - gen-sound-service.xml.c \ - $(music_bridge_VALASOURCES:.vala=.c) - -CLEANFILES = \ - $(BUILT_SOURCES) - +BUILT_SOURCES = music_bridge_vala.stamp $(music_bridge_APIFILES) \ + gen-sound-service.xml.h gen-sound-service.xml.c \ + $(music_bridge_VALASOURCES:.vala=.c) $(marshal_h) $(marshal_c) +CLEANFILES = $(BUILT_SOURCES) stamp-marshal +DISTCLEANFILES = $(marshal_h) $(marshal_c) +marshal_h = $(glib_marshal_list:.list=.h) +marshal_c = $(glib_marshal_list:.list=.c) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.marshal $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -582,8 +597,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-settings-manager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-slider-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service-dbus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service-marshal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-state.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-specific-items-manager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-transport-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-voip-input-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-gen-sound-service.xml.Plo@am__quote@ @@ -836,6 +853,22 @@ indicator_sound_service-gen-sound-service.xml.obj: gen-sound-service.xml.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-gen-sound-service.xml.obj `if test -f 'gen-sound-service.xml.c'; then $(CYGPATH_W) 'gen-sound-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-sound-service.xml.c'; fi` +indicator_sound_service-sound-service-marshal.o: sound-service-marshal.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-sound-service-marshal.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-sound-service-marshal.Tpo -c -o indicator_sound_service-sound-service-marshal.o `test -f 'sound-service-marshal.c' || echo '$(srcdir)/'`sound-service-marshal.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-sound-service-marshal.Tpo $(DEPDIR)/indicator_sound_service-sound-service-marshal.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sound-service-marshal.c' object='indicator_sound_service-sound-service-marshal.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-sound-service-marshal.o `test -f 'sound-service-marshal.c' || echo '$(srcdir)/'`sound-service-marshal.c + +indicator_sound_service-sound-service-marshal.obj: sound-service-marshal.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-sound-service-marshal.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-sound-service-marshal.Tpo -c -o indicator_sound_service-sound-service-marshal.obj `if test -f 'sound-service-marshal.c'; then $(CYGPATH_W) 'sound-service-marshal.c'; else $(CYGPATH_W) '$(srcdir)/sound-service-marshal.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-sound-service-marshal.Tpo $(DEPDIR)/indicator_sound_service-sound-service-marshal.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sound-service-marshal.c' object='indicator_sound_service-sound-service-marshal.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-sound-service-marshal.obj `if test -f 'sound-service-marshal.c'; then $(CYGPATH_W) 'sound-service-marshal.c'; else $(CYGPATH_W) '$(srcdir)/sound-service-marshal.c'; fi` + indicator_sound_service-music-player-bridge.o: music-player-bridge.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-music-player-bridge.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-music-player-bridge.Tpo -c -o indicator_sound_service-music-player-bridge.o `test -f 'music-player-bridge.c' || echo '$(srcdir)/'`music-player-bridge.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-music-player-bridge.Tpo $(DEPDIR)/indicator_sound_service-music-player-bridge.Po @@ -868,6 +901,22 @@ indicator_sound_service-transport-menu-item.obj: transport-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-transport-menu-item.obj `if test -f 'transport-menu-item.c'; then $(CYGPATH_W) 'transport-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/transport-menu-item.c'; fi` +indicator_sound_service-specific-items-manager.o: specific-items-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-specific-items-manager.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-specific-items-manager.Tpo -c -o indicator_sound_service-specific-items-manager.o `test -f 'specific-items-manager.c' || echo '$(srcdir)/'`specific-items-manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-specific-items-manager.Tpo $(DEPDIR)/indicator_sound_service-specific-items-manager.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='specific-items-manager.c' object='indicator_sound_service-specific-items-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-specific-items-manager.o `test -f 'specific-items-manager.c' || echo '$(srcdir)/'`specific-items-manager.c + +indicator_sound_service-specific-items-manager.obj: specific-items-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-specific-items-manager.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-specific-items-manager.Tpo -c -o indicator_sound_service-specific-items-manager.obj `if test -f 'specific-items-manager.c'; then $(CYGPATH_W) 'specific-items-manager.c'; else $(CYGPATH_W) '$(srcdir)/specific-items-manager.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-specific-items-manager.Tpo $(DEPDIR)/indicator_sound_service-specific-items-manager.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='specific-items-manager.c' object='indicator_sound_service-specific-items-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-specific-items-manager.obj `if test -f 'specific-items-manager.c'; then $(CYGPATH_W) 'specific-items-manager.c'; else $(CYGPATH_W) '$(srcdir)/specific-items-manager.c'; fi` + indicator_sound_service-metadata-menu-item.o: metadata-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-metadata-menu-item.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-metadata-menu-item.Tpo -c -o indicator_sound_service-metadata-menu-item.o `test -f 'metadata-menu-item.c' || echo '$(srcdir)/'`metadata-menu-item.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-metadata-menu-item.Tpo $(DEPDIR)/indicator_sound_service-metadata-menu-item.Po @@ -1147,6 +1196,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -1263,6 +1313,27 @@ gen-%.xml.c: %.xml @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ @echo ";" >> $@ +stamp-marshal: $(glib_marshal_list) + $(QUIET_GEN)$(GLIB_GENMARSHAL) \ + --prefix=$(glib_marshal_prefix) \ + --header \ + $(srcdir)/$(glib_marshal_list) > xgen-mh \ + && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \ + && rm -f xgen-mh \ + && echo timestamp > $(@F) + +$(marshal_h): stamp-marshal + @true + +$(marshal_c): $(marshal_h) + $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \ + $(GLIB_GENMARSHAL) \ + --prefix=$(glib_marshal_prefix) \ + --body \ + $(srcdir)/$(glib_marshal_list)) > xgen-mc \ + && cp xgen-mc $(marshal_c) \ + && rm -f xgen-mc + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/common-defs.h b/src/common-defs.h index b1b001e..a20fb03 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -67,6 +67,8 @@ typedef enum { #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" +#define DBUSMENU_TRACK_SPECIFIC_MENUITEM_TYPE "x-canonical-sound-menu-player-track-specific-type" + #define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" #define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist" #define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title" diff --git a/src/gen-sound-service.xml.c b/src/gen-sound-service.xml.c index 2590cae..ec38a89 100644 --- a/src/gen-sound-service.xml.c +++ b/src/gen-sound-service.xml.c @@ -13,11 +13,20 @@ const char * _sound_service = " <arg type='s' name='player_desktop_name' direction=\"in\"/>\n" " <arg type='b' name='result' direction=\"out\"/>\n" " </method>\n" -"\n" " <method name = \"GetSoundState\">\n" " <annotation name=\"org.freedesktop.DBus.GLib.Async\" value=\"true\"/>\n" " <arg type='i' name='current_state' direction=\"out\"/>\n" " </method>\n" +" <method name = \"EnableTrackSpecificItems\">\n" +" <annotation name=\"org.freedesktop.DBus.GLib.Async\" value=\"true\"/>\n" +" <arg type='o' name='player_object_path' direction=\"in\"/>\n" +" <arg type='s' name='player_desktop_id' direction=\"in\"/>\n" +" </method>\n" +" <method name = \"EnablePlayerSpecificItems\">\n" +" <annotation name=\"org.freedesktop.DBus.GLib.Async\" value=\"true\"/>\n" +" <arg type='o' name='player_object_path' direction=\"in\"/>\n" +" <arg type='s' name='player_desktop_id' direction=\"in\"/>\n" +" </method> \n" " <signal name=\"SoundStateUpdate\">\n" " <arg name=\"new_state\" type=\"i\" direction=\"out\"/>\n" " </signal>\n" diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c index 56c0c8c..7e368e2 100644 --- a/src/metadata-menu-item.c +++ b/src/metadata-menu-item.c @@ -122,6 +122,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c index 8b3ad14..b08c8a6 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -26,7 +26,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdlib.h> #include <string.h> #include <common-defs.h> -#include <gee.h> #include <libdbusmenu-glib/client.h> #include <libdbusmenu-glib/dbusmenu-glib.h> #include <libdbusmenu-glib/enum-types.h> @@ -34,6 +33,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/types.h> +#include <gee.h> #define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ()) @@ -238,6 +238,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala index d508959..06ccb6e 100644 --- a/src/mpris2-watcher.vala +++ b/src/mpris2-watcher.vala @@ -38,7 +38,7 @@ public class Mpris2Watcher : GLib.Object this.fdesktop_obj = Bus.get_proxy_sync ( BusType.SESSION, FREEDESKTOP_SERVICE, FREEDESKTOP_OBJECT, - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES ); + DBusProxyFlags.DO_NOT_LOAD_PROPERTIES ); this.fdesktop_obj.name_owner_changed.connect (this.name_changes_detected); this.check_for_active_clients.begin(); } diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index 852acd5..73af633 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -132,6 +132,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; @@ -185,6 +186,10 @@ Mpris2Watcher* mpris2_watcher_new (void); Mpris2Watcher* mpris2_watcher_construct (GType object_type); static void _music_player_bridge_client_has_become_available_mpris2_watcher_client_appeared (Mpris2Watcher* _sender, const gchar* desktop_file_name, const gchar* dbus_name, gboolean use_playlists, gpointer self); static void _music_player_bridge_client_has_vanished_mpris2_watcher_client_disappeared (Mpris2Watcher* _sender, const gchar* dbus_name, gpointer self); +void music_player_bridge_enable_player_specific_items_for_client (MusicPlayerBridge* self, const gchar* object_path, const gchar* desktop_id); +void player_controller_enable_player_specific_items (PlayerController* self, const gchar* object_path); +void music_player_bridge_enable_track_specific_items_for_client (MusicPlayerBridge* self, const gchar* object_path, const gchar* desktop_id); +void player_controller_enable_track_specific_items (PlayerController* self, const gchar* object_path); static GObject * music_player_bridge_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); SettingsManager* settings_manager_new (void); SettingsManager* settings_manager_construct (GType object_type); @@ -537,6 +542,62 @@ void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMe } +void music_player_bridge_enable_player_specific_items_for_client (MusicPlayerBridge* self, const gchar* object_path, const gchar* desktop_id) { + gchar* _tmp0_; + gchar* _tmp1_ = NULL; + gchar* mpris_key; + gboolean _tmp2_; + gpointer _tmp3_ = NULL; + PlayerController* _tmp4_; + g_return_if_fail (self != NULL); + g_return_if_fail (object_path != NULL); + g_return_if_fail (desktop_id != NULL); + _tmp0_ = g_strdup (desktop_id); + _tmp1_ = music_player_bridge_determine_key (_tmp0_); + mpris_key = _tmp1_; + _tmp2_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + if (_tmp2_ == FALSE) { + g_warning ("music-player-bridge.vala:166: we don't have a client with desktop id %" \ +"s registered", desktop_id); + _g_free0 (mpris_key); + return; + } + _tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp4_ = (PlayerController*) _tmp3_; + player_controller_enable_player_specific_items (_tmp4_, object_path); + _g_object_unref0 (_tmp4_); + _g_free0 (mpris_key); +} + + +void music_player_bridge_enable_track_specific_items_for_client (MusicPlayerBridge* self, const gchar* object_path, const gchar* desktop_id) { + gchar* _tmp0_; + gchar* _tmp1_ = NULL; + gchar* mpris_key; + gboolean _tmp2_; + gpointer _tmp3_ = NULL; + PlayerController* _tmp4_; + g_return_if_fail (self != NULL); + g_return_if_fail (object_path != NULL); + g_return_if_fail (desktop_id != NULL); + _tmp0_ = g_strdup (desktop_id); + _tmp1_ = music_player_bridge_determine_key (_tmp0_); + mpris_key = _tmp1_; + _tmp2_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + if (_tmp2_ == FALSE) { + g_warning ("music-player-bridge.vala:177: we don't have a client with desktop id %" \ +"s registered", desktop_id); + _g_free0 (mpris_key); + return; + } + _tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp4_ = (PlayerController*) _tmp3_; + player_controller_enable_track_specific_items (_tmp4_, object_path); + _g_object_unref0 (_tmp4_); + _g_free0 (mpris_key); +} + + static GAppInfo* music_player_bridge_create_app_info (const gchar* desktop) { GAppInfo* result = NULL; GDesktopAppInfo* _tmp0_ = NULL; @@ -554,7 +615,7 @@ static GAppInfo* music_player_bridge_create_app_info (const gchar* desktop) { _tmp1_ = info == NULL; } if (_tmp1_) { - g_warning ("music-player-bridge.vala:166: Could not create a desktopappinfo instan" \ + g_warning ("music-player-bridge.vala:187: Could not create a desktopappinfo instan" \ "ce from app: %s", desktop); result = NULL; _g_object_unref0 (info); @@ -612,7 +673,7 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop) { GError * _error_; _error_ = _inner_error_; _inner_error_ = NULL; - g_warning ("music-player-bridge.vala:182: Error loading keyfile - FileError"); + g_warning ("music-player-bridge.vala:203: Error loading keyfile - FileError"); result = NULL; _g_error_free0 (_error_); _g_key_file_free0 (desktop_keyfile); @@ -625,7 +686,7 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop) { GError * _error_; _error_ = _inner_error_; _inner_error_ = NULL; - g_warning ("music-player-bridge.vala:186: Error loading keyfile - KeyFileError"); + g_warning ("music-player-bridge.vala:207: Error loading keyfile - KeyFileError"); result = NULL; _g_error_free0 (_error_); _g_key_file_free0 (desktop_keyfile); @@ -662,7 +723,7 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop) { GError * _error_; _error_ = _inner_error_; _inner_error_ = NULL; - g_warning ("music-player-bridge.vala:195: Error trying to fetch the icon name from" \ + g_warning ("music-player-bridge.vala:216: Error trying to fetch the icon name from" \ " the keyfile"); result = NULL; _g_error_free0 (_error_); @@ -716,7 +777,7 @@ static gchar* music_player_bridge_determine_key (gchar* desktop_or_interface) { _g_free0 (_result_); _result_ = _tmp6_; } - g_debug ("music-player-bridge.vala:218: determine key result = %s", _result_); + g_debug ("music-player-bridge.vala:239: 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); diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index 7b7bcd8..7db0948 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -65,6 +65,19 @@ typedef struct _TransportMenuitemPrivate TransportMenuitemPrivate; typedef struct _PlayerController PlayerController; typedef struct _PlayerControllerClass PlayerControllerClass; +#define TYPE_SPECIFIC_ITEMS_MANAGER (specific_items_manager_get_type ()) +#define SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManager)) +#define SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) +#define IS_SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SPECIFIC_ITEMS_MANAGER)) +#define IS_SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SPECIFIC_ITEMS_MANAGER)) +#define SPECIFIC_ITEMS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) + +typedef struct _SpecificItemsManager SpecificItemsManager; +typedef struct _SpecificItemsManagerClass SpecificItemsManagerClass; +typedef struct _SpecificItemsManagerPrivate SpecificItemsManagerPrivate; + +#define SPECIFIC_ITEMS_MANAGER_TYPE_CATEGORY (specific_items_manager_category_get_type ()) + #define TYPE_METADATA_MENUITEM (metadata_menuitem_get_type ()) #define METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitem)) #define METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_METADATA_MENUITEM, MetadataMenuitemClass)) @@ -229,6 +242,20 @@ struct _TransportMenuitemClass { PlayerItemClass parent_class; }; +struct _SpecificItemsManager { + GObject parent_instance; + SpecificItemsManagerPrivate * priv; +}; + +struct _SpecificItemsManagerClass { + GObjectClass parent_class; +}; + +typedef enum { + SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK, + SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER +} SpecificItemsManagercategory; + struct _MetadataMenuitem { PlayerItem parent_instance; MetadataMenuitemPrivate * priv; @@ -242,6 +269,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; @@ -400,6 +428,8 @@ MusicPlayerBridge* music_player_bridge_construct (GType object_type); void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, const gchar* desktop, const gchar* dbus_name, gboolean use_playlists); void music_player_bridge_client_has_vanished (MusicPlayerBridge* self, const gchar* mpris_root_interface); void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMenuitem* menu); +void music_player_bridge_enable_player_specific_items_for_client (MusicPlayerBridge* self, const gchar* object_path, const gchar* desktop_id); +void music_player_bridge_enable_track_specific_items_for_client (MusicPlayerBridge* self, const gchar* object_path, const gchar* desktop_id); GType player_item_get_type (void) G_GNUC_CONST; GType transport_menuitem_get_type (void) G_GNUC_CONST; GType player_controller_get_type (void) G_GNUC_CONST; @@ -408,6 +438,11 @@ TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerContro void transport_menuitem_handle_cached_action (TransportMenuitem* self); void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); GeeHashSet* transport_menuitem_attributes_format (void); +GType specific_items_manager_get_type (void) G_GNUC_CONST; +GType specific_items_manager_category_get_type (void) G_GNUC_CONST; +SpecificItemsManager* specific_items_manager_new (PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); +SpecificItemsManager* specific_items_manager_construct (GType object_type, PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); +GeeArrayList* specific_items_manager_get_proxy_items (SpecificItemsManager* self); GType metadata_menuitem_get_type (void) G_GNUC_CONST; extern gchar* metadata_menuitem_album_art_cache_dir; #define METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX "indicators/sound/album-art-cache" @@ -428,6 +463,9 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); void player_controller_activate (PlayerController* self, const gchar* dbus_name); void player_controller_instantiate (PlayerController* self); +void player_controller_enable_track_specific_items (PlayerController* self, const gchar* object_path); +void player_controller_enable_player_specific_items (PlayerController* self, const gchar* object_path); +gint player_controller_track_specific_count (PlayerController* self); void player_controller_remove_from_menu (PlayerController* self); void player_controller_hibernate (PlayerController* self); void player_controller_update_layout (PlayerController* self); diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index b5932fa..72c9bdb 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -27,7 +27,7 @@ public class MusicPlayerBridge : GLib.Object private SettingsManager settings_manager; private Dbusmenu.Menuitem root_menu; - private HashMap<string, PlayerController> registered_clients; + private HashMap<string, PlayerController> registered_clients; private Mpris2Watcher watcher; public MusicPlayerBridge() @@ -158,10 +158,31 @@ public class MusicPlayerBridge : GLib.Object this.watcher.client_disappeared.connect (this.client_has_vanished); } - private static AppInfo? create_app_info ( string desktop ) + public void enable_player_specific_items_for_client (string object_path, + string desktop_id) { - DesktopAppInfo info = new DesktopAppInfo ( desktop ) ; + var mpris_key = determine_key ( desktop_id ); + if (this.registered_clients.has_key (mpris_key) == false){ + warning ("we don't have a client with desktop id %s registered", desktop_id); + return; + } + this.registered_clients[mpris_key].enable_player_specific_items(object_path); + } + public void enable_track_specific_items_for_client (string object_path, + string desktop_id) + { + var mpris_key = determine_key ( desktop_id ); + if (this.registered_clients.has_key (mpris_key) == false){ + warning ("we don't have a client with desktop id %s registered", desktop_id); + return; + } + this.registered_clients[mpris_key].enable_track_specific_items(object_path); + } + + private static AppInfo? create_app_info ( string desktop ) + { + DesktopAppInfo info = new DesktopAppInfo ( desktop ); if ( desktop == null || info == null ){ warning ( "Could not create a desktopappinfo instance from app: %s", desktop ); return null; diff --git a/src/player-controller.c b/src/player-controller.c index 0510150..dbb5536 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -2,7 +2,6 @@ * generated from player-controller.vala, do not modify */ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. Copyright 2010 Canonical Ltd. Authors: @@ -23,7 +22,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> #include <glib-object.h> -#include <gee.h> #include <libdbusmenu-glib/client.h> #include <libdbusmenu-glib/dbusmenu-glib.h> #include <libdbusmenu-glib/enum-types.h> @@ -31,6 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/types.h> +#include <gee.h> #include <stdlib.h> #include <string.h> #include <gio/gio.h> @@ -68,6 +67,16 @@ typedef struct _PlayerItemClass PlayerItemClass; typedef struct _Mpris2Controller Mpris2Controller; typedef struct _Mpris2ControllerClass Mpris2ControllerClass; +#define TYPE_SPECIFIC_ITEMS_MANAGER (specific_items_manager_get_type ()) +#define SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManager)) +#define SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) +#define IS_SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SPECIFIC_ITEMS_MANAGER)) +#define IS_SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SPECIFIC_ITEMS_MANAGER)) +#define SPECIFIC_ITEMS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) + +typedef struct _SpecificItemsManager SpecificItemsManager; +typedef struct _SpecificItemsManagerClass SpecificItemsManagerClass; + #define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ()) #define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ()) @@ -75,6 +84,8 @@ typedef struct _Mpris2ControllerClass Mpris2ControllerClass; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) +#define SPECIFIC_ITEMS_MANAGER_TYPE_CATEGORY (specific_items_manager_category_get_type ()) + #define TYPE_PLAYLISTS_MENUITEM (playlists_menuitem_get_type ()) #define PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitem)) #define PLAYLISTS_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitemClass)) @@ -111,6 +122,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; @@ -121,11 +133,12 @@ struct _PlayerControllerClass { }; struct _PlayerControllerPrivate { - DbusmenuMenuitem* root_menu; gchar* _dbus_name; GAppInfo* _app_info; gint _menu_offset; gchar* _icon_name; + SpecificItemsManager* track_specific_mgr; + SpecificItemsManager* player_specific_mgr; }; typedef enum { @@ -143,6 +156,11 @@ typedef enum { PLAYER_CONTROLLER_STATE_DISCONNECTED } PlayerControllerstate; +typedef enum { + SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK, + SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER +} SpecificItemsManagercategory; + struct _PlayerItem { DbusmenuMenuitem parent_instance; PlayerItemPrivate * priv; @@ -168,6 +186,7 @@ static gpointer player_controller_parent_class = NULL; GType player_controller_get_type (void) G_GNUC_CONST; GType player_item_get_type (void) G_GNUC_CONST; GType mpris2_controller_get_type (void) G_GNUC_CONST; +GType specific_items_manager_get_type (void) G_GNUC_CONST; #define PLAYER_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLAYER_CONTROLLER, PlayerControllerPrivate)) enum { PLAYER_CONTROLLER_DUMMY_PROPERTY, @@ -194,6 +213,13 @@ const gchar* player_controller_get_icon_name (PlayerController* self); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); void player_controller_activate (PlayerController* self, const gchar* dbus_name); void player_controller_instantiate (PlayerController* self); +void player_controller_enable_track_specific_items (PlayerController* self, const gchar* object_path); +GType specific_items_manager_category_get_type (void) G_GNUC_CONST; +SpecificItemsManager* specific_items_manager_new (PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); +SpecificItemsManager* specific_items_manager_construct (GType object_type, PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); +void player_controller_enable_player_specific_items (PlayerController* self, const gchar* object_path); +gint player_controller_track_specific_count (PlayerController* self); +GeeArrayList* specific_items_manager_get_proxy_items (SpecificItemsManager* self); const gchar* player_controller_get_dbus_name (PlayerController* self); Mpris2Controller* mpris2_controller_new (PlayerController* ctrl); Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl); @@ -283,8 +309,8 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit _g_free0 (self->use_playlists); self->use_playlists = _tmp0_; _tmp1_ = _g_object_ref0 (root); - _g_object_unref0 (self->priv->root_menu); - self->priv->root_menu = _tmp1_; + _g_object_unref0 (self->root_menu); + self->root_menu = _tmp1_; player_controller_set_app_info (self, app); player_controller_set_dbus_name (self, dbus_name); player_controller_set_icon_name (self, icon_name); @@ -297,7 +323,7 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit player_controller_establish_mpris_connection (self); player_controller_update_layout (self); _tmp3_ = g_app_info_get_name (self->priv->_app_info); - g_debug ("player-controller.vala:73: New player controller for %s with icon nam" \ + g_debug ("player-controller.vala:74: New player controller for %s with icon nam" \ "e %s", _tmp3_, self->priv->_icon_name); return self; } @@ -312,7 +338,7 @@ void player_controller_update_state (PlayerController* self, PlayerControllersta const gchar* _tmp0_ = NULL; g_return_if_fail (self != NULL); _tmp0_ = g_app_info_get_name (self->priv->_app_info); - g_debug ("player-controller.vala:78: update_state - player controller %s : new s" \ + g_debug ("player-controller.vala:79: update_state - player controller %s : new s" \ "tate %i", _tmp0_, (gint) new_state); self->current_state = (gint) new_state; player_controller_update_layout (self); @@ -332,7 +358,7 @@ void player_controller_instantiate (PlayerController* self) { GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); _tmp0_ = g_app_info_get_name (self->priv->_app_info); - g_debug ("player-controller.vala:98: instantiate in player controller for %s", _tmp0_); + g_debug ("player-controller.vala:99: instantiate in player controller for %s", _tmp0_); g_app_info_launch (self->priv->_app_info, NULL, NULL, &_inner_error_); if (_inner_error_ != NULL) { goto __catch6_g_error; @@ -346,7 +372,7 @@ void player_controller_instantiate (PlayerController* self) { _error_ = _inner_error_; _inner_error_ = NULL; _tmp1_ = g_app_info_get_name (self->priv->_app_info); - g_warning ("player-controller.vala:104: Failed to launch app %s with error message" \ + g_warning ("player-controller.vala:105: Failed to launch app %s with error message" \ ": %s", _tmp1_, _error_->message); _g_error_free0 (_error_); } @@ -359,6 +385,46 @@ void player_controller_instantiate (PlayerController* self) { } +void player_controller_enable_track_specific_items (PlayerController* self, const gchar* object_path) { + g_return_if_fail (self != NULL); + g_return_if_fail (object_path != NULL); + if (self->priv->track_specific_mgr == NULL) { + SpecificItemsManager* _tmp0_ = NULL; + _tmp0_ = specific_items_manager_new (self, object_path, SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK); + _g_object_unref0 (self->priv->track_specific_mgr); + self->priv->track_specific_mgr = _tmp0_; + } +} + + +void player_controller_enable_player_specific_items (PlayerController* self, const gchar* object_path) { + g_return_if_fail (self != NULL); + g_return_if_fail (object_path != NULL); + if (self->priv->player_specific_mgr == NULL) { + SpecificItemsManager* _tmp0_ = NULL; + _tmp0_ = specific_items_manager_new (self, object_path, SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER); + _g_object_unref0 (self->priv->player_specific_mgr); + self->priv->player_specific_mgr = _tmp0_; + } +} + + +gint player_controller_track_specific_count (PlayerController* self) { + gint result = 0; + GeeArrayList* _tmp0_ = NULL; + gint _tmp1_; + g_return_val_if_fail (self != NULL, 0); + if (self->priv->track_specific_mgr == NULL) { + result = 0; + return result; + } + _tmp0_ = specific_items_manager_get_proxy_items (self->priv->track_specific_mgr); + _tmp1_ = gee_collection_get_size ((GeeCollection*) _tmp0_); + result = _tmp1_; + return result; +} + + static gchar* bool_to_string (gboolean self) { gchar* result = NULL; if (self) { @@ -387,13 +453,13 @@ static void player_controller_establish_mpris_connection (PlayerController* self _tmp0_ = self->priv->_dbus_name == NULL; } if (_tmp0_) { - g_debug ("player-controller.vala:112: establish_mpris_connection - Not ready to " \ + g_debug ("player-controller.vala:139: establish_mpris_connection - Not ready to " \ "connect"); return; } _tmp1_ = bool_to_string (*self->use_playlists); _tmp2_ = _tmp1_; - g_debug ("player-controller.vala:115: establish mpris connection - use playlist" \ + g_debug ("player-controller.vala:142: establish mpris connection - use playlist" \ "s value = %s ", _tmp2_); _g_free0 (_tmp2_); _tmp3_ = mpris2_controller_new (self); @@ -440,7 +506,7 @@ void player_controller_remove_from_menu (PlayerController* self) { } _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index); item = (PlayerItem*) _tmp2_; - dbusmenu_menuitem_child_delete (self->priv->root_menu, (DbusmenuMenuitem*) item); + dbusmenu_menuitem_child_delete (self->root_menu, (DbusmenuMenuitem*) item); _g_object_unref0 (item); } _g_object_unref0 (_item_list); @@ -453,7 +519,7 @@ void player_controller_remove_from_menu (PlayerController* self) { _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); _tmp5_ = (PlayerItem*) _tmp4_; playlists_menuitem = IS_PLAYLISTS_MENUITEM (_tmp5_) ? ((PlaylistsMenuitem*) _tmp5_) : NULL; - dbusmenu_menuitem_child_delete (self->priv->root_menu, playlists_menuitem->root_item); + dbusmenu_menuitem_child_delete (self->root_menu, playlists_menuitem->root_item); _g_object_unref0 (playlists_menuitem); } } @@ -508,7 +574,7 @@ void player_controller_update_layout (PlayerController* self) { gboolean _tmp11_; const gchar* _tmp12_ = NULL; g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:146: a call to update layout"); + g_debug ("player-controller.vala:172: a call to update layout"); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); _tmp1_ = (PlayerItem*) _tmp0_; playlists_menuitem = IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL; @@ -607,7 +673,7 @@ static void player_controller_construct_widgets (PlayerController* self) { _tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index); item = (PlayerItem*) _tmp7_; _tmp8_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); - if (_tmp8_ == 3) { + if (_tmp8_ == 4) { PlayerItem* _tmp9_; PlaylistsMenuitem* _tmp10_; PlaylistsMenuitem* playlists_menuitem; @@ -616,12 +682,12 @@ static void player_controller_construct_widgets (PlayerController* self) { _tmp10_ = _g_object_ref0 (IS_PLAYLISTS_MENUITEM (_tmp9_) ? ((PlaylistsMenuitem*) _tmp9_) : NULL); playlists_menuitem = _tmp10_; _tmp11_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); - dbusmenu_menuitem_child_add_position (self->priv->root_menu, playlists_menuitem->root_item, (guint) (self->priv->_menu_offset + _tmp11_)); + dbusmenu_menuitem_child_add_position (self->root_menu, playlists_menuitem->root_item, (guint) (self->priv->_menu_offset + _tmp11_)); _g_object_unref0 (playlists_menuitem); } else { gint _tmp12_; _tmp12_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); - dbusmenu_menuitem_child_add_position (self->priv->root_menu, (DbusmenuMenuitem*) item, (guint) (self->priv->_menu_offset + _tmp12_)); + dbusmenu_menuitem_child_add_position (self->root_menu, (DbusmenuMenuitem*) item, (guint) (self->priv->_menu_offset + _tmp12_)); } _g_object_unref0 (item); } @@ -745,13 +811,15 @@ static void player_controller_instance_init (PlayerController * self) { static void player_controller_finalize (GObject* obj) { PlayerController * self; self = PLAYER_CONTROLLER (obj); - _g_object_unref0 (self->priv->root_menu); + _g_object_unref0 (self->root_menu); _g_free0 (self->priv->_dbus_name); _g_object_unref0 (self->custom_items); _g_object_unref0 (self->mpris_bridge); _g_object_unref0 (self->priv->_app_info); _g_free0 (self->priv->_icon_name); _g_free0 (self->use_playlists); + _g_object_unref0 (self->priv->track_specific_mgr); + _g_object_unref0 (self->priv->player_specific_mgr); G_OBJECT_CLASS (player_controller_parent_class)->finalize (obj); } diff --git a/src/player-controller.vala b/src/player-controller.vala index a08f692..ced7d96 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -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: @@ -42,7 +41,7 @@ public class PlayerController : GLib.Object public int current_state = state.OFFLINE; - private Dbusmenu.Menuitem root_menu; + public Dbusmenu.Menuitem root_menu; public string dbus_name { get; set;} public ArrayList<PlayerItem> custom_items; public Mpris2Controller mpris_bridge; @@ -50,6 +49,8 @@ public class PlayerController : GLib.Object public int menu_offset { get; set;} public string icon_name { get; set; } public bool? use_playlists; + private SpecificItemsManager track_specific_mgr; + private SpecificItemsManager player_specific_mgr; public PlayerController(Dbusmenu.Menuitem root, GLib.AppInfo app, @@ -105,7 +106,33 @@ public class PlayerController : GLib.Object error.message ); } } + + public void enable_track_specific_items (string object_path) + { + if (this.track_specific_mgr == null){ + track_specific_mgr = new SpecificItemsManager (this, + object_path, + SpecificItemsManager.category.TRACK); + } + } + + public void enable_player_specific_items (string object_path) + { + if (this.player_specific_mgr == null){ + player_specific_mgr = new SpecificItemsManager (this, + object_path, + SpecificItemsManager.category.PLAYER); + } + } + public int track_specific_count () + { + if (this.track_specific_mgr == null) { + return 0; + } + return this.track_specific_mgr.proxy_items.size; + } + private void establish_mpris_connection() { if(this.current_state != state.READY || this.dbus_name == null ){ @@ -114,9 +141,8 @@ public class PlayerController : GLib.Object } debug ( " establish mpris connection - use playlists value = %s ", this.use_playlists.to_string() ); - - this.mpris_bridge = new Mpris2Controller(this); - this.determine_state(); + this.mpris_bridge = new Mpris2Controller (this); + this.determine_state (); } public void remove_from_menu() @@ -186,16 +212,17 @@ public class PlayerController : GLib.Object this.custom_items.add(playlist_menuitem); foreach(PlayerItem item in this.custom_items){ - if (this.custom_items.index_of(item) == 3) { + if (this.custom_items.index_of(item) == 4) { PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); } else{ - root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + root_menu.child_add_position (item, + this.menu_offset + this.custom_items.index_of(item)); } } } - + private void determine_state() { if(this.mpris_bridge.connected() == true){ diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c index c87dab1..fe673e1 100644 --- a/src/playlists-menu-item.c +++ b/src/playlists-menu-item.c @@ -124,6 +124,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; @@ -482,7 +483,7 @@ static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (menu_item_id)); if (!_tmp0_) { - g_warning ("playlists-menu-item.vala:125: item %i was activated but we don't have " \ + g_warning ("playlists-menu-item.vala:124: item %i was activated but we don't have " \ "a corresponding playlist", menu_item_id); return; } diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 7faa214..452a586 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -39,7 +39,6 @@ public class PlaylistsMenuitem : PlayerItem this.root_item = new Menuitem(); this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") ); this.root_item.property_set ( MENUITEM_PATH, "" ); - } public new void update (PlaylistDetails[] playlists) diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 6fb0a64..b69f081 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -32,6 +32,7 @@ #include "device.h" #include "gen-sound-service.xml.h" #include "dbus-shared-names.h" +#include "sound-service-marshal.h" // DBUS methods static void bus_method_call (GDBusConnection * connection, @@ -56,8 +57,17 @@ struct _SoundServiceDbusPrivate { GDBusConnection* connection; DbusmenuMenuitem* root_menuitem; Device* device; + gboolean greeter_mode; }; +enum { + TRACK_SPECIFIC_ITEM, + PLAYER_SPECIFIC_ITEM, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + static GDBusNodeInfo * node_info = NULL; static GDBusInterfaceInfo * interface_info = NULL; @@ -110,6 +120,22 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); } } + signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + _sound_service_marshal_VOID__STRING_STRING, + G_TYPE_NONE, 2, G_TYPE_STRING, + G_TYPE_STRING); + signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + _sound_service_marshal_VOID__STRING_STRING, + G_TYPE_NONE, 2, G_TYPE_STRING, + G_TYPE_STRING); } static void @@ -144,11 +170,11 @@ sound_service_dbus_init (SoundServiceDbus *self) } DbusmenuMenuitem* -sound_service_dbus_create_root_item (SoundServiceDbus* self) +sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode) { SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); + priv->greeter_mode = greeter_mode; 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); @@ -169,25 +195,27 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, dbusmenu_menuitem_child_add_position (priv->root_menuitem, slider_item, 1); dbusmenu_menuitem_child_add_position (priv->root_menuitem, voip_input_menu_item, 2); - // Separator - DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); - - dbusmenu_menuitem_property_set (separator, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); - g_object_unref (separator); - - // Sound preferences dialog - DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new(); - - dbusmenu_menuitem_property_set( settings_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Sound Settings...")); - 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); + if (!priv->greeter_mode) { + // Separator + DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); + + dbusmenu_menuitem_property_set (separator, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); + g_object_unref (separator); + + // Sound preferences dialog + DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new(); + + dbusmenu_menuitem_property_set( settings_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Sound Settings...")); + 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); + } } /** @@ -297,6 +325,36 @@ bus_method_call (GDBusConnection * connection, player_name); retval = g_variant_new ("(b)", result); } + else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) { + g_debug ("EnableTrackSpecificItems"); + gchar* player_object_path; + gchar* player_id; + g_variant_get (params, "(os)", &player_object_path, &player_id); + //g_debug ("object path = %s and id = %s", player_object_path, player_id); + g_signal_emit (service, + signals[TRACK_SPECIFIC_ITEM], + 0, + player_object_path, + player_id); + g_free (player_object_path); + g_free (player_id); + + } + else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) { + gchar* player_object_path; + gchar* player_id; + g_variant_get (params, "(os)", &player_object_path, &player_id); + g_debug ("PLayer specific item - object path = %s and id = %s", + player_object_path, + player_id); + g_signal_emit (service, + signals[PLAYER_SPECIFIC_ITEM], + 0, + player_object_path, + player_id); + g_free (player_object_path); + g_free (player_id); + } else { g_warning("Calling method '%s' on the sound service but it's unknown", method); } diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index 9b19a5e..1c15fc7 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -53,7 +53,7 @@ struct _SoundServiceDbusClass { GType sound_service_dbus_get_type (void) G_GNUC_CONST; -DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self); +DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode); void sound_service_dbus_update_sound_state (SoundServiceDbus* self, SoundState new_state); void sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, DbusmenuMenuitem* mute_item, diff --git a/src/sound-service-marshal.c b/src/sound-service-marshal.c new file mode 100644 index 0000000..3f75f3a --- /dev/null +++ b/src/sound-service-marshal.c @@ -0,0 +1,89 @@ +#include "sound-service-marshal.h" + +#include <glib-object.h> + + +#ifdef G_ENABLE_DEBUG +#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) +#define g_marshal_value_peek_char(v) g_value_get_char (v) +#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) +#define g_marshal_value_peek_int(v) g_value_get_int (v) +#define g_marshal_value_peek_uint(v) g_value_get_uint (v) +#define g_marshal_value_peek_long(v) g_value_get_long (v) +#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) +#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) +#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) +#define g_marshal_value_peek_enum(v) g_value_get_enum (v) +#define g_marshal_value_peek_flags(v) g_value_get_flags (v) +#define g_marshal_value_peek_float(v) g_value_get_float (v) +#define g_marshal_value_peek_double(v) g_value_get_double (v) +#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) +#define g_marshal_value_peek_param(v) g_value_get_param (v) +#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) +#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) +#define g_marshal_value_peek_object(v) g_value_get_object (v) +#define g_marshal_value_peek_variant(v) g_value_get_variant (v) +#else /* !G_ENABLE_DEBUG */ +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. + * Do not access GValues directly in your code. Instead, use the + * g_value_get_*() functions + */ +#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int +#define g_marshal_value_peek_char(v) (v)->data[0].v_int +#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint +#define g_marshal_value_peek_int(v) (v)->data[0].v_int +#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint +#define g_marshal_value_peek_long(v) (v)->data[0].v_long +#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 +#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong +#define g_marshal_value_peek_float(v) (v)->data[0].v_float +#define g_marshal_value_peek_double(v) (v)->data[0].v_double +#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer +#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer +#endif /* !G_ENABLE_DEBUG */ + + +/* VOID:STRING,STRING (./sound-service-marshal.list:1) */ +void +_sound_service_marshal_VOID__STRING_STRING (GClosure *closure, + GValue *return_value G_GNUC_UNUSED, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint G_GNUC_UNUSED, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_VOID__STRING_STRING callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + data2); +} + diff --git a/src/sound-service-marshal.h b/src/sound-service-marshal.h new file mode 100644 index 0000000..9c48351 --- /dev/null +++ b/src/sound-service-marshal.h @@ -0,0 +1,20 @@ + +#ifndef ___sound_service_marshal_MARSHAL_H__ +#define ___sound_service_marshal_MARSHAL_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/* VOID:STRING,STRING (./sound-service-marshal.list:1) */ +extern void _sound_service_marshal_VOID__STRING_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +G_END_DECLS + +#endif /* ___sound_service_marshal_MARSHAL_H__ */ + diff --git a/src/sound-service-marshal.list b/src/sound-service-marshal.list new file mode 100644 index 0000000..4c756d4 --- /dev/null +++ b/src/sound-service-marshal.list @@ -0,0 +1,2 @@ +VOID:STRING,STRING + diff --git a/src/sound-service.c b/src/sound-service.c index 1324537..0170f81 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -17,19 +17,18 @@ 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 <locale.h> + #include "sound-service.h" #include "pulseaudio-mgr.h" #include "sound-service-dbus.h" #include "music-player-bridge.h" -#include <locale.h> - static GMainLoop *mainloop = NULL; - -/**********************************************************************************************************************/ +static MusicPlayerBridge* player_bridge = NULL; +/***********************************************************************************************************/ // Init and exit functions /**********************************************************************************************************************/ - /** service_shutdown: When the service interface starts to shutdown, we @@ -47,29 +46,74 @@ service_shutdown (IndicatorService *service, gpointer user_data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + +void +on_player_specific_item_requested (SoundServiceDbus* sound_service, + const gchar* desktop_id, + const gchar* player_object_path, + gpointer userdata) +{ + if (player_bridge != NULL){ + music_player_bridge_enable_player_specific_items_for_client (player_bridge, + desktop_id, + player_object_path); + } +} + +void +on_track_specific_item_requested (SoundServiceDbus* sound_service, + const gchar* desktop_id, + const gchar* player_object_path, + gpointer userdata) +{ + if (player_bridge != NULL){ + music_player_bridge_enable_track_specific_items_for_client (player_bridge, + desktop_id, + player_object_path); + } +} + /** main: **/ int main (int argc, char ** argv) { + gboolean greeter_mode; g_type_init(); textdomain (GETTEXT_PACKAGE); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); setlocale (LC_ALL, ""); - IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_DBUS_VERSION); + IndicatorService *service = indicator_service_new_version (INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_VERSION); g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_shutdown), NULL); SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); + g_signal_connect(G_OBJECT(sound_service), + "track-specific-item-requested", + G_CALLBACK(on_track_specific_item_requested), NULL); + g_signal_connect(G_OBJECT(sound_service), + "player-specific-item-requested", + G_CALLBACK(on_player_specific_item_requested), 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); + greeter_mode = get_greeter_mode(); + + DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service, greeter_mode); + if (!greeter_mode) { + player_bridge = music_player_bridge_new(); + music_player_bridge_set_root_menu_item(player_bridge, root_menuitem); + } // Run the loop mainloop = g_main_loop_new(NULL, FALSE); diff --git a/src/sound-service.xml b/src/sound-service.xml index 517088e..796fa22 100644 --- a/src/sound-service.xml +++ b/src/sound-service.xml @@ -12,11 +12,20 @@ <arg type='s' name='player_desktop_name' direction="in"/> <arg type='b' name='result' direction="out"/> </method> - <method name = "GetSoundState"> <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> <arg type='i' name='current_state' direction="out"/> </method> + <method name = "EnableTrackSpecificItems"> + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> + <arg type='o' name='player_object_path' direction="in"/> + <arg type='s' name='player_desktop_id' direction="in"/> + </method> + <method name = "EnablePlayerSpecificItems"> + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> + <arg type='o' name='player_object_path' direction="in"/> + <arg type='s' name='player_desktop_id' direction="in"/> + </method> <signal name="SoundStateUpdate"> <arg name="new_state" type="i" direction="out"/> </signal> diff --git a/src/specific-items-manager.c b/src/specific-items-manager.c new file mode 100644 index 0000000..b01e8c1 --- /dev/null +++ b/src/specific-items-manager.c @@ -0,0 +1,481 @@ +/* specific-items-manager.c generated by valac 0.12.1, the Vala compiler + * generated from specific-items-manager.vala, do not modify */ + +/* +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 <glib.h> +#include <glib-object.h> +#include <stdlib.h> +#include <string.h> +#include <libdbusmenu-glib/client.h> +#include <libdbusmenu-glib/dbusmenu-glib.h> +#include <libdbusmenu-glib/enum-types.h> +#include <libdbusmenu-glib/menuitem-proxy.h> +#include <libdbusmenu-glib/menuitem.h> +#include <libdbusmenu-glib/server.h> +#include <libdbusmenu-glib/types.h> +#include <gee.h> + + +#define TYPE_SPECIFIC_ITEMS_MANAGER (specific_items_manager_get_type ()) +#define SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManager)) +#define SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) +#define IS_SPECIFIC_ITEMS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SPECIFIC_ITEMS_MANAGER)) +#define IS_SPECIFIC_ITEMS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SPECIFIC_ITEMS_MANAGER)) +#define SPECIFIC_ITEMS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerClass)) + +typedef struct _SpecificItemsManager SpecificItemsManager; +typedef struct _SpecificItemsManagerClass SpecificItemsManagerClass; +typedef struct _SpecificItemsManagerPrivate SpecificItemsManagerPrivate; + +#define TYPE_PLAYER_CONTROLLER (player_controller_get_type ()) +#define PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_CONTROLLER, PlayerController)) +#define PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_CONTROLLER, PlayerControllerClass)) +#define IS_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_CONTROLLER)) +#define IS_PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_CONTROLLER)) +#define PLAYER_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_CONTROLLER, PlayerControllerClass)) + +typedef struct _PlayerController PlayerController; +typedef struct _PlayerControllerClass PlayerControllerClass; + +#define SPECIFIC_ITEMS_MANAGER_TYPE_CATEGORY (specific_items_manager_category_get_type ()) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_free0(var) (var = (g_free (var), NULL)) +typedef struct _PlayerControllerPrivate PlayerControllerPrivate; + +#define TYPE_PLAYER_ITEM (player_item_get_type ()) +#define PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_ITEM, PlayerItem)) +#define PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_ITEM, PlayerItemClass)) +#define IS_PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_ITEM)) +#define IS_PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_ITEM)) +#define PLAYER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_ITEM, PlayerItemClass)) + +typedef struct _PlayerItem PlayerItem; +typedef struct _PlayerItemClass PlayerItemClass; + +#define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ()) +#define MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2Controller)) +#define MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass)) +#define IS_MPRIS2_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS2_CONTROLLER)) +#define IS_MPRIS2_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS2_CONTROLLER)) +#define MPRIS2_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerClass)) + +typedef struct _Mpris2Controller Mpris2Controller; +typedef struct _Mpris2ControllerClass Mpris2ControllerClass; +#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL))) + +struct _SpecificItemsManager { + GObject parent_instance; + SpecificItemsManagerPrivate * priv; +}; + +struct _SpecificItemsManagerClass { + GObjectClass parent_class; +}; + +struct _SpecificItemsManagerPrivate { + PlayerController* _owner; + gchar* dbus_path; + DbusmenuClient* client; + GeeArrayList* _proxy_items; + gint of_type; +}; + +typedef enum { + SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK, + SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER +} SpecificItemsManagercategory; + +struct _PlayerController { + GObject parent_instance; + PlayerControllerPrivate * priv; + gint current_state; + DbusmenuMenuitem* root_menu; + GeeArrayList* custom_items; + Mpris2Controller* mpris_bridge; + gboolean* use_playlists; +}; + +struct _PlayerControllerClass { + GObjectClass parent_class; +}; + + +static gpointer specific_items_manager_parent_class = NULL; + +GType specific_items_manager_get_type (void) G_GNUC_CONST; +GType player_controller_get_type (void) G_GNUC_CONST; +#define SPECIFIC_ITEMS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SPECIFIC_ITEMS_MANAGER, SpecificItemsManagerPrivate)) +enum { + SPECIFIC_ITEMS_MANAGER_DUMMY_PROPERTY, + SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS +}; +GType specific_items_manager_category_get_type (void) G_GNUC_CONST; +SpecificItemsManager* specific_items_manager_new (PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); +SpecificItemsManager* specific_items_manager_construct (GType object_type, PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type); +static void specific_items_manager_set_owner (SpecificItemsManager* self, PlayerController* value); +static PlayerController* specific_items_manager_get_owner (SpecificItemsManager* self); +const gchar* player_controller_get_dbus_name (PlayerController* self); +static void specific_items_manager_on_root_changed (SpecificItemsManager* self, GObject* newroot); +static void _specific_items_manager_on_root_changed_dbusmenu_client_root_changed (DbusmenuClient* _sender, GObject* newroot, gpointer self); +static gint specific_items_manager_figure_out_positioning (SpecificItemsManager* self); +gint player_controller_get_menu_offset (PlayerController* self); +GeeArrayList* specific_items_manager_get_proxy_items (SpecificItemsManager* self); +gint player_controller_track_specific_count (PlayerController* self); +GType player_item_get_type (void) G_GNUC_CONST; +GType mpris2_controller_get_type (void) G_GNUC_CONST; +static gboolean _bool_equal (const gboolean* s1, const gboolean* s2); +static void specific_items_manager_on_child_added (SpecificItemsManager* self, GObject* child, guint position); +static void _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added (DbusmenuMenuitem* _sender, GObject* child, guint position, gpointer self); +static void specific_items_manager_on_child_removed (SpecificItemsManager* self, GObject* child); +static void _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed (DbusmenuMenuitem* _sender, GObject* child, gpointer self); +static void specific_items_manager_set_proxy_items (SpecificItemsManager* self, GeeArrayList* value); +static GObject * specific_items_manager_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void specific_items_manager_finalize (GObject* obj); +static void _vala_specific_items_manager_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void _vala_specific_items_manager_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); + + +GType specific_items_manager_category_get_type (void) { + static volatile gsize specific_items_manager_category_type_id__volatile = 0; + if (g_once_init_enter (&specific_items_manager_category_type_id__volatile)) { + static const GEnumValue values[] = {{SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK, "SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK", "track"}, {SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER, "SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER", "player"}, {0, NULL, NULL}}; + GType specific_items_manager_category_type_id; + specific_items_manager_category_type_id = g_enum_register_static ("SpecificItemsManagercategory", values); + g_once_init_leave (&specific_items_manager_category_type_id__volatile, specific_items_manager_category_type_id); + } + return specific_items_manager_category_type_id__volatile; +} + + +static void _specific_items_manager_on_root_changed_dbusmenu_client_root_changed (DbusmenuClient* _sender, GObject* newroot, gpointer self) { + specific_items_manager_on_root_changed (self, newroot); +} + + +SpecificItemsManager* specific_items_manager_construct (GType object_type, PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type) { + SpecificItemsManager * self = NULL; + gchar* _tmp0_; + const gchar* _tmp1_ = NULL; + DbusmenuClient* _tmp2_ = NULL; + g_return_val_if_fail (controller != NULL, NULL); + g_return_val_if_fail (path != NULL, NULL); + self = (SpecificItemsManager*) g_object_new (object_type, NULL); + self->priv->of_type = (gint) which_type; + specific_items_manager_set_owner (self, controller); + _tmp0_ = g_strdup (path); + _g_free0 (self->priv->dbus_path); + self->priv->dbus_path = _tmp0_; + _tmp1_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp2_ = dbusmenu_client_new (_tmp1_, self->priv->dbus_path); + _g_object_unref0 (self->priv->client); + self->priv->client = _tmp2_; + g_signal_connect_object (self->priv->client, "root-changed", (GCallback) _specific_items_manager_on_root_changed_dbusmenu_client_root_changed, self, 0); + return self; +} + + +SpecificItemsManager* specific_items_manager_new (PlayerController* controller, const gchar* path, SpecificItemsManagercategory which_type) { + return specific_items_manager_construct (TYPE_SPECIFIC_ITEMS_MANAGER, controller, path, which_type); +} + + +static gboolean _bool_equal (const gboolean* s1, const gboolean* s2) { + if (s1 == s2) { + return TRUE; + } + if (s1 == NULL) { + return FALSE; + } + if (s2 == NULL) { + return FALSE; + } + return (*s1) == (*s2); +} + + +static gint specific_items_manager_figure_out_positioning (SpecificItemsManager* self) { + gint result = 0; + gint _result_; + g_return_val_if_fail (self != NULL, 0); + _result_ = 0; + if (self->priv->of_type == SPECIFIC_ITEMS_MANAGER_CATEGORY_TRACK) { + gint _tmp0_; + gint _tmp1_; + _tmp0_ = player_controller_get_menu_offset (self->priv->_owner); + _tmp1_ = gee_collection_get_size ((GeeCollection*) self->priv->_proxy_items); + _result_ = (_tmp0_ + 4) + _tmp1_; + } else { + if (self->priv->of_type == SPECIFIC_ITEMS_MANAGER_CATEGORY_PLAYER) { + gint _tmp2_; + gint _tmp3_; + gint pos; + gint _tmp4_ = 0; + gboolean _tmp5_; + _tmp2_ = player_controller_get_menu_offset (self->priv->_owner); + _tmp3_ = player_controller_track_specific_count (self->priv->_owner); + pos = (_tmp2_ + 4) + _tmp3_; + _tmp5_ = TRUE; + if (_bool_equal (self->priv->_owner->use_playlists, &_tmp5_) == TRUE) { + _tmp4_ = 1; + } else { + _tmp4_ = 0; + } + pos = pos + _tmp4_; + _result_ = pos; + } + } + g_debug ("specific-items-manager.vala:61: !!!!! Menu pos of type %i is = %i", self->priv->of_type, _result_); + result = _result_; + return result; +} + + +static gpointer _g_object_ref0 (gpointer self) { + return self ? g_object_ref (self) : NULL; +} + + +static void _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added (DbusmenuMenuitem* _sender, GObject* child, guint position, gpointer self) { + specific_items_manager_on_child_added (self, child, position); +} + + +static void _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed (DbusmenuMenuitem* _sender, GObject* child, gpointer self) { + specific_items_manager_on_child_removed (self, child); +} + + +static void specific_items_manager_on_root_changed (SpecificItemsManager* self, GObject* newroot) { + DbusmenuMenuitem* _tmp4_ = NULL; + DbusmenuMenuitem* _tmp5_; + DbusmenuMenuitem* root; + GList* _tmp6_ = NULL; + GList* _tmp7_ = NULL; + GList* children; + g_return_if_fail (self != NULL); + if (newroot == NULL) { + gint _tmp3_; + g_debug ("specific-items-manager.vala:68: root disappeared -remove proxyitems"); + { + GeeArrayList* _tmp0_; + GeeArrayList* _p_list; + gint _tmp1_; + gint _p_size; + gint _p_index; + _tmp0_ = _g_object_ref0 (self->priv->_proxy_items); + _p_list = _tmp0_; + _tmp1_ = gee_collection_get_size ((GeeCollection*) _p_list); + _p_size = _tmp1_; + _p_index = -1; + while (TRUE) { + gpointer _tmp2_ = NULL; + DbusmenuMenuitemProxy* p; + _p_index = _p_index + 1; + if (!(_p_index < _p_size)) { + break; + } + _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _p_list, _p_index); + p = (DbusmenuMenuitemProxy*) _tmp2_; + dbusmenu_menuitem_child_delete (self->priv->_owner->root_menu, (DbusmenuMenuitem*) p); + _g_object_unref0 (p); + } + _g_object_unref0 (_p_list); + } + gee_abstract_collection_clear ((GeeAbstractCollection*) self->priv->_proxy_items); + _tmp3_ = gee_collection_get_size ((GeeCollection*) self->priv->_proxy_items); + g_debug ("specific-items-manager.vala:73: array list size is now %i", _tmp3_); + return; + } + _tmp4_ = dbusmenu_client_get_root (self->priv->client); + _tmp5_ = _g_object_ref0 (_tmp4_); + root = _tmp5_; + g_signal_connect_object (root, "child-added", (GCallback) _specific_items_manager_on_child_added_dbusmenu_menuitem_child_added, self, 0); + g_signal_connect_object (root, "child-removed", (GCallback) _specific_items_manager_on_child_removed_dbusmenu_menuitem_child_removed, self, 0); + _tmp6_ = dbusmenu_menuitem_get_children (root); + _tmp7_ = g_list_copy (_tmp6_); + children = _tmp7_; + { + GList* child_collection; + GList* child_it; + child_collection = children; + for (child_it = child_collection; child_it != NULL; child_it = child_it->next) { + void* child; + child = child_it->data; + { + gint _tmp8_; + gint pos; + DbusmenuMenuitem* item; + DbusmenuMenuitemProxy* _tmp9_ = NULL; + DbusmenuMenuitemProxy* proxy; + const gchar* _tmp10_ = NULL; + _tmp8_ = specific_items_manager_figure_out_positioning (self); + pos = _tmp8_; + item = DBUSMENU_MENUITEM (child); + _tmp9_ = dbusmenu_menuitem_proxy_new (item); + proxy = _tmp9_; + gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->_proxy_items, proxy); + _tmp10_ = dbusmenu_menuitem_property_get (item, DBUSMENU_MENUITEM_PROP_LABEL); + g_debug ("specific-items-manager.vala:90: Proxy item of label = %s added to coll" \ +"ection", _tmp10_); + dbusmenu_menuitem_child_add_position (self->priv->_owner->root_menu, (DbusmenuMenuitem*) proxy, (guint) pos); + _g_object_unref0 (proxy); + } + } + } + _g_list_free0 (children); + _g_object_unref0 (root); +} + + +static void specific_items_manager_on_child_added (SpecificItemsManager* self, GObject* child, guint position) { + g_return_if_fail (self != NULL); + g_return_if_fail (child != NULL); + g_debug ("specific-items-manager.vala:99: On child added Specific root node"); +} + + +static void specific_items_manager_on_child_removed (SpecificItemsManager* self, GObject* child) { + g_return_if_fail (self != NULL); + g_return_if_fail (child != NULL); + g_debug ("specific-items-manager.vala:104: On child removed Specific root node"); +} + + +static PlayerController* specific_items_manager_get_owner (SpecificItemsManager* self) { + PlayerController* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_owner; + return result; +} + + +static void specific_items_manager_set_owner (SpecificItemsManager* self, PlayerController* value) { + PlayerController* _tmp0_; + g_return_if_fail (self != NULL); + _tmp0_ = _g_object_ref0 (value); + _g_object_unref0 (self->priv->_owner); + self->priv->_owner = _tmp0_; +} + + +GeeArrayList* specific_items_manager_get_proxy_items (SpecificItemsManager* self) { + GeeArrayList* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_proxy_items; + return result; +} + + +static void specific_items_manager_set_proxy_items (SpecificItemsManager* self, GeeArrayList* value) { + GeeArrayList* _tmp0_; + g_return_if_fail (self != NULL); + _tmp0_ = _g_object_ref0 (value); + _g_object_unref0 (self->priv->_proxy_items); + self->priv->_proxy_items = _tmp0_; + g_object_notify ((GObject *) self, "proxy-items"); +} + + +static GObject * specific_items_manager_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + SpecificItemsManager * self; + GeeArrayList* _tmp0_ = NULL; + GeeArrayList* _tmp1_; + parent_class = G_OBJECT_CLASS (specific_items_manager_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = SPECIFIC_ITEMS_MANAGER (obj); + _tmp0_ = gee_array_list_new (DBUSMENU_TYPE_MENUITEM_PROXY, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + _tmp1_ = _tmp0_; + specific_items_manager_set_proxy_items (self, _tmp1_); + _g_object_unref0 (_tmp1_); + return obj; +} + + +static void specific_items_manager_class_init (SpecificItemsManagerClass * klass) { + specific_items_manager_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (SpecificItemsManagerPrivate)); + G_OBJECT_CLASS (klass)->get_property = _vala_specific_items_manager_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_specific_items_manager_set_property; + G_OBJECT_CLASS (klass)->constructor = specific_items_manager_constructor; + G_OBJECT_CLASS (klass)->finalize = specific_items_manager_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS, g_param_spec_object ("proxy-items", "proxy-items", "proxy-items", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); +} + + +static void specific_items_manager_instance_init (SpecificItemsManager * self) { + self->priv = SPECIFIC_ITEMS_MANAGER_GET_PRIVATE (self); +} + + +static void specific_items_manager_finalize (GObject* obj) { + SpecificItemsManager * self; + self = SPECIFIC_ITEMS_MANAGER (obj); + _g_object_unref0 (self->priv->_owner); + _g_free0 (self->priv->dbus_path); + _g_object_unref0 (self->priv->client); + _g_object_unref0 (self->priv->_proxy_items); + G_OBJECT_CLASS (specific_items_manager_parent_class)->finalize (obj); +} + + +GType specific_items_manager_get_type (void) { + static volatile gsize specific_items_manager_type_id__volatile = 0; + if (g_once_init_enter (&specific_items_manager_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (SpecificItemsManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) specific_items_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SpecificItemsManager), 0, (GInstanceInitFunc) specific_items_manager_instance_init, NULL }; + GType specific_items_manager_type_id; + specific_items_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "SpecificItemsManager", &g_define_type_info, 0); + g_once_init_leave (&specific_items_manager_type_id__volatile, specific_items_manager_type_id); + } + return specific_items_manager_type_id__volatile; +} + + +static void _vala_specific_items_manager_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + SpecificItemsManager * self; + self = SPECIFIC_ITEMS_MANAGER (object); + switch (property_id) { + case SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS: + g_value_set_object (value, specific_items_manager_get_proxy_items (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void _vala_specific_items_manager_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + SpecificItemsManager * self; + self = SPECIFIC_ITEMS_MANAGER (object); + switch (property_id) { + case SPECIFIC_ITEMS_MANAGER_PROXY_ITEMS: + specific_items_manager_set_proxy_items (self, g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + + diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala new file mode 100644 index 0000000..d26199f --- /dev/null +++ b/src/specific-items-manager.vala @@ -0,0 +1,107 @@ +/* +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/>. +*/ + +using Dbusmenu; +using Gee; + +public class SpecificItemsManager : GLib.Object +{ + public static enum category{ + TRACK, + PLAYER + } + + private PlayerController owner {get; set;} + private string dbus_path; + private Dbusmenu.Client client; + public Gee.ArrayList<Dbusmenu.MenuitemProxy> proxy_items {get; construct;} + private int of_type; + + public SpecificItemsManager (PlayerController controller, + string path, + category which_type) + { + this.of_type = which_type; + this.owner = controller; + this.dbus_path = path; + this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); + this.client.root_changed.connect (on_root_changed); + } + construct{ + this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>(); + } + + private int figure_out_positioning() + { + int result = 0 ; + if (this.of_type == category.TRACK){ + result = this.owner.menu_offset + 4 + this.proxy_items.size; + } + else if (this.of_type == category.PLAYER){ + int pos = this.owner.menu_offset + 4 + this.owner.track_specific_count(); + pos += this.owner.use_playlists == true ? 1 : 0; + result = pos; + } + debug ("!!!!! Menu pos of type %i is = %i", this.of_type, result); + return result; + } + + private void on_root_changed (GLib.Object? newroot) + { + if (newroot == null){ + debug ("root disappeared -remove proxyitems"); + foreach(var p in proxy_items){ + this.owner.root_menu.child_delete (p); + } + this.proxy_items.clear(); + debug ("array list size is now %i", this.proxy_items.size); + //this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>(); + return; + } + + Dbusmenu.Menuitem? root = this.client.get_root(); + root.child_added.connect (on_child_added); + root.child_removed.connect (on_child_removed); + + // Fetch what children are there already. + GLib.List<weak void*> children = root.get_children().copy(); + + foreach (void* child in children) { + int pos = figure_out_positioning(); + unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child; + Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item); + proxy_items.add (proxy); + debug ("Proxy item of label = %s added to collection", + item.property_get (MENUITEM_PROP_LABEL)); + this.owner.root_menu.child_add_position (proxy, pos); + + } + } + + private void on_child_added (GLib.Object child, uint position) + { + debug ("On child added Specific root node"); + } + + private void on_child_removed (GLib.Object child) + { + debug ("On child removed Specific root node"); + } + +} diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c index 2f2fe0f..746efa7 100644 --- a/src/transport-menu-item.c +++ b/src/transport-menu-item.c @@ -108,6 +108,7 @@ struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; gint current_state; + DbusmenuMenuitem* root_menu; GeeArrayList* custom_items; Mpris2Controller* mpris_bridge; gboolean* use_playlists; |