From 13d392dab3f0fcba861bd6607ce17d68990b9228 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Tue, 11 Jan 2011 14:38:35 -0600 Subject: Import upstream version 0.5.4 --- Makefile.am | 2 +- Makefile.in | 2 +- aclocal.m4 | 16 +- configure | 86 ++-- configure.ac | 10 +- src/Makefile.am | 1 + src/Makefile.in | 19 + src/common-defs.h | 3 + src/dbus-menu-manager.c | 1 + src/fetch-file.c | 16 +- src/mpris2-controller.c | 445 +++++++++++++++++---- src/mpris2-controller.vala | 72 +++- src/mpris2-interfaces.c | 915 ++++++++++++++++++++++++++++++++++++++++++- src/mpris2-interfaces.vala | 29 +- src/mpris2-watcher.c | 88 ++--- src/music-player-bridge.c | 429 ++++++++++---------- src/music-player-bridge.h | 105 ++++- src/music-player-bridge.vala | 71 ++-- src/player-controller.c | 225 ++++++----- src/player-controller.vala | 43 +- src/player-item.vala | 2 +- src/playlists-menu-item.c | 407 +++++++++++++++++++ src/playlists-menu-item.vala | 87 ++++ src/settings-manager.c | 124 +++++- src/settings-manager.vala | 30 +- src/title-menu-item.c | 12 +- src/title-menu-item.vala | 3 +- src/title-widget.c | 10 +- src/transport-menu-item.c | 17 +- src/transport-menu-item.vala | 2 +- src/transport-widget.c | 2 + vapi/Indicate-0.2.vapi | 218 ----------- vapi/common-defs.vapi | 37 +- 33 files changed, 2705 insertions(+), 824 deletions(-) create mode 100644 src/playlists-menu-item.c create mode 100644 src/playlists-menu-item.vala delete mode 100644 vapi/Indicate-0.2.vapi diff --git a/Makefile.am b/Makefile.am index 70e69c1..466806a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = \ tests \ po -EXTRA_DIST = autogen.sh vapi/common-defs.vapi vapi/Indicate-0.2.vapi +EXTRA_DIST = autogen.sh vapi/common-defs.vapi DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/Makefile.in b/Makefile.in index 9dfd4fc..ca05132 100644 --- a/Makefile.in +++ b/Makefile.in @@ -273,7 +273,7 @@ SUBDIRS = \ tests \ po -EXTRA_DIST = autogen.sh vapi/common-defs.vapi vapi/Indicate-0.2.vapi +EXTRA_DIST = autogen.sh vapi/common-defs.vapi DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff --git a/aclocal.m4 b/aclocal.m4 index 5b73575..7228fa9 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -536,7 +536,7 @@ mostlyclean-am: clean-gsettings-schemas gsettings__enum_file = $(addsuffix .enums.xml,$(gsettings_ENUM_NAMESPACE)) %.gschema.valid: %.gschema.xml $(gsettings__enum_file) - $(AM_V_GEN) if test -f "$<"; then d=; else d="$(srcdir)/"; fi; $(GLIB_COMPILE_SCHEMAS) --dry-run $(addprefix --schema-file=,$(gsettings__enum_file)) --schema-file=$${d}$< && touch [$]@ + $(AM_V_GEN) if test -f "$<"; then d=; else d="$(srcdir)/"; fi; $(GLIB_COMPILE_SCHEMAS) --strict --dry-run $(addprefix --schema-file=,$(gsettings__enum_file)) --schema-file=$${d}$< && touch [$]@ all-am: $(gsettings_SCHEMAS:.xml=.valid) uninstall-am: uninstall-gsettings-schemas @@ -546,9 +546,11 @@ install-data-am: install-gsettings-schemas install-gsettings-schemas: $(gsettings_SCHEMAS) $(gsettings__enum_file) @$(NORMAL_INSTALL) - test -z "$(gsettingsschemadir)" || $(MKDIR_P) "$(DESTDIR)$(gsettingsschemadir)" - $(INSTALL_DATA) $^ "$(DESTDIR)$(gsettingsschemadir)" - test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir) + if test -n "$^"; then \ + test -z "$(gsettingsschemadir)" || $(MKDIR_P) "$(DESTDIR)$(gsettingsschemadir)"; \ + $(INSTALL_DATA) $^ "$(DESTDIR)$(gsettingsschemadir)"; \ + test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir); \ + fi uninstall-gsettings-schemas: @$(NORMAL_UNINSTALL) @@ -564,7 +566,7 @@ clean-gsettings-schemas: ifdef gsettings_ENUM_NAMESPACE $(gsettings__enum_file): $(gsettings_ENUM_FILES) - $(AM_V_GEN) glib-mkenums --comments '\'''\'' --fhead "" --vhead " <@type@ id='\''$(gsettings_ENUM_NAMESPACE).@EnumName@'\''>" --vprod " " --vtail " " --ftail "" $(gsettings_ENUM_FILES) > [$]@.tmp && mv [$]@.tmp [$]@ + $(AM_V_GEN) glib-mkenums --comments '\'''\'' --fhead "" --vhead " <@type@ id='\''$(gsettings_ENUM_NAMESPACE).@EnumName@'\''>" --vprod " " --vtail " " --ftail "" [$]^ > [$]@.tmp && mv [$]@.tmp [$]@ endif ' _GSETTINGS_SUBST(GSETTINGS_RULES) @@ -8909,7 +8911,7 @@ $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -_PKG_TEXT])dnl +_PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) @@ -8920,7 +8922,7 @@ path to pkg-config. _PKG_TEXT -To get pkg-config, see .])dnl +To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS diff --git a/configure b/configure index 1bc85bf..b513441 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for indicator-sound 0.5.3. +# Generated by GNU Autoconf 2.67 for indicator-sound 0.5.4. # # Report bugs to . # @@ -761,8 +761,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='indicator-sound' PACKAGE_TARNAME='indicator-sound' -PACKAGE_VERSION='0.5.3' -PACKAGE_STRING='indicator-sound 0.5.3' +PACKAGE_VERSION='0.5.4' +PACKAGE_STRING='indicator-sound 0.5.4' PACKAGE_BUGREPORT='conor.curran@canonical.com' PACKAGE_URL='' @@ -1565,7 +1565,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures indicator-sound 0.5.3 to adapt to many kinds of systems. +\`configure' configures indicator-sound 0.5.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1635,7 +1635,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of indicator-sound 0.5.3:";; + short | recursive ) echo "Configuration of indicator-sound 0.5.4:";; esac cat <<\_ACEOF @@ -1768,7 +1768,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -indicator-sound configure 0.5.3 +indicator-sound configure 0.5.4 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2137,7 +2137,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by indicator-sound $as_me 0.5.3, which was +It was created by indicator-sound $as_me 0.5.4, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2957,7 +2957,7 @@ fi # Define the identity of the package. PACKAGE=indicator-sound - VERSION=0.5.3 + VERSION=0.5.4 cat >>confdefs.h <<_ACEOF @@ -12383,12 +12383,15 @@ if test -n "$PULSEAUDIO_CFLAGS"; then pkg_cv_PULSEAUDIO_CFLAGS="$PULSEAUDIO_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-mainloop-glib >= \$PULSE_AUDIO_REQUIRED_VERSION\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-mainloop-glib >= \$PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION" 2>/dev/null` + pkg_cv_PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0" 2>/dev/null` else pkg_failed=yes fi @@ -12399,12 +12402,15 @@ if test -n "$PULSEAUDIO_LIBS"; then pkg_cv_PULSEAUDIO_LIBS="$PULSEAUDIO_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-mainloop-glib >= \$PULSE_AUDIO_REQUIRED_VERSION\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-mainloop-glib >= \$PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_PULSEAUDIO_LIBS=`$PKG_CONFIG --libs "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION" 2>/dev/null` + pkg_cv_PULSEAUDIO_LIBS=`$PKG_CONFIG --libs "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0" 2>/dev/null` else pkg_failed=yes fi @@ -12424,14 +12430,17 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION" 2>&1` + PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0" 2>&1` else - PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION" 2>&1` + PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors "libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PULSEAUDIO_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION) were not met: + as_fn_error $? "Package requirements (libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0) were not met: $PULSEAUDIO_PKG_ERRORS @@ -12478,18 +12487,21 @@ if test -n "$SOUNDSERVICE_CFLAGS"; then { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbusmenu-glib >= \$DBUSMENUGLIB_REQUIRED_VERSION indicator >= \$INDICATOR_REQUIRED_VERSION indicate >= \$INDICATE_REQUIRED_VERSION - gee-1.0\""; } >&5 + gee-1.0 + gio-unix-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0") 2>&5 + gee-1.0 + gio-unix-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SOUNDSERVICE_CFLAGS=`$PKG_CONFIG --cflags "dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0" 2>/dev/null` + gee-1.0 + gio-unix-2.0" 2>/dev/null` else pkg_failed=yes fi @@ -12503,18 +12515,21 @@ if test -n "$SOUNDSERVICE_LIBS"; then { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbusmenu-glib >= \$DBUSMENUGLIB_REQUIRED_VERSION indicator >= \$INDICATOR_REQUIRED_VERSION indicate >= \$INDICATE_REQUIRED_VERSION - gee-1.0\""; } >&5 + gee-1.0 + gio-unix-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0") 2>&5 + gee-1.0 + gio-unix-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SOUNDSERVICE_LIBS=`$PKG_CONFIG --libs "dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0" 2>/dev/null` + gee-1.0 + gio-unix-2.0" 2>/dev/null` else pkg_failed=yes fi @@ -12537,12 +12552,14 @@ fi SOUNDSERVICE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0" 2>&1` + gee-1.0 + gio-unix-2.0" 2>&1` else SOUNDSERVICE_PKG_ERRORS=`$PKG_CONFIG --print-errors "dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0" 2>&1` + gee-1.0 + gio-unix-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SOUNDSERVICE_PKG_ERRORS" >&5 @@ -12550,7 +12567,8 @@ fi as_fn_error $? "Package requirements (dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0) were not met: + gee-1.0 + gio-unix-2.0) were not met: $SOUNDSERVICE_PKG_ERRORS @@ -12993,7 +13011,7 @@ mostlyclean-am: clean-gsettings-schemas gsettings__enum_file = $(addsuffix .enums.xml,$(gsettings_ENUM_NAMESPACE)) %.gschema.valid: %.gschema.xml $(gsettings__enum_file) - $(AM_V_GEN) if test -f "$<"; then d=; else d="$(srcdir)/"; fi; $(GLIB_COMPILE_SCHEMAS) --dry-run $(addprefix --schema-file=,$(gsettings__enum_file)) --schema-file=$${d}$< && touch $@ + $(AM_V_GEN) if test -f "$<"; then d=; else d="$(srcdir)/"; fi; $(GLIB_COMPILE_SCHEMAS) --strict --dry-run $(addprefix --schema-file=,$(gsettings__enum_file)) --schema-file=$${d}$< && touch $@ all-am: $(gsettings_SCHEMAS:.xml=.valid) uninstall-am: uninstall-gsettings-schemas @@ -13003,9 +13021,11 @@ install-data-am: install-gsettings-schemas install-gsettings-schemas: $(gsettings_SCHEMAS) $(gsettings__enum_file) @$(NORMAL_INSTALL) - test -z "$(gsettingsschemadir)" || $(MKDIR_P) "$(DESTDIR)$(gsettingsschemadir)" - $(INSTALL_DATA) $^ "$(DESTDIR)$(gsettingsschemadir)" - test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir) + if test -n "$^"; then \ + test -z "$(gsettingsschemadir)" || $(MKDIR_P) "$(DESTDIR)$(gsettingsschemadir)"; \ + $(INSTALL_DATA) $^ "$(DESTDIR)$(gsettingsschemadir)"; \ + test -n "$(GSETTINGS_DISABLE_SCHEMAS_COMPILE)$(DESTDIR)" || $(GLIB_COMPILE_SCHEMAS) $(gsettingsschemadir); \ + fi uninstall-gsettings-schemas: @$(NORMAL_UNINSTALL) @@ -13021,7 +13041,7 @@ clean-gsettings-schemas: ifdef gsettings_ENUM_NAMESPACE $(gsettings__enum_file): $(gsettings_ENUM_FILES) - $(AM_V_GEN) glib-mkenums --comments '\'''\'' --fhead "" --vhead " <@type@ id='\''$(gsettings_ENUM_NAMESPACE).@EnumName@'\''>" --vprod " " --vtail " " --ftail "" $(gsettings_ENUM_FILES) > $@.tmp && mv $@.tmp $@ + $(AM_V_GEN) glib-mkenums --comments '\'''\'' --fhead "" --vhead " <@type@ id='\''$(gsettings_ENUM_NAMESPACE).@EnumName@'\''>" --vprod " " --vtail " " --ftail "" $^ > $@.tmp && mv $@.tmp $@ endif ' @@ -14322,7 +14342,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by indicator-sound $as_me 0.5.3, which was +This file was extended by indicator-sound $as_me 0.5.4, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14388,7 +14408,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -indicator-sound config.status 0.5.3 +indicator-sound config.status 0.5.4 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 88ffe6d..c9227cd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.5.3, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.5.4, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.5.3) +AM_INIT_AUTOMAKE(indicator-sound, 0.5.4) AM_MAINTAINER_MODE @@ -46,14 +46,16 @@ AC_SUBST(APPLET_CFLAGS) AC_SUBST(APPLET_LIBS) -PKG_CHECK_MODULES(PULSEAUDIO, libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION) +PKG_CHECK_MODULES(PULSEAUDIO, libpulse-mainloop-glib >= $PULSE_AUDIO_REQUIRED_VERSION + gio-unix-2.0) AC_SUBST(PULSEAUDIO_CFLAGS) AC_SUBST(PULSEAUDIO_LIBS) PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION indicate >= $INDICATE_REQUIRED_VERSION - gee-1.0) + gee-1.0 + gio-unix-2.0) AC_SUBST(SOUNDSERVICE_CFLAGS) AC_SUBST(SOUNDERVICE_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 5ef9ef0..82830e1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,6 +65,7 @@ music_bridge_VALASOURCES = \ mpris2-controller.vala \ player-item.vala \ settings-manager.vala \ + playlists-menu-item.vala \ fetch-file.vala diff --git a/src/Makefile.in b/src/Makefile.in index 3f0467f..a8d81e2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -96,6 +96,7 @@ am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \ indicator_sound_service-mpris2-controller.$(OBJEXT) \ indicator_sound_service-player-item.$(OBJEXT) \ indicator_sound_service-settings-manager.$(OBJEXT) \ + indicator_sound_service-playlists-menu-item.$(OBJEXT) \ indicator_sound_service-fetch-file.$(OBJEXT) am_indicator_sound_service_OBJECTS = \ indicator_sound_service-sound-service.$(OBJEXT) \ @@ -343,6 +344,7 @@ music_bridge_VALASOURCES = \ mpris2-controller.vala \ player-item.vala \ settings-manager.vala \ + playlists-menu-item.vala \ fetch-file.vala music_bridge_VALAFLAGS = \ @@ -537,6 +539,7 @@ distclean-compile: @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-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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-pulse-manager.Po@am__quote@ @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@ @@ -854,6 +857,22 @@ indicator_sound_service-settings-manager.obj: settings-manager.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-settings-manager.obj `if test -f 'settings-manager.c'; then $(CYGPATH_W) 'settings-manager.c'; else $(CYGPATH_W) '$(srcdir)/settings-manager.c'; fi` +indicator_sound_service-playlists-menu-item.o: playlists-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-playlists-menu-item.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-playlists-menu-item.Tpo -c -o indicator_sound_service-playlists-menu-item.o `test -f 'playlists-menu-item.c' || echo '$(srcdir)/'`playlists-menu-item.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-playlists-menu-item.Tpo $(DEPDIR)/indicator_sound_service-playlists-menu-item.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='playlists-menu-item.c' object='indicator_sound_service-playlists-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-playlists-menu-item.o `test -f 'playlists-menu-item.c' || echo '$(srcdir)/'`playlists-menu-item.c + +indicator_sound_service-playlists-menu-item.obj: playlists-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-playlists-menu-item.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-playlists-menu-item.Tpo -c -o indicator_sound_service-playlists-menu-item.obj `if test -f 'playlists-menu-item.c'; then $(CYGPATH_W) 'playlists-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/playlists-menu-item.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-playlists-menu-item.Tpo $(DEPDIR)/indicator_sound_service-playlists-menu-item.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='playlists-menu-item.c' object='indicator_sound_service-playlists-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-playlists-menu-item.obj `if test -f 'playlists-menu-item.c'; then $(CYGPATH_W) 'playlists-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/playlists-menu-item.c'; fi` + indicator_sound_service-fetch-file.o: fetch-file.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-fetch-file.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-fetch-file.Tpo -c -o indicator_sound_service-fetch-file.o `test -f 'fetch-file.c' || echo '$(srcdir)/'`fetch-file.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-fetch-file.Tpo $(DEPDIR)/indicator_sound_service-fetch-file.Po diff --git a/src/common-defs.h b/src/common-defs.h index 214f60a..8ec69e8 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -49,3 +49,6 @@ with this program. If not, see . #define DBUSMENU_SCRUB_MENUITEM_POSITION "x-canonical-sound-menu-player-scrub-position" #define DBUSMENU_SCRUB_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-scrub-play-state" +#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 diff --git a/src/dbus-menu-manager.c b/src/dbus-menu-manager.c index 37e1c18..f92c324 100644 --- a/src/dbus-menu-manager.c +++ b/src/dbus-menu-manager.c @@ -214,6 +214,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service // 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, diff --git a/src/fetch-file.c b/src/fetch-file.c index 1e6c1af..a20e7f6 100644 --- a/src/fetch-file.c +++ b/src/fetch-file.c @@ -200,7 +200,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 __catch11_g_error; + goto __catch12_g_error; } data->_tmp2_ = data->_tmp1_; data->_tmp3_ = NULL; @@ -210,15 +210,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 __finally11; - __catch11_g_error: + goto __finally12; + __catch12_g_error: { data->e = data->_inner_error_; data->_inner_error_ = NULL; g_signal_emit_by_name (data->self, "failed"); _g_error_free0 (data->e); } - __finally11: + __finally12: 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_); @@ -302,7 +302,7 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD data->_tmp3_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_); data->_tmp4_ = data->_tmp3_; if (data->_inner_error_ != NULL) { - goto __catch12_g_error; + goto __catch13_g_error; } data->bufsize = data->_tmp4_; if (data->bufsize < 1) { @@ -321,15 +321,15 @@ static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncD } else { g_byte_array_append (data->self->priv->data, data->buffer, data->buffer_length1); } - goto __finally12; - __catch12_g_error: + goto __finally13; + __catch13_g_error: { data->e = data->_inner_error_; data->_inner_error_ = NULL; g_signal_emit_by_name (data->self, "failed"); _g_error_free0 (data->e); } - __finally12: + __finally13: 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/mpris2-controller.c b/src/mpris2-controller.c index edb443a..acedf64 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -77,6 +77,22 @@ typedef struct _MprisPlayerIface MprisPlayerIface; #define TYPE_MPRIS_PLAYER_PROXY (mpris_player_proxy_get_type ()) +#define TYPE_MPRIS_PLAYLISTS (mpris_playlists_get_type ()) +#define MPRIS_PLAYLISTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_PLAYLISTS, MprisPlaylists)) +#define IS_MPRIS_PLAYLISTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_PLAYLISTS)) +#define MPRIS_PLAYLISTS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MPRIS_PLAYLISTS, MprisPlaylistsIface)) + +typedef struct _MprisPlaylists MprisPlaylists; +typedef struct _MprisPlaylistsIface MprisPlaylistsIface; + +#define TYPE_MPRIS_PLAYLISTS_PROXY (mpris_playlists_proxy_get_type ()) + +#define TYPE_PLAYLIST_DETAILS (playlist_details_get_type ()) +typedef struct _PlaylistDetails PlaylistDetails; + +#define TYPE_ACTIVE_PLAYLIST_CONTAINER (active_playlist_container_get_type ()) +typedef struct _ActivePlaylistContainer ActivePlaylistContainer; + #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)) @@ -115,6 +131,16 @@ 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 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)) +#define IS_PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYLISTS_MENUITEM)) +#define IS_PLAYLISTS_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYLISTS_MENUITEM)) +#define PLAYLISTS_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitemClass)) + +typedef struct _PlaylistsMenuitem PlaylistsMenuitem; +typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass; #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) struct _FreeDesktopPropertiesIface { @@ -164,9 +190,34 @@ struct _MprisPlayerIface { void (*set_PlaybackStatus) (MprisPlayer* self, const gchar* value); }; +struct _PlaylistDetails { + char* path; + gchar* name; + gchar* icon_path; +}; + +struct _ActivePlaylistContainer { + gboolean valid; + PlaylistDetails details; +}; + +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); + gchar** (*get_Orderings) (MprisPlaylists* self, int* result_length1); + void (*set_Orderings) (MprisPlaylists* self, gchar** value, int value_length1); + guint32 (*get_PlaylistCount) (MprisPlaylists* self); + void (*set_PlaylistCount) (MprisPlaylists* self, guint32 value); + void (*get_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); + void (*set_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); +}; + struct _Mpris2ControllerPrivate { MprisRoot* _mpris2_root; MprisPlayer* _player; + MprisPlaylists* _playlists; FreeDesktopProperties* _properties_interface; PlayerController* _owner; }; @@ -192,7 +243,8 @@ typedef enum { PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, - PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT + PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, + PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS } PlayerControllerwidget_order; typedef enum { @@ -223,12 +275,26 @@ GType mpris_root_get_type (void) G_GNUC_CONST; GType mpris_player_proxy_get_type (void) G_GNUC_CONST; guint mpris_player_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); GType mpris_player_get_type (void) G_GNUC_CONST; +GType mpris_playlists_proxy_get_type (void) G_GNUC_CONST; +guint mpris_playlists_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); +GType playlist_details_get_type (void) G_GNUC_CONST; +PlaylistDetails* playlist_details_dup (const PlaylistDetails* self); +void playlist_details_free (PlaylistDetails* self); +void playlist_details_copy (const PlaylistDetails* self, PlaylistDetails* dest); +void playlist_details_destroy (PlaylistDetails* self); +GType active_playlist_container_get_type (void) G_GNUC_CONST; +ActivePlaylistContainer* active_playlist_container_dup (const ActivePlaylistContainer* self); +void active_playlist_container_free (ActivePlaylistContainer* self); +void active_playlist_container_copy (const ActivePlaylistContainer* self, ActivePlaylistContainer* dest); +void active_playlist_container_destroy (ActivePlaylistContainer* self); +GType mpris_playlists_get_type (void) G_GNUC_CONST; GType player_controller_get_type (void) G_GNUC_CONST; #define MPRIS2_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS2_CONTROLLER, Mpris2ControllerPrivate)) enum { MPRIS2_CONTROLLER_DUMMY_PROPERTY, MPRIS2_CONTROLLER_MPRIS2_ROOT, MPRIS2_CONTROLLER_PLAYER, + MPRIS2_CONTROLLER_PLAYLISTS, MPRIS2_CONTROLLER_PROPERTIES_INTERFACE, MPRIS2_CONTROLLER_OWNER }; @@ -253,6 +319,11 @@ void player_item_reset (PlayerItem* self, GeeHashSet* attrs); GeeHashSet* metadata_menuitem_attributes_format (void); void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes); gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); +static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self); +gboolean mpris2_controller_playlists_support_exist (Mpris2Controller* self); +MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self); +guint32 mpris_playlists_get_PlaylistCount (MprisPlaylists* self); +static guint32* _uint32_dup (guint32* self); 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); @@ -260,6 +331,7 @@ static GVariant* _variant_new2 (const gchar* value); static const gchar* _variant_get3 (GVariant* value); static GVariant* _variant_new4 (gint64 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_); @@ -268,13 +340,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); +PlaylistDetails* mpris_playlists_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error); +GType playlists_menuitem_get_type (void) G_GNUC_CONST; +void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1); +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); static void mpris2_controller_set_mpris2_root (Mpris2Controller* self, MprisRoot* value); static void mpris2_controller_set_player (Mpris2Controller* self, MprisPlayer* value); +static void mpris2_controller_set_playlists (Mpris2Controller* self, MprisPlaylists* value); FreeDesktopProperties* mpris2_controller_get_properties_interface (Mpris2Controller* self); static void mpris2_controller_set_properties_interface (Mpris2Controller* self, FreeDesktopProperties* value); static void mpris2_controller_set_owner (Mpris2Controller* self, PlayerController* value); @@ -348,53 +430,53 @@ static void free_desktop_properties_proxy_class_init (FreeDesktopPropertiesProxy static void _dbus_handle_free_desktop_properties_properties_changed (FreeDesktopProperties* self, GVariant* parameters) { GVariantIter _arguments_iter; gchar* source = NULL; - GVariant* _tmp27_; + GVariant* _tmp79_; GHashTable* changed_properties = NULL; - GVariant* _tmp28_; - GHashTable* _tmp29_; - GVariantIter _tmp30_; - GVariant* _tmp31_; - GVariant* _tmp32_; + GVariant* _tmp80_; + GHashTable* _tmp81_; + GVariantIter _tmp82_; + GVariant* _tmp83_; + GVariant* _tmp84_; gchar** invalid = NULL; int invalid_length1; - GVariant* _tmp33_; - gchar** _tmp34_; - int _tmp34__length; - int _tmp34__size; - int _tmp34__length1; - GVariantIter _tmp35_; - GVariant* _tmp36_; + GVariant* _tmp85_; + gchar** _tmp86_; + int _tmp86__length; + int _tmp86__size; + int _tmp86__length1; + GVariantIter _tmp87_; + GVariant* _tmp88_; g_variant_iter_init (&_arguments_iter, parameters); - _tmp27_ = g_variant_iter_next_value (&_arguments_iter); - source = g_variant_dup_string (_tmp27_, NULL); - g_variant_unref (_tmp27_); - _tmp28_ = g_variant_iter_next_value (&_arguments_iter); - _tmp29_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - g_variant_iter_init (&_tmp30_, _tmp28_); - while (g_variant_iter_loop (&_tmp30_, "{?*}", &_tmp31_, &_tmp32_)) { - g_hash_table_insert (_tmp29_, g_variant_dup_string (_tmp31_, NULL), g_variant_get_variant (_tmp32_)); + _tmp79_ = g_variant_iter_next_value (&_arguments_iter); + source = g_variant_dup_string (_tmp79_, NULL); + g_variant_unref (_tmp79_); + _tmp80_ = g_variant_iter_next_value (&_arguments_iter); + _tmp81_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + g_variant_iter_init (&_tmp82_, _tmp80_); + while (g_variant_iter_loop (&_tmp82_, "{?*}", &_tmp83_, &_tmp84_)) { + g_hash_table_insert (_tmp81_, g_variant_dup_string (_tmp83_, NULL), g_variant_get_variant (_tmp84_)); } - changed_properties = _tmp29_; - g_variant_unref (_tmp28_); + changed_properties = _tmp81_; + g_variant_unref (_tmp80_); invalid_length1 = 0; - _tmp33_ = g_variant_iter_next_value (&_arguments_iter); - _tmp34_ = g_new (gchar*, 5); - _tmp34__length = 0; - _tmp34__size = 4; - _tmp34__length1 = 0; - g_variant_iter_init (&_tmp35_, _tmp33_); - for (; _tmp36_ = g_variant_iter_next_value (&_tmp35_); _tmp34__length1++) { - if (_tmp34__size == _tmp34__length) { - _tmp34__size = 2 * _tmp34__size; - _tmp34_ = g_renew (gchar*, _tmp34_, _tmp34__size + 1); + _tmp85_ = g_variant_iter_next_value (&_arguments_iter); + _tmp86_ = g_new (gchar*, 5); + _tmp86__length = 0; + _tmp86__size = 4; + _tmp86__length1 = 0; + g_variant_iter_init (&_tmp87_, _tmp85_); + for (; _tmp88_ = g_variant_iter_next_value (&_tmp87_); _tmp86__length1++) { + if (_tmp86__size == _tmp86__length) { + _tmp86__size = 2 * _tmp86__size; + _tmp86_ = g_renew (gchar*, _tmp86_, _tmp86__size + 1); } - _tmp34_[_tmp34__length++] = g_variant_dup_string (_tmp36_, NULL); - g_variant_unref (_tmp36_); + _tmp86_[_tmp86__length++] = g_variant_dup_string (_tmp88_, NULL); + g_variant_unref (_tmp88_); } - invalid_length1 = _tmp34__length1; - _tmp34_[_tmp34__length] = NULL; - invalid = _tmp34_; - g_variant_unref (_tmp33_); + invalid_length1 = _tmp86__length1; + _tmp86_[_tmp86__length] = NULL; + invalid = _tmp86_; + g_variant_unref (_tmp85_); g_signal_emit_by_name (self, "properties-changed", source, changed_properties, invalid, invalid_length1); _g_free0 (source); _g_hash_table_unref0 (changed_properties); @@ -449,34 +531,34 @@ static void _dbus_free_desktop_properties_properties_changed (GObject* _sender, const gchar * _path; GVariant *_arguments; GVariantBuilder _arguments_builder; - GVariantBuilder _tmp37_; - GHashTableIter _tmp38_; - gpointer _tmp39_; - gpointer _tmp40_; - gchar** _tmp41_; - GVariantBuilder _tmp42_; - int _tmp43_; + GVariantBuilder _tmp89_; + GHashTableIter _tmp90_; + gpointer _tmp91_; + gpointer _tmp92_; + gchar** _tmp93_; + GVariantBuilder _tmp94_; + int _tmp95_; _connection = _data[1]; _path = _data[2]; g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (source)); - g_hash_table_iter_init (&_tmp38_, changed_properties); - g_variant_builder_init (&_tmp37_, G_VARIANT_TYPE_DICTIONARY); - while (g_hash_table_iter_next (&_tmp38_, &_tmp39_, &_tmp40_)) { + g_hash_table_iter_init (&_tmp90_, changed_properties); + g_variant_builder_init (&_tmp89_, G_VARIANT_TYPE_DICTIONARY); + while (g_hash_table_iter_next (&_tmp90_, &_tmp91_, &_tmp92_)) { gchar* _key; GVariant* _value; - _key = (gchar*) _tmp39_; - _value = (GVariant*) _tmp40_; - g_variant_builder_add (&_tmp37_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value)); + _key = (gchar*) _tmp91_; + _value = (GVariant*) _tmp92_; + g_variant_builder_add (&_tmp89_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value)); } - g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp37_)); - _tmp41_ = invalid; - g_variant_builder_init (&_tmp42_, G_VARIANT_TYPE ("as")); - for (_tmp43_ = 0; _tmp43_ < invalid_length1; _tmp43_++) { - g_variant_builder_add_value (&_tmp42_, g_variant_new_string (*_tmp41_)); - _tmp41_++; + g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp89_)); + _tmp93_ = invalid; + g_variant_builder_init (&_tmp94_, G_VARIANT_TYPE ("as")); + for (_tmp95_ = 0; _tmp95_ < invalid_length1; _tmp95_++) { + g_variant_builder_add_value (&_tmp94_, g_variant_new_string (*_tmp93_)); + _tmp93_++; } - g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp42_)); + g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp94_)); _arguments = g_variant_builder_end (&_arguments_builder); g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.DBus.Properties", "PropertiesChanged", _arguments, NULL); } @@ -542,11 +624,14 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* gconstpointer _tmp10_ = NULL; GVariant* _tmp11_; GVariant* meta_v; + gconstpointer _tmp21_ = NULL; + GVariant* _tmp22_; + GVariant* playlist_v; g_return_if_fail (self != NULL); g_return_if_fail (interface_source != NULL); g_return_if_fail (changed_properties != NULL); _tmp0_ = player_controller_get_dbus_name (self->priv->_owner); - g_debug ("mpris2-controller.vala:68: properties-changed for interface %s and own" \ + g_debug ("mpris2-controller.vala:71: properties-changed for interface %s and own" \ "er %s", interface_source, _tmp0_); if (changed_properties == NULL) { _tmp1_ = TRUE; @@ -556,7 +641,7 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* _tmp1_ = _tmp2_ == FALSE; } if (_tmp1_) { - g_warning ("mpris2-controller.vala:71: Property-changed hash is null or this is an" \ + g_warning ("mpris2-controller.vala:74: Property-changed hash is null or this is an" \ " interface that doesn't concerns us"); return; } @@ -617,11 +702,61 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* _g_object_unref0 (metadata); _g_hash_table_unref0 (changed_updates); } + _tmp21_ = g_hash_table_lookup (changed_properties, "ActivePlaylist"); + _tmp22_ = _g_variant_ref0 ((GVariant*) _tmp21_); + playlist_v = _tmp22_; + if (playlist_v != NULL) { + mpris2_controller_fetch_active_playlist (self); + } + _g_variant_unref0 (playlist_v); _g_variant_unref0 (meta_v); _g_variant_unref0 (play_v); } +static guint32* _uint32_dup (guint32* self) { + guint32* dup; + dup = g_new0 (guint32, 1); + memcpy (dup, self, sizeof (guint32)); + return dup; +} + + +static gpointer __uint32_dup0 (gpointer self) { + return self ? _uint32_dup (self) : NULL; +} + + +gboolean mpris2_controller_playlists_support_exist (Mpris2Controller* self) { + gboolean result = FALSE; + guint32 _tmp0_; + guint32* _tmp1_; + guint32* count; + gboolean _tmp2_ = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + if (self->priv->_playlists == NULL) { + result = FALSE; + return result; + } + _tmp0_ = mpris_playlists_get_PlaylistCount (self->priv->_playlists); + _tmp1_ = __uint32_dup0 (&_tmp0_); + count = _tmp1_; + if (count == NULL) { + _tmp2_ = TRUE; + } else { + _tmp2_ = (*count) <= 0; + } + if (_tmp2_) { + result = FALSE; + _g_free0 (count); + return result; + } + result = TRUE; + _g_free0 (count); + return result; +} + + static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controller* self) { gboolean result = FALSE; gchar* _tmp0_ = NULL; @@ -637,7 +772,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:97: TEST playback status = %s", _tmp1_); + g_debug ("mpris2-controller.vala:113: TEST playback status = %s", _tmp1_); _g_free0 (_tmp1_); _tmp2_ = mpris_player_get_PlaybackStatus (self->priv->_player); _tmp3_ = _tmp2_; @@ -757,7 +892,7 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { _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:111: artist : %s", _variant_get3 ((GVariant*) _tmp19_)); + g_debug ("mpris2-controller.vala:127: artist : %s", _variant_get3 ((GVariant*) _tmp19_)); _g_free0 (display_artists); artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL); } @@ -843,13 +978,15 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { player_item_update (_tmp9_, cleaned_metadata, _tmp11_); _g_object_unref0 (_tmp11_); _g_object_unref0 (_tmp9_); + mpris2_controller_fetch_playlists (self); + mpris2_controller_fetch_active_playlist (self); _g_hash_table_unref0 (cleaned_metadata); } void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command) { g_return_if_fail (self != NULL); - g_debug ("mpris2-controller.vala:145: transport_event input = %i", (gint) command); + g_debug ("mpris2-controller.vala:163: transport_event input = %i", (gint) command); if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) { mpris_player_PlayPause (self->priv->_player, NULL, NULL); } else { @@ -864,6 +1001,86 @@ void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuit } +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); +} + + +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); + if (self->priv->_playlists == NULL) { + return; + } + _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; + } + if (current_playlists != NULL) { + gpointer _tmp3_ = NULL; + PlayerItem* _tmp4_; + PlaylistsMenuitem* playlists_item; + g_debug ("mpris2-controller.vala:184: 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); + } + current_playlists = (_vala_PlaylistDetails_array_free (current_playlists, current_playlists_length1), NULL); + return; +} + + +static void mpris2_controller_fetch_active_playlist (Mpris2Controller* self) { + gboolean _tmp0_ = FALSE; + gpointer _tmp3_ = NULL; + PlayerItem* _tmp4_; + PlaylistsMenuitem* playlists_item; + ActivePlaylistContainer _tmp5_ = {0}; + ActivePlaylistContainer _tmp6_; + g_return_if_fail (self != NULL); + if (self->priv->_playlists == NULL) { + ActivePlaylistContainer _tmp1_ = {0}; + ActivePlaylistContainer _tmp2_; + mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp1_); + _tmp2_ = _tmp1_; + _tmp0_ = _tmp2_.valid == FALSE; + active_playlist_container_destroy (&_tmp2_); + } else { + _tmp0_ = FALSE; + } + if (_tmp0_) { + g_warning ("mpris2-controller.vala:194: Playlists object is null or 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); + mpris_playlists_get_ActivePlaylist (self->priv->_playlists, &_tmp5_); + _tmp6_ = _tmp5_; + playlists_menuitem_update_active_playlist (playlists_item, &_tmp6_.details); + active_playlist_container_destroy (&_tmp6_); + _g_object_unref0 (playlists_item); +} + + gboolean mpris2_controller_connected (Mpris2Controller* self) { gboolean result = FALSE; gboolean _tmp0_ = FALSE; @@ -888,6 +1105,33 @@ void mpris2_controller_expose (Mpris2Controller* self) { } +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); + if (self->priv->_playlists == NULL) { + g_warning ("mpris2-controller.vala:216: playlists mpris instance is null !"); + return; + } + mpris_playlists_ActivatePlaylist (self->priv->_playlists, path, NULL, NULL); + goto __finally10; + __catch10_g_io_error: + { + GError * e; + e = _inner_error_; + _inner_error_ = NULL; + g_debug ("mpris2-controller.vala:223: Could not activate playlist %s because %s", (const gchar*) path, e->message); + _g_error_free0 (e); + } + __finally10: + 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; + } +} + + MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self) { MprisRoot* result; g_return_val_if_fail (self != NULL, NULL); @@ -933,6 +1177,26 @@ static void mpris2_controller_set_player (Mpris2Controller* self, MprisPlayer* v } +MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self) { + MprisPlaylists* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_playlists; + return result; +} + + +static void mpris2_controller_set_playlists (Mpris2Controller* self, MprisPlaylists* value) { + MprisPlaylists* _tmp0_; + MprisPlaylists* _tmp1_; + g_return_if_fail (self != NULL); + _tmp0_ = _g_object_ref0 (value); + _tmp1_ = _tmp0_; + _g_object_unref0 (self->priv->_playlists); + self->priv->_playlists = _tmp1_; + g_object_notify ((GObject *) self, "playlists"); +} + + FreeDesktopProperties* mpris2_controller_get_properties_interface (Mpris2Controller* self) { FreeDesktopProperties* result; g_return_val_if_fail (self != NULL, NULL); @@ -990,8 +1254,12 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr const gchar* _tmp5_ = NULL; MprisPlayer* _tmp6_; MprisPlayer* _tmp7_; - FreeDesktopProperties* _tmp8_; - FreeDesktopProperties* _tmp9_; + const gchar* _tmp8_ = NULL; + const gchar* _tmp9_ = NULL; + MprisPlaylists* _tmp10_; + MprisPlaylists* _tmp11_; + FreeDesktopProperties* _tmp12_; + FreeDesktopProperties* _tmp13_; GError * _inner_error_ = NULL; parent_class = G_OBJECT_CLASS (mpris2_controller_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); @@ -1001,7 +1269,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr _tmp2_ = (MprisRoot*) g_initable_new (TYPE_MPRIS_ROOT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp1_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2", NULL); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { - goto __catch10_g_io_error; + goto __catch11_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_); @@ -1014,7 +1282,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr _tmp6_ = (MprisPlayer*) g_initable_new (TYPE_MPRIS_PLAYER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp5_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Player", NULL); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { - goto __catch10_g_io_error; + goto __catch11_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_); @@ -1022,28 +1290,41 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr _tmp7_ = _tmp6_; mpris2_controller_set_player (self, _tmp7_); _g_object_unref0 (_tmp7_); - _tmp8_ = (FreeDesktopProperties*) g_initable_new (TYPE_FREE_DESKTOP_PROPERTIES_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freedesktop.Properties.PropertiesChanged", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.freedesktop.DBus.Properties", NULL); + _tmp8_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp9_ = player_controller_get_dbus_name (self->priv->_owner); + _tmp10_ = (MprisPlaylists*) g_initable_new (TYPE_MPRIS_PLAYLISTS_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", _tmp9_, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.mpris.MediaPlayer2.Playlists", NULL); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_IO_ERROR) { - goto __catch10_g_io_error; + goto __catch11_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_); } - _tmp9_ = _tmp8_; - mpris2_controller_set_properties_interface (self, _tmp9_); - _g_object_unref0 (_tmp9_); + _tmp11_ = _tmp10_; + mpris2_controller_set_playlists (self, _tmp11_); + _g_object_unref0 (_tmp11_); + _tmp12_ = (FreeDesktopProperties*) g_initable_new (TYPE_FREE_DESKTOP_PROPERTIES_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.freedesktop.Properties.PropertiesChanged", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/mpris/MediaPlayer2", "g-interface-name", "org.freedesktop.DBus.Properties", NULL); + if (_inner_error_ != NULL) { + if (_inner_error_->domain == G_IO_ERROR) { + goto __catch11_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_); + } + _tmp13_ = _tmp12_; + mpris2_controller_set_properties_interface (self, _tmp13_); + _g_object_unref0 (_tmp13_); g_signal_connect_object (self->priv->_properties_interface, "properties-changed", (GCallback) _mpris2_controller_property_changed_cb_free_desktop_properties_properties_changed, self, 0); - goto __finally10; - __catch10_g_io_error: + goto __finally11; + __catch11_g_io_error: { GError * e; e = _inner_error_; _inner_error_ = NULL; - g_error ("mpris2-controller.vala:60: Problems connecting to the session bus - %s", e->message); + g_error ("mpris2-controller.vala:63: Problems connecting to the session bus - %s", e->message); _g_error_free0 (e); } - __finally10: + __finally11: 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_); @@ -1061,6 +1342,7 @@ static void mpris2_controller_class_init (Mpris2ControllerClass * klass) { G_OBJECT_CLASS (klass)->finalize = mpris2_controller_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS2_CONTROLLER_MPRIS2_ROOT, g_param_spec_object ("mpris2-root", "mpris2-root", "mpris2-root", TYPE_MPRIS_ROOT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS2_CONTROLLER_PLAYER, g_param_spec_object ("player", "player", "player", TYPE_MPRIS_PLAYER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS2_CONTROLLER_PLAYLISTS, g_param_spec_object ("playlists", "playlists", "playlists", TYPE_MPRIS_PLAYLISTS, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS2_CONTROLLER_PROPERTIES_INTERFACE, g_param_spec_object ("properties-interface", "properties-interface", "properties-interface", TYPE_FREE_DESKTOP_PROPERTIES, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS2_CONTROLLER_OWNER, g_param_spec_object ("owner", "owner", "owner", TYPE_PLAYER_CONTROLLER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); } @@ -1076,6 +1358,7 @@ static void mpris2_controller_finalize (GObject* obj) { self = MPRIS2_CONTROLLER (obj); _g_object_unref0 (self->priv->_mpris2_root); _g_object_unref0 (self->priv->_player); + _g_object_unref0 (self->priv->_playlists); _g_object_unref0 (self->priv->_properties_interface); _g_object_unref0 (self->priv->_owner); G_OBJECT_CLASS (mpris2_controller_parent_class)->finalize (obj); @@ -1104,6 +1387,9 @@ static void _vala_mpris2_controller_get_property (GObject * object, guint proper case MPRIS2_CONTROLLER_PLAYER: g_value_set_object (value, mpris2_controller_get_player (self)); break; + case MPRIS2_CONTROLLER_PLAYLISTS: + g_value_set_object (value, mpris2_controller_get_playlists (self)); + break; case MPRIS2_CONTROLLER_PROPERTIES_INTERFACE: g_value_set_object (value, mpris2_controller_get_properties_interface (self)); break; @@ -1127,6 +1413,9 @@ static void _vala_mpris2_controller_set_property (GObject * object, guint proper case MPRIS2_CONTROLLER_PLAYER: mpris2_controller_set_player (self, g_value_get_object (value)); break; + case MPRIS2_CONTROLLER_PLAYLISTS: + mpris2_controller_set_playlists (self, g_value_get_object (value)); + break; case MPRIS2_CONTROLLER_PROPERTIES_INTERFACE: mpris2_controller_set_properties_interface (self, g_value_get_object (value)); break; diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 7f14efe..5f98541 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -18,11 +18,10 @@ with this program. If not, see . */ using Dbusmenu; - [DBus (name = "org.freedesktop.DBus.Properties")] - public interface FreeDesktopProperties : Object{ - public signal void PropertiesChanged(string source, HashTable changed_properties, - string[] invalid); +public interface FreeDesktopProperties : Object{ + public signal void PropertiesChanged (string source, HashTable changed_properties, + string[] invalid ); } /* @@ -33,13 +32,14 @@ public class Mpris2Controller : GLib.Object { public MprisRoot mpris2_root {get; construct;} public MprisPlayer player {get; construct;} + public MprisPlaylists playlists {get; construct;} public FreeDesktopProperties properties_interface {get; construct;} public PlayerController owner {get; construct;} - + public Mpris2Controller(PlayerController ctrl) { - GLib.Object(owner: ctrl); + GLib.Object(owner: ctrl); } construct{ @@ -50,10 +50,13 @@ public class Mpris2Controller : GLib.Object this.player = Bus.get_proxy_sync ( BusType.SESSION, this.owner.dbus_name, "/org/mpris/MediaPlayer2" ); + this.playlists = Bus.get_proxy_sync ( BusType.SESSION, + this.owner.dbus_name, + "/org/mpris/MediaPlayer2" ); this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, "org.freedesktop.Properties.PropertiesChanged", - "/org/mpris/MediaPlayer2" ); + "/org/mpris/MediaPlayer2" ); this.properties_interface.PropertiesChanged.connect ( property_changed_cb ); } catch (IOError e) { @@ -91,8 +94,21 @@ public class Mpris2Controller : GLib.Object metadata.property_set_bool ( MENUITEM_PROP_VISIBLE, metadata.populated(MetadataMenuitem.attributes_format())); } + Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); + if ( playlist_v != null ){ + this.fetch_active_playlist(); + //Timeout.add ( 200, fetch_active_playlist ); + } } + public bool playlists_support_exist() + { + if (this.playlists == null) return false; + uint32? count = this.playlists.PlaylistCount; + if ( count == null || count <= 0 ) return false; + return true; + } + private bool ensure_correct_playback_status(){ debug("TEST playback status = %s", this.player.PlaybackStatus); TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus); @@ -138,6 +154,8 @@ public class Mpris2Controller : GLib.Object GLib.HashTable? cleaned_metadata = this.clean_metadata(); this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata, MetadataMenuitem.attributes_format()); + this.fetch_playlists(); + this.fetch_active_playlist(); } public void transport_update(TransportMenuitem.action command) @@ -154,6 +172,32 @@ public class Mpris2Controller : GLib.Object } } + public void fetch_playlists() + { + if (this.playlists == null) return; + + PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0, + 10, + "Alphabetical", + false); + 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; + playlists_item.update(current_playlists); + } + return; + } + + private void fetch_active_playlist() + { + if (this.playlists == null && this.playlists.ActivePlaylist.valid == false){ + warning("Playlists object is null or we don't have an active playlist"); + } + PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; + playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details ); + } + + public bool connected() { return (this.player != null && this.mpris2_root != null); @@ -165,4 +209,18 @@ public class Mpris2Controller : GLib.Object this.mpris2_root.Raise.begin(); } } + + public void activate_playlist (ObjectPath path) + { + if(this.playlists == null){ + warning("playlists mpris instance is null !"); + return; + } + try{ + this.playlists.ActivatePlaylist.begin(path); + } + catch(IOError e){ + debug("Could not activate playlist %s because %s", (string)path, e.message); + } + } } \ No newline at end of file diff --git a/src/mpris2-interfaces.c b/src/mpris2-interfaces.c index 2755782..2de05a9 100644 --- a/src/mpris2-interfaces.c +++ b/src/mpris2-interfaces.c @@ -3,7 +3,6 @@ /* Copyright 2010 Canonical Ltd. - Authors: Conor Curran @@ -53,6 +52,24 @@ typedef GDBusProxy MprisPlayerProxy; typedef GDBusProxyClass MprisPlayerProxyClass; #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) +#define TYPE_PLAYLIST_DETAILS (playlist_details_get_type ()) +typedef struct _PlaylistDetails PlaylistDetails; + +#define TYPE_ACTIVE_PLAYLIST_CONTAINER (active_playlist_container_get_type ()) +typedef struct _ActivePlaylistContainer ActivePlaylistContainer; + +#define TYPE_MPRIS_PLAYLISTS (mpris_playlists_get_type ()) +#define MPRIS_PLAYLISTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_PLAYLISTS, MprisPlaylists)) +#define IS_MPRIS_PLAYLISTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_PLAYLISTS)) +#define MPRIS_PLAYLISTS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MPRIS_PLAYLISTS, MprisPlaylistsIface)) + +typedef struct _MprisPlaylists MprisPlaylists; +typedef struct _MprisPlaylistsIface MprisPlaylistsIface; + +#define TYPE_MPRIS_PLAYLISTS_PROXY (mpris_playlists_proxy_get_type ()) +typedef GDBusProxy MprisPlaylistsProxy; +typedef GDBusProxyClass MprisPlaylistsProxyClass; + struct _MprisRootIface { GTypeInterface parent_iface; void (*Quit) (MprisRoot* self, GAsyncReadyCallback _callback_, gpointer _user_data_); @@ -87,6 +104,30 @@ struct _MprisPlayerIface { void (*set_PlaybackStatus) (MprisPlayer* self, const gchar* value); }; +struct _PlaylistDetails { + char* path; + gchar* name; + gchar* icon_path; +}; + +struct _ActivePlaylistContainer { + gboolean valid; + PlaylistDetails details; +}; + +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); + gchar** (*get_Orderings) (MprisPlaylists* self, int* result_length1); + void (*set_Orderings) (MprisPlaylists* self, gchar** value, int value_length1); + guint32 (*get_PlaylistCount) (MprisPlaylists* self); + void (*set_PlaylistCount) (MprisPlaylists* self, guint32 value); + void (*get_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); + void (*set_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); +}; + GType mpris_root_proxy_get_type (void) G_GNUC_CONST; @@ -189,6 +230,55 @@ static void _dbus_mpris_player_set_Position (MprisPlayer* self, GVariant* _value static void _dbus_mpris_player_set_PlaybackStatus (MprisPlayer* self, GVariant* _value); static void _dbus_mpris_player_seeked (GObject* _sender, gint64 new_position, gpointer* _data); static void _mpris_player_unregister_object (gpointer user_data); +GType playlist_details_get_type (void) G_GNUC_CONST; +PlaylistDetails* playlist_details_dup (const PlaylistDetails* self); +void playlist_details_free (PlaylistDetails* self); +void playlist_details_copy (const PlaylistDetails* self, PlaylistDetails* dest); +void playlist_details_destroy (PlaylistDetails* self); +GType active_playlist_container_get_type (void) G_GNUC_CONST; +ActivePlaylistContainer* active_playlist_container_dup (const ActivePlaylistContainer* self); +void active_playlist_container_free (ActivePlaylistContainer* self); +void active_playlist_container_copy (const ActivePlaylistContainer* self, ActivePlaylistContainer* dest); +void active_playlist_container_destroy (ActivePlaylistContainer* self); +GType mpris_playlists_proxy_get_type (void) G_GNUC_CONST; +guint mpris_playlists_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); +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); +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); +void mpris_playlists_set_PlaylistCount (MprisPlaylists* self, guint32 value); +void mpris_playlists_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result); +void mpris_playlists_set_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* value); +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 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); +static void mpris_playlists_dbus_proxy_set_PlaylistCount (MprisPlaylists* self, guint32 value); +static void mpris_playlists_dbus_proxy_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result); +static void mpris_playlists_dbus_proxy_set_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* value); +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 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); +static GVariant* _dbus_mpris_playlists_get_PlaylistCount (MprisPlaylists* self); +static GVariant* _dbus_mpris_playlists_get_ActivePlaylist (MprisPlaylists* self); +static gboolean mpris_playlists_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data); +static void _dbus_mpris_playlists_set_Orderings (MprisPlaylists* self, GVariant* _value); +static void _dbus_mpris_playlists_set_PlaylistCount (MprisPlaylists* self, GVariant* _value); +static void _dbus_mpris_playlists_set_ActivePlaylist (MprisPlaylists* self, GVariant* _value); +static void _mpris_playlists_unregister_object (gpointer user_data); +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 const GDBusArgInfo * const _mpris_root_dbus_arg_info_Quit_in[] = {NULL}; static const GDBusArgInfo * const _mpris_root_dbus_arg_info_Quit_out[] = {NULL}; @@ -226,6 +316,26 @@ static const GDBusPropertyInfo _mpris_player_dbus_property_info_PlaybackStatus = static const GDBusPropertyInfo * const _mpris_player_dbus_property_info[] = {&_mpris_player_dbus_property_info_Metadata, &_mpris_player_dbus_property_info_Position, &_mpris_player_dbus_property_info_PlaybackStatus, NULL}; static const GDBusInterfaceInfo _mpris_player_dbus_interface_info = {-1, "org.mpris.MediaPlayer2.Player", (GDBusMethodInfo **) (&_mpris_player_dbus_method_info), (GDBusSignalInfo **) (&_mpris_player_dbus_signal_info), (GDBusPropertyInfo **) (&_mpris_player_dbus_property_info)}; static const GDBusInterfaceVTable _mpris_player_dbus_interface_vtable = {mpris_player_dbus_interface_method_call, mpris_player_dbus_interface_get_property, mpris_player_dbus_interface_set_property}; +static const GDBusArgInfo _mpris_playlists_dbus_arg_info_ActivatePlaylist_playlist_id = {-1, "playlist_id", "o"}; +static const GDBusArgInfo * const _mpris_playlists_dbus_arg_info_ActivatePlaylist_in[] = {&_mpris_playlists_dbus_arg_info_ActivatePlaylist_playlist_id, NULL}; +static const GDBusArgInfo * const _mpris_playlists_dbus_arg_info_ActivatePlaylist_out[] = {NULL}; +static const GDBusMethodInfo _mpris_playlists_dbus_method_info_ActivatePlaylist = {-1, "ActivatePlaylist", (GDBusArgInfo **) (&_mpris_playlists_dbus_arg_info_ActivatePlaylist_in), (GDBusArgInfo **) (&_mpris_playlists_dbus_arg_info_ActivatePlaylist_out)}; +static const GDBusArgInfo _mpris_playlists_dbus_arg_info_GetPlaylists_index = {-1, "index", "u"}; +static const GDBusArgInfo _mpris_playlists_dbus_arg_info_GetPlaylists_max_count = {-1, "max_count", "u"}; +static const GDBusArgInfo _mpris_playlists_dbus_arg_info_GetPlaylists_order = {-1, "order", "s"}; +static const GDBusArgInfo _mpris_playlists_dbus_arg_info_GetPlaylists_reverse_order = {-1, "reverse_order", "b"}; +static const GDBusArgInfo _mpris_playlists_dbus_arg_info_GetPlaylists_result = {-1, "result", "a(oss)"}; +static const GDBusArgInfo * const _mpris_playlists_dbus_arg_info_GetPlaylists_in[] = {&_mpris_playlists_dbus_arg_info_GetPlaylists_index, &_mpris_playlists_dbus_arg_info_GetPlaylists_max_count, &_mpris_playlists_dbus_arg_info_GetPlaylists_order, &_mpris_playlists_dbus_arg_info_GetPlaylists_reverse_order, NULL}; +static const GDBusArgInfo * const _mpris_playlists_dbus_arg_info_GetPlaylists_out[] = {&_mpris_playlists_dbus_arg_info_GetPlaylists_result, NULL}; +static const GDBusMethodInfo _mpris_playlists_dbus_method_info_GetPlaylists = {-1, "GetPlaylists", (GDBusArgInfo **) (&_mpris_playlists_dbus_arg_info_GetPlaylists_in), (GDBusArgInfo **) (&_mpris_playlists_dbus_arg_info_GetPlaylists_out)}; +static const GDBusMethodInfo * const _mpris_playlists_dbus_method_info[] = {&_mpris_playlists_dbus_method_info_ActivatePlaylist, &_mpris_playlists_dbus_method_info_GetPlaylists, NULL}; +static const GDBusSignalInfo * const _mpris_playlists_dbus_signal_info[] = {NULL}; +static const GDBusPropertyInfo _mpris_playlists_dbus_property_info_Orderings = {-1, "Orderings", "as", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE}; +static const GDBusPropertyInfo _mpris_playlists_dbus_property_info_PlaylistCount = {-1, "PlaylistCount", "u", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE}; +static const GDBusPropertyInfo _mpris_playlists_dbus_property_info_ActivePlaylist = {-1, "ActivePlaylist", "(b(oss))", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE}; +static const GDBusPropertyInfo * const _mpris_playlists_dbus_property_info[] = {&_mpris_playlists_dbus_property_info_Orderings, &_mpris_playlists_dbus_property_info_PlaylistCount, &_mpris_playlists_dbus_property_info_ActivePlaylist, NULL}; +static const GDBusInterfaceInfo _mpris_playlists_dbus_interface_info = {-1, "org.mpris.MediaPlayer2.Playlists", (GDBusMethodInfo **) (&_mpris_playlists_dbus_method_info), (GDBusSignalInfo **) (&_mpris_playlists_dbus_signal_info), (GDBusPropertyInfo **) (&_mpris_playlists_dbus_property_info)}; +static const GDBusInterfaceVTable _mpris_playlists_dbus_interface_vtable = {mpris_playlists_dbus_interface_method_call, mpris_playlists_dbus_interface_get_property, mpris_playlists_dbus_interface_set_property}; void mpris_root_Quit (MprisRoot* self, GAsyncReadyCallback _callback_, gpointer _user_data_) { MPRIS_ROOT_GET_INTERFACE (self)->Quit (self, _callback_, _user_data_); @@ -1515,4 +1625,807 @@ static void _mpris_player_unregister_object (gpointer user_data) { } +void playlist_details_copy (const PlaylistDetails* self, PlaylistDetails* dest) { + dest->path = g_strdup (self->path); + dest->name = g_strdup (self->name); + dest->icon_path = g_strdup (self->icon_path); +} + + +void playlist_details_destroy (PlaylistDetails* self) { + _g_free0 (self->path); + _g_free0 (self->name); + _g_free0 (self->icon_path); +} + + +PlaylistDetails* playlist_details_dup (const PlaylistDetails* self) { + PlaylistDetails* dup; + dup = g_new0 (PlaylistDetails, 1); + playlist_details_copy (self, dup); + return dup; +} + + +void playlist_details_free (PlaylistDetails* self) { + playlist_details_destroy (self); + g_free (self); +} + + +GType playlist_details_get_type (void) { + static volatile gsize playlist_details_type_id__volatile = 0; + if (g_once_init_enter (&playlist_details_type_id__volatile)) { + GType playlist_details_type_id; + playlist_details_type_id = g_boxed_type_register_static ("PlaylistDetails", (GBoxedCopyFunc) playlist_details_dup, (GBoxedFreeFunc) playlist_details_free); + g_once_init_leave (&playlist_details_type_id__volatile, playlist_details_type_id); + } + return playlist_details_type_id__volatile; +} + + +void active_playlist_container_copy (const ActivePlaylistContainer* self, ActivePlaylistContainer* dest) { + PlaylistDetails _tmp0_ = {0}; + dest->valid = self->valid; + dest->details = (playlist_details_copy (&self->details, &_tmp0_), _tmp0_); +} + + +void active_playlist_container_destroy (ActivePlaylistContainer* self) { + playlist_details_destroy (&self->details); +} + + +ActivePlaylistContainer* active_playlist_container_dup (const ActivePlaylistContainer* self) { + ActivePlaylistContainer* dup; + dup = g_new0 (ActivePlaylistContainer, 1); + active_playlist_container_copy (self, dup); + return dup; +} + + +void active_playlist_container_free (ActivePlaylistContainer* self) { + active_playlist_container_destroy (self); + g_free (self); +} + + +GType active_playlist_container_get_type (void) { + static volatile gsize active_playlist_container_type_id__volatile = 0; + if (g_once_init_enter (&active_playlist_container_type_id__volatile)) { + GType active_playlist_container_type_id; + active_playlist_container_type_id = g_boxed_type_register_static ("ActivePlaylistContainer", (GBoxedCopyFunc) active_playlist_container_dup, (GBoxedFreeFunc) active_playlist_container_free); + g_once_init_leave (&active_playlist_container_type_id__volatile, active_playlist_container_type_id); + } + return active_playlist_container_type_id__volatile; +} + + +void mpris_playlists_ActivatePlaylist (MprisPlaylists* self, const char* playlist_id, GAsyncReadyCallback _callback_, gpointer _user_data_) { + MPRIS_PLAYLISTS_GET_INTERFACE (self)->ActivatePlaylist (self, playlist_id, _callback_, _user_data_); +} + + +void mpris_playlists_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult* _res_, GError** error) { + MPRIS_PLAYLISTS_GET_INTERFACE (self)->ActivatePlaylist_finish (self, _res_, error); +} + + +PlaylistDetails* mpris_playlists_real_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error) { + g_return_val_if_fail (self != NULL, NULL); + g_critical ("Type `%s' does not implement abstract method `mpris_playlists_GetPlaylists'", g_type_name (G_TYPE_FROM_INSTANCE (self))); + return NULL; +} + + +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); +} + + +gchar** mpris_playlists_get_Orderings (MprisPlaylists* self, int* result_length1) { + return MPRIS_PLAYLISTS_GET_INTERFACE (self)->get_Orderings (self, result_length1); +} + + +void mpris_playlists_set_Orderings (MprisPlaylists* self, gchar** value, int value_length1) { + MPRIS_PLAYLISTS_GET_INTERFACE (self)->set_Orderings (self, value, value_length1); +} + + +guint32 mpris_playlists_get_PlaylistCount (MprisPlaylists* self) { + return MPRIS_PLAYLISTS_GET_INTERFACE (self)->get_PlaylistCount (self); +} + + +void mpris_playlists_set_PlaylistCount (MprisPlaylists* self, guint32 value) { + MPRIS_PLAYLISTS_GET_INTERFACE (self)->set_PlaylistCount (self, value); +} + + +void mpris_playlists_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result) { + MPRIS_PLAYLISTS_GET_INTERFACE (self)->get_ActivePlaylist (self, result); +} + + +void mpris_playlists_set_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* value) { + MPRIS_PLAYLISTS_GET_INTERFACE (self)->set_ActivePlaylist (self, value); +} + + +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); + } +} + + +GType mpris_playlists_get_type (void) { + static volatile gsize mpris_playlists_type_id__volatile = 0; + if (g_once_init_enter (&mpris_playlists_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (MprisPlaylistsIface), (GBaseInitFunc) mpris_playlists_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; + 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_once_init_leave (&mpris_playlists_type_id__volatile, mpris_playlists_type_id); + } + return mpris_playlists_type_id__volatile; +} + + +G_DEFINE_TYPE_EXTENDED (MprisPlaylistsProxy, mpris_playlists_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_MPRIS_PLAYLISTS, mpris_playlists_proxy_mpris_playlists_interface_init) ); +static void mpris_playlists_proxy_class_init (MprisPlaylistsProxyClass* klass) { + G_DBUS_PROXY_CLASS (klass)->g_signal = mpris_playlists_proxy_g_signal; +} + + +static void mpris_playlists_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters) { +} + + +static void mpris_playlists_proxy_init (MprisPlaylistsProxy* self) { +} + + +static void mpris_playlists_proxy_ActivatePlaylist_async (MprisPlaylists* self, const char* playlist_id, 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", "ActivatePlaylist"); + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_object_path (playlist_id)); + _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 (self, _callback_, _user_data_, NULL)); + g_object_unref (_message); +} + + +static void mpris_playlists_proxy_ActivatePlaylist_finish (MprisPlaylists* self, GAsyncResult* _res_, GError** error) { + GDBusMessage *_reply_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 (_res_), error); + if (!_reply_message) { + return; + } + if (g_dbus_message_to_gerror (_reply_message, error)) { + g_object_unref (_reply_message); + return; + } + g_object_unref (_reply_message); +} + + +static PlaylistDetails* mpris_playlists_proxy_GetPlaylists (MprisPlaylists* self, guint32 index, guint32 max_count, const gchar* order, gboolean reverse_order, int* result_length1, GError** error) { + GDBusMessage *_message; + GVariant *_arguments; + GVariantBuilder _arguments_builder; + GDBusMessage *_reply_message; + GVariant *_reply; + GVariantIter _reply_iter; + PlaylistDetails* _result; + int _result_length1; + GVariant* _tmp17_; + PlaylistDetails* _tmp18_; + int _tmp18__length; + int _tmp18__size; + 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); + if (!_reply_message) { + return NULL; + } + if (g_dbus_message_to_gerror (_reply_message, error)) { + g_object_unref (_reply_message); + return NULL; + } + _reply = g_dbus_message_get_body (_reply_message); + g_variant_iter_init (&_reply_iter, _reply); + _result_length1 = 0; + _tmp17_ = g_variant_iter_next_value (&_reply_iter); + _tmp18_ = g_new (PlaylistDetails, 5); + _tmp18__length = 0; + _tmp18__size = 4; + _tmp18__length1 = 0; + g_variant_iter_init (&_tmp19_, _tmp17_); + for (; _tmp20_ = g_variant_iter_next_value (&_tmp19_); _tmp18__length1++) { + PlaylistDetails _tmp21_; + GVariantIter _tmp22_; + GVariant* _tmp23_; + GVariant* _tmp24_; + GVariant* _tmp25_; + if (_tmp18__size == _tmp18__length) { + _tmp18__size = 2 * _tmp18__size; + _tmp18_ = g_renew (PlaylistDetails, _tmp18_, _tmp18__size + 1); + } + g_variant_iter_init (&_tmp22_, _tmp20_); + _tmp23_ = g_variant_iter_next_value (&_tmp22_); + _tmp21_.path = g_variant_dup_string (_tmp23_, NULL); + g_variant_unref (_tmp23_); + _tmp24_ = g_variant_iter_next_value (&_tmp22_); + _tmp21_.name = g_variant_dup_string (_tmp24_, NULL); + g_variant_unref (_tmp24_); + _tmp25_ = g_variant_iter_next_value (&_tmp22_); + _tmp21_.icon_path = g_variant_dup_string (_tmp25_, NULL); + g_variant_unref (_tmp25_); + _tmp18_[_tmp18__length++] = _tmp21_; + g_variant_unref (_tmp20_); + } + _result_length1 = _tmp18__length1; + _result = _tmp18_; + g_variant_unref (_tmp17_); + *result_length1 = _result_length1; + g_object_unref (_reply_message); + return _result; +} + + +static gchar** mpris_playlists_dbus_proxy_get_Orderings (MprisPlaylists* self, int* result_length1) { + GVariant *_inner_reply; + gchar** _result; + int _result_length1; + gchar** _tmp26_; + int _tmp26__length; + int _tmp26__size; + int _tmp26__length1; + GVariantIter _tmp27_; + GVariant* _tmp28_; + _inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "Orderings"); + if (!_inner_reply) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.mpris.MediaPlayer2.Playlists")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("Orderings")); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return NULL; + } + g_variant_get (_reply, "(v)", &_inner_reply); + g_variant_unref (_reply); + } + _result_length1 = 0; + _tmp26_ = g_new (gchar*, 5); + _tmp26__length = 0; + _tmp26__size = 4; + _tmp26__length1 = 0; + g_variant_iter_init (&_tmp27_, _inner_reply); + for (; _tmp28_ = g_variant_iter_next_value (&_tmp27_); _tmp26__length1++) { + if (_tmp26__size == _tmp26__length) { + _tmp26__size = 2 * _tmp26__size; + _tmp26_ = g_renew (gchar*, _tmp26_, _tmp26__size + 1); + } + _tmp26_[_tmp26__length++] = g_variant_dup_string (_tmp28_, NULL); + g_variant_unref (_tmp28_); + } + _result_length1 = _tmp26__length1; + _tmp26_[_tmp26__length] = NULL; + _result = _tmp26_; + *result_length1 = _result_length1; + g_variant_unref (_inner_reply); + return _result; +} + + +static void mpris_playlists_dbus_proxy_set_Orderings (MprisPlaylists* self, gchar** value, int value_length1) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + gchar** _tmp29_; + GVariantBuilder _tmp30_; + int _tmp31_; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.mpris.MediaPlayer2.Playlists")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("Orderings")); + g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT); + _tmp29_ = value; + g_variant_builder_init (&_tmp30_, G_VARIANT_TYPE ("as")); + for (_tmp31_ = 0; _tmp31_ < value_length1; _tmp31_++) { + g_variant_builder_add_value (&_tmp30_, g_variant_new_string (*_tmp29_)); + _tmp29_++; + } + g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp30_)); + g_variant_builder_close (&_arguments_builder); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Set", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return; + } + g_variant_unref (_reply); +} + + +static guint32 mpris_playlists_dbus_proxy_get_PlaylistCount (MprisPlaylists* self) { + GVariant *_inner_reply; + guint32 _result; + _inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "PlaylistCount"); + if (!_inner_reply) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.mpris.MediaPlayer2.Playlists")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("PlaylistCount")); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return 0U; + } + g_variant_get (_reply, "(v)", &_inner_reply); + g_variant_unref (_reply); + } + _result = g_variant_get_uint32 (_inner_reply); + g_variant_unref (_inner_reply); + return _result; +} + + +static void mpris_playlists_dbus_proxy_set_PlaylistCount (MprisPlaylists* self, guint32 value) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.mpris.MediaPlayer2.Playlists")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("PlaylistCount")); + g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (value)); + g_variant_builder_close (&_arguments_builder); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Set", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return; + } + g_variant_unref (_reply); +} + + +static void mpris_playlists_dbus_proxy_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result) { + GVariant *_inner_reply; + ActivePlaylistContainer _tmp32_; + GVariantIter _tmp33_; + GVariant* _tmp34_; + GVariant* _tmp35_; + PlaylistDetails _tmp36_; + GVariantIter _tmp37_; + GVariant* _tmp38_; + GVariant* _tmp39_; + GVariant* _tmp40_; + _inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "ActivePlaylist"); + if (!_inner_reply) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.mpris.MediaPlayer2.Playlists")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("ActivePlaylist")); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return; + } + g_variant_get (_reply, "(v)", &_inner_reply); + g_variant_unref (_reply); + } + g_variant_iter_init (&_tmp33_, _inner_reply); + _tmp34_ = g_variant_iter_next_value (&_tmp33_); + _tmp32_.valid = g_variant_get_boolean (_tmp34_); + g_variant_unref (_tmp34_); + _tmp35_ = g_variant_iter_next_value (&_tmp33_); + g_variant_iter_init (&_tmp37_, _tmp35_); + _tmp38_ = g_variant_iter_next_value (&_tmp37_); + _tmp36_.path = g_variant_dup_string (_tmp38_, NULL); + g_variant_unref (_tmp38_); + _tmp39_ = g_variant_iter_next_value (&_tmp37_); + _tmp36_.name = g_variant_dup_string (_tmp39_, NULL); + g_variant_unref (_tmp39_); + _tmp40_ = g_variant_iter_next_value (&_tmp37_); + _tmp36_.icon_path = g_variant_dup_string (_tmp40_, NULL); + g_variant_unref (_tmp40_); + _tmp32_.details = _tmp36_; + g_variant_unref (_tmp35_); + *result = _tmp32_; + g_variant_unref (_inner_reply); + return; +} + + +static void mpris_playlists_dbus_proxy_set_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* value) { + GVariant *_arguments; + GVariant *_reply; + GVariantBuilder _arguments_builder; + GVariantBuilder _tmp41_; + GVariantBuilder _tmp42_; + g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.mpris.MediaPlayer2.Playlists")); + g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("ActivePlaylist")); + g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT); + g_variant_builder_init (&_tmp41_, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_tmp41_, g_variant_new_boolean ((*value).valid)); + g_variant_builder_init (&_tmp42_, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_tmp42_, g_variant_new_object_path ((*value).details.path)); + g_variant_builder_add_value (&_tmp42_, g_variant_new_string ((*value).details.name)); + g_variant_builder_add_value (&_tmp42_, g_variant_new_string ((*value).details.icon_path)); + g_variant_builder_add_value (&_tmp41_, g_variant_builder_end (&_tmp42_)); + g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp41_)); + g_variant_builder_close (&_arguments_builder); + _arguments = g_variant_builder_end (&_arguments_builder); + _reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Set", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); + if (!_reply) { + return; + } + g_variant_unref (_reply); +} + + +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->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; + iface->set_PlaylistCount = mpris_playlists_dbus_proxy_set_PlaylistCount; + iface->get_ActivePlaylist = mpris_playlists_dbus_proxy_get_ActivePlaylist; + iface->set_ActivePlaylist = mpris_playlists_dbus_proxy_set_ActivePlaylist; +} + + +static void _dbus_mpris_playlists_ActivatePlaylist (MprisPlaylists* self, GVariant* parameters, GDBusMethodInvocation* invocation) { + GVariantIter _arguments_iter; + char* playlist_id = NULL; + GVariant* _tmp43_; + g_variant_iter_init (&_arguments_iter, parameters); + _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)); + _g_free0 (playlist_id); +} + + +static void _dbus_mpris_playlists_ActivatePlaylist_ready (GObject * source_object, GAsyncResult * _res_, gpointer * _user_data_) { + GDBusMethodInvocation * invocation; + GError* error; + GVariantIter _arguments_iter; + 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); + 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); + _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); +} + + +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_; + guint32 max_count = 0U; + GVariant* _tmp45_; + gchar* order = NULL; + 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_); + g_variant_unref (_tmp44_); + _tmp45_ = g_variant_iter_next_value (&_arguments_iter); + max_count = g_variant_get_uint32 (_tmp45_); + g_variant_unref (_tmp45_); + _tmp46_ = g_variant_iter_next_value (&_arguments_iter); + order = g_variant_dup_string (_tmp46_, NULL); + g_variant_unref (_tmp46_); + _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); + if (error) { + g_dbus_method_invocation_return_gerror (g_object_ref (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); + _tmp48_ = result; + g_variant_builder_init (&_tmp49_, G_VARIANT_TYPE ("a(oss)")); + for (_tmp50_ = 0; _tmp50_ < result_length1; _tmp50_++) { + GVariantBuilder _tmp51_; + g_variant_builder_init (&_tmp51_, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_tmp51_, g_variant_new_object_path ((*_tmp48_).path)); + g_variant_builder_add_value (&_tmp51_, g_variant_new_string ((*_tmp48_).name)); + g_variant_builder_add_value (&_tmp51_, g_variant_new_string ((*_tmp48_).icon_path)); + g_variant_builder_add_value (&_tmp49_, g_variant_builder_end (&_tmp51_)); + _tmp48_++; + } + g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp49_)); + 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 (_reply_message); +} + + +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) { + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (method_name, "ActivatePlaylist") == 0) { + _dbus_mpris_playlists_ActivatePlaylist (object, parameters, invocation); + } else if (strcmp (method_name, "GetPlaylists") == 0) { + _dbus_mpris_playlists_GetPlaylists (object, parameters, invocation); + } + g_object_unref (invocation); +} + + +static GVariant* _dbus_mpris_playlists_get_Orderings (MprisPlaylists* self) { + gchar** result; + int result_length1; + gchar** _tmp52_; + GVariantBuilder _tmp53_; + int _tmp54_; + GVariant* _reply; + result = mpris_playlists_get_Orderings (self, &result_length1); + _tmp52_ = result; + g_variant_builder_init (&_tmp53_, G_VARIANT_TYPE ("as")); + for (_tmp54_ = 0; _tmp54_ < result_length1; _tmp54_++) { + g_variant_builder_add_value (&_tmp53_, g_variant_new_string (*_tmp52_)); + _tmp52_++; + } + _reply = g_variant_builder_end (&_tmp53_); + result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL); + return _reply; +} + + +static GVariant* _dbus_mpris_playlists_get_PlaylistCount (MprisPlaylists* self) { + guint32 result; + GVariant* _reply; + result = mpris_playlists_get_PlaylistCount (self); + _reply = g_variant_new_uint32 (result); + return _reply; +} + + +static GVariant* _dbus_mpris_playlists_get_ActivePlaylist (MprisPlaylists* self) { + ActivePlaylistContainer result = {0}; + GVariantBuilder _tmp55_; + GVariantBuilder _tmp56_; + GVariant* _reply; + mpris_playlists_get_ActivePlaylist (self, &result); + g_variant_builder_init (&_tmp55_, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_tmp55_, g_variant_new_boolean (result.valid)); + g_variant_builder_init (&_tmp56_, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&_tmp56_, g_variant_new_object_path (result.details.path)); + g_variant_builder_add_value (&_tmp56_, g_variant_new_string (result.details.name)); + 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); + return _reply; +} + + +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) { + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (property_name, "Orderings") == 0) { + return _dbus_mpris_playlists_get_Orderings (object); + } else if (strcmp (property_name, "PlaylistCount") == 0) { + return _dbus_mpris_playlists_get_PlaylistCount (object); + } else if (strcmp (property_name, "ActivePlaylist") == 0) { + return _dbus_mpris_playlists_get_ActivePlaylist (object); + } + return NULL; +} + + +static void _dbus_mpris_playlists_set_Orderings (MprisPlaylists* self, GVariant* _value) { + gchar** value = NULL; + int value_length1; + gchar** _tmp57_; + int _tmp57__length; + int _tmp57__size; + int _tmp57__length1; + GVariantIter _tmp58_; + GVariant* _tmp59_; + _tmp57_ = g_new (gchar*, 5); + _tmp57__length = 0; + _tmp57__size = 4; + _tmp57__length1 = 0; + g_variant_iter_init (&_tmp58_, _value); + for (; _tmp59_ = g_variant_iter_next_value (&_tmp58_); _tmp57__length1++) { + if (_tmp57__size == _tmp57__length) { + _tmp57__size = 2 * _tmp57__size; + _tmp57_ = g_renew (gchar*, _tmp57_, _tmp57__size + 1); + } + _tmp57_[_tmp57__length++] = g_variant_dup_string (_tmp59_, NULL); + g_variant_unref (_tmp59_); + } + value_length1 = _tmp57__length1; + _tmp57_[_tmp57__length] = NULL; + value = _tmp57_; + mpris_playlists_set_Orderings (self, value, value_length1); + value = (_vala_array_free (value, value_length1, (GDestroyNotify) g_free), NULL); +} + + +static void _dbus_mpris_playlists_set_PlaylistCount (MprisPlaylists* self, GVariant* _value) { + guint32 value = 0U; + value = g_variant_get_uint32 (_value); + mpris_playlists_set_PlaylistCount (self, value); +} + + +static void _dbus_mpris_playlists_set_ActivePlaylist (MprisPlaylists* self, GVariant* _value) { + ActivePlaylistContainer value = {0}; + ActivePlaylistContainer _tmp60_; + GVariantIter _tmp61_; + GVariant* _tmp62_; + GVariant* _tmp63_; + PlaylistDetails _tmp64_; + GVariantIter _tmp65_; + GVariant* _tmp66_; + GVariant* _tmp67_; + GVariant* _tmp68_; + g_variant_iter_init (&_tmp61_, _value); + _tmp62_ = g_variant_iter_next_value (&_tmp61_); + _tmp60_.valid = g_variant_get_boolean (_tmp62_); + g_variant_unref (_tmp62_); + _tmp63_ = g_variant_iter_next_value (&_tmp61_); + g_variant_iter_init (&_tmp65_, _tmp63_); + _tmp66_ = g_variant_iter_next_value (&_tmp65_); + _tmp64_.path = g_variant_dup_string (_tmp66_, NULL); + g_variant_unref (_tmp66_); + _tmp67_ = g_variant_iter_next_value (&_tmp65_); + _tmp64_.name = g_variant_dup_string (_tmp67_, NULL); + g_variant_unref (_tmp67_); + _tmp68_ = g_variant_iter_next_value (&_tmp65_); + _tmp64_.icon_path = g_variant_dup_string (_tmp68_, NULL); + g_variant_unref (_tmp68_); + _tmp60_.details = _tmp64_; + g_variant_unref (_tmp63_); + value = _tmp60_; + mpris_playlists_set_ActivePlaylist (self, &value); + active_playlist_container_destroy (&value); +} + + +static gboolean mpris_playlists_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) { + gpointer* data; + gpointer object; + data = user_data; + object = data[0]; + if (strcmp (property_name, "Orderings") == 0) { + _dbus_mpris_playlists_set_Orderings (object, value); + return TRUE; + } else if (strcmp (property_name, "PlaylistCount") == 0) { + _dbus_mpris_playlists_set_PlaylistCount (object, value); + return TRUE; + } else if (strcmp (property_name, "ActivePlaylist") == 0) { + _dbus_mpris_playlists_set_ActivePlaylist (object, value); + return TRUE; + } + return FALSE; +} + + +guint mpris_playlists_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) { + guint result; + gpointer *data; + data = g_new (gpointer, 3); + data[0] = g_object_ref (object); + data[1] = g_object_ref (connection); + data[2] = g_strdup (path); + result = g_dbus_connection_register_object (connection, path, &_mpris_playlists_dbus_interface_info, &_mpris_playlists_dbus_interface_vtable, data, _mpris_playlists_unregister_object, error); + if (!result) { + return 0; + } + return result; +} + + +static void _mpris_playlists_unregister_object (gpointer user_data) { + gpointer* data; + data = user_data; + g_object_unref (data[0]); + g_object_unref (data[1]); + g_free (data[2]); + g_free (data); +} + + +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); +} + + diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index ebea135..88610e6 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -1,6 +1,5 @@ /* Copyright 2010 Canonical Ltd. - Authors: Conor Curran @@ -44,3 +43,31 @@ public interface MprisPlayer : Object { // signals public signal void Seeked(int64 new_position); } + +// Playlist container +public struct PlaylistDetails{ + public ObjectPath path; + public string name; + public string icon_path; +} + +// Active playlist property container +public struct ActivePlaylistContainer{ + public bool valid; + public PlaylistDetails details; +} + +[DBus (name = "org.mpris.MediaPlayer2.Playlists")] +public interface MprisPlaylists : Object { + //properties + public abstract string[] Orderings{owned get; set;} + public abstract uint32 PlaylistCount{owned get; set;} + public abstract ActivePlaylistContainer ActivePlaylist {owned get; set;} + + //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; +} \ No newline at end of file diff --git a/src/mpris2-watcher.c b/src/mpris2-watcher.c index f6b5805..76d8995 100644 --- a/src/mpris2-watcher.c +++ b/src/mpris2-watcher.c @@ -258,21 +258,21 @@ static void free_desktop_object_proxy_class_init (FreeDesktopObjectProxyClass* k static void _dbus_handle_free_desktop_object_name_owner_changed (FreeDesktopObject* self, GVariant* parameters) { GVariantIter _arguments_iter; gchar* name = NULL; - GVariant* _tmp17_; + GVariant* _tmp69_; gchar* old_owner = NULL; - GVariant* _tmp18_; + GVariant* _tmp70_; gchar* new_owner = NULL; - GVariant* _tmp19_; + GVariant* _tmp71_; g_variant_iter_init (&_arguments_iter, parameters); - _tmp17_ = g_variant_iter_next_value (&_arguments_iter); - name = g_variant_dup_string (_tmp17_, NULL); - g_variant_unref (_tmp17_); - _tmp18_ = g_variant_iter_next_value (&_arguments_iter); - old_owner = g_variant_dup_string (_tmp18_, NULL); - g_variant_unref (_tmp18_); - _tmp19_ = g_variant_iter_next_value (&_arguments_iter); - new_owner = g_variant_dup_string (_tmp19_, NULL); - g_variant_unref (_tmp19_); + _tmp69_ = g_variant_iter_next_value (&_arguments_iter); + name = g_variant_dup_string (_tmp69_, NULL); + g_variant_unref (_tmp69_); + _tmp70_ = g_variant_iter_next_value (&_arguments_iter); + old_owner = g_variant_dup_string (_tmp70_, NULL); + g_variant_unref (_tmp70_); + _tmp71_ = g_variant_iter_next_value (&_arguments_iter); + new_owner = g_variant_dup_string (_tmp71_, NULL); + g_variant_unref (_tmp71_); g_signal_emit_by_name (self, "name-owner-changed", name, old_owner, new_owner); _g_free0 (name); _g_free0 (old_owner); @@ -318,13 +318,13 @@ static gchar** free_desktop_object_proxy_list_names_finish (FreeDesktopObject* s GVariantIter _reply_iter; gchar** _result; int _result_length1; - GVariant* _tmp20_; - gchar** _tmp21_; - int _tmp21__length; - int _tmp21__size; - int _tmp21__length1; - GVariantIter _tmp22_; - GVariant* _tmp23_; + GVariant* _tmp72_; + gchar** _tmp73_; + int _tmp73__length; + int _tmp73__size; + int _tmp73__length1; + GVariantIter _tmp74_; + GVariant* _tmp75_; _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 (_res_), error); if (!_reply_message) { return NULL; @@ -336,24 +336,24 @@ static gchar** free_desktop_object_proxy_list_names_finish (FreeDesktopObject* s _reply = g_dbus_message_get_body (_reply_message); g_variant_iter_init (&_reply_iter, _reply); _result_length1 = 0; - _tmp20_ = g_variant_iter_next_value (&_reply_iter); - _tmp21_ = g_new (gchar*, 5); - _tmp21__length = 0; - _tmp21__size = 4; - _tmp21__length1 = 0; - g_variant_iter_init (&_tmp22_, _tmp20_); - for (; _tmp23_ = g_variant_iter_next_value (&_tmp22_); _tmp21__length1++) { - if (_tmp21__size == _tmp21__length) { - _tmp21__size = 2 * _tmp21__size; - _tmp21_ = g_renew (gchar*, _tmp21_, _tmp21__size + 1); + _tmp72_ = g_variant_iter_next_value (&_reply_iter); + _tmp73_ = g_new (gchar*, 5); + _tmp73__length = 0; + _tmp73__size = 4; + _tmp73__length1 = 0; + g_variant_iter_init (&_tmp74_, _tmp72_); + for (; _tmp75_ = g_variant_iter_next_value (&_tmp74_); _tmp73__length1++) { + if (_tmp73__size == _tmp73__length) { + _tmp73__size = 2 * _tmp73__size; + _tmp73_ = g_renew (gchar*, _tmp73_, _tmp73__size + 1); } - _tmp21_[_tmp21__length++] = g_variant_dup_string (_tmp23_, NULL); - g_variant_unref (_tmp23_); + _tmp73_[_tmp73__length++] = g_variant_dup_string (_tmp75_, NULL); + g_variant_unref (_tmp75_); } - _result_length1 = _tmp21__length1; - _tmp21_[_tmp21__length] = NULL; - _result = _tmp21_; - g_variant_unref (_tmp20_); + _result_length1 = _tmp73__length1; + _tmp73_[_tmp73__length] = NULL; + _result = _tmp73_; + g_variant_unref (_tmp72_); *result_length1 = _result_length1; g_object_unref (_reply_message); return _result; @@ -382,9 +382,9 @@ static void _dbus_free_desktop_object_list_names_ready (GObject * source_object, GVariantBuilder _reply_builder; gchar** result; int result_length1 = 0; - gchar** _tmp24_; - GVariantBuilder _tmp25_; - int _tmp26_; + gchar** _tmp76_; + GVariantBuilder _tmp77_; + int _tmp78_; invocation = _user_data_; error = NULL; result = free_desktop_object_list_names_finish ((FreeDesktopObject*) source_object, _res_, &result_length1, &error); @@ -394,13 +394,13 @@ static void _dbus_free_desktop_object_list_names_ready (GObject * source_object, } _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); - _tmp24_ = result; - g_variant_builder_init (&_tmp25_, G_VARIANT_TYPE ("as")); - for (_tmp26_ = 0; _tmp26_ < result_length1; _tmp26_++) { - g_variant_builder_add_value (&_tmp25_, g_variant_new_string (*_tmp24_)); - _tmp24_++; + _tmp76_ = result; + g_variant_builder_init (&_tmp77_, G_VARIANT_TYPE ("as")); + for (_tmp78_ = 0; _tmp78_ < result_length1; _tmp78_++) { + g_variant_builder_add_value (&_tmp77_, g_variant_new_string (*_tmp76_)); + _tmp76_++; } - g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp25_)); + g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp77_)); 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); diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index e397913..2b8fc17 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -94,7 +94,6 @@ struct _MusicPlayerBridgePrivate { DbusmenuMenuitem* root_menu; GeeHashMap* registered_clients; Mpris2Watcher* watcher; - GSettings* settings; }; typedef enum { @@ -116,22 +115,23 @@ GType mpris2_watcher_get_type (void) G_GNUC_CONST; enum { MUSIC_PLAYER_BRIDGE_DUMMY_PROPERTY }; -#define MUSIC_PLAYER_BRIDGE_DESKTOP_PREFIX "/usr/share/applications/" MusicPlayerBridge* music_player_bridge_new (void); MusicPlayerBridge* music_player_bridge_construct (GType object_type); static void music_player_bridge_on_blacklist_update (MusicPlayerBridge* self, gchar** blacklist, int blacklist_length1); static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self); -gchar** settings_manager_fetch_interested (SettingsManager* self, int* result_length1); -static GAppInfo* music_player_bridge_create_app_info (const gchar* path); -static gchar* music_player_bridge_determine_key (gchar* path); -static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop_path); +GeeArrayList* settings_manager_fetch_interested (SettingsManager* self); +static GAppInfo* music_player_bridge_create_app_info (const gchar* desktop); +static gchar* music_player_bridge_determine_key (gchar* desktop_or_interface); +static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop); static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self); GType player_controller_state_get_type (void) G_GNUC_CONST; PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state); PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state); -#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5 void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, const gchar* desktop, const gchar* dbus_name); -gboolean settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); +gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_length1); +static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle); +void settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); void player_controller_activate (PlayerController* self, const gchar* dbus_name); void music_player_bridge_client_has_vanished (MusicPlayerBridge* self, const gchar* mpris_root_interface); @@ -165,75 +165,73 @@ MusicPlayerBridge* music_player_bridge_new (void) { static void music_player_bridge_on_blacklist_update (MusicPlayerBridge* self, gchar** blacklist, int blacklist_length1) { g_return_if_fail (self != NULL); - g_debug ("music-player-bridge.vala:45: some blacklist update"); + g_debug ("music-player-bridge.vala:43: some blacklist update"); } static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self) { - gint _tmp0_; - gchar** _tmp1_ = NULL; g_return_if_fail (self != NULL); - _tmp1_ = settings_manager_fetch_interested (self->priv->settings_manager, &_tmp0_); { - gchar** desktop_collection; - int desktop_collection_length1; - int desktop_it; - desktop_collection = _tmp1_; - desktop_collection_length1 = _tmp0_; - for (desktop_it = 0; desktop_it < _tmp0_; desktop_it = desktop_it + 1) { - gchar* _tmp2_; + GeeArrayList* _tmp0_ = NULL; + GeeArrayList* _desktop_list; + gint _tmp1_; + gint _desktop_size; + gint _desktop_index; + _tmp0_ = settings_manager_fetch_interested (self->priv->settings_manager); + _desktop_list = _tmp0_; + _tmp1_ = gee_collection_get_size ((GeeCollection*) _desktop_list); + _desktop_size = _tmp1_; + _desktop_index = -1; + while (TRUE) { + gpointer _tmp2_ = NULL; gchar* desktop; - _tmp2_ = g_strdup (desktop_collection[desktop_it]); - desktop = _tmp2_; - { - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - gchar* _tmp5_ = NULL; - gchar* _tmp6_; - gchar* path; - GAppInfo* _tmp7_ = NULL; - GAppInfo* app_info; - gchar* _tmp8_; - gchar* _tmp9_ = NULL; - gchar* mpris_key; - gchar* _tmp10_ = NULL; - gchar* _tmp11_; - gint _tmp12_; - PlayerController* _tmp13_ = NULL; - PlayerController* _tmp14_; - PlayerController* ctrl; - g_debug ("music-player-bridge.vala:51: interested client found : %s", desktop); - _tmp3_ = g_strconcat (desktop, ".desktop", NULL); - _tmp4_ = _tmp3_; - _tmp5_ = g_strconcat (MUSIC_PLAYER_BRIDGE_DESKTOP_PREFIX, _tmp4_, NULL); - path = (_tmp6_ = _tmp5_, _g_free0 (_tmp4_), _tmp6_); - _tmp7_ = music_player_bridge_create_app_info (path); - app_info = _tmp7_; - if (app_info == NULL) { - g_warning ("music-player-bridge.vala:55: Could not create app_info for path %s \n" \ -" Getting out of here ", path); - _g_object_unref0 (app_info); - _g_free0 (path); - _g_free0 (desktop); - continue; - } - _tmp8_ = g_strdup (path); - _tmp9_ = music_player_bridge_determine_key (_tmp8_); - mpris_key = _tmp9_; - _tmp10_ = music_player_bridge_fetch_icon_name (path); - _tmp11_ = _tmp10_; - _tmp12_ = music_player_bridge_calculate_menu_position (self); - _tmp13_ = player_controller_new (self->priv->root_menu, app_info, NULL, _tmp11_, _tmp12_, PLAYER_CONTROLLER_STATE_OFFLINE); - ctrl = (_tmp14_ = _tmp13_, _g_free0 (_tmp11_), _tmp14_); - gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, mpris_key, ctrl); - _g_object_unref0 (ctrl); - _g_free0 (mpris_key); + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + GAppInfo* _tmp5_ = NULL; + GAppInfo* _tmp6_; + GAppInfo* app_info; + gchar* _tmp7_; + gchar* _tmp8_ = NULL; + gchar* mpris_key; + gchar* _tmp9_ = NULL; + gchar* _tmp10_; + gint _tmp11_; + PlayerController* _tmp12_ = NULL; + PlayerController* _tmp13_; + PlayerController* ctrl; + _desktop_index = _desktop_index + 1; + if (!(_desktop_index < _desktop_size)) { + break; + } + _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _desktop_list, _desktop_index); + desktop = (gchar*) _tmp2_; + g_debug ("music-player-bridge.vala:49: interested client found : %s", desktop); + _tmp3_ = g_strconcat (desktop, ".desktop", NULL); + _tmp4_ = _tmp3_; + _tmp5_ = music_player_bridge_create_app_info (_tmp4_); + app_info = (_tmp6_ = _tmp5_, _g_free0 (_tmp4_), _tmp6_); + if (app_info == NULL) { + g_warning ("music-player-bridge.vala:52: Could not create app_info for path %s \n" \ +" Getting out of here ", desktop); _g_object_unref0 (app_info); - _g_free0 (path); _g_free0 (desktop); + continue; } + _tmp7_ = g_strdup (desktop); + _tmp8_ = music_player_bridge_determine_key (_tmp7_); + mpris_key = _tmp8_; + _tmp9_ = music_player_bridge_fetch_icon_name (desktop); + _tmp10_ = _tmp9_; + _tmp11_ = music_player_bridge_calculate_menu_position (self); + _tmp12_ = player_controller_new (self->priv->root_menu, app_info, NULL, _tmp10_, _tmp11_, PLAYER_CONTROLLER_STATE_OFFLINE); + ctrl = (_tmp13_ = _tmp12_, _g_free0 (_tmp10_), _tmp13_); + gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, mpris_key, ctrl); + _g_object_unref0 (ctrl); + _g_free0 (mpris_key); + _g_object_unref0 (app_info); + _g_free0 (desktop); } - desktop_collection = (_vala_array_free (desktop_collection, desktop_collection_length1, (GDestroyNotify) g_free), NULL); + _g_object_unref0 (_desktop_list); } } @@ -255,19 +253,33 @@ static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self } +static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) { + int i; + for (i = 0; i < stack_length; i++) { + if (g_strcmp0 (stack[i], needle) == 0) { + return TRUE; + } + } + return FALSE; +} + + void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, const gchar* desktop, const gchar* dbus_name) { gboolean _tmp0_ = FALSE; - gchar* _tmp1_ = NULL; - gchar* _tmp2_; - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - gchar* path; - GAppInfo* _tmp5_ = NULL; - GAppInfo* app_info; + gint _tmp1_; + gchar** _tmp2_ = NULL; + gchar** _tmp3_; + gint _tmp3__length1; + gboolean _tmp4_; + gchar* _tmp5_ = NULL; gchar* _tmp6_; - gchar* _tmp7_ = NULL; + GAppInfo* _tmp7_ = NULL; + GAppInfo* _tmp8_; + GAppInfo* app_info; + gchar* _tmp9_; + gchar* _tmp10_ = NULL; gchar* mpris_key; - gboolean _tmp8_; + gboolean _tmp11_; g_return_if_fail (self != NULL); g_return_if_fail (desktop != NULL); g_return_if_fail (dbus_name != NULL); @@ -277,91 +289,102 @@ void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, c _tmp0_ = g_strcmp0 (desktop, "") == 0; } if (_tmp0_) { - g_warning ("music-player-bridge.vala:82: Client %s attempting to register without " \ + g_warning ("music-player-bridge.vala:80: Client %s attempting to register without " \ "desktop entry being set on the mpris root", dbus_name); return; } - g_debug ("music-player-bridge.vala:86: client_has_become_available %s", desktop); - _tmp1_ = g_strconcat (desktop, ".desktop", NULL); - _tmp2_ = _tmp1_; - _tmp3_ = g_strconcat (MUSIC_PLAYER_BRIDGE_DESKTOP_PREFIX, _tmp2_, NULL); - path = (_tmp4_ = _tmp3_, _g_free0 (_tmp2_), _tmp4_); - _tmp5_ = music_player_bridge_create_app_info (path); - app_info = _tmp5_; + _tmp2_ = settings_manager_fetch_blacklist (self->priv->settings_manager, &_tmp1_); + _tmp3_ = _tmp2_; + _tmp3__length1 = _tmp1_; + if ((_tmp4_ = _vala_string_array_contains (_tmp3_, _tmp1_, desktop), _tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL), _tmp4_)) { + g_debug ("music-player-bridge.vala:85: Client %s attempting to register but it h" \ +"as been blacklisted", desktop); + } + g_debug ("music-player-bridge.vala:89: client_has_become_available %s", desktop); + _tmp5_ = g_strconcat (desktop, ".desktop", NULL); + _tmp6_ = _tmp5_; + _tmp7_ = music_player_bridge_create_app_info (_tmp6_); + app_info = (_tmp8_ = _tmp7_, _g_free0 (_tmp6_), _tmp8_); if (app_info == NULL) { - g_warning ("music-player-bridge.vala:90: Could not create app_info for path %s \n" \ -" Getting out of here ", path); + g_warning ("music-player-bridge.vala:92: Could not create app_info for path %s \n" \ +" Getting out of here ", desktop); _g_object_unref0 (app_info); - _g_free0 (path); return; } - _tmp6_ = g_strdup (path); - _tmp7_ = music_player_bridge_determine_key (_tmp6_); - mpris_key = _tmp7_; - _tmp8_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); - if (_tmp8_ == FALSE) { - gchar* _tmp9_ = NULL; - gchar* _tmp10_; - gint _tmp11_; - PlayerController* _tmp12_ = NULL; - PlayerController* _tmp13_; + _tmp9_ = g_strdup (desktop); + _tmp10_ = music_player_bridge_determine_key (_tmp9_); + mpris_key = _tmp10_; + _tmp11_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + if (_tmp11_ == FALSE) { + gchar* _tmp12_ = NULL; + gchar* _tmp13_; + gint _tmp14_; + PlayerController* _tmp15_ = NULL; + PlayerController* _tmp16_; PlayerController* ctrl; - g_debug ("music-player-bridge.vala:97: New client has registered that we have no" \ -"t seen before: %s", dbus_name); - _tmp9_ = music_player_bridge_fetch_icon_name (path); - _tmp10_ = _tmp9_; - _tmp11_ = music_player_bridge_calculate_menu_position (self); - _tmp12_ = player_controller_new (self->priv->root_menu, app_info, dbus_name, _tmp10_, _tmp11_, PLAYER_CONTROLLER_STATE_READY); - ctrl = (_tmp13_ = _tmp12_, _g_free0 (_tmp10_), _tmp13_); + g_debug ("music-player-bridge.vala:100: New client has registered that we have n" \ +"ot seen before: %s", dbus_name); + _tmp12_ = music_player_bridge_fetch_icon_name (desktop); + _tmp13_ = _tmp12_; + _tmp14_ = music_player_bridge_calculate_menu_position (self); + _tmp15_ = player_controller_new (self->priv->root_menu, app_info, dbus_name, _tmp13_, _tmp14_, PLAYER_CONTROLLER_STATE_READY); + ctrl = (_tmp16_ = _tmp15_, _g_free0 (_tmp13_), _tmp16_); gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, mpris_key, ctrl); - g_debug ("music-player-bridge.vala:105: Have not seen this %s before, new contro" \ + g_debug ("music-player-bridge.vala:108: Have not seen this %s before, new contro" \ "ller created.", desktop); settings_manager_add_interested (self->priv->settings_manager, desktop); - g_debug ("music-player-bridge.vala:107: application added to the interested list"); + g_debug ("music-player-bridge.vala:110: application added to the interested list"); _g_object_unref0 (ctrl); } else { - gpointer _tmp14_ = NULL; - PlayerController* _tmp15_; - gpointer _tmp16_ = NULL; - PlayerController* _tmp17_; - _tmp14_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); - _tmp15_ = (PlayerController*) _tmp14_; - player_controller_update_state (_tmp15_, PLAYER_CONTROLLER_STATE_READY); - _g_object_unref0 (_tmp15_); - _tmp16_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); - _tmp17_ = (PlayerController*) _tmp16_; - player_controller_activate (_tmp17_, dbus_name); - _g_object_unref0 (_tmp17_); - g_debug ("music-player-bridge.vala:112: Application has already registered - awa" \ + gpointer _tmp17_ = NULL; + PlayerController* _tmp18_; + gpointer _tmp19_ = NULL; + PlayerController* _tmp20_; + _tmp17_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp18_ = (PlayerController*) _tmp17_; + player_controller_update_state (_tmp18_, PLAYER_CONTROLLER_STATE_READY); + _g_object_unref0 (_tmp18_); + _tmp19_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp20_ = (PlayerController*) _tmp19_; + player_controller_activate (_tmp20_, dbus_name); + _g_object_unref0 (_tmp20_); + g_debug ("music-player-bridge.vala:115: Application has already registered - awa" \ "ken the hibernation: %s \n", dbus_name); } _g_free0 (mpris_key); _g_object_unref0 (app_info); - _g_free0 (path); } void music_player_bridge_client_has_vanished (MusicPlayerBridge* self, const gchar* mpris_root_interface) { g_return_if_fail (self != NULL); g_return_if_fail (mpris_root_interface != NULL); - g_debug ("music-player-bridge.vala:118: MusicPlayerBridge -> on_server_removed w" \ + g_debug ("music-player-bridge.vala:121: MusicPlayerBridge -> on_server_removed w" \ "ith value %s", mpris_root_interface); if (self->priv->root_menu != NULL) { gchar* _tmp0_; gchar* _tmp1_ = NULL; gchar* mpris_key; - g_debug ("music-player-bridge.vala:120: attempt to remove %s", mpris_root_interface); + gboolean _tmp2_ = FALSE; + g_debug ("music-player-bridge.vala:123: attempt to remove %s", mpris_root_interface); _tmp0_ = g_strdup (mpris_root_interface); _tmp1_ = music_player_bridge_determine_key (_tmp0_); mpris_key = _tmp1_; if (mpris_key != NULL) { - gpointer _tmp2_ = NULL; - PlayerController* _tmp3_; - _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); - _tmp3_ = (PlayerController*) _tmp2_; - player_controller_hibernate (_tmp3_); - _g_object_unref0 (_tmp3_); - g_debug ("music-player-bridge.vala:124: Successively offlined client %s", mpris_key); + gboolean _tmp3_; + _tmp3_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp2_ = _tmp3_; + } else { + _tmp2_ = FALSE; + } + if (_tmp2_) { + gpointer _tmp4_ = NULL; + PlayerController* _tmp5_; + _tmp4_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, mpris_key); + _tmp5_ = (PlayerController*) _tmp4_; + player_controller_hibernate (_tmp5_); + _g_object_unref0 (_tmp5_); + g_debug ("music-player-bridge.vala:127: Successively offlined client %s", mpris_key); } _g_free0 (mpris_key); } @@ -394,17 +417,17 @@ void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMe _tmp1_ = _tmp0_; _g_object_unref0 (self->priv->root_menu); self->priv->root_menu = _tmp1_; + music_player_bridge_try_to_add_inactive_familiar_clients (self); _tmp2_ = mpris2_watcher_new (); _tmp3_ = _tmp2_; _g_object_unref0 (self->priv->watcher); self->priv->watcher = _tmp3_; g_signal_connect_object (self->priv->watcher, "client-appeared", (GCallback) _music_player_bridge_client_has_become_available_mpris2_watcher_client_appeared, self, 0); g_signal_connect_object (self->priv->watcher, "client-disappeared", (GCallback) _music_player_bridge_client_has_vanished_mpris2_watcher_client_disappeared, self, 0); - music_player_bridge_try_to_add_inactive_familiar_clients (self); } -static GAppInfo* music_player_bridge_create_app_info (const gchar* path) { +static GAppInfo* music_player_bridge_create_app_info (const gchar* desktop) { GAppInfo* result = NULL; GDesktopAppInfo* _tmp0_ = NULL; GDesktopAppInfo* info; @@ -412,17 +435,17 @@ static GAppInfo* music_player_bridge_create_app_info (const gchar* path) { GDesktopAppInfo* _tmp2_; GAppInfo* _tmp3_; GAppInfo* app_info; - g_return_val_if_fail (path != NULL, NULL); - _tmp0_ = g_desktop_app_info_new_from_filename (path); + g_return_val_if_fail (desktop != NULL, NULL); + _tmp0_ = g_desktop_app_info_new (desktop); info = _tmp0_; - if (path == NULL) { + if (desktop == NULL) { _tmp1_ = TRUE; } else { _tmp1_ = info == NULL; } if (_tmp1_) { - g_warning ("music-player-bridge.vala:142: Could not create a desktopappinfo instan" \ -"ce from app: %s", path); + g_warning ("music-player-bridge.vala:146: Could not create a desktopappinfo instan" \ +"ce from app: %s", desktop); result = NULL; _g_object_unref0 (info); return result; @@ -435,17 +458,28 @@ static GAppInfo* music_player_bridge_create_app_info (const gchar* path) { } -static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop_path) { +static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop) { gchar* result = NULL; - GKeyFile* _tmp0_ = NULL; + gchar* _tmp0_ = NULL; + gchar* _tmp1_; + GDesktopAppInfo* _tmp2_ = NULL; + GDesktopAppInfo* _tmp3_; + GDesktopAppInfo* info; + GKeyFile* _tmp4_ = NULL; GKeyFile* desktop_keyfile; - gchar* _tmp1_ = NULL; - gchar* _tmp2_; + const gchar* _tmp5_ = NULL; + gchar* _tmp6_ = NULL; + gchar* _tmp7_; GError * _inner_error_ = NULL; - g_return_val_if_fail (desktop_path != NULL, NULL); - _tmp0_ = g_key_file_new (); - desktop_keyfile = _tmp0_; - g_key_file_load_from_file (desktop_keyfile, desktop_path, G_KEY_FILE_NONE, &_inner_error_); + g_return_val_if_fail (desktop != NULL, NULL); + _tmp0_ = g_strconcat (desktop, ".desktop", NULL); + _tmp1_ = _tmp0_; + _tmp2_ = g_desktop_app_info_new (_tmp1_); + info = (_tmp3_ = _tmp2_, _g_free0 (_tmp1_), _tmp3_); + _tmp4_ = g_key_file_new (); + desktop_keyfile = _tmp4_; + _tmp5_ = g_desktop_app_info_get_filename (info); + g_key_file_load_from_file (desktop_keyfile, _tmp5_, G_KEY_FILE_NONE, &_inner_error_); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_FILE_ERROR) { goto __catch0_g_file_error; @@ -454,6 +488,7 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop_path) { goto __catch0_g_key_file_error; } _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); 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_); return NULL; @@ -464,10 +499,11 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop_path) { GError * _error_; _error_ = _inner_error_; _inner_error_ = NULL; - g_warning ("music-player-bridge.vala:156: Error loading keyfile - FileError"); + g_warning ("music-player-bridge.vala:162: Error loading keyfile - FileError"); result = NULL; _g_error_free0 (_error_); _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); return result; } goto __finally0; @@ -476,32 +512,36 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop_path) { GError * _error_; _error_ = _inner_error_; _inner_error_ = NULL; - g_warning ("music-player-bridge.vala:160: Error loading keyfile - KeyFileError"); + g_warning ("music-player-bridge.vala:166: Error loading keyfile - KeyFileError"); result = NULL; _g_error_free0 (_error_); _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); return result; } __finally0: if (_inner_error_ != NULL) { _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); 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 NULL; } - _tmp1_ = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &_inner_error_); - _tmp2_ = _tmp1_; + _tmp6_ = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &_inner_error_); + _tmp7_ = _tmp6_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_KEY_FILE_ERROR) { goto __catch1_g_key_file_error; } _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); 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_); return NULL; } - result = _tmp2_; + result = _tmp7_; _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); return result; goto __finally1; __catch1_g_key_file_error: @@ -509,93 +549,73 @@ static gchar* music_player_bridge_fetch_icon_name (const gchar* desktop_path) { GError * _error_; _error_ = _inner_error_; _inner_error_ = NULL; - g_warning ("music-player-bridge.vala:169: Error trying to fetch the icon name from" \ + g_warning ("music-player-bridge.vala:175: Error trying to fetch the icon name from" \ " the keyfile"); result = NULL; _g_error_free0 (_error_); _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); return result; } __finally1: _g_key_file_free0 (desktop_keyfile); + _g_object_unref0 (info); 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 NULL; } -static gchar* music_player_bridge_determine_key (gchar* path) { +static gchar* music_player_bridge_determine_key (gchar* desktop_or_interface) { gchar* result = NULL; - gchar** _tmp0_; - gchar** _tmp1_ = NULL; + gchar* _tmp0_; + gchar* _result_; + gchar** _tmp1_; + gchar** _tmp2_ = NULL; gint tokens_length1; gint _tokens_size_; - gchar** _tmp2_; + gchar** _tmp3_; gchar** tokens; - gchar* _tmp6_; - gchar* filename; - gchar** _tmp7_; - gchar** _tmp8_ = NULL; - gchar** _tmp9_; - gint _tmp9__length1; - gchar* _tmp10_; - gchar* _tmp11_; - gchar* _result_; - gchar** _tmp12_; - gchar** _tmp13_ = NULL; + gchar** _tmp6_; + gchar** _tmp7_ = NULL; gint temp_length1; gint _temp_size_; - gchar** _tmp14_; + gchar** _tmp8_; gchar** temp; - g_return_val_if_fail (path != NULL, NULL); - _tmp1_ = _tmp0_ = g_strsplit (path, "/", 0); - _tmp2_ = _tmp1_; - tokens_length1 = _vala_array_length (_tmp0_); + 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_length1 = _vala_array_length (_tmp1_); _tokens_size_ = tokens_length1; - tokens = _tmp2_; - if (tokens_length1 < 2) { - gchar** _tmp3_; - gchar** _tmp4_ = NULL; - gchar** _tmp5_; - _tmp4_ = _tmp3_ = g_strsplit (path, ".", 0); + tokens = _tmp3_; + if (tokens_length1 > 1) { + gchar* _tmp4_; + gchar* _tmp5_; + _tmp4_ = g_strdup (tokens[tokens_length1 - 1]); _tmp5_ = _tmp4_; - tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL); - tokens_length1 = _vala_array_length (_tmp3_); - _tokens_size_ = tokens_length1; - tokens = _tmp5_; - if (tokens_length1 < 2) { - result = NULL; - tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL); - _g_free0 (path); - return result; - } + _g_free0 (_result_); + _result_ = _tmp5_; } - _tmp6_ = g_strdup (tokens[tokens_length1 - 1]); - filename = _tmp6_; - _tmp8_ = _tmp7_ = g_strsplit (filename, ".", 0); - _tmp9_ = _tmp8_; - _tmp9__length1 = _vala_array_length (_tmp7_); - _tmp10_ = g_strdup (_tmp9_[0]); - _result_ = (_tmp11_ = _tmp10_, _tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL), _tmp11_); - _tmp13_ = _tmp12_ = g_strsplit (_result_, "-", 0); - _tmp14_ = _tmp13_; - temp_length1 = _vala_array_length (_tmp12_); + _tmp7_ = _tmp6_ = g_strsplit (_result_, "-", 0); + _tmp8_ = _tmp7_; + temp_length1 = _vala_array_length (_tmp6_); _temp_size_ = temp_length1; - temp = _tmp14_; + temp = _tmp8_; if (temp_length1 > 1) { - gchar* _tmp15_; - gchar* _tmp16_; - _tmp15_ = g_strdup (temp[0]); - _tmp16_ = _tmp15_; + gchar* _tmp9_; + gchar* _tmp10_; + _tmp9_ = g_strdup (temp[0]); + _tmp10_ = _tmp9_; _g_free0 (_result_); - _result_ = _tmp16_; + _result_ = _tmp10_; } - g_debug ("music-player-bridge.vala:197: determine key result = %s", _result_); + g_debug ("music-player-bridge.vala:198: determine key result = %s", _result_); result = _result_; temp = (_vala_array_free (temp, temp_length1, (GDestroyNotify) g_free), NULL); - _g_free0 (filename); tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL); - _g_free0 (path); + _g_free0 (desktop_or_interface); return result; } @@ -649,7 +669,6 @@ static void music_player_bridge_finalize (GObject* obj) { _g_object_unref0 (self->priv->root_menu); _g_object_unref0 (self->priv->registered_clients); _g_object_unref0 (self->priv->watcher); - _g_object_unref0 (self->priv->settings); G_OBJECT_CLASS (music_player_bridge_parent_class)->finalize (obj); } diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index 13eebe1..24eedb8 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -122,6 +122,22 @@ typedef struct _MprisPlayerIface MprisPlayerIface; #define TYPE_MPRIS_PLAYER_PROXY (mpris_player_proxy_get_type ()) +#define TYPE_PLAYLIST_DETAILS (playlist_details_get_type ()) +typedef struct _PlaylistDetails PlaylistDetails; + +#define TYPE_ACTIVE_PLAYLIST_CONTAINER (active_playlist_container_get_type ()) +typedef struct _ActivePlaylistContainer ActivePlaylistContainer; + +#define TYPE_MPRIS_PLAYLISTS (mpris_playlists_get_type ()) +#define MPRIS_PLAYLISTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_PLAYLISTS, MprisPlaylists)) +#define IS_MPRIS_PLAYLISTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_PLAYLISTS)) +#define MPRIS_PLAYLISTS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MPRIS_PLAYLISTS, MprisPlaylistsIface)) + +typedef struct _MprisPlaylists MprisPlaylists; +typedef struct _MprisPlaylistsIface MprisPlaylistsIface; + +#define TYPE_MPRIS_PLAYLISTS_PROXY (mpris_playlists_proxy_get_type ()) + #define TYPE_FREE_DESKTOP_OBJECT (free_desktop_object_get_type ()) #define FREE_DESKTOP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FREE_DESKTOP_OBJECT, FreeDesktopObject)) #define IS_FREE_DESKTOP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FREE_DESKTOP_OBJECT)) @@ -165,6 +181,17 @@ typedef struct _SettingsManager SettingsManager; typedef struct _SettingsManagerClass SettingsManagerClass; typedef struct _SettingsManagerPrivate SettingsManagerPrivate; +#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)) +#define IS_PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYLISTS_MENUITEM)) +#define IS_PLAYLISTS_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYLISTS_MENUITEM)) +#define PLAYLISTS_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitemClass)) + +typedef struct _PlaylistsMenuitem PlaylistsMenuitem; +typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass; +typedef struct _PlaylistsMenuitemPrivate PlaylistsMenuitemPrivate; + #define TYPE_FETCH_FILE (fetch_file_get_type ()) #define FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FETCH_FILE, FetchFile)) #define FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FETCH_FILE, FetchFileClass)) @@ -248,7 +275,8 @@ typedef enum { PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, - PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT + PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, + PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS } PlayerControllerwidget_order; typedef enum { @@ -293,6 +321,30 @@ struct _MprisPlayerIface { void (*set_PlaybackStatus) (MprisPlayer* self, const gchar* value); }; +struct _PlaylistDetails { + char* path; + gchar* name; + gchar* icon_path; +}; + +struct _ActivePlaylistContainer { + gboolean valid; + PlaylistDetails details; +}; + +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); + gchar** (*get_Orderings) (MprisPlaylists* self, int* result_length1); + void (*set_Orderings) (MprisPlaylists* self, gchar** value, int value_length1); + guint32 (*get_PlaylistCount) (MprisPlaylists* self); + void (*set_PlaylistCount) (MprisPlaylists* self, guint32 value); + void (*get_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); + void (*set_ActivePlaylist) (MprisPlaylists* self, ActivePlaylistContainer* value); +}; + struct _FreeDesktopObjectIface { GTypeInterface parent_iface; void (*list_names) (FreeDesktopObject* self, GAsyncReadyCallback _callback_, gpointer _user_data_); @@ -330,6 +382,16 @@ struct _SettingsManagerClass { GObjectClass parent_class; }; +struct _PlaylistsMenuitem { + PlayerItem parent_instance; + PlaylistsMenuitemPrivate * priv; + DbusmenuMenuitem* root_item; +}; + +struct _PlaylistsMenuitemClass { + PlayerItemClass parent_class; +}; + struct _FetchFile { GObject parent_instance; FetchFilePrivate * priv; @@ -370,7 +432,7 @@ GeeHashSet* title_menuitem_attributes_format (void); GType mpris2_controller_get_type (void) G_GNUC_CONST; GType player_controller_widget_order_get_type (void) G_GNUC_CONST; GType player_controller_state_get_type (void) G_GNUC_CONST; -#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5 PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state); PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); @@ -379,8 +441,6 @@ void player_controller_instantiate (PlayerController* self); void player_controller_vanish (PlayerController* self); void player_controller_hibernate (PlayerController* self); void player_controller_update_layout (PlayerController* self); -const gchar* player_controller_get_name (PlayerController* self); -void player_controller_set_name (PlayerController* self, const gchar* value); const gchar* player_controller_get_dbus_name (PlayerController* self); void player_controller_set_dbus_name (PlayerController* self, const gchar* value); GAppInfo* player_controller_get_app_info (PlayerController* self); @@ -421,6 +481,28 @@ gint32 mpris_player_get_Position (MprisPlayer* self); void mpris_player_set_Position (MprisPlayer* self, gint32 value); gchar* mpris_player_get_PlaybackStatus (MprisPlayer* self); void mpris_player_set_PlaybackStatus (MprisPlayer* self, const gchar* value); +GType playlist_details_get_type (void) G_GNUC_CONST; +PlaylistDetails* playlist_details_dup (const PlaylistDetails* self); +void playlist_details_free (PlaylistDetails* self); +void playlist_details_copy (const PlaylistDetails* self, PlaylistDetails* dest); +void playlist_details_destroy (PlaylistDetails* self); +GType active_playlist_container_get_type (void) G_GNUC_CONST; +ActivePlaylistContainer* active_playlist_container_dup (const ActivePlaylistContainer* self); +void active_playlist_container_free (ActivePlaylistContainer* self); +void active_playlist_container_copy (const ActivePlaylistContainer* self, ActivePlaylistContainer* dest); +void active_playlist_container_destroy (ActivePlaylistContainer* self); +GType mpris_playlists_proxy_get_type (void) G_GNUC_CONST; +guint mpris_playlists_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); +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); +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); +void mpris_playlists_set_PlaylistCount (MprisPlaylists* self, guint32 value); +void mpris_playlists_get_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* result); +void mpris_playlists_set_ActivePlaylist (MprisPlaylists* self, ActivePlaylistContainer* value); GType free_desktop_object_proxy_get_type (void) G_GNUC_CONST; guint free_desktop_object_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); GType free_desktop_object_get_type (void) G_GNUC_CONST; @@ -436,12 +518,16 @@ guint free_desktop_properties_register_object (void* object, GDBusConnection* co Mpris2Controller* mpris2_controller_new (PlayerController* ctrl); Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl); void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* interface_source, GHashTable* changed_properties, gchar** invalid, int invalid_length1); +gboolean mpris2_controller_playlists_support_exist (Mpris2Controller* self); 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_activate_playlist (Mpris2Controller* self, const char* path); MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self); MprisPlayer* mpris2_controller_get_player (Mpris2Controller* self); +MprisPlaylists* mpris2_controller_get_playlists (Mpris2Controller* self); FreeDesktopProperties* mpris2_controller_get_properties_interface (Mpris2Controller* self); PlayerController* mpris2_controller_get_owner (Mpris2Controller* self); PlayerItem* player_item_new (const gchar* type); @@ -455,8 +541,15 @@ GType settings_manager_get_type (void) G_GNUC_CONST; SettingsManager* settings_manager_new (void); SettingsManager* settings_manager_construct (GType object_type); gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_length1); -gchar** settings_manager_fetch_interested (SettingsManager* self, int* result_length1); -gboolean settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); +GeeArrayList* settings_manager_fetch_interested (SettingsManager* self); +void settings_manager_clear_list (SettingsManager* self); +void settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); +GType playlists_menuitem_get_type (void) G_GNUC_CONST; +PlaylistsMenuitem* playlists_menuitem_new (PlayerController* parent); +PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerController* parent); +void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1); +void playlists_menuitem_update_active_playlist (PlaylistsMenuitem* self, PlaylistDetails* detail); +GeeHashSet* playlists_menuitem_attributes_format (void); GType fetch_file_get_type (void) G_GNUC_CONST; FetchFile* fetch_file_new (const gchar* uri, const gchar* prop); FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gchar* prop); diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 327a775..c7391cf 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -27,8 +27,6 @@ public class MusicPlayerBridge : GLib.Object private Dbusmenu.Menuitem root_menu; private HashMap registered_clients; private Mpris2Watcher watcher; - private const string DESKTOP_PREFIX = "/usr/share/applications/"; - private Settings settings; public MusicPlayerBridge() { @@ -49,17 +47,17 @@ public class MusicPlayerBridge : GLib.Object { foreach ( string desktop in this.settings_manager.fetch_interested()){ debug ( "interested client found : %s", desktop ); - string path = DESKTOP_PREFIX.concat ( desktop.concat( ".desktop" ) ); - AppInfo? app_info = create_app_info ( path ); + AppInfo? app_info = create_app_info ( desktop.concat( ".desktop" ) ); if ( app_info == null ){ - warning ( "Could not create app_info for path %s \n Getting out of here ", path); + warning ( "Could not create app_info for path %s \n Getting out of here ", + desktop ); continue; } - var mpris_key = determine_key ( path ); + var mpris_key = determine_key ( desktop ); PlayerController ctrl = new PlayerController ( this.root_menu, app_info, null, - this.fetch_icon_name(path), + this.fetch_icon_name(desktop), calculate_menu_position(), PlayerController.state.OFFLINE ); this.registered_clients.set(mpris_key, ctrl); @@ -76,29 +74,34 @@ public class MusicPlayerBridge : GLib.Object } } - public void client_has_become_available ( string desktop, string dbus_name ) + public void client_has_become_available ( string desktop, string dbus_name ) { if (desktop == null || desktop == ""){ warning("Client %s attempting to register without desktop entry being set on the mpris root", dbus_name); return; } + if (desktop in this.settings_manager.fetch_blacklist()) { + debug ("Client %s attempting to register but it has been blacklisted", + desktop); + } + debug ( "client_has_become_available %s", desktop ); - string path = DESKTOP_PREFIX.concat ( desktop.concat( ".desktop" ) ); - AppInfo? app_info = create_app_info ( path ); + AppInfo? app_info = create_app_info ( desktop.concat( ".desktop" ) ); if ( app_info == null ){ - warning ( "Could not create app_info for path %s \n Getting out of here ", path); + warning ( "Could not create app_info for path %s \n Getting out of here ", + desktop ); return; } - var mpris_key = determine_key ( path ); + var mpris_key = determine_key ( desktop ); // Are we sure clients will appear like this with the new registration method in place. if ( this.registered_clients.has_key (mpris_key) == false ){ debug("New client has registered that we have not seen before: %s", dbus_name ); PlayerController ctrl = new PlayerController ( this.root_menu, app_info, dbus_name, - this.fetch_icon_name(path), + this.fetch_icon_name(desktop), this.calculate_menu_position(), PlayerController.state.READY ); this.registered_clients.set ( mpris_key, ctrl ); @@ -119,7 +122,7 @@ public class MusicPlayerBridge : GLib.Object if (root_menu != null){ debug("attempt to remove %s", mpris_root_interface); var mpris_key = determine_key ( mpris_root_interface ); - if ( mpris_key != null ){ + if ( mpris_key != null && this.registered_clients.has_key(mpris_key)){ registered_clients[mpris_key].hibernate(); debug("Successively offlined client %s", mpris_key); } @@ -129,28 +132,31 @@ public class MusicPlayerBridge : GLib.Object public void set_root_menu_item ( Dbusmenu.Menuitem menu ) { 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.try_to_add_inactive_familiar_clients(); } - private static AppInfo? create_app_info ( string path ) + private static AppInfo? create_app_info ( string desktop ) { - DesktopAppInfo info = new DesktopAppInfo.from_filename ( path ) ; - if ( path == null || info == null ){ - warning ( "Could not create a desktopappinfo instance from app: %s", path ); + DesktopAppInfo info = new DesktopAppInfo ( desktop ) ; + + if ( desktop == null || info == null ){ + warning ( "Could not create a desktopappinfo instance from app: %s", desktop ); return null; } GLib.AppInfo app_info = info as GLib.AppInfo; return app_info; } - private static string? fetch_icon_name(string desktop_path) + private static string? fetch_icon_name(string desktop) { + // We know the appinfo is good because it was loaded in the previous reg step. + DesktopAppInfo info = new DesktopAppInfo ( desktop.concat( ".desktop" ) ) ; KeyFile desktop_keyfile = new KeyFile (); try{ - desktop_keyfile.load_from_file (desktop_path, KeyFileFlags.NONE); + desktop_keyfile.load_from_file (info.get_filename(), KeyFileFlags.NONE); } catch(GLib.FileError error){ warning("Error loading keyfile - FileError"); @@ -172,24 +178,19 @@ public class MusicPlayerBridge : GLib.Object } /* - Messy but necessary method to consolidate desktop filesnames and mpris dbus names - into the one single word string (used as the key in the players hash). + Messy but necessary method to consolidate desktop filesnames and mpris dbus + names into the one single word string (used as the key in the players hash). So this means that we can determine the key for the players_hash from the - dbus interface name or the desktop file name. + dbus interface name or the desktop file name, at startup offline/online and + shutdown. */ - private static string? determine_key(owned string path) + private static string? determine_key(owned string desktop_or_interface) { - var tokens = path.split( "/" ); - if ( tokens.length < 2 ){ - // try to split on "." - tokens = path.split("."); - if ( tokens.length < 2 ){ - // don't know what this is - return null; - } + var result = desktop_or_interface; + var tokens = desktop_or_interface.split( "." ); + if ( tokens.length > 1 ){ + result = tokens[tokens.length - 1]; } - var filename = tokens[tokens.length - 1]; - var result = filename.split(".")[0]; var temp = result.split("-"); if (temp.length > 1){ result = temp[0]; diff --git a/src/player-controller.c b/src/player-controller.c index 2872736..6a84368 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -81,6 +81,18 @@ typedef struct _Mpris2ControllerClass Mpris2ControllerClass; typedef struct _TitleMenuitem TitleMenuitem; typedef struct _TitleMenuitemClass TitleMenuitemClass; +#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)) +#define IS_PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYLISTS_MENUITEM)) +#define IS_PLAYLISTS_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYLISTS_MENUITEM)) +#define PLAYLISTS_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitemClass)) + +typedef struct _PlaylistsMenuitem PlaylistsMenuitem; +typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass; +typedef struct _PlayerItemPrivate PlayerItemPrivate; +typedef struct _PlaylistsMenuitemPrivate PlaylistsMenuitemPrivate; + #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)) @@ -115,7 +127,6 @@ struct _PlayerControllerClass { struct _PlayerControllerPrivate { DbusmenuMenuitem* root_menu; - gchar* _name; gchar* _dbus_name; GAppInfo* _app_info; gint _menu_offset; @@ -126,7 +137,8 @@ typedef enum { PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, - PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT + PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, + PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS } PlayerControllerwidget_order; typedef enum { @@ -137,6 +149,25 @@ typedef enum { PLAYER_CONTROLLER_STATE_DISCONNECTED } PlayerControllerstate; +struct _PlayerItem { + DbusmenuMenuitem parent_instance; + PlayerItemPrivate * priv; +}; + +struct _PlayerItemClass { + DbusmenuMenuitemClass parent_class; +}; + +struct _PlaylistsMenuitem { + PlayerItem parent_instance; + PlaylistsMenuitemPrivate * priv; + DbusmenuMenuitem* root_item; +}; + +struct _PlaylistsMenuitemClass { + PlayerItemClass parent_class; +}; + static gpointer player_controller_parent_class = NULL; @@ -146,7 +177,6 @@ GType mpris2_controller_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, - PLAYER_CONTROLLER_NAME, PLAYER_CONTROLLER_DBUS_NAME, PLAYER_CONTROLLER_APP_INFO, PLAYER_CONTROLLER_MENU_OFFSET, @@ -154,21 +184,18 @@ enum { }; GType player_controller_widget_order_get_type (void) G_GNUC_CONST; GType player_controller_state_get_type (void) G_GNUC_CONST; -#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5 PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state); PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, PlayerControllerstate initial_state); void player_controller_set_app_info (PlayerController* self, GAppInfo* value); void player_controller_set_dbus_name (PlayerController* self, const gchar* value); -static gchar* player_controller_format_player_name (gchar* app_info_name); -GAppInfo* player_controller_get_app_info (PlayerController* self); -void player_controller_set_name (PlayerController* self, const gchar* value); void player_controller_set_icon_name (PlayerController* self, const gchar* value); void player_controller_set_menu_offset (PlayerController* self, gint value); static void player_controller_construct_widgets (PlayerController* self); static void player_controller_establish_mpris_connection (PlayerController* self); void player_controller_update_layout (PlayerController* self); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); -const gchar* player_controller_get_name (PlayerController* self); +GAppInfo* player_controller_get_app_info (PlayerController* self); void player_controller_activate (PlayerController* self, const gchar* dbus_name); void player_controller_instantiate (PlayerController* self); const gchar* player_controller_get_dbus_name (PlayerController* self); @@ -182,7 +209,9 @@ GeeHashSet* transport_menuitem_attributes_format (void); GeeHashSet* metadata_menuitem_attributes_format (void); GType title_menuitem_get_type (void) G_GNUC_CONST; void title_menuitem_toggle_active_triangle (TitleMenuitem* self, gboolean update); +GType playlists_menuitem_get_type (void) G_GNUC_CONST; gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); +gboolean mpris2_controller_playlists_support_exist (Mpris2Controller* self); PlayerItem* player_item_new (const gchar* type); PlayerItem* player_item_construct (GType object_type, const gchar* type); TitleMenuitem* title_menuitem_new (PlayerController* parent); @@ -193,7 +222,10 @@ GType metadata_menuitem_get_type (void) G_GNUC_CONST; TransportMenuitem* transport_menuitem_new (PlayerController* parent); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent); 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); @@ -208,7 +240,7 @@ static gint _vala_array_length (gpointer array); GType player_controller_widget_order_get_type (void) { static volatile gsize player_controller_widget_order_type_id__volatile = 0; if (g_once_init_enter (&player_controller_widget_order_type_id__volatile)) { - static const GEnumValue values[] = {{PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, "PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR", "separator"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, "PLAYER_CONTROLLER_WIDGET_ORDER_TITLE", "title"}, {PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, "PLAYER_CONTROLLER_WIDGET_ORDER_METADATA", "metadata"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, "PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT", "transport"}, {0, NULL, NULL}}; + static const GEnumValue values[] = {{PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, "PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR", "separator"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, "PLAYER_CONTROLLER_WIDGET_ORDER_TITLE", "title"}, {PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, "PLAYER_CONTROLLER_WIDGET_ORDER_METADATA", "metadata"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, "PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT", "transport"}, {PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS, "PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS", "playlists"}, {0, NULL, NULL}}; GType player_controller_widget_order_type_id; player_controller_widget_order_type_id = g_enum_register_static ("PlayerControllerwidget_order", values); g_once_init_leave (&player_controller_widget_order_type_id__volatile, player_controller_widget_order_type_id); @@ -238,12 +270,8 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit PlayerController * self = NULL; DbusmenuMenuitem* _tmp0_; DbusmenuMenuitem* _tmp1_; - const gchar* _tmp2_ = NULL; - gchar* _tmp3_; - gchar* _tmp4_ = NULL; - gchar* _tmp5_; - GeeArrayList* _tmp6_ = NULL; - GeeArrayList* _tmp7_; + GeeArrayList* _tmp2_ = NULL; + GeeArrayList* _tmp3_; g_return_val_if_fail (root != NULL, NULL); g_return_val_if_fail (app != NULL, NULL); g_return_val_if_fail (icon_name != NULL, NULL); @@ -254,17 +282,11 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit self->priv->root_menu = _tmp1_; player_controller_set_app_info (self, app); player_controller_set_dbus_name (self, dbus_name); - _tmp2_ = g_app_info_get_name (self->priv->_app_info); - _tmp3_ = g_strdup (_tmp2_); - _tmp4_ = player_controller_format_player_name (_tmp3_); - _tmp5_ = _tmp4_; - player_controller_set_name (self, _tmp5_); - _g_free0 (_tmp5_); player_controller_set_icon_name (self, icon_name); - _tmp6_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); - _tmp7_ = _tmp6_; + _tmp2_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + _tmp3_ = _tmp2_; _g_object_unref0 (self->custom_items); - self->custom_items = _tmp7_; + self->custom_items = _tmp3_; self->current_state = (gint) initial_state; player_controller_set_menu_offset (self, offset); player_controller_construct_widgets (self); @@ -280,9 +302,11 @@ PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) { + const gchar* _tmp0_ = NULL; g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:76: update_state - player controller %s : new s" \ -"tate %i", self->priv->_name, (gint) new_state); + _tmp0_ = g_app_info_get_name (self->priv->_app_info); + g_debug ("player-controller.vala:75: update_state - player controller %s : new s" \ +"tate %i", _tmp0_, (gint) new_state); self->current_state = (gint) new_state; player_controller_update_layout (self); } @@ -297,9 +321,11 @@ void player_controller_activate (PlayerController* self, const gchar* dbus_name) void player_controller_instantiate (PlayerController* self) { + const gchar* _tmp0_ = NULL; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:95: instantiate in player controller for %s", self->priv->_name); + _tmp0_ = g_app_info_get_name (self->priv->_app_info); + g_debug ("player-controller.vala:95: 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; @@ -309,10 +335,12 @@ void player_controller_instantiate (PlayerController* self) { __catch6_g_error: { GError * _error_; + const gchar* _tmp1_ = NULL; _error_ = _inner_error_; _inner_error_ = NULL; + _tmp1_ = g_app_info_get_name (self->priv->_app_info); g_warning ("player-controller.vala:101: Failed to launch app %s with error message" \ -": %s", self->priv->_name, _error_->message); +": %s", _tmp1_, _error_->message); _g_error_free0 (_error_); } __finally6: @@ -335,7 +363,7 @@ static void player_controller_establish_mpris_connection (PlayerController* self _tmp0_ = self->priv->_dbus_name == NULL; } if (_tmp0_) { - g_debug ("player-controller.vala:108: establish_mpris_connection - Not ready to " \ + g_debug ("player-controller.vala:109: establish_mpris_connection - Not ready to " \ "connect"); return; } @@ -389,6 +417,7 @@ void player_controller_hibernate (PlayerController* self) { gpointer _tmp8_ = NULL; PlayerItem* _tmp9_; TitleMenuitem* title; + Mpris2Controller* _tmp10_; g_return_if_fail (self != NULL); player_controller_update_state (self, PLAYER_CONTROLLER_STATE_OFFLINE); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); @@ -408,51 +437,65 @@ void player_controller_hibernate (PlayerController* self) { _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); title = (_tmp9_ = (PlayerItem*) _tmp8_, IS_TITLE_MENUITEM (_tmp9_) ? ((TitleMenuitem*) _tmp9_) : NULL); title_menuitem_toggle_active_triangle (title, FALSE); + _tmp10_ = NULL; + _g_object_unref0 (self->mpris_bridge); + self->mpris_bridge = _tmp10_; _g_object_unref0 (title); } void player_controller_update_layout (PlayerController* self) { - gpointer _tmp4_ = NULL; - PlayerItem* _tmp5_; + gpointer _tmp0_ = NULL; + PlayerItem* _tmp1_; + PlaylistsMenuitem* playlists_menuitem; gpointer _tmp6_ = NULL; PlayerItem* _tmp7_; - GeeHashSet* _tmp8_ = NULL; - GeeHashSet* _tmp9_; - gboolean _tmp10_; - gpointer _tmp11_ = NULL; - PlayerItem* _tmp12_; + gpointer _tmp8_ = NULL; + PlayerItem* _tmp9_; + GeeHashSet* _tmp10_ = NULL; + GeeHashSet* _tmp11_; + gboolean _tmp12_; + gpointer _tmp13_ = NULL; + PlayerItem* _tmp14_; + gboolean _tmp15_; g_return_if_fail (self != NULL); + _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); + playlists_menuitem = (_tmp1_ = (PlayerItem*) _tmp0_, IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL); if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) { - gpointer _tmp0_ = NULL; - PlayerItem* _tmp1_; gpointer _tmp2_ = NULL; PlayerItem* _tmp3_; - _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp1_ = (PlayerItem*) _tmp0_; - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp1_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - _g_object_unref0 (_tmp1_); - _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + gpointer _tmp4_ = NULL; + PlayerItem* _tmp5_; + _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); _tmp3_ = (PlayerItem*) _tmp2_; dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp3_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); _g_object_unref0 (_tmp3_); + _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp5_ = (PlayerItem*) _tmp4_; + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp5_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + _g_object_unref0 (_tmp5_); + dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + _g_object_unref0 (playlists_menuitem); return; } - _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); - _tmp5_ = (PlayerItem*) _tmp4_; _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp7_ = (PlayerItem*) _tmp6_; - _tmp8_ = metadata_menuitem_attributes_format (); - _tmp9_ = _tmp8_; - _tmp10_ = player_item_populated (_tmp7_, _tmp9_); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp5_, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp10_); + _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp9_ = (PlayerItem*) _tmp8_; + _tmp10_ = metadata_menuitem_attributes_format (); + _tmp11_ = _tmp10_; + _tmp12_ = player_item_populated (_tmp9_, _tmp11_); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp7_, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp12_); + _g_object_unref0 (_tmp11_); _g_object_unref0 (_tmp9_); _g_object_unref0 (_tmp7_); - _g_object_unref0 (_tmp5_); - _tmp11_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp12_ = (PlayerItem*) _tmp11_; - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp12_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - _g_object_unref0 (_tmp12_); + _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); + _tmp14_ = (PlayerItem*) _tmp13_; + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp14_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + _g_object_unref0 (_tmp14_); + _tmp15_ = mpris2_controller_playlists_support_exist (self->mpris_bridge); + dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp15_); + _g_object_unref0 (playlists_menuitem); } @@ -465,6 +508,8 @@ static void player_controller_construct_widgets (PlayerController* self) { MetadataMenuitem* metadata_item; TransportMenuitem* _tmp4_ = NULL; TransportMenuitem* transport_item; + PlaylistsMenuitem* _tmp5_ = NULL; + PlaylistsMenuitem* playlist_menuitem; g_return_if_fail (self != NULL); _tmp0_ = player_item_new (DBUSMENU_CLIENT_TYPES_SEPARATOR); _tmp1_ = _tmp0_; @@ -479,33 +524,51 @@ static void player_controller_construct_widgets (PlayerController* self) { _tmp4_ = transport_menuitem_new (self); transport_item = _tmp4_; gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) transport_item); + _tmp5_ = playlists_menuitem_new (self); + playlist_menuitem = _tmp5_; + gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) playlist_menuitem); { - GeeArrayList* _tmp5_; + GeeArrayList* _tmp6_; GeeArrayList* _item_list; - gint _tmp6_; + gint _tmp7_; gint _item_size; gint _item_index; - _tmp5_ = _g_object_ref0 (self->custom_items); - _item_list = _tmp5_; - _tmp6_ = gee_collection_get_size ((GeeCollection*) _item_list); - _item_size = _tmp6_; + _tmp6_ = _g_object_ref0 (self->custom_items); + _item_list = _tmp6_; + _tmp7_ = gee_collection_get_size ((GeeCollection*) _item_list); + _item_size = _tmp7_; _item_index = -1; while (TRUE) { - gpointer _tmp7_ = NULL; + gpointer _tmp8_ = NULL; PlayerItem* item; - gint _tmp8_; + gint _tmp9_; _item_index = _item_index + 1; if (!(_item_index < _item_size)) { break; } - _tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index); - item = (PlayerItem*) _tmp7_; - _tmp8_ = 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 + _tmp8_)); + _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index); + item = (PlayerItem*) _tmp8_; + _tmp9_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); + if (_tmp9_ != 4) { + gint _tmp10_; + _tmp10_ = 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 + _tmp10_)); + } else { + PlayerItem* _tmp11_; + PlaylistsMenuitem* _tmp12_; + PlaylistsMenuitem* playlists_menuitem; + gint _tmp13_; + _tmp12_ = _g_object_ref0 ((_tmp11_ = item, IS_PLAYLISTS_MENUITEM (_tmp11_) ? ((PlaylistsMenuitem*) _tmp11_) : NULL)); + playlists_menuitem = _tmp12_; + _tmp13_ = 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 + _tmp13_)); + _g_object_unref0 (playlists_menuitem); + } _g_object_unref0 (item); } _g_object_unref0 (_item_list); } + _g_object_unref0 (playlist_menuitem); _g_object_unref0 (transport_item); _g_object_unref0 (metadata_item); _g_object_unref0 (title_menu_item); @@ -627,7 +690,7 @@ static gchar* player_controller_format_player_name (gchar* app_info_name) { _g_free0 (_tmp14_); _g_free0 (_tmp11_); } - g_debug ("player-controller.vala:178: PlayerController->format_player_name - : %" \ + g_debug ("player-controller.vala:197: PlayerController->format_player_name - : %" \ "s", _result_); result = _result_; tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL); @@ -656,26 +719,6 @@ static void player_controller_determine_state (PlayerController* self) { } -const gchar* player_controller_get_name (PlayerController* self) { - const gchar* result; - g_return_val_if_fail (self != NULL, NULL); - result = self->priv->_name; - return result; -} - - -void player_controller_set_name (PlayerController* self, const gchar* value) { - gchar* _tmp0_; - gchar* _tmp1_; - g_return_if_fail (self != NULL); - _tmp0_ = g_strdup (value); - _tmp1_ = _tmp0_; - _g_free0 (self->priv->_name); - self->priv->_name = _tmp1_; - g_object_notify ((GObject *) self, "name"); -} - - const gchar* player_controller_get_dbus_name (PlayerController* self) { const gchar* result; g_return_val_if_fail (self != NULL, NULL); @@ -757,7 +800,6 @@ static void player_controller_class_init (PlayerControllerClass * klass) { G_OBJECT_CLASS (klass)->get_property = _vala_player_controller_get_property; G_OBJECT_CLASS (klass)->set_property = _vala_player_controller_set_property; G_OBJECT_CLASS (klass)->finalize = player_controller_finalize; - g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_DBUS_NAME, g_param_spec_string ("dbus-name", "dbus-name", "dbus-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_APP_INFO, g_param_spec_object ("app-info", "app-info", "app-info", G_TYPE_APP_INFO, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MENU_OFFSET, g_param_spec_int ("menu-offset", "menu-offset", "menu-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); @@ -775,7 +817,6 @@ static void player_controller_finalize (GObject* obj) { PlayerController * self; self = PLAYER_CONTROLLER (obj); _g_object_unref0 (self->priv->root_menu); - _g_free0 (self->priv->_name); _g_free0 (self->priv->_dbus_name); _g_object_unref0 (self->custom_items); _g_object_unref0 (self->mpris_bridge); @@ -801,9 +842,6 @@ static void _vala_player_controller_get_property (GObject * object, guint proper PlayerController * self; self = PLAYER_CONTROLLER (object); switch (property_id) { - case PLAYER_CONTROLLER_NAME: - g_value_set_string (value, player_controller_get_name (self)); - break; case PLAYER_CONTROLLER_DBUS_NAME: g_value_set_string (value, player_controller_get_dbus_name (self)); break; @@ -827,9 +865,6 @@ static void _vala_player_controller_set_property (GObject * object, guint proper PlayerController * self; self = PLAYER_CONTROLLER (object); switch (property_id) { - case PLAYER_CONTROLLER_NAME: - player_controller_set_name (self, g_value_get_string (value)); - break; case PLAYER_CONTROLLER_DBUS_NAME: player_controller_set_dbus_name (self, g_value_get_string (value)); break; diff --git a/src/player-controller.vala b/src/player-controller.vala index 97f5303..3922ecf 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,13 +23,14 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 4; + public const int WIDGET_QUANTITY = 5; public static enum widget_order{ SEPARATOR, TITLE, METADATA, - TRANSPORT + TRANSPORT, + PLAYLISTS } public enum state{ @@ -43,7 +44,6 @@ public class PlayerController : GLib.Object public int current_state = state.OFFLINE; private Dbusmenu.Menuitem root_menu; - public string name { get; set;} public string dbus_name { get; set;} public ArrayList custom_items; public Mpris2Controller mpris_bridge; @@ -61,7 +61,6 @@ public class PlayerController : GLib.Object this.root_menu = root; this.app_info = app; this.dbus_name = dbus_name; - this.name = format_player_name(this.app_info.get_name()); this.icon_name = icon_name; this.custom_items = new ArrayList(); this.current_state = initial_state; @@ -73,7 +72,8 @@ public class PlayerController : GLib.Object public void update_state(state new_state) { - debug("update_state - player controller %s : new state %i", this.name, new_state); + debug("update_state - player controller %s : new state %i", this.app_info.get_name(), + new_state); this.current_state = new_state; this.update_layout(); } @@ -92,13 +92,14 @@ public class PlayerController : GLib.Object */ public void instantiate() { - debug("instantiate in player controller for %s", this.name); + debug("instantiate in player controller for %s", this.app_info.get_name() ); try{ this.app_info.launch(null, null); this.update_state(state.INSTANTIATING); } catch(GLib.Error error){ - warning("Failed to launch app %s with error message: %s", this.name, error.message); + warning("Failed to launch app %s with error message: %s", this.app_info.get_name(), + error.message ); } } @@ -125,22 +126,29 @@ public class PlayerController : GLib.Object this.custom_items[widget_order.TRANSPORT].reset(TransportMenuitem.attributes_format()); this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format()); TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem; - title.toggle_active_triangle(false); + title.toggle_active_triangle(false); + this.mpris_bridge = null; } public void update_layout() { + PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem; + if(this.current_state != state.CONNECTED){ this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, false); this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, false); + playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, + false ); return; } this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, true); + playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, + this.mpris_bridge.playlists_support_exist() ); } private void construct_widgets() @@ -159,11 +167,22 @@ public class PlayerController : GLib.Object // Transport item TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); - + + // Playlist item + PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this); + this.custom_items.add(playlist_menuitem); + foreach(PlayerItem item in this.custom_items){ - root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + if (this.custom_items.index_of(item) != 4) { + root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + } + else{ + PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; + root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); + } } } + private static string format_player_name(owned string app_info_name) { @@ -184,11 +203,11 @@ public class PlayerController : GLib.Object if(this.mpris_bridge.connected() == true){ this.update_state(state.CONNECTED); TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem; - title.toggle_active_triangle(true); + title.toggle_active_triangle(true); this.mpris_bridge.initial_update(); } else{ this.update_state(state.DISCONNECTED); } - } + } } diff --git a/src/player-item.vala b/src/player-item.vala index c80a17d..f883a1e 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -54,7 +54,7 @@ public class PlayerItem : Dbusmenu.Menuitem if(data == null){ debug("PlayerItem::Update -> The hashtable was null - just leave it!"); return; - } + } foreach(string property in attributes){ string[] input_keys = property.split("-"); diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c new file mode 100644 index 0000000..3750074 --- /dev/null +++ b/src/playlists-menu-item.c @@ -0,0 +1,407 @@ +/* playlists-menu-item.c generated by valac 0.11.2, the Vala compiler + * generated from playlists-menu-item.vala, do not modify */ + +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#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; +typedef struct _PlayerItemPrivate PlayerItemPrivate; + +#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)) +#define IS_PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYLISTS_MENUITEM)) +#define IS_PLAYLISTS_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYLISTS_MENUITEM)) +#define PLAYLISTS_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitemClass)) + +typedef struct _PlaylistsMenuitem PlaylistsMenuitem; +typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass; +typedef struct _PlaylistsMenuitemPrivate PlaylistsMenuitemPrivate; + +#define TYPE_PLAYLIST_DETAILS (playlist_details_get_type ()) +typedef struct _PlaylistDetails PlaylistDetails; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +#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; +typedef struct _Block1Data Block1Data; +#define _playlist_details_free0(var) ((var == NULL) ? NULL : (var = (playlist_details_free (var), NULL))) +#define _g_free0(var) (var = (g_free (var), NULL)) +typedef struct _PlayerControllerPrivate PlayerControllerPrivate; + +#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; + +struct _PlayerItem { + DbusmenuMenuitem parent_instance; + PlayerItemPrivate * priv; +}; + +struct _PlayerItemClass { + DbusmenuMenuitemClass parent_class; +}; + +struct _PlaylistsMenuitem { + PlayerItem parent_instance; + PlaylistsMenuitemPrivate * priv; + DbusmenuMenuitem* root_item; +}; + +struct _PlaylistsMenuitemClass { + PlayerItemClass parent_class; +}; + +struct _PlaylistDetails { + char* path; + gchar* name; + gchar* icon_path; +}; + +struct _PlaylistsMenuitemPrivate { + GeeHashMap* current_playlists; +}; + +struct _Block1Data { + int _ref_count_; + PlaylistsMenuitem * self; + DbusmenuMenuitem* menuitem; +}; + +struct _PlayerController { + GObject parent_instance; + PlayerControllerPrivate * priv; + gint current_state; + GeeArrayList* custom_items; + Mpris2Controller* mpris_bridge; +}; + +struct _PlayerControllerClass { + GObjectClass parent_class; +}; + + +static gpointer playlists_menuitem_parent_class = NULL; + +GType player_item_get_type (void) G_GNUC_CONST; +GType playlists_menuitem_get_type (void) G_GNUC_CONST; +GType playlist_details_get_type (void) G_GNUC_CONST; +PlaylistDetails* playlist_details_dup (const PlaylistDetails* self); +void playlist_details_free (PlaylistDetails* self); +void playlist_details_copy (const PlaylistDetails* self, PlaylistDetails* dest); +void playlist_details_destroy (PlaylistDetails* self); +#define PLAYLISTS_MENUITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitemPrivate)) +enum { + PLAYLISTS_MENUITEM_DUMMY_PROPERTY +}; +GType player_controller_get_type (void) G_GNUC_CONST; +PlaylistsMenuitem* playlists_menuitem_new (PlayerController* parent); +PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerController* parent); +void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1); +static Block1Data* block1_data_ref (Block1Data* _data1_); +static void block1_data_unref (Block1Data* _data1_); +static gboolean playlists_menuitem_already_observed (PlaylistsMenuitem* self, PlaylistDetails* new_detail); +static void _lambda1_ (Block1Data* _data1_); +static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, gint menu_item_id); +static void __lambda1__dbusmenu_menuitem_item_activated (DbusmenuMenuitem* _sender, guint timestamp, gpointer self); +void playlists_menuitem_update_active_playlist (PlaylistsMenuitem* self, PlaylistDetails* detail); +PlayerController* player_item_get_owner (PlayerItem* self); +GType mpris2_controller_get_type (void) G_GNUC_CONST; +void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* path); +GeeHashSet* playlists_menuitem_attributes_format (void); +static GObject * playlists_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void playlists_menuitem_finalize (GObject* obj); + + +PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerController* parent) { + PlaylistsMenuitem * self = NULL; + g_return_val_if_fail (parent != NULL, NULL); + self = (PlaylistsMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_PLAYLISTS_MENUITEM_TYPE, "owner", parent, NULL); + return self; +} + + +PlaylistsMenuitem* playlists_menuitem_new (PlayerController* parent) { + return playlists_menuitem_construct (TYPE_PLAYLISTS_MENUITEM, parent); +} + + +static Block1Data* block1_data_ref (Block1Data* _data1_) { + g_atomic_int_inc (&_data1_->_ref_count_); + return _data1_; +} + + +static void block1_data_unref (Block1Data* _data1_) { + if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) { + _g_object_unref0 (_data1_->self); + _g_object_unref0 (_data1_->menuitem); + g_slice_free (Block1Data, _data1_); + } +} + + +static void _lambda1_ (Block1Data* _data1_) { + PlaylistsMenuitem * self; + gint _tmp0_; + self = _data1_->self; + _tmp0_ = dbusmenu_menuitem_get_id (_data1_->menuitem); + playlists_menuitem_submenu_item_activated (self, _tmp0_); +} + + +static void __lambda1__dbusmenu_menuitem_item_activated (DbusmenuMenuitem* _sender, guint timestamp, gpointer self) { + _lambda1_ (self); +} + + +void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playlists, int playlists_length1) { + g_return_if_fail (self != NULL); + { + PlaylistDetails* detail_collection; + int detail_collection_length1; + int detail_it; + detail_collection = playlists; + detail_collection_length1 = playlists_length1; + for (detail_it = 0; detail_it < playlists_length1; detail_it = detail_it + 1) { + PlaylistDetails _tmp0_; + PlaylistDetails _tmp1_ = {0}; + PlaylistDetails detail; + _tmp0_ = (playlist_details_copy (&detail_collection[detail_it], &_tmp1_), _tmp1_); + detail = _tmp0_; + { + Block1Data* _data1_; + gboolean _tmp2_; + DbusmenuMenuitem* _tmp3_ = NULL; + gint _tmp4_; + _data1_ = g_slice_new0 (Block1Data); + _data1_->_ref_count_ = 1; + _data1_->self = g_object_ref (self); + _tmp2_ = playlists_menuitem_already_observed (self, &detail); + if (_tmp2_) { + playlist_details_destroy (&detail); + block1_data_unref (_data1_); + continue; + } + _tmp3_ = dbusmenu_menuitem_new (); + _data1_->menuitem = _tmp3_; + dbusmenu_menuitem_property_set (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_LABEL, detail.name); + dbusmenu_menuitem_property_set (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, "source-smart-playlist"); + dbusmenu_menuitem_property_set_bool (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + _tmp4_ = dbusmenu_menuitem_get_id (_data1_->menuitem); + gee_abstract_map_set ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (_tmp4_), &detail); + g_signal_connect_data (_data1_->menuitem, "item-activated", (GCallback) __lambda1__dbusmenu_menuitem_item_activated, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); + dbusmenu_menuitem_child_append (self->root_item, _data1_->menuitem); + playlist_details_destroy (&detail); + block1_data_unref (_data1_); + } + } + } +} + + +static gboolean playlists_menuitem_already_observed (PlaylistsMenuitem* self, PlaylistDetails* new_detail) { + gboolean result = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + { + GeeCollection* _tmp0_ = NULL; + GeeCollection* _tmp1_; + GeeIterator* _tmp2_ = NULL; + GeeIterator* _tmp3_; + GeeIterator* _detail_it; + _tmp0_ = gee_map_get_values ((GeeMap*) self->priv->current_playlists); + _tmp1_ = _tmp0_; + _tmp2_ = gee_iterable_iterator ((GeeIterable*) _tmp1_); + _detail_it = (_tmp3_ = _tmp2_, _g_object_unref0 (_tmp1_), _tmp3_); + while (TRUE) { + gboolean _tmp4_; + gpointer _tmp5_ = NULL; + PlaylistDetails* _tmp6_; + PlaylistDetails _tmp7_; + PlaylistDetails _tmp8_ = {0}; + PlaylistDetails _tmp9_; + PlaylistDetails detail; + _tmp4_ = gee_iterator_next (_detail_it); + if (!_tmp4_) { + break; + } + _tmp5_ = gee_iterator_get (_detail_it); + _tmp6_ = (PlaylistDetails*) _tmp5_; + _tmp7_ = (playlist_details_copy (_tmp6_, &_tmp8_), _tmp8_); + detail = (_tmp9_ = _tmp7_, _playlist_details_free0 (_tmp6_), _tmp9_); + if (g_strcmp0 ((*new_detail).path, detail.path) == 0) { + result = TRUE; + playlist_details_destroy (&detail); + _g_object_unref0 (_detail_it); + return result; + } + playlist_details_destroy (&detail); + } + _g_object_unref0 (_detail_it); + } + result = FALSE; + return result; +} + + +void playlists_menuitem_update_active_playlist (PlaylistsMenuitem* self, PlaylistDetails* detail) { + gchar* _tmp0_; + gchar* update; + g_return_if_fail (self != NULL); + _tmp0_ = g_strdup ((*detail).name); + update = _tmp0_; + if (g_strcmp0 (update, "") == 0) { + gchar* _tmp1_; + gchar* _tmp2_; + _tmp1_ = g_strdup ("Choose Playlist"); + _tmp2_ = _tmp1_; + _g_free0 (update); + update = _tmp2_; + } + dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, update); + _g_free0 (update); +} + + +static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, gint menu_item_id) { + gboolean _tmp0_; + PlayerController* _tmp1_ = NULL; + gpointer _tmp2_ = NULL; + PlaylistDetails* _tmp3_; + 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:72: item %i was activated but we don't have a" \ +" corresponding playlist", menu_item_id); + return; + } + _tmp1_ = player_item_get_owner ((PlayerItem*) self); + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (menu_item_id)); + _tmp3_ = (PlaylistDetails*) _tmp2_; + mpris2_controller_activate_playlist (_tmp1_->mpris_bridge, (*_tmp3_).path); + _playlist_details_free0 (_tmp3_); +} + + +GeeHashSet* playlists_menuitem_attributes_format (void) { + GeeHashSet* result = NULL; + GeeHashSet* _tmp0_ = NULL; + GeeHashSet* attrs; + _tmp0_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL); + attrs = _tmp0_; + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_PLAYLISTS_MENUITEM_TITLE); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS); + result = attrs; + return result; +} + + +static GObject * playlists_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + PlaylistsMenuitem * self; + GeeHashMap* _tmp0_ = NULL; + GeeHashMap* _tmp1_; + DbusmenuMenuitem* _tmp2_ = NULL; + DbusmenuMenuitem* _tmp3_; + parent_class = G_OBJECT_CLASS (playlists_menuitem_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = PLAYLISTS_MENUITEM (obj); + _tmp0_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, TYPE_PLAYLIST_DETAILS, (GBoxedCopyFunc) playlist_details_dup, playlist_details_free, NULL, NULL, NULL); + _tmp1_ = _tmp0_; + _g_object_unref0 (self->priv->current_playlists); + self->priv->current_playlists = _tmp1_; + _tmp2_ = dbusmenu_menuitem_new (); + _tmp3_ = _tmp2_; + _g_object_unref0 (self->root_item); + self->root_item = _tmp3_; + dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, "Choose Playlist"); + return obj; +} + + +static void playlists_menuitem_class_init (PlaylistsMenuitemClass * klass) { + playlists_menuitem_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (PlaylistsMenuitemPrivate)); + G_OBJECT_CLASS (klass)->constructor = playlists_menuitem_constructor; + G_OBJECT_CLASS (klass)->finalize = playlists_menuitem_finalize; +} + + +static void playlists_menuitem_instance_init (PlaylistsMenuitem * self) { + self->priv = PLAYLISTS_MENUITEM_GET_PRIVATE (self); +} + + +static void playlists_menuitem_finalize (GObject* obj) { + PlaylistsMenuitem * self; + self = PLAYLISTS_MENUITEM (obj); + _g_object_unref0 (self->priv->current_playlists); + _g_object_unref0 (self->root_item); + G_OBJECT_CLASS (playlists_menuitem_parent_class)->finalize (obj); +} + + +GType playlists_menuitem_get_type (void) { + static volatile gsize playlists_menuitem_type_id__volatile = 0; + if (g_once_init_enter (&playlists_menuitem_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (PlaylistsMenuitemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) playlists_menuitem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PlaylistsMenuitem), 0, (GInstanceInitFunc) playlists_menuitem_instance_init, NULL }; + GType playlists_menuitem_type_id; + playlists_menuitem_type_id = g_type_register_static (TYPE_PLAYER_ITEM, "PlaylistsMenuitem", &g_define_type_info, 0); + g_once_init_leave (&playlists_menuitem_type_id__volatile, playlists_menuitem_type_id); + } + return playlists_menuitem_type_id__volatile; +} + + + diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala new file mode 100644 index 0000000..024839c --- /dev/null +++ b/src/playlists-menu-item.vala @@ -0,0 +1,87 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Dbusmenu; +using DbusmenuPlaylists; +using Gee; + +public class PlaylistsMenuitem : PlayerItem +{ + private HashMap current_playlists; + public Menuitem root_item; + public PlaylistsMenuitem ( PlayerController parent ) + { + Object ( item_type: MENUITEM_TYPE, owner: parent ); + } + construct{ + this.current_playlists = new HashMap(); + this.root_item = new Menuitem(); + this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" ); + } + + public new void update (PlaylistDetails[] playlists) + { + foreach ( PlaylistDetails detail in playlists ){ + if (this.already_observed(detail)) continue; + Dbusmenu.Menuitem menuitem = new Menuitem(); + menuitem.property_set (MENUITEM_PROP_LABEL, detail.name); + menuitem.property_set (MENUITEM_PROP_ICON_NAME, "source-smart-playlist"); + menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true); + menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true); + this.current_playlists.set( menuitem.id, detail ); + menuitem.item_activated.connect(() => { + submenu_item_activated (menuitem.id );}); + this.root_item.child_append( menuitem ); + } + } + + private bool already_observed (PlaylistDetails new_detail) + { + foreach ( PlaylistDetails detail in this.current_playlists.values ){ + if (new_detail.path == detail.path) return true; + } + return false; + } + + public void update_active_playlist(PlaylistDetails detail) + { + var update = detail.name; + if ( update == "" ) update = "Choose Playlist"; + this.root_item.property_set ( MENUITEM_PROP_LABEL, update ); + } + + private void submenu_item_activated (int menu_item_id) + { + if(!this.current_playlists.has_key(menu_item_id)){ + warning( "item %i was activated but we don't have a corresponding playlist", + menu_item_id ); + return; + } + this.owner.mpris_bridge.activate_playlist ( this.current_playlists[menu_item_id].path ); + } + + public static HashSet attributes_format() + { + HashSet attrs = new HashSet(); + attrs.add(MENUITEM_TITLE); + attrs.add(MENUITEM_PLAYLISTS); + return attrs; + } + +} diff --git a/src/settings-manager.c b/src/settings-manager.c index 06f3afb..060bba8 100644 --- a/src/settings-manager.c +++ b/src/settings-manager.c @@ -25,6 +25,7 @@ with this program. If not, see . #include #include #include +#include #define TYPE_SETTINGS_MANAGER (settings_manager_get_type ()) @@ -38,6 +39,7 @@ typedef struct _SettingsManager SettingsManager; typedef struct _SettingsManagerClass SettingsManagerClass; typedef struct _SettingsManagerPrivate SettingsManagerPrivate; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_free0(var) (var = (g_free (var), NULL)) struct _SettingsManager { GObject parent_instance; @@ -63,8 +65,10 @@ enum { SettingsManager* settings_manager_new (void); SettingsManager* settings_manager_construct (GType object_type); gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_length1); -gchar** settings_manager_fetch_interested (SettingsManager* self, int* result_length1); -gboolean settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); +GeeArrayList* settings_manager_fetch_interested (SettingsManager* self); +static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle); +void settings_manager_clear_list (SettingsManager* self); +void settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name); static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* value); static void settings_manager_on_blacklist_event (SettingsManager* self); static void g_cclosure_user_marshal_VOID__BOXED_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data); @@ -102,20 +106,80 @@ gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_len } -gchar** settings_manager_fetch_interested (SettingsManager* self, int* result_length1) { - gchar** result = NULL; +static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) { + int i; + for (i = 0; i < stack_length; i++) { + if (g_strcmp0 (stack[i], needle) == 0) { + return TRUE; + } + } + return FALSE; +} + + +GeeArrayList* settings_manager_fetch_interested (SettingsManager* self) { + GeeArrayList* result = NULL; gchar** _tmp0_; gchar** _tmp1_ = NULL; + gint blacklisted_length1; + gint _blacklisted_size_; gchar** _tmp2_; + gchar** blacklisted; + gchar** _tmp3_; + gchar** _tmp4_ = NULL; + gint interested_length1; + gint _interested_size_; + gchar** _tmp5_; + gchar** interested; + GeeArrayList* _tmp6_ = NULL; + GeeArrayList* list; g_return_val_if_fail (self != NULL, NULL); - _tmp1_ = _tmp0_ = g_settings_get_strv (self->priv->settings, "interested-media-players"); + _tmp1_ = _tmp0_ = g_settings_get_strv (self->priv->settings, "blacklisted-media-players"); _tmp2_ = _tmp1_; - *result_length1 = _vala_array_length (_tmp0_); - result = _tmp2_; + 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_; + { + gchar** s_collection; + int s_collection_length1; + int s_it; + s_collection = interested; + s_collection_length1 = interested_length1; + for (s_it = 0; s_it < interested_length1; s_it = s_it + 1) { + gchar* _tmp7_; + gchar* s; + _tmp7_ = g_strdup (s_collection[s_it]); + s = _tmp7_; + { + if (_vala_string_array_contains (blacklisted, blacklisted_length1, s)) { + _g_free0 (s); + continue; + } + gee_abstract_collection_add ((GeeAbstractCollection*) list, s); + _g_free0 (s); + } + } + } + result = list; + interested = (_vala_array_free (interested, interested_length1, (GDestroyNotify) g_free), NULL); + blacklisted = (_vala_array_free (blacklisted, blacklisted_length1, (GDestroyNotify) g_free), NULL); return result; } +void settings_manager_clear_list (SettingsManager* self) { + g_return_if_fail (self != NULL); + g_settings_reset (self->priv->settings, "interested-media-players"); +} + + static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* value) { if ((*length) == (*size)) { *size = (*size) ? (2 * (*size)) : 4; @@ -126,29 +190,47 @@ static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* val } -gboolean settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name) { - gboolean result = FALSE; - gint _tmp0_; +void settings_manager_add_interested (SettingsManager* self, const gchar* app_desktop_name) { + gchar** _tmp0_; gchar** _tmp1_ = NULL; gint already_interested_length1; gint _already_interested_size_; gchar** _tmp2_; gchar** already_interested; - gchar* _tmp3_; - gboolean _tmp4_; - g_return_val_if_fail (self != NULL, FALSE); - g_return_val_if_fail (app_desktop_name != NULL, FALSE); - _tmp1_ = settings_manager_fetch_interested (self, &_tmp0_); + gchar* _tmp4_; + 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_length1 = _tmp0_; + already_interested_length1 = _vala_array_length (_tmp0_); _already_interested_size_ = already_interested_length1; already_interested = _tmp2_; - _tmp3_ = g_strdup (app_desktop_name); - _vala_array_add1 (&already_interested, &already_interested_length1, &_already_interested_size_, _tmp3_); - _tmp4_ = g_settings_set_strv (self->priv->settings, "interested-media-players", already_interested); - result = _tmp4_; + { + gchar** s_collection; + int s_collection_length1; + int s_it; + 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* s; + _tmp3_ = g_strdup (s_collection[s_it]); + s = _tmp3_; + { + if (g_strcmp0 (s, app_desktop_name) == 0) { + _g_free0 (s); + already_interested = (_vala_array_free (already_interested, already_interested_length1, (GDestroyNotify) g_free), NULL); + return; + } + _g_free0 (s); + } + } + } + _tmp4_ = g_strdup (app_desktop_name); + _vala_array_add1 (&already_interested, &already_interested_length1, &_already_interested_size_, _tmp4_); + 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); - return result; } diff --git a/src/settings-manager.vala b/src/settings-manager.vala index 05db430..57b4487 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -27,7 +27,7 @@ public class SettingsManager : GLib.Object } construct{ this.settings = new Settings ("com.canonical.indicators.sound"); - settings.changed["blacklisted-media-players"].connect (on_blacklist_event); + this.settings.changed["blacklisted-media-players"].connect (on_blacklist_event); } public string[] fetch_blacklist() @@ -35,17 +35,33 @@ public class SettingsManager : GLib.Object return this.settings.get_strv ("blacklisted-media-players"); } - public string[] fetch_interested() + public ArrayList fetch_interested() { - return this.settings.get_strv ("interested-media-players"); + var blacklisted = this.settings.get_strv ("blacklisted-media-players"); + var interested = this.settings.get_strv ("interested-media-players"); + var list = new ArrayList(); + foreach(var s in interested){ + if ( s in blacklisted ) continue; + list.add(s); + } + return list; } - public bool add_interested(string app_desktop_name) + public void clear_list() { - string[] already_interested = fetch_interested(); + this.settings.reset("interested-media-players"); + } + + public void add_interested(string app_desktop_name) + { + var already_interested = this.settings.get_strv ("interested-media-players"); + foreach ( var s in already_interested){ + if ( s == app_desktop_name ) return; + } already_interested += (app_desktop_name); - return this.settings.set_strv( "interested-media-players", - already_interested ); + this.settings.set_strv( "interested-media-players", + already_interested ); + this.settings.apply(); } private void on_blacklist_event() diff --git a/src/title-menu-item.c b/src/title-menu-item.c index 5e4ee1c..19df676 100644 --- a/src/title-menu-item.c +++ b/src/title-menu-item.c @@ -27,6 +27,7 @@ with this program. If not, see . #include #include #include +#include #include #include #include @@ -127,7 +128,7 @@ enum { GType player_controller_get_type (void) G_GNUC_CONST; TitleMenuitem* title_menuitem_new (PlayerController* parent); TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent); -const gchar* player_controller_get_name (PlayerController* self); +GAppInfo* player_controller_get_app_info (PlayerController* self); const gchar* player_controller_get_icon_name (PlayerController* self); static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GValue* input_value, guint timestamp); PlayerController* player_item_get_owner (PlayerItem* self); @@ -141,15 +142,14 @@ GeeHashSet* title_menuitem_attributes_format (void); TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent) { TitleMenuitem * self = NULL; - const gchar* _tmp0_ = NULL; + GAppInfo* _tmp0_ = NULL; const gchar* _tmp1_ = NULL; const gchar* _tmp2_ = NULL; g_return_val_if_fail (parent != NULL, NULL); self = (TitleMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_TITLE_MENUITEM_TYPE, "owner", parent, NULL); - _tmp0_ = player_controller_get_name (parent); - dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_NAME, _tmp0_); - _tmp1_ = player_controller_get_icon_name (parent); - g_debug ("title-menu-item.vala:30: title init - icon name = %s", _tmp1_); + _tmp0_ = player_controller_get_app_info (parent); + _tmp1_ = g_app_info_get_name (_tmp0_); + dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_NAME, _tmp1_); _tmp2_ = player_controller_get_icon_name (parent); dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_ICON, _tmp2_); dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_RUNNING, FALSE); diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index d782e84..0b99ae3 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -26,8 +26,7 @@ public class TitleMenuitem : PlayerItem public TitleMenuitem(PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - this.property_set(MENUITEM_NAME, parent.name); - debug("title init - icon name = %s", parent.icon_name); + this.property_set(MENUITEM_NAME, parent.app_info.get_name()); this.property_set(MENUITEM_ICON, parent.icon_name); this.property_set_bool(MENUITEM_RUNNING, false); } diff --git a/src/title-widget.c b/src/title-widget.c index cbdf28e..08b4b81 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -92,7 +92,7 @@ title_widget_set_icon(TitleWidget *self) GString* app_panel = g_string_new ( g_utf8_strdown ( dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_TITLE_MENUITEM_NAME), -1 )); GtkWidget * icon = NULL; - + // Not ideal but apparently we want the banshee icon to be the greyscale one // and any others to be the icon from the desktop file => colour. if ( g_string_equal ( banshee_string, app_panel ) == TRUE && @@ -153,18 +153,12 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property, { g_return_if_fail (IS_TITLE_WIDGET (userdata)); TitleWidget* mitem = TITLE_WIDGET(userdata); - g_debug("PROPERTY UPDATE FOR THE TITLE"); if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), g_value_get_string(value)); } else if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_ICON, property) == 0){ - g_debug("changing the icon data on the title - %s", - g_value_get_string(value)); - GtkWidget * icon = gtk_image_new_from_icon_name(g_value_get_string(value), - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mitem), GTK_WIDGET(icon)); - + title_widget_set_icon (mitem); } } diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c index 37a63d9..5299ae1 100644 --- a/src/transport-menu-item.c +++ b/src/transport-menu-item.c @@ -29,6 +29,7 @@ with this program. If not, see . #include #include #include +#include #include @@ -138,7 +139,7 @@ TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerContro void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMenuitemstate update); static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GValue* input_value, guint timestamp); PlayerController* player_item_get_owner (PlayerItem* self); -const gchar* player_controller_get_name (PlayerController* self); +GAppInfo* player_controller_get_app_info (PlayerController* self); GType mpris2_controller_get_type (void) G_GNUC_CONST; void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command); GeeHashSet* transport_menuitem_attributes_format (void); @@ -197,8 +198,9 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* _tmp1_ = NULL; gchar* _tmp2_; PlayerController* _tmp3_ = NULL; - const gchar* _tmp4_ = NULL; - PlayerController* _tmp5_ = NULL; + GAppInfo* _tmp4_ = NULL; + const gchar* _tmp5_ = NULL; + PlayerController* _tmp6_ = NULL; self = (TransportMenuitem*) base; g_return_if_fail (name != NULL); _tmp0_ = g_value_get_int (input_value); @@ -208,10 +210,11 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const g_debug ("transport-menu-item.vala:53: handle_event with value %s", _tmp2_); _g_free0 (_tmp2_); _tmp3_ = player_item_get_owner ((PlayerItem*) self); - _tmp4_ = player_controller_get_name (_tmp3_); - g_debug ("transport-menu-item.vala:54: transport owner name = %s", _tmp4_); - _tmp5_ = player_item_get_owner ((PlayerItem*) self); - mpris2_controller_transport_update (_tmp5_->mpris_bridge, (TransportMenuitemaction) input); + _tmp4_ = player_controller_get_app_info (_tmp3_); + _tmp5_ = g_app_info_get_name (_tmp4_); + g_debug ("transport-menu-item.vala:54: transport owner name = %s", _tmp5_); + _tmp6_ = player_item_get_owner ((PlayerItem*) self); + mpris2_controller_transport_update (_tmp6_->mpris_bridge, (TransportMenuitemaction) input); } diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 57eb67b..0e4e6ee 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -51,7 +51,7 @@ public class TransportMenuitem : PlayerItem { int input = input_value.get_int(); debug("handle_event with value %s", input.to_string()); - debug("transport owner name = %s", this.owner.name); + debug("transport owner name = %s", this.owner.app_info.get_name()); this.owner.mpris_bridge.transport_update((action)input); } diff --git a/src/transport-widget.c b/src/transport-widget.c index d9c499d..d7f4b75 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -4,6 +4,7 @@ Copyright 2010 Canonical Ltd. Authors: Conor Curran Mirco Müller + Andrea Cimitan 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 @@ -1156,6 +1157,7 @@ static void draw (GtkWidget* button, cairo_t *cr) { g_return_if_fail(IS_TRANSPORT_WIDGET(button)); + g_return_if_fail( cr != NULL ); TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button); cairo_surface_t* surf = NULL; diff --git a/vapi/Indicate-0.2.vapi b/vapi/Indicate-0.2.vapi deleted file mode 100644 index 1381037..0000000 --- a/vapi/Indicate-0.2.vapi +++ /dev/null @@ -1,218 +0,0 @@ -/* Indicate-0.2.vapi generated by vapigen, do not modify. */ - -[CCode (cprefix = "Indicate", lower_case_cprefix = "indicate_")] -namespace Indicate { - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public class Indicator : GLib.Object { - public weak GLib.Object parent; - [CCode (has_construct_function = false)] - public Indicator (); - public bool get_displayed (); - public uint get_id (); - public virtual GLib.Value get_property (string key); - public GLib.Value get_property_value (string key); - public Indicate.Server get_server (); - public bool is_visible (); - public string[] list_properties (); - public void set_displayed (bool displayed); - public virtual void set_property (string key, GLib.Value data); - public void set_property_bool (string key, bool value); - public void set_property_int (string key, int value); - public void set_property_time (string key, GLib.TimeVal time); - public void set_property_value (string key, GLib.Value value); - public void set_server (Indicate.Server server); - [CCode (has_construct_function = false)] - public Indicator.with_server (Indicate.Server server); - public signal void displayed (bool object); - [HasEmitter] - public signal void hide (); - public signal void modified (string object); - [HasEmitter] - public signal void show (); - [HasEmitter] - public signal void user_display (uint object); - } - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public class Listener : GLib.Object { - public weak GLib.Object parent; - [CCode (has_construct_function = false)] - public Listener (); - public void display (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, uint timestamp); - public void displayed (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, bool displayed); - public void get_property (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_cb callback); - public void get_property_bool (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_bool_cb callback); - public void get_property_int (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_int_cb callback); - public void get_property_time (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_time_cb callback); - public void get_property_value (Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, [CCode (delegate_target_pos = 0)] Indicate.listener_get_property_value_cb callback); - public static GLib.Type indicator_get_gtype (); - public static Indicate.Listener ref_default (); - public bool server_check_interest (Indicate.ListenerServer server, Indicate.Interests interest); - public void server_get_count (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_uint_property_cb callback); - public void server_get_desktop (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback, void* data); - public static GLib.Type server_get_gtype (); - public void server_get_menu (Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); - public static void server_get_type (Indicate.Listener listener, Indicate.ListenerServer server, [CCode (delegate_target_pos = 0)] Indicate.listener_get_server_property_cb callback); - public void server_remove_interest (Indicate.ListenerServer server, Indicate.Interests interest); - public void server_show_interest (Indicate.ListenerServer server, Indicate.Interests interest); - public void set_default_max_indicators (int max); - public void set_server_max_indicators (Indicate.ListenerServer server, int max); - public signal void indicator_added (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); - public signal void indicator_modified (Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string p1); - public signal void indicator_removed (Indicate.ListenerServer object, Indicate.ListenerIndicator p0); - public signal void indicator_servers_report (); - public signal void server_added (Indicate.ListenerServer object, string p0); - public signal void server_count_changed (Indicate.ListenerServer object, uint p0); - public signal void server_removed (Indicate.ListenerServer object, string p0); - } - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public class Server : GLib.Object { - public weak GLib.Object parent; - public void add_indicator (Indicate.Indicator indicator); - public virtual bool check_interest (Indicate.Interests interest); - public virtual bool get_indicator_count (out uint count) throws GLib.Error; - public virtual bool get_indicator_property (uint id, owned string property, GLib.Value value) throws GLib.Error; - public int get_max_indicators (); - public virtual uint get_next_id (); - public void hide (); - public virtual void indicator_added (uint id); - public virtual bool indicator_displayed (owned string sender, uint id, bool displayed) throws GLib.Error; - public virtual void indicator_removed (uint id); - public virtual int max_indicators_get (); - public virtual bool max_indicators_set (owned string sender, int max); - public static Indicate.Server ref_default (); - public void remove_indicator (Indicate.Indicator indicator); - public virtual bool remove_interest (owned string sender, Indicate.Interests interest); - public void set_count (uint count); - public static void set_dbus_object (string obj); - public void set_default (); - public void set_desktop_file (string path); - public void set_menu (Dbusmenu.Server menu); - public void set_type (string type); - public void show (); - public virtual bool show_indicator_to_user (uint id, uint timestamp) throws GLib.Error; - public virtual bool show_interest (owned string sender, Indicate.Interests interest); - public uint count { get; set; } - public string desktop { get; set; } - public string type { get; set; } - public signal void indicator_delete (uint object); - public signal void indicator_modified (uint object, string p0); - public signal void indicator_new (uint object); - public signal void interest_added (uint object); - public signal void interest_removed (uint object); - public signal void max_indicators_changed (int object); - public signal void server_count_changed (uint object); - public signal void server_display (uint object); - public signal void server_hide (string object); - public signal void server_show (string object); - } - [CCode (type_id = "INDICATE_TYPE_LISTENER_INDICATOR", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public struct ListenerIndicator { - public uint get_id (); - } - [CCode (type_id = "INDICATE_TYPE_LISTENER_SERVER", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public struct ListenerServer { - public unowned string get_dbusname (); - } - [CCode (cprefix = "INDICATE_INTEREST_", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public enum Interests { - NONE, - SERVER_DISPLAY, - SERVER_SIGNAL, - INDICATOR_DISPLAY, - INDICATOR_SIGNAL, - INDICATOR_COUNT, - LAST - } - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate string[] indicator_list_properties_slot_t (Indicate.Indicator indicator); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_property_bool_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, bool propertydata, void* data); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, string propertydata, void* data); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_property_int_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, int propertydata, void* data); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_property_time_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.TimeVal propertydata, void* data); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_property_value_cb (Indicate.Listener listener, Indicate.ListenerServer server, Indicate.ListenerIndicator indicator, owned string property, GLib.Value propertydata, void* data); - [CCode (cname ="indicate_listener_get_server_property_cb", cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_server_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, owned string value, void* data); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate void listener_get_server_uint_property_cb (Indicate.Listener listener, Indicate.ListenerServer server, uint value, void* data); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate bool server_get_indicator_list_slot_t (Indicate.Server server, out unowned Indicate.Indicator[] indicators); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate bool server_get_indicator_properties_slot_t (Indicate.Server server, uint id, out string[] properties); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h", has_target = false)] - public delegate bool server_get_indicator_property_group_slot_t (Indicate.Server server, uint id, string[] properties, out string[] value); - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const int INDICATOR_H_INCLUDED__; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const int INDICATOR_MESSAGES_H_INCLUDED__; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_MESSAGES_PROP_ATTENTION; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_MESSAGES_PROP_COUNT; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_MESSAGES_PROP_ICON; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_MESSAGES_PROP_NAME; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_MESSAGES_PROP_TIME; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_MESSAGES_SERVER_TYPE; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_SIGNAL_DISPLAY; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_SIGNAL_DISPLAYED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_SIGNAL_HIDE; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_SIGNAL_MODIFIED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_SIGNAL_SHOW; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_VALUE_FALSE; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string INDICATOR_VALUE_TRUE; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const int INTERESTS_H_INCLUDED__; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const int LISTENER_H_INCLUDED__; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string LISTENER_SIGNAL_INDICATOR_ADDED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string LISTENER_SIGNAL_INDICATOR_MODIFIED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string LISTENER_SIGNAL_INDICATOR_REMOVED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string LISTENER_SIGNAL_SERVER_ADDED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string LISTENER_SIGNAL_SERVER_COUNT_CHANGED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string LISTENER_SIGNAL_SERVER_REMOVED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const int SERVER_H_INCLUDED__; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const int SERVER_INDICATOR_NULL; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_INDICATOR_ADDED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_INDICATOR_MODIFIED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_INDICATOR_REMOVED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_INTEREST_ADDED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_INTEREST_REMOVED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_MAX_INDICATORS_CHANGED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_SERVER_COUNT_CHANGED; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_SERVER_DISPLAY; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_SERVER_HIDE; - [CCode (cheader_filename = "libindicate/./indicator-messages.h,libindicate/./indicator.h,libindicate/./interests.h,libindicate/./listener.h,libindicate/./server.h")] - public const string SERVER_SIGNAL_SERVER_SHOW; -} diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 6938420..2946d25 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -19,31 +19,38 @@ with this program. If not, see . [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuMetadata{ - public const string MENUITEM_TYPE; - public const string MENUITEM_ARTIST; - public const string MENUITEM_TITLE; - public const string MENUITEM_ALBUM; - public const string MENUITEM_ARTURL; + public const string MENUITEM_TYPE; + public const string MENUITEM_ARTIST; + public const string MENUITEM_TITLE; + public const string MENUITEM_ALBUM; + public const string MENUITEM_ARTURL; } [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuTransport{ - public const string MENUITEM_TYPE; - public const string MENUITEM_PLAY_STATE; + public const string MENUITEM_TYPE; + public const string MENUITEM_PLAY_STATE; } [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuTitle{ - public const string MENUITEM_TYPE; - public const string MENUITEM_NAME; - public const string MENUITEM_ICON; - public const string MENUITEM_RUNNING; + public const string MENUITEM_TYPE; + public const string MENUITEM_NAME; + public const string MENUITEM_ICON; + public const string MENUITEM_RUNNING; } [CCode (cheader_filename = "common-defs.h")] namespace DbusmenuScrub{ - public const string MENUITEM_TYPE; - public const string MENUITEM_POSITION; - public const string MENUITEM_DURATION; - public const string MENUITEM_PLAY_STATE; + public const string MENUITEM_TYPE; + public const string MENUITEM_POSITION; + public const string MENUITEM_DURATION; + public const string MENUITEM_PLAY_STATE; +} + +[CCode (cheader_filename = "common-defs.h")] +namespace DbusmenuPlaylists{ + public const string MENUITEM_TYPE; + public const string MENUITEM_TITLE; + public const string MENUITEM_PLAYLISTS; } \ No newline at end of file -- cgit v1.2.3