aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2010-09-08 12:24:23 +0200
committerSebastien Bacher <seb128@ubuntu.com>2010-09-08 12:24:23 +0200
commitb347212eb1cb41fb9739a9873b0ff8eb8abb4b77 (patch)
tree3c9cb3c86b5668c2c03155c60a041f6cc85d28ba /src
parent80e5ad4f83a8b1218133761de11d433a7854041e (diff)
downloadayatana-indicator-sound-b347212eb1cb41fb9739a9873b0ff8eb8abb4b77.tar.gz
ayatana-indicator-sound-b347212eb1cb41fb9739a9873b0ff8eb8abb4b77.tar.bz2
ayatana-indicator-sound-b347212eb1cb41fb9739a9873b0ff8eb8abb4b77.zip
Import upstream version 0.4.2
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/Makefile.in69
-rw-r--r--src/familiar-players-db.c46
-rw-r--r--src/familiar-players-db.vala2
-rw-r--r--src/fetch-file.c480
-rw-r--r--src/fetch-file.vala86
-rw-r--r--src/indicator-sound.c31
-rw-r--r--src/metadata-menu-item.c367
-rw-r--r--src/metadata-menu-item.vala128
-rw-r--r--src/metadata-widget.c48
-rw-r--r--src/mpris-bridge.c246
-rw-r--r--src/mpris-bridge.vala70
-rw-r--r--src/mpris-controller.c748
-rw-r--r--src/mpris-controller.vala130
-rw-r--r--src/mpris2-controller.c150
-rw-r--r--src/mpris2-controller.vala10
-rw-r--r--src/music-player-bridge.c95
-rw-r--r--src/music-player-bridge.h116
-rw-r--r--src/music-player-bridge.vala40
-rw-r--r--src/play-button.c20
-rw-r--r--src/play-button.h4
-rw-r--r--src/player-controller.c64
-rw-r--r--src/player-controller.vala9
-rw-r--r--src/player-item.c122
-rw-r--r--src/player-item.vala26
-rw-r--r--src/scrub-menu-item.c26
-rw-r--r--src/sound-service.c3
-rw-r--r--src/title-menu-item.c26
-rw-r--r--src/transport-menu-item.c26
-rw-r--r--src/transport-widget.c25
-rw-r--r--src/volume-widget.c4
31 files changed, 1538 insertions, 1689 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 74e0297..e85ed93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,11 +65,11 @@ music_bridge_VALASOURCES = \
scrub-menu-item.vala \
title-menu-item.vala \
player-controller.vala \
- mpris-bridge.vala \
- mpris-controller.vala \
mpris2-controller.vala \
player-item.vala \
- familiar-players-db.vala
+ familiar-players-db.vala \
+ fetch-file.vala
+
music_bridge_VALAFLAGS = \
--ccode \
@@ -83,7 +83,9 @@ music_bridge_VALAFLAGS = \
--pkg Dbusmenu-Glib-0.2 \
--pkg common-defs \
--pkg dbus-glib-1 \
- --pkg gio-unix-2.0
+ --pkg gio-unix-2.0 \
+ --pkg gdk-pixbuf-2.0
+
$(MAINTAINER_VALAFLAGS)
diff --git a/src/Makefile.in b/src/Makefile.in
index fd23190..3393025 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -39,10 +39,7 @@ libexec_PROGRAMS = indicator-sound-service$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -97,11 +94,10 @@ am__objects_1 = indicator_sound_service-music-player-bridge.$(OBJEXT) \
indicator_sound_service-scrub-menu-item.$(OBJEXT) \
indicator_sound_service-title-menu-item.$(OBJEXT) \
indicator_sound_service-player-controller.$(OBJEXT) \
- indicator_sound_service-mpris-bridge.$(OBJEXT) \
- indicator_sound_service-mpris-controller.$(OBJEXT) \
indicator_sound_service-mpris2-controller.$(OBJEXT) \
indicator_sound_service-player-item.$(OBJEXT) \
- indicator_sound_service-familiar-players-db.$(OBJEXT)
+ indicator_sound_service-familiar-players-db.$(OBJEXT) \
+ indicator_sound_service-fetch-file.$(OBJEXT)
am_indicator_sound_service_OBJECTS = \
indicator_sound_service-sound-service.$(OBJEXT) \
indicator_sound_service-dbus-menu-manager.$(OBJEXT) \
@@ -345,11 +341,10 @@ music_bridge_VALASOURCES = \
scrub-menu-item.vala \
title-menu-item.vala \
player-controller.vala \
- mpris-bridge.vala \
- mpris-controller.vala \
mpris2-controller.vala \
player-item.vala \
- familiar-players-db.vala
+ familiar-players-db.vala \
+ fetch-file.vala
music_bridge_VALAFLAGS = \
--ccode \
@@ -363,7 +358,8 @@ music_bridge_VALAFLAGS = \
--pkg Dbusmenu-Glib-0.2 \
--pkg common-defs \
--pkg dbus-glib-1 \
- --pkg gio-unix-2.0
+ --pkg gio-unix-2.0 \
+ --pkg gdk-pixbuf-2.0
music_bridge_APIFILES = \
music-player-bridge.h
@@ -536,9 +532,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-dbus-menu-manager.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-familiar-players-db.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-fetch-file.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-metadata-menu-item.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris-bridge.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris-controller.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-mpris2-controller.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-music-player-bridge.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_sound_service-player-controller.Po@am__quote@
@@ -814,38 +809,6 @@ indicator_sound_service-player-controller.obj: player-controller.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-player-controller.obj `if test -f 'player-controller.c'; then $(CYGPATH_W) 'player-controller.c'; else $(CYGPATH_W) '$(srcdir)/player-controller.c'; fi`
-indicator_sound_service-mpris-bridge.o: mpris-bridge.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-mpris-bridge.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-mpris-bridge.Tpo -c -o indicator_sound_service-mpris-bridge.o `test -f 'mpris-bridge.c' || echo '$(srcdir)/'`mpris-bridge.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mpris-bridge.Tpo $(DEPDIR)/indicator_sound_service-mpris-bridge.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpris-bridge.c' object='indicator_sound_service-mpris-bridge.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-mpris-bridge.o `test -f 'mpris-bridge.c' || echo '$(srcdir)/'`mpris-bridge.c
-
-indicator_sound_service-mpris-bridge.obj: mpris-bridge.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-mpris-bridge.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-mpris-bridge.Tpo -c -o indicator_sound_service-mpris-bridge.obj `if test -f 'mpris-bridge.c'; then $(CYGPATH_W) 'mpris-bridge.c'; else $(CYGPATH_W) '$(srcdir)/mpris-bridge.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mpris-bridge.Tpo $(DEPDIR)/indicator_sound_service-mpris-bridge.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpris-bridge.c' object='indicator_sound_service-mpris-bridge.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-mpris-bridge.obj `if test -f 'mpris-bridge.c'; then $(CYGPATH_W) 'mpris-bridge.c'; else $(CYGPATH_W) '$(srcdir)/mpris-bridge.c'; fi`
-
-indicator_sound_service-mpris-controller.o: mpris-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-mpris-controller.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-mpris-controller.Tpo -c -o indicator_sound_service-mpris-controller.o `test -f 'mpris-controller.c' || echo '$(srcdir)/'`mpris-controller.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mpris-controller.Tpo $(DEPDIR)/indicator_sound_service-mpris-controller.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpris-controller.c' object='indicator_sound_service-mpris-controller.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-mpris-controller.o `test -f 'mpris-controller.c' || echo '$(srcdir)/'`mpris-controller.c
-
-indicator_sound_service-mpris-controller.obj: mpris-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-mpris-controller.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-mpris-controller.Tpo -c -o indicator_sound_service-mpris-controller.obj `if test -f 'mpris-controller.c'; then $(CYGPATH_W) 'mpris-controller.c'; else $(CYGPATH_W) '$(srcdir)/mpris-controller.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mpris-controller.Tpo $(DEPDIR)/indicator_sound_service-mpris-controller.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mpris-controller.c' object='indicator_sound_service-mpris-controller.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-mpris-controller.obj `if test -f 'mpris-controller.c'; then $(CYGPATH_W) 'mpris-controller.c'; else $(CYGPATH_W) '$(srcdir)/mpris-controller.c'; fi`
-
indicator_sound_service-mpris2-controller.o: mpris2-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-mpris2-controller.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-mpris2-controller.Tpo -c -o indicator_sound_service-mpris2-controller.o `test -f 'mpris2-controller.c' || echo '$(srcdir)/'`mpris2-controller.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-mpris2-controller.Tpo $(DEPDIR)/indicator_sound_service-mpris2-controller.Po
@@ -894,6 +857,22 @@ indicator_sound_service-familiar-players-db.obj: familiar-players-db.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-familiar-players-db.obj `if test -f 'familiar-players-db.c'; then $(CYGPATH_W) 'familiar-players-db.c'; else $(CYGPATH_W) '$(srcdir)/familiar-players-db.c'; fi`
+indicator_sound_service-fetch-file.o: fetch-file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-fetch-file.o -MD -MP -MF $(DEPDIR)/indicator_sound_service-fetch-file.Tpo -c -o indicator_sound_service-fetch-file.o `test -f 'fetch-file.c' || echo '$(srcdir)/'`fetch-file.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-fetch-file.Tpo $(DEPDIR)/indicator_sound_service-fetch-file.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fetch-file.c' object='indicator_sound_service-fetch-file.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-fetch-file.o `test -f 'fetch-file.c' || echo '$(srcdir)/'`fetch-file.c
+
+indicator_sound_service-fetch-file.obj: fetch-file.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_sound_service_CFLAGS) $(CFLAGS) -MT indicator_sound_service-fetch-file.obj -MD -MP -MF $(DEPDIR)/indicator_sound_service-fetch-file.Tpo -c -o indicator_sound_service-fetch-file.obj `if test -f 'fetch-file.c'; then $(CYGPATH_W) 'fetch-file.c'; else $(CYGPATH_W) '$(srcdir)/fetch-file.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_sound_service-fetch-file.Tpo $(DEPDIR)/indicator_sound_service-fetch-file.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fetch-file.c' object='indicator_sound_service-fetch-file.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-fetch-file.obj `if test -f 'fetch-file.c'; then $(CYGPATH_W) 'fetch-file.c'; else $(CYGPATH_W) '$(srcdir)/fetch-file.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo
diff --git a/src/familiar-players-db.c b/src/familiar-players-db.c
index ec0c16f..6371823 100644
--- a/src/familiar-players-db.c
+++ b/src/familiar-players-db.c
@@ -1,4 +1,4 @@
-/* familiar-players-db.c generated by valac 0.9.7, the Vala compiler
+/* familiar-players-db.c generated by valac 0.9.8, the Vala compiler
* generated from familiar-players-db.vala, do not modify */
/*
@@ -140,10 +140,10 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
_tmp1_ = g_key_file_load_from_file (self->priv->key_file, self->priv->file_name, G_KEY_FILE_NONE, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch9_g_key_file_error;
+ goto __catch11_g_key_file_error;
}
if (_inner_error_->domain == G_FILE_ERROR) {
- goto __catch9_g_file_error;
+ goto __catch11_g_file_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -151,8 +151,8 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
}
_result_ = _tmp1_;
}
- goto __finally9;
- __catch9_g_key_file_error:
+ goto __finally11;
+ __catch11_g_key_file_error:
{
GError * e;
e = _inner_error_;
@@ -163,8 +163,8 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
_g_error_free0 (e);
}
}
- goto __finally9;
- __catch9_g_file_error:
+ goto __finally11;
+ __catch11_g_file_error:
{
GError * e;
e = _inner_error_;
@@ -175,7 +175,7 @@ static gboolean familiar_players_db_create_key_file (FamiliarPlayersDB* self) {
_g_error_free0 (e);
}
}
- __finally9:
+ __finally11:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -196,7 +196,7 @@ static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
_tmp0_ = g_key_file_has_key (self->priv->key_file, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch10_g_key_file_error;
+ goto __catch12_g_key_file_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -207,8 +207,8 @@ static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
return result;
}
}
- goto __finally10;
- __catch10_g_key_file_error:
+ goto __finally12;
+ __catch12_g_key_file_error:
{
GError * e;
e = _inner_error_;
@@ -219,7 +219,7 @@ static gboolean familiar_players_db_check_for_keys (FamiliarPlayersDB* self) {
return result;
}
}
- __finally10:
+ __finally12:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -245,7 +245,7 @@ static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB*
desktops = (_tmp1_ = g_key_file_get_string_list (self->priv->key_file, FAMILIAR_PLAYERS_DB_GROUP_NAME, FAMILIAR_PLAYERS_DB_KEY_NAME, &_tmp0_, &_inner_error_), desktops_length1 = _tmp0_, _desktops_size_ = desktops_length1, _tmp1_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_KEY_FILE_ERROR) {
- goto __catch11_g_key_file_error;
+ goto __catch13_g_key_file_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -270,8 +270,8 @@ static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB*
desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
return result;
}
- goto __finally11;
- __catch11_g_key_file_error:
+ goto __finally13;
+ __catch13_g_key_file_error:
{
GError * _error_;
_error_ = _inner_error_;
@@ -283,7 +283,7 @@ static gboolean familiar_players_db_load_data_from_key_file (FamiliarPlayersDB*
return result;
}
}
- __finally11:
+ __finally13:
{
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -338,8 +338,8 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
char* _tmp4_;
data = (_tmp4_ = g_key_file_to_data (keyfile, &data_length, NULL), _g_free0 (data), _tmp4_);
}
- goto __finally12;
- __catch12_g_key_file_error:
+ goto __finally14;
+ __catch14_g_key_file_error:
{
GError * e;
e = _inner_error_;
@@ -354,7 +354,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
return result;
}
}
- __finally12:
+ __finally14:
if (_inner_error_ != NULL) {
_g_free0 (data);
desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
@@ -376,7 +376,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
_tmp5_ = g_file_set_contents (self->priv->file_name, data, (gssize) data_length, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_FILE_ERROR) {
- goto __catch13_g_file_error;
+ goto __catch15_g_file_error;
}
_g_free0 (data);
desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
@@ -389,8 +389,8 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
g_warning ("familiar-players-db.vala:125: Unable to write out file '%s'", self->priv->file_name);
}
}
- goto __finally13;
- __catch13_g_file_error:
+ goto __finally15;
+ __catch15_g_file_error:
{
GError * err;
err = _inner_error_;
@@ -400,7 +400,7 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
_g_error_free0 (err);
}
}
- __finally13:
+ __finally15:
if (_inner_error_ != NULL) {
_g_free0 (data);
desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala
index 2bc0a3c..894447c 100644
--- a/src/familiar-players-db.vala
+++ b/src/familiar-players-db.vala
@@ -83,7 +83,7 @@ public class FamiliarPlayersDB : GLib.Object
private bool load_data_from_key_file(){
try{
string[] desktops = this.key_file.get_string_list(GROUP_NAME,
- KEY_NAME);
+ KEY_NAME);
foreach(string s in desktops){
this.players_DB.set(s, true);
}
diff --git a/src/fetch-file.c b/src/fetch-file.c
new file mode 100644
index 0000000..76e987d
--- /dev/null
+++ b/src/fetch-file.c
@@ -0,0 +1,480 @@
+/* fetch-file.c generated by valac 0.9.8, the Vala compiler
+ * generated from fetch-file.vala, do not modify */
+
+/*
+ * Copyright (C) 2010 Canonical, Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License
+ * version 3.0 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3.0 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors
+ * Gordon Allott <gord.allott@canonical.com>
+ * Conor Curran <conor.curran@canonical.com>
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gio/gio.h>
+
+
+#define TYPE_FETCH_FILE (fetch_file_get_type ())
+#define FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FETCH_FILE, FetchFile))
+#define FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FETCH_FILE, FetchFileClass))
+#define IS_FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FETCH_FILE))
+#define IS_FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FETCH_FILE))
+#define FETCH_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FETCH_FILE, FetchFileClass))
+
+typedef struct _FetchFile FetchFile;
+typedef struct _FetchFileClass FetchFileClass;
+typedef struct _FetchFilePrivate FetchFilePrivate;
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_byte_array_free0(var) ((var == NULL) ? NULL : (var = (g_byte_array_free (var, TRUE), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+typedef struct _FetchFileFetchDataData FetchFileFetchDataData;
+typedef struct _FetchFileReadSomethingAsyncData FetchFileReadSomethingAsyncData;
+
+struct _FetchFile {
+ GObject parent_instance;
+ FetchFilePrivate * priv;
+};
+
+struct _FetchFileClass {
+ GObjectClass parent_class;
+};
+
+struct _FetchFilePrivate {
+ char* _uri;
+ char* _intended_property;
+ GDataInputStream* stream;
+ GFile* file;
+ GByteArray* data;
+};
+
+struct _FetchFileFetchDataData {
+ int _state_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ FetchFile* self;
+ GFileInputStream* _tmp0_;
+ GFileInputStream* _tmp1_;
+ GDataInputStream* _tmp2_;
+ GError * e;
+ GError * _inner_error_;
+};
+
+struct _FetchFileReadSomethingAsyncData {
+ int _state_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ FetchFile* self;
+ gssize size;
+ guint8* buffer;
+ gint buffer_length1;
+ gint _buffer_size_;
+ guint8* _tmp0_;
+ gssize bufsize;
+ gboolean _tmp1_;
+ gssize _tmp2_;
+ guint8* cpybuf;
+ gint cpybuf_length1;
+ gint _cpybuf_size_;
+ guint8* _tmp3_;
+ GError * e;
+ GError * _inner_error_;
+};
+
+
+static gpointer fetch_file_parent_class = NULL;
+
+GType fetch_file_get_type (void) G_GNUC_CONST;
+#define FETCH_FILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FETCH_FILE, FetchFilePrivate))
+enum {
+ FETCH_FILE_DUMMY_PROPERTY,
+ FETCH_FILE_URI,
+ FETCH_FILE_INTENDED_PROPERTY
+};
+FetchFile* fetch_file_new (const char* uri, const char* prop);
+FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop);
+static void fetch_file_fetch_data_data_free (gpointer _data);
+static void fetch_file_fetch_data_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_);
+static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data);
+static void fetch_file_read_something_async (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static void fetch_file_read_something_finish (FetchFile* self, GAsyncResult* _res_);
+static void fetch_file_read_something_async_data_free (gpointer _data);
+static void fetch_file_read_something_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* data);
+const char* fetch_file_get_intended_property (FetchFile* self);
+const char* fetch_file_get_uri (FetchFile* self);
+static void fetch_file_set_uri (FetchFile* self, const char* value);
+static void fetch_file_set_intended_property (FetchFile* self, const char* value);
+static GObject * fetch_file_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
+static void fetch_file_finalize (GObject* obj);
+static void fetch_file_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
+static void fetch_file_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
+
+
+static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
+
+FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop) {
+ FetchFile * self;
+ g_return_val_if_fail (uri != NULL, NULL);
+ g_return_val_if_fail (prop != NULL, NULL);
+ self = (FetchFile*) g_object_new (object_type, "uri", uri, "intended-property", prop, NULL);
+ return self;
+}
+
+
+FetchFile* fetch_file_new (const char* uri, const char* prop) {
+ return fetch_file_construct (TYPE_FETCH_FILE, uri, prop);
+}
+
+
+static void fetch_file_fetch_data_data_free (gpointer _data) {
+ FetchFileFetchDataData* data;
+ data = _data;
+ g_object_unref (data->self);
+ g_slice_free (FetchFileFetchDataData, data);
+}
+
+
+void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ FetchFileFetchDataData* _data_;
+ _data_ = g_slice_new0 (FetchFileFetchDataData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fetch_file_fetch_data);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fetch_file_fetch_data_data_free);
+ _data_->self = g_object_ref (self);
+ fetch_file_fetch_data_co (_data_);
+}
+
+
+void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_) {
+ FetchFileFetchDataData* _data_;
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static void fetch_file_fetch_data_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ FetchFileFetchDataData* data;
+ data = _user_data_;
+ data->_res_ = _res_;
+ fetch_file_fetch_data_co (data);
+}
+
+
+static gboolean fetch_file_fetch_data_co (FetchFileFetchDataData* data) {
+ switch (data->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ {
+ data->_tmp0_ = g_file_read (data->self->priv->file, NULL, &data->_inner_error_);
+ if (data->_inner_error_ != NULL) {
+ goto __catch16_g_error;
+ }
+ data->self->priv->stream = (data->_tmp2_ = g_data_input_stream_new ((GInputStream*) (data->_tmp1_ = data->_tmp0_)), _g_object_unref0 (data->self->priv->stream), data->_tmp2_);
+ _g_object_unref0 (data->_tmp1_);
+ g_data_input_stream_set_byte_order (data->self->priv->stream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
+ }
+ goto __finally16;
+ __catch16_g_error:
+ {
+ data->e = data->_inner_error_;
+ data->_inner_error_ = NULL;
+ {
+ g_signal_emit_by_name (data->self, "failed");
+ _g_error_free0 (data->e);
+ }
+ }
+ __finally16:
+ if (data->_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code);
+ g_clear_error (&data->_inner_error_);
+ return FALSE;
+ }
+ fetch_file_read_something_async (data->self, NULL, NULL);
+ {
+ if (data->_state_ == 0) {
+ g_simple_async_result_complete_in_idle (data->_async_result);
+ } else {
+ g_simple_async_result_complete (data->_async_result);
+ }
+ g_object_unref (data->_async_result);
+ return FALSE;
+ }
+}
+
+
+static void fetch_file_read_something_async_data_free (gpointer _data) {
+ FetchFileReadSomethingAsyncData* data;
+ data = _data;
+ g_object_unref (data->self);
+ g_slice_free (FetchFileReadSomethingAsyncData, data);
+}
+
+
+static void fetch_file_read_something_async (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ FetchFileReadSomethingAsyncData* _data_;
+ _data_ = g_slice_new0 (FetchFileReadSomethingAsyncData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, fetch_file_read_something_async);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, fetch_file_read_something_async_data_free);
+ _data_->self = g_object_ref (self);
+ fetch_file_read_something_async_co (_data_);
+}
+
+
+static void fetch_file_read_something_finish (FetchFile* self, GAsyncResult* _res_) {
+ FetchFileReadSomethingAsyncData* _data_;
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static void fetch_file_read_something_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ FetchFileReadSomethingAsyncData* data;
+ data = _user_data_;
+ data->_res_ = _res_;
+ fetch_file_read_something_async_co (data);
+}
+
+
+static gboolean fetch_file_read_something_async_co (FetchFileReadSomethingAsyncData* data) {
+ switch (data->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ case 1:
+ goto _state_1;
+ }
+ _state_0:
+ data->size = (gssize) 1024;
+ data->buffer = (data->_tmp0_ = g_new0 (guint8, data->size), data->buffer_length1 = data->size, data->_buffer_size_ = data->buffer_length1, data->_tmp0_);
+ data->bufsize = (gssize) 1;
+ {
+ data->_tmp1_ = TRUE;
+ while (TRUE) {
+ if (!data->_tmp1_) {
+ if (!(data->bufsize > 0)) {
+ break;
+ }
+ }
+ data->_tmp1_ = FALSE;
+ {
+ data->_state_ = 1;
+ g_input_stream_read_async ((GInputStream*) data->self->priv->stream, data->buffer, (gsize) data->size, G_PRIORITY_DEFAULT, NULL, fetch_file_read_something_async_ready, data);
+ return FALSE;
+ _state_1:
+ data->_tmp2_ = g_input_stream_read_finish ((GInputStream*) data->self->priv->stream, data->_res_, &data->_inner_error_);
+ if (data->_inner_error_ != NULL) {
+ goto __catch17_g_error;
+ }
+ data->bufsize = data->_tmp2_;
+ if (data->bufsize < 1) {
+ break;
+ }
+ if (data->bufsize != data->size) {
+ data->cpybuf = (data->_tmp3_ = g_new0 (guint8, data->bufsize), data->cpybuf_length1 = data->bufsize, data->_cpybuf_size_ = data->cpybuf_length1, data->_tmp3_);
+ memcpy (data->cpybuf, data->buffer, (gsize) data->bufsize);
+ g_byte_array_append (data->self->priv->data, data->cpybuf, data->cpybuf_length1);
+ data->cpybuf = (g_free (data->cpybuf), NULL);
+ } else {
+ g_byte_array_append (data->self->priv->data, data->buffer, data->buffer_length1);
+ }
+ }
+ goto __finally17;
+ __catch17_g_error:
+ {
+ data->e = data->_inner_error_;
+ data->_inner_error_ = NULL;
+ {
+ g_signal_emit_by_name (data->self, "failed");
+ _g_error_free0 (data->e);
+ }
+ }
+ __finally17:
+ if (data->_inner_error_ != NULL) {
+ data->buffer = (g_free (data->buffer), NULL);
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code);
+ g_clear_error (&data->_inner_error_);
+ return FALSE;
+ }
+ }
+ }
+ g_signal_emit_by_name (data->self, "completed", data->self->priv->data, data->self->priv->_intended_property);
+ data->buffer = (g_free (data->buffer), NULL);
+ {
+ if (data->_state_ == 0) {
+ g_simple_async_result_complete_in_idle (data->_async_result);
+ } else {
+ g_simple_async_result_complete (data->_async_result);
+ }
+ g_object_unref (data->_async_result);
+ return FALSE;
+ }
+}
+
+
+const char* fetch_file_get_uri (FetchFile* self) {
+ const char* result;
+ g_return_val_if_fail (self != NULL, NULL);
+ result = self->priv->_uri;
+ return result;
+}
+
+
+static void fetch_file_set_uri (FetchFile* self, const char* value) {
+ char* _tmp0_;
+ g_return_if_fail (self != NULL);
+ self->priv->_uri = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_uri), _tmp0_);
+ g_object_notify ((GObject *) self, "uri");
+}
+
+
+const char* fetch_file_get_intended_property (FetchFile* self) {
+ const char* result;
+ g_return_val_if_fail (self != NULL, NULL);
+ result = self->priv->_intended_property;
+ return result;
+}
+
+
+static void fetch_file_set_intended_property (FetchFile* self, const char* value) {
+ char* _tmp0_;
+ g_return_if_fail (self != NULL);
+ self->priv->_intended_property = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_intended_property), _tmp0_);
+ g_object_notify ((GObject *) self, "intended-property");
+}
+
+
+static GObject * fetch_file_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ GObjectClass * parent_class;
+ FetchFile * self;
+ parent_class = G_OBJECT_CLASS (fetch_file_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = FETCH_FILE (obj);
+ {
+ GFile* _tmp0_;
+ GByteArray* _tmp1_;
+ self->priv->file = (_tmp0_ = g_file_new_for_uri (self->priv->_uri), _g_object_unref0 (self->priv->file), _tmp0_);
+ self->priv->data = (_tmp1_ = g_byte_array_new (), _g_byte_array_free0 (self->priv->data), _tmp1_);
+ }
+ return obj;
+}
+
+
+static void fetch_file_class_init (FetchFileClass * klass) {
+ fetch_file_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (FetchFilePrivate));
+ G_OBJECT_CLASS (klass)->get_property = fetch_file_get_property;
+ G_OBJECT_CLASS (klass)->set_property = fetch_file_set_property;
+ G_OBJECT_CLASS (klass)->constructor = fetch_file_constructor;
+ G_OBJECT_CLASS (klass)->finalize = fetch_file_finalize;
+ g_object_class_install_property (G_OBJECT_CLASS (klass), FETCH_FILE_URI, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), FETCH_FILE_INTENDED_PROPERTY, g_param_spec_string ("intended-property", "intended-property", "intended-property", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+ g_signal_new ("failed", TYPE_FETCH_FILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("completed", TYPE_FETCH_FILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__POINTER_STRING, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING);
+}
+
+
+static void fetch_file_instance_init (FetchFile * self) {
+ self->priv = FETCH_FILE_GET_PRIVATE (self);
+}
+
+
+static void fetch_file_finalize (GObject* obj) {
+ FetchFile * self;
+ self = FETCH_FILE (obj);
+ _g_free0 (self->priv->_uri);
+ _g_free0 (self->priv->_intended_property);
+ _g_object_unref0 (self->priv->stream);
+ _g_object_unref0 (self->priv->file);
+ _g_byte_array_free0 (self->priv->data);
+ G_OBJECT_CLASS (fetch_file_parent_class)->finalize (obj);
+}
+
+
+GType fetch_file_get_type (void) {
+ static volatile gsize fetch_file_type_id__volatile = 0;
+ if (g_once_init_enter (&fetch_file_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (FetchFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fetch_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FetchFile), 0, (GInstanceInitFunc) fetch_file_instance_init, NULL };
+ GType fetch_file_type_id;
+ fetch_file_type_id = g_type_register_static (G_TYPE_OBJECT, "FetchFile", &g_define_type_info, 0);
+ g_once_init_leave (&fetch_file_type_id__volatile, fetch_file_type_id);
+ }
+ return fetch_file_type_id__volatile;
+}
+
+
+static void fetch_file_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
+ FetchFile * self;
+ self = FETCH_FILE (object);
+ switch (property_id) {
+ case FETCH_FILE_URI:
+ g_value_set_string (value, fetch_file_get_uri (self));
+ break;
+ case FETCH_FILE_INTENDED_PROPERTY:
+ g_value_set_string (value, fetch_file_get_intended_property (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void fetch_file_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
+ FetchFile * self;
+ self = FETCH_FILE (object);
+ switch (property_id) {
+ case FETCH_FILE_URI:
+ fetch_file_set_uri (self, g_value_get_string (value));
+ break;
+ case FETCH_FILE_INTENDED_PROPERTY:
+ fetch_file_set_intended_property (self, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+
+static void g_cclosure_user_marshal_VOID__POINTER_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
+ typedef void (*GMarshalFunc_VOID__POINTER_STRING) (gpointer data1, gpointer arg_1, const char* arg_2, gpointer data2);
+ register GMarshalFunc_VOID__POINTER_STRING callback;
+ register GCClosure * cc;
+ register gpointer data1, data2;
+ cc = (GCClosure *) closure;
+ g_return_if_fail (n_param_values == 3);
+ if (G_CCLOSURE_SWAP_DATA (closure)) {
+ data1 = closure->data;
+ data2 = param_values->data[0].v_pointer;
+ } else {
+ data1 = param_values->data[0].v_pointer;
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__POINTER_STRING) (marshal_data ? marshal_data : cc->callback);
+ callback (data1, g_value_get_pointer (param_values + 1), g_value_get_string (param_values + 2), data2);
+}
+
+
+
diff --git a/src/fetch-file.vala b/src/fetch-file.vala
new file mode 100644
index 0000000..1811cc1
--- /dev/null
+++ b/src/fetch-file.vala
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Canonical, Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License
+ * version 3.0 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3.0 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors
+ * Gordon Allott <gord.allott@canonical.com>
+ * Conor Curran <conor.curran@canonical.com>
+ */
+
+public class FetchFile : Object
+{
+ /* public variables */
+ public string uri {get; construct;}
+ public string intended_property {get; construct;}
+
+ /* private variables */
+ private DataInputStream stream;
+ private File? file;
+ private ByteArray data;
+
+ /* public signals */
+ public signal void failed ();
+ public signal void completed (ByteArray data, string property);
+
+ public FetchFile (string uri, string prop)
+ {
+ Object (uri: uri, intended_property: prop);
+ }
+
+ construct
+ {
+ this.file = File.new_for_uri(this.uri);
+ this.data = new ByteArray ();
+ }
+
+ public async void fetch_data ()
+ {
+ try {
+ this.stream = new DataInputStream(this.file.read(null));
+ this.stream.set_byte_order (DataStreamByteOrder.LITTLE_ENDIAN);
+ } catch (GLib.Error e) {
+ this.failed ();
+ }
+ this.read_something_async ();
+ }
+
+ private async void read_something_async ()
+ {
+ ssize_t size = 1024;
+ uint8[] buffer = new uint8[size];
+
+ ssize_t bufsize = 1;
+ do {
+ try {
+ bufsize = yield this.stream.read_async (buffer, size, GLib.Priority.DEFAULT, null);
+ if (bufsize < 1) { break;}
+
+ if (bufsize != size)
+ {
+ uint8[] cpybuf = new uint8[bufsize];
+ Memory.copy (cpybuf, buffer, bufsize);
+ this.data.append (cpybuf);
+ }
+ else
+ {
+ this.data.append (buffer);
+ }
+ } catch (Error e) {
+ this.failed ();
+ }
+ } while (bufsize > 0);
+ this.completed (this.data, this.intended_property);
+ }
+}
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 63ad72d..b59eb98 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -67,6 +67,8 @@ G_DEFINE_TYPE (IndicatorSound, indicator_sound, INDICATOR_OBJECT_TYPE);
static GtkLabel * get_label (IndicatorObject * io);
static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
+static void indicator_sound_scroll (IndicatorObject* io, gint delta, IndicatorScrollDirection direction);
+
//Slider related
static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client);
@@ -135,7 +137,7 @@ indicator_sound_class_init (IndicatorSoundClass *klass)
io_class->get_label = get_label;
io_class->get_image = get_icon;
io_class->get_menu = get_menu;
-
+ io_class->scroll = indicator_sound_scroll;
design_team_size = gtk_icon_size_register("design-team-size", 22, 22);
return;
@@ -493,7 +495,6 @@ start_animation()
{
blocked_iter = blocked_animation_list;
blocked_id = 0;
- //g_debug("exit from blocked hold start the animation\n");
animation_id = g_timeout_add(50, fade_back_to_mute_image, NULL);
return FALSE;
}
@@ -502,7 +503,6 @@ static gboolean
fade_back_to_mute_image()
{
if (blocked_iter != NULL) {
- g_debug("in animation 'loop'\n");
gtk_image_set_from_pixbuf(speaker_image, blocked_iter->data);
blocked_iter = blocked_iter->next;
return TRUE;
@@ -710,3 +710,28 @@ style_changed_cb(GtkWidget *widget, gpointer user_data)
free_the_animation_list();
prepare_blocked_animation();
}
+
+static void
+indicator_sound_scroll (IndicatorObject *io, gint delta, IndicatorScrollDirection direction)
+{
+ g_debug("indicator-sound-scroll - current slider value");
+
+ if (device_available == FALSE || current_state == STATE_MUTED)
+ return;
+
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+
+ GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
+ GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);
+ GtkRange* range = (GtkRange*)slider;
+ gdouble value = gtk_range_get_value(range);
+ GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider));
+ g_debug("indicator-sound-scroll - current slider value %f", value);
+ if (direction == INDICATOR_OBJECT_SCROLL_UP) {
+ value += adj->step_increment;
+ } else {
+ value -= adj->step_increment;
+ }
+ g_debug("indicator-sound-scroll - update slider with value %f", value);
+ volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value);
+} \ No newline at end of file
diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c
index 311057e..07f18e5 100644
--- a/src/metadata-menu-item.c
+++ b/src/metadata-menu-item.c
@@ -1,4 +1,4 @@
-/* metadata-menu-item.c generated by valac 0.9.7, the Vala compiler
+/* metadata-menu-item.c generated by valac 0.9.8, the Vala compiler
* generated from metadata-menu-item.vala, do not modify */
/*
@@ -26,10 +26,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/menuitem-proxy.h>
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
-#include <common-defs.h>
-#include <gee.h>
#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>
#define TYPE_PLAYER_ITEM (player_item_get_type ())
@@ -53,7 +56,19 @@ typedef struct _PlayerItemPrivate PlayerItemPrivate;
typedef struct _MetadataMenuitem MetadataMenuitem;
typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
typedef struct _MetadataMenuitemPrivate MetadataMenuitemPrivate;
+
+#define TYPE_FETCH_FILE (fetch_file_get_type ())
+#define FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FETCH_FILE, FetchFile))
+#define FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FETCH_FILE, FetchFileClass))
+#define IS_FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FETCH_FILE))
+#define IS_FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FETCH_FILE))
+#define FETCH_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FETCH_FILE, FetchFileClass))
+
+typedef struct _FetchFile FetchFile;
+typedef struct _FetchFileClass FetchFileClass;
+#define _g_free0(var) (var = (g_free (var), NULL))
#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)))
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
@@ -73,18 +88,44 @@ struct _MetadataMenuitemClass {
PlayerItemClass parent_class;
};
+struct _MetadataMenuitemPrivate {
+ char* previous_temp_album_art_path;
+};
+
+extern char* metadata_menuitem_album_art_cache_dir;
+char* metadata_menuitem_album_art_cache_dir = NULL;
+static FetchFile* metadata_menuitem_fetcher;
+static FetchFile* metadata_menuitem_fetcher = NULL;
static gpointer metadata_menuitem_parent_class = NULL;
GType player_item_get_type (void) G_GNUC_CONST;
GType metadata_menuitem_get_type (void) G_GNUC_CONST;
+#define METADATA_MENUITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_METADATA_MENUITEM, MetadataMenuitemPrivate))
enum {
METADATA_MENUITEM_DUMMY_PROPERTY
};
+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);
+static void metadata_menuitem_clean_album_art_temp_dir (void);
+static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir);
+static char* metadata_menuitem_create_album_art_temp_dir (void);
+void metadata_menuitem_fetch_art (MetadataMenuitem* self, const char* uri, const char* prop);
+FetchFile* fetch_file_new (const char* uri, const char* prop);
+FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop);
+static void _lambda0_ (MetadataMenuitem* self);
+static void metadata_menuitem_on_fetcher_failed (MetadataMenuitem* self);
+static void __lambda0__fetch_file_failed (FetchFile* _sender, gpointer self);
+static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByteArray* update, const char* property);
+static void _metadata_menuitem_on_fetcher_completed_fetch_file_completed (FetchFile* _sender, GByteArray* data, const char* 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 GObject * metadata_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
+static void metadata_menuitem_finalize (GObject* obj);
@@ -103,6 +144,296 @@ MetadataMenuitem* metadata_menuitem_new (void) {
}
+static void metadata_menuitem_clean_album_art_temp_dir (void) {
+ char* path;
+ GFile* album_art_dir;
+ path = g_build_filename (g_get_user_cache_dir (), METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX, NULL);
+ album_art_dir = g_file_new_for_path (path);
+ if (metadata_menuitem_delete_album_art_contents (album_art_dir) == FALSE) {
+ g_warning ("metadata-menu-item.vala:52: could not remove the temp album art files " \
+"%s", path);
+ }
+ _g_object_unref0 (album_art_dir);
+ _g_free0 (path);
+}
+
+
+static char* metadata_menuitem_create_album_art_temp_dir (void) {
+ char* result = NULL;
+ char* path;
+ path = g_build_filename (g_get_user_cache_dir (), METADATA_MENUITEM_ALBUM_ART_DIR_SUFFIX, NULL);
+ if (g_mkdir (path, 0700) == (-1)) {
+ g_warning ("metadata-menu-item.vala:60: could not create a temp dir for remote alb" \
+"um art, it must have been created already");
+ }
+ result = path;
+ return result;
+}
+
+
+static const char* string_to_string (const char* self) {
+ const char* result = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ result = self;
+ return result;
+}
+
+
+static gboolean metadata_menuitem_delete_album_art_contents (GFile* dir) {
+ gboolean result = FALSE;
+ gboolean _result_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (dir != NULL, FALSE);
+ _result_ = TRUE;
+ {
+ GFileEnumerator* e;
+ e = g_file_enumerate_children (dir, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch0_g_error;
+ }
+ while (TRUE) {
+ GFileInfo* file;
+ GFile* child;
+ file = g_file_enumerator_next_file (e, NULL, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (e);
+ goto __catch0_g_error;
+ }
+ g_debug ("metadata-menu-item.vala:76: file name = %s", g_file_info_get_name (file));
+ if (file == NULL) {
+ _g_object_unref0 (file);
+ break;
+ }
+ child = g_file_get_child (dir, g_file_info_get_name (file));
+ {
+ g_file_delete (child, NULL, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch1_g_error;
+ }
+ }
+ goto __finally1;
+ __catch1_g_error:
+ {
+ GError * error_;
+ error_ = _inner_error_;
+ _inner_error_ = NULL;
+ {
+ char* _tmp0_;
+ char* _tmp1_;
+ g_warning ("metadata-menu-item.vala:86: %s", _tmp1_ = g_strconcat ("Unable to delete file '", string_to_string (_tmp0_ = g_file_get_basename (child)), ": ", string_to_string (error_->message), NULL));
+ _g_free0 (_tmp1_);
+ _g_free0 (_tmp0_);
+ _result_ = FALSE;
+ _g_error_free0 (error_);
+ }
+ }
+ __finally1:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (child);
+ _g_object_unref0 (file);
+ _g_object_unref0 (e);
+ goto __catch0_g_error;
+ }
+ _g_object_unref0 (child);
+ _g_object_unref0 (file);
+ }
+ _g_object_unref0 (e);
+ }
+ goto __finally0;
+ __catch0_g_error:
+ {
+ GError * _error_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ {
+ char* _tmp2_;
+ char* _tmp3_;
+ g_warning (_tmp3_ = g_strconcat ("Unable to read files from directory '", string_to_string (_tmp2_ = g_file_get_basename (dir)), "': %s", NULL), _error_->message);
+ _g_free0 (_tmp3_);
+ _g_free0 (_tmp2_);
+ _result_ = FALSE;
+ _g_error_free0 (_error_);
+ }
+ }
+ __finally0:
+ if (_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return FALSE;
+ }
+ result = _result_;
+ return result;
+}
+
+
+static char* string_strip (const char* self) {
+ char* result = NULL;
+ char* _result_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _result_ = g_strdup (self);
+ g_strstrip (_result_);
+ result = _result_;
+ return result;
+}
+
+
+static void _lambda0_ (MetadataMenuitem* self) {
+ metadata_menuitem_on_fetcher_failed (self);
+}
+
+
+static void __lambda0__fetch_file_failed (FetchFile* _sender, gpointer self) {
+ _lambda0_ (self);
+}
+
+
+static void _metadata_menuitem_on_fetcher_completed_fetch_file_completed (FetchFile* _sender, GByteArray* data, const char* property, gpointer self) {
+ metadata_menuitem_on_fetcher_completed (self, data, property);
+}
+
+
+void metadata_menuitem_fetch_art (MetadataMenuitem* self, const char* uri, const char* prop) {
+ GFile* art_file;
+ FetchFile* _tmp4_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (uri != NULL);
+ g_return_if_fail (prop != NULL);
+ art_file = g_file_new_for_uri (uri);
+ if (g_file_is_native (art_file) == TRUE) {
+ char* path;
+ path = NULL;
+ {
+ char* _tmp0_;
+ char* _tmp1_;
+ char* _tmp2_;
+ char* _tmp3_;
+ _tmp2_ = (_tmp1_ = g_filename_from_uri (_tmp0_ = string_strip (uri), NULL, &_inner_error_), _g_free0 (_tmp0_), _tmp1_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_CONVERT_ERROR) {
+ goto __catch2_g_convert_error;
+ }
+ _g_free0 (path);
+ _g_object_unref0 (art_file);
+ g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return;
+ }
+ path = (_tmp3_ = _tmp2_, _g_free0 (path), _tmp3_);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, prop, path);
+ }
+ goto __finally2;
+ __catch2_g_convert_error:
+ {
+ GError * e;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ {
+ g_warning ("metadata-menu-item.vala:108: Problem converting URI %s to file path", uri);
+ _g_error_free0 (e);
+ }
+ }
+ __finally2:
+ if (_inner_error_ != NULL) {
+ _g_free0 (path);
+ _g_object_unref0 (art_file);
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return;
+ }
+ _g_free0 (path);
+ _g_object_unref0 (art_file);
+ return;
+ }
+ g_debug ("metadata-menu-item.vala:114: fetch_art -remotely %s", metadata_menuitem_album_art_cache_dir);
+ if (metadata_menuitem_album_art_cache_dir == NULL) {
+ _g_object_unref0 (art_file);
+ return;
+ }
+ metadata_menuitem_fetcher = (_tmp4_ = fetch_file_new (uri, prop), _g_object_unref0 (metadata_menuitem_fetcher), _tmp4_);
+ 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);
+ _g_object_unref0 (art_file);
+}
+
+
+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" \
+"ork");
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void metadata_menuitem_on_fetcher_completed (MetadataMenuitem* self, GByteArray* update, const char* property) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (update != NULL);
+ g_return_if_fail (property != NULL);
+ {
+ GdkPixbufLoader* loader;
+ GdkPixbuf* icon;
+ char* path;
+ gint r;
+ loader = gdk_pixbuf_loader_new ();
+ gdk_pixbuf_loader_write (loader, update->data, (gsize) update->len, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (loader);
+ goto __catch3_g_error;
+ }
+ gdk_pixbuf_loader_close (loader, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (loader);
+ goto __catch3_g_error;
+ }
+ icon = _g_object_ref0 (gdk_pixbuf_loader_get_pixbuf (loader));
+ path = g_strconcat (metadata_menuitem_album_art_cache_dir, "/downloaded-coverart-XXXXXX", NULL);
+ r = g_mkstemp (path);
+ if (r != (-1)) {
+ char* _tmp0_;
+ gdk_pixbuf_save (icon, path, gdk_pixbuf_format_get_name (gdk_pixbuf_loader_get_format (loader)), &_inner_error_, NULL);
+ if (_inner_error_ != NULL) {
+ _g_free0 (path);
+ _g_object_unref0 (icon);
+ _g_object_unref0 (loader);
+ goto __catch3_g_error;
+ }
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, property, path);
+ if (self->priv->previous_temp_album_art_path != NULL) {
+ g_remove (self->priv->previous_temp_album_art_path);
+ }
+ self->priv->previous_temp_album_art_path = (_tmp0_ = g_strdup (path), _g_free0 (self->priv->previous_temp_album_art_path), _tmp0_);
+ }
+ _g_free0 (path);
+ _g_object_unref0 (icon);
+ _g_object_unref0 (loader);
+ }
+ goto __finally3;
+ __catch3_g_error:
+ {
+ GError * e;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ {
+ g_warning ("metadata-menu-item.vala:151: Problem creating file from bytearray fetc" \
+"hed from the interweb - error: %s", e->message);
+ _g_error_free0 (e);
+ }
+ }
+ __finally3:
+ if (_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return;
+ }
+}
+
+
GeeHashSet* metadata_menuitem_attributes_format (void) {
GeeHashSet* result = NULL;
GeeHashSet* attrs;
@@ -116,12 +447,42 @@ GeeHashSet* metadata_menuitem_attributes_format (void) {
}
+static GObject * metadata_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
+ GObject * obj;
+ GObjectClass * parent_class;
+ MetadataMenuitem * self;
+ parent_class = G_OBJECT_CLASS (metadata_menuitem_parent_class);
+ obj = parent_class->constructor (type, n_construct_properties, construct_properties);
+ self = METADATA_MENUITEM (obj);
+ {
+ char* _tmp0_;
+ char* _tmp1_;
+ metadata_menuitem_clean_album_art_temp_dir ();
+ self->priv->previous_temp_album_art_path = (_tmp0_ = NULL, _g_free0 (self->priv->previous_temp_album_art_path), _tmp0_);
+ metadata_menuitem_album_art_cache_dir = (_tmp1_ = metadata_menuitem_create_album_art_temp_dir (), _g_free0 (metadata_menuitem_album_art_cache_dir), _tmp1_);
+ }
+ return obj;
+}
+
+
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));
+ G_OBJECT_CLASS (klass)->constructor = metadata_menuitem_constructor;
+ G_OBJECT_CLASS (klass)->finalize = metadata_menuitem_finalize;
}
static void metadata_menuitem_instance_init (MetadataMenuitem * self) {
+ self->priv = METADATA_MENUITEM_GET_PRIVATE (self);
+}
+
+
+static void metadata_menuitem_finalize (GObject* obj) {
+ MetadataMenuitem * self;
+ self = METADATA_MENUITEM (obj);
+ _g_free0 (self->priv->previous_temp_album_art_path);
+ G_OBJECT_CLASS (metadata_menuitem_parent_class)->finalize (obj);
}
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 0bb4a85..3f71653 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -17,18 +17,141 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using Dbusmenu;
using Gee;
using DbusmenuMetadata;
+using Gdk;
public class MetadataMenuitem : PlayerItem
{
+ public const string ALBUM_ART_DIR_SUFFIX = "indicators/sound/album-art-cache";
+
+ public static string album_art_cache_dir;
+ private static FetchFile fetcher;
+ private string previous_temp_album_art_path;
+
public MetadataMenuitem()
{
Object(item_type: MENUITEM_TYPE);
reset(attributes_format());
}
+
+ construct{
+ MetadataMenuitem.clean_album_art_temp_dir();
+ this.previous_temp_album_art_path = null;
+ this.album_art_cache_dir = MetadataMenuitem.create_album_art_temp_dir();
+ }
+ private static void clean_album_art_temp_dir()
+ {
+ string path = GLib.Path.build_filename(Environment.get_user_cache_dir(), ALBUM_ART_DIR_SUFFIX);
+
+ GLib.File? album_art_dir = GLib.File.new_for_path(path);
+
+ if(delete_album_art_contents(album_art_dir) == false)
+ {
+ warning("could not remove the temp album art files %s", path);
+ }
+ }
+
+ private static string? create_album_art_temp_dir()
+ {
+ string path = GLib.Path.build_filename(Environment.get_user_cache_dir(), ALBUM_ART_DIR_SUFFIX);
+ if(DirUtils.create(path, 0700) == -1){
+ warning("could not create a temp dir for remote album art, it must have been created already");
+ }
+ return path;
+ }
+
+ private static bool delete_album_art_contents (GLib.File dir)
+ {
+ bool result = true;
+ try {
+ var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME,
+ FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
+ null);
+ while (true)
+ {
+ var file = e.next_file (null);
+
+ debug("file name = %s", file.get_name());
+
+ if (file == null)
+ break;
+
+ var child = dir.get_child (file.get_name ());
+
+ try {
+ child.delete (null);
+ } catch (Error error_) {
+ warning (@"Unable to delete file '$(child.get_basename ()): $(error_.message)");
+ result = false;
+ }
+ }
+ } catch (Error error) {
+ warning (@"Unable to read files from directory '$(dir.get_basename ())': %s",
+ error.message);
+ result = false;
+ }
+ return result;
+ }
+
+ public void fetch_art(string uri, string prop)
+ {
+ File art_file = File.new_for_uri(uri);
+ if(art_file.is_native() == true){
+ string path;
+ try{
+ path = Filename.from_uri(uri.strip());
+ this.property_set(prop, path);
+ }
+ catch(ConvertError e){
+ warning("Problem converting URI %s to file path",
+ uri);
+ }
+ // eitherway return, the artwork was local
+ return;
+ }
+ debug("fetch_art -remotely %s", this.album_art_cache_dir);
+ // If we didn't manage to create the temp dir
+ // don't bother with remote
+ if(this.album_art_cache_dir == null){
+ return;
+ }
+ // green light to go remote
+ this.fetcher = new FetchFile (uri, prop);
+ this.fetcher.failed.connect (() => { this.on_fetcher_failed ();});
+ this.fetcher.completed.connect (this.on_fetcher_completed);
+ this.fetcher.fetch_data ();
+ }
+
+ private void on_fetcher_failed ()
+ {
+ warning("on_fetcher_failed -> could not fetch artwork");
+ }
+
+ private void on_fetcher_completed(ByteArray update, string property)
+ {
+ try{
+ PixbufLoader loader = new PixbufLoader ();
+ loader.write (update.data, update.len);
+ loader.close ();
+ Pixbuf icon = loader.get_pixbuf ();
+ string path = this.album_art_cache_dir.concat("/downloaded-coverart-XXXXXX");
+ int r = FileUtils.mkstemp(path);
+ if(r != -1){
+ icon.save (path, loader.get_format().get_name());
+ this.property_set(property, path);
+ if(this.previous_temp_album_art_path != null){
+ FileUtils.remove(this.previous_temp_album_art_path);
+ }
+ this.previous_temp_album_art_path = path;
+ }
+ }
+ catch(GLib.Error e){
+ warning("Problem creating file from bytearray fetched from the interweb - error: %s",
+ e.message);
+ }
+ }
public static HashSet<string> attributes_format()
{
@@ -38,6 +161,5 @@ public class MetadataMenuitem : PlayerItem
attrs.add(MENUITEM_ALBUM);
attrs.add(MENUITEM_ARTURL);
return attrs;
- }
-
+ }
}
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index f600238..18ebd38 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -25,6 +25,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "metadata-widget.h"
#include "common-defs.h"
#include <gtk/gtk.h>
+#include <glib.h>
static DbusmenuMenuitem* twin_item;
@@ -69,7 +70,7 @@ static void image_set_from_pixbuf (GtkWidget *widget,
MetadataWidget* metadata,
GdkPixbuf *source);
-
+static void draw_album_art_placeholder(GtkWidget *metadata);
G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
@@ -160,7 +161,7 @@ metadata_widget_init (MetadataWidget *self)
g_signal_connect(self, "style-set", G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self));
- gtk_widget_set_size_request(GTK_WIDGET(self), 200, 60);
+ gtk_widget_set_size_request(GTK_WIDGET(self), 200, 65);
gtk_container_add (GTK_CONTAINER (self), hbox);
}
@@ -178,7 +179,7 @@ metadata_widget_finalize (GObject *object)
/**
* We override the expose method to enable primitive drawing of the
- * empty album art image (and soon rounded rectangles on the album art)
+ * empty album art image and rounded rectangles on the album art.
*/
static gboolean
metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user_data)
@@ -186,24 +187,33 @@ 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);
-
if(priv->image_path->len > 0){
-
- if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){
+ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){
GdkPixbuf* pixbuf;
pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
- g_debug("metadata_widget_expose, album art update -> pixbuf from %s",
- priv->image_path->str);
+ 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");
+ draw_album_art_placeholder(metadata);
+ return TRUE;
+ }
pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR);
image_set_from_pixbuf (metadata, widget, pixbuf);
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);
+ g_object_unref(pixbuf);
}
return FALSE;
}
-
+ draw_album_art_placeholder(metadata);
+ return TRUE;
+}
+
+static void draw_album_art_placeholder(GtkWidget *metadata)
+{
+
cairo_t *cr;
cr = gdk_cairo_create (metadata->window);
GtkAllocation alloc;
@@ -255,8 +265,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
g_object_unref(pcontext);
g_string_free (string, TRUE);
cairo_destroy (cr);
-
- return TRUE;
+
}
/* Suppress/consume keyevents */
@@ -314,7 +323,12 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
}
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){
g_string_erase(priv->image_path, 0, -1);
- g_string_overwrite(priv->image_path, 0, g_value_get_string (value));
+ g_string_overwrite(priv->image_path, 0, g_value_get_string (value));
+ // if its a remote image queue a redraw incase the download took too long
+ if (g_str_has_prefix(g_value_get_string (value), g_get_user_cache_dir())){
+ g_debug("the image update is a download so redraw");
+ gtk_widget_queue_draw(GTK_WIDGET(mitem));
+ }
}
}
@@ -348,10 +362,9 @@ rounded_rectangle (cairo_t *cr,
{
gdouble radius;
gdouble degrees;
-
+
radius = corner_radius / aspect;
degrees = G_PI / 180.0;
-
cairo_new_sub_path (cr);
cairo_arc (cr,
x + width - radius,
@@ -377,6 +390,7 @@ rounded_rectangle (cairo_t *cr,
radius,
180 * degrees,
270 * degrees);
+
cairo_close_path (cr);
}
@@ -401,12 +415,12 @@ image_set_from_pixbuf (GtkWidget *widget,
MetadataWidgetPrivate* priv = METADATA_WIDGET_GET_PRIVATE(metadata);
GtkImage* image = GTK_IMAGE(priv->album_art);
- frame_width = 5;
+ frame_width = 3;
w = gdk_pixbuf_get_width (source) + frame_width * 2;
h = gdk_pixbuf_get_height (source) + frame_width * 2;
- radius = w / 10;
+ radius = 10;
pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), w, h, -1);
bitmask = gdk_pixmap_new (gtk_widget_get_window (widget), w, h, 1);
diff --git a/src/mpris-bridge.c b/src/mpris-bridge.c
deleted file mode 100644
index d85ec3d..0000000
--- a/src/mpris-bridge.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* mpris-bridge.c generated by valac 0.9.7, the Vala compiler
- * generated from mpris-bridge.vala, do not modify */
-
-
-#include <glib.h>
-#include <glib-object.h>
-#include <stdlib.h>
-#include <string.h>
-#include <float.h>
-#include <math.h>
-
-
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-
-typedef struct _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
-typedef struct _MprisBridgePrivate MprisBridgePrivate;
-
-#define TYPE_MPRIS_CONTROLLER (mpris_controller_get_type ())
-#define MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CONTROLLER, MprisController))
-#define MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
-#define IS_MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CONTROLLER))
-#define IS_MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CONTROLLER))
-#define MPRIS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
-
-typedef struct _MprisController MprisController;
-typedef struct _MprisControllerClass MprisControllerClass;
-
-#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 MPRIS_BRIDGE_TYPE_MODE (mpris_bridge_mode_get_type ())
-#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-
-#define TYPE_PLAYER_CONTROLLER (player_controller_get_type ())
-#define PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_CONTROLLER, PlayerController))
-#define PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_CONTROLLER, PlayerControllerClass))
-#define IS_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_CONTROLLER))
-#define IS_PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_CONTROLLER))
-#define PLAYER_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_CONTROLLER, PlayerControllerClass))
-
-typedef struct _PlayerController PlayerController;
-typedef struct _PlayerControllerClass PlayerControllerClass;
-
-#define TRANSPORT_MENUITEM_TYPE_ACTION (transport_menuitem_action_get_type ())
-
-struct _MprisBridge {
- GObject parent_instance;
- MprisBridgePrivate * priv;
-};
-
-struct _MprisBridgeClass {
- GObjectClass parent_class;
-};
-
-typedef enum {
- MPRIS_BRIDGE_MODE_MPRIS_1,
- MPRIS_BRIDGE_MODE_MPRIS_2
-} MprisBridgemode;
-
-struct _MprisBridgePrivate {
- MprisController* mpris1_controller;
- Mpris2Controller* mpris2_controller;
- MprisBridgemode mode_in_use;
-};
-
-typedef enum {
- TRANSPORT_MENUITEM_ACTION_PREVIOUS,
- TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE,
- TRANSPORT_MENUITEM_ACTION_NEXT
-} TransportMenuitemaction;
-
-
-static gpointer mpris_bridge_parent_class = NULL;
-
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
-GType mpris_controller_get_type (void) G_GNUC_CONST;
-GType mpris2_controller_get_type (void) G_GNUC_CONST;
-static GType mpris_bridge_mode_get_type (void) G_GNUC_UNUSED;
-#define MPRIS_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS_BRIDGE, MprisBridgePrivate))
-enum {
- MPRIS_BRIDGE_DUMMY_PROPERTY
-};
-GType player_controller_get_type (void) G_GNUC_CONST;
-MprisBridge* mpris_bridge_new (PlayerController* ctrl);
-MprisBridge* mpris_bridge_construct (GType object_type, PlayerController* ctrl);
-Mpris2Controller* mpris2_controller_new (PlayerController* ctrl);
-Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl);
-gboolean mpris2_controller_was_successfull (Mpris2Controller* self);
-void mpris2_controller_initial_update (Mpris2Controller* self);
-MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter);
-MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter);
-gboolean mpris_bridge_connected (MprisBridge* self);
-gboolean mpris_controller_connected (MprisController* self);
-gboolean mpris2_controller_connected (Mpris2Controller* self);
-GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
-void mpris_bridge_transport_update (MprisBridge* self, TransportMenuitemaction update);
-void mpris_controller_transport_event (MprisController* self, TransportMenuitemaction command);
-void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuitemaction command);
-void mpris_bridge_expose (MprisBridge* self);
-void mpris2_controller_expose (Mpris2Controller* self);
-void mpris_bridge_set_track_position (MprisBridge* self, double pos);
-void mpris_controller_set_position (MprisController* self, double position);
-void mpris2_controller_set_position (Mpris2Controller* self, double position);
-static void mpris_bridge_finalize (GObject* obj);
-
-
-
-static GType mpris_bridge_mode_get_type (void) {
- static volatile gsize mpris_bridge_mode_type_id__volatile = 0;
- if (g_once_init_enter (&mpris_bridge_mode_type_id__volatile)) {
- static const GEnumValue values[] = {{MPRIS_BRIDGE_MODE_MPRIS_1, "MPRIS_BRIDGE_MODE_MPRIS_1", "mpris-1"}, {MPRIS_BRIDGE_MODE_MPRIS_2, "MPRIS_BRIDGE_MODE_MPRIS_2", "mpris-2"}, {0, NULL, NULL}};
- GType mpris_bridge_mode_type_id;
- mpris_bridge_mode_type_id = g_enum_register_static ("MprisBridgemode", values);
- g_once_init_leave (&mpris_bridge_mode_type_id__volatile, mpris_bridge_mode_type_id);
- }
- return mpris_bridge_mode_type_id__volatile;
-}
-
-
-MprisBridge* mpris_bridge_construct (GType object_type, PlayerController* ctrl) {
- MprisBridge * self;
- Mpris2Controller* _tmp0_;
- g_return_val_if_fail (ctrl != NULL, NULL);
- self = (MprisBridge*) g_object_new (object_type, NULL);
- self->priv->mpris2_controller = (_tmp0_ = mpris2_controller_new (ctrl), _g_object_unref0 (self->priv->mpris2_controller), _tmp0_);
- if (mpris2_controller_was_successfull (self->priv->mpris2_controller) == TRUE) {
- MprisController* _tmp1_;
- self->priv->mode_in_use = MPRIS_BRIDGE_MODE_MPRIS_2;
- self->priv->mpris1_controller = (_tmp1_ = NULL, _g_object_unref0 (self->priv->mpris1_controller), _tmp1_);
- mpris2_controller_initial_update (self->priv->mpris2_controller);
- } else {
- Mpris2Controller* _tmp2_;
- MprisController* _tmp3_;
- self->priv->mpris2_controller = (_tmp2_ = NULL, _g_object_unref0 (self->priv->mpris2_controller), _tmp2_);
- self->priv->mode_in_use = MPRIS_BRIDGE_MODE_MPRIS_1;
- self->priv->mpris1_controller = (_tmp3_ = mpris_controller_new (ctrl, "org.freedesktop.MediaPlayer"), _g_object_unref0 (self->priv->mpris1_controller), _tmp3_);
- }
- return self;
-}
-
-
-MprisBridge* mpris_bridge_new (PlayerController* ctrl) {
- return mpris_bridge_construct (TYPE_MPRIS_BRIDGE, ctrl);
-}
-
-
-gboolean mpris_bridge_connected (MprisBridge* self) {
- gboolean result = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_1) {
- result = mpris_controller_connected (self->priv->mpris1_controller);
- return result;
- } else {
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_2) {
- result = mpris2_controller_connected (self->priv->mpris2_controller);
- return result;
- }
- }
- result = FALSE;
- return result;
-}
-
-
-void mpris_bridge_transport_update (MprisBridge* self, TransportMenuitemaction update) {
- g_return_if_fail (self != NULL);
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_1) {
- mpris_controller_transport_event (self->priv->mpris1_controller, update);
- } else {
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_2) {
- mpris2_controller_transport_event (self->priv->mpris2_controller, update);
- }
- }
-}
-
-
-void mpris_bridge_expose (MprisBridge* self) {
- g_return_if_fail (self != NULL);
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_2) {
- mpris2_controller_expose (self->priv->mpris2_controller);
- } else {
- g_warning ("mpris-bridge.vala:56: MPRIS1 clients don't have the ability to raise/e" \
-"xpose the client");
- }
-}
-
-
-void mpris_bridge_set_track_position (MprisBridge* self, double pos) {
- g_return_if_fail (self != NULL);
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_1) {
- mpris_controller_set_position (self->priv->mpris1_controller, pos);
- } else {
- if (self->priv->mode_in_use == MPRIS_BRIDGE_MODE_MPRIS_2) {
- mpris2_controller_set_position (self->priv->mpris2_controller, pos);
- }
- }
-}
-
-
-static void mpris_bridge_class_init (MprisBridgeClass * klass) {
- mpris_bridge_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (MprisBridgePrivate));
- G_OBJECT_CLASS (klass)->finalize = mpris_bridge_finalize;
-}
-
-
-static void mpris_bridge_instance_init (MprisBridge * self) {
- self->priv = MPRIS_BRIDGE_GET_PRIVATE (self);
-}
-
-
-static void mpris_bridge_finalize (GObject* obj) {
- MprisBridge * self;
- self = MPRIS_BRIDGE (obj);
- _g_object_unref0 (self->priv->mpris1_controller);
- _g_object_unref0 (self->priv->mpris2_controller);
- G_OBJECT_CLASS (mpris_bridge_parent_class)->finalize (obj);
-}
-
-
-GType mpris_bridge_get_type (void) {
- static volatile gsize mpris_bridge_type_id__volatile = 0;
- if (g_once_init_enter (&mpris_bridge_type_id__volatile)) {
- static const GTypeInfo g_define_type_info = { sizeof (MprisBridgeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mpris_bridge_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MprisBridge), 0, (GInstanceInitFunc) mpris_bridge_instance_init, NULL };
- GType mpris_bridge_type_id;
- mpris_bridge_type_id = g_type_register_static (G_TYPE_OBJECT, "MprisBridge", &g_define_type_info, 0);
- g_once_init_leave (&mpris_bridge_type_id__volatile, mpris_bridge_type_id);
- }
- return mpris_bridge_type_id__volatile;
-}
-
-
-
-
diff --git a/src/mpris-bridge.vala b/src/mpris-bridge.vala
deleted file mode 100644
index bd9d472..0000000
--- a/src/mpris-bridge.vala
+++ /dev/null
@@ -1,70 +0,0 @@
-public class MprisBridge : GLib.Object
-{
- private MprisController mpris1_controller;
- private Mpris2Controller mpris2_controller;
- private enum mode{
- MPRIS_1,
- MPRIS_2
- }
- private mode mode_in_use;
-
- public MprisBridge(PlayerController ctrl)
- {
- this.mpris2_controller = new Mpris2Controller(ctrl);
- if(this.mpris2_controller.was_successfull() == true){
- this.mode_in_use = mode.MPRIS_2;
- this.mpris1_controller = null;
- this.mpris2_controller.initial_update();
- }
- else{
- this.mpris2_controller = null;
- this.mode_in_use = mode.MPRIS_1;
- this.mpris1_controller = new MprisController(ctrl);
- }
- }
-
- // The handling of both mpris controllers can be abstracted further
- // once the mpris2 is implemented. This will allow for one instance
- // variable to point at the active controller. For now handle both ...
- public bool connected()
- {
- if(this.mode_in_use == mode.MPRIS_1){
- return this.mpris1_controller.connected();
- }
- else if(this.mode_in_use == mode.MPRIS_2){
- return this.mpris2_controller.connected();
- }
- return false;
- }
-
- public void transport_update(TransportMenuitem.action update)
- {
- if(this.mode_in_use == mode.MPRIS_1){
- this.mpris1_controller.transport_event(update);
- }
- else if(this.mode_in_use == mode.MPRIS_2){
- this.mpris2_controller.transport_event(update);
- }
- }
-
- public void expose()
- {
- if(this.mode_in_use == mode.MPRIS_2){
- this.mpris2_controller.expose();
- }
- else{
- warning("MPRIS1 clients don't have the ability to raise/expose the client");
- }
- }
-
-
- public void set_track_position(double pos)
- {
- if(this.mode_in_use == mode.MPRIS_1){
- this.mpris1_controller.set_position(pos);
- }
- else if(this.mode_in_use == mode.MPRIS_2){
- this.mpris2_controller.set_position(pos);
- }
- }
-} \ No newline at end of file
diff --git a/src/mpris-controller.c b/src/mpris-controller.c
deleted file mode 100644
index 98151e0..0000000
--- a/src/mpris-controller.c
+++ /dev/null
@@ -1,748 +0,0 @@
-/* mpris-controller.c generated by valac 0.9.7, the Vala compiler
- * generated from mpris-controller.vala, do not modify */
-
-/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
-Copyright 2010 Canonical Ltd.
-
-Authors:
- 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 <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
-#include <stdlib.h>
-#include <string.h>
-#include <gee.h>
-#include <libdbusmenu-glib/client.h>
-#include <libdbusmenu-glib/menuitem-proxy.h>
-#include <libdbusmenu-glib/menuitem.h>
-#include <libdbusmenu-glib/server.h>
-#include <float.h>
-#include <math.h>
-
-
-#define TYPE_MPRIS_CONTROLLER (mpris_controller_get_type ())
-#define MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CONTROLLER, MprisController))
-#define MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
-#define IS_MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CONTROLLER))
-#define IS_MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CONTROLLER))
-#define MPRIS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
-
-typedef struct _MprisController MprisController;
-typedef struct _MprisControllerClass MprisControllerClass;
-typedef struct _MprisControllerPrivate MprisControllerPrivate;
-
-#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 _dbus_g_connection_unref0(var) ((var == NULL) ? NULL : (var = (dbus_g_connection_unref (var), NULL)))
-#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-#define _g_free0(var) (var = (g_free (var), NULL))
-
-#define MPRIS_CONTROLLER_TYPE_STATUS (mpris_controller_status_get_type ())
-typedef struct _MprisControllerstatus MprisControllerstatus;
-typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
-
-#define TYPE_PLAYER_ITEM (player_item_get_type ())
-#define PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_ITEM, PlayerItem))
-#define PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_ITEM, PlayerItemClass))
-#define IS_PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_ITEM))
-#define IS_PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_ITEM))
-#define PLAYER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_ITEM, PlayerItemClass))
-
-typedef struct _PlayerItem PlayerItem;
-typedef struct _PlayerItemClass PlayerItemClass;
-
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-
-typedef struct _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
-
-#define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ())
-
-#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ())
-#define TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitem))
-#define TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass))
-#define IS_TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRANSPORT_MENUITEM))
-#define IS_TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRANSPORT_MENUITEM))
-#define TRANSPORT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass))
-
-typedef struct _TransportMenuitem TransportMenuitem;
-typedef struct _TransportMenuitemClass TransportMenuitemClass;
-#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
-
-#define TRANSPORT_MENUITEM_TYPE_ACTION (transport_menuitem_action_get_type ())
-#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
-
-struct _MprisController {
- GObject parent_instance;
- MprisControllerPrivate * priv;
-};
-
-struct _MprisControllerClass {
- GObjectClass parent_class;
-};
-
-struct _MprisControllerPrivate {
- DBusGConnection* connection;
- DBusGProxy* _mpris_player;
- PlayerController* _owner;
- char* _mpris_interface;
-};
-
-struct _MprisControllerstatus {
- gint32 playback;
- gint32 shuffle;
- gint32 repeat;
- gint32 endless;
-};
-
-struct _PlayerController {
- GObject parent_instance;
- PlayerControllerPrivate * priv;
- gint current_state;
- GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
-};
-
-struct _PlayerControllerClass {
- GObjectClass parent_class;
-};
-
-typedef enum {
- PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR,
- PLAYER_CONTROLLER_WIDGET_ORDER_TITLE,
- PLAYER_CONTROLLER_WIDGET_ORDER_METADATA,
- PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT
-} PlayerControllerwidget_order;
-
-typedef enum {
- TRANSPORT_MENUITEM_ACTION_PREVIOUS,
- TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE,
- TRANSPORT_MENUITEM_ACTION_NEXT
-} TransportMenuitemaction;
-
-
-static gpointer mpris_controller_parent_class = NULL;
-
-GType mpris_controller_get_type (void) G_GNUC_CONST;
-GType player_controller_get_type (void) G_GNUC_CONST;
-#define MPRIS_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS_CONTROLLER, MprisControllerPrivate))
-enum {
- MPRIS_CONTROLLER_DUMMY_PROPERTY,
- MPRIS_CONTROLLER_MPRIS_PLAYER,
- MPRIS_CONTROLLER_OWNER,
- MPRIS_CONTROLLER_MPRIS_INTERFACE
-};
-MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter);
-MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter);
-static void mpris_controller_initial_update (MprisController* self);
-DBusGProxy* mpris_controller_get_mpris_player (MprisController* self);
-static GType mpris_controller_status_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
-static MprisControllerstatus* mpris_controller_status_dup (const MprisControllerstatus* self);
-static void mpris_controller_status_free (MprisControllerstatus* self);
-static void _dynamic_GetStatus0 (DBusGProxy* self, MprisControllerstatus* result, GError** error);
-PlayerController* mpris_controller_get_owner (MprisController* self);
-GType player_item_get_type (void) G_GNUC_CONST;
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
-GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
-GType transport_menuitem_get_type (void) G_GNUC_CONST;
-void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
-static GHashTable* _dynamic_GetMetadata1 (DBusGProxy* self, GError** error);
-void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
-GeeHashSet* metadata_menuitem_attributes_format (void);
-GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
-void mpris_controller_transport_event (MprisController* self, TransportMenuitemaction command);
-static void _dynamic_Pause2 (DBusGProxy* self, GError** error);
-static void _dynamic_Prev3 (DBusGProxy* self, GError** error);
-static void _dynamic_Next4 (DBusGProxy* self, GError** error);
-void mpris_controller_set_position (MprisController* self, double position);
-static GHashTable* _dynamic_GetMetadata5 (DBusGProxy* self, GError** error);
-static GValue* _g_value_dup (GValue* self);
-static void _dynamic_PositionSet6 (DBusGProxy* self, gint32 param1, GError** error);
-gboolean mpris_controller_connected (MprisController* self);
-static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* mpris_client, MprisControllerstatus* st);
-GeeHashSet* transport_menuitem_attributes_format (void);
-static void mpris_controller_onTrackChange (MprisController* self, DBusGProxy* mpris_client, GHashTable* ht);
-void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
-static void _dynamic_GetStatus7 (DBusGProxy* self, MprisControllerstatus* result, GError** error);
-static void mpris_controller_set_mpris_player (MprisController* self, DBusGProxy* value);
-static void mpris_controller_set_owner (MprisController* self, PlayerController* value);
-const char* mpris_controller_get_mpris_interface (MprisController* self);
-static void mpris_controller_set_mpris_interface (MprisController* self, const char* value);
-const char* player_controller_get_name (PlayerController* self);
-static void _mpris_controller_onTrackChange_dynamic_TrackChange0_ (DBusGProxy* _sender, GHashTable* ht, gpointer self);
-void _dynamic_TrackChange1_connect (gpointer obj, const char * signal_name, GCallback handler, gpointer data);
-static void _mpris_controller_onStatusChange_dynamic_StatusChange2_ (DBusGProxy* _sender, MprisControllerstatus* st, gpointer self);
-void _dynamic_StatusChange3_connect (gpointer obj, const char * signal_name, GCallback handler, gpointer data);
-static GObject * mpris_controller_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-static void mpris_controller_finalize (GObject* obj);
-static void mpris_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
-static void mpris_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
-
-
-static void g_cclosure_user_marshal_VOID__BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
-
-MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter) {
- MprisController * self;
- g_return_val_if_fail (ctrl != NULL, NULL);
- g_return_val_if_fail (inter != NULL, NULL);
- self = (MprisController*) g_object_new (object_type, "owner", ctrl, "mpris-interface", inter, NULL);
- return self;
-}
-
-
-MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter) {
- return mpris_controller_construct (TYPE_MPRIS_CONTROLLER, ctrl, inter);
-}
-
-
-static void _dynamic_GetStatus0 (DBusGProxy* self, MprisControllerstatus* result, GError** error) {
- GValueArray* dbus_result;
- dbus_g_proxy_call (self, "GetStatus", error, G_TYPE_INVALID, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), &dbus_result, G_TYPE_INVALID);
- if (*error) {
- return;
- }
- result->playback = g_value_get_int (&dbus_result->values[0]);
- result->shuffle = g_value_get_int (&dbus_result->values[1]);
- result->repeat = g_value_get_int (&dbus_result->values[2]);
- result->endless = g_value_get_int (&dbus_result->values[3]);
-}
-
-
-static GHashTable* _dynamic_GetMetadata1 (DBusGProxy* self, GError** error) {
- GHashTable* result;
- dbus_g_proxy_call (self, "GetMetadata", error, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &result, G_TYPE_INVALID);
- if (*error) {
- return NULL;
- }
- return result;
-}
-
-
-static void mpris_controller_initial_update (MprisController* self) {
- MprisControllerstatus _tmp0_ = {0};
- MprisControllerstatus st;
- gint play_state;
- PlayerItem* _tmp1_;
- TransportMenuitem* _tmp2_;
- GHashTable* _tmp3_;
- PlayerItem* _tmp4_;
- GHashTable* _tmp5_;
- GeeHashSet* _tmp6_;
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- st = (_dynamic_GetStatus0 (self->priv->_mpris_player, &_tmp0_, &_inner_error_), _tmp0_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- play_state = (gint) st.playback;
- g_debug ("mpris-controller.vala:60: GetStatusChange - play state %i", play_state);
- transport_menuitem_change_play_state (_tmp2_ = (_tmp1_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT), IS_TRANSPORT_MENUITEM (_tmp1_) ? ((TransportMenuitem*) _tmp1_) : NULL), play_state);
- _g_object_unref0 (_tmp2_);
- _tmp3_ = _dynamic_GetMetadata1 (self->priv->_mpris_player, &_inner_error_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- player_item_update (_tmp4_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp5_ = _tmp3_, _tmp6_ = metadata_menuitem_attributes_format ());
- _g_object_unref0 (_tmp6_);
- _g_hash_table_unref0 (_tmp5_);
- _g_object_unref0 (_tmp4_);
-}
-
-
-static void _dynamic_Pause2 (DBusGProxy* self, GError** error) {
- dbus_g_proxy_call (self, "Pause", error, G_TYPE_INVALID, G_TYPE_INVALID);
- if (*error) {
- return;
- }
-}
-
-
-static void _dynamic_Prev3 (DBusGProxy* self, GError** error) {
- dbus_g_proxy_call (self, "Prev", error, G_TYPE_INVALID, G_TYPE_INVALID);
- if (*error) {
- return;
- }
-}
-
-
-static void _dynamic_Next4 (DBusGProxy* self, GError** error) {
- dbus_g_proxy_call (self, "Next", error, G_TYPE_INVALID, G_TYPE_INVALID);
- if (*error) {
- return;
- }
-}
-
-
-void mpris_controller_transport_event (MprisController* self, TransportMenuitemaction command) {
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- g_debug ("mpris-controller.vala:68: transport_event input = %i", (gint) command);
- if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) {
- g_debug ("mpris-controller.vala:70: transport_event PLAY_PAUSE");
- _dynamic_Pause2 (self->priv->_mpris_player, &_inner_error_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- } else {
- if (command == TRANSPORT_MENUITEM_ACTION_PREVIOUS) {
- _dynamic_Prev3 (self->priv->_mpris_player, &_inner_error_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- } else {
- if (command == TRANSPORT_MENUITEM_ACTION_NEXT) {
- _dynamic_Next4 (self->priv->_mpris_player, &_inner_error_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- }
- }
- }
-}
-
-
-static GHashTable* _dynamic_GetMetadata5 (DBusGProxy* self, GError** error) {
- GHashTable* result;
- dbus_g_proxy_call (self, "GetMetadata", error, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &result, G_TYPE_INVALID);
- if (*error) {
- return NULL;
- }
- return result;
-}
-
-
-static GValue* _g_value_dup (GValue* self) {
- return g_boxed_copy (G_TYPE_VALUE, self);
-}
-
-
-static gpointer __g_value_dup0 (gpointer self) {
- return self ? _g_value_dup (self) : NULL;
-}
-
-
-static void _dynamic_PositionSet6 (DBusGProxy* self, gint32 param1, GError** error) {
- dbus_g_proxy_call (self, "PositionSet", error, G_TYPE_INT, param1, G_TYPE_INVALID, G_TYPE_INVALID);
- if (*error) {
- return;
- }
-}
-
-
-void mpris_controller_set_position (MprisController* self, double position) {
- GHashTable* data;
- GValue* time_value;
- guint32 total_time;
- double new_time_position;
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- g_debug ("mpris-controller.vala:83: Set position with pos (0-100) %f", position);
- data = _dynamic_GetMetadata5 (self->priv->_mpris_player, &_inner_error_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- time_value = __g_value_dup0 ((GValue*) g_hash_table_lookup (data, "time"));
- if (time_value == NULL) {
- g_warning ("mpris-controller.vala:87: Can't fetch the duration of the track theref" \
-"ore cant set the position");
- _g_free0 (time_value);
- _g_hash_table_unref0 (data);
- return;
- }
- total_time = (guint32) g_value_get_uint (time_value);
- g_debug ("mpris-controller.vala:91: total time of track = %i", (gint) total_time);
- new_time_position = (total_time * position) / 100.0;
- g_debug ("mpris-controller.vala:93: new position = %f", new_time_position * 1000);
- _dynamic_PositionSet6 (self->priv->_mpris_player, (gint32) new_time_position, &_inner_error_);
- if (_inner_error_ != NULL) {
- _g_free0 (time_value);
- _g_hash_table_unref0 (data);
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- _g_free0 (time_value);
- _g_hash_table_unref0 (data);
-}
-
-
-gboolean mpris_controller_connected (MprisController* self) {
- gboolean result = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- result = self->priv->_mpris_player != NULL;
- return result;
-}
-
-
-static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* mpris_client, MprisControllerstatus* st) {
- MprisControllerstatus* status;
- GValueArray* ar;
- gint play_state;
- GHashTable* ht;
- GValue v = {0};
- PlayerItem* _tmp0_;
- GeeHashSet* _tmp1_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (mpris_client != NULL);
- g_debug ("mpris-controller.vala:104: onStatusChange - signal received");
- status = st;
- ar = (GValueArray*) status;
- play_state = g_value_get_int (g_value_array_get_nth (ar, (guint) 0));
- g_debug ("mpris-controller.vala:108: onStatusChange - play state %i", play_state);
- ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- g_value_init (&v, G_TYPE_INT);
- g_value_set_int (&v, play_state);
- g_hash_table_insert (ht, g_strdup ("state"), __g_value_dup0 (&v));
- player_item_update (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT), ht, _tmp1_ = transport_menuitem_attributes_format ());
- _g_object_unref0 (_tmp1_);
- _g_object_unref0 (_tmp0_);
- G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
- _g_hash_table_unref0 (ht);
-}
-
-
-static void _dynamic_GetStatus7 (DBusGProxy* self, MprisControllerstatus* result, GError** error) {
- GValueArray* dbus_result;
- dbus_g_proxy_call (self, "GetStatus", error, G_TYPE_INVALID, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), &dbus_result, G_TYPE_INVALID);
- if (*error) {
- return;
- }
- result->playback = g_value_get_int (&dbus_result->values[0]);
- result->shuffle = g_value_get_int (&dbus_result->values[1]);
- result->repeat = g_value_get_int (&dbus_result->values[2]);
- result->endless = g_value_get_int (&dbus_result->values[3]);
-}
-
-
-static void mpris_controller_onTrackChange (MprisController* self, DBusGProxy* mpris_client, GHashTable* ht) {
- PlayerItem* _tmp0_;
- GeeHashSet* _tmp1_;
- MprisControllerstatus _tmp2_ = {0};
- MprisControllerstatus st;
- gint play_state;
- PlayerItem* _tmp3_;
- GeeHashSet* _tmp4_;
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- g_return_if_fail (mpris_client != NULL);
- g_return_if_fail (ht != NULL);
- g_debug ("mpris-controller.vala:118: onTrackChange");
- player_item_reset (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp1_ = metadata_menuitem_attributes_format ());
- _g_object_unref0 (_tmp1_);
- _g_object_unref0 (_tmp0_);
- st = (_dynamic_GetStatus7 (self->priv->_mpris_player, &_tmp2_, &_inner_error_), _tmp2_);
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- play_state = (gint) st.playback;
- g_debug ("mpris-controller.vala:124: GetStatusChange, about to update scrub with" \
-" play state - %i", play_state);
- player_item_update (_tmp3_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), ht, _tmp4_ = metadata_menuitem_attributes_format ());
- _g_object_unref0 (_tmp4_);
- _g_object_unref0 (_tmp3_);
- g_debug ("mpris-controller.vala:128: about to update the duration on the scrub b" \
-"ar");
-}
-
-
-DBusGProxy* mpris_controller_get_mpris_player (MprisController* self) {
- DBusGProxy* result;
- g_return_val_if_fail (self != NULL, NULL);
- result = self->priv->_mpris_player;
- return result;
-}
-
-
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
-}
-
-
-static void mpris_controller_set_mpris_player (MprisController* self, DBusGProxy* value) {
- DBusGProxy* _tmp0_;
- g_return_if_fail (self != NULL);
- self->priv->_mpris_player = (_tmp0_ = _g_object_ref0 (value), _g_object_unref0 (self->priv->_mpris_player), _tmp0_);
- g_object_notify ((GObject *) self, "mpris-player");
-}
-
-
-PlayerController* mpris_controller_get_owner (MprisController* self) {
- PlayerController* result;
- g_return_val_if_fail (self != NULL, NULL);
- result = self->priv->_owner;
- return result;
-}
-
-
-static void mpris_controller_set_owner (MprisController* self, PlayerController* value) {
- PlayerController* _tmp0_;
- g_return_if_fail (self != NULL);
- self->priv->_owner = (_tmp0_ = _g_object_ref0 (value), _g_object_unref0 (self->priv->_owner), _tmp0_);
- g_object_notify ((GObject *) self, "owner");
-}
-
-
-const char* mpris_controller_get_mpris_interface (MprisController* self) {
- const char* result;
- g_return_val_if_fail (self != NULL, NULL);
- result = self->priv->_mpris_interface;
- return result;
-}
-
-
-static void mpris_controller_set_mpris_interface (MprisController* self, const char* value) {
- char* _tmp0_;
- g_return_if_fail (self != NULL);
- self->priv->_mpris_interface = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_mpris_interface), _tmp0_);
- g_object_notify ((GObject *) self, "mpris-interface");
-}
-
-
-static void _mpris_controller_onTrackChange_dynamic_TrackChange0_ (DBusGProxy* _sender, GHashTable* ht, gpointer self) {
- mpris_controller_onTrackChange (self, _sender, ht);
-}
-
-
-void _dynamic_TrackChange1_connect (gpointer obj, const char * signal_name, GCallback handler, gpointer data) {
- dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__BOXED, G_TYPE_NONE, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), G_TYPE_INVALID);
- dbus_g_proxy_add_signal (obj, "TrackChange", dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (obj, "TrackChange", handler, data, NULL);
-}
-
-
-static void _mpris_controller_onStatusChange_dynamic_StatusChange2_ (DBusGProxy* _sender, MprisControllerstatus* st, gpointer self) {
- mpris_controller_onStatusChange (self, _sender, st);
-}
-
-
-void _dynamic_StatusChange3_connect (gpointer obj, const char * signal_name, GCallback handler, gpointer data) {
- dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__BOXED, G_TYPE_NONE, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), G_TYPE_INVALID);
- dbus_g_proxy_add_signal (obj, "StatusChange", dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (obj, "StatusChange", handler, data, NULL);
-}
-
-
-static GObject * mpris_controller_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
- GObject * obj;
- GObjectClass * parent_class;
- MprisController * self;
- GError * _inner_error_;
- parent_class = G_OBJECT_CLASS (mpris_controller_parent_class);
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = MPRIS_CONTROLLER (obj);
- _inner_error_ = NULL;
- {
- char* _tmp2_;
- char* _tmp3_;
- DBusGProxy* _tmp4_;
- char* _tmp5_;
- char* _tmp6_;
- {
- DBusGConnection* _tmp0_;
- DBusGConnection* _tmp1_;
- _tmp0_ = dbus_g_bus_get (DBUS_BUS_SESSION, &_inner_error_);
- if (_inner_error_ != NULL) {
- goto __catch1_g_error;
- }
- self->priv->connection = (_tmp1_ = _tmp0_, _dbus_g_connection_unref0 (self->priv->connection), _tmp1_);
- }
- goto __finally1;
- __catch1_g_error:
- {
- GError * e;
- e = _inner_error_;
- _inner_error_ = NULL;
- {
- g_error ("mpris-controller.vala:45: Problems connecting to the session bus - %s", e->message);
- _g_error_free0 (e);
- }
- }
- __finally1:
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- }
- mpris_controller_set_mpris_player (self, _tmp4_ = dbus_g_proxy_new_for_name (self->priv->connection, _tmp3_ = g_strconcat ("org.mpris.", _tmp2_ = g_utf8_strdown (player_controller_get_name (self->priv->_owner), -1), NULL), "/Player", self->priv->_mpris_interface));
- _g_object_unref0 (_tmp4_);
- _g_free0 (_tmp3_);
- _g_free0 (_tmp2_);
- g_debug ("mpris-controller.vala:49: Attempting to establish an mpris connection " \
-"to %s, %s, %s", _tmp6_ = g_strconcat ("org.mpris.", _tmp5_ = g_utf8_strdown (player_controller_get_name (self->priv->_owner), -1), NULL), "/Player", self->priv->_mpris_interface);
- _g_free0 (_tmp6_);
- _g_free0 (_tmp5_);
- _dynamic_TrackChange1_connect (self->priv->_mpris_player, "TrackChange", (GCallback) _mpris_controller_onTrackChange_dynamic_TrackChange0_, self);
- _dynamic_StatusChange3_connect (self->priv->_mpris_player, "StatusChange", (GCallback) _mpris_controller_onStatusChange_dynamic_StatusChange2_, self);
- mpris_controller_initial_update (self);
- }
- return obj;
-}
-
-
-static MprisControllerstatus* mpris_controller_status_dup (const MprisControllerstatus* self) {
- MprisControllerstatus* dup;
- dup = g_new0 (MprisControllerstatus, 1);
- memcpy (dup, self, sizeof (MprisControllerstatus));
- return dup;
-}
-
-
-static void mpris_controller_status_free (MprisControllerstatus* self) {
- g_free (self);
-}
-
-
-static GType mpris_controller_status_get_type (void) {
- static volatile gsize mpris_controller_status_type_id__volatile = 0;
- if (g_once_init_enter (&mpris_controller_status_type_id__volatile)) {
- GType mpris_controller_status_type_id;
- mpris_controller_status_type_id = g_boxed_type_register_static ("MprisControllerstatus", (GBoxedCopyFunc) mpris_controller_status_dup, (GBoxedFreeFunc) mpris_controller_status_free);
- g_once_init_leave (&mpris_controller_status_type_id__volatile, mpris_controller_status_type_id);
- }
- return mpris_controller_status_type_id__volatile;
-}
-
-
-static void mpris_controller_class_init (MprisControllerClass * klass) {
- mpris_controller_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (MprisControllerPrivate));
- G_OBJECT_CLASS (klass)->get_property = mpris_controller_get_property;
- G_OBJECT_CLASS (klass)->set_property = mpris_controller_set_property;
- G_OBJECT_CLASS (klass)->constructor = mpris_controller_constructor;
- G_OBJECT_CLASS (klass)->finalize = mpris_controller_finalize;
- g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS_CONTROLLER_MPRIS_PLAYER, g_param_spec_object ("mpris-player", "mpris-player", "mpris-player", DBUS_TYPE_G_PROXY, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS_CONTROLLER_OWNER, g_param_spec_object ("owner", "owner", "owner", TYPE_PLAYER_CONTROLLER, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (G_OBJECT_CLASS (klass), MPRIS_CONTROLLER_MPRIS_INTERFACE, g_param_spec_string ("mpris-interface", "mpris-interface", "mpris-interface", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-
-static void mpris_controller_instance_init (MprisController * self) {
- self->priv = MPRIS_CONTROLLER_GET_PRIVATE (self);
-}
-
-
-static void mpris_controller_finalize (GObject* obj) {
- MprisController * self;
- self = MPRIS_CONTROLLER (obj);
- _dbus_g_connection_unref0 (self->priv->connection);
- _g_object_unref0 (self->priv->_mpris_player);
- _g_object_unref0 (self->priv->_owner);
- _g_free0 (self->priv->_mpris_interface);
- G_OBJECT_CLASS (mpris_controller_parent_class)->finalize (obj);
-}
-
-
-GType mpris_controller_get_type (void) {
- static volatile gsize mpris_controller_type_id__volatile = 0;
- if (g_once_init_enter (&mpris_controller_type_id__volatile)) {
- static const GTypeInfo g_define_type_info = { sizeof (MprisControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mpris_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MprisController), 0, (GInstanceInitFunc) mpris_controller_instance_init, NULL };
- GType mpris_controller_type_id;
- mpris_controller_type_id = g_type_register_static (G_TYPE_OBJECT, "MprisController", &g_define_type_info, 0);
- g_once_init_leave (&mpris_controller_type_id__volatile, mpris_controller_type_id);
- }
- return mpris_controller_type_id__volatile;
-}
-
-
-static void mpris_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
- MprisController * self;
- self = MPRIS_CONTROLLER (object);
- switch (property_id) {
- case MPRIS_CONTROLLER_MPRIS_PLAYER:
- g_value_set_object (value, mpris_controller_get_mpris_player (self));
- break;
- case MPRIS_CONTROLLER_OWNER:
- g_value_set_object (value, mpris_controller_get_owner (self));
- break;
- case MPRIS_CONTROLLER_MPRIS_INTERFACE:
- g_value_set_string (value, mpris_controller_get_mpris_interface (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-static void mpris_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
- MprisController * self;
- self = MPRIS_CONTROLLER (object);
- switch (property_id) {
- case MPRIS_CONTROLLER_MPRIS_PLAYER:
- mpris_controller_set_mpris_player (self, g_value_get_object (value));
- break;
- case MPRIS_CONTROLLER_OWNER:
- mpris_controller_set_owner (self, g_value_get_object (value));
- break;
- case MPRIS_CONTROLLER_MPRIS_INTERFACE:
- mpris_controller_set_mpris_interface (self, g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-
-static void g_cclosure_user_marshal_VOID__BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
- typedef void (*GMarshalFunc_VOID__BOXED) (gpointer data1, gpointer arg_1, gpointer data2);
- register GMarshalFunc_VOID__BOXED callback;
- register GCClosure * cc;
- register gpointer data1, data2;
- cc = (GCClosure *) closure;
- g_return_if_fail (n_param_values == 2);
- if (G_CCLOSURE_SWAP_DATA (closure)) {
- data1 = closure->data;
- data2 = param_values->data[0].v_pointer;
- } else {
- data1 = param_values->data[0].v_pointer;
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__BOXED) (marshal_data ? marshal_data : cc->callback);
- callback (data1, g_value_get_boxed (param_values + 1), data2);
-}
-
-
-
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
deleted file mode 100644
index fc9eee0..0000000
--- a/src/mpris-controller.vala
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
-Copyright 2010 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-using Gee;
-
-public class MprisController : GLib.Object
-{
- private DBus.Connection connection;
- public dynamic DBus.Object mpris_player{get; construct;}
- public PlayerController owner {get; construct;}
- public string mpris_interface {get; construct;}
-
- struct status {
- public int32 playback;
- public int32 shuffle;
- public int32 repeat;
- public int32 endless;
- }
-
- public MprisController(PlayerController ctrl, string inter="org.freedesktop.MediaPlayer"){
- Object(owner: ctrl, mpris_interface: inter);
- }
-
- construct{
- try {
- this.connection = DBus.Bus.get (DBus.BusType.SESSION);
- } catch (Error e) {
- error("Problems connecting to the session bus - %s", e.message);
- }
- this.mpris_player = this.connection.get_object ("org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface);
-
- debug("Attempting to establish an mpris connection to %s, %s, %s", "org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface);
-
- this.mpris_player.TrackChange += onTrackChange;
- this.mpris_player.StatusChange += onStatusChange;
- initial_update();
- }
-
- private void initial_update()
- {
- status st = this.mpris_player.GetStatus();
- int play_state = st.playback;
- debug("GetStatusChange - play state %i", play_state);
- (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
- this.owner.custom_items[PlayerController.widget_order.METADATA].update(this.mpris_player.GetMetadata(),
- MetadataMenuitem.attributes_format());
- }
-
- public void transport_event(TransportMenuitem.action command)
- {
- debug("transport_event input = %i", (int)command);
- if(command == TransportMenuitem.action.PLAY_PAUSE){
- debug("transport_event PLAY_PAUSE");
- this.mpris_player.Pause();
- }
- else if(command == TransportMenuitem.action.PREVIOUS){
- this.mpris_player.Prev();
- }
- else if(command == TransportMenuitem.action.NEXT){
- this.mpris_player.Next();
- }
- }
-
- public void set_position(double position)
- {
- debug("Set position with pos (0-100) %f", position);
- HashTable<string, Value?> data = this.mpris_player.GetMetadata();
- Value? time_value = data.lookup("time");
- if(time_value == null){
- warning("Can't fetch the duration of the track therefore cant set the position");
- return;
- }
- uint32 total_time = time_value.get_uint();
- debug("total time of track = %i", (int)total_time);
- double new_time_position = total_time * position/100.0;
- debug("new position = %f", (new_time_position * 1000));
- this.mpris_player.PositionSet((int32)(new_time_position));
- }
-
- public bool connected()
- {
- return (this.mpris_player != null);
- }
-
- private void onStatusChange(dynamic DBus.Object mpris_client, status st)
- {
- debug("onStatusChange - signal received");
- status* status = &st;
- unowned ValueArray ar = (ValueArray)status;
- int play_state = ar.get_nth(0).get_int();
- debug("onStatusChange - play state %i", play_state);
- HashTable<string, Value?> ht = new HashTable<string, Value?>(str_hash, str_equal);
- Value v = Value(typeof(int));
- v.set_int(play_state);
- ht.insert("state", v);
- this.owner.custom_items[PlayerController.widget_order.TRANSPORT].update(ht, TransportMenuitem.attributes_format());
- }
-
- private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
- {
- debug("onTrackChange");
-
- this.owner.custom_items[PlayerController.widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
-
- status st = this.mpris_player.GetStatus();
- int play_state = st.playback;
- debug("GetStatusChange, about to update scrub with play state - %i", play_state);
-
- this.owner.custom_items[PlayerController.widget_order.METADATA].update(ht,
- MetadataMenuitem.attributes_format());
- debug("about to update the duration on the scrub bar");
- }
-}
diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c
index 87ec14a..6aa2be2 100644
--- a/src/mpris2-controller.c
+++ b/src/mpris2-controller.c
@@ -1,4 +1,4 @@
-/* mpris2-controller.c generated by valac 0.9.7, the Vala compiler
+/* mpris2-controller.c generated by valac 0.9.8, the Vala compiler
* generated from mpris2-controller.vala, do not modify */
/*
@@ -103,16 +103,6 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
typedef struct _PlayerItem PlayerItem;
typedef struct _PlayerItemClass PlayerItemClass;
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-
-typedef struct _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
-
#define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ())
#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ())
@@ -124,6 +114,7 @@ typedef struct _MprisBridgeClass MprisBridgeClass;
typedef struct _TransportMenuitem TransportMenuitem;
typedef struct _TransportMenuitemClass TransportMenuitemClass;
+#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
#define TRANSPORT_MENUITEM_TYPE_ACTION (transport_menuitem_action_get_type ())
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
@@ -204,7 +195,7 @@ struct _PlayerController {
PlayerControllerPrivate * priv;
gint current_state;
GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
+ Mpris2Controller* mpris_bridge;
};
struct _PlayerControllerClass {
@@ -357,11 +348,11 @@ enum {
Mpris2Controller* mpris2_controller_new (PlayerController* ctrl);
Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl);
void mpris2_controller_property_changed_cb (Mpris2Controller* self, const char* interface_source, GHashTable* changed_properties, char** invalid, int invalid_length1);
+PlayerController* mpris2_controller_get_owner (Mpris2Controller* self);
+const char* player_controller_get_name (PlayerController* self);
static GValue* _g_value_dup (GValue* self);
static gint mpris2_controller_determine_play_state (Mpris2Controller* self, const char* status);
-PlayerController* mpris2_controller_get_owner (Mpris2Controller* self);
GType player_item_get_type (void) G_GNUC_CONST;
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
GType transport_menuitem_get_type (void) G_GNUC_CONST;
void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
@@ -369,12 +360,13 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self);
void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
GeeHashSet* metadata_menuitem_attributes_format (void);
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
+static void _vala_GValue_free (GValue* self);
MprisPlayer* mpris2_controller_get_player (Mpris2Controller* self);
static char** _vala_array_dup1 (char** self, int length);
void mpris2_controller_initial_update (Mpris2Controller* self);
GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
-void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuitemaction command);
-void mpris2_controller_set_position (Mpris2Controller* self, double position);
+void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command);
+void mpris2_controller_set_track_position (Mpris2Controller* self, double position);
void mpris2_controller_onSeeked (Mpris2Controller* self, gint64 position);
gboolean mpris2_controller_connected (Mpris2Controller* self);
MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self);
@@ -385,7 +377,6 @@ static void mpris2_controller_set_player (Mpris2Controller* self, MprisPlayer* v
static void mpris2_controller_set_owner (Mpris2Controller* self, PlayerController* value);
FreeDesktopProperties* mpris2_controller_get_properties_interface (Mpris2Controller* self);
static void mpris2_controller_set_properties_interface (Mpris2Controller* self, FreeDesktopProperties* value);
-const char* player_controller_get_name (PlayerController* self);
static void _mpris2_controller_onSeeked_mpris_player_seeked (MprisPlayer* _sender, gint64 new_position, gpointer self);
static void _mpris2_controller_property_changed_cb_free_desktop_properties_properties_changed (FreeDesktopProperties* _sender, const char* source, GHashTable* changed_properties, char** invalid, int invalid_length1, gpointer self);
static GObject * mpris2_controller_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
@@ -4669,21 +4660,30 @@ static gpointer __g_value_dup0 (gpointer self) {
}
+static void _vala_GValue_free (GValue* self) {
+ g_value_unset (self);
+ g_free (self);
+}
+
+
void mpris2_controller_property_changed_cb (Mpris2Controller* self, const char* interface_source, GHashTable* changed_properties, char** invalid, int invalid_length1) {
- gboolean _tmp0_ = FALSE;
+ char* _tmp0_;
+ gboolean _tmp1_ = FALSE;
GValue* play_v;
GValue* pos_v;
GValue* meta_v;
g_return_if_fail (self != NULL);
g_return_if_fail (interface_source != NULL);
g_return_if_fail (changed_properties != NULL);
- g_debug ("mpris2-controller.vala:99: properties-changed for interface %s", interface_source);
+ g_debug ("mpris2-controller.vala:99: properties-changed for interface %s and own" \
+"er %s", interface_source, _tmp0_ = g_utf8_strdown (player_controller_get_name (self->priv->_owner), -1));
+ _g_free0 (_tmp0_);
if (changed_properties == NULL) {
- _tmp0_ = TRUE;
+ _tmp1_ = TRUE;
} else {
- _tmp0_ = g_str_has_prefix (interface_source, MPRIS2_CONTROLLER_root_interface) == FALSE;
+ _tmp1_ = g_str_has_prefix (interface_source, MPRIS2_CONTROLLER_root_interface) == FALSE;
}
- if (_tmp0_) {
+ if (_tmp1_) {
g_warning ("mpris2-controller.vala:101: Property-changed hash is null or this is a" \
"n interface that concerns us");
return;
@@ -4692,13 +4692,13 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const char*
if (play_v != NULL) {
char* state;
gint p;
- PlayerItem* _tmp1_;
- TransportMenuitem* _tmp2_;
+ PlayerItem* _tmp2_;
+ TransportMenuitem* _tmp3_;
state = g_strdup (g_value_get_string (play_v));
g_debug ("mpris2-controller.vala:107: new playback state = %s", state);
p = mpris2_controller_determine_play_state (self, state);
- transport_menuitem_change_play_state (_tmp2_ = (_tmp1_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT), IS_TRANSPORT_MENUITEM (_tmp1_) ? ((TransportMenuitem*) _tmp1_) : NULL), p);
- _g_object_unref0 (_tmp2_);
+ transport_menuitem_change_play_state (_tmp3_ = (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT), IS_TRANSPORT_MENUITEM (_tmp2_) ? ((TransportMenuitem*) _tmp2_) : NULL), p);
+ _g_object_unref0 (_tmp3_);
_g_free0 (state);
}
pos_v = __g_value_dup0 ((GValue*) g_hash_table_lookup (changed_properties, "Position"));
@@ -4710,22 +4710,22 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const char*
meta_v = __g_value_dup0 ((GValue*) g_hash_table_lookup (changed_properties, "Metadata"));
if (meta_v != NULL) {
GHashTable* changed_updates;
- PlayerItem* _tmp3_;
- GeeHashSet* _tmp4_;
- PlayerItem* _tmp5_;
- GeeHashSet* _tmp6_;
+ PlayerItem* _tmp4_;
+ GeeHashSet* _tmp5_;
+ PlayerItem* _tmp6_;
+ GeeHashSet* _tmp7_;
changed_updates = mpris2_controller_clean_metadata (self);
- player_item_reset (_tmp3_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp4_ = metadata_menuitem_attributes_format ());
+ player_item_reset (_tmp4_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp5_ = metadata_menuitem_attributes_format ());
+ _g_object_unref0 (_tmp5_);
_g_object_unref0 (_tmp4_);
- _g_object_unref0 (_tmp3_);
- player_item_update (_tmp5_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), changed_updates, _tmp6_ = metadata_menuitem_attributes_format ());
+ player_item_update (_tmp6_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), changed_updates, _tmp7_ = metadata_menuitem_attributes_format ());
+ _g_object_unref0 (_tmp7_);
_g_object_unref0 (_tmp6_);
- _g_object_unref0 (_tmp5_);
_g_hash_table_unref0 (changed_updates);
}
- _g_free0 (meta_v);
- _g_free0 (pos_v);
- _g_free0 (play_v);
+ __vala_GValue_free0 (meta_v);
+ __vala_GValue_free0 (pos_v);
+ __vala_GValue_free0 (play_v);
}
@@ -4779,8 +4779,8 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) {
g_hash_table_replace (changed_updates, g_strdup ("mpris:length"), (_tmp11_ = g_new0 (GValue, 1), g_value_init (_tmp11_, G_TYPE_INT64), g_value_set_int64 (_tmp11_, duration / 1000000), _tmp11_));
}
result = changed_updates;
- _g_free0 (length_v);
- _g_free0 (artist_v);
+ __vala_GValue_free0 (length_v);
+ __vala_GValue_free0 (artist_v);
return result;
}
@@ -4837,7 +4837,7 @@ void mpris2_controller_initial_update (Mpris2Controller* self) {
}
-void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuitemaction command) {
+void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command) {
GError * _inner_error_ = NULL;
g_return_if_fail (self != NULL);
g_debug ("mpris2-controller.vala:176: transport_event input = %i", (gint) command);
@@ -4847,15 +4847,15 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
mpris_player_PlayPause (self->priv->_player, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == DBUS_GERROR) {
- goto __catch2_dbus_gerror;
+ goto __catch5_dbus_gerror;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
- goto __finally2;
- __catch2_dbus_gerror:
+ goto __finally5;
+ __catch5_dbus_gerror:
{
GError * _error_;
_error_ = _inner_error_;
@@ -4866,7 +4866,7 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
_g_error_free0 (_error_);
}
}
- __finally2:
+ __finally5:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -4878,15 +4878,15 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
mpris_player_Previous (self->priv->_player, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == DBUS_GERROR) {
- goto __catch3_dbus_gerror;
+ goto __catch6_dbus_gerror;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
- goto __finally3;
- __catch3_dbus_gerror:
+ goto __finally6;
+ __catch6_dbus_gerror:
{
GError * _error_;
_error_ = _inner_error_;
@@ -4897,7 +4897,7 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
_g_error_free0 (_error_);
}
}
- __finally3:
+ __finally6:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -4909,15 +4909,15 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
mpris_player_Next (self->priv->_player, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == DBUS_GERROR) {
- goto __catch4_dbus_gerror;
+ goto __catch7_dbus_gerror;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
- goto __finally4;
- __catch4_dbus_gerror:
+ goto __finally7;
+ __catch7_dbus_gerror:
{
GError * _error_;
_error_ = _inner_error_;
@@ -4928,7 +4928,7 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
_g_error_free0 (_error_);
}
}
- __finally4:
+ __finally7:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -4944,7 +4944,7 @@ void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuite
TODO: SetPosition on the player object is not working with rhythmbox,
runtime error - "dbus function not supported"
*/
-void mpris2_controller_set_position (Mpris2Controller* self, double position) {
+void mpris2_controller_set_track_position (Mpris2Controller* self, double position) {
GHashTable* _tmp0_;
GValue* _tmp1_;
GValue* time_value;
@@ -4960,7 +4960,7 @@ void mpris2_controller_set_position (Mpris2Controller* self, double position) {
if (time_value == NULL) {
g_warning ("mpris2-controller.vala:215: Can't fetch the duration of the track ther" \
"efore cant set the position");
- _g_free0 (time_value);
+ __vala_GValue_free0 (time_value);
return;
}
total_time = g_value_get_int64 (time_value);
@@ -4976,33 +4976,33 @@ void mpris2_controller_set_position (Mpris2Controller* self, double position) {
mpris_player_SetPosition (self->priv->_player, path, (gint64) new_time_position, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == DBUS_GERROR) {
- goto __catch5_dbus_gerror;
+ goto __catch8_dbus_gerror;
}
_g_free0 (path);
- _g_free0 (v);
- _g_free0 (time_value);
+ __vala_GValue_free0 (v);
+ __vala_GValue_free0 (time_value);
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
- goto __finally5;
- __catch5_dbus_gerror:
+ goto __finally8;
+ __catch8_dbus_gerror:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
{
- g_error ("mpris2-controller.vala:234: DBus Error calling the player objects SetP" \
+ g_error ("mpris2-controller.vala:232: DBus Error calling the player objects SetP" \
"osition method %s", e->message);
_g_error_free0 (e);
}
}
- __finally5:
+ __finally8:
if (_inner_error_ != NULL) {
_g_free0 (path);
- _g_free0 (v);
- _g_free0 (time_value);
+ __vala_GValue_free0 (v);
+ __vala_GValue_free0 (time_value);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
@@ -5010,14 +5010,14 @@ void mpris2_controller_set_position (Mpris2Controller* self, double position) {
_g_free0 (path);
}
}
- _g_free0 (v);
- _g_free0 (time_value);
+ __vala_GValue_free0 (v);
+ __vala_GValue_free0 (time_value);
}
void mpris2_controller_onSeeked (Mpris2Controller* self, gint64 position) {
g_return_if_fail (self != NULL);
- g_debug ("mpris2-controller.vala:242: Seeked signal callback with pos = %i", ((gint) position) / 1000);
+ g_debug ("mpris2-controller.vala:240: Seeked signal callback with pos = %i", ((gint) position) / 1000);
}
@@ -5061,26 +5061,26 @@ void mpris2_controller_expose (Mpris2Controller* self) {
mpris_root_Raise (self->priv->_mpris2_root, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == DBUS_GERROR) {
- goto __catch6_dbus_gerror;
+ goto __catch9_dbus_gerror;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
- goto __finally6;
- __catch6_dbus_gerror:
+ goto __finally9;
+ __catch9_dbus_gerror:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
{
- g_error ("mpris2-controller.vala:267: Exception thrown while calling root functi" \
+ g_error ("mpris2-controller.vala:263: Exception thrown while calling root functi" \
"on Raise - %s", e->message);
_g_error_free0 (e);
}
}
- __finally6:
+ __finally9:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -5206,7 +5206,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == DBUS_GERROR) {
- goto __catch7_dbus_gerror;
+ goto __catch10_dbus_gerror;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -5240,8 +5240,8 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
g_signal_connect_object (self->priv->_properties_interface, "properties-changed", (GCallback) _mpris2_controller_property_changed_cb_free_desktop_properties_properties_changed, self, 0);
_dbus_g_connection_unref0 (connection);
}
- goto __finally7;
- __catch7_dbus_gerror:
+ goto __finally10;
+ __catch10_dbus_gerror:
{
GError * e;
e = _inner_error_;
@@ -5251,7 +5251,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
_g_error_free0 (e);
}
}
- __finally7:
+ __finally10:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index df2bbd3..cf5a39e 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -96,7 +96,7 @@ public class Mpris2Controller : GLib.Object
public void property_changed_cb(string interface_source, HashTable<string, Value?> changed_properties, string[] invalid )
{
- debug("properties-changed for interface %s", interface_source);
+ debug("properties-changed for interface %s and owner %s", interface_source, this.owner.name.down());
if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false){
warning("Property-changed hash is null or this is an interface that concerns us");
return;
@@ -171,7 +171,7 @@ public class Mpris2Controller : GLib.Object
MetadataMenuitem.attributes_format());
}
- public void transport_event(TransportMenuitem.action command)
+ public void transport_update(TransportMenuitem.action command)
{
debug("transport_event input = %i", (int)command);
if(command == TransportMenuitem.action.PLAY_PAUSE){
@@ -207,7 +207,7 @@ public class Mpris2Controller : GLib.Object
TODO: SetPosition on the player object is not working with rhythmbox,
runtime error - "dbus function not supported"
*/
- public void set_position(double position)
+ public void set_track_position(double position)
{
debug("Set position with pos (0-100) %f", position);
Value? time_value = this.player.Metadata.lookup("mpris:length");
@@ -227,8 +227,6 @@ public class Mpris2Controller : GLib.Object
DBus.ObjectPath path = new ObjectPath(v.get_string());
try{
this.player.SetPosition(path, (int64)(new_time_position));
- //ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
- //scrub.update_position(((int32)new_time_position) / 1000);
}
catch(DBus.Error e){
error("DBus Error calling the player objects SetPosition method %s",
@@ -240,8 +238,6 @@ public class Mpris2Controller : GLib.Object
public void onSeeked(int64 position){
debug("Seeked signal callback with pos = %i", (int)position/1000);
- //ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
- //scrub.update_position((int32)position/1000);
}
public bool connected()
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c
index 1e908a9..0f513ae 100644
--- a/src/music-player-bridge.c
+++ b/src/music-player-bridge.c
@@ -1,4 +1,4 @@
-/* music-player-bridge.c generated by valac 0.9.7, the Vala compiler
+/* music-player-bridge.c generated by valac 0.9.8, the Vala compiler
* generated from music-player-bridge.vala, do not modify */
/*
@@ -218,9 +218,7 @@ static char* string_strip (const char* self) {
static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self) {
- gint count;
g_return_if_fail (self != NULL);
- count = 0;
{
GeeSet* _tmp0_;
GeeIterator* _tmp1_;
@@ -228,50 +226,41 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
_app_it = (_tmp1_ = gee_iterable_iterator ((GeeIterable*) (_tmp0_ = familiar_players_db_records (self->priv->playersDB))), _g_object_unref0 (_tmp0_), _tmp1_);
while (TRUE) {
char* app;
+ GDesktopAppInfo* info;
+ GDesktopAppInfo* _tmp2_;
+ GAppInfo* app_info;
+ PlayerController* ctrl;
+ char* _tmp3_;
+ char* _tmp4_;
if (!gee_iterator_next (_app_it)) {
break;
}
app = (char*) gee_iterator_get (_app_it);
- if (count == 0) {
- GDesktopAppInfo* info;
- GDesktopAppInfo* _tmp2_;
- GAppInfo* app_info;
- PlayerController* ctrl;
- char* _tmp3_;
- char* _tmp4_;
- char* _tmp5_;
- char* _tmp6_;
- if (app == NULL) {
- g_warning ("music-player-bridge.vala:52: App string in keyfile is null therefore m" \
+ if (app == NULL) {
+ g_warning ("music-player-bridge.vala:49: App string in keyfile is null therefore m" \
"oving on to next player");
- _g_free0 (app);
- continue;
- }
- info = g_desktop_app_info_new_from_filename (app);
- if (info == NULL) {
- g_warning ("music-player-bridge.vala:57: Could not create a desktopappinfo instanc" \
+ _g_free0 (app);
+ continue;
+ }
+ g_debug ("music-player-bridge.vala:53: attempting to make an app info from %s", app);
+ info = g_desktop_app_info_new_from_filename (app);
+ if (info == NULL) {
+ g_warning ("music-player-bridge.vala:57: Could not create a desktopappinfo instanc" \
"e from app: %s", app);
- _g_object_unref0 (info);
- _g_free0 (app);
- continue;
- }
- app_info = _g_object_ref0 ((_tmp2_ = info, G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL));
- ctrl = player_controller_new (self->priv->root_menu, g_app_info_get_name (app_info), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE);
- g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
- gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp4_ = string_strip (_tmp3_ = g_utf8_strdown (g_app_info_get_name (app_info), -1)), ctrl);
- _g_free0 (_tmp4_);
- _g_free0 (_tmp3_);
- g_debug ("music-player-bridge.vala:67: Created a player controller for %s which " \
-"was found in the cache file", _tmp6_ = string_strip (_tmp5_ = g_utf8_strdown (g_app_info_get_name (app_info), -1)));
- _g_free0 (_tmp6_);
- _g_free0 (_tmp5_);
- count = count + 1;
- _g_object_unref0 (ctrl);
- _g_object_unref0 (app_info);
_g_object_unref0 (info);
+ _g_free0 (app);
+ continue;
}
+ app_info = _g_object_ref0 ((_tmp2_ = info, G_IS_APP_INFO (_tmp2_) ? ((GAppInfo*) _tmp2_) : NULL));
+ ctrl = player_controller_new (self->priv->root_menu, g_app_info_get_name (app_info), music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_OFFLINE);
+ g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
+ gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, _tmp4_ = string_strip (_tmp3_ = g_utf8_strdown (g_app_info_get_name (app_info), -1)), ctrl);
+ _g_free0 (_tmp4_);
+ _g_free0 (_tmp3_);
+ _g_object_unref0 (ctrl);
+ _g_object_unref0 (app_info);
+ _g_object_unref0 (info);
_g_free0 (app);
- break;
}
_g_object_unref0 (_app_it);
}
@@ -300,7 +289,7 @@ void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListe
gboolean _tmp3_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (type != NULL);
- g_debug ("music-player-bridge.vala:86: MusicPlayerBridge -> on_server_added with" \
+ g_debug ("music-player-bridge.vala:82: MusicPlayerBridge -> on_server_added with" \
" value %s", type);
if (music_player_bridge_server_is_not_of_interest (self, type)) {
return;
@@ -319,7 +308,7 @@ void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListe
if ((_tmp5_ = gee_collection_contains ((GeeCollection*) (_tmp4_ = gee_map_get_keys ((GeeMap*) self->priv->registered_clients)), client_name), _g_object_unref0 (_tmp4_), _tmp5_)) {
PlayerController* _tmp6_;
PlayerController* _tmp7_;
- g_debug ("music-player-bridge.vala:92: It figured out that it already has an ins" \
+ g_debug ("music-player-bridge.vala:88: It figured out that it already has an ins" \
"tance for this player already");
player_controller_update_state (_tmp6_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name), PLAYER_CONTROLLER_STATE_READY);
_g_object_unref0 (_tmp6_);
@@ -329,8 +318,8 @@ void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListe
PlayerController* ctrl;
ctrl = player_controller_new (self->priv->root_menu, client_name, music_player_bridge_calculate_menu_position (self), PLAYER_CONTROLLER_STATE_READY);
gee_abstract_map_set ((GeeAbstractMap*) self->priv->registered_clients, client_name, ctrl);
- g_debug ("music-player-bridge.vala:103: New Client of name %s has successfully r" \
-"egistered with us", client_name);
+ g_debug ("music-player-bridge.vala:99: New Client of name %s has successfully re" \
+"gistered with us", client_name);
_g_object_unref0 (ctrl);
}
if ((_tmp9_ = player_controller_get_app_info (_tmp8_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name)) == NULL, _g_object_unref0 (_tmp8_), _tmp9_)) {
@@ -352,7 +341,7 @@ void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateLis
gboolean _tmp3_ = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (type != NULL);
- g_debug ("music-player-bridge.vala:115: MusicPlayerBridge -> on_server_removed w" \
+ g_debug ("music-player-bridge.vala:111: MusicPlayerBridge -> on_server_removed w" \
"ith value %s", type);
if (music_player_bridge_server_is_not_of_interest (self, type)) {
return;
@@ -367,7 +356,7 @@ void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateLis
PlayerController* _tmp4_;
player_controller_hibernate (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name));
_g_object_unref0 (_tmp4_);
- g_debug ("music-player-bridge.vala:120: Successively offlined client %s", client_name);
+ g_debug ("music-player-bridge.vala:116: Successively offlined client %s", client_name);
}
_g_free0 (client_name);
}
@@ -391,7 +380,7 @@ static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge
return result;
}
if (string_contains (type, "music") == FALSE) {
- g_debug ("music-player-bridge.vala:127: server is of no interest, it is not an " \
+ g_debug ("music-player-bridge.vala:123: server is of no interest, it is not an " \
"music server");
result = TRUE;
return result;
@@ -415,7 +404,7 @@ static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self,
}
if (_tmp1_) {
GAppInfo* app_info;
- g_debug ("music-player-bridge.vala:138: About to store desktop file path: %s", path);
+ g_debug ("music-player-bridge.vala:134: About to store desktop file path: %s", path);
familiar_players_db_insert (bridge->priv->playersDB, path);
app_info = music_player_bridge_create_app_info (path);
if (app_info != NULL) {
@@ -425,13 +414,13 @@ static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self,
PlayerController* ctrl;
ctrl = (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) bridge->priv->registered_clients, _tmp3_ = string_strip (_tmp2_ = g_utf8_strdown (g_app_info_get_name (app_info), -1))), _g_free0 (_tmp3_), _g_free0 (_tmp2_), _tmp4_);
g_object_set ((GObject*) ctrl, "app_info", app_info, NULL);
- g_debug ("music-player-bridge.vala:144: successfully created appinfo from path a" \
+ g_debug ("music-player-bridge.vala:140: successfully created appinfo from path a" \
"nd set it on the respective instance");
_g_object_unref0 (ctrl);
}
_g_object_unref0 (app_info);
} else {
- g_debug ("music-player-bridge.vala:148: Ignoring desktop file path because its e" \
+ g_debug ("music-player-bridge.vala:144: Ignoring desktop file path because its e" \
"ither invalid of the db cache file has it already: %s", path);
}
_g_object_unref0 (bridge);
@@ -450,20 +439,20 @@ void music_player_bridge_set_root_menu_item (MusicPlayerBridge* self, DbusmenuMe
void music_player_bridge_on_server_count_changed (MusicPlayerBridge* self, IndicateListenerServer* object, guint i) {
g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:160: MusicPlayerBridge-> on_server_count_chan" \
+ g_debug ("music-player-bridge.vala:156: MusicPlayerBridge-> on_server_count_chan" \
"ged with value %u", i);
}
void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0) {
g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:164: MusicPlayerBridge-> on_indicator_added");
+ g_debug ("music-player-bridge.vala:160: MusicPlayerBridge-> on_indicator_added");
}
void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0) {
g_return_if_fail (self != NULL);
- g_debug ("music-player-bridge.vala:169: MusicPlayerBridge -> on_indicator_remove" \
+ g_debug ("music-player-bridge.vala:165: MusicPlayerBridge -> on_indicator_remove" \
"d");
}
@@ -471,7 +460,7 @@ void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, Indicate
void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s) {
g_return_if_fail (self != NULL);
g_return_if_fail (s != NULL);
- g_debug ("music-player-bridge.vala:174: MusicPlayerBridge -> indicator_modified " \
+ g_debug ("music-player-bridge.vala:170: MusicPlayerBridge -> indicator_modified " \
"with vale %s", s);
}
@@ -484,7 +473,7 @@ GAppInfo* music_player_bridge_create_app_info (const char* path) {
g_return_val_if_fail (path != NULL, NULL);
info = g_desktop_app_info_new_from_filename (path);
if (path == NULL) {
- g_warning ("music-player-bridge.vala:181: Could not create a desktopappinfo instan" \
+ g_warning ("music-player-bridge.vala:177: Could not create a desktopappinfo instan" \
"ce from app: %s", path);
result = NULL;
_g_object_unref0 (info);
diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h
index 64ccb1c..d1a612f 100644
--- a/src/music-player-bridge.h
+++ b/src/music-player-bridge.h
@@ -1,4 +1,4 @@
-/* music-player-bridge.h generated by valac 0.9.7, the Vala compiler, do not modify */
+/* music-player-bridge.h generated by valac 0.9.8, the Vala compiler, do not modify */
#ifndef __MUSIC_PLAYER_BRIDGE_H__
@@ -19,10 +19,10 @@
#include <libdbusmenu-glib/server.h>
#include <gio/gio.h>
#include <gee.h>
-#include <float.h>
-#include <math.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus-glib.h>
+#include <float.h>
+#include <math.h>
G_BEGIN_DECLS
@@ -106,31 +106,19 @@ typedef struct _TitleMenuitemClass TitleMenuitemClass;
typedef struct _TitleMenuitemPrivate TitleMenuitemPrivate;
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
+#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 _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
+typedef struct _Mpris2Controller Mpris2Controller;
+typedef struct _Mpris2ControllerClass Mpris2ControllerClass;
#define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ())
#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ())
-typedef struct _MprisBridgePrivate MprisBridgePrivate;
-
-#define TYPE_MPRIS_CONTROLLER (mpris_controller_get_type ())
-#define MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CONTROLLER, MprisController))
-#define MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
-#define IS_MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CONTROLLER))
-#define IS_MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CONTROLLER))
-#define MPRIS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
-
-typedef struct _MprisController MprisController;
-typedef struct _MprisControllerClass MprisControllerClass;
-typedef struct _MprisControllerPrivate MprisControllerPrivate;
#define TYPE_MPRIS_ROOT (mpris_root_get_type ())
#define MPRIS_ROOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_ROOT, MprisRoot))
@@ -155,16 +143,6 @@ typedef struct _MprisPlayerIface MprisPlayerIface;
typedef struct _FreeDesktopProperties FreeDesktopProperties;
typedef struct _FreeDesktopPropertiesIface FreeDesktopPropertiesIface;
-
-#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;
typedef struct _Mpris2ControllerPrivate Mpris2ControllerPrivate;
#define TYPE_FAMILIAR_PLAYERS_DB (familiar_players_db_get_type ())
@@ -178,6 +156,17 @@ typedef struct _FamiliarPlayersDB FamiliarPlayersDB;
typedef struct _FamiliarPlayersDBClass FamiliarPlayersDBClass;
typedef struct _FamiliarPlayersDBPrivate FamiliarPlayersDBPrivate;
+#define TYPE_FETCH_FILE (fetch_file_get_type ())
+#define FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FETCH_FILE, FetchFile))
+#define FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FETCH_FILE, FetchFileClass))
+#define IS_FETCH_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FETCH_FILE))
+#define IS_FETCH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FETCH_FILE))
+#define FETCH_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FETCH_FILE, FetchFileClass))
+
+typedef struct _FetchFile FetchFile;
+typedef struct _FetchFileClass FetchFileClass;
+typedef struct _FetchFilePrivate FetchFilePrivate;
+
struct _MusicPlayerBridge {
GObject parent_instance;
MusicPlayerBridgePrivate * priv;
@@ -243,7 +232,7 @@ struct _PlayerController {
PlayerControllerPrivate * priv;
gint current_state;
GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
+ Mpris2Controller* mpris_bridge;
};
struct _PlayerControllerClass {
@@ -265,24 +254,6 @@ typedef enum {
PLAYER_CONTROLLER_STATE_DISCONNECTED
} PlayerControllerstate;
-struct _MprisBridge {
- GObject parent_instance;
- MprisBridgePrivate * priv;
-};
-
-struct _MprisBridgeClass {
- GObjectClass parent_class;
-};
-
-struct _MprisController {
- GObject parent_instance;
- MprisControllerPrivate * priv;
-};
-
-struct _MprisControllerClass {
- GObjectClass parent_class;
-};
-
struct _MprisRootIface {
GTypeInterface parent_iface;
void (*Quit) (MprisRoot* self, GError** error);
@@ -336,6 +307,15 @@ struct _FamiliarPlayersDBClass {
GObjectClass parent_class;
};
+struct _FetchFile {
+ GObject parent_instance;
+ FetchFilePrivate * priv;
+};
+
+struct _FetchFileClass {
+ GObjectClass parent_class;
+};
+
GType music_player_bridge_get_type (void) G_GNUC_CONST;
MusicPlayerBridge* music_player_bridge_new (void);
@@ -357,8 +337,11 @@ TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerContro
void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
GeeHashSet* transport_menuitem_attributes_format (void);
GType metadata_menuitem_get_type (void) G_GNUC_CONST;
+extern char* 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);
+void metadata_menuitem_fetch_art (MetadataMenuitem* self, const char* uri, const char* prop);
GeeHashSet* metadata_menuitem_attributes_format (void);
GType scrub_menuitem_get_type (void) G_GNUC_CONST;
ScrubMenuitem* scrub_menuitem_new (PlayerController* parent);
@@ -370,7 +353,7 @@ GType title_menuitem_get_type (void) G_GNUC_CONST;
TitleMenuitem* title_menuitem_new (PlayerController* parent);
TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
GeeHashSet* title_menuitem_attributes_format (void);
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
+GType mpris2_controller_get_type (void) G_GNUC_CONST;
GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
GType player_controller_state_get_type (void) G_GNUC_CONST;
#define PLAYER_CONTROLLER_WIDGET_QUANTITY 4
@@ -389,21 +372,6 @@ GAppInfo* player_controller_get_app_info (PlayerController* self);
void player_controller_set_app_info (PlayerController* self, GAppInfo* value);
gint player_controller_get_menu_offset (PlayerController* self);
void player_controller_set_menu_offset (PlayerController* self, gint value);
-MprisBridge* mpris_bridge_new (PlayerController* ctrl);
-MprisBridge* mpris_bridge_construct (GType object_type, PlayerController* ctrl);
-gboolean mpris_bridge_connected (MprisBridge* self);
-void mpris_bridge_transport_update (MprisBridge* self, TransportMenuitemaction update);
-void mpris_bridge_expose (MprisBridge* self);
-void mpris_bridge_set_track_position (MprisBridge* self, double pos);
-GType mpris_controller_get_type (void) G_GNUC_CONST;
-MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter);
-MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter);
-void mpris_controller_transport_event (MprisController* self, TransportMenuitemaction command);
-void mpris_controller_set_position (MprisController* self, double position);
-gboolean mpris_controller_connected (MprisController* self);
-DBusGProxy* mpris_controller_get_mpris_player (MprisController* self);
-PlayerController* mpris_controller_get_owner (MprisController* self);
-const char* mpris_controller_get_mpris_interface (MprisController* self);
MprisRoot* mpris_root_dbus_proxy_new (DBusGConnection* connection, const char* name, const char* path);
GType mpris_root_get_type (void) G_GNUC_CONST;
void mpris_root_Quit (MprisRoot* self, GError** error);
@@ -433,14 +401,13 @@ char* mpris_player_get_PlaybackStatus (MprisPlayer* self);
void mpris_player_set_PlaybackStatus (MprisPlayer* self, const char* value);
GType free_desktop_properties_get_type (void) G_GNUC_CONST;
FreeDesktopProperties* free_desktop_properties_dbus_proxy_new (DBusGConnection* connection, const char* name, const char* path);
-GType mpris2_controller_get_type (void) G_GNUC_CONST;
#define MPRIS2_CONTROLLER_root_interface "org.mpris.MediaPlayer2"
Mpris2Controller* mpris2_controller_new (PlayerController* ctrl);
Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl);
void mpris2_controller_property_changed_cb (Mpris2Controller* self, const char* interface_source, GHashTable* changed_properties, char** invalid, int invalid_length1);
void mpris2_controller_initial_update (Mpris2Controller* self);
-void mpris2_controller_transport_event (Mpris2Controller* self, TransportMenuitemaction command);
-void mpris2_controller_set_position (Mpris2Controller* self, double position);
+void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command);
+void mpris2_controller_set_track_position (Mpris2Controller* self, double position);
void mpris2_controller_onSeeked (Mpris2Controller* self, gint64 position);
gboolean mpris2_controller_connected (Mpris2Controller* self);
gboolean mpris2_controller_was_successfull (Mpris2Controller* self);
@@ -462,6 +429,13 @@ FamiliarPlayersDB* familiar_players_db_construct (GType object_type);
void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop);
gboolean familiar_players_db_already_familiar (FamiliarPlayersDB* self, const char* desktop);
GeeSet* familiar_players_db_records (FamiliarPlayersDB* self);
+GType fetch_file_get_type (void) G_GNUC_CONST;
+FetchFile* fetch_file_new (const char* uri, const char* prop);
+FetchFile* fetch_file_construct (GType object_type, const char* uri, const char* prop);
+void fetch_file_fetch_data (FetchFile* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void fetch_file_fetch_data_finish (FetchFile* self, GAsyncResult* _res_);
+const char* fetch_file_get_uri (FetchFile* self);
+const char* fetch_file_get_intended_property (FetchFile* self);
G_END_DECLS
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index daad42f..c677d15 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -44,30 +44,26 @@ public class MusicPlayerBridge : GLib.Object
}
private void try_to_add_inactive_familiar_clients(){
- // TODO handle multple players - just working with one right now
- int count = 0;
foreach(string app in this.playersDB.records()){
- if(count == 0){
- if(app == null){
- warning("App string in keyfile is null therefore moving on to next player");
- continue;
- }
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
- if(info == null){
- warning("Could not create a desktopappinfo instance from app: %s", app);
- continue;
- }
- GLib.AppInfo app_info = info as GLib.AppInfo;
- PlayerController ctrl = new PlayerController(this.root_menu,
- app_info.get_name(),
- calculate_menu_position(),
- PlayerController.state.OFFLINE);
- ctrl.set("app_info", app_info);
- this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
- debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
- count += 1;
+ if(app == null){
+ warning("App string in keyfile is null therefore moving on to next player");
+ continue;
+ }
+
+ debug("attempting to make an app info from %s", app);
+
+ DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
+ if(info == null){
+ warning("Could not create a desktopappinfo instance from app: %s", app);
+ continue;
}
- break;
+ GLib.AppInfo app_info = info as GLib.AppInfo;
+ PlayerController ctrl = new PlayerController(this.root_menu,
+ app_info.get_name(),
+ calculate_menu_position(),
+ PlayerController.state.OFFLINE);
+ ctrl.set("app_info", app_info);
+ this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
}
}
diff --git a/src/play-button.c b/src/play-button.c
index a2eaf2e..ccc23cb 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -409,11 +409,12 @@ play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command)
g_return_if_fail(IS_PLAY_BUTTON(button));
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
priv->current_command = command;
-
+
cairo_t *cr;
cr = gdk_cairo_create (button->window);
- GList* list = g_hash_table_lookup(priv->command_coordinates, GINT_TO_POINTER(command));
+ GList* list = g_hash_table_lookup(priv->command_coordinates,
+ GINT_TO_POINTER(priv->current_command));
cairo_rectangle(cr,
GPOINTER_TO_INT(g_list_nth_data(list, 0)),
GPOINTER_TO_INT(g_list_nth_data(list, 1)),
@@ -426,10 +427,19 @@ play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command)
void
-play_button_react_to_button_release(GtkWidget* button)
+play_button_react_to_button_release(GtkWidget* button, PlayButtonEvent command)
{
g_return_if_fail(IS_PLAY_BUTTON(button));
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+ if(priv->current_command == TRANSPORT_NADA){
+ g_debug("returning from the playbutton release because my previous command was nada");
+ return;
+ }
+ else if(priv->current_command != TRANSPORT_NADA &&
+ command != TRANSPORT_NADA){
+ priv->current_command = command;
+ }
+
cairo_t *cr;
cr = gdk_cairo_create (button->window);
@@ -437,7 +447,7 @@ play_button_react_to_button_release(GtkWidget* button)
GINT_TO_POINTER(priv->current_command));
priv->current_command = TRANSPORT_NADA;
-
+
cairo_rectangle(cr,
GPOINTER_TO_INT(g_list_nth_data(list, 0)),
GPOINTER_TO_INT(g_list_nth_data(list, 1)),
@@ -456,6 +466,7 @@ play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update)
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
priv->current_state = update;
g_debug("PlayButton::toggle play state : %i", priv->current_state);
+ gtk_widget_queue_draw (GTK_WIDGET(button));
}
@@ -955,7 +966,6 @@ draw (GtkWidget* button, cairo_t *cr)
}
-
/**
* play_button_new:
* @returns: a new #PlayButton.
diff --git a/src/play-button.h b/src/play-button.h
index 727a489..6bacac7 100644
--- a/src/play-button.h
+++ b/src/play-button.h
@@ -56,8 +56,8 @@ struct _PlayButton {
GType play_button_get_type (void);
void play_button_set_style(GtkWidget* button, GtkStyle* style);
PlayButtonEvent determine_button_event(GtkWidget* button, GdkEventButton* event);
-void play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command);
-void play_button_react_to_button_release(GtkWidget* button);
+void play_button_react_to_button_press(GtkWidget* button, PlayButtonEvent command);
+void play_button_react_to_button_release(GtkWidget* button, PlayButtonEvent command);
void play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update);
GtkWidget* play_button_new();
diff --git a/src/player-controller.c b/src/player-controller.c
index 28bb28c..51eafe8 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -1,4 +1,4 @@
-/* player-controller.c generated by valac 0.9.7, the Vala compiler
+/* player-controller.c generated by valac 0.9.8, the Vala compiler
* generated from player-controller.vala, do not modify */
/*
@@ -54,15 +54,15 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
typedef struct _PlayerItem PlayerItem;
typedef struct _PlayerItemClass PlayerItemClass;
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
+#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 _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
+typedef struct _Mpris2Controller Mpris2Controller;
+typedef struct _Mpris2ControllerClass Mpris2ControllerClass;
#define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ())
@@ -106,7 +106,7 @@ struct _PlayerController {
PlayerControllerPrivate * priv;
gint current_state;
GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
+ Mpris2Controller* mpris_bridge;
};
struct _PlayerControllerClass {
@@ -140,7 +140,7 @@ static gpointer player_controller_parent_class = NULL;
GType player_controller_get_type (void) G_GNUC_CONST;
GType player_item_get_type (void) G_GNUC_CONST;
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
+GType mpris2_controller_get_type (void) G_GNUC_CONST;
#define PLAYER_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLAYER_CONTROLLER, PlayerControllerPrivate))
enum {
PLAYER_CONTROLLER_DUMMY_PROPERTY,
@@ -164,8 +164,8 @@ const char* player_controller_get_name (PlayerController* self);
void player_controller_activate (PlayerController* self);
void player_controller_instantiate (PlayerController* self);
GAppInfo* player_controller_get_app_info (PlayerController* self);
-MprisBridge* mpris_bridge_new (PlayerController* ctrl);
-MprisBridge* mpris_bridge_construct (GType object_type, PlayerController* ctrl);
+Mpris2Controller* mpris2_controller_new (PlayerController* ctrl);
+Mpris2Controller* mpris2_controller_construct (GType object_type, PlayerController* ctrl);
void player_controller_determine_state (PlayerController* self);
void player_controller_vanish (PlayerController* self);
void player_controller_hibernate (PlayerController* self);
@@ -185,7 +185,7 @@ TransportMenuitem* transport_menuitem_new (PlayerController* parent);
TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent);
GType transport_menuitem_get_type (void) G_GNUC_CONST;
gint player_controller_get_menu_offset (PlayerController* self);
-gboolean mpris_bridge_connected (MprisBridge* self);
+gboolean mpris2_controller_connected (Mpris2Controller* self);
void player_controller_set_app_info (PlayerController* self, GAppInfo* value);
static void player_controller_finalize (GObject* obj);
static void player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
@@ -263,7 +263,7 @@ PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* cli
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) {
g_return_if_fail (self != NULL);
- g_debug ("player-controller.vala:66: update_state - player controller %s : new s" \
+ g_debug ("player-controller.vala:69: update_state - player controller %s : new s" \
"tate %i", self->priv->_name, (gint) new_state);
self->current_state = (gint) new_state;
player_controller_update_layout (self);
@@ -279,27 +279,27 @@ void player_controller_activate (PlayerController* self) {
void player_controller_instantiate (PlayerController* self) {
GError * _inner_error_ = NULL;
g_return_if_fail (self != NULL);
- g_debug ("player-controller.vala:84: instantiate in player controller for %s", self->priv->_name);
+ g_debug ("player-controller.vala:87: instantiate in player controller for %s", self->priv->_name);
{
g_app_info_launch (self->priv->_app_info, NULL, NULL, &_inner_error_);
if (_inner_error_ != NULL) {
- goto __catch0_g_error;
+ goto __catch4_g_error;
}
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_INSTANTIATING);
}
- goto __finally0;
- __catch0_g_error:
+ goto __finally4;
+ __catch4_g_error:
{
GError * _error_;
_error_ = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("player-controller.vala:90: Failed to launch app %s with error message:" \
+ g_warning ("player-controller.vala:93: Failed to launch app %s with error message:" \
" %s", self->priv->_name, _error_->message);
_g_error_free0 (_error_);
}
}
- __finally0:
+ __finally4:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -309,14 +309,14 @@ void player_controller_instantiate (PlayerController* self) {
static void player_controller_establish_mpris_connection (PlayerController* self) {
- MprisBridge* _tmp0_;
+ Mpris2Controller* _tmp0_;
g_return_if_fail (self != NULL);
if (self->current_state != PLAYER_CONTROLLER_STATE_READY) {
- g_debug ("player-controller.vala:97: establish_mpris_connection - Not ready to c" \
-"onnect");
+ g_debug ("player-controller.vala:100: establish_mpris_connection - Not ready to " \
+"connect");
return;
}
- self->mpris_bridge = (_tmp0_ = mpris_bridge_new (self), _g_object_unref0 (self->mpris_bridge), _tmp0_);
+ self->mpris_bridge = (_tmp0_ = mpris2_controller_new (self), _g_object_unref0 (self->mpris_bridge), _tmp0_);
player_controller_determine_state (self);
}
@@ -414,6 +414,14 @@ static void player_controller_construct_widgets (PlayerController* self) {
}
+static glong string_get_length (const char* self) {
+ glong result;
+ g_return_val_if_fail (self != NULL, 0L);
+ result = g_utf8_strlen (self, (gssize) (-1));
+ return result;
+}
+
+
static char* string_slice (const char* self, glong start, glong end) {
char* result = NULL;
glong string_length;
@@ -421,7 +429,7 @@ static char* string_slice (const char* self, glong start, glong end) {
gboolean _tmp1_ = FALSE;
const char* start_string;
g_return_val_if_fail (self != NULL, NULL);
- string_length = g_utf8_strlen (self, -1);
+ string_length = string_get_length (self);
if (start < 0) {
start = string_length + start;
}
@@ -459,7 +467,7 @@ static char* player_controller_format_client_name (const char* client_name) {
formatted = (_tmp2_ = g_strconcat (_tmp0_ = g_utf8_strup (client_name, (gssize) 1), _tmp1_ = string_slice (client_name, (glong) 1, g_utf8_strlen (client_name, -1)), NULL), _g_free0 (formatted), _tmp2_);
_g_free0 (_tmp1_);
_g_free0 (_tmp0_);
- g_debug ("player-controller.vala:160: PlayerController->format_client_name - : %" \
+ g_debug ("player-controller.vala:163: PlayerController->format_client_name - : %" \
"s", formatted);
}
result = formatted;
@@ -469,7 +477,7 @@ static char* player_controller_format_client_name (const char* client_name) {
void player_controller_determine_state (PlayerController* self) {
g_return_if_fail (self != NULL);
- if (mpris_bridge_connected (self->mpris_bridge) == TRUE) {
+ if (mpris2_controller_connected (self->mpris_bridge) == TRUE) {
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED);
} else {
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED);
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 3e12dce..4d9f054 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -45,11 +45,14 @@ public class PlayerController : GLib.Object
private Dbusmenu.Menuitem root_menu;
public string name { get; set;}
public ArrayList<PlayerItem> custom_items;
- public MprisBridge mpris_bridge;
+ public Mpris2Controller mpris_bridge;
public AppInfo? app_info { get; set;}
public int menu_offset { get; set;}
- public PlayerController(Dbusmenu.Menuitem root, string client_name, int offset, state initial_state)
+ public PlayerController(Dbusmenu.Menuitem root,
+ string client_name,
+ int offset,
+ state initial_state)
{
this.root_menu = root;
this.name = format_client_name(client_name.strip());
@@ -97,7 +100,7 @@ public class PlayerController : GLib.Object
debug("establish_mpris_connection - Not ready to connect");
return;
}
- this.mpris_bridge = new MprisBridge(this);
+ this.mpris_bridge = new Mpris2Controller(this);
this.determine_state();
}
diff --git a/src/player-item.c b/src/player-item.c
index f70c04c..2449bfb 100644
--- a/src/player-item.c
+++ b/src/player-item.c
@@ -1,4 +1,4 @@
-/* player-item.c generated by valac 0.9.7, the Vala compiler
+/* player-item.c generated by valac 0.9.8, the Vala compiler
* generated from player-item.vala, do not modify */
/*
@@ -53,7 +53,17 @@ typedef struct _PlayerController PlayerController;
typedef struct _PlayerControllerClass PlayerControllerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
-#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+#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 _MetadataMenuitem MetadataMenuitem;
+typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
+#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
@@ -86,6 +96,9 @@ PlayerItem* player_item_construct (GType object_type, const char* type);
void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
static GValue* _g_value_dup (GValue* self);
+GType metadata_menuitem_get_type (void) G_GNUC_CONST;
+void metadata_menuitem_fetch_art (MetadataMenuitem* self, const char* uri, const char* prop);
+static void _vala_GValue_free (GValue* self);
gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
PlayerController* player_item_get_owner (PlayerItem* self);
static void player_item_set_owner (PlayerItem* self, PlayerController* value);
@@ -135,6 +148,12 @@ void player_item_reset (PlayerItem* self, GeeHashSet* attrs) {
}
+/**
+ * update()
+ * Base update method for playeritems, takes the attributes and the incoming updates
+ * and attmepts to update the appropriate props on the object.
+ * Album art is handled separately to deal with remote and local file paths.
+ */
static GValue* _g_value_dup (GValue* self) {
return g_boxed_copy (G_TYPE_VALUE, self);
}
@@ -165,6 +184,17 @@ static gboolean string_contains (const char* self, const char* needle) {
}
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void _vala_GValue_free (GValue* self) {
+ g_value_unset (self);
+ g_free (self);
+}
+
+
static char* bool_to_string (gboolean self) {
char* result = NULL;
if (self) {
@@ -178,13 +208,12 @@ static char* bool_to_string (gboolean self) {
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes) {
- GError * _inner_error_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (attributes != NULL);
- g_debug ("player-item.vala:47: PlayerItem::update()");
+ g_debug ("player-item.vala:53: PlayerItem::update()");
if (data == NULL) {
- g_debug ("player-item.vala:49: PlayerItem::Update -> The hashtable was null - ju" \
+ g_debug ("player-item.vala:55: PlayerItem::Update -> The hashtable was null - ju" \
"st leave it!");
return;
}
@@ -208,80 +237,48 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
property = (char*) gee_iterator_get (_property_it);
input_keys = (_tmp1_ = _tmp0_ = g_strsplit (property, "-", 0), input_keys_length1 = _vala_array_length (_tmp0_), _input_keys_size_ = input_keys_length1, _tmp1_);
search_key = g_strdup ((_tmp3_ = input_keys + (input_keys_length1 - 1), _tmp2_ = input_keys_length1 - (input_keys_length1 - 1), _tmp3_)[0]);
- g_debug ("player-item.vala:56: search key = %s", search_key);
+ g_debug ("player-item.vala:62: search key = %s", search_key);
v = __g_value_dup0 ((GValue*) g_hash_table_lookup (data, search_key));
if (G_VALUE_HOLDS (v, G_TYPE_STRING)) {
char* update;
update = string_strip (g_value_get_string (v));
- g_debug ("player-item.vala:61: with value : %s", update);
+ g_debug ("player-item.vala:67: with value : %s", update);
if (string_contains (property, "mpris:artUrl")) {
- {
- char* _tmp4_;
- char* _tmp5_;
- char* _tmp6_;
- char* _tmp7_;
- _tmp6_ = (_tmp5_ = g_filename_from_uri (_tmp4_ = string_strip (update), NULL, &_inner_error_), _g_free0 (_tmp4_), _tmp5_);
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == G_CONVERT_ERROR) {
- goto __catch8_g_convert_error;
- }
- _g_free0 (update);
- _g_free0 (v);
- _g_free0 (search_key);
- input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
- _g_free0 (property);
- _g_object_unref0 (_property_it);
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- update = (_tmp7_ = _tmp6_, _g_free0 (update), _tmp7_);
- }
- goto __finally8;
- __catch8_g_convert_error:
- {
- GError * e;
- e = _inner_error_;
- _inner_error_ = NULL;
- {
- g_warning ("player-item.vala:68: Problem converting URI %s to file path", update);
- _g_error_free0 (e);
- }
- }
- __finally8:
- if (_inner_error_ != NULL) {
- _g_free0 (update);
- _g_free0 (v);
- _g_free0 (search_key);
- input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
- _g_free0 (property);
- _g_object_unref0 (_property_it);
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
+ PlayerItem* _tmp4_;
+ MetadataMenuitem* metadata;
+ char* _tmp5_;
+ metadata = _g_object_ref0 ((_tmp4_ = self, IS_METADATA_MENUITEM (_tmp4_) ? ((MetadataMenuitem*) _tmp4_) : NULL));
+ metadata_menuitem_fetch_art (metadata, _tmp5_ = string_strip (update), property);
+ _g_free0 (_tmp5_);
+ _g_object_unref0 (metadata);
+ _g_free0 (update);
+ __vala_GValue_free0 (v);
+ _g_free0 (search_key);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (property);
+ continue;
}
dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, property, update);
_g_free0 (update);
} else {
if (G_VALUE_HOLDS (v, G_TYPE_INT)) {
- g_debug ("player-item.vala:74: with value : %i", g_value_get_int (v));
+ g_debug ("player-item.vala:78: with value : %i", g_value_get_int (v));
dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, g_value_get_int (v));
} else {
if (G_VALUE_HOLDS (v, G_TYPE_INT64)) {
- g_debug ("player-item.vala:78: with value : %i", (gint) g_value_get_int64 (v));
+ g_debug ("player-item.vala:82: with value : %i", (gint) g_value_get_int64 (v));
dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, property, (gint) g_value_get_int64 (v));
} else {
if (G_VALUE_HOLDS (v, G_TYPE_BOOLEAN)) {
- char* _tmp8_;
- g_debug ("player-item.vala:82: with value : %s", _tmp8_ = bool_to_string (g_value_get_boolean (v)));
- _g_free0 (_tmp8_);
+ char* _tmp6_;
+ g_debug ("player-item.vala:86: with value : %s", _tmp6_ = bool_to_string (g_value_get_boolean (v)));
+ _g_free0 (_tmp6_);
dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, property, g_value_get_boolean (v));
}
}
}
}
- _g_free0 (v);
+ __vala_GValue_free0 (v);
_g_free0 (search_key);
input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (property);
@@ -308,9 +305,9 @@ gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs) {
break;
}
prop = (char*) gee_iterator_get (_prop_it);
- g_debug ("player-item.vala:95: populated ? - prop: %s", prop);
+ g_debug ("player-item.vala:98: populated ? - prop: %s", prop);
value_int = dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop);
- g_debug ("player-item.vala:97: populated ? - prop %s and value %i", prop, value_int);
+ g_debug ("player-item.vala:100: populated ? - prop %s and value %i", prop, value_int);
if (dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop) != PLAYER_ITEM_EMPTY) {
result = TRUE;
_g_free0 (prop);
@@ -334,11 +331,6 @@ PlayerController* player_item_get_owner (PlayerItem* self) {
}
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
-}
-
-
static void player_item_set_owner (PlayerItem* self, PlayerController* value) {
PlayerController* _tmp0_;
g_return_if_fail (self != NULL);
diff --git a/src/player-item.vala b/src/player-item.vala
index fbfacbd..68ae6ef 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -25,7 +25,7 @@ public class PlayerItem : Dbusmenu.Menuitem
public PlayerController owner {get; construct;}
public string item_type { get; construct; }
private const int EMPTY = -1;
-
+
public PlayerItem(string type)
{
Object(item_type: type);
@@ -42,6 +42,12 @@ public class PlayerItem : Dbusmenu.Menuitem
}
}
+ /**
+ * update()
+ * Base update method for playeritems, takes the attributes and the incoming updates
+ * and attmepts to update the appropriate props on the object.
+ * Album art is handled separately to deal with remote and local file paths.
+ */
public void update(HashTable<string, Value?> data, HashSet<string> attributes)
{
debug("PlayerItem::update()");
@@ -59,16 +65,14 @@ public class PlayerItem : Dbusmenu.Menuitem
if (v.holds (typeof (string))){
string update = v.get_string().strip();
debug("with value : %s", update);
- // Special case for the arturl URI's.
- if(property.contains("mpris:artUrl")){
- try{
- update = Filename.from_uri(update.strip());
- }
- catch(ConvertError e){
- warning("Problem converting URI %s to file path", update);
- }
+ if(property.contains("mpris:artUrl")){
+ // We know its a metadata instance because thats the only
+ // object with the arturl prop
+ MetadataMenuitem metadata = this as MetadataMenuitem;
+ metadata.fetch_art(update.strip(), property);
+ continue;
}
- this.property_set(property, update);
+ this.property_set(property, update);
}
else if (v.holds (typeof (int))){
debug("with value : %i", v.get_int());
@@ -83,7 +87,6 @@ public class PlayerItem : Dbusmenu.Menuitem
this.property_set_bool(property, v.get_boolean());
}
}
-
if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){
this.property_set_bool(MENUITEM_PROP_VISIBLE, true);
}
@@ -101,5 +104,6 @@ public class PlayerItem : Dbusmenu.Menuitem
}
return false;
}
+
}
diff --git a/src/scrub-menu-item.c b/src/scrub-menu-item.c
index c4aa807..18a8129 100644
--- a/src/scrub-menu-item.c
+++ b/src/scrub-menu-item.c
@@ -1,4 +1,4 @@
-/* scrub-menu-item.c generated by valac 0.9.7, the Vala compiler
+/* scrub-menu-item.c generated by valac 0.9.8, the Vala compiler
* generated from scrub-menu-item.vala, do not modify */
/*
@@ -68,15 +68,15 @@ typedef struct _PlayerControllerClass PlayerControllerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
+#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 _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
+typedef struct _Mpris2Controller Mpris2Controller;
+typedef struct _Mpris2ControllerClass Mpris2ControllerClass;
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
@@ -101,7 +101,7 @@ struct _PlayerController {
PlayerControllerPrivate * priv;
gint current_state;
GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
+ Mpris2Controller* mpris_bridge;
};
struct _PlayerControllerClass {
@@ -124,8 +124,8 @@ GeeHashSet* scrub_menuitem_attributes_format (void);
static void scrub_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
PlayerController* player_item_get_owner (PlayerItem* self);
const char* player_controller_get_name (PlayerController* self);
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
-void mpris_bridge_set_track_position (MprisBridge* self, double pos);
+GType mpris2_controller_get_type (void) G_GNUC_CONST;
+void mpris2_controller_set_track_position (Mpris2Controller* self, double position);
void scrub_menuitem_update_position (ScrubMenuitem* self, gint32 new_position);
void scrub_menuitem_update_playstate (ScrubMenuitem* self, gint state);
@@ -152,7 +152,7 @@ static void scrub_menuitem_real_handle_event (DbusmenuMenuitem* base, const char
self = (ScrubMenuitem*) base;
g_return_if_fail (name != NULL);
g_debug ("scrub-menu-item.vala:34: handle_event for owner %s with value: %f", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)), g_value_get_double (input_value));
- mpris_bridge_set_track_position (player_item_get_owner ((PlayerItem*) self)->mpris_bridge, g_value_get_double (input_value));
+ mpris2_controller_set_track_position (player_item_get_owner ((PlayerItem*) self)->mpris_bridge, g_value_get_double (input_value));
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 12f067e..f19379d 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,14 +40,13 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- // TODO: uncomment for release !!
+ //TODO: uncomment for release !!
close_pulse_activites();
g_main_loop_quit(mainloop);
}
return;
}
-
/**
main:
**/
diff --git a/src/title-menu-item.c b/src/title-menu-item.c
index 2733bde..56621ac 100644
--- a/src/title-menu-item.c
+++ b/src/title-menu-item.c
@@ -1,4 +1,4 @@
-/* title-menu-item.c generated by valac 0.9.7, the Vala compiler
+/* title-menu-item.c generated by valac 0.9.8, the Vala compiler
* generated from title-menu-item.vala, do not modify */
/*
@@ -65,15 +65,15 @@ typedef struct _PlayerController PlayerController;
typedef struct _PlayerControllerClass PlayerControllerClass;
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
+#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 _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
+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)))
@@ -101,7 +101,7 @@ struct _PlayerController {
PlayerControllerPrivate * priv;
gint current_state;
GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
+ Mpris2Controller* mpris_bridge;
};
struct _PlayerControllerClass {
@@ -130,10 +130,10 @@ TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* pa
const char* player_controller_get_name (PlayerController* self);
static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
PlayerController* player_item_get_owner (PlayerItem* self);
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
+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 mpris_bridge_expose (MprisBridge* self);
+void mpris2_controller_expose (Mpris2Controller* self);
GeeHashSet* title_menuitem_attributes_format (void);
@@ -160,7 +160,7 @@ static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const char
player_controller_instantiate (player_item_get_owner ((PlayerItem*) self));
} else {
if (player_item_get_owner ((PlayerItem*) self)->current_state == PLAYER_CONTROLLER_STATE_CONNECTED) {
- mpris_bridge_expose (player_item_get_owner ((PlayerItem*) self)->mpris_bridge);
+ mpris2_controller_expose (player_item_get_owner ((PlayerItem*) self)->mpris_bridge);
}
}
}
diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c
index 40051f4..ff00f5f 100644
--- a/src/transport-menu-item.c
+++ b/src/transport-menu-item.c
@@ -1,4 +1,4 @@
-/* transport-menu-item.c generated by valac 0.9.7, the Vala compiler
+/* transport-menu-item.c generated by valac 0.9.8, the Vala compiler
* generated from transport-menu-item.vala, do not modify */
/*
@@ -68,15 +68,15 @@ typedef struct _PlayerControllerClass PlayerControllerClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
-#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ())
-#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge))
-#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
-#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE))
-#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE))
-#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass))
+#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 _MprisBridge MprisBridge;
-typedef struct _MprisBridgeClass MprisBridgeClass;
+typedef struct _Mpris2Controller Mpris2Controller;
+typedef struct _Mpris2ControllerClass Mpris2ControllerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _PlayerItem {
@@ -108,7 +108,7 @@ struct _PlayerController {
PlayerControllerPrivate * priv;
gint current_state;
GeeArrayList* custom_items;
- MprisBridge* mpris_bridge;
+ Mpris2Controller* mpris_bridge;
};
struct _PlayerControllerClass {
@@ -131,8 +131,8 @@ void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
PlayerController* player_item_get_owner (PlayerItem* self);
const char* player_controller_get_name (PlayerController* self);
-GType mpris_bridge_get_type (void) G_GNUC_CONST;
-void mpris_bridge_transport_update (MprisBridge* self, TransportMenuitemaction update);
+GType mpris2_controller_get_type (void) G_GNUC_CONST;
+void mpris2_controller_transport_update (Mpris2Controller* self, TransportMenuitemaction command);
GeeHashSet* transport_menuitem_attributes_format (void);
@@ -179,7 +179,7 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const
g_debug ("transport-menu-item.vala:46: handle_event with value %s", _tmp0_ = g_strdup_printf ("%i", input));
_g_free0 (_tmp0_);
g_debug ("transport-menu-item.vala:47: transport owner name = %s", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)));
- mpris_bridge_transport_update (player_item_get_owner ((PlayerItem*) self)->mpris_bridge, (TransportMenuitemaction) input);
+ mpris2_controller_transport_update (player_item_get_owner ((PlayerItem*) self)->mpris_bridge, (TransportMenuitemaction) input);
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 702b472..979f6fd 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -136,22 +136,12 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
-
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
-
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (GTK_WIDGET (menuitem));
-
+
PlayButtonEvent result = determine_button_event(priv->play_button, event);
if(result != TRANSPORT_NADA){
- GValue value = {0};
- g_value_init(&value, G_TYPE_INT);
- g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
- g_value_set_int(&value, (int)result);
play_button_react_to_button_press(priv->play_button, result);
- dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
}
return TRUE;
}
@@ -164,7 +154,17 @@ transport_widget_button_release_event (GtkWidget *menuitem,
g_debug("TransportWidget::menu_release_event");
g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
- play_button_react_to_button_release(priv->play_button);
+
+ PlayButtonEvent result = determine_button_event(priv->play_button, event);
+
+ if(result != TRANSPORT_NADA){
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_INT);
+ g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
+ g_value_set_int(&value, (int)result);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
+ }
+ play_button_react_to_button_release(priv->play_button, result);
return TRUE;
}
@@ -187,6 +187,7 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
int update_value = g_value_get_int(value);
g_debug("transport_widget_update_state - with value %i", update_value);
play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
+
}
}
diff --git a/src/volume-widget.c b/src/volume-widget.c
index bf1ddb9..5e7cf9f 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -1,3 +1,4 @@
+
/*
Copyright 2010 Canonical Ltd.
@@ -48,6 +49,7 @@ static void volume_widget_set_twin_item( VolumeWidget* self,
DbusmenuMenuitem* twin_item);
static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata);
+
static gboolean volume_widget_change_value_cb (GtkRange *range,
GtkScrollType scroll,
gdouble value,
@@ -103,7 +105,7 @@ volume_widget_init (VolumeWidget *self)
g_object_unref(secondary_gicon);
GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (volume_widget));
- gtk_adjustment_set_step_increment(adj, 3);
+ gtk_adjustment_set_step_increment(adj, 4);
}
static void