aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2010-07-12 17:45:04 +0200
committerSebastien Bacher <seb128@ubuntu.com>2010-07-12 17:45:04 +0200
commitf6ffb190261dfdbbf55e90b63c1cd06f03037e35 (patch)
treef34ba1947d158c3c38de6556f4049c518dc58c43
parent964106d9c8c140d9c27a22aca8078dfdab57c5e9 (diff)
parentd8253fc0cfe667316e2e5f033bcbfba4c3044297 (diff)
downloadayatana-indicator-sound-f6ffb190261dfdbbf55e90b63c1cd06f03037e35.tar.gz
ayatana-indicator-sound-f6ffb190261dfdbbf55e90b63c1cd06f03037e35.tar.bz2
ayatana-indicator-sound-f6ffb190261dfdbbf55e90b63c1cd06f03037e35.zip
Import upstream version 0.3.6
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac4
-rw-r--r--src/indicator-sound.c4
-rw-r--r--src/mpris-controller-v2.c21
-rw-r--r--src/mpris-controller-v2.vala4
-rw-r--r--src/mpris-controller.c493
-rw-r--r--src/mpris-controller.vala40
-rw-r--r--src/music-player-bridge.c127
-rw-r--r--src/music-player-bridge.h23
-rw-r--r--src/music-player-bridge.vala47
-rw-r--r--src/play-button.c14
-rw-r--r--src/player-controller.c98
-rw-r--r--src/player-controller.vala25
-rw-r--r--src/player-item.c143
-rw-r--r--src/player-item.vala23
-rw-r--r--src/title-menu-item.c32
-rw-r--r--src/title-menu-item.vala7
-rw-r--r--src/title-widget.c53
-rw-r--r--src/transport-menu-item.c4
-rw-r--r--src/transport-menu-item.vala2
-rw-r--r--src/transport-widget.c47
21 files changed, 705 insertions, 526 deletions
diff --git a/configure b/configure
index 0d44171..32d0f76 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.65 for indicator-sound 0.3.5.
+# Generated by GNU Autoconf 2.65 for indicator-sound 0.3.6.
#
# Report bugs to <conor.curran@canonical.com>.
#
@@ -761,8 +761,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='indicator-sound'
PACKAGE_TARNAME='indicator-sound'
-PACKAGE_VERSION='0.3.5'
-PACKAGE_STRING='indicator-sound 0.3.5'
+PACKAGE_VERSION='0.3.6'
+PACKAGE_STRING='indicator-sound 0.3.6'
PACKAGE_BUGREPORT='conor.curran@canonical.com'
PACKAGE_URL=''
@@ -1555,7 +1555,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures indicator-sound 0.3.5 to adapt to many kinds of systems.
+\`configure' configures indicator-sound 0.3.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1625,7 +1625,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of indicator-sound 0.3.5:";;
+ short | recursive ) echo "Configuration of indicator-sound 0.3.6:";;
esac
cat <<\_ACEOF
@@ -1752,7 +1752,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-indicator-sound configure 0.3.5
+indicator-sound configure 0.3.6
generated by GNU Autoconf 2.65
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -2123,7 +2123,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by indicator-sound $as_me 0.3.5, which was
+It was created by indicator-sound $as_me 0.3.6, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ $0 $@
@@ -2936,7 +2936,7 @@ fi
# Define the identity of the package.
PACKAGE=indicator-sound
- VERSION=0.3.5
+ VERSION=0.3.6
cat >>confdefs.h <<_ACEOF
@@ -14069,7 +14069,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by indicator-sound $as_me 0.3.5, which was
+This file was extended by indicator-sound $as_me 0.3.6, which was
generated by GNU Autoconf 2.65. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -14135,7 +14135,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-indicator-sound config.status 0.3.5
+indicator-sound config.status 0.3.6
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 5a6abc4..0a41bc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,10 @@
-AC_INIT(indicator-sound, 0.3.5, conor.curran@canonical.com)
+AC_INIT(indicator-sound, 0.3.6, conor.curran@canonical.com)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-sound, 0.3.5)
+AM_INIT_AUTOMAKE(indicator-sound, 0.3.6)
AM_MAINTAINER_MODE
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 8be97b4..a2d9762 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -366,10 +366,10 @@ new_title_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu
title = title_widget_new (newitem);
GtkMenuItem *menu_title_widget = GTK_MENU_ITEM(title);
- dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent);
-
gtk_widget_show_all(title);
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_title_widget, parent);
+
return TRUE;
}
diff --git a/src/mpris-controller-v2.c b/src/mpris-controller-v2.c
index 4a48165..40fe3da 100644
--- a/src/mpris-controller-v2.c
+++ b/src/mpris-controller-v2.c
@@ -23,8 +23,6 @@ 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>
@@ -64,7 +62,6 @@ typedef struct _PlayerControllerClass PlayerControllerClass;
struct _MprisController {
GObject parent_instance;
MprisControllerPrivate * priv;
- DBusGProxy* mpris_player;
};
struct _MprisControllerClass {
@@ -89,24 +86,22 @@ enum {
MPRIS_CONTROLLER_V2_DUMMY_PROPERTY
};
GType player_controller_get_type (void);
-MprisController* mpris_controller_new (const char* name, PlayerController* controller, const char* mpris_interface);
-MprisController* mpris_controller_construct (GType object_type, const char* name, PlayerController* controller, const char* mpris_interface);
-MprisControllerV2* mpris_controller_v2_new (const char* name, PlayerController* controller);
-MprisControllerV2* mpris_controller_v2_construct (GType object_type, const char* name, PlayerController* controller);
+MprisControllerV2* mpris_controller_v2_new (PlayerController* ctrl, const char* inter);
+MprisControllerV2* mpris_controller_v2_construct (GType object_type, PlayerController* ctrl, const char* inter);
-MprisControllerV2* mpris_controller_v2_construct (GType object_type, const char* name, PlayerController* controller) {
+MprisControllerV2* mpris_controller_v2_construct (GType object_type, PlayerController* ctrl, const char* inter) {
MprisControllerV2 * self;
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (controller != NULL, NULL);
- self = (MprisControllerV2*) mpris_controller_construct (object_type, name, controller, "org.mpris.MediaPlayer.Player");
+ g_return_val_if_fail (ctrl != NULL, NULL);
+ g_return_val_if_fail (inter != NULL, NULL);
+ self = (MprisControllerV2*) g_object_new (object_type, "owner", ctrl, "mpris-interface", inter, NULL);
return self;
}
-MprisControllerV2* mpris_controller_v2_new (const char* name, PlayerController* controller) {
- return mpris_controller_v2_construct (TYPE_MPRIS_CONTROLLER_V2, name, controller);
+MprisControllerV2* mpris_controller_v2_new (PlayerController* ctrl, const char* inter) {
+ return mpris_controller_v2_construct (TYPE_MPRIS_CONTROLLER_V2, ctrl, inter);
}
diff --git a/src/mpris-controller-v2.vala b/src/mpris-controller-v2.vala
index 0392cfc..efb5084 100644
--- a/src/mpris-controller-v2.vala
+++ b/src/mpris-controller-v2.vala
@@ -21,8 +21,8 @@ using Gee;
public class MprisControllerV2 : MprisController
{
- public MprisControllerV2(string name, PlayerController controller){
- base(name, controller, "org.mpris.MediaPlayer.Player");
+ public MprisControllerV2(PlayerController ctrl, string inter="org.mpris.MediaPlayer.Player"){
+ Object(owner: ctrl, mpris_interface: inter);
}
}
diff --git a/src/mpris-controller.c b/src/mpris-controller.c
index 7ef0aa3..041177c 100644
--- a/src/mpris-controller.c
+++ b/src/mpris-controller.c
@@ -56,11 +56,7 @@ 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_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (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 ())
@@ -73,6 +69,13 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
typedef struct _PlayerItem PlayerItem;
typedef struct _PlayerItemClass PlayerItemClass;
+#define TRANSPORT_MENUITEM_TYPE_ACTION (transport_menuitem_action_get_type ())
+
+#define MPRIS_CONTROLLER_TYPE_STATUS (mpris_controller_status_get_type ())
+typedef struct _MprisControllerstatus MprisControllerstatus;
+#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
#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))
@@ -82,14 +85,10 @@ typedef struct _PlayerItemClass PlayerItemClass;
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 ())
struct _MprisController {
GObject parent_instance;
MprisControllerPrivate * priv;
- DBusGProxy* mpris_player;
};
struct _MprisControllerClass {
@@ -98,11 +97,10 @@ struct _MprisControllerClass {
struct _MprisControllerPrivate {
DBusGConnection* connection;
- PlayerController* controller;
-};
-
-struct _MprisControllerstatus {
- gint32 playback;
+ DBusGProxy* _mpris_player;
+ PlayerController* _owner;
+ char* _mpris_interface;
+ char* name;
};
struct _PlayerController {
@@ -123,6 +121,10 @@ typedef enum {
TRANSPORT_MENUITEM_ACTION_NEXT
} TransportMenuitemaction;
+struct _MprisControllerstatus {
+ gint32 playback;
+};
+
static gpointer mpris_controller_parent_class = NULL;
@@ -130,172 +132,68 @@ GType mpris_controller_get_type (void);
GType player_controller_get_type (void);
#define MPRIS_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS_CONTROLLER, MprisControllerPrivate))
enum {
- MPRIS_CONTROLLER_DUMMY_PROPERTY
+ 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);
+PlayerController* mpris_controller_get_owner (MprisController* self);
+GType player_item_get_type (void);
+#define PLAYER_CONTROLLER_METADATA 2
+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 mpris_controller_onTrackChange (MprisController* self, DBusGProxy* mpris_client, GHashTable* ht);
-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);
+GType transport_menuitem_action_get_type (void);
+DBusGProxy* mpris_controller_get_mpris_player (MprisController* self);
static GType mpris_controller_status_get_type (void) G_GNUC_UNUSED;
static MprisControllerstatus* mpris_controller_status_dup (const MprisControllerstatus* self);
static void mpris_controller_status_free (MprisControllerstatus* self);
-static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* mpris_client, MprisControllerstatus* st);
-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 void _dynamic_GetStatus0 (DBusGProxy* self, MprisControllerstatus* result, GError** error);
-GType player_item_get_type (void);
-#define PLAYER_CONTROLLER_TRANSPORT 3
-GType transport_menuitem_get_type (void);
-void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
-static GHashTable* _dynamic_GetMetadata1 (DBusGProxy* self, GError** error);
-#define PLAYER_CONTROLLER_METADATA 2
-void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
-GeeHashSet* metadata_menuitem_attributes_format (void);
-MprisController* mpris_controller_new (const char* name, PlayerController* controller, const char* mpris_interface);
-MprisController* mpris_controller_construct (GType object_type, const char* name, PlayerController* controller, const char* mpris_interface);
-void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
-GType transport_menuitem_action_get_type (void);
-static void _dynamic_GetStatus2 (DBusGProxy* self, MprisControllerstatus* result, GError** error);
-static void _dynamic_Play3 (DBusGProxy* self, GError** error);
-static void _dynamic_Pause4 (DBusGProxy* self, GError** error);
-static void _dynamic_previous5 (DBusGProxy* self, GError** error);
-static void _dynamic_next6 (DBusGProxy* self, GError** error);
+static void _dynamic_Play1 (DBusGProxy* self, GError** error);
+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_transport_event (MprisController* self, TransportMenuitemaction command);
gboolean mpris_controller_connected (MprisController* self);
static GValue* _g_value_dup (GValue* self);
+#define PLAYER_CONTROLLER_TRANSPORT 3
GeeHashSet* transport_menuitem_attributes_format (void);
+static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* mpris_client, MprisControllerstatus* st);
+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 void _dynamic_GetStatus5 (DBusGProxy* self, MprisControllerstatus* result, GError** error);
+GType transport_menuitem_get_type (void);
+void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
+static GHashTable* _dynamic_GetMetadata6 (DBusGProxy* self, GError** error);
+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);
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
-}
-
-
-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, signal_name, 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_INVALID), G_TYPE_INVALID);
- dbus_g_proxy_add_signal (obj, "StatusChange", dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INVALID), G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (obj, signal_name, handler, data, NULL);
-}
-
-
-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_INVALID), &dbus_result, G_TYPE_INVALID);
- if (*error) {
- return;
- }
- result->playback = g_value_get_int (&dbus_result->values[0]);
-}
-
-
-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;
-}
-
-
-MprisController* mpris_controller_construct (GType object_type, const char* name, PlayerController* controller, const char* mpris_interface) {
- GError * _inner_error_;
+MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter) {
MprisController * self;
- PlayerController* _tmp2_;
- DBusGProxy* _tmp5_;
- char* _tmp4_;
- char* _tmp3_;
- MprisControllerstatus _tmp6_ = {0};
- MprisControllerstatus st;
- gint play_state;
- TransportMenuitem* _tmp8_;
- PlayerItem* _tmp7_;
- GHashTable* _tmp9_;
- GeeHashSet* _tmp12_;
- GHashTable* _tmp11_;
- PlayerItem* _tmp10_;
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (controller != NULL, NULL);
- g_return_val_if_fail (mpris_interface != NULL, NULL);
- _inner_error_ = NULL;
- self = (MprisController*) g_object_new (object_type, NULL);
- {
- DBusGConnection* _tmp0_;
- DBusGConnection* _tmp1_;
- _tmp0_ = dbus_g_bus_get (DBUS_BUS_SESSION, &_inner_error_);
- if (_inner_error_ != NULL) {
- goto __catch2_g_error;
- }
- self->priv->connection = (_tmp1_ = _tmp0_, _dbus_g_connection_unref0 (self->priv->connection), _tmp1_);
- }
- goto __finally2;
- __catch2_g_error:
- {
- GError * e;
- e = _inner_error_;
- _inner_error_ = NULL;
- {
- g_error ("mpris-controller.vala:39: Problems connecting to the session bus - %s", e->message);
- _g_error_free0 (e);
- }
- }
- __finally2:
- 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 NULL;
- }
- self->priv->controller = (_tmp2_ = _g_object_ref0 (controller), _g_object_unref0 (self->priv->controller), _tmp2_);
- self->mpris_player = (_tmp5_ = dbus_g_proxy_new_for_name (self->priv->connection, _tmp4_ = g_strconcat ("org.mpris.", _tmp3_ = g_utf8_strdown (name, -1), NULL), "/Player", mpris_interface), _g_object_unref0 (self->mpris_player), _tmp5_);
- _g_free0 (_tmp4_);
- _g_free0 (_tmp3_);
- _dynamic_TrackChange1_connect (self->mpris_player, "TrackChange", (GCallback) _mpris_controller_onTrackChange_dynamic_TrackChange0_, self);
- _dynamic_StatusChange3_connect (self->mpris_player, "StatusChange", (GCallback) _mpris_controller_onStatusChange_dynamic_StatusChange2_, self);
- st = (_dynamic_GetStatus0 (self->mpris_player, &_tmp6_, &_inner_error_), _tmp6_);
- 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 NULL;
- }
- play_state = (gint) st.playback;
- g_debug ("mpris-controller.vala:48: GetStatusChange - play state %i", play_state);
- transport_menuitem_change_play_state (_tmp8_ = (_tmp7_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->controller->custom_items, PLAYER_CONTROLLER_TRANSPORT), IS_TRANSPORT_MENUITEM (_tmp7_) ? ((TransportMenuitem*) _tmp7_) : NULL), play_state);
- _g_object_unref0 (_tmp8_);
- _tmp9_ = _dynamic_GetMetadata1 (self->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 NULL;
- }
- player_item_update (_tmp10_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->controller->custom_items, PLAYER_CONTROLLER_METADATA), _tmp11_ = _tmp9_, _tmp12_ = metadata_menuitem_attributes_format ());
- _g_object_unref0 (_tmp12_);
- _g_hash_table_unref0 (_tmp11_);
- _g_object_unref0 (_tmp10_);
+ 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 (const char* name, PlayerController* controller, const char* mpris_interface) {
- return mpris_controller_construct (TYPE_MPRIS_CONTROLLER, name, controller, mpris_interface);
+MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter) {
+ return mpris_controller_construct (TYPE_MPRIS_CONTROLLER, ctrl, inter);
}
@@ -307,17 +205,17 @@ static void mpris_controller_onTrackChange (MprisController* self, DBusGProxy* m
g_return_if_fail (self != NULL);
g_return_if_fail (mpris_client != NULL);
g_return_if_fail (ht != NULL);
- g_debug ("mpris-controller.vala:58: onTrackChange");
- player_item_reset (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->controller->custom_items, PLAYER_CONTROLLER_METADATA), _tmp1_ = metadata_menuitem_attributes_format ());
+ g_debug ("mpris-controller.vala:68: onTrackChange");
+ player_item_reset (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, PLAYER_CONTROLLER_METADATA), _tmp1_ = metadata_menuitem_attributes_format ());
_g_object_unref0 (_tmp1_);
_g_object_unref0 (_tmp0_);
- player_item_update (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->controller->custom_items, PLAYER_CONTROLLER_METADATA), ht, _tmp3_ = metadata_menuitem_attributes_format ());
+ player_item_update (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, PLAYER_CONTROLLER_METADATA), ht, _tmp3_ = metadata_menuitem_attributes_format ());
_g_object_unref0 (_tmp3_);
_g_object_unref0 (_tmp2_);
}
-static void _dynamic_GetStatus2 (DBusGProxy* self, MprisControllerstatus* result, GError** error) {
+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_INVALID), &dbus_result, G_TYPE_INVALID);
if (*error) {
@@ -327,7 +225,7 @@ static void _dynamic_GetStatus2 (DBusGProxy* self, MprisControllerstatus* result
}
-static void _dynamic_Play3 (DBusGProxy* self, GError** error) {
+static void _dynamic_Play1 (DBusGProxy* self, GError** error) {
dbus_g_proxy_call (self, "Play", error, G_TYPE_INVALID, G_TYPE_INVALID);
if (*error) {
return;
@@ -335,7 +233,7 @@ static void _dynamic_Play3 (DBusGProxy* self, GError** error) {
}
-static void _dynamic_Pause4 (DBusGProxy* self, GError** error) {
+static void _dynamic_Pause2 (DBusGProxy* self, GError** error) {
dbus_g_proxy_call (self, "Pause", error, G_TYPE_INVALID, G_TYPE_INVALID);
if (*error) {
return;
@@ -343,15 +241,15 @@ static void _dynamic_Pause4 (DBusGProxy* self, GError** error) {
}
-static void _dynamic_previous5 (DBusGProxy* self, GError** error) {
- dbus_g_proxy_call (self, "Previous", error, G_TYPE_INVALID, G_TYPE_INVALID);
+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_next6 (DBusGProxy* self, GError** error) {
+static void _dynamic_Next4 (DBusGProxy* self, GError** error) {
dbus_g_proxy_call (self, "Next", error, G_TYPE_INVALID, G_TYPE_INVALID);
if (*error) {
return;
@@ -363,33 +261,33 @@ void mpris_controller_transport_event (MprisController* self, TransportMenuitema
GError * _inner_error_;
g_return_if_fail (self != NULL);
_inner_error_ = NULL;
- g_debug ("mpris-controller.vala:70: transport_event input = %i", (gint) command);
+ g_debug ("mpris-controller.vala:80: transport_event input = %i", (gint) command);
if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) {
MprisControllerstatus _tmp0_ = {0};
MprisControllerstatus st;
gboolean play_state;
gboolean new_play_state;
- st = (_dynamic_GetStatus2 (self->mpris_player, &_tmp0_, &_inner_error_), _tmp0_);
+ 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 = st.playback == 1;
- g_debug ("mpris-controller.vala:74: toggle_playback - initial play state %i", (gint) play_state);
+ g_debug ("mpris-controller.vala:84: toggle_playback - initial play state %i", (gint) play_state);
new_play_state = !play_state;
- g_debug ("mpris-controller.vala:76: toggle_playback - new play state %i", (gint) new_play_state);
+ g_debug ("mpris-controller.vala:86: toggle_playback - new play state %i", (gint) new_play_state);
if (new_play_state == TRUE) {
- g_debug ("mpris-controller.vala:78: about to play");
- _dynamic_Play3 (self->mpris_player, &_inner_error_);
+ g_debug ("mpris-controller.vala:88: about to play");
+ _dynamic_Play1 (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 {
- g_debug ("mpris-controller.vala:82: about to pause");
- _dynamic_Pause4 (self->mpris_player, &_inner_error_);
+ g_debug ("mpris-controller.vala:92: about to 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_);
@@ -398,7 +296,7 @@ void mpris_controller_transport_event (MprisController* self, TransportMenuitema
}
} else {
if (command == TRANSPORT_MENUITEM_ACTION_PREVIOUS) {
- _dynamic_previous5 (self->mpris_player, &_inner_error_);
+ _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_);
@@ -406,7 +304,7 @@ void mpris_controller_transport_event (MprisController* self, TransportMenuitema
}
} else {
if (command == TRANSPORT_MENUITEM_ACTION_NEXT) {
- _dynamic_next6 (self->mpris_player, &_inner_error_);
+ _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_);
@@ -421,7 +319,7 @@ void mpris_controller_transport_event (MprisController* self, TransportMenuitema
gboolean mpris_controller_connected (MprisController* self) {
gboolean result = FALSE;
g_return_val_if_fail (self != NULL, FALSE);
- result = self->mpris_player != NULL;
+ result = self->priv->_mpris_player != NULL;
return result;
}
@@ -446,16 +344,16 @@ static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy*
PlayerItem* _tmp0_;
g_return_if_fail (self != NULL);
g_return_if_fail (mpris_client != NULL);
- g_debug ("mpris-controller.vala:101: onStatusChange - signal received");
+ g_debug ("mpris-controller.vala:111: 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:105: onStatusChange - play state %i", play_state);
+ g_debug ("mpris-controller.vala:115: onStatusChange - play state %i", play_state);
ht = g_hash_table_new (g_str_hash, g_str_equal);
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->controller->custom_items, PLAYER_CONTROLLER_TRANSPORT), ht, _tmp1_ = transport_menuitem_attributes_format ());
+ player_item_update (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, PLAYER_CONTROLLER_TRANSPORT), ht, _tmp1_ = transport_menuitem_attributes_format ());
_g_object_unref0 (_tmp1_);
_g_object_unref0 (_tmp0_);
_g_hash_table_unref0 (ht);
@@ -463,6 +361,185 @@ static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy*
}
+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, signal_name, 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_INVALID), G_TYPE_INVALID);
+ dbus_g_proxy_add_signal (obj, "StatusChange", dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INVALID), G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (obj, signal_name, handler, data, NULL);
+}
+
+
+static void _dynamic_GetStatus5 (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_INVALID), &dbus_result, G_TYPE_INVALID);
+ if (*error) {
+ return;
+ }
+ result->playback = g_value_get_int (&dbus_result->values[0]);
+}
+
+
+static GHashTable* _dynamic_GetMetadata6 (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 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;
+ {
+ DBusGProxy* _tmp4_;
+ char* _tmp3_;
+ char* _tmp2_;
+ char* _tmp6_;
+ char* _tmp5_;
+ MprisControllerstatus _tmp7_ = {0};
+ MprisControllerstatus st;
+ gint play_state;
+ TransportMenuitem* _tmp9_;
+ PlayerItem* _tmp8_;
+ GHashTable* _tmp10_;
+ GeeHashSet* _tmp13_;
+ GHashTable* _tmp12_;
+ PlayerItem* _tmp11_;
+ {
+ 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:47: 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:51: just attempting to establish an mpris connec" \
+"tion 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);
+ st = (_dynamic_GetStatus5 (self->priv->_mpris_player, &_tmp7_, &_inner_error_), _tmp7_);
+ 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_);
+ }
+ play_state = (gint) st.playback;
+ g_debug ("mpris-controller.vala:58: GetStatusChange - play state %i", play_state);
+ transport_menuitem_change_play_state (_tmp9_ = (_tmp8_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, PLAYER_CONTROLLER_TRANSPORT), IS_TRANSPORT_MENUITEM (_tmp8_) ? ((TransportMenuitem*) _tmp8_) : NULL), play_state);
+ _g_object_unref0 (_tmp9_);
+ _tmp10_ = _dynamic_GetMetadata6 (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_);
+ }
+ player_item_update (_tmp11_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, PLAYER_CONTROLLER_METADATA), _tmp12_ = _tmp10_, _tmp13_ = metadata_menuitem_attributes_format ());
+ _g_object_unref0 (_tmp13_);
+ _g_hash_table_unref0 (_tmp12_);
+ _g_object_unref0 (_tmp11_);
+ }
+ return obj;
+}
+
+
static MprisControllerstatus* mpris_controller_status_dup (const MprisControllerstatus* self) {
MprisControllerstatus* dup;
dup = g_new0 (MprisControllerstatus, 1);
@@ -490,7 +567,13 @@ static GType mpris_controller_status_get_type (void) {
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));
}
@@ -503,8 +586,10 @@ static void mpris_controller_finalize (GObject* obj) {
MprisController * self;
self = MPRIS_CONTROLLER (obj);
_dbus_g_connection_unref0 (self->priv->connection);
- _g_object_unref0 (self->mpris_player);
- _g_object_unref0 (self->priv->controller);
+ _g_object_unref0 (self->priv->_mpris_player);
+ _g_object_unref0 (self->priv->_owner);
+ _g_free0 (self->priv->_mpris_interface);
+ _g_free0 (self->priv->name);
G_OBJECT_CLASS (mpris_controller_parent_class)->finalize (obj);
}
@@ -521,6 +606,46 @@ GType mpris_controller_get_type (void) {
}
+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);
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index 2194d44..8dd0cc9 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -22,32 +22,42 @@ using Gee;
public class MprisController : GLib.Object
{
- private DBus.Connection connection;
- public dynamic DBus.Object mpris_player;
- private PlayerController controller;
- struct status {
+ private DBus.Connection connection;
+ public dynamic DBus.Object mpris_player{get; construct;}
+ public PlayerController owner {get; construct;}
+ public string mpris_interface {get; construct;}
+ private string name;
+
+
+ struct status {
public int32 playback;
//public int32 shuffle; // Not used just yet
//public int32 repeat;
//public int32 endless;
}
- public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){
+ 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.controller = controller;
- this.mpris_player = this.connection.get_object ("org.mpris.".concat(name.down()) , "/Player", mpris_interface);
- this.mpris_player.TrackChange += onTrackChange;
+ this.mpris_player = this.connection.get_object ("org.mpris.".concat(this.owner.name.down()) , "/Player", this.mpris_interface);
+
+ debug("just 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;
status st = this.mpris_player.GetStatus();
int play_state = st.playback;
debug("GetStatusChange - play state %i", play_state);
- (this.controller.custom_items[this.controller.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
- this.controller.custom_items[this.controller.METADATA].update(this.mpris_player.GetMetadata(),
+ (this.owner.custom_items[this.owner.TRANSPORT] as TransportMenuitem).change_play_state(play_state);
+ this.owner.custom_items[this.owner.METADATA].update(this.mpris_player.GetMetadata(),
MetadataMenuitem.attributes_format());
}
@@ -56,8 +66,8 @@ public class MprisController : GLib.Object
private void onTrackChange(dynamic DBus.Object mpris_client, HashTable<string,Value?> ht)
{
debug("onTrackChange");
- this.controller.custom_items[this.controller.METADATA].reset(MetadataMenuitem.attributes_format());
- this.controller.custom_items[this.controller.METADATA].update(ht,
+ this.owner.custom_items[this.owner.METADATA].reset(MetadataMenuitem.attributes_format());
+ this.owner.custom_items[this.owner.METADATA].update(ht,
MetadataMenuitem.attributes_format());
}
@@ -84,10 +94,10 @@ public class MprisController : GLib.Object
}
}
else if(command == TransportMenuitem.action.PREVIOUS){
- this.mpris_player.previous();
+ this.mpris_player.Prev();
}
else if(command == TransportMenuitem.action.NEXT){
- this.mpris_player.next();
+ this.mpris_player.Next();
}
}
@@ -107,7 +117,7 @@ public class MprisController : GLib.Object
Value v = Value(typeof(int));
v.set_int(play_state);
ht.insert("state", v);
- this.controller.custom_items[this.controller.TRANSPORT].update(ht, TransportMenuitem.attributes_format());
+ this.owner.custom_items[this.owner.TRANSPORT].update(ht, TransportMenuitem.attributes_format());
}
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c
index 9fd386a..2dfc99c 100644
--- a/src/music-player-bridge.c
+++ b/src/music-player-bridge.c
@@ -72,7 +72,6 @@ typedef struct _FamiliarPlayersDBClass FamiliarPlayersDBClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ())
-#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
struct _MusicPlayerBridge {
GObject parent_instance;
@@ -125,9 +124,10 @@ static void _music_player_bridge_on_server_count_changed_indicate_listener_serve
MusicPlayerBridge* music_player_bridge_new (void);
MusicPlayerBridge* music_player_bridge_construct (GType object_type);
GeeSet* familiar_players_db_records (FamiliarPlayersDB* self);
+static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self);
GType player_controller_state_get_type (void);
-PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state);
-PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state);
+PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
+PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self);
static gboolean music_player_bridge_server_is_not_of_interest (MusicPlayerBridge* self, const char* type);
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
@@ -217,10 +217,8 @@ static char* string_strip (const char* self) {
static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlayerBridge* self) {
- GError * _inner_error_;
gint count;
g_return_if_fail (self != NULL);
- _inner_error_ = NULL;
count = 0;
{
GeeSet* _tmp0_;
@@ -234,64 +232,42 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
}
app = (char*) gee_iterator_get (_app_it);
if (count == 0) {
+ GDesktopAppInfo* info;
+ GDesktopAppInfo* _tmp2_;
+ GAppInfo* app_info;
+ PlayerController* ctrl;
+ char* _tmp4_;
+ char* _tmp3_;
+ char* _tmp6_;
+ char* _tmp5_;
if (app == NULL) {
g_warning ("music-player-bridge.vala:52: App string in keyfile is null therefore m" \
"oving on to next player");
_g_free0 (app);
continue;
}
- {
- GDesktopAppInfo* info;
- GDesktopAppInfo* _tmp2_;
- GAppInfo* app_info;
- PlayerController* ctrl;
- char* _tmp4_;
- char* _tmp3_;
- char* _tmp6_;
- char* _tmp5_;
- info = g_desktop_app_info_new_from_filename (app);
- if (info == NULL) {
- g_warning ("music-player-bridge.vala:58: Could not create a desktopappinfo instanc" \
+ 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), 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 (info);
- _g_object_unref0 (app_info);
- _g_object_unref0 (ctrl);
- }
- goto __finally0;
- __catch0_g_error:
- {
- GError * er;
- er = _inner_error_;
- _inner_error_ = NULL;
- {
- g_warning ("music-player-bridge.vala:71: desktop path in cache is not formatted as" \
-" we have anticipated");
- _g_error_free0 (er);
- }
- }
- __finally0:
- if (_inner_error_ != NULL) {
_g_free0 (app);
- _g_object_unref0 (_app_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;
+ 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 (info);
+ _g_object_unref0 (app_info);
+ _g_object_unref0 (ctrl);
}
_g_free0 (app);
break;
@@ -301,6 +277,19 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
}
+static gint music_player_bridge_calculate_menu_position (MusicPlayerBridge* self) {
+ gint result = 0;
+ g_return_val_if_fail (self != NULL, 0);
+ if (gee_map_get_size ((GeeMap*) self->priv->registered_clients) == 0) {
+ result = 2;
+ return result;
+ } else {
+ result = 2 + (gee_map_get_size ((GeeMap*) self->priv->registered_clients) * 4);
+ return result;
+ }
+}
+
+
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type) {
gint _tmp1__length1;
char** _tmp1_;
@@ -310,7 +299,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:80: MusicPlayerBridge -> on_server_added with" \
+ g_debug ("music-player-bridge.vala:86: MusicPlayerBridge -> on_server_added with" \
" value %s", type);
if (music_player_bridge_server_is_not_of_interest (self, type)) {
return;
@@ -329,7 +318,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:86: It figured out that it already has an ins" \
+ g_debug ("music-player-bridge.vala:92: 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_);
@@ -337,10 +326,10 @@ void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListe
_g_object_unref0 (_tmp7_);
} else {
PlayerController* ctrl;
- ctrl = player_controller_new (self->priv->root_menu, client_name, PLAYER_CONTROLLER_STATE_READY);
+ 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:94: New Client of name %s has successfully re" \
-"gistered with us", client_name);
+ g_debug ("music-player-bridge.vala:105: New Client of name %s has successfully r" \
+"egistered 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_)) {
@@ -362,7 +351,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:106: MusicPlayerBridge -> on_server_removed w" \
+ g_debug ("music-player-bridge.vala:117: MusicPlayerBridge -> on_server_removed w" \
"ith value %s", type);
if (music_player_bridge_server_is_not_of_interest (self, type)) {
return;
@@ -378,7 +367,7 @@ void music_player_bridge_on_server_removed (MusicPlayerBridge* self, IndicateLis
player_controller_vanish (_tmp4_ = (PlayerController*) gee_abstract_map_get ((GeeAbstractMap*) self->priv->registered_clients, client_name));
_g_object_unref0 (_tmp4_);
gee_map_remove ((GeeMap*) self->priv->registered_clients, client_name, NULL);
- g_debug ("music-player-bridge.vala:112: Successively removed menu_item for clien" \
+ g_debug ("music-player-bridge.vala:123: Successively removed menu_item for clien" \
"t %s from registered_clients", client_name);
}
_g_free0 (client_name);
@@ -403,7 +392,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:120: server is of no interest, it is not an " \
+ g_debug ("music-player-bridge.vala:131: server is of no interest, it is not an " \
"music server");
result = TRUE;
return result;
@@ -427,7 +416,7 @@ static void music_player_bridge_desktop_info_callback (MusicPlayerBridge* self,
}
if (_tmp1_) {
GAppInfo* app_info;
- g_debug ("music-player-bridge.vala:131: About to store desktop file path: %s", path);
+ g_debug ("music-player-bridge.vala:142: 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) {
@@ -437,13 +426,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:137: successfully created appinfo from path a" \
+ g_debug ("music-player-bridge.vala:148: 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:141: Ignoring desktop file path because its e" \
+ g_debug ("music-player-bridge.vala:152: Ignoring desktop file path because its e" \
"ither invalid of the db cache file has it already: %s", path);
}
_g_object_unref0 (bridge);
@@ -462,20 +451,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:153: MusicPlayerBridge-> on_server_count_chan" \
+ g_debug ("music-player-bridge.vala:164: 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:157: MusicPlayerBridge-> on_indicator_added");
+ g_debug ("music-player-bridge.vala:168: 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:162: MusicPlayerBridge -> on_indicator_remove" \
+ g_debug ("music-player-bridge.vala:173: MusicPlayerBridge -> on_indicator_remove" \
"d");
}
@@ -483,7 +472,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:167: MusicPlayerBridge -> indicator_modified " \
+ g_debug ("music-player-bridge.vala:178: MusicPlayerBridge -> indicator_modified " \
"with vale %s", s);
}
@@ -496,7 +485,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:174: Could not create a desktopappinfo instan" \
+ g_warning ("music-player-bridge.vala:185: 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 d2a031e..baeb597 100644
--- a/src/music-player-bridge.h
+++ b/src/music-player-bridge.h
@@ -202,7 +202,6 @@ typedef enum {
struct _MprisController {
GObject parent_instance;
MprisControllerPrivate * priv;
- DBusGProxy* mpris_player;
};
struct _MprisControllerClass {
@@ -253,14 +252,14 @@ MetadataMenuitem* metadata_menuitem_construct (GType object_type);
GeeHashSet* metadata_menuitem_attributes_format (void);
gboolean metadata_menuitem_populated (MetadataMenuitem* self);
GType title_menuitem_get_type (void);
-TitleMenuitem* title_menuitem_new (PlayerController* parent, const char* name);
-TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent, const char* name);
+TitleMenuitem* title_menuitem_new (PlayerController* parent);
+TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
GeeHashSet* title_menuitem_attributes_format (void);
GType mpris_controller_get_type (void);
GType player_controller_state_get_type (void);
#define PLAYER_CONTROLLER_METADATA 2
-PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state);
-PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state);
+PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
+PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
void player_controller_activate (PlayerController* self);
void player_controller_instantiate (PlayerController* self);
@@ -269,18 +268,22 @@ const char* player_controller_get_name (PlayerController* self);
void player_controller_set_name (PlayerController* self, const char* value);
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);
GType mpris_controller_v2_get_type (void);
-MprisControllerV2* mpris_controller_v2_new (const char* name, PlayerController* controller);
-MprisControllerV2* mpris_controller_v2_construct (GType object_type, const char* name, PlayerController* controller);
-MprisController* mpris_controller_new (const char* name, PlayerController* controller, const char* mpris_interface);
-MprisController* mpris_controller_construct (GType object_type, const char* name, PlayerController* controller, const char* mpris_interface);
+MprisControllerV2* mpris_controller_v2_new (PlayerController* ctrl, const char* inter);
+MprisControllerV2* mpris_controller_v2_construct (GType object_type, PlayerController* ctrl, const char* inter);
+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);
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);
PlayerItem* player_item_new (const char* type);
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);
-char* player_item_sanitize_string (const char* st);
PlayerController* player_item_get_owner (PlayerItem* self);
const char* player_item_get_item_type (PlayerItem* self);
GType familiar_players_db_get_type (void);
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index d771192..2f87b2d 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -52,28 +52,34 @@ public class MusicPlayerBridge : GLib.Object
warning("App string in keyfile is null therefore moving on to next player");
continue;
}
- try{
- 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(),
- 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;
- }
- catch(Error er){
- warning("desktop path in cache is not formatted as we have anticipated");
+ 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;
}
break;
}
}
+
+ private int calculate_menu_position()
+ {
+ if(this.registered_clients.size == 0){
+ return 2;
+ }
+ else{
+ return (2 + (this.registered_clients.size * 4));
+ }
+ }
public void on_server_added(Indicate.ListenerServer object, string type)
{
@@ -89,8 +95,13 @@ public class MusicPlayerBridge : GLib.Object
}
//else init a new one
else{
- PlayerController ctrl = new PlayerController(root_menu, client_name, PlayerController.state.READY);
+
+ PlayerController ctrl = new PlayerController(root_menu,
+ client_name,
+ calculate_menu_position(),
+ PlayerController.state.READY);
registered_clients.set(client_name, ctrl);
+
debug("New Client of name %s has successfully registered with us", client_name);
}
// irregardless check that it has a desktop file if not kick off a request for it
diff --git a/src/play-button.c b/src/play-button.c
index 2fddbcf..d6d243c 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -29,7 +29,7 @@ Uses code from ctk
#define RECT_WIDTH 130.0f
#define Y 15.0f
-#define X 22.0f
+#define X 37.0f
#define INNER_RADIUS 12.5
#define MIDDLE_RADIUS 13.5f
#define OUTER_RADIUS 14.5f
@@ -41,16 +41,16 @@ Uses code from ctk
#define TRI_WIDTH 11.0f
#define TRI_HEIGHT 13.0f
#define TRI_OFFSET 6.0f
-#define PREV_X 20.0f
+#define PREV_X 35.0f
#define PREV_Y 21.0f
-#define NEXT_X 98.0f
+#define NEXT_X 113.0f
#define NEXT_Y 21.0f //prev_y
#define PAUSE_WIDTH 21.0f
#define PAUSE_HEIGHT 27.0f
#define BAR_WIDTH 4.5f
#define BAR_HEIGHT 24.0f
#define BAR_OFFSET 10.0f
-#define PAUSE_X 62.0f
+#define PAUSE_X 77.0f
#define PAUSE_Y 15.0f
// Transport events
@@ -363,15 +363,15 @@ determine_button_event(GtkWidget* button, GdkEventButton* event)
g_debug("event y coordinate = %f", event->y);
gint result = 0;
// For now very simple rectangular collision detection
- if(event->x > 40 && event->x < 80
+ if(event->x > 55 && event->x < 95
&& event->y > 22 && event->y < 46){
result = PREVIOUS;
}
- else if(event->x > 86 && event->x < 118
+ else if(event->x > 101 && event->x < 133
&& event->y > 20 && event->y < 47){
result = PLAY_PAUSE;
}
- else if(event->x > 122 && event->x < 164
+ else if(event->x > 137 && event->x < 179
&& event->y > 22 && event->y < 46){
result = NEXT;
}
diff --git a/src/player-controller.c b/src/player-controller.c
index bbdbcbf..ca1485e 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -69,16 +69,6 @@ typedef struct _MprisControllerClass MprisControllerClass;
#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_MPRIS_CONTROLLER_V2 (mpris_controller_v2_get_type ())
-#define MPRIS_CONTROLLER_V2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CONTROLLER_V2, MprisControllerV2))
-#define MPRIS_CONTROLLER_V2_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CONTROLLER_V2, MprisControllerV2Class))
-#define IS_MPRIS_CONTROLLER_V2(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CONTROLLER_V2))
-#define IS_MPRIS_CONTROLLER_V2_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CONTROLLER_V2))
-#define MPRIS_CONTROLLER_V2_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CONTROLLER_V2, MprisControllerV2Class))
-
-typedef struct _MprisControllerV2 MprisControllerV2;
-typedef struct _MprisControllerV2Class MprisControllerV2Class;
-
#define TYPE_TITLE_MENUITEM (title_menuitem_get_type ())
#define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem))
#define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass))
@@ -125,6 +115,7 @@ struct _PlayerControllerPrivate {
DbusmenuMenuitem* root_menu;
char* _name;
GAppInfo* _app_info;
+ gint _menu_offset;
};
typedef enum {
@@ -145,7 +136,8 @@ GType mpris_controller_get_type (void);
enum {
PLAYER_CONTROLLER_DUMMY_PROPERTY,
PLAYER_CONTROLLER_NAME,
- PLAYER_CONTROLLER_APP_INFO
+ PLAYER_CONTROLLER_APP_INFO,
+ PLAYER_CONTROLLER_MENU_OFFSET
};
GType player_controller_state_get_type (void);
#define PLAYER_CONTROLLER_METADATA 2
@@ -153,26 +145,24 @@ GType player_controller_state_get_type (void);
static char* player_controller_format_client_name (const char* client_name);
void player_controller_set_name (PlayerController* self, const char* value);
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state);
+void player_controller_set_menu_offset (PlayerController* self, gint value);
static void player_controller_construct_widgets (PlayerController* self);
static void player_controller_establish_mpris_connection (PlayerController* self);
static void player_controller_update_layout (PlayerController* self);
-PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state);
-PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state);
+PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
+PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state);
+const char* player_controller_get_name (PlayerController* self);
void player_controller_activate (PlayerController* self);
GAppInfo* player_controller_get_app_info (PlayerController* self);
-const char* player_controller_get_name (PlayerController* self);
void player_controller_instantiate (PlayerController* self);
-MprisControllerV2* mpris_controller_v2_new (const char* name, PlayerController* controller);
-MprisControllerV2* mpris_controller_v2_construct (GType object_type, const char* name, PlayerController* controller);
-GType mpris_controller_v2_get_type (void);
-MprisController* mpris_controller_new (const char* name, PlayerController* controller, const char* mpris_interface);
-MprisController* mpris_controller_construct (GType object_type, const char* name, PlayerController* controller, const char* mpris_interface);
+MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter);
+MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter);
gboolean mpris_controller_connected (MprisController* self);
void player_controller_vanish (PlayerController* self);
PlayerItem* player_item_new (const char* type);
PlayerItem* player_item_construct (GType object_type, const char* type);
-TitleMenuitem* title_menuitem_new (PlayerController* parent, const char* name);
-TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent, const char* name);
+TitleMenuitem* title_menuitem_new (PlayerController* parent);
+TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
GType title_menuitem_get_type (void);
MetadataMenuitem* metadata_menuitem_new (void);
MetadataMenuitem* metadata_menuitem_construct (GType object_type);
@@ -180,6 +170,7 @@ GType metadata_menuitem_get_type (void);
TransportMenuitem* transport_menuitem_new (PlayerController* parent);
TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent);
GType transport_menuitem_get_type (void);
+gint player_controller_get_menu_offset (PlayerController* 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);
@@ -216,7 +207,7 @@ static char* string_strip (const char* self) {
}
-PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state) {
+PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state) {
PlayerController * self;
DbusmenuMenuitem* _tmp0_;
char* _tmp2_;
@@ -231,6 +222,8 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit
_g_free0 (_tmp1_);
self->custom_items = (_tmp3_ = gee_array_list_new (TYPE_PLAYER_ITEM, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->custom_items), _tmp3_);
player_controller_update_state (self, initial_state);
+ player_controller_set_menu_offset (self, offset);
+ g_debug ("player-controller.vala:54: offset = %i", offset);
player_controller_construct_widgets (self);
player_controller_establish_mpris_connection (self);
player_controller_update_layout (self);
@@ -238,14 +231,15 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit
}
-PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, PlayerControllerstate initial_state) {
- return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, client_name, initial_state);
+PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state) {
+ return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, client_name, offset, initial_state);
}
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) {
g_return_if_fail (self != NULL);
- g_debug ("player-controller.vala:59: update_state : new state %i", (gint) new_state);
+ g_debug ("player-controller.vala:62: update_state - player controller %s : new s" \
+"tate %i", self->priv->_name, (gint) new_state);
self->current_state = (gint) new_state;
}
@@ -263,26 +257,27 @@ void player_controller_instantiate (PlayerController* self) {
GError * _inner_error_;
g_return_if_fail (self != NULL);
_inner_error_ = NULL;
+ g_debug ("player-controller.vala:80: 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 __catch1_g_error;
+ goto __catch0_g_error;
}
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_INSTANTIATING);
}
- goto __finally1;
- __catch1_g_error:
+ goto __finally0;
+ __catch0_g_error:
{
GError * _error_;
_error_ = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("player-controller.vala:82: Failed to launch app %s with error message:" \
+ g_warning ("player-controller.vala:86: Failed to launch app %s with error message:" \
" %s", self->priv->_name, _error_->message);
_g_error_free0 (_error_);
}
}
- __finally1:
+ __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_);
@@ -294,18 +289,20 @@ void player_controller_instantiate (PlayerController* self) {
static void player_controller_establish_mpris_connection (PlayerController* self) {
g_return_if_fail (self != NULL);
if (self->current_state != PLAYER_CONTROLLER_STATE_READY) {
- g_debug ("player-controller.vala:89: establish_mpris_connection - Not ready to c" \
+ g_debug ("player-controller.vala:93: establish_mpris_connection - Not ready to c" \
"onnect");
return;
}
if (_vala_strcmp0 (self->priv->_name, "Vlc") == 0) {
MprisController* _tmp0_;
- self->mpris_adaptor = (_tmp0_ = (MprisController*) mpris_controller_v2_new (self->priv->_name, self), _g_object_unref0 (self->mpris_adaptor), _tmp0_);
+ g_debug ("player-controller.vala:98: establishing a vlc mpris controller");
+ self->mpris_adaptor = (_tmp0_ = mpris_controller_new (self, "org.mpris.MediaPlayer.Player"), _g_object_unref0 (self->mpris_adaptor), _tmp0_);
} else {
MprisController* _tmp1_;
- self->mpris_adaptor = (_tmp1_ = mpris_controller_new (self->priv->_name, self, "org.freedesktop.MediaPlayer"), _g_object_unref0 (self->mpris_adaptor), _tmp1_);
+ self->mpris_adaptor = (_tmp1_ = mpris_controller_new (self, "org.freedesktop.MediaPlayer"), _g_object_unref0 (self->mpris_adaptor), _tmp1_);
}
if (mpris_controller_connected (self->mpris_adaptor) == TRUE) {
+ g_debug ("player-controller.vala:106: yup I'm connected");
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED);
} else {
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED);
@@ -355,13 +352,16 @@ static void player_controller_update_layout (PlayerController* self) {
if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) {
visibility = FALSE;
}
- g_debug ("player-controller.vala:120: about the set the visibility on both the t" \
+ g_debug ("player-controller.vala:128: about the set the visibility on both the t" \
"ransport and metadata widget to %s", _tmp0_ = bool_to_string (visibility));
_g_free0 (_tmp0_);
dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp1_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, PLAYER_CONTROLLER_TRANSPORT)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
_g_object_unref0 (_tmp1_);
dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, PLAYER_CONTROLLER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
_g_object_unref0 (_tmp2_);
+ if (self->mpris_adaptor == NULL) {
+ g_warning ("player-controller.vala:133: Why is the mpris object null");
+ }
}
@@ -370,17 +370,15 @@ static void player_controller_construct_widgets (PlayerController* self) {
TitleMenuitem* title_menu_item;
MetadataMenuitem* metadata_item;
TransportMenuitem* transport_item;
- gint offset;
g_return_if_fail (self != NULL);
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, _tmp0_ = player_item_new (DBUSMENU_CLIENT_TYPES_SEPARATOR));
_g_object_unref0 (_tmp0_);
- title_menu_item = title_menuitem_new (self, self->priv->_name);
+ title_menu_item = title_menuitem_new (self);
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) title_menu_item);
metadata_item = metadata_menuitem_new ();
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) metadata_item);
transport_item = transport_menuitem_new (self);
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) transport_item);
- offset = 2;
{
GeeIterator* _item_it;
_item_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) self->custom_items);
@@ -390,7 +388,7 @@ static void player_controller_construct_widgets (PlayerController* self) {
break;
}
item = (PlayerItem*) gee_iterator_get (_item_it);
- dbusmenu_menuitem_child_add_position (self->priv->root_menu, (DbusmenuMenuitem*) item, (guint) (offset + gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item)));
+ dbusmenu_menuitem_child_add_position (self->priv->root_menu, (DbusmenuMenuitem*) item, (guint) (self->priv->_menu_offset + gee_abstract_list_index_of ((GeeAbstractList*) self->custom_items, item)));
_g_object_unref0 (item);
}
_g_object_unref0 (_item_it);
@@ -446,7 +444,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:154: PlayerController->format_client_name - : %" \
+ g_debug ("player-controller.vala:165: PlayerController->format_client_name - : %" \
"s", formatted);
}
result = formatted;
@@ -486,6 +484,21 @@ void player_controller_set_app_info (PlayerController* self, GAppInfo* value) {
}
+gint player_controller_get_menu_offset (PlayerController* self) {
+ gint result;
+ g_return_val_if_fail (self != NULL, 0);
+ result = self->priv->_menu_offset;
+ return result;
+}
+
+
+void player_controller_set_menu_offset (PlayerController* self, gint value) {
+ g_return_if_fail (self != NULL);
+ self->priv->_menu_offset = value;
+ g_object_notify ((GObject *) self, "menu-offset");
+}
+
+
static void player_controller_class_init (PlayerControllerClass * klass) {
player_controller_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (PlayerControllerPrivate));
@@ -494,6 +507,7 @@ static void player_controller_class_init (PlayerControllerClass * klass) {
G_OBJECT_CLASS (klass)->finalize = player_controller_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_APP_INFO, g_param_spec_object ("app-info", "app-info", "app-info", G_TYPE_APP_INFO, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MENU_OFFSET, g_param_spec_int ("menu-offset", "menu-offset", "menu-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}
@@ -537,6 +551,9 @@ static void player_controller_get_property (GObject * object, guint property_id,
case PLAYER_CONTROLLER_APP_INFO:
g_value_set_object (value, player_controller_get_app_info (self));
break;
+ case PLAYER_CONTROLLER_MENU_OFFSET:
+ g_value_set_int (value, player_controller_get_menu_offset (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -554,6 +571,9 @@ static void player_controller_set_property (GObject * object, guint property_id,
case PLAYER_CONTROLLER_APP_INFO:
player_controller_set_app_info (self, g_value_get_object (value));
break;
+ case PLAYER_CONTROLLER_MENU_OFFSET:
+ player_controller_set_menu_offset (self, g_value_get_int (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 3fb4750..d272d14 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -42,13 +42,16 @@ public class PlayerController : GLib.Object
public ArrayList<PlayerItem> custom_items;
public MprisController mpris_adaptor;
public AppInfo? app_info { get; set;}
+ public int menu_offset { get; set;}
- public PlayerController(Dbusmenu.Menuitem root, string client_name, 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());
this.custom_items = new ArrayList<PlayerItem>();
this.update_state(initial_state);
+ this.menu_offset = offset;
+ debug("offset = %i", offset);
construct_widgets();
establish_mpris_connection();
update_layout();
@@ -56,7 +59,7 @@ public class PlayerController : GLib.Object
public void update_state(state new_state)
{
- debug("update_state : new state %i", new_state);
+ debug("update_state - player controller %s : new state %i", this.name, new_state);
this.current_state = new_state;
}
@@ -74,6 +77,7 @@ public class PlayerController : GLib.Object
*/
public void instantiate()
{
+ debug("instantiate in player controller for %s", this.name);
try{
this.app_info.launch(null, null);
this.update_state(state.INSTANTIATING);
@@ -89,13 +93,17 @@ public class PlayerController : GLib.Object
debug("establish_mpris_connection - Not ready to connect");
return;
}
+
if(this.name == "Vlc"){
- this.mpris_adaptor = new MprisControllerV2(this.name, this);
+ debug("establishing a vlc mpris controller");
+ this.mpris_adaptor = new MprisController(this, "org.mpris.MediaPlayer.Player");
}
else{
- this.mpris_adaptor = new MprisController(this.name, this);
+ this.mpris_adaptor = new MprisController(this);
}
+
if(this.mpris_adaptor.connected() == true){
+ debug("yup I'm connected");
this.update_state(state.CONNECTED);
}
else{
@@ -120,6 +128,10 @@ public class PlayerController : GLib.Object
debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string());
this.custom_items[TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
this.custom_items[METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
+ // DEBUG
+ if(this.mpris_adaptor == null){
+ warning("Why is the mpris object null");
+ }
}
@@ -129,7 +141,7 @@ public class PlayerController : GLib.Object
this.custom_items.add(new PlayerItem(CLIENT_TYPES_SEPARATOR));
// Title item
- TitleMenuitem title_menu_item = new TitleMenuitem(this, this.name);
+ TitleMenuitem title_menu_item = new TitleMenuitem(this);
this.custom_items.add(title_menu_item);
// Metadata item
@@ -140,9 +152,8 @@ public class PlayerController : GLib.Object
TransportMenuitem transport_item = new TransportMenuitem(this);
this.custom_items.add(transport_item);
- int offset = 2;
foreach(PlayerItem item in this.custom_items){
- root_menu.child_add_position(item, offset + this.custom_items.index_of(item));
+ root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
}
}
diff --git a/src/player-item.c b/src/player-item.c
index 6152703..2ef44a8 100644
--- a/src/player-item.c
+++ b/src/player-item.c
@@ -53,6 +53,7 @@ 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)))
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
@@ -84,7 +85,6 @@ PlayerItem* player_item_construct (GType object_type, const char* type);
void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
static gboolean player_item_ensure_valid_updates (GHashTable* data, GeeHashSet* attributes);
static GValue* _g_value_dup (GValue* self);
-char* player_item_sanitize_string (const char* st);
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
PlayerController* player_item_get_owner (PlayerItem* self);
static void player_item_set_owner (PlayerItem* self, PlayerController* value);
@@ -144,10 +144,32 @@ static gpointer __g_value_dup0 (gpointer self) {
}
+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 gboolean string_contains (const char* self, const char* needle) {
+ gboolean result = FALSE;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (needle != NULL, FALSE);
+ result = strstr (self, needle) != NULL;
+ return result;
+}
+
+
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes) {
+ GError * _inner_error_;
g_return_if_fail (self != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (attributes != NULL);
+ _inner_error_ = NULL;
g_debug ("player-item.vala:46: PlayerItem::update()");
if (player_item_ensure_valid_updates (data, attributes) == FALSE) {
g_debug ("player-item.vala:48: PlayerItem::Update -> The hashtable update does n" \
@@ -177,13 +199,61 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
g_debug ("player-item.vala:54: 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* _tmp4_;
- g_debug ("player-item.vala:58: with value : %s", g_value_get_string (v));
- dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, property, _tmp4_ = player_item_sanitize_string (g_value_get_string (v)));
- _g_free0 (_tmp4_);
+ char* update;
+ update = string_strip (g_value_get_string (v));
+ g_debug ("player-item.vala:59: with value : %s", update);
+ if (string_contains (property, "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 __catch2_g_convert_error;
+ }
+ _g_free0 (update);
+ _g_free0 (property);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (search_key);
+ _g_free0 (v);
+ _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 __finally2;
+ __catch2_g_convert_error:
+ {
+ GError * e;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ {
+ g_warning ("player-item.vala:65: Problem converting URI %s to file path", update);
+ _g_error_free0 (e);
+ }
+ }
+ __finally2:
+ if (_inner_error_ != NULL) {
+ _g_free0 (update);
+ _g_free0 (property);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (search_key);
+ _g_free0 (v);
+ _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;
+ }
+ }
+ 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:62: with value : %i", g_value_get_int (v));
+ g_debug ("player-item.vala:71: 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_BOOLEAN)) {
@@ -210,7 +280,7 @@ static gboolean player_item_ensure_valid_updates (GHashTable* data, GeeHashSet*
return result;
}
if (g_hash_table_size (data) < gee_collection_get_size ((GeeCollection*) attributes)) {
- g_warning ("player-item.vala:77: update hash was too small for the target");
+ g_warning ("player-item.vala:86: update hash was too small for the target");
result = FALSE;
return result;
}
@@ -219,65 +289,6 @@ static gboolean player_item_ensure_valid_updates (GHashTable* data, GeeHashSet*
}
-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 char* string_slice (const char* self, glong start, glong end) {
- char* result = NULL;
- glong string_length;
- gboolean _tmp0_ = FALSE;
- gboolean _tmp1_ = FALSE;
- const char* start_string;
- g_return_val_if_fail (self != NULL, NULL);
- string_length = g_utf8_strlen (self, -1);
- if (start < 0) {
- start = string_length + start;
- }
- if (end < 0) {
- end = string_length + end;
- }
- if (start >= 0) {
- _tmp0_ = start <= string_length;
- } else {
- _tmp0_ = FALSE;
- }
- g_return_val_if_fail (_tmp0_, NULL);
- if (end >= 0) {
- _tmp1_ = end <= string_length;
- } else {
- _tmp1_ = FALSE;
- }
- g_return_val_if_fail (_tmp1_, NULL);
- g_return_val_if_fail (start <= end, NULL);
- start_string = g_utf8_offset_to_pointer (self, start);
- result = g_strndup (start_string, ((gchar*) g_utf8_offset_to_pointer (start_string, end - start)) - ((gchar*) start_string));
- return result;
-}
-
-
-char* player_item_sanitize_string (const char* st) {
- char* result = NULL;
- char* _result_;
- g_return_val_if_fail (st != NULL, NULL);
- _result_ = string_strip (st);
- if (g_str_has_prefix (_result_, "file:///")) {
- char* _tmp0_;
- _result_ = (_tmp0_ = string_slice (_result_, (glong) 7, g_utf8_strlen (_result_, -1)), _g_free0 (_result_), _tmp0_);
- }
- g_debug ("player-item.vala:89: Sanitize string - result = %s", _result_);
- result = _result_;
- return result;
-}
-
-
PlayerController* player_item_get_owner (PlayerItem* self) {
PlayerController* result;
g_return_val_if_fail (self != NULL, NULL);
diff --git a/src/player-item.vala b/src/player-item.vala
index 171c140..3e10b7b 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -55,8 +55,17 @@ public class PlayerItem : Dbusmenu.Menuitem
Value? v = data.lookup(search_key);
if (v.holds (typeof (string))){
- debug("with value : %s", v.get_string());
- this.property_set(property, this.sanitize_string(v.get_string()));
+ string update = v.get_string().strip();
+ debug("with value : %s", update);
+ if(property.contains("arturl")){
+ try{
+ update = Filename.from_uri(update.strip());
+ }
+ catch(ConvertError e){
+ warning("Problem converting URI %s to file path", update);
+ }
+ }
+ this.property_set(property, update);
}
else if (v.holds (typeof (int))){
debug("with value : %i", v.get_int());
@@ -80,15 +89,5 @@ public class PlayerItem : Dbusmenu.Menuitem
return true;
}
- public static string sanitize_string(string st)
- {
- string result = st.strip();
- if(result.has_prefix("file:///")){
- result = result.slice(7, result.len());
- }
- debug("Sanitize string - result = %s", result);
- return result;
- }
-
}
diff --git a/src/title-menu-item.c b/src/title-menu-item.c
index 0bf7db1..20d0aa4 100644
--- a/src/title-menu-item.c
+++ b/src/title-menu-item.c
@@ -63,7 +63,6 @@ typedef struct _TitleMenuitemPrivate TitleMenuitemPrivate;
typedef struct _PlayerController PlayerController;
typedef struct _PlayerControllerClass PlayerControllerClass;
-#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
#define TYPE_MPRIS_CONTROLLER (mpris_controller_get_type ())
@@ -126,8 +125,9 @@ enum {
TITLE_MENUITEM_DUMMY_PROPERTY
};
GType player_controller_get_type (void);
-TitleMenuitem* title_menuitem_new (PlayerController* parent, const char* name);
-TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent, const char* name);
+const char* player_controller_get_name (PlayerController* self);
+TitleMenuitem* title_menuitem_new (PlayerController* parent);
+TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
PlayerController* player_item_get_owner (PlayerItem* self);
GType mpris_controller_get_type (void);
GType player_controller_state_get_type (void);
@@ -137,40 +137,26 @@ GeeHashSet* title_menuitem_attributes_format (void);
-TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent, const char* name) {
+TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent) {
TitleMenuitem * self;
g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
self = (TitleMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_TITLE_MENUITEM_TYPE, "owner", parent, NULL);
- dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_TEXT_NAME, name);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_TEXT_NAME, player_controller_get_name (parent));
return self;
}
-TitleMenuitem* title_menuitem_new (PlayerController* parent, const char* name) {
- return title_menuitem_construct (TYPE_TITLE_MENUITEM, parent, name);
-}
-
-
-static char* bool_to_string (gboolean self) {
- char* result = NULL;
- if (self) {
- result = g_strdup ("true");
- return result;
- } else {
- result = g_strdup ("false");
- return result;
- }
+TitleMenuitem* title_menuitem_new (PlayerController* parent) {
+ return title_menuitem_construct (TYPE_TITLE_MENUITEM, parent);
}
static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp) {
TitleMenuitem * self;
- char* _tmp0_;
self = (TitleMenuitem*) base;
g_return_if_fail (name != NULL);
- g_debug ("title-menu-item.vala:34: handle_event with bool value %s", _tmp0_ = bool_to_string (g_value_get_boolean (input_value)));
- _g_free0 (_tmp0_);
+ g_debug ("title-menu-item.vala:34: handle_event for owner %s with owner state = " \
+"%i and title menu name %s", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)), player_item_get_owner ((PlayerItem*) self)->current_state, dbusmenu_menuitem_property_get ((DbusmenuMenuitem*) self, DBUSMENU_TITLE_MENUITEM_TEXT_NAME));
if (player_item_get_owner ((PlayerItem*) self)->current_state == PLAYER_CONTROLLER_STATE_OFFLINE) {
player_controller_instantiate (player_item_get_owner ((PlayerItem*) self));
}
diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala
index 612d279..8183821 100644
--- a/src/title-menu-item.vala
+++ b/src/title-menu-item.vala
@@ -23,15 +23,16 @@ using Gee;
public class TitleMenuitem : PlayerItem
{
- public TitleMenuitem(PlayerController parent, string name)
+ public TitleMenuitem(PlayerController parent)
{
Object(item_type: MENUITEM_TYPE, owner: parent);
- this.property_set(MENUITEM_TEXT_NAME, name);
+ this.property_set(MENUITEM_TEXT_NAME, parent.name);
}
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
{
- debug("handle_event with bool value %s", input_value.get_boolean().to_string());
+ debug("handle_event for owner %s with owner state = %i and title menu name %s", this.owner.name, this.owner.current_state, property_get(MENUITEM_TEXT_NAME));
+
if(this.owner.current_state == PlayerController.state.OFFLINE)
{
this.owner.instantiate();
diff --git a/src/title-widget.c b/src/title-widget.c
index 1b57fe9..7e48940 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -27,7 +27,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include <libindicator/indicator-image-helper.h>
-static DbusmenuMenuitem* twin_item;
typedef struct _TitleWidgetPrivate TitleWidgetPrivate;
@@ -36,6 +35,7 @@ struct _TitleWidgetPrivate
GtkWidget* hbox;
GtkWidget* name;
GtkWidget* player_icon;
+ DbusmenuMenuitem* twin_item;
};
#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate))
@@ -57,7 +57,10 @@ static gboolean title_widget_expose_event(GtkWidget* widget,
// Dbusmenuitem properties update callback
static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata);
-static void style_name_text(TitleWidget* self);
+static void title_widget_set_twin_item( TitleWidget* self,
+ DbusmenuMenuitem* twin_item);
+static void title_widget_style_name_text(TitleWidget* self);
+
G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_MENU_ITEM);
@@ -90,22 +93,9 @@ title_widget_init (TitleWidget *self)
hbox = gtk_hbox_new(FALSE, 0);
priv->hbox = hbox;
- g_signal_connect(G_OBJECT(twin_item), "property-changed",
- G_CALLBACK(title_widget_property_update), self);
priv->player_icon = indicator_image_helper("sound_icon");
gtk_box_pack_start(GTK_BOX (priv->hbox), priv->player_icon, FALSE, FALSE, 0);
-
- priv->name = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_TITLE_MENUITEM_TEXT_NAME));
- gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0);
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0);
-
- style_name_text(self);
-
- gtk_widget_show_all (priv->hbox);
- gtk_container_add (GTK_CONTAINER (self), hbox);
-
}
static void
@@ -126,12 +116,13 @@ title_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TitleWidget::menu_press_event");
-
+ TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);
+
GValue value = {0};
g_value_init(&value, G_TYPE_BOOLEAN);
g_value_set_boolean(&value, TRUE);
- dbusmenu_menuitem_handle_event (twin_item, "Title menu event", &value, 0);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
return TRUE;
}
@@ -163,12 +154,31 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_TEXT_NAME, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value));
- style_name_text(mitem);
+ title_widget_style_name_text(mitem);
}
}
static void
-style_name_text(TitleWidget* self)
+title_widget_set_twin_item(TitleWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(twin_item), "property-changed",
+ G_CALLBACK(title_widget_property_update), self);
+ priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item,
+ DBUSMENU_TITLE_MENUITEM_TEXT_NAME));
+ gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0);
+
+ title_widget_style_name_text(self);
+
+ gtk_widget_show_all (priv->hbox);
+ gtk_container_add (GTK_CONTAINER (self), priv->hbox);
+}
+
+static void
+title_widget_style_name_text(TitleWidget* self)
{
TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);
@@ -186,7 +196,8 @@ style_name_text(TitleWidget* self)
GtkWidget*
title_widget_new(DbusmenuMenuitem *item)
{
- twin_item = item;
- return g_object_new(TITLE_WIDGET_TYPE, NULL);
+ GtkWidget* widget = g_object_new(TITLE_WIDGET_TYPE, NULL);
+ title_widget_set_twin_item((TitleWidget*)widget, item);
+ return widget;
}
diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c
index 48c437a..0734a97 100644
--- a/src/transport-menu-item.c
+++ b/src/transport-menu-item.c
@@ -27,9 +27,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <common-defs.h>
-#include <gee.h>
#include <stdlib.h>
#include <string.h>
+#include <gee.h>
#define TYPE_PLAYER_ITEM (player_item_get_type ())
@@ -129,6 +129,7 @@ TransportMenuitem* transport_menuitem_new (PlayerController* parent);
TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent);
void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
PlayerController* player_item_get_owner (PlayerItem* self);
+const char* player_controller_get_name (PlayerController* self);
GType mpris_controller_get_type (void);
void mpris_controller_transport_event (MprisController* self, TransportMenuitemaction command);
static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
@@ -176,6 +177,7 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const
input = g_value_get_int (input_value);
g_debug ("transport-menu-item.vala:45: handle_event with value %s", _tmp0_ = g_strdup_printf ("%i", input));
_g_free0 (_tmp0_);
+ g_debug ("transport-menu-item.vala:46: transport owner name = %s", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)));
mpris_controller_transport_event (player_item_get_owner ((PlayerItem*) self)->mpris_adaptor, (TransportMenuitemaction) input);
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index e0710a8..8e837c2 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -43,7 +43,7 @@ public class TransportMenuitem : PlayerItem
{
int input = input_value.get_int();
debug("handle_event with value %s", input.to_string());
- // Fire and forgot - the widget would not have sent it over it didn't think it was relevant.
+ debug("transport owner name = %s", this.owner.name);
this.owner.mpris_adaptor.transport_event((action)input);
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 9852b50..f02200e 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -27,15 +27,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include "play-button.h"
-
-static DbusmenuMenuitem* twin_item;
-
typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
struct _TransportWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* play_button;
+ DbusmenuMenuitem* twin_item;
};
#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
@@ -45,18 +43,24 @@ static void transport_widget_class_init (TransportWidgetClass *klass);
static void transport_widget_init (TransportWidget *self);
static void transport_widget_dispose (GObject *object);
static void transport_widget_finalize (GObject *object);
-static gboolean transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event);
+
+static void transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item);
+
+static gboolean transport_widget_expose_event(GtkWidget* widget,
+ GdkEventExpose* event);
/* UI and dbusmenu callbacks */
-static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
- GdkEventButton *event);
-static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event);
+static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
+ GdkEventButton *event);
+static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
+ GdkEventButton *event);
static void transport_widget_property_update(DbusmenuMenuitem* item,
gchar * property,
GValue * value,
gpointer userdata);
+
G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
static void
@@ -93,8 +97,6 @@ transport_widget_init (TransportWidget *self)
play_button_set_style(priv->play_button, style);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->play_button, FALSE, FALSE, 0);
-
- g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self);
gtk_container_add (GTK_CONTAINER (self), priv->hbox);
@@ -120,14 +122,21 @@ transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
//gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event);
return TRUE;
}
-
+
+static void transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
+ G_CALLBACK(transport_widget_property_update), self);
+}
/* keyevents */
static gboolean
transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportWidget::menu_press_event");
if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){
return FALSE;
}
@@ -136,20 +145,15 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GtkWidget *parent;
- // can we block emissions of "grab-notify" on parent??
parent = gtk_widget_get_parent (GTK_WIDGET (menuitem));
- gint result = determine_button_event(priv->play_button, event);
- //GTK_OBJECT_FLAGS (scale) |= GTK_HAS_GRAB;
- //gtk_widget_event (scale,
- //((GdkEvent *)(void*)(event)));
- //GTK_OBJECT_FLAGS (scale) &= ~(GTK_HAS_GRAB);
+ gint result = determine_button_event(priv->play_button, event);
GValue value = {0};
g_value_init(&value, G_TYPE_INT);
g_debug("TransportWidget::menu_press_event - going to send value %i", result);
g_value_set_int(&value, result);
- dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
return TRUE;
}
@@ -191,7 +195,8 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GtkWidget*
transport_widget_new(DbusmenuMenuitem *item)
{
- twin_item = item;
- return g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ GtkWidget* widget = g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ transport_widget_set_twin_item((TransportWidget*)widget, item);
+ return widget;
}