diff options
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | debian/changelog | 13 | ||||
-rw-r--r-- | debian/control | 8 | ||||
-rw-r--r-- | debian/patches/lp_750823.patch | 38 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/Makefile.in | 31 | ||||
-rw-r--r-- | src/common-defs.h | 19 | ||||
-rw-r--r-- | src/indicator-sound.c | 41 | ||||
-rw-r--r-- | src/metadata-menu-item.c | 231 | ||||
-rw-r--r-- | src/metadata-menu-item.vala | 73 | ||||
-rw-r--r-- | src/metadata-widget.c | 321 | ||||
-rw-r--r-- | src/metadata-widget.h | 4 | ||||
-rw-r--r-- | src/mpris2-controller.c | 198 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 22 | ||||
-rw-r--r-- | src/music-player-bridge.c | 2 | ||||
-rw-r--r-- | src/music-player-bridge.h | 38 | ||||
-rw-r--r-- | src/player-controller.c | 194 | ||||
-rw-r--r-- | src/player-controller.vala | 43 | ||||
-rw-r--r-- | src/player-item.c | 5 | ||||
-rw-r--r-- | src/player-item.vala | 6 | ||||
-rw-r--r-- | src/playlists-menu-item.c | 2 | ||||
-rw-r--r-- | src/playlists-menu-item.vala | 1 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 2 | ||||
-rw-r--r-- | src/title-menu-item.c | 262 | ||||
-rw-r--r-- | src/title-menu-item.vala | 68 | ||||
-rw-r--r-- | src/title-widget.c | 248 | ||||
-rw-r--r-- | src/title-widget.h | 52 | ||||
-rw-r--r-- | vapi/common-defs.vapi | 9 |
29 files changed, 822 insertions, 1136 deletions
@@ -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.7.0. +# Generated by GNU Autoconf 2.67 for indicator-sound 0.7.1. # # Report bugs to <conor.curran@canonical.com>. # @@ -761,8 +761,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='indicator-sound' PACKAGE_TARNAME='indicator-sound' -PACKAGE_VERSION='0.7.0' -PACKAGE_STRING='indicator-sound 0.7.0' +PACKAGE_VERSION='0.7.1' +PACKAGE_STRING='indicator-sound 0.7.1' PACKAGE_BUGREPORT='conor.curran@canonical.com' PACKAGE_URL='' @@ -1564,7 +1564,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.7.0 to adapt to many kinds of systems. +\`configure' configures indicator-sound 0.7.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1634,7 +1634,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of indicator-sound 0.7.0:";; + short | recursive ) echo "Configuration of indicator-sound 0.7.1:";; esac cat <<\_ACEOF @@ -1767,7 +1767,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -indicator-sound configure 0.7.0 +indicator-sound configure 0.7.1 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2136,7 +2136,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.7.0, which was +It was created by indicator-sound $as_me 0.7.1, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2956,7 +2956,7 @@ fi # Define the identity of the package. PACKAGE=indicator-sound - VERSION=0.7.0 + VERSION=0.7.1 cat >>confdefs.h <<_ACEOF @@ -14349,7 +14349,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.7.0, which was +This file was extended by indicator-sound $as_me 0.7.1, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14415,7 +14415,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.7.0 +indicator-sound config.status 0.7.1 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 22f04c5..ab02d4e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.7.0, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.7.1, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.7.0) +AM_INIT_AUTOMAKE(indicator-sound, 0.7.1) AM_MAINTAINER_MODE diff --git a/debian/changelog b/debian/changelog index f8c9a98..9694512 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +indicator-sound (0.7.1-0ubuntu1) oneiric; urgency=low + + * New upstream release. + - "Sound Preferences..." should be "Sound Settings" (LP: #785571) + - Not obvious what track info menu item does (LP: #699899) + * debian/patches/lp_750823.patch + - Dropped patch, merged upstream + * debian/control + - Updated standards version to 3.9.2 + - Cleaned up description to quiet lintian + + -- Ken VanDine <ken.vandine@canonical.com> Thu, 16 Jun 2011 21:21:27 -0400 + indicator-sound (0.7.0-0ubuntu1) oneiric; urgency=low * New upstream release. diff --git a/debian/control b/debian/control index 02a8467..7d45ccb 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,7 @@ Build-Depends: debhelper (>= 7), libnotify-dev, valac-0.12, dh-autoreconf -Standards-Version: 3.9.1 +Standards-Version: 3.9.2 Homepage: https://launchpad.net/indicator-sound Package: indicator-sound @@ -28,8 +28,6 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, pulseaudio -Description: A system sound indicator. - A system sound indicator which provides easy control of the PulseAudio sound +Description: System sound indicator. + System sound indicator which provides easy control of the PulseAudio sound daemon. - - diff --git a/debian/patches/lp_750823.patch b/debian/patches/lp_750823.patch deleted file mode 100644 index 837c183..0000000 --- a/debian/patches/lp_750823.patch +++ /dev/null @@ -1,38 +0,0 @@ -=== modified file 'src/mpris2-controller.vala' ---- src/mpris2-controller.vala 2011-03-29 10:43:34 +0000 -+++ src/mpris2-controller.vala 2011-04-18 19:02:26 +0000 -@@ -83,13 +83,7 @@ - } - Variant? meta_v = changed_properties.lookup("Metadata"); - if(meta_v != null){ -- GLib.HashTable<string, Variant?> changed_updates = clean_metadata(); -- PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA]; -- metadata.reset ( MetadataMenuitem.attributes_format()); -- metadata.update ( changed_updates, -- MetadataMenuitem.attributes_format()); -- metadata.property_set_bool ( MENUITEM_PROP_VISIBLE, -- metadata.populated(MetadataMenuitem.attributes_format())); -+ Timeout.add (300, this.ensure_correct_metadata); - } - Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); - if ( playlist_v != null && this.owner.use_playlists == true ){ -@@ -113,7 +107,17 @@ - title.alter_label (this.mpris2_root.Identity); - } - } -- -+ -+ private bool ensure_correct_metadata(){ -+ GLib.HashTable<string, Variant?> changed_updates = clean_metadata(); -+ PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA]; -+ metadata.reset ( MetadataMenuitem.attributes_format()); -+ metadata.update ( changed_updates, -+ MetadataMenuitem.attributes_format()); -+ metadata.property_set_bool ( MENUITEM_PROP_VISIBLE, -+ metadata.populated(MetadataMenuitem.attributes_format())); -+ return false; -+ } - private bool ensure_correct_playback_status(){ - //debug("TEST playback status = %s", this.player.PlaybackStatus); - Transport.State p = (Transport.State)this.determine_play_state(this.player.PlaybackStatus); - diff --git a/src/Makefile.am b/src/Makefile.am index bafd6be..c546f0f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,8 +18,6 @@ libsoundmenu_la_SOURCES = \ transport-widget.h \ metadata-widget.c \ metadata-widget.h \ - title-widget.c \ - title-widget.h \ volume-widget.c \ volume-widget.h \ voip-input-widget.c \ @@ -49,7 +47,6 @@ music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ metadata-menu-item.vala \ - title-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ mpris2-watcher.vala \ diff --git a/src/Makefile.in b/src/Makefile.in index 2011cba..d50e2b5 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -77,7 +77,6 @@ am_libsoundmenu_la_OBJECTS = libsoundmenu_la-indicator-sound.lo \ libsoundmenu_la-sound-state-manager.lo \ libsoundmenu_la-transport-widget.lo \ libsoundmenu_la-metadata-widget.lo \ - libsoundmenu_la-title-widget.lo \ libsoundmenu_la-volume-widget.lo \ libsoundmenu_la-voip-input-widget.lo \ libsoundmenu_la-gen-sound-service.xml.lo @@ -93,7 +92,6 @@ PROGRAMS = $(libexec_PROGRAMS) am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \ indicator_sound_service-transport-menu-item.$(OBJEXT) \ indicator_sound_service-metadata-menu-item.$(OBJEXT) \ - indicator_sound_service-title-menu-item.$(OBJEXT) \ indicator_sound_service-player-controller.$(OBJEXT) \ indicator_sound_service-mpris2-interfaces.$(OBJEXT) \ indicator_sound_service-mpris2-watcher.$(OBJEXT) \ @@ -331,8 +329,6 @@ libsoundmenu_la_SOURCES = \ transport-widget.h \ metadata-widget.c \ metadata-widget.h \ - title-widget.c \ - title-widget.h \ volume-widget.c \ volume-widget.h \ voip-input-widget.c \ @@ -356,7 +352,6 @@ music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ metadata-menu-item.vala \ - title-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ mpris2-watcher.vala \ @@ -581,7 +576,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service-dbus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-sound-state.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-title-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-transport-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-voip-input-menu-item.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-gen-sound-service.xml.Plo@am__quote@ @@ -589,7 +583,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-metadata-widget.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-sound-state-manager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-sound-state.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-title-widget.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-transport-widget.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-voip-input-widget.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsoundmenu_la-volume-widget.Plo@am__quote@ @@ -658,14 +651,6 @@ libsoundmenu_la-metadata-widget.lo: metadata-widget.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-metadata-widget.lo `test -f 'metadata-widget.c' || echo '$(srcdir)/'`metadata-widget.c -libsoundmenu_la-title-widget.lo: title-widget.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-title-widget.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-title-widget.Tpo -c -o libsoundmenu_la-title-widget.lo `test -f 'title-widget.c' || echo '$(srcdir)/'`title-widget.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-title-widget.Tpo $(DEPDIR)/libsoundmenu_la-title-widget.Plo -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='title-widget.c' object='libsoundmenu_la-title-widget.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -c -o libsoundmenu_la-title-widget.lo `test -f 'title-widget.c' || echo '$(srcdir)/'`title-widget.c - libsoundmenu_la-volume-widget.lo: volume-widget.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsoundmenu_la_CFLAGS) $(CFLAGS) -MT libsoundmenu_la-volume-widget.lo -MD -MP -MF $(DEPDIR)/libsoundmenu_la-volume-widget.Tpo -c -o libsoundmenu_la-volume-widget.lo `test -f 'volume-widget.c' || echo '$(srcdir)/'`volume-widget.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libsoundmenu_la-volume-widget.Tpo $(DEPDIR)/libsoundmenu_la-volume-widget.Plo @@ -882,22 +867,6 @@ indicator_sound_service-metadata-menu-item.obj: metadata-menu-item.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -c -o indicator_sound_service-metadata-menu-item.obj `if test -f 'metadata-menu-item.c'; then $(CYGPATH_W) 'metadata-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/metadata-menu-item.c'; fi` -indicator_sound_service-title-menu-item.o: title-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-title-menu-item.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-title-menu-item.Tpo -c -o indicator_sound_service-title-menu-item.o `test -f 'title-menu-item.c' || echo '$(srcdir)/'`title-menu-item.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-title-menu-item.Tpo $(DEPDIR)/indicator_sound_service-title-menu-item.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='title-menu-item.c' object='indicator_sound_service-title-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-title-menu-item.o `test -f 'title-menu-item.c' || echo '$(srcdir)/'`title-menu-item.c - -indicator_sound_service-title-menu-item.obj: title-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-title-menu-item.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-title-menu-item.Tpo -c -o indicator_sound_service-title-menu-item.obj `if test -f 'title-menu-item.c'; then $(CYGPATH_W) 'title-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/title-menu-item.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-title-menu-item.Tpo $(DEPDIR)/indicator_sound_service-title-menu-item.Po -@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='title-menu-item.c' object='indicator_sound_service-title-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-title-menu-item.obj `if test -f 'title-menu-item.c'; then $(CYGPATH_W) 'title-menu-item.c'; else $(CYGPATH_W) '$(srcdir)/title-menu-item.c'; fi` - indicator_sound_service-player-controller.o: player-controller.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-player-controller.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-player-controller.Tpo -c -o indicator_sound_service-player-controller.o `test -f 'player-controller.c' || echo '$(srcdir)/'`player-controller.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-player-controller.Tpo $(DEPDIR)/indicator_sound_service-player-controller.Po diff --git a/src/common-defs.h b/src/common-defs.h index b118d4b..b1b001e 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -67,16 +67,15 @@ typedef enum { #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type" #define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state" -#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" -#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist" -#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title" -#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-xesam:album" -#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-mpris:artUrl" - -#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type" -#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name" -#define DBUSMENU_TITLE_MENUITEM_ICON "x-canonical-sound-menu-player-title-icon" -#define DBUSMENU_TITLE_MENUITEM_RUNNING "x-canonical-sound-menu-player-title-running" +#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" +#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist" +#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title" +#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-xesam:album" +#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-mpris:artUrl" +#define DBUSMENU_METADATA_MENUITEM_PLAYER_NAME "x-canonical-sound-menu-player-metadata-player-name" +#define DBUSMENU_METADATA_MENUITEM_PLAYER_ICON "x-canonical-sound-menu-player-metadata-player-icon" +#define DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING "x-canonical-sound-menu-player-metadata-player-running" +#define DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS "x-canonical-sound-menu-player-metadata-hide-track-details" #define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type" #define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-mpris:length" diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 5002463..f2ec0a2 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -31,7 +31,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "indicator-sound.h" #include "transport-widget.h" #include "metadata-widget.h" -#include "title-widget.h" #include "volume-widget.h" #include "voip-input-widget.h" #include "dbus-shared-names.h" @@ -94,10 +93,6 @@ static gboolean new_metadata_widget (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -static gboolean new_title_widget (DbusmenuMenuitem * newitem, - DbusmenuMenuitem * parent, - DbusmenuClient * client, - gpointer user_data); // DBUS communication static GDBusNodeInfo *node_info = NULL; @@ -208,9 +203,6 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler (DBUSMENU_CLIENT(client), DBUSMENU_METADATA_MENUITEM_TYPE, new_metadata_widget); - dbusmenu_client_add_type_handler (DBUSMENU_CLIENT(client), - DBUSMENU_TITLE_MENUITEM_TYPE, - new_title_widget); // Note: Not ideal but all key handling needs to be managed here and then // delegated to the appropriate widget. g_signal_connect (menu, "key-press-event", G_CALLBACK(key_press_cb), io); @@ -360,36 +352,19 @@ new_metadata_widget (DbusmenuMenuitem * newitem, g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + metadata = metadata_widget_new (newitem); + + g_debug ("%s (\"%s\")", __func__, + dbusmenu_menuitem_property_get(newitem, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME)); + GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata); gtk_widget_show_all(metadata); dbusmenu_gtkclient_newitem_base (DBUSMENU_GTKCLIENT(client), - newitem, menu_metadata_widget, parent); - return TRUE; -} - -static gboolean -new_title_widget(DbusmenuMenuitem * newitem, - DbusmenuMenuitem * parent, - DbusmenuClient * client, - gpointer user_data) -{ - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); - g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - - g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, DBUSMENU_TITLE_MENUITEM_NAME)); - - GtkWidget* title = NULL; - - title = title_widget_new (newitem); - GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title); - - gtk_widget_show_all(title); - - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), - newitem, - menu_title_widget, parent); + newitem, + menu_metadata_widget, + parent); return TRUE; } diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c index 17a4c5d..4344945 100644 --- a/src/metadata-menu-item.c +++ b/src/metadata-menu-item.c @@ -32,10 +32,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdlib.h> #include <string.h> #include <common-defs.h> -#include <gee.h> #include <gio/gio.h> #include <gdk-pixbuf/gdk-pixdata.h> #include <glib/gstdio.h> +#include <gee.h> #define TYPE_PLAYER_ITEM (player_item_get_type ()) @@ -70,8 +70,31 @@ typedef struct _MetadataMenuitemPrivate MetadataMenuitemPrivate; typedef struct _FetchFile FetchFile; typedef struct _FetchFileClass FetchFileClass; #define _g_free0(var) (var = (g_free (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; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_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; + +#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ()) struct _PlayerItem { DbusmenuMenuitem parent_instance; @@ -95,6 +118,27 @@ struct _MetadataMenuitemPrivate { gchar* previous_temp_album_art_path; }; +struct _PlayerController { + GObject parent_instance; + PlayerControllerPrivate * priv; + gint current_state; + GeeArrayList* custom_items; + Mpris2Controller* mpris_bridge; + gboolean* use_playlists; +}; + +struct _PlayerControllerClass { + GObjectClass parent_class; +}; + +typedef enum { + PLAYER_CONTROLLER_STATE_OFFLINE, + PLAYER_CONTROLLER_STATE_INSTANTIATING, + PLAYER_CONTROLLER_STATE_READY, + PLAYER_CONTROLLER_STATE_CONNECTED, + PLAYER_CONTROLLER_STATE_DISCONNECTED +} PlayerControllerstate; + static gpointer metadata_menuitem_parent_class = NULL; extern gchar* metadata_menuitem_album_art_cache_dir; @@ -110,14 +154,14 @@ enum { }; GType fetch_file_get_type (void) G_GNUC_CONST; #define METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX "indicators/sound/album-art-cache" -MetadataMenuitem* metadata_menuitem_new (void); -MetadataMenuitem* metadata_menuitem_construct (GType object_type); -void player_item_reset (PlayerItem* self, GeeHashSet* attrs); -GeeHashSet* metadata_menuitem_attributes_format (void); +GType player_controller_get_type (void) G_GNUC_CONST; +MetadataMenuitem* metadata_menuitem_new (PlayerController* parent); +MetadataMenuitem* metadata_menuitem_construct (GType object_type, PlayerController* parent); static void metadata_menuitem_clean_album_art_temp_dir (void); static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir); static gchar* metadata_menuitem_create_album_art_temp_dir (void); void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, const gchar* prop); +#define PLAYER_ITEM_EMPTY (-1) FetchFile* fetch_file_new (const gchar* uri, const gchar* prop); FetchFile* fetch_file_construct (GType object_type, const gchar* uri, const gchar* prop); static void _lambda0_ (MetadataMenuitem* self); @@ -127,25 +171,34 @@ static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByt static void _metadata_menuitem_on_fetcher_completed_fetch_file_completed (FetchFile* _sender, GByteArray* data, const gchar* property, gpointer self); void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_); void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_); +static void metadata_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp); +PlayerController* player_item_get_owner (PlayerItem* self); +GType mpris2_controller_get_type (void) G_GNUC_CONST; +GType player_controller_state_get_type (void) G_GNUC_CONST; +void player_controller_instantiate (PlayerController* self); +void mpris2_controller_expose (Mpris2Controller* self); +void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title); +void metadata_menuitem_toggle_active_triangle (MetadataMenuitem* self, gboolean update); +void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse); +GeeHashSet* metadata_menuitem_attributes_format (void); +GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void); static GObject * metadata_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +GAppInfo* player_controller_get_app_info (PlayerController* self); +const gchar* player_controller_get_icon_name (PlayerController* self); +void player_item_reset (PlayerItem* self, GeeHashSet* attrs); static void metadata_menuitem_finalize (GObject* obj); -MetadataMenuitem* metadata_menuitem_construct (GType object_type) { +MetadataMenuitem* metadata_menuitem_construct (GType object_type, PlayerController* parent) { MetadataMenuitem * self = NULL; - GeeHashSet* _tmp0_ = NULL; - GeeHashSet* _tmp1_; - self = (MetadataMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_METADATA_MENUITEM_TYPE, NULL); - _tmp0_ = metadata_menuitem_attributes_format (); - _tmp1_ = _tmp0_; - player_item_reset ((PlayerItem*) self, _tmp1_); - _g_object_unref0 (_tmp1_); + g_return_val_if_fail (parent != NULL, NULL); + self = (MetadataMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_METADATA_MENUITEM_TYPE, "owner", parent, NULL); return self; } -MetadataMenuitem* metadata_menuitem_new (void) { - return metadata_menuitem_construct (TYPE_METADATA_MENUITEM); +MetadataMenuitem* metadata_menuitem_new (PlayerController* parent) { + return metadata_menuitem_construct (TYPE_METADATA_MENUITEM, parent); } @@ -163,7 +216,7 @@ static void metadata_menuitem_clean_album_art_temp_dir (void) { album_art_dir = _tmp2_; _tmp3_ = metadata_menuitem_delete_album_art_contents (album_art_dir); if (_tmp3_ == FALSE) { - g_warning ("metadata-menu-item.vala:52: could not remove the temp album art files " \ + g_warning ("metadata-menu-item.vala:58: could not remove the temp album art files " \ "%s", path); } _g_object_unref0 (album_art_dir); @@ -182,7 +235,7 @@ static gchar* metadata_menuitem_create_album_art_temp_dir (void) { path = _tmp1_; _tmp2_ = g_mkdir (path, 0700); if (_tmp2_ == (-1)) { - g_warning ("metadata-menu-item.vala:60: could not create a temp dir for remote alb" \ + g_warning ("metadata-menu-item.vala:66: could not create a temp dir for remote alb" \ "um art, it must have been created already"); } result = path; @@ -225,7 +278,7 @@ static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir) { goto __catch2_g_error; } _tmp2_ = g_file_info_get_name (file); - g_debug ("metadata-menu-item.vala:76: file name = %s", _tmp2_); + g_debug ("metadata-menu-item.vala:82: file name = %s", _tmp2_); if (file == NULL) { _g_object_unref0 (file); break; @@ -255,7 +308,7 @@ static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir) { _tmp8_ = string_to_string (error_->message); _tmp9_ = g_strconcat ("Unable to delete file '", _tmp7_, ": ", _tmp8_, NULL); _tmp10_ = _tmp9_; - g_warning ("metadata-menu-item.vala:86: %s", _tmp10_); + g_warning ("metadata-menu-item.vala:92: %s", _tmp10_); _g_free0 (_tmp10_); _g_free0 (_tmp6_); _result_ = FALSE; @@ -337,7 +390,7 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons GFile* _tmp0_ = NULL; GFile* art_file; gboolean _tmp1_; - FetchFile* _tmp7_ = NULL; + FetchFile* _tmp10_ = NULL; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (uri != NULL); @@ -346,18 +399,27 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons art_file = _tmp0_; _tmp1_ = g_file_is_native (art_file); if (_tmp1_ == TRUE) { + gboolean _tmp2_; gchar* path = NULL; - gchar* _tmp2_ = NULL; - gchar* _tmp3_; - gchar* _tmp4_ = NULL; - gchar* _tmp5_; + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + gchar* _tmp5_ = NULL; gchar* _tmp6_; - _tmp2_ = string_strip (uri); - _tmp3_ = _tmp2_; - _tmp4_ = g_filename_from_uri (_tmp3_, NULL, &_inner_error_); - _tmp5_ = _tmp4_; - _g_free0 (_tmp3_); + gchar* _tmp7_; + gchar* _tmp8_ = NULL; + gchar* _tmp9_; + _tmp2_ = g_file_query_exists (art_file, NULL); + if (_tmp2_ == FALSE) { + dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, prop, PLAYER_ITEM_EMPTY); + _g_object_unref0 (art_file); + return; + } + _tmp3_ = string_strip (uri); + _tmp4_ = _tmp3_; + _tmp5_ = g_filename_from_uri (_tmp4_, NULL, &_inner_error_); _tmp6_ = _tmp5_; + _g_free0 (_tmp4_); + _tmp7_ = _tmp6_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_CONVERT_ERROR) { goto __catch4_g_convert_error; @@ -369,7 +431,11 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons return; } _g_free0 (path); - path = _tmp6_; + path = _tmp7_; + _tmp8_ = string_strip (uri); + _tmp9_ = _tmp8_; + g_debug ("metadata-menu-item.vala:116: Populating the artwork field with %s", _tmp9_); + _g_free0 (_tmp9_); dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, prop, path); goto __finally4; __catch4_g_convert_error: @@ -377,7 +443,7 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons GError * e; e = _inner_error_; _inner_error_ = NULL; - g_warning ("metadata-menu-item.vala:108: Problem converting URI %s to file path", uri); + g_warning ("metadata-menu-item.vala:120: Problem converting URI %s to file path", uri); _g_error_free0 (e); } __finally4: @@ -392,14 +458,14 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons _g_object_unref0 (art_file); return; } - g_debug ("metadata-menu-item.vala:114: fetch_art -remotely %s", metadata_menuitem_album_art_cache_dir); + g_debug ("metadata-menu-item.vala:126: fetch_art -remotely %s", metadata_menuitem_album_art_cache_dir); if (metadata_menuitem_album_art_cache_dir == NULL) { _g_object_unref0 (art_file); return; } - _tmp7_ = fetch_file_new (uri, prop); + _tmp10_ = fetch_file_new (uri, prop); _g_object_unref0 (metadata_menuitem_fetcher); - metadata_menuitem_fetcher = _tmp7_; + metadata_menuitem_fetcher = _tmp10_; g_signal_connect_object (metadata_menuitem_fetcher, "failed", (GCallback) __lambda0__fetch_file_failed, self, 0); g_signal_connect_object (metadata_menuitem_fetcher, "completed", (GCallback) _metadata_menuitem_on_fetcher_completed_fetch_file_completed, self, 0); fetch_file_fetch_data (metadata_menuitem_fetcher, NULL, NULL); @@ -409,7 +475,7 @@ void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, cons static void metadata_menuitem_on_fetcher_failed (MetadataMenuitem* self) { g_return_if_fail (self != NULL); - g_warning ("metadata-menu-item.vala:129: on_fetcher_failed -> could not fetch artw" \ + g_warning ("metadata-menu-item.vala:141: on_fetcher_failed -> could not fetch artw" \ "ork"); } @@ -482,7 +548,7 @@ static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByt GError * e; e = _inner_error_; _inner_error_ = NULL; - g_warning ("metadata-menu-item.vala:151: Problem creating file from bytearray fetc" \ + g_warning ("metadata-menu-item.vala:163: Problem creating file from bytearray fetc" \ "hed from the interweb - error: %s", e->message); _g_error_free0 (e); } @@ -495,6 +561,52 @@ static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByt } +static void metadata_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp) { + MetadataMenuitem * self; + PlayerController* _tmp0_ = NULL; + self = (MetadataMenuitem*) base; + g_return_if_fail (name != NULL); + g_return_if_fail (input_value != NULL); + _tmp0_ = player_item_get_owner ((PlayerItem*) self); + if (_tmp0_->current_state == PLAYER_CONTROLLER_STATE_OFFLINE) { + PlayerController* _tmp1_ = NULL; + _tmp1_ = player_item_get_owner ((PlayerItem*) self); + player_controller_instantiate (_tmp1_); + } else { + PlayerController* _tmp2_ = NULL; + _tmp2_ = player_item_get_owner ((PlayerItem*) self); + if (_tmp2_->current_state == PLAYER_CONTROLLER_STATE_CONNECTED) { + PlayerController* _tmp3_ = NULL; + _tmp3_ = player_item_get_owner ((PlayerItem*) self); + mpris2_controller_expose (_tmp3_->mpris_bridge); + } + } +} + + +void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title) { + g_return_if_fail (self != NULL); + g_return_if_fail (new_title != NULL); + if (new_title == NULL) { + return; + } + dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, new_title); +} + + +void metadata_menuitem_toggle_active_triangle (MetadataMenuitem* self, gboolean update) { + g_return_if_fail (self != NULL); + g_debug ("metadata-menu-item.vala:189: toggle active triangle"); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING, update); +} + + +void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse) { + g_return_if_fail (self != NULL); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS, collapse); +} + + GeeHashSet* metadata_menuitem_attributes_format (void) { GeeHashSet* result = NULL; GeeHashSet* _tmp0_ = NULL; @@ -505,6 +617,24 @@ GeeHashSet* metadata_menuitem_attributes_format (void) { gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTIST); gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ALBUM); gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTURL); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING); + result = attrs; + return result; +} + + +GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (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_METADATA_MENUITEM_TITLE); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTIST); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ALBUM); + gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_METADATA_MENUITEM_ARTURL); result = attrs; return result; } @@ -515,6 +645,16 @@ static GObject * metadata_menuitem_constructor (GType type, guint n_construct_pr GObjectClass * parent_class; MetadataMenuitem * self; gchar* _tmp0_ = NULL; + PlayerController* _tmp1_ = NULL; + GAppInfo* _tmp2_ = NULL; + const gchar* _tmp3_ = NULL; + PlayerController* _tmp4_ = NULL; + GAppInfo* _tmp5_ = NULL; + const gchar* _tmp6_ = NULL; + PlayerController* _tmp7_ = NULL; + const gchar* _tmp8_ = NULL; + GeeHashSet* _tmp9_ = NULL; + GeeHashSet* _tmp10_; parent_class = G_OBJECT_CLASS (metadata_menuitem_parent_class); obj = parent_class->constructor (type, n_construct_properties, construct_properties); self = METADATA_MENUITEM (obj); @@ -524,6 +664,24 @@ static GObject * metadata_menuitem_constructor (GType type, guint n_construct_pr _tmp0_ = metadata_menuitem_create_album_art_temp_dir (); _g_free0 (metadata_menuitem_album_art_cache_dir); metadata_menuitem_album_art_cache_dir = _tmp0_; + _tmp1_ = player_item_get_owner ((PlayerItem*) self); + _tmp2_ = player_controller_get_app_info (_tmp1_); + _tmp3_ = g_app_info_get_name (_tmp2_); + g_debug ("metadata-menu-item.vala:42: JUST ABOUT TO ATTEMPT PLAYER NAME SETTING " \ +"%s", _tmp3_); + _tmp4_ = player_item_get_owner ((PlayerItem*) self); + _tmp5_ = player_controller_get_app_info (_tmp4_); + _tmp6_ = g_app_info_get_name (_tmp5_); + dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, _tmp6_); + _tmp7_ = player_item_get_owner ((PlayerItem*) self); + _tmp8_ = player_controller_get_icon_name (_tmp7_); + dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_ICON, _tmp8_); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING, FALSE); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS, TRUE); + _tmp9_ = metadata_menuitem_relevant_attributes_for_ui (); + _tmp10_ = _tmp9_; + player_item_reset ((PlayerItem*) self, _tmp10_); + _g_object_unref0 (_tmp10_); return obj; } @@ -531,6 +689,7 @@ static GObject * metadata_menuitem_constructor (GType type, guint n_construct_pr static void metadata_menuitem_class_init (MetadataMenuitemClass * klass) { metadata_menuitem_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (MetadataMenuitemPrivate)); + DBUSMENU_MENUITEM_CLASS (klass)->handle_event = metadata_menuitem_real_handle_event; G_OBJECT_CLASS (klass)->constructor = metadata_menuitem_constructor; G_OBJECT_CLASS (klass)->finalize = metadata_menuitem_finalize; } diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 741bb9f..995d248 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -18,6 +18,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. */ using Gee; +using Dbusmenu; using DbusmenuMetadata; using Gdk; @@ -29,16 +30,21 @@ public class MetadataMenuitem : PlayerItem private static FetchFile fetcher; private string previous_temp_album_art_path; - public MetadataMenuitem() + public MetadataMenuitem (PlayerController parent) { - Object(item_type: MENUITEM_TYPE); - reset(attributes_format()); + Object(item_type: MENUITEM_TYPE, owner: parent); } construct{ MetadataMenuitem.clean_album_art_temp_dir(); - this.previous_temp_album_art_path = null; + this.previous_temp_album_art_path = null; this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir(); + debug ("JUST ABOUT TO ATTEMPT PLAYER NAME SETTING %s", this.owner.app_info.get_name()); + this.property_set (MENUITEM_PLAYER_NAME, this.owner.app_info.get_name()); + this.property_set (MENUITEM_PLAYER_ICON, this.owner.icon_name); + this.property_set_bool (MENUITEM_PLAYER_RUNNING, false); + this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, true); + reset (relevant_attributes_for_ui()); } private static void clean_album_art_temp_dir() @@ -98,10 +104,16 @@ public class MetadataMenuitem : PlayerItem public void fetch_art(string uri, string prop) { File art_file = File.new_for_uri(uri); - if(art_file.is_native() == true){ + if (art_file.is_native() == true){ + if (art_file.query_exists() == false){ + // Can't load the image, set prop to empty and return. + this.property_set_int ( prop, EMPTY ); + return; + } string path; try{ - path = Filename.from_uri ( uri.strip() ); + path = Filename.from_uri ( uri.strip() ); + debug ("Populating the artwork field with %s", uri.strip()); this.property_set ( prop, path ); } catch(ConvertError e){ @@ -135,7 +147,7 @@ public class MetadataMenuitem : PlayerItem PixbufLoader loader = new PixbufLoader (); loader.write (update.data); loader.close (); - Pixbuf icon = loader.get_pixbuf (); + Pixbuf icon = loader.get_pixbuf (); string path = this.album_art_cache_dir.concat("/downloaded-coverart-XXXXXX"); int r = FileUtils.mkstemp(path); if(r != -1){ @@ -144,7 +156,7 @@ public class MetadataMenuitem : PlayerItem if(this.previous_temp_album_art_path != null){ FileUtils.remove(this.previous_temp_album_art_path); } - this.previous_temp_album_art_path = path; + this.previous_temp_album_art_path = path; } } catch(GLib.Error e){ @@ -152,7 +164,37 @@ public class MetadataMenuitem : PlayerItem e.message); } } + + public override void handle_event (string name, + Variant input_value, + uint timestamp) + { + if(this.owner.current_state == PlayerController.state.OFFLINE) + { + this.owner.instantiate(); + } + else if(this.owner.current_state == PlayerController.state.CONNECTED){ + this.owner.mpris_bridge.expose(); + } + } + public void alter_label (string new_title) + { + if (new_title == null) return; + this.property_set (MENUITEM_PLAYER_NAME, new_title); + } + + public void toggle_active_triangle (bool update) + { + debug ("toggle active triangle"); + this.property_set_bool (MENUITEM_PLAYER_RUNNING, update); + } + + public void should_collapse(bool collapse) + { + this.property_set_bool (MENUITEM_HIDE_TRACK_DETAILS, collapse); + } + public static HashSet<string> attributes_format() { HashSet<string> attrs = new HashSet<string>(); @@ -160,6 +202,19 @@ public class MetadataMenuitem : PlayerItem attrs.add(MENUITEM_ARTIST); attrs.add(MENUITEM_ALBUM); attrs.add(MENUITEM_ARTURL); + attrs.add(MENUITEM_PLAYER_NAME); + attrs.add(MENUITEM_PLAYER_ICON); + attrs.add(MENUITEM_PLAYER_RUNNING); + return attrs; + } + + public static HashSet<string> relevant_attributes_for_ui() + { + HashSet<string> attrs = new HashSet<string>(); + attrs.add(MENUITEM_TITLE); + attrs.add(MENUITEM_ARTIST); + attrs.add(MENUITEM_ALBUM); + attrs.add(MENUITEM_ARTURL); return attrs; - } + } } diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 38ed529..f687d0c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -28,20 +28,24 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <gtk/gtk.h> #include <glib.h> #include "transport-widget.h" +#include <libindicator/indicator-image-helper.h> typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; struct _MetadataWidgetPrivate { gboolean theme_change_occured; - GtkWidget* hbox; + GtkWidget* meta_data_h_box; + GtkWidget* meta_data_v_box; GtkWidget* album_art; GString* image_path; GString* old_image_path; GtkWidget* artist_label; GtkWidget* piece_label; GtkWidget* container_label; - DbusmenuMenuitem* twin_item; + GtkWidget* player_label; + GdkPixbuf* icon_buf; + DbusmenuMenuitem* twin_item; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -51,12 +55,15 @@ static void metadata_widget_class_init (MetadataWidgetClass *klass); static void metadata_widget_init (MetadataWidget *self); static void metadata_widget_dispose (GObject *object); static void metadata_widget_finalize (GObject *object); -static gboolean metadata_image_expose (GtkWidget *image, GdkEventExpose *event, gpointer user_data); +static gboolean metadata_image_expose (GtkWidget *image, + GdkEventExpose *event, + gpointer user_data); static void metadata_widget_set_style (GtkWidget* button, GtkStyle* style); -static void metadata_widget_set_twin_item (MetadataWidget* self, DbusmenuMenuitem* twin_item); +static void metadata_widget_set_twin_item (MetadataWidget* self, + DbusmenuMenuitem* twin_item); // keyevent consumers -static gboolean metadata_widget_button_press_event (GtkWidget *menuitem, +static gboolean metadata_widget_button_release_event (GtkWidget *menuitem, GdkEventButton *event); // Dbusmenuitem properties update callback static void metadata_widget_property_update (DbusmenuMenuitem* item, @@ -71,16 +78,23 @@ static void metadata_widget_selection_received_event_callback( GtkWidget GtkSelectionData *data, guint time, gpointer user_data); -G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); +static gboolean metadata_widget_icon_triangle_draw_cb ( GtkWidget *image, + GdkEventExpose *event, + gpointer user_data ); + +static void metadata_widget_set_icon (MetadataWidget *self); +static void metadata_widget_handle_resizing (MetadataWidget* self); +G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM); + static void metadata_widget_class_init (MetadataWidgetClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - widget_class->button_press_event = metadata_widget_button_press_event; + widget_class->button_release_event = metadata_widget_button_release_event; g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate)); @@ -88,16 +102,20 @@ metadata_widget_class_init (MetadataWidgetClass *klass) gobject_class->finalize = metadata_widget_finalize; } + + static void metadata_widget_init (MetadataWidget *self) { - //g_debug("MetadataWidget::metadata_widget_init"); - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); GtkWidget *hbox; - + GtkWidget *outer_v_box; + priv->icon_buf = NULL; + + outer_v_box = gtk_vbox_new (FALSE, 0); hbox = gtk_hbox_new(FALSE, 0); - priv->hbox = hbox; + + priv->meta_data_h_box = hbox; // image priv->album_art = gtk_image_new(); @@ -107,8 +125,12 @@ metadata_widget_init (MetadataWidget *self) g_signal_connect(priv->album_art, "expose-event", G_CALLBACK(metadata_image_expose), GTK_WIDGET(self)); + + g_signal_connect_after (GTK_WIDGET(self), "expose-event", + G_CALLBACK(metadata_widget_icon_triangle_draw_cb), + GTK_WIDGET(self)); - gtk_box_pack_start (GTK_BOX (priv->hbox), + gtk_box_pack_start (GTK_BOX (priv->meta_data_h_box), priv->album_art, FALSE, FALSE, @@ -150,20 +172,36 @@ metadata_widget_init (MetadataWidget *self) gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->meta_data_h_box), vbox, FALSE, FALSE, 0); g_signal_connect(self, "style-set", G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self)); g_signal_connect (self, "selection-received", G_CALLBACK(metadata_widget_selection_received_event_callback), GTK_WIDGET(self)); - gtk_widget_set_size_request(GTK_WIDGET(self), 200, 75); - gtk_container_add (GTK_CONTAINER (self), hbox); + + // player label + GtkWidget* player_label; + player_label = gtk_label_new(""); + gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); + gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)0); + gtk_widget_set_size_request (player_label, 200, 25); + priv->player_label = player_label; + + gtk_box_pack_start (GTK_BOX(outer_v_box), priv->player_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(outer_v_box), priv->meta_data_h_box, FALSE, FALSE, 0); + + gtk_container_add (GTK_CONTAINER (self), outer_v_box); } static void metadata_widget_dispose (GObject *object) { + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); + + if (priv->icon_buf != NULL){ + gdk_pixbuf_unref(priv->icon_buf); + } G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); } @@ -183,37 +221,46 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user { g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); MetadataWidget* widget = METADATA_WIDGET(user_data); - MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); - draw_album_border(metadata, FALSE); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); + + if ( TRUE == dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(priv->twin_item), + DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS)) + { + return FALSE; + } + + draw_album_border(metadata, FALSE); + if(priv->image_path->len > 0){ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE || priv->theme_change_occured == TRUE){ - priv->theme_change_occured = FALSE; + priv->theme_change_occured = FALSE; GdkPixbuf* pixbuf; pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL); - //g_debug("metadata_load_new_image -> pixbuf from %s", - // priv->image_path->str); + if(GDK_IS_PIXBUF(pixbuf) == FALSE){ - //g_debug("problem loading the downloaded image just use the placeholder instead"); + gtk_image_clear ( GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); - return TRUE; + return FALSE; } + gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); - g_string_erase(priv->old_image_path, 0, -1); - g_string_overwrite(priv->old_image_path, 0, priv->image_path->str); + g_string_erase (priv->old_image_path, 0, -1); + g_string_overwrite (priv->old_image_path, 0, priv->image_path->str); g_object_unref(pixbuf); } return FALSE; } + gtk_image_clear (GTK_IMAGE(priv->album_art)); gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60); draw_album_art_placeholder(metadata); - return TRUE; + return FALSE; } static void @@ -308,7 +355,7 @@ draw_album_border(GtkWidget *metadata, gboolean selected) static void draw_album_art_placeholder(GtkWidget *metadata) -{ +{ cairo_t *cr; cr = gdk_cairo_create (metadata->window); GtkStyle *style; @@ -341,7 +388,6 @@ draw_album_art_placeholder(GtkWidget *metadata) _color_shade ( &fg_normal, 0.78, &light_bottom_color ); - cairo_set_source_rgba (cr, light_bottom_color.r, light_bottom_color.g, @@ -349,14 +395,13 @@ draw_album_art_placeholder(GtkWidget *metadata) 1.0); pango_cairo_update_layout(cr, layout); - cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y + alloc.height/8); + cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y + 3); pango_cairo_show_layout(cr, layout); g_object_unref(layout); g_object_unref(pcontext); g_string_free (string, TRUE); cairo_destroy (cr); - } static void @@ -366,33 +411,48 @@ metadata_widget_selection_received_event_callback ( GtkWidget *widget, gpointer user_data ) { - //g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); - //MetadataWidget* widget = METADATA_WIDGET(user_data); - //MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget); - g_debug("metadata_widget_selection_request_event_callback"); draw_album_border(widget, TRUE); } /* Suppress/consume keyevents */ static gboolean -metadata_widget_button_press_event (GtkWidget *menuitem, - GdkEventButton *event) +metadata_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) { - GtkClipboard* board = gtk_clipboard_get (GDK_NONE); - - MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(menuitem)); - - gchar* contents = g_strdup_printf("artist: %s \ntitle: %s \nalbum: %s", - dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_METADATA_MENUITEM_ARTIST), - dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_METADATA_MENUITEM_TITLE), - dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_METADATA_MENUITEM_ALBUM)); - gtk_clipboard_set_text (board, contents, -1); - gtk_clipboard_store (board); - g_free(contents); - return FALSE; + g_return_val_if_fail (IS_METADATA_WIDGET (menuitem), FALSE); + MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(menuitem)); + // For the left raise/launch the player + if (event->button == 1){ + GVariant* new_title_event = g_variant_new_boolean(TRUE); + dbusmenu_menuitem_handle_event (priv->twin_item, + "Title menu event", + new_title_event, + 0); + } + // For the right copy track details to clipboard only if the player is running + // and there is something there + else if (event->button == 3){ + gboolean running = dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING); + gboolean hidden = dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS); + g_return_val_if_fail ( running, FALSE ); + + g_return_val_if_fail ( !hidden, FALSE ); + + GtkClipboard* board = gtk_clipboard_get (GDK_NONE); + gchar* contents = g_strdup_printf("artist: %s \ntitle: %s \nalbum: %s", + dbusmenu_menuitem_property_get(priv->twin_item, + DBUSMENU_METADATA_MENUITEM_ARTIST), + dbusmenu_menuitem_property_get(priv->twin_item, + DBUSMENU_METADATA_MENUITEM_TITLE), + dbusmenu_menuitem_property_get(priv->twin_item, + DBUSMENU_METADATA_MENUITEM_ALBUM)); + gtk_clipboard_set_text (board, contents, -1); + gtk_clipboard_store (board); + g_free(contents); + } + return TRUE; } static void @@ -403,7 +463,6 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, if(g_variant_is_of_type(value, G_VARIANT_TYPE_INT32) == TRUE && g_variant_get_int32(value) == DBUSMENU_PROPERTY_EMPTY){ - //g_debug("Metadata widget: property update - reset"); GVariant* new_value = g_variant_new_string (""); value = new_value; } @@ -427,11 +486,48 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property, g_string_erase(priv->image_path, 0, -1); g_string_overwrite(priv->image_path, 0, g_variant_get_string (value, NULL)); // if its a remote image queue a redraw incase the download took too long - if (g_str_has_prefix(g_variant_get_string (value, NULL), g_get_user_cache_dir())){ - //g_debug("the image update is a download so redraw"); - gtk_widget_queue_draw(GTK_WIDGET(mitem)); - } - } + //if (g_str_has_prefix(g_variant_get_string (value, NULL), g_get_user_cache_dir())){ + gtk_widget_queue_draw(GTK_WIDGET(mitem)); + //} + } + else if (g_ascii_strcasecmp (DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, property) == 0){ + gtk_label_set_label (GTK_LABEL (priv->player_label), + g_variant_get_string(value, NULL)); + } + else if (g_ascii_strcasecmp (DBUSMENU_METADATA_MENUITEM_PLAYER_ICON, property) == 0){ + metadata_widget_set_icon (mitem); + } + else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS, property) == 0){ + metadata_widget_handle_resizing (mitem); + } +} + +static void +metadata_widget_handle_resizing (MetadataWidget* self) +{ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS) == TRUE){ + gtk_widget_hide (priv->meta_data_h_box); + gtk_widget_hide (priv->artist_label); + gtk_widget_hide (priv->piece_label); + gtk_widget_hide (priv->container_label); + gtk_widget_hide (priv->album_art); + gtk_widget_hide (priv->meta_data_v_box); + gtk_widget_set_size_request(GTK_WIDGET(self), 200, 20); + } + else{ + + gtk_widget_show (priv->meta_data_h_box); + gtk_widget_show (priv->artist_label); + gtk_widget_show (priv->piece_label); + gtk_widget_show (priv->container_label); + gtk_widget_show (priv->album_art); + gtk_widget_show (priv->meta_data_v_box); + gtk_widget_set_size_request(GTK_WIDGET(self), 200, 95); + } + gtk_widget_queue_draw(GTK_WIDGET(self)); } static void @@ -454,9 +550,54 @@ metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style) gtk_widget_queue_draw(GTK_WIDGET(metadata)); } +static void +metadata_widget_set_icon (MetadataWidget *self) +{ + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self); + + if (priv->icon_buf != NULL){ + gdk_pixbuf_unref(priv->icon_buf); + priv->icon_buf = NULL; + } + + gint padding = 0; + gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); + gint width, height; + gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height); + + GString* banshee_string = g_string_new ( "banshee" ); + GString* app_panel = g_string_new ( g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME), + -1)); + GdkPixbuf* icon_buf; + + // Banshee Special case! + // 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 && + gtk_icon_theme_has_icon ( gtk_icon_theme_get_default(), app_panel->str ) ){ + g_string_append ( app_panel, "-panel" ); + } + else{ + // Otherwise use what is stored in the props + g_string_erase (app_panel, 0, -1); + g_string_overwrite (app_panel, + 0, + dbusmenu_menuitem_property_get ( priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_ICON )); + } + icon_buf = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), + app_panel->str, + (width > height) ? width : height, + GTK_ICON_LOOKUP_GENERIC_FALLBACK, + NULL ); + priv->icon_buf = icon_buf; + g_string_free ( app_panel, TRUE); + g_string_free ( banshee_string, TRUE); +} + static void -metadata_widget_set_twin_item(MetadataWidget* self, - DbusmenuMenuitem* twin_item) +metadata_widget_set_twin_item (MetadataWidget* self, + DbusmenuMenuitem* twin_item) { MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(self); priv->twin_item = twin_item; @@ -479,16 +620,77 @@ metadata_widget_set_twin_item(MetadataWidget* self, g_string_erase(priv->image_path, 0, -1); const gchar *arturl = dbusmenu_menuitem_property_get( priv->twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL ); + + gtk_label_set_label (GTK_LABEL(priv->player_label), + dbusmenu_menuitem_property_get(priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_NAME)); + + metadata_widget_set_icon(self); + if (arturl != NULL){ g_string_overwrite( priv->image_path, 0, arturl); - // if its a remote image queue a redraw incase the download took too long if (g_str_has_prefix (arturl, g_get_user_cache_dir())){ gtk_widget_queue_draw(GTK_WIDGET(self)); } } + metadata_widget_handle_resizing (self); +} + +// Draw the triangle if the player is running ... +static gboolean +metadata_widget_icon_triangle_draw_cb (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data) +{ + g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE); + MetadataWidget* meta = METADATA_WIDGET(user_data); + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta); + + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + gint offset = 3; + arrow_width = 5; + arrow_height = 9; + + style = gtk_widget_get_style (widget); + + cr = (cairo_t*) gdk_cairo_create (widget->window); + + x = widget->allocation.x; + y = widget->allocation.y; + + // Draw player icon + if (priv->icon_buf != NULL){ + gdk_cairo_set_source_pixbuf (cr, + priv->icon_buf, + x + arrow_width + 1, + y + offset); + cairo_paint (cr); + } + + // Draw triangle but only if the player is running. + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ + y += (double)arrow_height/2.0 + offset; + cairo_set_line_width (cr, 1.0); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + } + + cairo_destroy (cr); + return FALSE; } /** @@ -498,7 +700,6 @@ metadata_widget_set_twin_item(MetadataWidget* self, GtkWidget* metadata_widget_new(DbusmenuMenuitem *item) { - GtkWidget* widget = g_object_new(METADATA_WIDGET_TYPE, NULL); metadata_widget_set_twin_item ( METADATA_WIDGET(widget), item ); diff --git a/src/metadata-widget.h b/src/metadata-widget.h index 6021af5..30b629c 100644 --- a/src/metadata-widget.h +++ b/src/metadata-widget.h @@ -35,11 +35,11 @@ typedef struct _MetadataWidget MetadataWidget; typedef struct _MetadataWidgetClass MetadataWidgetClass; struct _MetadataWidgetClass { - GtkMenuItemClass parent_class; + GtkMenuItemClass parent_class; }; struct _MetadataWidget { - GtkMenuItem parent; + GtkMenuItem parent; }; GType metadata_widget_get_type (void); diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c index 8e381d6..64381ad 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -127,17 +127,17 @@ typedef struct _PlayerItemClass PlayerItemClass; typedef struct _TransportMenuitem TransportMenuitem; typedef struct _TransportMenuitemClass TransportMenuitemClass; #define _g_free0(var) (var = (g_free (var), NULL)) -#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) -#define TYPE_TITLE_MENUITEM (title_menuitem_get_type ()) -#define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem)) -#define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) -#define IS_TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TITLE_MENUITEM)) -#define IS_TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TITLE_MENUITEM)) -#define TITLE_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) +#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)) +#define IS_METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_METADATA_MENUITEM)) +#define IS_METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_METADATA_MENUITEM)) +#define METADATA_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitemClass)) -typedef struct _TitleMenuitem TitleMenuitem; -typedef struct _TitleMenuitemClass TitleMenuitemClass; +typedef struct _MetadataMenuitem MetadataMenuitem; +typedef struct _MetadataMenuitemClass MetadataMenuitemClass; +#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL))) #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) #define TYPE_PLAYLISTS_MENUITEM (playlists_menuitem_get_type ()) @@ -249,7 +249,6 @@ struct _PlayerControllerClass { 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_PLAYLISTS @@ -330,21 +329,23 @@ GType transport_menuitem_get_type (void) G_GNUC_CONST; void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self); void player_item_reset (PlayerItem* self, GeeHashSet* attrs); -GeeHashSet* metadata_menuitem_attributes_format (void); +GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void); void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes); +GType metadata_menuitem_get_type (void) G_GNUC_CONST; gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); +void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse); static gboolean _bool_equal (const gboolean* s1, const gboolean* s2); static gboolean mpris2_controller_fetch_active_playlist (Mpris2Controller* self); static gboolean _mpris2_controller_fetch_active_playlist_gsource_func (gpointer self); void mpris2_controller_fetch_playlists (Mpris2Controller* self, GAsyncReadyCallback _callback_, gpointer _user_data_); void mpris2_controller_fetch_playlists_finish (Mpris2Controller* self, GAsyncResult* _res_); -GType title_menuitem_get_type (void) G_GNUC_CONST; -void title_menuitem_alter_label (TitleMenuitem* self, const gchar* new_title); +void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title); MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self); gchar* mpris_root_get_Identity (MprisRoot* self); GHashTable* mpris_player_get_Metadata (MprisPlayer* self); static GVariant* _variant_new1 (const gchar* value); void mpris2_controller_initial_update (Mpris2Controller* self); +GeeHashSet* metadata_menuitem_attributes_format (void); void mpris2_controller_transport_update (Mpris2Controller* self, TransportAction command); void mpris_player_PlayPause (MprisPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_); void mpris_player_PlayPause_finish (MprisPlayer* self, GAsyncResult* _res_, GError** error); @@ -417,6 +418,22 @@ static gboolean _mpris2_controller_ensure_correct_playback_status_gsource_func ( } +static gchar* bool_to_string (gboolean self) { + gchar* result = NULL; + if (self) { + gchar* _tmp0_; + _tmp0_ = g_strdup ("true"); + result = _tmp0_; + return result; + } else { + gchar* _tmp1_; + _tmp1_ = g_strdup ("false"); + result = _tmp1_; + return result; + } +} + + static gboolean _bool_equal (const gboolean* s1, const gboolean* s2) { if (s1 == s2) { return TRUE; @@ -446,20 +463,20 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* gconstpointer _tmp9_ = NULL; GVariant* _tmp10_; GVariant* meta_v; - gconstpointer _tmp20_ = NULL; - GVariant* _tmp21_; + gconstpointer _tmp25_ = NULL; + GVariant* _tmp26_; GVariant* playlist_v; - gboolean _tmp22_ = FALSE; - gconstpointer _tmp24_ = NULL; - GVariant* _tmp25_; + gboolean _tmp27_ = FALSE; + gconstpointer _tmp29_ = NULL; + GVariant* _tmp30_; GVariant* playlist_count_v; - gboolean _tmp26_ = FALSE; - gconstpointer _tmp28_ = NULL; - GVariant* _tmp29_; + gboolean _tmp31_ = FALSE; + gconstpointer _tmp33_ = NULL; + GVariant* _tmp34_; GVariant* playlist_orderings_v; - gboolean _tmp30_ = FALSE; - gconstpointer _tmp32_ = NULL; - GVariant* _tmp33_; + gboolean _tmp35_ = FALSE; + gconstpointer _tmp37_ = NULL; + GVariant* _tmp38_; GVariant* identity_v; g_return_if_fail (self != NULL); g_return_if_fail (interface_source != NULL); @@ -472,7 +489,7 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* _tmp0_ = _tmp1_ == FALSE; } if (_tmp0_) { - g_warning ("mpris2-controller.vala:72: Property-changed hash is null or this is an" \ + g_warning ("mpris2-controller.vala:71: Property-changed hash is null or this is an" \ " interface that doesn't concern us"); return; } @@ -511,87 +528,104 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar* GeeHashSet* _tmp14_; GeeHashSet* _tmp15_ = NULL; GeeHashSet* _tmp16_; - GeeHashSet* _tmp17_ = NULL; - GeeHashSet* _tmp18_; - gboolean _tmp19_; + gpointer _tmp17_ = NULL; + PlayerItem* _tmp18_; + MetadataMenuitem* md; + GeeHashSet* _tmp19_ = NULL; + GeeHashSet* _tmp20_; + gboolean _tmp21_; + gboolean _tmp22_; + gboolean collapsing; + gchar* _tmp23_ = NULL; + gchar* _tmp24_; _tmp11_ = mpris2_controller_clean_metadata (self); changed_updates = _tmp11_; _tmp12_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); metadata = (PlayerItem*) _tmp12_; - _tmp13_ = metadata_menuitem_attributes_format (); + _tmp13_ = metadata_menuitem_relevant_attributes_for_ui (); _tmp14_ = _tmp13_; player_item_reset (metadata, _tmp14_); _g_object_unref0 (_tmp14_); - _tmp15_ = metadata_menuitem_attributes_format (); + _tmp15_ = metadata_menuitem_relevant_attributes_for_ui (); _tmp16_ = _tmp15_; player_item_update (metadata, changed_updates, _tmp16_); _g_object_unref0 (_tmp16_); - _tmp17_ = metadata_menuitem_attributes_format (); - _tmp18_ = _tmp17_; - _tmp19_ = player_item_populated (metadata, _tmp18_); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) metadata, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp19_); - _g_object_unref0 (_tmp18_); + _tmp17_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp18_ = (PlayerItem*) _tmp17_; + md = IS_METADATA_MENUITEM (_tmp18_) ? ((MetadataMenuitem*) _tmp18_) : NULL; + _tmp19_ = metadata_menuitem_relevant_attributes_for_ui (); + _tmp20_ = _tmp19_; + _tmp21_ = player_item_populated (metadata, _tmp20_); + _tmp22_ = !_tmp21_; + _g_object_unref0 (_tmp20_); + collapsing = _tmp22_; + metadata_menuitem_should_collapse (md, collapsing); + _tmp23_ = bool_to_string (collapsing); + _tmp24_ = _tmp23_; + g_debug ("mpris2-controller.vala:95: Should metadata collapse %s", _tmp24_); + _g_free0 (_tmp24_); + _g_object_unref0 (md); _g_object_unref0 (metadata); _g_hash_table_unref0 (changed_updates); } - _tmp20_ = g_hash_table_lookup (changed_properties, "ActivePlaylist"); - _tmp21_ = _g_variant_ref0 ((GVariant*) _tmp20_); - playlist_v = _tmp21_; + _tmp25_ = g_hash_table_lookup (changed_properties, "ActivePlaylist"); + _tmp26_ = _g_variant_ref0 ((GVariant*) _tmp25_); + playlist_v = _tmp26_; if (playlist_v != NULL) { - gboolean _tmp23_; - _tmp23_ = TRUE; - _tmp22_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp23_) == TRUE; + gboolean _tmp28_; + _tmp28_ = TRUE; + _tmp27_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp28_) == TRUE; } else { - _tmp22_ = FALSE; + _tmp27_ = FALSE; } - if (_tmp22_) { + if (_tmp27_) { g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 300, _mpris2_controller_fetch_active_playlist_gsource_func, g_object_ref (self), g_object_unref); } - _tmp24_ = g_hash_table_lookup (changed_properties, "PlaylistCount"); - _tmp25_ = _g_variant_ref0 ((GVariant*) _tmp24_); - playlist_count_v = _tmp25_; + _tmp29_ = g_hash_table_lookup (changed_properties, "PlaylistCount"); + _tmp30_ = _g_variant_ref0 ((GVariant*) _tmp29_); + playlist_count_v = _tmp30_; if (playlist_count_v != NULL) { - gboolean _tmp27_; - _tmp27_ = TRUE; - _tmp26_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp27_) == TRUE; + gboolean _tmp32_; + _tmp32_ = TRUE; + _tmp31_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp32_) == TRUE; } else { - _tmp26_ = FALSE; + _tmp31_ = FALSE; } - if (_tmp26_) { + if (_tmp31_) { mpris2_controller_fetch_playlists (self, NULL, NULL); mpris2_controller_fetch_active_playlist (self); } - _tmp28_ = g_hash_table_lookup (changed_properties, "Orderings"); - _tmp29_ = _g_variant_ref0 ((GVariant*) _tmp28_); - playlist_orderings_v = _tmp29_; + _tmp33_ = g_hash_table_lookup (changed_properties, "Orderings"); + _tmp34_ = _g_variant_ref0 ((GVariant*) _tmp33_); + playlist_orderings_v = _tmp34_; if (playlist_orderings_v != NULL) { - gboolean _tmp31_; - _tmp31_ = TRUE; - _tmp30_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp31_) == TRUE; + gboolean _tmp36_; + _tmp36_ = TRUE; + _tmp35_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp36_) == TRUE; } else { - _tmp30_ = FALSE; + _tmp35_ = FALSE; } - if (_tmp30_) { + if (_tmp35_) { mpris2_controller_fetch_playlists (self, NULL, NULL); mpris2_controller_fetch_active_playlist (self); } - _tmp32_ = g_hash_table_lookup (changed_properties, "Identity"); - _tmp33_ = _g_variant_ref0 ((GVariant*) _tmp32_); - identity_v = _tmp33_; + _tmp37_ = g_hash_table_lookup (changed_properties, "Identity"); + _tmp38_ = _g_variant_ref0 ((GVariant*) _tmp37_); + identity_v = _tmp38_; if (identity_v != NULL) { - gpointer _tmp34_ = NULL; - PlayerItem* _tmp35_; - TitleMenuitem* title; - gchar* _tmp36_ = NULL; - gchar* _tmp37_; - _tmp34_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); - _tmp35_ = (PlayerItem*) _tmp34_; - title = IS_TITLE_MENUITEM (_tmp35_) ? ((TitleMenuitem*) _tmp35_) : NULL; - _tmp36_ = mpris_root_get_Identity (self->priv->_mpris2_root); - _tmp37_ = _tmp36_; - title_menuitem_alter_label (title, _tmp37_); - _g_free0 (_tmp37_); - _g_object_unref0 (title); + gpointer _tmp39_ = NULL; + PlayerItem* _tmp40_; + MetadataMenuitem* md; + gchar* _tmp41_ = NULL; + gchar* _tmp42_; + _tmp39_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp40_ = (PlayerItem*) _tmp39_; + md = IS_METADATA_MENUITEM (_tmp40_) ? ((MetadataMenuitem*) _tmp40_) : NULL; + _tmp41_ = mpris_root_get_Identity (self->priv->_mpris2_root); + _tmp42_ = _tmp41_; + metadata_menuitem_alter_label (md, _tmp42_); + _g_free0 (_tmp42_); + _g_object_unref0 (md); } _g_variant_unref0 (identity_v); _g_variant_unref0 (playlist_orderings_v); @@ -766,17 +800,17 @@ void mpris2_controller_initial_update (Mpris2Controller* self) { if (_tmp8_) { gpointer _tmp9_ = NULL; PlayerItem* _tmp10_; - TitleMenuitem* title; + MetadataMenuitem* md; gchar* _tmp11_ = NULL; gchar* _tmp12_; - _tmp9_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); + _tmp9_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp10_ = (PlayerItem*) _tmp9_; - title = IS_TITLE_MENUITEM (_tmp10_) ? ((TitleMenuitem*) _tmp10_) : NULL; + md = IS_METADATA_MENUITEM (_tmp10_) ? ((MetadataMenuitem*) _tmp10_) : NULL; _tmp11_ = mpris_root_get_Identity (self->priv->_mpris2_root); _tmp12_ = _tmp11_; - title_menuitem_alter_label (title, _tmp12_); + metadata_menuitem_alter_label (md, _tmp12_); _g_free0 (_tmp12_); - _g_object_unref0 (title); + _g_object_unref0 (md); } _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); _tmp14_ = (PlayerItem*) _tmp13_; @@ -989,7 +1023,7 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl playlists_menuitem_update (data->playlists_item, data->current_playlists, data->current_playlists_length1); _g_object_unref0 (data->playlists_item); } else { - g_warning ("mpris2-controller.vala:241: Playlists are on but its returning no cur" \ + g_warning ("mpris2-controller.vala:243: Playlists are on but its returning no cur" \ "rent_playlists"); data->_tmp5_ = FALSE; data->_tmp6_ = __bool_dup0 (&data->_tmp5_); @@ -1245,7 +1279,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr GError * e; e = _inner_error_; _inner_error_ = NULL; - g_critical ("mpris2-controller.vala:61: Problems connecting to the session bus - %s", e->message); + g_critical ("mpris2-controller.vala:60: Problems connecting to the session bus - %s", e->message); _g_error_free0 (e); } __finally13: diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 9a0c1a5..2975066 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -16,7 +16,6 @@ PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ - using Dbusmenu; using Transport; @@ -84,13 +83,16 @@ public class Mpris2Controller : GLib.Object } Variant? meta_v = changed_properties.lookup("Metadata"); if(meta_v != null){ - GLib.HashTable<string, Variant?> changed_updates = clean_metadata(); + GLib.HashTable<string, Variant?> changed_updates = clean_metadata(); PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA]; - metadata.reset ( MetadataMenuitem.attributes_format()); + metadata.reset (MetadataMenuitem.relevant_attributes_for_ui()); metadata.update ( changed_updates, - MetadataMenuitem.attributes_format()); - metadata.property_set_bool ( MENUITEM_PROP_VISIBLE, - metadata.populated(MetadataMenuitem.attributes_format())); + MetadataMenuitem.relevant_attributes_for_ui()); + MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem; + bool collapsing = !metadata.populated(MetadataMenuitem.relevant_attributes_for_ui()); + md.should_collapse(collapsing); + + debug ("Should metadata collapse %s", collapsing.to_string()); } Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); if ( playlist_v != null && this.owner.use_playlists == true ){ @@ -110,8 +112,8 @@ public class Mpris2Controller : GLib.Object } Variant? identity_v = changed_properties.lookup("Identity"); if (identity_v != null){ - TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; - title.alter_label (this.mpris2_root.Identity); + MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem; + md.alter_label (this.mpris2_root.Identity); } } @@ -163,8 +165,8 @@ public class Mpris2Controller : GLib.Object update = determine_play_state (this.player.PlaybackStatus); } if (this.mpris2_root.Identity != null){ - TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; - title.alter_label (this.mpris2_root.Identity); + MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem; + md.alter_label (this.mpris2_root.Identity); } (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state (update); GLib.HashTable<string, Value?>? cleaned_metadata = this.clean_metadata(); diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c index 48087b6..e9c688b 100644 --- a/src/music-player-bridge.c +++ b/src/music-player-bridge.c @@ -168,7 +168,7 @@ 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, gboolean* use_playlists, PlayerControllerstate initial_state); PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, gboolean* use_playlists, PlayerControllerstate initial_state); -#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 void music_player_bridge_client_has_become_available (MusicPlayerBridge* self, const gchar* desktop, const gchar* dbus_name, gboolean use_playlists); gchar** settings_manager_fetch_blacklist (SettingsManager* self, int* result_length1); static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle); diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index 8e636ef..d644c9c 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -75,17 +75,6 @@ typedef struct _PlayerControllerClass PlayerControllerClass; typedef struct _MetadataMenuitem MetadataMenuitem; typedef struct _MetadataMenuitemClass MetadataMenuitemClass; typedef struct _MetadataMenuitemPrivate MetadataMenuitemPrivate; - -#define TYPE_TITLE_MENUITEM (title_menuitem_get_type ()) -#define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem)) -#define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) -#define IS_TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TITLE_MENUITEM)) -#define IS_TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TITLE_MENUITEM)) -#define TITLE_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) - -typedef struct _TitleMenuitem TitleMenuitem; -typedef struct _TitleMenuitemClass TitleMenuitemClass; -typedef struct _TitleMenuitemPrivate TitleMenuitemPrivate; typedef struct _PlayerControllerPrivate PlayerControllerPrivate; #define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ()) @@ -249,15 +238,6 @@ struct _MetadataMenuitemClass { PlayerItemClass parent_class; }; -struct _TitleMenuitem { - PlayerItem parent_instance; - TitleMenuitemPrivate * priv; -}; - -struct _TitleMenuitemClass { - PlayerItemClass parent_class; -}; - struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; @@ -273,7 +253,6 @@ struct _PlayerControllerClass { 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_PLAYLISTS @@ -432,20 +411,18 @@ GeeHashSet* transport_menuitem_attributes_format (void); GType metadata_menuitem_get_type (void) G_GNUC_CONST; extern gchar* metadata_menuitem_album_art_cache_dir; #define METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX "indicators/sound/album-art-cache" -MetadataMenuitem* metadata_menuitem_new (void); -MetadataMenuitem* metadata_menuitem_construct (GType object_type); +MetadataMenuitem* metadata_menuitem_new (PlayerController* parent); +MetadataMenuitem* metadata_menuitem_construct (GType object_type, PlayerController* parent); void metadata_menuitem_fetch_art (MetadataMenuitem* self, const gchar* uri, const gchar* prop); +void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title); +void metadata_menuitem_toggle_active_triangle (MetadataMenuitem* self, gboolean update); +void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse); GeeHashSet* metadata_menuitem_attributes_format (void); -GType title_menuitem_get_type (void) G_GNUC_CONST; -TitleMenuitem* title_menuitem_new (PlayerController* parent); -TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent); -void title_menuitem_alter_label (TitleMenuitem* self, const gchar* new_title); -void title_menuitem_toggle_active_triangle (TitleMenuitem* self, gboolean update); -GeeHashSet* title_menuitem_attributes_format (void); +GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (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 5 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, gboolean* use_playlists, PlayerControllerstate initial_state); PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, gboolean* use_playlists, PlayerControllerstate initial_state); void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); @@ -542,6 +519,7 @@ GType free_desktop_properties_proxy_get_type (void) G_GNUC_CONST; guint free_desktop_properties_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); FreeDesktopProperties* mpris2_controller_get_properties_interface (Mpris2Controller* self); PlayerController* mpris2_controller_get_owner (Mpris2Controller* self); +#define PLAYER_ITEM_EMPTY (-1) PlayerItem* player_item_new (const gchar* type); PlayerItem* player_item_construct (GType object_type, const gchar* type); void player_item_reset (PlayerItem* self, GeeHashSet* attrs); diff --git a/src/player-controller.c b/src/player-controller.c index 1873a71..e2e2043 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -97,16 +97,6 @@ typedef struct _PlaylistsMenuitemPrivate PlaylistsMenuitemPrivate; typedef struct _TransportMenuitem TransportMenuitem; typedef struct _TransportMenuitemClass TransportMenuitemClass; -#define TYPE_TITLE_MENUITEM (title_menuitem_get_type ()) -#define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem)) -#define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) -#define IS_TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TITLE_MENUITEM)) -#define IS_TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TITLE_MENUITEM)) -#define TITLE_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) - -typedef struct _TitleMenuitem TitleMenuitem; -typedef struct _TitleMenuitemClass TitleMenuitemClass; - #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)) @@ -140,7 +130,6 @@ struct _PlayerControllerPrivate { 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_PLAYLISTS @@ -189,7 +178,7 @@ 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 5 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4 PlayerController* player_controller_new (DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, gboolean* use_playlists, PlayerControllerstate initial_state); PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, GAppInfo* app, const gchar* dbus_name, const gchar* icon_name, gint offset, gboolean* use_playlists, PlayerControllerstate initial_state); static gboolean* _bool_dup (gboolean* self); @@ -200,8 +189,9 @@ 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); GAppInfo* player_controller_get_app_info (PlayerController* self); +const gchar* player_controller_get_icon_name (PlayerController* self); +void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state); void player_controller_activate (PlayerController* self, const gchar* dbus_name); void player_controller_instantiate (PlayerController* self); const gchar* player_controller_get_dbus_name (PlayerController* self); @@ -215,18 +205,16 @@ void player_controller_hibernate (PlayerController* self); GType transport_menuitem_get_type (void) G_GNUC_CONST; void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); void player_item_reset (PlayerItem* self, GeeHashSet* attrs); -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); +GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void); +GType metadata_menuitem_get_type (void) G_GNUC_CONST; +void metadata_menuitem_toggle_active_triangle (MetadataMenuitem* self, gboolean update); +void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse); gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); void transport_menuitem_handle_cached_action (TransportMenuitem* self); PlayerItem* player_item_new (const gchar* type); PlayerItem* player_item_construct (GType object_type, const gchar* type); -TitleMenuitem* title_menuitem_new (PlayerController* parent); -TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent); -MetadataMenuitem* metadata_menuitem_new (void); -MetadataMenuitem* metadata_menuitem_construct (GType object_type); -GType metadata_menuitem_get_type (void) G_GNUC_CONST; +MetadataMenuitem* metadata_menuitem_new (PlayerController* parent); +MetadataMenuitem* metadata_menuitem_construct (GType object_type, PlayerController* parent); TransportMenuitem* transport_menuitem_new (PlayerController* parent); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent); PlaylistsMenuitem* playlists_menuitem_new (PlayerController* parent); @@ -234,7 +222,6 @@ PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerContro gint player_controller_get_menu_offset (PlayerController* self); gboolean mpris2_controller_connected (Mpris2Controller* self); void mpris2_controller_initial_update (Mpris2Controller* self); -const gchar* player_controller_get_icon_name (PlayerController* self); static void player_controller_finalize (GObject* obj); static void _vala_player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void _vala_player_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); @@ -243,7 +230,7 @@ static void _vala_player_controller_set_property (GObject * object, guint proper 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"}, {PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS, "PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS", "playlists"}, {0, NULL, NULL}}; + static const GEnumValue values[] = {{PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, "PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR", "separator"}, {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); @@ -287,6 +274,7 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit gboolean* _tmp0_; DbusmenuMenuitem* _tmp1_; GeeArrayList* _tmp2_ = NULL; + const gchar* _tmp3_ = NULL; 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); @@ -308,6 +296,9 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit player_controller_construct_widgets (self); player_controller_establish_mpris_connection (self); player_controller_update_layout (self); + _tmp3_ = g_app_info_get_name (self->priv->_app_info); + g_debug ("player-controller.vala:73: New player controller for %s with icon nam" \ +"e %s", _tmp3_, self->priv->_icon_name); return self; } @@ -478,7 +469,7 @@ void player_controller_hibernate (PlayerController* self) { GeeHashSet* _tmp5_; gpointer _tmp6_ = NULL; PlayerItem* _tmp7_; - TitleMenuitem* title; + MetadataMenuitem* md; 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); @@ -487,18 +478,18 @@ void player_controller_hibernate (PlayerController* self) { transport_menuitem_change_play_state (transport, TRANSPORT_STATE_PAUSED); _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp3_ = (PlayerItem*) _tmp2_; - _tmp4_ = metadata_menuitem_attributes_format (); + _tmp4_ = metadata_menuitem_relevant_attributes_for_ui (); _tmp5_ = _tmp4_; player_item_reset (_tmp3_, _tmp5_); _g_object_unref0 (_tmp5_); _g_object_unref0 (_tmp3_); - _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); + _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp7_ = (PlayerItem*) _tmp6_; - title = IS_TITLE_MENUITEM (_tmp7_) ? ((TitleMenuitem*) _tmp7_) : NULL; - title_menuitem_toggle_active_triangle (title, FALSE); + md = IS_METADATA_MENUITEM (_tmp7_) ? ((MetadataMenuitem*) _tmp7_) : NULL; + metadata_menuitem_toggle_active_triangle (md, FALSE); _g_object_unref0 (self->mpris_bridge); self->mpris_bridge = NULL; - _g_object_unref0 (title); + _g_object_unref0 (md); _g_object_unref0 (transport); } @@ -507,67 +498,66 @@ void player_controller_update_layout (PlayerController* self) { gpointer _tmp0_ = NULL; PlayerItem* _tmp1_; PlaylistsMenuitem* playlists_menuitem; + gpointer _tmp2_ = NULL; + PlayerItem* _tmp3_; + MetadataMenuitem* metadata_menuitem; gpointer _tmp7_ = NULL; PlayerItem* _tmp8_; - gpointer _tmp9_ = NULL; - PlayerItem* _tmp10_; - GeeHashSet* _tmp11_ = NULL; - GeeHashSet* _tmp12_; - gboolean _tmp13_; - const gchar* _tmp14_ = NULL; + GeeHashSet* _tmp9_ = NULL; + GeeHashSet* _tmp10_; + gboolean _tmp11_; + const gchar* _tmp12_ = NULL; g_return_if_fail (self != NULL); + g_debug ("player-controller.vala:146: a call to update layout"); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); _tmp1_ = (PlayerItem*) _tmp0_; playlists_menuitem = IS_PLAYLISTS_MENUITEM (_tmp1_) ? ((PlaylistsMenuitem*) _tmp1_) : NULL; + _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp3_ = (PlayerItem*) _tmp2_; + metadata_menuitem = IS_METADATA_MENUITEM (_tmp3_) ? ((MetadataMenuitem*) _tmp3_) : NULL; if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) { - gpointer _tmp2_ = NULL; - PlayerItem* _tmp3_; gpointer _tmp4_ = NULL; PlayerItem* _tmp5_; const gchar* _tmp6_ = NULL; - _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); - _tmp3_ = (PlayerItem*) _tmp2_; - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp3_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - _g_object_unref0 (_tmp3_); + metadata_menuitem_should_collapse (metadata_menuitem, TRUE); dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); _tmp5_ = (PlayerItem*) _tmp4_; _tmp6_ = g_app_info_get_id (self->priv->_app_info); dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp5_, DBUSMENU_MENUITEM_PROP_VISIBLE, g_strcmp0 (_tmp6_, "banshee.desktop") == 0); _g_object_unref0 (_tmp5_); + _g_object_unref0 (metadata_menuitem); _g_object_unref0 (playlists_menuitem); return; } _tmp7_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp8_ = (PlayerItem*) _tmp7_; - _tmp9_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); - _tmp10_ = (PlayerItem*) _tmp9_; - _tmp11_ = metadata_menuitem_attributes_format (); - _tmp12_ = _tmp11_; - _tmp13_ = player_item_populated (_tmp10_, _tmp12_); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp8_, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp13_); - _g_object_unref0 (_tmp12_); + _tmp9_ = metadata_menuitem_relevant_attributes_for_ui (); + _tmp10_ = _tmp9_; + _tmp11_ = player_item_populated (_tmp8_, _tmp10_); + metadata_menuitem_should_collapse (metadata_menuitem, !_tmp11_); _g_object_unref0 (_tmp10_); _g_object_unref0 (_tmp8_); - _tmp14_ = g_app_info_get_id (self->priv->_app_info); - if (g_strcmp0 (_tmp14_, "banshee.desktop") == 0) { - gpointer _tmp15_ = NULL; - PlayerItem* _tmp16_; + _tmp12_ = g_app_info_get_id (self->priv->_app_info); + if (g_strcmp0 (_tmp12_, "banshee.desktop") == 0) { + gpointer _tmp13_ = NULL; + PlayerItem* _tmp14_; TransportMenuitem* transport; - _tmp15_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp16_ = (PlayerItem*) _tmp15_; - transport = IS_TRANSPORT_MENUITEM (_tmp16_) ? ((TransportMenuitem*) _tmp16_) : NULL; + _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); + _tmp14_ = (PlayerItem*) _tmp13_; + transport = IS_TRANSPORT_MENUITEM (_tmp14_) ? ((TransportMenuitem*) _tmp14_) : NULL; transport_menuitem_handle_cached_action (transport); _g_object_unref0 (transport); } else { - gpointer _tmp17_ = NULL; - PlayerItem* _tmp18_; - _tmp17_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp18_ = (PlayerItem*) _tmp17_; - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp18_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - _g_object_unref0 (_tmp18_); + gpointer _tmp15_ = NULL; + PlayerItem* _tmp16_; + _tmp15_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); + _tmp16_ = (PlayerItem*) _tmp15_; + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp16_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + _g_object_unref0 (_tmp16_); } dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, *self->use_playlists); + _g_object_unref0 (metadata_menuitem); _g_object_unref0 (playlists_menuitem); } @@ -575,68 +565,63 @@ void player_controller_update_layout (PlayerController* self) { static void player_controller_construct_widgets (PlayerController* self) { PlayerItem* _tmp0_ = NULL; PlayerItem* _tmp1_; - TitleMenuitem* _tmp2_ = NULL; - TitleMenuitem* title_menu_item; - MetadataMenuitem* _tmp3_ = NULL; + MetadataMenuitem* _tmp2_ = NULL; MetadataMenuitem* metadata_item; - TransportMenuitem* _tmp4_ = NULL; + TransportMenuitem* _tmp3_ = NULL; TransportMenuitem* transport_item; - PlaylistsMenuitem* _tmp5_ = NULL; + PlaylistsMenuitem* _tmp4_ = NULL; PlaylistsMenuitem* playlist_menuitem; g_return_if_fail (self != NULL); _tmp0_ = player_item_new (DBUSMENU_CLIENT_TYPES_SEPARATOR); _tmp1_ = _tmp0_; gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, _tmp1_); _g_object_unref0 (_tmp1_); - _tmp2_ = title_menuitem_new (self); - title_menu_item = _tmp2_; - gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) title_menu_item); - _tmp3_ = metadata_menuitem_new (); - metadata_item = _tmp3_; + _tmp2_ = metadata_menuitem_new (self); + metadata_item = _tmp2_; gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) metadata_item); - _tmp4_ = transport_menuitem_new (self); - transport_item = _tmp4_; + _tmp3_ = transport_menuitem_new (self); + transport_item = _tmp3_; gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) transport_item); - _tmp5_ = playlists_menuitem_new (self); - playlist_menuitem = _tmp5_; + _tmp4_ = playlists_menuitem_new (self); + playlist_menuitem = _tmp4_; gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) playlist_menuitem); { - GeeArrayList* _tmp6_; + GeeArrayList* _tmp5_; GeeArrayList* _item_list; - gint _tmp7_; + gint _tmp6_; gint _item_size; gint _item_index; - _tmp6_ = _g_object_ref0 (self->custom_items); - _item_list = _tmp6_; - _tmp7_ = gee_collection_get_size ((GeeCollection*) _item_list); - _item_size = _tmp7_; + _tmp5_ = _g_object_ref0 (self->custom_items); + _item_list = _tmp5_; + _tmp6_ = gee_collection_get_size ((GeeCollection*) _item_list); + _item_size = _tmp6_; _item_index = -1; while (TRUE) { - gpointer _tmp8_ = NULL; + gpointer _tmp7_ = NULL; PlayerItem* item; - gint _tmp9_; + gint _tmp8_; _item_index = _item_index + 1; if (!(_item_index < _item_size)) { break; } - _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_; + _tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _item_list, _item_index); + item = (PlayerItem*) _tmp7_; + _tmp8_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); + if (_tmp8_ == 3) { + PlayerItem* _tmp9_; + PlaylistsMenuitem* _tmp10_; PlaylistsMenuitem* playlists_menuitem; - gint _tmp13_; - _tmp11_ = item; - _tmp12_ = _g_object_ref0 (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_)); + gint _tmp11_; + _tmp9_ = item; + _tmp10_ = _g_object_ref0 (IS_PLAYLISTS_MENUITEM (_tmp9_) ? ((PlaylistsMenuitem*) _tmp9_) : NULL); + playlists_menuitem = _tmp10_; + _tmp11_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); + dbusmenu_menuitem_child_add_position (self->priv->root_menu, playlists_menuitem->root_item, (guint) (self->priv->_menu_offset + _tmp11_)); _g_object_unref0 (playlists_menuitem); + } else { + gint _tmp12_; + _tmp12_ = gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item); + dbusmenu_menuitem_child_add_position (self->priv->root_menu, (DbusmenuMenuitem*) item, (guint) (self->priv->_menu_offset + _tmp12_)); } _g_object_unref0 (item); } @@ -645,7 +630,6 @@ static void player_controller_construct_widgets (PlayerController* self) { _g_object_unref0 (playlist_menuitem); _g_object_unref0 (transport_item); _g_object_unref0 (metadata_item); - _g_object_unref0 (title_menu_item); } @@ -656,14 +640,14 @@ static void player_controller_determine_state (PlayerController* self) { if (_tmp0_ == TRUE) { gpointer _tmp1_ = NULL; PlayerItem* _tmp2_; - TitleMenuitem* title; + MetadataMenuitem* md; player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED); - _tmp1_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); + _tmp1_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp2_ = (PlayerItem*) _tmp1_; - title = IS_TITLE_MENUITEM (_tmp2_) ? ((TitleMenuitem*) _tmp2_) : NULL; - title_menuitem_toggle_active_triangle (title, TRUE); + md = IS_METADATA_MENUITEM (_tmp2_) ? ((MetadataMenuitem*) _tmp2_) : NULL; + metadata_menuitem_toggle_active_triangle (md, TRUE); mpris2_controller_initial_update (self->mpris_bridge); - _g_object_unref0 (title); + _g_object_unref0 (md); } else { player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED); } diff --git a/src/player-controller.vala b/src/player-controller.vala index 20479d9..a08f692 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,11 +23,10 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 5; + public const int WIDGET_QUANTITY = 4; public static enum widget_order{ SEPARATOR, - TITLE, METADATA, TRANSPORT, PLAYLISTS @@ -71,6 +70,7 @@ public class PlayerController : GLib.Object this.construct_widgets(); this.establish_mpris_connection(); this.update_layout(); + debug ("New player controller for %s with icon name %s", this.app_info.get_name(), this.icon_name); } public void update_state(state new_state) @@ -111,10 +111,10 @@ public class PlayerController : GLib.Object if(this.current_state != state.READY || this.dbus_name == null ){ debug("establish_mpris_connection - Not ready to connect"); return; - } + } debug ( " establish mpris connection - use playlists value = %s ", this.use_playlists.to_string() ); - + this.mpris_bridge = new Mpris2Controller(this); this.determine_state(); } @@ -135,26 +135,27 @@ public class PlayerController : GLib.Object update_state(PlayerController.state.OFFLINE); TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem; transport.change_play_state (Transport.State.PAUSED); - 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); + this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.relevant_attributes_for_ui()); + MetadataMenuitem md = this.custom_items[widget_order.METADATA] as MetadataMenuitem; + md.toggle_active_triangle (false); this.mpris_bridge = null; } public void update_layout() - { + { + debug ("a call to update layout"); PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem; + MetadataMenuitem metadata_menuitem = this.custom_items[widget_order.METADATA] as MetadataMenuitem; if(this.current_state != state.CONNECTED){ - this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE, - false); + // TODO + metadata_menuitem.should_collapse (true); playlists_menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, false ); this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE, this.app_info.get_id() == "banshee.desktop"); return; } - this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE, - this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); + metadata_menuitem.should_collapse (!this.custom_items[widget_order.METADATA].populated (MetadataMenuitem.relevant_attributes_for_ui()) ); if (this.app_info.get_id() == "banshee.desktop"){ TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem; transport.handle_cached_action(); @@ -172,12 +173,8 @@ public class PlayerController : GLib.Object // Separator item this.custom_items.add(new PlayerItem(CLIENT_TYPES_SEPARATOR)); - // Title item - TitleMenuitem title_menu_item = new TitleMenuitem(this); - this.custom_items.add(title_menu_item); - // Metadata item - MetadataMenuitem metadata_item = new MetadataMenuitem(); + MetadataMenuitem metadata_item = new MetadataMenuitem(this); this.custom_items.add(metadata_item); // Transport item @@ -189,12 +186,12 @@ public class PlayerController : GLib.Object this.custom_items.add(playlist_menuitem); foreach(PlayerItem item in this.custom_items){ - if (this.custom_items.index_of(item) != 4) { - root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + if (this.custom_items.index_of(item) == 3) { + PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; + root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); } else{ - PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; - root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); + root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } } } @@ -203,8 +200,8 @@ 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); + MetadataMenuitem md = this.custom_items[widget_order.METADATA] as MetadataMenuitem; + md.toggle_active_triangle(true); this.mpris_bridge.initial_update(); } else{ diff --git a/src/player-item.c b/src/player-item.c index d880347..cf9e806 100644 --- a/src/player-item.c +++ b/src/player-item.c @@ -194,12 +194,11 @@ static gpointer _g_object_ref0 (gpointer self) { void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes) { - gboolean _tmp20_; g_return_if_fail (self != NULL); g_return_if_fail (data != NULL); g_return_if_fail (attributes != NULL); if (data == NULL) { - g_warning ("player-item.vala:55: PlayerItem::Update -> The hashtable was null - ju" \ + g_warning ("player-item.vala:54: PlayerItem::Update -> The hashtable was null - ju" \ "st leave it!"); return; } @@ -298,8 +297,6 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu } _g_object_unref0 (_property_it); } - _tmp20_ = player_item_populated (self, attributes); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp20_); } diff --git a/src/player-item.vala b/src/player-item.vala index f71b166..162dbea 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -24,7 +24,7 @@ public class PlayerItem : Dbusmenu.Menuitem { public PlayerController owner {get; construct;} public string item_type { get; construct; } - private const int EMPTY = -1; + public const int EMPTY = -1; public PlayerItem(string type) { @@ -37,7 +37,6 @@ public class PlayerItem : Dbusmenu.Menuitem public void reset(HashSet<string> attrs){ foreach(string s in attrs){ - //debug("attempting to set prop %s to EMPTY", s); this.property_set_int(s, EMPTY); } } @@ -87,15 +86,12 @@ public class PlayerItem : Dbusmenu.Menuitem this.property_set_bool(property, v.get_boolean()); } } - this.property_set_bool(MENUITEM_PROP_VISIBLE, populated(attributes)); } public bool populated(HashSet<string> attrs) { foreach(string prop in attrs){ - //debug("populated ? - prop: %s", prop); if(property_get_int(prop) != EMPTY){ - //debug("populated - prop %s and value %i", prop, property_get_int(prop)); return true; } } diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c index 8ae00e1..23d115e 100644 --- a/src/playlists-menu-item.c +++ b/src/playlists-menu-item.c @@ -482,7 +482,7 @@ static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (menu_item_id)); if (!_tmp0_) { - g_warning ("playlists-menu-item.vala:126: item %i was activated but we don't have " \ + g_warning ("playlists-menu-item.vala:125: item %i was activated but we don't have " \ "a corresponding playlist", menu_item_id); return; } diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 58c3875..7faa214 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -37,7 +37,6 @@ public class PlaylistsMenuitem : PlayerItem construct{ this.current_playlists = new HashMap<int, Dbusmenu.Menuitem>(); this.root_item = new Menuitem(); - this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") ); this.root_item.property_set ( MENUITEM_PATH, "" ); diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index d0fd765..6fb0a64 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -183,7 +183,7 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, dbusmenu_menuitem_property_set( settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, - _("Sound Preferences...")); + _("Sound Settings...")); dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi); g_object_unref (settings_mi); g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, diff --git a/src/title-menu-item.c b/src/title-menu-item.c deleted file mode 100644 index 7888200..0000000 --- a/src/title-menu-item.c +++ /dev/null @@ -1,262 +0,0 @@ -/* title-menu-item.c generated by valac 0.12.0, the Vala compiler - * generated from title-menu-item.vala, do not modify */ - -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran <conor.curran@canonical.com> - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <glib.h> -#include <glib-object.h> -#include <libdbusmenu-glib/client.h> -#include <libdbusmenu-glib/dbusmenu-glib.h> -#include <libdbusmenu-glib/enum-types.h> -#include <libdbusmenu-glib/menuitem-proxy.h> -#include <libdbusmenu-glib/menuitem.h> -#include <libdbusmenu-glib/server.h> -#include <libdbusmenu-glib/types.h> -#include <common-defs.h> -#include <stdlib.h> -#include <string.h> -#include <gee.h> -#include <gio/gio.h> - - -#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_TITLE_MENUITEM (title_menuitem_get_type ()) -#define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem)) -#define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) -#define IS_TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TITLE_MENUITEM)) -#define IS_TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TITLE_MENUITEM)) -#define TITLE_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) - -typedef struct _TitleMenuitem TitleMenuitem; -typedef struct _TitleMenuitemClass TitleMenuitemClass; -typedef struct _TitleMenuitemPrivate TitleMenuitemPrivate; - -#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 _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; - -#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ()) -#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) - -struct _PlayerItem { - DbusmenuMenuitem parent_instance; - PlayerItemPrivate * priv; -}; - -struct _PlayerItemClass { - DbusmenuMenuitemClass parent_class; -}; - -struct _TitleMenuitem { - PlayerItem parent_instance; - TitleMenuitemPrivate * priv; -}; - -struct _TitleMenuitemClass { - PlayerItemClass parent_class; -}; - -struct _PlayerController { - GObject parent_instance; - PlayerControllerPrivate * priv; - gint current_state; - GeeArrayList* custom_items; - Mpris2Controller* mpris_bridge; - gboolean* use_playlists; -}; - -struct _PlayerControllerClass { - GObjectClass parent_class; -}; - -typedef enum { - PLAYER_CONTROLLER_STATE_OFFLINE, - PLAYER_CONTROLLER_STATE_INSTANTIATING, - PLAYER_CONTROLLER_STATE_READY, - PLAYER_CONTROLLER_STATE_CONNECTED, - PLAYER_CONTROLLER_STATE_DISCONNECTED -} PlayerControllerstate; - - -static gpointer title_menuitem_parent_class = NULL; - -GType player_item_get_type (void) G_GNUC_CONST; -GType title_menuitem_get_type (void) G_GNUC_CONST; -enum { - TITLE_MENUITEM_DUMMY_PROPERTY -}; -GType player_controller_get_type (void) G_GNUC_CONST; -TitleMenuitem* title_menuitem_new (PlayerController* parent); -TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent); -static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp); -PlayerController* player_item_get_owner (PlayerItem* self); -GType mpris2_controller_get_type (void) G_GNUC_CONST; -GType player_controller_state_get_type (void) G_GNUC_CONST; -void player_controller_instantiate (PlayerController* self); -void mpris2_controller_expose (Mpris2Controller* self); -void title_menuitem_alter_label (TitleMenuitem* self, const gchar* new_title); -void title_menuitem_toggle_active_triangle (TitleMenuitem* self, gboolean update); -GeeHashSet* title_menuitem_attributes_format (void); -static GObject * title_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); -GAppInfo* player_controller_get_app_info (PlayerController* self); -const gchar* player_controller_get_icon_name (PlayerController* self); - - -TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent) { - TitleMenuitem * self = 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); - return self; -} - - -TitleMenuitem* title_menuitem_new (PlayerController* parent) { - return title_menuitem_construct (TYPE_TITLE_MENUITEM, parent); -} - - -static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp) { - TitleMenuitem * self; - PlayerController* _tmp0_ = NULL; - self = (TitleMenuitem*) base; - g_return_if_fail (name != NULL); - g_return_if_fail (input_value != NULL); - _tmp0_ = player_item_get_owner ((PlayerItem*) self); - if (_tmp0_->current_state == PLAYER_CONTROLLER_STATE_OFFLINE) { - PlayerController* _tmp1_ = NULL; - _tmp1_ = player_item_get_owner ((PlayerItem*) self); - player_controller_instantiate (_tmp1_); - } else { - PlayerController* _tmp2_ = NULL; - _tmp2_ = player_item_get_owner ((PlayerItem*) self); - if (_tmp2_->current_state == PLAYER_CONTROLLER_STATE_CONNECTED) { - PlayerController* _tmp3_ = NULL; - _tmp3_ = player_item_get_owner ((PlayerItem*) self); - mpris2_controller_expose (_tmp3_->mpris_bridge); - } - } -} - - -void title_menuitem_alter_label (TitleMenuitem* self, const gchar* new_title) { - g_return_if_fail (self != NULL); - g_return_if_fail (new_title != NULL); - if (new_title == NULL) { - return; - } - dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_NAME, new_title); -} - - -void title_menuitem_toggle_active_triangle (TitleMenuitem* self, gboolean update) { - g_return_if_fail (self != NULL); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_RUNNING, update); -} - - -GeeHashSet* title_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_TITLE_MENUITEM_NAME); - gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_TITLE_MENUITEM_RUNNING); - gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_TITLE_MENUITEM_ICON); - result = attrs; - return result; -} - - -static GObject * title_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { - GObject * obj; - GObjectClass * parent_class; - TitleMenuitem * self; - PlayerController* _tmp0_ = NULL; - GAppInfo* _tmp1_ = NULL; - const gchar* _tmp2_ = NULL; - PlayerController* _tmp3_ = NULL; - const gchar* _tmp4_ = NULL; - parent_class = G_OBJECT_CLASS (title_menuitem_parent_class); - obj = parent_class->constructor (type, n_construct_properties, construct_properties); - self = TITLE_MENUITEM (obj); - _tmp0_ = player_item_get_owner ((PlayerItem*) self); - _tmp1_ = player_controller_get_app_info (_tmp0_); - _tmp2_ = g_app_info_get_name (_tmp1_); - dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_NAME, _tmp2_); - _tmp3_ = player_item_get_owner ((PlayerItem*) self); - _tmp4_ = player_controller_get_icon_name (_tmp3_); - dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_ICON, _tmp4_); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_RUNNING, FALSE); - return obj; -} - - -static void title_menuitem_class_init (TitleMenuitemClass * klass) { - title_menuitem_parent_class = g_type_class_peek_parent (klass); - DBUSMENU_MENUITEM_CLASS (klass)->handle_event = title_menuitem_real_handle_event; - G_OBJECT_CLASS (klass)->constructor = title_menuitem_constructor; -} - - -static void title_menuitem_instance_init (TitleMenuitem * self) { -} - - -GType title_menuitem_get_type (void) { - static volatile gsize title_menuitem_type_id__volatile = 0; - if (g_once_init_enter (&title_menuitem_type_id__volatile)) { - static const GTypeInfo g_define_type_info = { sizeof (TitleMenuitemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) title_menuitem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TitleMenuitem), 0, (GInstanceInitFunc) title_menuitem_instance_init, NULL }; - GType title_menuitem_type_id; - title_menuitem_type_id = g_type_register_static (TYPE_PLAYER_ITEM, "TitleMenuitem", &g_define_type_info, 0); - g_once_init_leave (&title_menuitem_type_id__volatile, title_menuitem_type_id); - } - return title_menuitem_type_id__volatile; -} - - - diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala deleted file mode 100644 index ac93b89..0000000 --- a/src/title-menu-item.vala +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran <conor.curran@canonical.com> - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -using Dbusmenu; -using DbusmenuTitle; -using Gee; - -public class TitleMenuitem : PlayerItem -{ - public TitleMenuitem(PlayerController parent) - { - Object(item_type: MENUITEM_TYPE, owner: parent); - } - - construct - { - this.property_set(MENUITEM_NAME, this.owner.app_info.get_name()); - this.property_set(MENUITEM_ICON, this.owner.icon_name); - this.property_set_bool(MENUITEM_RUNNING, false); - } - - public override void handle_event(string name, Variant input_value, uint timestamp) - { - if(this.owner.current_state == PlayerController.state.OFFLINE) - { - this.owner.instantiate(); - } - else if(this.owner.current_state == PlayerController.state.CONNECTED){ - this.owner.mpris_bridge.expose(); - } - } - - public void alter_label (string new_title) - { - if (new_title == null) return; - this.property_set(MENUITEM_NAME, new_title); - } - - public void toggle_active_triangle(bool update) - { - this.property_set_bool(MENUITEM_RUNNING, update); - } - - public static HashSet<string> attributes_format() - { - HashSet<string> attrs = new HashSet<string>(); - attrs.add(MENUITEM_NAME); - attrs.add(MENUITEM_RUNNING); - attrs.add(MENUITEM_ICON); - return attrs; - } -}
\ No newline at end of file diff --git a/src/title-widget.c b/src/title-widget.c deleted file mode 100644 index b8058b8..0000000 --- a/src/title-widget.c +++ /dev/null @@ -1,248 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran <conor.curran@canonical.com> - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <glib/gi18n.h> -#include "title-widget.h" -#include "common-defs.h" -#include <gtk/gtk.h> -#include <libindicator/indicator-image-helper.h> - - -typedef struct _TitleWidgetPrivate TitleWidgetPrivate; - -struct _TitleWidgetPrivate -{ - DbusmenuMenuitem* twin_item; -}; - -#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate)) - -/* Prototypes */ -static void title_widget_class_init (TitleWidgetClass *klass); -static void title_widget_init (TitleWidget *self); -static void title_widget_dispose (GObject *object); -static void title_widget_finalize (GObject *object); - -// keyevent consumers -static gboolean title_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); - -// Dbusmenuitem properties update callback -static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property, - GVariant* value, gpointer userdata); -static void title_widget_set_twin_item( TitleWidget* self, - DbusmenuMenuitem* twin_item); -static gboolean title_widget_triangle_draw_cb (GtkWidget *widget, - GdkEventExpose *event, - gpointer data); - -G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_IMAGE_MENU_ITEM); - -static void -title_widget_class_init (TitleWidgetClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - widget_class->button_release_event = title_widget_button_release_event; - - g_type_class_add_private (klass, sizeof (TitleWidgetPrivate)); - - gobject_class->dispose = title_widget_dispose; - gobject_class->finalize = title_widget_finalize; -} - -static void -title_widget_init (TitleWidget *self) -{ - //g_debug("TitleWidget::title_widget_init"); -} - -static void -title_widget_set_icon(TitleWidget *self) -{ - TitleWidgetPrivate *priv = TITLE_WIDGET_GET_PRIVATE(self); - - gint padding = 0; - gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); - gint width, height; - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - - GString* banshee_string = g_string_new ( "banshee" ); - 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 && - gtk_icon_theme_has_icon ( gtk_icon_theme_get_default(), app_panel->str ) ){ - g_string_append ( app_panel, "-panel" ); - icon = gtk_image_new_from_icon_name ( app_panel->str, - GTK_ICON_SIZE_MENU ); - } - else{ - icon = gtk_image_new_from_icon_name ( g_strdup (dbusmenu_menuitem_property_get ( priv->twin_item, DBUSMENU_TITLE_MENUITEM_ICON )), - GTK_ICON_SIZE_MENU ); - } - g_string_free ( app_panel, FALSE) ; - g_string_free ( banshee_string, FALSE) ; - - gtk_widget_set_size_request(icon, width - + 5 /* ref triangle is 5x9 pixels */ - + 1 /* padding */, - height); - gtk_misc_set_alignment(GTK_MISC(icon), 0.5 /* right aligned */, 0); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); - gtk_widget_show(icon); -} - - -static void -title_widget_dispose (GObject *object) -{ - G_OBJECT_CLASS (title_widget_parent_class)->dispose (object); -} - -static void -title_widget_finalize (GObject *object) -{ - G_OBJECT_CLASS (title_widget_parent_class)->finalize (object); -} - -/* Suppress/consume keyevents */ -static gboolean -title_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event) -{ - //g_debug("TitleWidget::menu_press_event"); - TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem); - - GVariant* new_title_event = g_variant_new_boolean(TRUE); - dbusmenu_menuitem_handle_event (priv->twin_item, - "Title menu event", - new_title_event, - 0); - return FALSE; -} - -static void -title_widget_property_update (DbusmenuMenuitem* item, gchar* property, - GVariant* value, gpointer userdata) -{ - g_return_if_fail (IS_TITLE_WIDGET (userdata)); - TitleWidget* mitem = TITLE_WIDGET(userdata); - if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_NAME, property) == 0){ - gtk_menu_item_set_label (GTK_MENU_ITEM(mitem), - g_variant_get_string(value, NULL)); - } - else if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_ICON, property) == 0){ - title_widget_set_icon (mitem); - } -} - -static void -title_widget_set_twin_item(TitleWidget* self, - DbusmenuMenuitem* twin_item) -{ - TitleWidgetPrivate *priv = TITLE_WIDGET_GET_PRIVATE(self); - - priv->twin_item = twin_item; - - g_signal_connect (G_OBJECT (twin_item), - "property-changed", - G_CALLBACK (title_widget_property_update), - self); - g_signal_connect_after (G_OBJECT (self), - "expose_event", - G_CALLBACK (title_widget_triangle_draw_cb), - twin_item); - - gtk_menu_item_set_label (GTK_MENU_ITEM(self), - dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_TITLE_MENUITEM_NAME)); - title_widget_set_icon(self); -} - -static gboolean -title_widget_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - GtkStyle *style; - cairo_t *cr; - int x, y, arrow_width, arrow_height; - - if (!GTK_IS_WIDGET (widget)) return FALSE; - if (!DBUSMENU_IS_MENUITEM (data)) return FALSE; - - /* render the triangle indicator only if the application is running */ - if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), - DBUSMENU_TITLE_MENUITEM_RUNNING)){ - return FALSE; - } - - /* get style */ - style = gtk_widget_get_style (widget); - - /* set arrow position / dimensions */ - arrow_width = 5; /* the pixel-based reference triangle is 5x9 */ - arrow_height = 9; - x = widget->allocation.x; - y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; - - /* initialize cairo drawing area */ - cr = (cairo_t*) gdk_cairo_create (widget->window); - - /* set line width */ - cairo_set_line_width (cr, 1.0); - - /* cairo drawing code */ - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - - /* remember to destroy cairo context to avoid leaks */ - cairo_destroy (cr); - - return FALSE; -} - - /** - * transport_new: - * @returns: a new #TitleWidget. - **/ -GtkWidget* -title_widget_new(DbusmenuMenuitem *item) -{ - GtkWidget* widget = g_object_new (TITLE_WIDGET_TYPE, - NULL); - gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (widget), TRUE); - title_widget_set_twin_item((TitleWidget*)widget, item); - - return widget; -} - diff --git a/src/title-widget.h b/src/title-widget.h deleted file mode 100644 index 2be904a..0000000 --- a/src/title-widget.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2010 Canonical Ltd. - -Authors: - Conor Curran <conor.curran@canonical.com> - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see <http://www.gnu.org/licenses/>. -*/ -#ifndef __TITLE_WIDGET_H__ -#define __TITLE_WIDGET_H__ - -#include <gtk/gtkimagemenuitem.h> -#include <libdbusmenu-glib/menuitem.h> - - -G_BEGIN_DECLS - -#define TITLE_WIDGET_TYPE (title_widget_get_type ()) -#define TITLE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TITLE_WIDGET_TYPE, TitleWidget)) -#define TITLE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TITLE_WIDGET_TYPE, TitleWidgetClass)) -#define IS_TITLE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TITLE_WIDGET_TYPE)) -#define IS_TITLE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TITLE_WIDGET_TYPE)) -#define TITLE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TITLE_WIDGET_TYPE, TitleWidgetClass)) - -typedef struct _TitleWidget TitleWidget; -typedef struct _TitleWidgetClass TitleWidgetClass; - -struct _TitleWidgetClass { - GtkImageMenuItemClass parent_class; -}; - -struct _TitleWidget { - GtkImageMenuItem parent; -}; - -GType title_widget_get_type (void); -GtkWidget* title_widget_new(DbusmenuMenuitem *twin_item); - -G_END_DECLS - -#endif - diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 0d28cdb..6262e2f 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -24,6 +24,10 @@ namespace DbusmenuMetadata{ public const string MENUITEM_TITLE; public const string MENUITEM_ALBUM; public const string MENUITEM_ARTURL; + public const string MENUITEM_PLAYER_NAME; + public const string MENUITEM_PLAYER_ICON; + public const string MENUITEM_PLAYER_RUNNING; + public const string MENUITEM_HIDE_TRACK_DETAILS; } [CCode (cheader_filename = "common-defs.h")] @@ -33,11 +37,8 @@ namespace DbusmenuTransport{ } [CCode (cheader_filename = "common-defs.h")] -namespace DbusmenuTitle{ +namespace DbusmenuTrackSpecific{ 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")] |