aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2010-07-29 11:26:41 -0400
committerKen VanDine <ken.vandine@canonical.com>2010-07-29 11:26:41 -0400
commit986fc648fc6544aaa3bb40a17e1345e0247a4b57 (patch)
treeda2904b0c642c44d65629a9657b550c2c26a7b08 /src
parent1777ee4291dc792ca3d4df087c8af23cd8458961 (diff)
parent859c48c87009fb12e0acc15fdeb8d69e42247176 (diff)
downloadayatana-indicator-sound-986fc648fc6544aaa3bb40a17e1345e0247a4b57.tar.gz
ayatana-indicator-sound-986fc648fc6544aaa3bb40a17e1345e0247a4b57.tar.bz2
ayatana-indicator-sound-986fc648fc6544aaa3bb40a17e1345e0247a4b57.zip
Import upstream version 0.3.9
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in2
-rw-r--r--src/common-defs.h23
-rw-r--r--src/familiar-players-db.c26
-rw-r--r--src/metadata-menu-item.c37
-rw-r--r--src/metadata-menu-item.vala7
-rw-r--r--src/metadata-widget.c10
-rw-r--r--src/mpris-controller-v2.c6
-rw-r--r--src/mpris-controller.c39
-rw-r--r--src/music-player-bridge.c14
-rw-r--r--src/music-player-bridge.h33
-rw-r--r--src/play-button.c100
-rw-r--r--src/player-controller.c171
-rw-r--r--src/player-controller.vala75
-rw-r--r--src/player-item.c71
-rw-r--r--src/player-item.vala34
-rw-r--r--src/scrub-menu-item.c20
-rw-r--r--src/scrub-menu-item.vala1
-rw-r--r--src/scrub-widget.c86
-rw-r--r--src/sound-service-server.h2
-rw-r--r--src/title-menu-item.c10
-rw-r--r--src/transport-menu-item.c10
-rw-r--r--src/transport-widget.c17
22 files changed, 463 insertions, 331 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index b60a421..164eee4 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -229,6 +229,8 @@ PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POFILES = @POFILES@
POSUB = @POSUB@
PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
diff --git a/src/common-defs.h b/src/common-defs.h
index 208c8cb..46ff520 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -19,26 +19,29 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
/* constants used for signals on the dbus. This file is shared between client and server implementation */
-#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
-#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
-#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
-#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate"
+#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
+#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
+#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
+#define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate"
+
+#define DBUSMENU_PROPERTY_EMPTY -1
/* DBUS Custom Items */
-#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item"
-#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar"
-#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-transport-play-state"
+#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-type"
+
+#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"
+#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
-#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-menu-item"
+#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type"
#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-artist"
#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-title"
#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-album"
#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-arturl"
-#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-menu-item"
+#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type"
#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name"
-#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-menu-item"
+#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type"
#define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-time"
#define DBUSMENU_SCRUB_MENUITEM_POSITION "x-canonical-sound-menu-player-scrub-position"
#define DBUSMENU_SCRUB_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-scrub-play-state"
diff --git a/src/familiar-players-db.c b/src/familiar-players-db.c
index 059bf5a..c7bfda3 100644
--- a/src/familiar-players-db.c
+++ b/src/familiar-players-db.c
@@ -63,7 +63,7 @@ struct _FamiliarPlayersDBPrivate {
static gpointer familiar_players_db_parent_class = NULL;
-GType familiar_players_db_get_type (void);
+GType familiar_players_db_get_type (void) G_GNUC_CONST;
#define FAMILIAR_PLAYERS_DB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FAMILIAR_PLAYERS_DB, FamiliarPlayersDBPrivate))
enum {
FAMILIAR_PLAYERS_DB_DUMMY_PROPERTY
@@ -352,17 +352,17 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
g_warning ("familiar-players-db.vala:114: Problems dumping keyfile to a string");
result = FALSE;
_g_error_free0 (e);
- _g_key_file_free0 (keyfile);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
return result;
}
}
__finally6:
if (_inner_error_ != NULL) {
- _g_key_file_free0 (keyfile);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return FALSE;
@@ -370,9 +370,9 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
if (g_mkdir_with_parents (self->priv->dir_name, 0700) != 0) {
g_warning ("familiar-players-db.vala:119: Unable to make directory: %s", self->priv->dir_name);
result = FALSE;
- _g_key_file_free0 (keyfile);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
return result;
}
{
@@ -382,9 +382,9 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
if (_inner_error_->domain == G_FILE_ERROR) {
goto __catch7_g_file_error;
}
- _g_key_file_free0 (keyfile);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
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 FALSE;
@@ -406,17 +406,17 @@ static gboolean familiar_players_db_write_db (FamiliarPlayersDB* self) {
}
__finally7:
if (_inner_error_ != NULL) {
- _g_key_file_free0 (keyfile);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return FALSE;
}
result = TRUE;
- _g_key_file_free0 (keyfile);
- desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
_g_free0 (data);
+ desktops = (_vala_array_free (desktops, desktops_length1, (GDestroyNotify) g_free), NULL);
+ _g_key_file_free0 (keyfile);
return result;
}
diff --git a/src/metadata-menu-item.c b/src/metadata-menu-item.c
index 792b638..aadaf2c 100644
--- a/src/metadata-menu-item.c
+++ b/src/metadata-menu-item.c
@@ -76,22 +76,24 @@ struct _MetadataMenuitemClass {
static gpointer metadata_menuitem_parent_class = NULL;
-GType player_item_get_type (void);
-GType metadata_menuitem_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType metadata_menuitem_get_type (void) G_GNUC_CONST;
enum {
METADATA_MENUITEM_DUMMY_PROPERTY
};
+void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
+GeeHashSet* metadata_menuitem_attributes_format (void);
MetadataMenuitem* metadata_menuitem_new (void);
MetadataMenuitem* metadata_menuitem_construct (GType object_type);
-GeeHashSet* metadata_menuitem_attributes_format (void);
-gboolean metadata_menuitem_not_populated (MetadataMenuitem* self);
-static int _vala_strcmp0 (const char * str1, const char * str2);
MetadataMenuitem* metadata_menuitem_construct (GType object_type) {
MetadataMenuitem * self;
+ GeeHashSet* _tmp0_;
self = (MetadataMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_METADATA_MENUITEM_TYPE, NULL);
+ player_item_reset ((PlayerItem*) self, _tmp0_ = metadata_menuitem_attributes_format ());
+ _g_object_unref0 (_tmp0_);
return self;
}
@@ -114,20 +116,6 @@ GeeHashSet* metadata_menuitem_attributes_format (void) {
}
-gboolean metadata_menuitem_not_populated (MetadataMenuitem* self) {
- gboolean result = FALSE;
- gboolean _tmp0_ = FALSE;
- g_return_val_if_fail (self != NULL, FALSE);
- if (dbusmenu_menuitem_property_get ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_TITLE) == NULL) {
- _tmp0_ = _vala_strcmp0 (dbusmenu_menuitem_property_get ((DbusmenuMenuitem*) self, DBUSMENU_METADATA_MENUITEM_TITLE), "") == 0;
- } else {
- _tmp0_ = FALSE;
- }
- result = _tmp0_;
- return result;
-}
-
-
static void metadata_menuitem_class_init (MetadataMenuitemClass * klass) {
metadata_menuitem_parent_class = g_type_class_peek_parent (klass);
}
@@ -149,16 +137,5 @@ GType metadata_menuitem_get_type (void) {
}
-static int _vala_strcmp0 (const char * str1, const char * str2) {
- if (str1 == NULL) {
- return -(str1 != str2);
- }
- if (str2 == NULL) {
- return str1 != str2;
- }
- return strcmp (str1, str2);
-}
-
-
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 388ef81..3818b1c 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -26,6 +26,7 @@ public class MetadataMenuitem : PlayerItem
public MetadataMenuitem()
{
Object(item_type: MENUITEM_TYPE);
+ reset(attributes_format());
}
public static HashSet<string> attributes_format()
@@ -37,11 +38,5 @@ public class MetadataMenuitem : PlayerItem
attrs.add(MENUITEM_ARTURL);
return attrs;
}
-
- public bool not_populated()
- {
- return (this.property_get(MENUITEM_TITLE) == null &&
- this.property_get(MENUITEM_TITLE) == "");
- }
} \ No newline at end of file
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index dce9226..670d983 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -199,6 +199,16 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
{
g_return_if_fail (IS_METADATA_WIDGET (userdata));
+ if(g_value_get_int(value) == DBUSMENU_PROPERTY_EMPTY){
+ g_debug("Metadata widget: property update - reset");
+ gchar* empty = "";
+ GValue new_value = {0};
+ g_value_init(&new_value, G_TYPE_STRING);
+ g_value_set_string(&new_value, g_strdup(""));
+ //g_free(empty);
+ value = &new_value;
+ }
+
MetadataWidget* mitem = METADATA_WIDGET(userdata);
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(mitem);
diff --git a/src/mpris-controller-v2.c b/src/mpris-controller-v2.c
index 40fe3da..03665a5 100644
--- a/src/mpris-controller-v2.c
+++ b/src/mpris-controller-v2.c
@@ -80,12 +80,12 @@ struct _MprisControllerV2Class {
static gpointer mpris_controller_v2_parent_class = NULL;
-GType mpris_controller_get_type (void);
-GType mpris_controller_v2_get_type (void);
+GType mpris_controller_get_type (void) G_GNUC_CONST;
+GType mpris_controller_v2_get_type (void) G_GNUC_CONST;
enum {
MPRIS_CONTROLLER_V2_DUMMY_PROPERTY
};
-GType player_controller_get_type (void);
+GType player_controller_get_type (void) G_GNUC_CONST;
MprisControllerV2* mpris_controller_v2_new (PlayerController* ctrl, const char* inter);
MprisControllerV2* mpris_controller_v2_construct (GType object_type, PlayerController* ctrl, const char* inter);
diff --git a/src/mpris-controller.c b/src/mpris-controller.c
index 4131b5f..14a462b 100644
--- a/src/mpris-controller.c
+++ b/src/mpris-controller.c
@@ -140,7 +140,8 @@ typedef enum {
PLAYER_CONTROLLER_WIDGET_ORDER_TITLE,
PLAYER_CONTROLLER_WIDGET_ORDER_METADATA,
PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB,
- PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT
+ PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT,
+ PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST
} PlayerControllerwidget_order;
typedef enum {
@@ -152,8 +153,8 @@ typedef enum {
static gpointer mpris_controller_parent_class = NULL;
-GType mpris_controller_get_type (void);
-GType player_controller_get_type (void);
+GType mpris_controller_get_type (void) G_GNUC_CONST;
+GType player_controller_get_type (void) G_GNUC_CONST;
#define MPRIS_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MPRIS_CONTROLLER, MprisControllerPrivate))
enum {
MPRIS_CONTROLLER_DUMMY_PROPERTY,
@@ -164,25 +165,25 @@ enum {
MprisController* mpris_controller_new (PlayerController* ctrl, const char* inter);
MprisController* mpris_controller_construct (GType object_type, PlayerController* ctrl, const char* inter);
DBusGProxy* mpris_controller_get_mpris_player (MprisController* self);
-static GType mpris_controller_status_get_type (void) G_GNUC_UNUSED;
+static GType mpris_controller_status_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
static MprisControllerstatus* mpris_controller_status_dup (const MprisControllerstatus* self);
static void mpris_controller_status_free (MprisControllerstatus* self);
static void _dynamic_GetStatus0 (DBusGProxy* self, MprisControllerstatus* result, GError** error);
PlayerController* mpris_controller_get_owner (MprisController* self);
-GType player_item_get_type (void);
-GType player_controller_widget_order_get_type (void);
-GType transport_menuitem_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
+GType transport_menuitem_get_type (void) G_GNUC_CONST;
void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
static GHashTable* _dynamic_GetMetadata1 (DBusGProxy* self, GError** error);
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
GeeHashSet* metadata_menuitem_attributes_format (void);
static GHashTable* _dynamic_GetMetadata2 (DBusGProxy* self, GError** error);
GeeHashSet* scrub_menuitem_attributes_format (void);
-GType scrub_menuitem_get_type (void);
+GType scrub_menuitem_get_type (void) G_GNUC_CONST;
static gint32 _dynamic_PositionGet3 (DBusGProxy* self, GError** error);
void scrub_menuitem_update_position (ScrubMenuitem* self, gint32 new_position);
static void mpris_controller_initial_update (MprisController* self);
-GType transport_menuitem_action_get_type (void);
+GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
static void _dynamic_Pause4 (DBusGProxy* self, GError** error);
static void _dynamic_Prev5 (DBusGProxy* self, GError** error);
static void _dynamic_Next6 (DBusGProxy* self, GError** error);
@@ -455,8 +456,8 @@ void mpris_controller_set_position (MprisController* self, double position) {
if (time_value == NULL) {
g_warning ("mpris-controller.vala:92: Can't fetch the duration of the track theref" \
"ore cant set the position");
- _g_hash_table_unref0 (data);
_g_free0 (time_value);
+ _g_hash_table_unref0 (data);
return;
}
total_time = (guint32) g_value_get_uint (time_value);
@@ -465,8 +466,8 @@ void mpris_controller_set_position (MprisController* self, double position) {
g_debug ("mpris-controller.vala:98: new position = %f", new_time_position * 1000);
_dynamic_PositionSet8 (self->priv->_mpris_player, (gint32) new_time_position, &_inner_error_);
if (_inner_error_ != NULL) {
- _g_hash_table_unref0 (data);
_g_free0 (time_value);
+ _g_hash_table_unref0 (data);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
@@ -474,17 +475,17 @@ void mpris_controller_set_position (MprisController* self, double position) {
scrub = (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), IS_SCRUB_MENUITEM (_tmp0_) ? ((ScrubMenuitem*) _tmp0_) : NULL);
_tmp1_ = _dynamic_PositionGet9 (self->priv->_mpris_player, &_inner_error_);
if (_inner_error_ != NULL) {
- _g_hash_table_unref0 (data);
- _g_free0 (time_value);
_g_object_unref0 (scrub);
+ _g_free0 (time_value);
+ _g_hash_table_unref0 (data);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
scrub_menuitem_update_position (scrub, _tmp1_);
- _g_hash_table_unref0 (data);
- _g_free0 (time_value);
_g_object_unref0 (scrub);
+ _g_free0 (time_value);
+ _g_hash_table_unref0 (data);
}
@@ -513,7 +514,7 @@ static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy*
ar = (GValueArray*) status;
play_state = g_value_get_int (g_value_array_get_nth (ar, (guint) 0));
g_debug ("mpris-controller.vala:115: onStatusChange - play state %i", play_state);
- ht = g_hash_table_new (g_str_hash, g_str_equal);
+ ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_value_init (&v, G_TYPE_INT);
g_value_set_int (&v, play_state);
g_hash_table_insert (ht, g_strdup ("state"), __g_value_dup0 (&v));
@@ -523,8 +524,8 @@ static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy*
player_item_update (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), ht, _tmp3_ = scrub_menuitem_attributes_format ());
_g_object_unref0 (_tmp3_);
_g_object_unref0 (_tmp2_);
- _g_hash_table_unref0 (ht);
G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ _g_hash_table_unref0 (ht);
}
@@ -663,7 +664,7 @@ static void _mpris_controller_onTrackChange_dynamic_TrackChange0_ (DBusGProxy* _
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);
+ dbus_g_proxy_connect_signal (obj, "TrackChange", handler, data, NULL);
}
@@ -675,7 +676,7 @@ static void _mpris_controller_onStatusChange_dynamic_StatusChange2_ (DBusGProxy*
void _dynamic_StatusChange3_connect (gpointer obj, const char * signal_name, GCallback handler, gpointer data) {
dbus_g_object_register_marshaller (g_cclosure_user_marshal_VOID__BOXED, G_TYPE_NONE, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), G_TYPE_INVALID);
dbus_g_proxy_add_signal (obj, "StatusChange", dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (obj, signal_name, handler, data, NULL);
+ dbus_g_proxy_connect_signal (obj, "StatusChange", handler, data, NULL);
}
diff --git a/src/music-player-bridge.c b/src/music-player-bridge.c
index aa4e5dd..6579e17 100644
--- a/src/music-player-bridge.c
+++ b/src/music-player-bridge.c
@@ -100,9 +100,9 @@ typedef enum {
static gpointer music_player_bridge_parent_class = NULL;
-GType music_player_bridge_get_type (void);
-GType player_controller_get_type (void);
-GType familiar_players_db_get_type (void);
+GType music_player_bridge_get_type (void) G_GNUC_CONST;
+GType player_controller_get_type (void) G_GNUC_CONST;
+GType familiar_players_db_get_type (void) G_GNUC_CONST;
#define MUSIC_PLAYER_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MUSIC_PLAYER_BRIDGE, MusicPlayerBridgePrivate))
enum {
MUSIC_PLAYER_BRIDGE_DUMMY_PROPERTY
@@ -125,11 +125,11 @@ 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);
+GType player_controller_state_get_type (void) G_GNUC_CONST;
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);
-#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5
+#define PLAYER_CONTROLLER_WIDGET_QUANTITY 6
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);
void player_controller_activate (PlayerController* self);
@@ -266,9 +266,9 @@ static void music_player_bridge_try_to_add_inactive_familiar_clients (MusicPlaye
_g_free0 (_tmp6_);
_g_free0 (_tmp5_);
count = count + 1;
- _g_object_unref0 (info);
- _g_object_unref0 (app_info);
_g_object_unref0 (ctrl);
+ _g_object_unref0 (app_info);
+ _g_object_unref0 (info);
}
_g_free0 (app);
break;
diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h
index 03c8831..6f08b8e 100644
--- a/src/music-player-bridge.h
+++ b/src/music-player-bridge.h
@@ -220,7 +220,8 @@ typedef enum {
PLAYER_CONTROLLER_WIDGET_ORDER_TITLE,
PLAYER_CONTROLLER_WIDGET_ORDER_METADATA,
PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB,
- PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT
+ PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT,
+ PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST
} PlayerControllerwidget_order;
typedef enum {
@@ -259,7 +260,7 @@ struct _FamiliarPlayersDBClass {
};
-GType music_player_bridge_get_type (void);
+GType music_player_bridge_get_type (void) G_GNUC_CONST;
MusicPlayerBridge* music_player_bridge_new (void);
MusicPlayerBridge* music_player_bridge_construct (GType object_type);
void music_player_bridge_on_server_added (MusicPlayerBridge* self, IndicateListenerServer* object, const char* type);
@@ -270,32 +271,31 @@ void music_player_bridge_on_indicator_added (MusicPlayerBridge* self, IndicateLi
void music_player_bridge_on_indicator_removed (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0);
void music_player_bridge_on_indicator_modified (MusicPlayerBridge* self, IndicateListenerServer* object, IndicateListenerIndicator* p0, const char* s);
GAppInfo* music_player_bridge_create_app_info (const char* path);
-GType player_item_get_type (void);
-GType transport_menuitem_get_type (void);
-GType transport_menuitem_action_get_type (void);
-GType player_controller_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType transport_menuitem_get_type (void) G_GNUC_CONST;
+GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
+GType player_controller_get_type (void) G_GNUC_CONST;
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);
GeeHashSet* transport_menuitem_attributes_format (void);
-GType metadata_menuitem_get_type (void);
+GType metadata_menuitem_get_type (void) G_GNUC_CONST;
MetadataMenuitem* metadata_menuitem_new (void);
MetadataMenuitem* metadata_menuitem_construct (GType object_type);
GeeHashSet* metadata_menuitem_attributes_format (void);
-gboolean metadata_menuitem_not_populated (MetadataMenuitem* self);
-GType scrub_menuitem_get_type (void);
+GType scrub_menuitem_get_type (void) G_GNUC_CONST;
ScrubMenuitem* scrub_menuitem_new (PlayerController* parent);
ScrubMenuitem* scrub_menuitem_construct (GType object_type, PlayerController* parent);
void scrub_menuitem_update_position (ScrubMenuitem* self, gint32 new_position);
GeeHashSet* scrub_menuitem_attributes_format (void);
-GType title_menuitem_get_type (void);
+GType title_menuitem_get_type (void) G_GNUC_CONST;
TitleMenuitem* title_menuitem_new (PlayerController* parent);
TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
GeeHashSet* title_menuitem_attributes_format (void);
-GType mpris_controller_get_type (void);
-GType player_controller_widget_order_get_type (void);
-GType player_controller_state_get_type (void);
-#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5
+GType mpris_controller_get_type (void) G_GNUC_CONST;
+GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
+GType player_controller_state_get_type (void) G_GNUC_CONST;
+#define PLAYER_CONTROLLER_WIDGET_QUANTITY 6
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);
@@ -309,7 +309,7 @@ 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);
+GType mpris_controller_v2_get_type (void) G_GNUC_CONST;
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);
@@ -324,9 +324,10 @@ 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);
+gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
PlayerController* player_item_get_owner (PlayerItem* self);
const char* player_item_get_item_type (PlayerItem* self);
-GType familiar_players_db_get_type (void);
+GType familiar_players_db_get_type (void) G_GNUC_CONST;
FamiliarPlayersDB* familiar_players_db_new (void);
FamiliarPlayersDB* familiar_players_db_construct (GType object_type);
void familiar_players_db_insert (FamiliarPlayersDB* self, const char* desktop);
diff --git a/src/play-button.c b/src/play-button.c
index 1aeff12..e4382c1 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -28,12 +28,12 @@ Uses code from ctk
#include "play-button.h"
#define RECT_WIDTH 130.0f
-#define Y 15.0f
+#define Y 5.0f
#define X 37.0f
#define INNER_RADIUS 12.5
#define MIDDLE_RADIUS 13.5f
#define OUTER_RADIUS 14.5f
-#define CIRCLE_RADIUS 19.0f
+#define CIRCLE_RADIUS 21.0f
#define PREV_WIDTH 25.0f
#define PREV_HEIGHT 17.0f
#define NEXT_WIDTH 25.0f //PREV_WIDTH
@@ -42,16 +42,16 @@ Uses code from ctk
#define TRI_HEIGHT 13.0f
#define TRI_OFFSET 6.0f
#define PREV_X 35.0f
-#define PREV_Y 21.0f
+#define PREV_Y 11.0f
#define NEXT_X 113.0f
-#define NEXT_Y 21.0f //prev_y
+#define NEXT_Y 11.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 77.0f
-#define PAUSE_Y 15.0f
+#define PAUSE_X 78.0f
+#define PAUSE_Y 5.0f
#define PLAY_WIDTH 28.0f
#define PLAY_HEIGHT 29.0f
#define PLAY_PADDING 5.0f
@@ -85,16 +85,6 @@ G_DEFINE_TYPE (PlayButton, play_button, GTK_TYPE_DRAWING_AREA);
/// internal helper functions //////////////////////////////////////////////////
-/*static double
-_align (double val)
-{
- double fract = val - (int) val;
-
- if (fract != 0.5f)
- return (double) ((int) val + 0.5f);
- else
- return val;
-}*/
static inline void
_blurinner (guchar* pixel,
@@ -331,7 +321,7 @@ play_button_init (PlayButton *self)
(GDestroyNotify)g_list_free);
GList* previous_list = NULL;
previous_list = g_list_insert(previous_list, GINT_TO_POINTER(15), 0);
- previous_list = g_list_insert(previous_list, GINT_TO_POINTER(10), 1);
+ previous_list = g_list_insert(previous_list, GINT_TO_POINTER(5), 1);
previous_list = g_list_insert(previous_list, GINT_TO_POINTER(60), 2);
previous_list = g_list_insert(previous_list, GINT_TO_POINTER(34), 3);
@@ -340,10 +330,10 @@ play_button_init (PlayButton *self)
previous_list);
GList* play_list = NULL;
- play_list = g_list_insert(play_list, GINT_TO_POINTER(60), 0);
- play_list = g_list_insert(play_list, GINT_TO_POINTER(10), 1);
- play_list = g_list_insert(play_list, GINT_TO_POINTER(45), 2);
- play_list = g_list_insert(play_list, GINT_TO_POINTER(40), 3);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(58), 0);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(0), 1);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(50), 2);
+ play_list = g_list_insert(play_list, GINT_TO_POINTER(43), 3);
g_hash_table_insert(priv->command_coordinates,
GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE),
@@ -351,7 +341,7 @@ play_button_init (PlayButton *self)
GList* next_list = NULL;
next_list = g_list_insert(next_list, GINT_TO_POINTER(100), 0);
- next_list = g_list_insert(next_list, GINT_TO_POINTER(10), 1);
+ next_list = g_list_insert(next_list, GINT_TO_POINTER(5), 1);
next_list = g_list_insert(next_list, GINT_TO_POINTER(60), 2);
next_list = g_list_insert(next_list, GINT_TO_POINTER(34), 3);
@@ -359,7 +349,7 @@ play_button_init (PlayButton *self)
GINT_TO_POINTER(TRANSPORT_NEXT),
next_list);
- gtk_widget_set_size_request(GTK_WIDGET(self), 200, 80);
+ gtk_widget_set_size_request(GTK_WIDGET(self), 200, 50);
}
static void
@@ -399,15 +389,15 @@ determine_button_event(GtkWidget* button, GdkEventButton* event)
PlayButtonEvent button_event = TRANSPORT_NADA;
// For now very simple rectangular collision detection
if(event->x > 55 && event->x < 95
- && event->y > 22 && event->y < 46){
+ && event->y > 12 && event->y < 40){
button_event = TRANSPORT_PREVIOUS;
}
- else if(event->x > 101 && event->x < 133
- && event->y > 20 && event->y < 47){
+ else if(event->x > 99 && event->x < 136
+ && event->y > 5 && event->y < 47){
button_event = TRANSPORT_PLAY_PAUSE;
}
else if(event->x > 137 && event->x < 179
- && event->y > 22 && event->y < 46){
+ && event->y > 12 && event->y < 40){
button_event = TRANSPORT_NEXT;
}
return button_event;
@@ -464,8 +454,29 @@ void
play_button_toggle_play_pause(GtkWidget* button, PlayButtonState update)
{
PlayButtonPrivate* priv = PLAY_BUTTON_GET_PRIVATE(button);
+ gboolean changed = priv->current_state != update;
priv->current_state = update;
g_debug("PlayButton::toggle play state : %i", priv->current_state);
+
+ if(changed == TRUE){
+ g_debug("Toggle play pause - changed of state detected - redraw button");
+ cairo_t *cr;
+
+ cr = gdk_cairo_create (button->window);
+
+ GList* list = g_hash_table_lookup(priv->command_coordinates,
+ GINT_TO_POINTER(TRANSPORT_PLAY_PAUSE));
+
+ cairo_rectangle(cr,
+ GPOINTER_TO_INT(g_list_nth_data(list, 0)),
+ GPOINTER_TO_INT(g_list_nth_data(list, 1)),
+ GPOINTER_TO_INT(g_list_nth_data(list, 2)),
+ GPOINTER_TO_INT(g_list_nth_data(list, 3)));
+
+ cairo_clip(cr);
+ draw (button, cr);
+ cairo_destroy (cr);
+ }
}
@@ -785,33 +796,34 @@ draw (GtkWidget* button, cairo_t *cr)
// play/pause-background
draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f,
Y - ((CIRCLE_RADIUS - OUTER_RADIUS)),
CIRCLE_RADIUS,
OUTER_START,
OUTER_END);
draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 1.0f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.0f,
- CIRCLE_RADIUS - 1,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 0.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 0.5f,
+ CIRCLE_RADIUS - 0.75f,
MIDDLE_START,
MIDDLE_END);
- draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 2.0f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 2.0f,
- CIRCLE_RADIUS - 2.0f,
- INNER_START,
- INNER_END);
+
if(priv->current_command == TRANSPORT_PLAY_PAUSE){
draw_circle (cr,
- X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 4.5f + 2.0f,
- Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 2.0f,
- CIRCLE_RADIUS - 2.0f,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f,
+ CIRCLE_RADIUS - 1.5f,
INNER_COMPRESSED_START,
INNER_COMPRESSED_END);
}
-
-
+ else{
+ draw_circle (cr,
+ X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.5f,
+ Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.5f,
+ CIRCLE_RADIUS - 1.5f,
+ INNER_START,
+ INNER_END);
+ }
// draw previous-button drop-shadow
_setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT);
_mask_prev (cr_surf,
@@ -940,7 +952,7 @@ draw (GtkWidget* button, cairo_t *cr)
BUTTON_SHADOW,
FALSE);
_surface_blur (surf, 1);
- _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f);
// draw play-button
_setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT);
cairo_set_line_width (cr, 10.5);
@@ -959,7 +971,7 @@ draw (GtkWidget* button, cairo_t *cr)
BUTTON_START,
BUTTON_END,
FALSE);
- _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y);
}
}
diff --git a/src/player-controller.c b/src/player-controller.c
index acb2da2..55b097f 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -71,16 +71,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_METADATA_MENUITEM (metadata_menuitem_get_type ())
-#define METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitem))
-#define METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
-#define IS_METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_METADATA_MENUITEM))
-#define IS_METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_METADATA_MENUITEM))
-#define METADATA_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
-
-typedef struct _MetadataMenuitem MetadataMenuitem;
-typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
-
#define 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))
@@ -91,6 +81,16 @@ typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
typedef struct _TitleMenuitem TitleMenuitem;
typedef struct _TitleMenuitemClass TitleMenuitemClass;
+#define TYPE_METADATA_MENUITEM (metadata_menuitem_get_type ())
+#define METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitem))
+#define METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
+#define IS_METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_METADATA_MENUITEM))
+#define IS_METADATA_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_METADATA_MENUITEM))
+#define METADATA_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitemClass))
+
+typedef struct _MetadataMenuitem MetadataMenuitem;
+typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
+
#define TYPE_SCRUB_MENUITEM (scrub_menuitem_get_type ())
#define SCRUB_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SCRUB_MENUITEM, ScrubMenuitem))
#define SCRUB_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SCRUB_MENUITEM, ScrubMenuitemClass))
@@ -135,7 +135,8 @@ typedef enum {
PLAYER_CONTROLLER_WIDGET_ORDER_TITLE,
PLAYER_CONTROLLER_WIDGET_ORDER_METADATA,
PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB,
- PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT
+ PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT,
+ PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST
} PlayerControllerwidget_order;
typedef enum {
@@ -149,9 +150,9 @@ typedef enum {
static gpointer player_controller_parent_class = NULL;
-GType player_controller_get_type (void);
-GType player_item_get_type (void);
-GType mpris_controller_get_type (void);
+GType player_controller_get_type (void) G_GNUC_CONST;
+GType player_item_get_type (void) G_GNUC_CONST;
+GType mpris_controller_get_type (void) G_GNUC_CONST;
#define PLAYER_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLAYER_CONTROLLER, PlayerControllerPrivate))
enum {
PLAYER_CONTROLLER_DUMMY_PROPERTY,
@@ -159,12 +160,11 @@ enum {
PLAYER_CONTROLLER_APP_INFO,
PLAYER_CONTROLLER_MENU_OFFSET
};
-GType player_controller_widget_order_get_type (void);
-GType player_controller_state_get_type (void);
-#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5
+GType player_controller_widget_order_get_type (void) G_GNUC_CONST;
+GType player_controller_state_get_type (void) G_GNUC_CONST;
+#define PLAYER_CONTROLLER_WIDGET_QUANTITY 6
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);
@@ -172,6 +172,7 @@ void player_controller_update_layout (PlayerController* self);
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_update_state (PlayerController* self, PlayerControllerstate new_state);
void player_controller_activate (PlayerController* self);
GAppInfo* player_controller_get_app_info (PlayerController* self);
void player_controller_instantiate (PlayerController* self);
@@ -179,20 +180,24 @@ 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);
-GType metadata_menuitem_get_type (void);
+gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
+GeeHashSet* metadata_menuitem_attributes_format (void);
+GeeHashSet* scrub_menuitem_attributes_format (void);
PlayerItem* player_item_new (const char* type);
PlayerItem* player_item_construct (GType object_type, const char* type);
TitleMenuitem* title_menuitem_new (PlayerController* parent);
TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* parent);
-GType title_menuitem_get_type (void);
+GType title_menuitem_get_type (void) G_GNUC_CONST;
MetadataMenuitem* metadata_menuitem_new (void);
MetadataMenuitem* metadata_menuitem_construct (GType object_type);
+GType metadata_menuitem_get_type (void) G_GNUC_CONST;
ScrubMenuitem* scrub_menuitem_new (PlayerController* parent);
ScrubMenuitem* scrub_menuitem_construct (GType object_type, PlayerController* parent);
-GType scrub_menuitem_get_type (void);
+GType scrub_menuitem_get_type (void) G_GNUC_CONST;
TransportMenuitem* transport_menuitem_new (PlayerController* parent);
TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent);
-GType transport_menuitem_get_type (void);
+GType transport_menuitem_get_type (void) G_GNUC_CONST;
+static PlayerItem* player_controller_create_playlist (PlayerController* self);
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);
@@ -205,7 +210,7 @@ static int _vala_strcmp0 (const char * str1, const char * str2);
GType player_controller_widget_order_get_type (void) {
static volatile gsize player_controller_widget_order_type_id__volatile = 0;
if (g_once_init_enter (&player_controller_widget_order_type_id__volatile)) {
- static const GEnumValue values[] = {{PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, "PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR", "separator"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, "PLAYER_CONTROLLER_WIDGET_ORDER_TITLE", "title"}, {PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, "PLAYER_CONTROLLER_WIDGET_ORDER_METADATA", "metadata"}, {PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB, "PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB", "scrub"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, "PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT", "transport"}, {0, NULL, NULL}};
+ static const GEnumValue values[] = {{PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR, "PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR", "separator"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TITLE, "PLAYER_CONTROLLER_WIDGET_ORDER_TITLE", "title"}, {PLAYER_CONTROLLER_WIDGET_ORDER_METADATA, "PLAYER_CONTROLLER_WIDGET_ORDER_METADATA", "metadata"}, {PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB, "PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB", "scrub"}, {PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT, "PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT", "transport"}, {PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST, "PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST", "playlist"}, {0, NULL, NULL}};
GType player_controller_widget_order_type_id;
player_controller_widget_order_type_id = g_enum_register_static ("PlayerControllerwidget_order", values);
g_once_init_leave (&player_controller_widget_order_type_id__volatile, player_controller_widget_order_type_id);
@@ -256,7 +261,7 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit
_g_free0 (_tmp2_);
_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);
+ self->current_state = (gint) initial_state;
player_controller_set_menu_offset (self, offset);
player_controller_construct_widgets (self);
player_controller_establish_mpris_connection (self);
@@ -272,9 +277,10 @@ PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* cli
void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) {
g_return_if_fail (self != NULL);
- g_debug ("player-controller.vala:68: update_state - player controller %s : new s" \
+ g_debug ("player-controller.vala:69: update_state - player controller %s : new s" \
"tate %i", self->priv->_name, (gint) new_state);
self->current_state = (gint) new_state;
+ player_controller_update_layout (self);
}
@@ -291,7 +297,7 @@ void player_controller_instantiate (PlayerController* self) {
GError * _inner_error_;
g_return_if_fail (self != NULL);
_inner_error_ = NULL;
- g_debug ("player-controller.vala:87: instantiate in player controller for %s", self->priv->_name);
+ g_debug ("player-controller.vala:88: 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) {
@@ -306,7 +312,7 @@ void player_controller_instantiate (PlayerController* self) {
_error_ = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("player-controller.vala:93: Failed to launch app %s with error message:" \
+ g_warning ("player-controller.vala:94: Failed to launch app %s with error message:" \
" %s", self->priv->_name, _error_->message);
_g_error_free0 (_error_);
}
@@ -323,25 +329,24 @@ 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:100: establish_mpris_connection - Not ready to " \
+ g_debug ("player-controller.vala:101: establish_mpris_connection - Not ready to " \
"connect");
return;
}
if (_vala_strcmp0 (self->priv->_name, "Vlc") == 0) {
MprisController* _tmp0_;
- g_debug ("player-controller.vala:105: establishing a vlc mpris controller");
+ g_debug ("player-controller.vala:106: 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, "org.freedesktop.MediaPlayer"), _g_object_unref0 (self->mpris_adaptor), _tmp1_);
}
if (mpris_controller_connected (self->mpris_adaptor) == TRUE) {
- g_debug ("player-controller.vala:113: yup I'm connected");
+ g_debug ("player-controller.vala:114: yup I'm connected");
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED);
} else {
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED);
}
- player_controller_update_layout (self);
}
@@ -377,33 +382,56 @@ static char* bool_to_string (gboolean self) {
void player_controller_update_layout (PlayerController* self) {
- gboolean visibility;
- PlayerItem* _tmp0_;
- MetadataMenuitem* meta_item;
- char* _tmp1_;
- PlayerItem* _tmp2_;
- PlayerItem* _tmp3_;
+ char* _tmp6_;
+ GeeHashSet* _tmp5_;
PlayerItem* _tmp4_;
+ GeeHashSet* _tmp9_;
+ PlayerItem* _tmp8_;
+ PlayerItem* _tmp7_;
+ char* _tmp12_;
+ GeeHashSet* _tmp11_;
+ PlayerItem* _tmp10_;
+ GeeHashSet* _tmp15_;
+ PlayerItem* _tmp14_;
+ PlayerItem* _tmp13_;
+ PlayerItem* _tmp16_;
+ PlayerItem* _tmp17_;
g_return_if_fail (self != NULL);
- visibility = TRUE;
- meta_item = (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), IS_METADATA_MENUITEM (_tmp0_) ? ((MetadataMenuitem*) _tmp0_) : NULL);
if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) {
- visibility = FALSE;
+ PlayerItem* _tmp0_;
+ PlayerItem* _tmp1_;
+ PlayerItem* _tmp2_;
+ PlayerItem* _tmp3_;
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT)), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ _g_object_unref0 (_tmp0_);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp1_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB)), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ _g_object_unref0 (_tmp1_);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ _g_object_unref0 (_tmp2_);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp3_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST)), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+ _g_object_unref0 (_tmp3_);
+ return;
}
- g_debug ("player-controller.vala:137: about the set the visibility on both the t" \
-"ransport and metadata widget to %s", _tmp1_ = bool_to_string (visibility));
- _g_free0 (_tmp1_);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
- _g_object_unref0 (_tmp2_);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp3_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
- _g_object_unref0 (_tmp3_);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp4_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
+ g_debug ("player-controller.vala:143: update layout - metadata %s", _tmp6_ = bool_to_string (player_item_populated (_tmp4_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp5_ = metadata_menuitem_attributes_format ())));
+ _g_free0 (_tmp6_);
+ _g_object_unref0 (_tmp5_);
_g_object_unref0 (_tmp4_);
- if (visibility == FALSE) {
- g_warning ("player-controller.vala:143: Update layout of client %s is setting widg" \
-"ets to invisibile!", self->priv->_name);
- }
- _g_object_unref0 (meta_item);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp7_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, player_item_populated (_tmp8_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp9_ = metadata_menuitem_attributes_format ()));
+ _g_object_unref0 (_tmp9_);
+ _g_object_unref0 (_tmp8_);
+ _g_object_unref0 (_tmp7_);
+ g_debug ("player-controller.vala:146: update layout - scrub %s", _tmp12_ = bool_to_string (player_item_populated (_tmp10_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), _tmp11_ = scrub_menuitem_attributes_format ())));
+ _g_free0 (_tmp12_);
+ _g_object_unref0 (_tmp11_);
+ _g_object_unref0 (_tmp10_);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp13_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB)), DBUSMENU_MENUITEM_PROP_VISIBLE, player_item_populated (_tmp14_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), _tmp15_ = scrub_menuitem_attributes_format ()));
+ _g_object_unref0 (_tmp15_);
+ _g_object_unref0 (_tmp14_);
+ _g_object_unref0 (_tmp13_);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp16_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT)), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ _g_object_unref0 (_tmp16_);
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp17_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST)), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ _g_object_unref0 (_tmp17_);
}
@@ -413,6 +441,7 @@ static void player_controller_construct_widgets (PlayerController* self) {
MetadataMenuitem* metadata_item;
ScrubMenuitem* scrub_item;
TransportMenuitem* transport_item;
+ PlayerItem* _tmp1_;
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_);
@@ -424,6 +453,8 @@ static void player_controller_construct_widgets (PlayerController* self) {
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) scrub_item);
transport_item = transport_menuitem_new (self);
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) transport_item);
+ gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, _tmp1_ = player_controller_create_playlist (self));
+ _g_object_unref0 (_tmp1_);
{
GeeIterator* _item_it;
_item_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) self->custom_items);
@@ -438,10 +469,36 @@ static void player_controller_construct_widgets (PlayerController* self) {
}
_g_object_unref0 (_item_it);
}
- _g_object_unref0 (title_menu_item);
- _g_object_unref0 (metadata_item);
- _g_object_unref0 (scrub_item);
_g_object_unref0 (transport_item);
+ _g_object_unref0 (scrub_item);
+ _g_object_unref0 (metadata_item);
+ _g_object_unref0 (title_menu_item);
+}
+
+
+static PlayerItem* player_controller_create_playlist (PlayerController* self) {
+ PlayerItem* result = NULL;
+ PlayerItem* playlist_root;
+ PlayerItem* subentry_1;
+ PlayerItem* subentry_2;
+ PlayerItem* subentry_3;
+ g_return_val_if_fail (self != NULL, NULL);
+ playlist_root = player_item_new (DBUSMENU_CLIENT_TYPES_DEFAULT);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) playlist_root, DBUSMENU_MENUITEM_PROP_LABEL, "Choose Playlist");
+ subentry_1 = player_item_new (DBUSMENU_CLIENT_TYPES_DEFAULT);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) subentry_1, DBUSMENU_MENUITEM_PROP_LABEL, "Raster-noton selection");
+ subentry_2 = player_item_new (DBUSMENU_CLIENT_TYPES_DEFAULT);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) subentry_2, DBUSMENU_MENUITEM_PROP_LABEL, "Rune Grammofon selection");
+ subentry_3 = player_item_new (DBUSMENU_CLIENT_TYPES_DEFAULT);
+ dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) subentry_3, DBUSMENU_MENUITEM_PROP_LABEL, "Kranky selection");
+ dbusmenu_menuitem_child_append ((DbusmenuMenuitem*) playlist_root, (DbusmenuMenuitem*) subentry_1);
+ dbusmenu_menuitem_child_append ((DbusmenuMenuitem*) playlist_root, (DbusmenuMenuitem*) subentry_2);
+ dbusmenu_menuitem_child_append ((DbusmenuMenuitem*) playlist_root, (DbusmenuMenuitem*) subentry_3);
+ result = playlist_root;
+ _g_object_unref0 (subentry_3);
+ _g_object_unref0 (subentry_2);
+ _g_object_unref0 (subentry_1);
+ return result;
}
@@ -490,7 +547,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:179: PlayerController->format_client_name - : %" \
+ g_debug ("player-controller.vala:212: PlayerController->format_client_name - : %" \
"s", formatted);
}
result = formatted;
diff --git a/src/player-controller.vala b/src/player-controller.vala
index f824d6f..fc5ca9b 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -23,14 +23,15 @@ using Gee;
public class PlayerController : GLib.Object
{
- public const int WIDGET_QUANTITY = 5;
+ public const int WIDGET_QUANTITY = 6;
public static enum widget_order{
SEPARATOR,
TITLE,
METADATA,
SCRUB,
- TRANSPORT
+ TRANSPORT,
+ PLAYLIST
}
public enum state{
@@ -56,7 +57,7 @@ public class PlayerController : GLib.Object
this.root_menu = root;
this.name = format_client_name(client_name.strip());
this.custom_items = new ArrayList<PlayerItem>();
- this.update_state(initial_state);
+ this.current_state = initial_state;
this.menu_offset = offset;
construct_widgets();
establish_mpris_connection();
@@ -67,7 +68,7 @@ public class PlayerController : GLib.Object
{
debug("update_state - player controller %s : new state %i", this.name, new_state);
this.current_state = new_state;
- //this.update_layout();
+ this.update_layout();
}
public void activate()
@@ -108,7 +109,7 @@ public class PlayerController : GLib.Object
else{
this.mpris_adaptor = new MprisController(this);
}
-
+ // TODO refactor
if(this.mpris_adaptor.connected() == true){
debug("yup I'm connected");
this.update_state(state.CONNECTED);
@@ -116,7 +117,6 @@ public class PlayerController : GLib.Object
else{
this.update_state(state.DISCONNECTED);
}
- this.update_layout();
}
public void vanish()
@@ -127,21 +127,32 @@ public class PlayerController : GLib.Object
}
public void update_layout()
- {
- bool visibility = true;
- MetadataMenuitem meta_item = this.custom_items[widget_order.METADATA] as MetadataMenuitem;
- if(this.current_state != state.CONNECTED /*||
- meta_item.not_populated()*/){
- visibility = false;
- }
- debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string());
- this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
- this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
- this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
- // DEBUG
- if(visibility == false){
- warning("Update layout of client %s is setting widgets to invisibile!", this.name);
+ {
+ if(this.current_state != state.CONNECTED){
+ this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE,
+ false);
+ this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE,
+ false);
+ this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE,
+ false);
+ this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE,
+ false);
+ return;
}
+
+ debug("update layout - metadata %s", this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()).to_string());
+ this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE,
+ this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format()));
+ debug("update layout - scrub %s", this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()).to_string());
+ this.custom_items[widget_order.SCRUB].property_set_bool(MENUITEM_PROP_VISIBLE,
+ this.custom_items[widget_order.SCRUB].populated(ScrubMenuitem.attributes_format()));
+
+
+ this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE,
+ true);
+
+ this.custom_items[widget_order.PLAYLIST].property_set_bool(MENUITEM_PROP_VISIBLE,
+ true);
}
private void construct_widgets()
@@ -164,12 +175,34 @@ public class PlayerController : GLib.Object
// Transport item
TransportMenuitem transport_item = new TransportMenuitem(this);
this.custom_items.add(transport_item);
-
+
+ this.custom_items.add(create_playlist());
foreach(PlayerItem item in this.custom_items){
root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
}
}
+
+ private PlayerItem create_playlist()
+ {
+ PlayerItem playlist_root = new PlayerItem(CLIENT_TYPES_DEFAULT);
+ playlist_root.property_set(MENUITEM_PROP_LABEL, "Choose Playlist");
+
+ PlayerItem subentry_1 = new PlayerItem(CLIENT_TYPES_DEFAULT);
+ subentry_1.property_set(MENUITEM_PROP_LABEL, "Raster-noton selection");
+
+ PlayerItem subentry_2 = new PlayerItem(CLIENT_TYPES_DEFAULT);
+ subentry_2.property_set(MENUITEM_PROP_LABEL, "Rune Grammofon selection");
+
+ PlayerItem subentry_3 = new PlayerItem(CLIENT_TYPES_DEFAULT);
+ subentry_3.property_set(MENUITEM_PROP_LABEL, "Kranky selection");
+
+ playlist_root.child_append(subentry_1);
+ playlist_root.child_append(subentry_2);
+ playlist_root.child_append(subentry_3);
+
+ return playlist_root;
+ }
private static string format_client_name(string client_name)
{
diff --git a/src/player-item.c b/src/player-item.c
index 7546ca2..301fb33 100644
--- a/src/player-item.c
+++ b/src/player-item.c
@@ -72,20 +72,21 @@ struct _PlayerItemPrivate {
static gpointer player_item_parent_class = NULL;
-GType player_item_get_type (void);
-GType player_controller_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType player_controller_get_type (void) G_GNUC_CONST;
#define PLAYER_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PLAYER_ITEM, PlayerItemPrivate))
enum {
PLAYER_ITEM_DUMMY_PROPERTY,
PLAYER_ITEM_OWNER,
PLAYER_ITEM_ITEM_TYPE
};
+#define PLAYER_ITEM_EMPTY (-1)
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);
-static gboolean player_item_ensure_valid_updates (GHashTable* data, GeeHashSet* attributes);
static GValue* _g_value_dup (GValue* self);
void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
+gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
PlayerController* player_item_get_owner (PlayerItem* self);
static void player_item_set_owner (PlayerItem* self, PlayerController* value);
const char* player_item_get_item_type (PlayerItem* self);
@@ -125,9 +126,8 @@ void player_item_reset (PlayerItem* self, GeeHashSet* attrs) {
break;
}
s = (char*) gee_iterator_get (_s_it);
- g_debug ("player-item.vala:39: attempting to set prop %s to null", s);
- dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, s, NULL);
- dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, s, 0);
+ g_debug ("player-item.vala:40: attempting to set prop %s to EMPTY", s);
+ dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, s, PLAYER_ITEM_EMPTY);
_g_free0 (s);
}
_g_object_unref0 (_s_it);
@@ -172,9 +172,9 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
g_return_if_fail (attributes != NULL);
_inner_error_ = NULL;
g_debug ("player-item.vala:47: PlayerItem::update()");
- if (player_item_ensure_valid_updates (data, attributes) == FALSE) {
- g_debug ("player-item.vala:49: PlayerItem::Update -> The hashtable update does n" \
-"ot contain what we were expecting - just leave it!");
+ if (data == NULL) {
+ g_debug ("player-item.vala:49: PlayerItem::Update -> The hashtable was null - ju" \
+"st leave it!");
return;
}
{
@@ -215,10 +215,10 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
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_free0 (search_key);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (property);
_g_object_unref0 (_property_it);
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -240,10 +240,10 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
__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_free0 (search_key);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (property);
_g_object_unref0 (_property_it);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
@@ -267,25 +267,46 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
}
}
}
- _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_free0 (search_key);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (property);
}
_g_object_unref0 (_property_it);
}
+ if (dbusmenu_menuitem_property_get_bool ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_VISIBLE) == FALSE) {
+ dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ }
}
-static gboolean player_item_ensure_valid_updates (GHashTable* data, GeeHashSet* attributes) {
+gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs) {
gboolean result = FALSE;
- g_return_val_if_fail (data != NULL, FALSE);
- g_return_val_if_fail (attributes != NULL, FALSE);
- if (data == NULL) {
- result = FALSE;
- return result;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (attrs != NULL, FALSE);
+ {
+ GeeIterator* _prop_it;
+ _prop_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) attrs);
+ while (TRUE) {
+ char* prop;
+ gint value_int;
+ if (!gee_iterator_next (_prop_it)) {
+ break;
+ }
+ prop = (char*) gee_iterator_get (_prop_it);
+ value_int = dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop);
+ g_debug ("player-item.vala:94: populate - prop %s and value %i", prop, value_int);
+ if (dbusmenu_menuitem_property_get_int ((DbusmenuMenuitem*) self, prop) != PLAYER_ITEM_EMPTY) {
+ result = TRUE;
+ _g_free0 (prop);
+ _g_object_unref0 (_prop_it);
+ return result;
+ }
+ _g_free0 (prop);
+ }
+ _g_object_unref0 (_prop_it);
}
- result = TRUE;
+ result = FALSE;
return result;
}
diff --git a/src/player-item.vala b/src/player-item.vala
index 2952f71..288ac47 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -24,7 +24,8 @@ public class PlayerItem : Dbusmenu.Menuitem
{
public PlayerController owner {get; construct;}
public string item_type { get; construct; }
-
+ private const int EMPTY = -1;
+
public PlayerItem(string type)
{
Object(item_type: type);
@@ -36,17 +37,16 @@ public class PlayerItem : Dbusmenu.Menuitem
public void reset(HashSet<string> attrs){
foreach(string s in attrs){
- debug("attempting to set prop %s to null", s);
- this.property_set(s, null);
- this.property_set_int(s, 0);
+ debug("attempting to set prop %s to EMPTY", s);
+ this.property_set_int(s, EMPTY);
}
}
public void update(HashTable<string, Value?> data, HashSet<string> attributes)
{
debug("PlayerItem::update()");
- if(ensure_valid_updates(data, attributes) == false){
- debug("PlayerItem::Update -> The hashtable update does not contain what we were expecting - just leave it!");
+ if(data == null){
+ debug("PlayerItem::Update -> The hashtable was null - just leave it!");
return;
}
@@ -82,19 +82,21 @@ public class PlayerItem : Dbusmenu.Menuitem
this.property_set_bool(property, v.get_boolean());
}
}
+ if(this.property_get_bool(MENUITEM_PROP_VISIBLE) == false){
+ this.property_set_bool(MENUITEM_PROP_VISIBLE, true);
+ }
}
-
- private static bool ensure_valid_updates(HashTable<string, Value?> data, HashSet<string> attributes)
+
+ public bool populated(HashSet<string> attrs)
{
- if(data == null){
- return false;
+ foreach(string prop in attrs){
+ int value_int = property_get_int(prop);
+ debug("populate - prop %s and value %i", prop, value_int);
+ if(property_get_int(prop) != EMPTY){
+ return true;
+ }
}
- /*if(data.size() < attributes.size){
- warning("update hash was too small for the target");
- return false;
- }*/
- return true;
+ return false;
}
-
}
diff --git a/src/scrub-menu-item.c b/src/scrub-menu-item.c
index 24b10e3..4cb0f02 100644
--- a/src/scrub-menu-item.c
+++ b/src/scrub-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>
#include <float.h>
#include <math.h>
@@ -55,6 +55,7 @@ typedef struct _PlayerItemPrivate PlayerItemPrivate;
typedef struct _ScrubMenuitem ScrubMenuitem;
typedef struct _ScrubMenuitemClass ScrubMenuitemClass;
typedef struct _ScrubMenuitemPrivate ScrubMenuitemPrivate;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define TYPE_PLAYER_CONTROLLER (player_controller_get_type ())
#define PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_CONTROLLER, PlayerController))
@@ -76,7 +77,6 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate;
typedef struct _MprisController MprisController;
typedef struct _MprisControllerClass MprisControllerClass;
-#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
@@ -111,28 +111,32 @@ struct _PlayerControllerClass {
static gpointer scrub_menuitem_parent_class = NULL;
-GType player_item_get_type (void);
-GType scrub_menuitem_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType scrub_menuitem_get_type (void) G_GNUC_CONST;
enum {
SCRUB_MENUITEM_DUMMY_PROPERTY
};
-GType player_controller_get_type (void);
+void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
+GeeHashSet* scrub_menuitem_attributes_format (void);
+GType player_controller_get_type (void) G_GNUC_CONST;
ScrubMenuitem* scrub_menuitem_new (PlayerController* parent);
ScrubMenuitem* scrub_menuitem_construct (GType object_type, PlayerController* parent);
PlayerController* player_item_get_owner (PlayerItem* self);
const char* player_controller_get_name (PlayerController* self);
-GType mpris_controller_get_type (void);
+GType mpris_controller_get_type (void) G_GNUC_CONST;
void mpris_controller_set_position (MprisController* self, double position);
static void scrub_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
void scrub_menuitem_update_position (ScrubMenuitem* self, gint32 new_position);
-GeeHashSet* scrub_menuitem_attributes_format (void);
ScrubMenuitem* scrub_menuitem_construct (GType object_type, PlayerController* parent) {
ScrubMenuitem * self;
+ GeeHashSet* _tmp0_;
g_return_val_if_fail (parent != NULL, NULL);
self = (ScrubMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_SCRUB_MENUITEM_TYPE, "owner", parent, NULL);
+ player_item_reset ((PlayerItem*) self, _tmp0_ = scrub_menuitem_attributes_format ());
+ _g_object_unref0 (_tmp0_);
return self;
}
@@ -146,7 +150,7 @@ static void scrub_menuitem_real_handle_event (DbusmenuMenuitem* base, const char
ScrubMenuitem * self;
self = (ScrubMenuitem*) base;
g_return_if_fail (name != NULL);
- g_debug ("scrub-menu-item.vala:33: handle_event for owner %s with value: %f", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)), g_value_get_double (input_value));
+ g_debug ("scrub-menu-item.vala:34: handle_event for owner %s with value: %f", player_controller_get_name (player_item_get_owner ((PlayerItem*) self)), g_value_get_double (input_value));
mpris_controller_set_position (player_item_get_owner ((PlayerItem*) self)->mpris_adaptor, g_value_get_double (input_value));
}
diff --git a/src/scrub-menu-item.vala b/src/scrub-menu-item.vala
index 29fa903..ca81c38 100644
--- a/src/scrub-menu-item.vala
+++ b/src/scrub-menu-item.vala
@@ -26,6 +26,7 @@ public class ScrubMenuitem : PlayerItem
public ScrubMenuitem(PlayerController parent)
{
Object(item_type: MENUITEM_TYPE, owner: parent);
+ reset(attributes_format());
}
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
diff --git a/src/scrub-widget.c b/src/scrub-widget.c
index fa290e0..52d7b83 100644
--- a/src/scrub-widget.c
+++ b/src/scrub-widget.c
@@ -93,10 +93,13 @@ scrub_widget_init (ScrubWidget *self)
priv->ido_scrub_bar = ido_scale_menu_item_new_with_range ("Scrub", IDO_RANGE_STYLE_SMALL, 0, 0, 100, 1);
priv->time_line = ido_timeline_new(0);
- ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), IDO_SCALE_MENU_ITEM_STYLE_LABEL);
+ ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), IDO_SCALE_MENU_ITEM_STYLE_LABEL);
+
g_object_set(priv->ido_scrub_bar, "reverse-scroll-events", TRUE, NULL);
priv->scrubbing = FALSE;
-
+
+ gtk_widget_set_size_request(GTK_WIDGET(priv->ido_scrub_bar), 100, 25);
+
// register slider changes listening on the range
GtkWidget* scrub_widget = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar);
g_signal_connect(scrub_widget, "change-value", G_CALLBACK(scrub_widget_change_value_cb), self);
@@ -105,6 +108,7 @@ scrub_widget_init (ScrubWidget *self)
g_signal_connect(priv->time_line, "finished", G_CALLBACK(scrub_widget_timeline_finished_cb), self);
g_signal_connect(priv->ido_scrub_bar, "slider-grabbed", G_CALLBACK(scrub_widget_slider_grabbed), self);
g_signal_connect(priv->ido_scrub_bar, "slider-released", G_CALLBACK(scrub_widget_slider_released), self);
+
}
static void
@@ -131,14 +135,15 @@ scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_DURATION, property) == 0){
g_debug("scrub-widget::update length = %i", g_value_get_int(value));
- ido_scale_menu_item_set_secondary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar),
+
+ ido_scale_menu_item_set_secondary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar),
scrub_widget_format_time(g_value_get_int(value)));
-
+
ido_timeline_set_duration(priv->time_line, g_value_get_int(value) * 1000);
ido_timeline_rewind(priv->time_line);
scrub_widget_check_play_state(mitem);
- g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line));
- g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line));
+ //g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line));
+ //g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line));
scrub_widget_set_ido_position(mitem,
dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_POSITION)/1000,
@@ -149,12 +154,14 @@ scrub_widget_property_update(DbusmenuMenuitem* item, gchar* property,
ido_timeline_pause(priv->time_line);
ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar),
scrub_widget_format_time(g_value_get_int(value)/1000));
+
+ g_debug("scrub-widget::update progress = %f", scrub_widget_calculate_progress(mitem)*100);
- ido_timeline_set_progress(priv->time_line, scrub_widget_calculate_progress(mitem)*1000);
+ ido_timeline_set_progress(priv->time_line, scrub_widget_calculate_progress(mitem));
scrub_widget_set_ido_position(mitem, g_value_get_int(value)/1000,
dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_DURATION));
- ido_timeline_start(priv->time_line);
+ scrub_widget_check_play_state(mitem);
}
else if(g_ascii_strcasecmp(DBUSMENU_SCRUB_MENUITEM_PLAY_STATE, property) == 0){
scrub_widget_check_play_state(mitem);
@@ -188,7 +195,8 @@ scrub_widget_set_twin_item(ScrubWidget* self,
g_signal_connect(G_OBJECT(twin_item), "property-changed",
G_CALLBACK(scrub_widget_property_update), self);
- gchar* left_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item, DBUSMENU_SCRUB_MENUITEM_POSITION)/1000);
+ gchar* left_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item,
+ DBUSMENU_SCRUB_MENUITEM_POSITION)/1000);
gchar* right_text = scrub_widget_format_time(dbusmenu_menuitem_property_get_int(priv->twin_item,
DBUSMENU_SCRUB_MENUITEM_DURATION));
scrub_widget_set_ido_position(self,
@@ -207,22 +215,20 @@ scrub_widget_change_value_cb (GtkRange *range,
gdouble new_value,
gpointer user_data)
{
- /*g_return_val_if_fail (IS_SCRUB_WIDGET (user_data), FALSE);
+ g_return_val_if_fail (IS_SCRUB_WIDGET (user_data), FALSE);
ScrubWidget* mitem = SCRUB_WIDGET(user_data);
ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem);
+ // Don't bother when the slider is grabbed
+ if(priv->scrubbing == TRUE)
+ return FALSE;
+
GValue value = {0};
g_value_init(&value, G_TYPE_DOUBLE);
gdouble clamped = CLAMP(new_value, 0, 100);
g_value_set_double(&value, clamped);
- //g_debug("scrub-widget-change-value callback - = %f", clamped);
- if(priv->scrubbing == FALSE){
- dbusmenu_menuitem_handle_event (priv->twin_item, "scrubbing", &value, 0);
- }
- else{
- g_debug("blocking scrubbing because the slider is still grabbed"
- }*/
- return FALSE;
+ dbusmenu_menuitem_handle_event (priv->twin_item, "scrubbing", &value, 0);
+ return TRUE;
}
GtkWidget*
@@ -235,18 +241,27 @@ scrub_widget_get_ido_bar(ScrubWidget* self)
static gchar*
scrub_widget_format_time(gint time)
{
- // Assuming its in seconds for now ...
- gint minutes = time/60;
- gint seconds = time % 60;
- gchar* prefix="0";
- gchar* seconds_prefix="0";
- if(minutes > 9)
- prefix="";
- if(seconds > 9)
- seconds_prefix="";
- return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds);
+// Assuming its in seconds for now ...
+ gchar* prefix = "-";
+ gchar* seconds_prefix = "-";
+
+ if(time != DBUSMENU_PROPERTY_EMPTY){
+ gint minutes = time/60;
+ gint seconds = time % 60;
+ prefix="0";
+ seconds_prefix="0";
+ if(minutes > 9)
+ prefix="";
+ if(seconds > 9)
+ seconds_prefix="";
+ return g_strdup_printf("%s%i:%s%i", prefix, minutes, seconds_prefix, seconds);
+
+ }
+ else{
+ return g_strdup_printf("%s-:%s-", prefix, seconds_prefix);
+ }
}
-
+
static void
scrub_widget_set_ido_position(ScrubWidget* self,
gint position,
@@ -289,7 +304,7 @@ scrub_widget_timeline_frame_cb( IdoTimeline *timeline,
ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem);
if(priv->scrubbing == TRUE)
{
- //g_debug("don't update the slider or timeline, slider is being scrubbed");
+ g_debug("don't update the slider or timeline, slider is being scrubbed");
return;
}
gint position = progress * dbusmenu_menuitem_property_get_int(priv->twin_item,
@@ -298,12 +313,12 @@ scrub_widget_timeline_frame_cb( IdoTimeline *timeline,
ido_scale_menu_item_set_primary_label(IDO_SCALE_MENU_ITEM(priv->ido_scrub_bar), left_text);
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_scrub_bar);
GtkRange *range = (GtkRange*)slider;
- gtk_range_set_value(range, progress * 100);
-
+ gtk_range_set_value(range, progress * 100);
/*g_debug("position in seconds %i and in words %s", position, left_text);
g_debug("timeline is running: %i", (gint)ido_timeline_is_running(priv->time_line));
g_debug("timeline duration = %i", ido_timeline_get_duration(priv->time_line));
*/
+ //g_debug("timeline-update - progress = %f", progress);
g_free(left_text);
}
@@ -329,8 +344,7 @@ scrub_widget_slider_grabbed(GtkWidget *widget, gpointer user_data)
{
ScrubWidget* mitem = SCRUB_WIDGET(user_data);
ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem);
- priv->scrubbing = TRUE;
-
+ priv->scrubbing = TRUE;
}
static void
@@ -345,10 +359,6 @@ scrub_widget_timeline_finished_cb(IdoTimeline *timeline,
gpointer user_data)
{
g_debug("Timeline Finished!");
- /*g_return_if_fail (IS_SCRUB_WIDGET (user_data));
- ScrubWidget* mitem = SCRUB_WIDGET(user_data);
- ScrubWidgetPrivate * priv = SCRUB_WIDGET_GET_PRIVATE(mitem);
- ido_timeline_rewind(priv->time_line);*/
}
/**
diff --git a/src/sound-service-server.h b/src/sound-service-server.h
index 2773619..e889c2d 100644
--- a/src/sound-service-server.h
+++ b/src/sound-service-server.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#define g_marshal_value_peek_variant(v) g_value_get_variant (v)
#else /* !G_ENABLE_DEBUG */
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
* Do not access GValues directly in your code. Instead, use the
@@ -50,6 +51,7 @@ G_BEGIN_DECLS
#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
#endif /* !G_ENABLE_DEBUG */
diff --git a/src/title-menu-item.c b/src/title-menu-item.c
index 9dab15f..70ddc74 100644
--- a/src/title-menu-item.c
+++ b/src/title-menu-item.c
@@ -119,18 +119,18 @@ typedef enum {
static gpointer title_menuitem_parent_class = NULL;
-GType player_item_get_type (void);
-GType title_menuitem_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType title_menuitem_get_type (void) G_GNUC_CONST;
enum {
TITLE_MENUITEM_DUMMY_PROPERTY
};
-GType player_controller_get_type (void);
+GType player_controller_get_type (void) G_GNUC_CONST;
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);
+GType mpris_controller_get_type (void) G_GNUC_CONST;
+GType player_controller_state_get_type (void) G_GNUC_CONST;
void player_controller_instantiate (PlayerController* self);
static void title_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
GeeHashSet* title_menuitem_attributes_format (void);
diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c
index bbe5a4d..50d166b 100644
--- a/src/transport-menu-item.c
+++ b/src/transport-menu-item.c
@@ -118,19 +118,19 @@ struct _PlayerControllerClass {
static gpointer transport_menuitem_parent_class = NULL;
-GType player_item_get_type (void);
-GType transport_menuitem_get_type (void);
+GType player_item_get_type (void) G_GNUC_CONST;
+GType transport_menuitem_get_type (void) G_GNUC_CONST;
enum {
TRANSPORT_MENUITEM_DUMMY_PROPERTY
};
-GType transport_menuitem_action_get_type (void);
-GType player_controller_get_type (void);
+GType transport_menuitem_action_get_type (void) G_GNUC_CONST;
+GType player_controller_get_type (void) G_GNUC_CONST;
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);
+GType mpris_controller_get_type (void) G_GNUC_CONST;
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);
GeeHashSet* transport_menuitem_attributes_format (void);
diff --git a/src/transport-widget.c b/src/transport-widget.c
index c616fff..702b472 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -118,8 +118,6 @@ transport_widget_finalize (GObject *object)
static gboolean
transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
{
- //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(widget);
- //gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event);
return TRUE;
}
@@ -152,8 +150,8 @@ transport_widget_button_press_event (GtkWidget *menuitem,
g_value_init(&value, G_TYPE_INT);
g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
g_value_set_int(&value, (int)result);
- dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
play_button_react_to_button_press(priv->play_button, result);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
}
return TRUE;
}
@@ -182,11 +180,14 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
g_debug("transport_widget_update_state - with property %s", property);
TransportWidget* bar = (TransportWidget*)userdata;
g_return_if_fail(IS_TRANSPORT_WIDGET(bar));
-
- TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
- int update_value = g_value_get_int(value);
- g_debug("transport_widget_update_state - with value %i", update_value);
- play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
+
+ if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0)
+ {
+ TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
+ int update_value = g_value_get_int(value);
+ g_debug("transport_widget_update_state - with value %i", update_value);
+ play_button_toggle_play_pause(priv->play_button, (PlayButtonState)update_value);
+ }
}
/**