aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-07-07 15:37:26 -0400
committerKen VanDine <ken.vandine@canonical.com>2011-07-07 15:37:26 -0400
commit4fe864d53eea581c95685e31a4372a83f87fce55 (patch)
treebea6d34e86a2f4f4dd91a2fac0f1c862c0069f81 /src
parentfbe33a6d8e37468d5f01c5747c9ccb1763208db6 (diff)
parent14f54b95128ac1d17d1c7aa8b2bcf46853fff3d5 (diff)
downloadayatana-indicator-sound-4fe864d53eea581c95685e31a4372a83f87fce55.tar.gz
ayatana-indicator-sound-4fe864d53eea581c95685e31a4372a83f87fce55.tar.bz2
ayatana-indicator-sound-4fe864d53eea581c95685e31a4372a83f87fce55.zip
Import upstream version 0.7.3
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in5
-rw-r--r--src/indicator-sound.c10
-rw-r--r--src/metadata-widget.c60
-rw-r--r--src/mpris2-controller.c291
-rw-r--r--src/mpris2-controller.vala78
-rw-r--r--src/player-item.c9
-rw-r--r--src/player-item.vala2
7 files changed, 194 insertions, 261 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 6ffa65e..4617dd3 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -39,10 +39,7 @@ libexec_PROGRAMS = indicator-sound-service$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index b8c0351..76bf710 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -72,8 +72,8 @@ static GtkLabel * get_label (IndicatorObject * io);
static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
static const gchar * get_accessible_desc (IndicatorObject * io);
-static void indicator_sound_scroll (IndicatorObject* io,
- gint delta,
+static void indicator_sound_scroll (IndicatorObject * io,
+ IndicatorObjectEntry * entry, gint delta,
IndicatorScrollDirection direction);
//key/moust event handlers
@@ -124,7 +124,7 @@ indicator_sound_class_init (IndicatorSoundClass *klass)
io_class->get_image = get_icon;
io_class->get_menu = get_menu;
io_class->get_accessible_desc = get_accessible_desc;
- io_class->scroll = indicator_sound_scroll;
+ io_class->entry_scrolled = indicator_sound_scroll;
}
static void
@@ -648,8 +648,8 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
}
static void
-indicator_sound_scroll (IndicatorObject *io, gint delta,
- IndicatorScrollDirection direction)
+indicator_sound_scroll (IndicatorObject * io, IndicatorObjectEntry * entry,
+ gint delta, IndicatorScrollDirection direction)
{
//g_debug("indicator-sound-scroll - current slider value");
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index d522358..d34f1fc 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -59,14 +59,6 @@ static void metadata_widget_finalize (GObject *object);
static void metadata_widget_set_style (GtkWidget* button, GtkStyle* style);
static void metadata_widget_set_twin_item (MetadataWidget* self,
DbusmenuMenuitem* twin_item);
-static void metadata_get_preferred_width (GtkWidget *widget,
- gint *minimal_width,
- gint *natural_width);
-static void metadata_get_preferred_height (GtkWidget *widget,
- gint *minimal_width,
- gint *natural_width);
-
-
// keyevent consumers
static gboolean metadata_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event);
@@ -85,7 +77,7 @@ static void metadata_widget_selection_received_event_callback( GtkWidget
guint time,
gpointer user_data);
-#if GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 0, 0)
static gboolean metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *image,
cairo_t* cr,
gpointer user_data);
@@ -115,36 +107,12 @@ metadata_widget_class_init (MetadataWidgetClass *klass)
widget_class->button_release_event = metadata_widget_button_release_event;
- #if GTK_CHECK_VERSION(3, 0, 0)
- widget_class->get_preferred_width = metadata_get_preferred_width;
- widget_class->get_preferred_height = metadata_get_preferred_height;
- #endif
g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate));
gobject_class->dispose = metadata_widget_dispose;
gobject_class->finalize = metadata_widget_finalize;
}
-#if GTK_CHECK_VERSION(3, 0, 0)
-static void
-metadata_get_preferred_width (GtkWidget *widget,
- gint *minimal_width,
- gint *natural_width)
-{
- *minimal_width = *natural_width = 200;
-}
-
-static void
-metadata_get_preferred_height (GtkWidget *widget,
- gint *minimal_height,
- gint *natural_height)
-{
- //MetadataWidget* self = METADATA_WIDGET (widget);
- //MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
- *minimal_height = *natural_height = 95;//priv->current_height;
-}
-#endif
-
static void
metadata_widget_init (MetadataWidget *self)
{
@@ -712,10 +680,7 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){
g_string_erase(priv->image_path, 0, -1);
g_string_overwrite(priv->image_path, 0, g_variant_get_string (value, NULL));
- // if its a remote image queue a redraw incase the download took too long
- //if (g_str_has_prefix(g_variant_get_string (value, NULL), g_get_user_cache_dir())){
gtk_widget_queue_draw(GTK_WIDGET(mitem));
- //}
}
else if (g_ascii_strcasecmp (DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, property) == 0){
gtk_label_set_label (GTK_LABEL (priv->player_label),
@@ -733,34 +698,13 @@ static void
metadata_widget_handle_resizing (MetadataWidget* self)
{
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
-
- g_debug ("SHOW/HIDE TRACK DETAILS - %i", dbusmenu_menuitem_property_get_bool (priv->twin_item, DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS));
-
+
if (dbusmenu_menuitem_property_get_bool (priv->twin_item,
DBUSMENU_METADATA_MENUITEM_HIDE_TRACK_DETAILS) == TRUE){
- // TODO
- // revert to hide
- #if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_show (priv->meta_data_h_box);
- #else
gtk_widget_hide (priv->meta_data_h_box);
- gtk_widget_hide (priv->artist_label);
- gtk_widget_hide (priv->piece_label);
- gtk_widget_hide (priv->container_label);
- gtk_widget_hide (priv->album_art);
- gtk_widget_hide (priv->meta_data_v_box);
- #endif
}
else{
- #if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_show (priv->meta_data_h_box);
- #else
gtk_widget_show (priv->meta_data_h_box);
- gtk_widget_show (priv->artist_label);
- gtk_widget_show (priv->piece_label);
- gtk_widget_show (priv->container_label);
- gtk_widget_show (priv->album_art);
- #endif
}
gtk_widget_queue_draw(GTK_WIDGET(self));
}
diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c
index 0905795..8b3ad14 100644
--- a/src/mpris2-controller.c
+++ b/src/mpris2-controller.c
@@ -137,8 +137,8 @@ typedef struct _TransportMenuitemClass TransportMenuitemClass;
typedef struct _MetadataMenuitem MetadataMenuitem;
typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
-#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
+#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define TYPE_PLAYLISTS_MENUITEM (playlists_menuitem_get_type ())
#define PLAYLISTS_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYLISTS_MENUITEM, PlaylistsMenuitem))
@@ -327,21 +327,23 @@ 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, TransportState update);
-static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self);
-void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
-GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void);
-void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
-GType metadata_menuitem_get_type (void) G_GNUC_CONST;
-gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
-void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse);
+static gboolean mpris2_controller_ensure_correct_metadata (Mpris2Controller* self);
+static gboolean _mpris2_controller_ensure_correct_metadata_gsource_func (gpointer self);
static gboolean _bool_equal (const gboolean* s1, const gboolean* s2);
static gboolean mpris2_controller_fetch_active_playlist (Mpris2Controller* self);
static gboolean _mpris2_controller_fetch_active_playlist_gsource_func (gpointer self);
void mpris2_controller_fetch_playlists (Mpris2Controller* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void mpris2_controller_fetch_playlists_finish (Mpris2Controller* self, GAsyncResult* _res_);
+GType metadata_menuitem_get_type (void) G_GNUC_CONST;
void metadata_menuitem_alter_label (MetadataMenuitem* self, const gchar* new_title);
MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self);
gchar* mpris_root_get_Identity (MprisRoot* self);
+static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self);
+void player_item_reset (PlayerItem* self, GeeHashSet* attrs);
+GeeHashSet* metadata_menuitem_relevant_attributes_for_ui (void);
+void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attributes);
+gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs);
+void metadata_menuitem_should_collapse (MetadataMenuitem* self, gboolean collapse);
GHashTable* mpris_player_get_Metadata (MprisPlayer* self);
static GVariant* _variant_new1 (const gchar* value);
void mpris2_controller_initial_update (Mpris2Controller* self);
@@ -418,19 +420,10 @@ static gboolean _mpris2_controller_ensure_correct_playback_status_gsource_func (
}
-static gchar* bool_to_string (gboolean self) {
- gchar* result = NULL;
- if (self) {
- gchar* _tmp0_;
- _tmp0_ = g_strdup ("true");
- result = _tmp0_;
- return result;
- } else {
- gchar* _tmp1_;
- _tmp1_ = g_strdup ("false");
- result = _tmp1_;
- return result;
- }
+static gboolean _mpris2_controller_ensure_correct_metadata_gsource_func (gpointer self) {
+ gboolean result;
+ result = mpris2_controller_ensure_correct_metadata (self);
+ return result;
}
@@ -463,20 +456,20 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
gconstpointer _tmp9_ = NULL;
GVariant* _tmp10_;
GVariant* meta_v;
- gconstpointer _tmp25_ = NULL;
- GVariant* _tmp26_;
+ gconstpointer _tmp11_ = NULL;
+ GVariant* _tmp12_;
GVariant* playlist_v;
- gboolean _tmp27_ = FALSE;
- gconstpointer _tmp29_ = NULL;
- GVariant* _tmp30_;
+ gboolean _tmp13_ = FALSE;
+ gconstpointer _tmp15_ = NULL;
+ GVariant* _tmp16_;
GVariant* playlist_count_v;
- gboolean _tmp31_ = FALSE;
- gconstpointer _tmp33_ = NULL;
- GVariant* _tmp34_;
+ gboolean _tmp17_ = FALSE;
+ gconstpointer _tmp19_ = NULL;
+ GVariant* _tmp20_;
GVariant* playlist_orderings_v;
- gboolean _tmp35_ = FALSE;
- gconstpointer _tmp37_ = NULL;
- GVariant* _tmp38_;
+ gboolean _tmp21_ = FALSE;
+ gconstpointer _tmp23_ = NULL;
+ GVariant* _tmp24_;
GVariant* identity_v;
g_return_if_fail (self != NULL);
g_return_if_fail (interface_source != NULL);
@@ -489,7 +482,7 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
_tmp0_ = _tmp1_ == FALSE;
}
if (_tmp0_) {
- g_warning ("mpris2-controller.vala:71: Property-changed hash is null or this is an" \
+ g_warning ("mpris2-controller.vala:77: Property-changed hash is null or this is an" \
" interface that doesn't concern us");
return;
}
@@ -520,111 +513,65 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
_tmp10_ = _g_variant_ref0 ((GVariant*) _tmp9_);
meta_v = _tmp10_;
if (meta_v != NULL) {
- GHashTable* _tmp11_ = NULL;
- GHashTable* changed_updates;
- gpointer _tmp12_ = NULL;
- PlayerItem* metadata;
- GeeHashSet* _tmp13_ = NULL;
- GeeHashSet* _tmp14_;
- GeeHashSet* _tmp15_ = NULL;
- GeeHashSet* _tmp16_;
- gpointer _tmp17_ = NULL;
- PlayerItem* _tmp18_;
- MetadataMenuitem* md;
- GeeHashSet* _tmp19_ = NULL;
- GeeHashSet* _tmp20_;
- gboolean _tmp21_;
- gboolean _tmp22_;
- gboolean collapsing;
- gchar* _tmp23_ = NULL;
- gchar* _tmp24_;
- _tmp11_ = mpris2_controller_clean_metadata (self);
- changed_updates = _tmp11_;
- _tmp12_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
- metadata = (PlayerItem*) _tmp12_;
- _tmp13_ = metadata_menuitem_relevant_attributes_for_ui ();
- _tmp14_ = _tmp13_;
- player_item_reset (metadata, _tmp14_);
- _g_object_unref0 (_tmp14_);
- _tmp15_ = metadata_menuitem_relevant_attributes_for_ui ();
- _tmp16_ = _tmp15_;
- player_item_update (metadata, changed_updates, _tmp16_);
- _g_object_unref0 (_tmp16_);
- _tmp17_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
- _tmp18_ = (PlayerItem*) _tmp17_;
- md = IS_METADATA_MENUITEM (_tmp18_) ? ((MetadataMenuitem*) _tmp18_) : NULL;
- _tmp19_ = metadata_menuitem_relevant_attributes_for_ui ();
- _tmp20_ = _tmp19_;
- _tmp21_ = player_item_populated (metadata, _tmp20_);
- _tmp22_ = !_tmp21_;
- _g_object_unref0 (_tmp20_);
- collapsing = _tmp22_;
- metadata_menuitem_should_collapse (md, collapsing);
- _tmp23_ = bool_to_string (collapsing);
- _tmp24_ = _tmp23_;
- g_debug ("mpris2-controller.vala:95: Should metadata collapse %s", _tmp24_);
- _g_free0 (_tmp24_);
- _g_object_unref0 (md);
- _g_object_unref0 (metadata);
- _g_hash_table_unref0 (changed_updates);
+ g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 200, _mpris2_controller_ensure_correct_metadata_gsource_func, g_object_ref (self), g_object_unref);
}
- _tmp25_ = g_hash_table_lookup (changed_properties, "ActivePlaylist");
- _tmp26_ = _g_variant_ref0 ((GVariant*) _tmp25_);
- playlist_v = _tmp26_;
+ _tmp11_ = g_hash_table_lookup (changed_properties, "ActivePlaylist");
+ _tmp12_ = _g_variant_ref0 ((GVariant*) _tmp11_);
+ playlist_v = _tmp12_;
if (playlist_v != NULL) {
- gboolean _tmp28_;
- _tmp28_ = TRUE;
- _tmp27_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp28_) == TRUE;
+ gboolean _tmp14_;
+ _tmp14_ = TRUE;
+ _tmp13_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp14_) == TRUE;
} else {
- _tmp27_ = FALSE;
+ _tmp13_ = FALSE;
}
- if (_tmp27_) {
+ if (_tmp13_) {
g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 300, _mpris2_controller_fetch_active_playlist_gsource_func, g_object_ref (self), g_object_unref);
}
- _tmp29_ = g_hash_table_lookup (changed_properties, "PlaylistCount");
- _tmp30_ = _g_variant_ref0 ((GVariant*) _tmp29_);
- playlist_count_v = _tmp30_;
+ _tmp15_ = g_hash_table_lookup (changed_properties, "PlaylistCount");
+ _tmp16_ = _g_variant_ref0 ((GVariant*) _tmp15_);
+ playlist_count_v = _tmp16_;
if (playlist_count_v != NULL) {
- gboolean _tmp32_;
- _tmp32_ = TRUE;
- _tmp31_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp32_) == TRUE;
+ gboolean _tmp18_;
+ _tmp18_ = TRUE;
+ _tmp17_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp18_) == TRUE;
} else {
- _tmp31_ = FALSE;
+ _tmp17_ = FALSE;
}
- if (_tmp31_) {
+ if (_tmp17_) {
mpris2_controller_fetch_playlists (self, NULL, NULL);
mpris2_controller_fetch_active_playlist (self);
}
- _tmp33_ = g_hash_table_lookup (changed_properties, "Orderings");
- _tmp34_ = _g_variant_ref0 ((GVariant*) _tmp33_);
- playlist_orderings_v = _tmp34_;
+ _tmp19_ = g_hash_table_lookup (changed_properties, "Orderings");
+ _tmp20_ = _g_variant_ref0 ((GVariant*) _tmp19_);
+ playlist_orderings_v = _tmp20_;
if (playlist_orderings_v != NULL) {
- gboolean _tmp36_;
- _tmp36_ = TRUE;
- _tmp35_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp36_) == TRUE;
+ gboolean _tmp22_;
+ _tmp22_ = TRUE;
+ _tmp21_ = _bool_equal (self->priv->_owner->use_playlists, &_tmp22_) == TRUE;
} else {
- _tmp35_ = FALSE;
+ _tmp21_ = FALSE;
}
- if (_tmp35_) {
+ if (_tmp21_) {
mpris2_controller_fetch_playlists (self, NULL, NULL);
mpris2_controller_fetch_active_playlist (self);
}
- _tmp37_ = g_hash_table_lookup (changed_properties, "Identity");
- _tmp38_ = _g_variant_ref0 ((GVariant*) _tmp37_);
- identity_v = _tmp38_;
+ _tmp23_ = g_hash_table_lookup (changed_properties, "Identity");
+ _tmp24_ = _g_variant_ref0 ((GVariant*) _tmp23_);
+ identity_v = _tmp24_;
if (identity_v != NULL) {
- gpointer _tmp39_ = NULL;
- PlayerItem* _tmp40_;
+ gpointer _tmp25_ = NULL;
+ PlayerItem* _tmp26_;
MetadataMenuitem* md;
- gchar* _tmp41_ = NULL;
- gchar* _tmp42_;
- _tmp39_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
- _tmp40_ = (PlayerItem*) _tmp39_;
- md = IS_METADATA_MENUITEM (_tmp40_) ? ((MetadataMenuitem*) _tmp40_) : NULL;
- _tmp41_ = mpris_root_get_Identity (self->priv->_mpris2_root);
- _tmp42_ = _tmp41_;
- metadata_menuitem_alter_label (md, _tmp42_);
- _g_free0 (_tmp42_);
+ gchar* _tmp27_ = NULL;
+ gchar* _tmp28_;
+ _tmp25_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
+ _tmp26_ = (PlayerItem*) _tmp25_;
+ md = IS_METADATA_MENUITEM (_tmp26_) ? ((MetadataMenuitem*) _tmp26_) : NULL;
+ _tmp27_ = mpris_root_get_Identity (self->priv->_mpris2_root);
+ _tmp28_ = _tmp27_;
+ metadata_menuitem_alter_label (md, _tmp28_);
+ _g_free0 (_tmp28_);
_g_object_unref0 (md);
}
_g_variant_unref0 (identity_v);
@@ -636,6 +583,55 @@ void mpris2_controller_property_changed_cb (Mpris2Controller* self, const gchar*
}
+static gboolean mpris2_controller_ensure_correct_metadata (Mpris2Controller* self) {
+ gboolean result = FALSE;
+ GHashTable* _tmp0_ = NULL;
+ GHashTable* changed_updates;
+ gpointer _tmp1_ = NULL;
+ PlayerItem* metadata;
+ GeeHashSet* _tmp2_ = NULL;
+ GeeHashSet* _tmp3_;
+ GeeHashSet* _tmp4_ = NULL;
+ GeeHashSet* _tmp5_;
+ gpointer _tmp6_ = NULL;
+ PlayerItem* _tmp7_;
+ MetadataMenuitem* md;
+ GeeHashSet* _tmp8_ = NULL;
+ GeeHashSet* _tmp9_;
+ gboolean _tmp10_;
+ gboolean _tmp11_;
+ gboolean collapsing;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0_ = mpris2_controller_clean_metadata (self);
+ changed_updates = _tmp0_;
+ _tmp1_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
+ metadata = (PlayerItem*) _tmp1_;
+ _tmp2_ = metadata_menuitem_relevant_attributes_for_ui ();
+ _tmp3_ = _tmp2_;
+ player_item_reset (metadata, _tmp3_);
+ _g_object_unref0 (_tmp3_);
+ _tmp4_ = metadata_menuitem_relevant_attributes_for_ui ();
+ _tmp5_ = _tmp4_;
+ player_item_update (metadata, changed_updates, _tmp5_);
+ _g_object_unref0 (_tmp5_);
+ _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA);
+ _tmp7_ = (PlayerItem*) _tmp6_;
+ md = IS_METADATA_MENUITEM (_tmp7_) ? ((MetadataMenuitem*) _tmp7_) : NULL;
+ _tmp8_ = metadata_menuitem_relevant_attributes_for_ui ();
+ _tmp9_ = _tmp8_;
+ _tmp10_ = player_item_populated (metadata, _tmp9_);
+ _tmp11_ = !_tmp10_;
+ _g_object_unref0 (_tmp9_);
+ collapsing = _tmp11_;
+ metadata_menuitem_should_collapse (md, collapsing);
+ result = FALSE;
+ _g_object_unref0 (md);
+ _g_object_unref0 (metadata);
+ _g_hash_table_unref0 (changed_updates);
+ return result;
+}
+
+
static gboolean mpris2_controller_ensure_correct_playback_status (Mpris2Controller* self) {
gboolean result = FALSE;
gchar* _tmp0_ = NULL;
@@ -689,50 +685,36 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) {
_g_hash_table_unref0 (_tmp2_);
artist_v = _tmp5_;
if (artist_v != NULL) {
- GHashTable* _tmp6_ = NULL;
- GHashTable* _tmp7_;
- gconstpointer _tmp8_ = NULL;
- GVariant* _tmp9_;
- GVariant* _tmp10_;
- GVariant* v_artists;
gchar* display_artists = NULL;
- const gchar* _tmp11_ = NULL;
- gchar* _tmp17_;
- _tmp6_ = mpris_player_get_Metadata (self->priv->_player);
- _tmp7_ = _tmp6_;
- _tmp8_ = g_hash_table_lookup (_tmp7_, "xesam:artist");
- _tmp9_ = _g_variant_ref0 ((GVariant*) _tmp8_);
- _tmp10_ = _tmp9_;
- _g_hash_table_unref0 (_tmp7_);
- v_artists = _tmp10_;
- _tmp11_ = g_variant_get_type_string (v_artists);
- if (g_strcmp0 (_tmp11_, "s") == 0) {
- const gchar* _tmp12_ = NULL;
- gchar* _tmp13_;
- _tmp12_ = g_variant_get_string (v_artists, NULL);
- _tmp13_ = g_strdup (_tmp12_);
+ const gchar* _tmp6_ = NULL;
+ gchar* _tmp12_;
+ _tmp6_ = g_variant_get_type_string (artist_v);
+ if (g_strcmp0 (_tmp6_, "s") == 0) {
+ const gchar* _tmp7_ = NULL;
+ gchar* _tmp8_;
+ _tmp7_ = g_variant_get_string (artist_v, NULL);
+ _tmp8_ = g_strdup (_tmp7_);
_g_free0 (display_artists);
- display_artists = _tmp13_;
+ display_artists = _tmp8_;
} else {
- size_t _tmp14_;
- gchar** _tmp15_ = NULL;
+ size_t _tmp9_;
+ gchar** _tmp10_ = NULL;
gchar** artists;
gint artists_length1;
gint _artists_size_;
- gchar* _tmp16_ = NULL;
- _tmp15_ = g_variant_dup_strv (v_artists, &_tmp14_);
- artists = _tmp15_;
- artists_length1 = _tmp14_;
- _artists_size_ = _tmp14_;
- _tmp16_ = g_strjoinv (", ", artists);
+ gchar* _tmp11_ = NULL;
+ _tmp10_ = g_variant_dup_strv (artist_v, &_tmp9_);
+ artists = _tmp10_;
+ artists_length1 = _tmp9_;
+ _artists_size_ = _tmp9_;
+ _tmp11_ = g_strjoinv (", ", artists);
_g_free0 (display_artists);
- display_artists = _tmp16_;
+ display_artists = _tmp11_;
artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL);
}
- _tmp17_ = g_strdup ("xesam:artist");
- g_hash_table_replace (changed_updates, _tmp17_, _variant_new1 (display_artists));
+ _tmp12_ = g_strdup ("xesam:artist");
+ g_hash_table_replace (changed_updates, _tmp12_, _variant_new1 (display_artists));
_g_free0 (display_artists);
- _g_variant_unref0 (v_artists);
}
result = changed_updates;
_g_variant_unref0 (artist_v);
@@ -1023,7 +1005,7 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl
playlists_menuitem_update (data->playlists_item, data->current_playlists, data->current_playlists_length1);
_g_object_unref0 (data->playlists_item);
} else {
- g_warning ("mpris2-controller.vala:243: Playlists are on but its returning no cur" \
+ g_warning ("mpris2-controller.vala:242: Playlists are on but its returning no cur" \
"rent_playlists");
data->_tmp5_ = FALSE;
data->_tmp6_ = __bool_dup0 (&data->_tmp5_);
@@ -1082,6 +1064,7 @@ void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* pa
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
+ g_warning ("mpris2-controller.vala:264: Could not activate playlist %s because %s", (const gchar*) path, e->message);
_g_error_free0 (e);
}
__finally12:
@@ -1279,7 +1262,7 @@ static GObject * mpris2_controller_constructor (GType type, guint n_construct_pr
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
- g_critical ("mpris2-controller.vala:60: Problems connecting to the session bus - %s", e->message);
+ g_critical ("mpris2-controller.vala:56: Problems connecting to the session bus - %s", e->message);
_g_error_free0 (e);
}
__finally13:
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 2975066..8eeac08 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -19,10 +19,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
using Dbusmenu;
using Transport;
-/*
- This class will entirely replace mpris-controller.vala hence why there is no
- point in trying to get encorporate both into the same object model.
- */
public class Mpris2Controller : GLib.Object
{
public MprisRoot mpris2_root {get; construct;}
@@ -60,12 +56,22 @@ public class Mpris2Controller : GLib.Object
critical("Problems connecting to the session bus - %s", e.message);
}
}
-
+ /*
+ * property_changed_cb
+ * Called when a property changed signal is emitted from any of mpris
+ * objects on the bus.
+ * Note that the signal will be received by each instance for each player
+ * and at that moment there is no way to know what player that signal
+ * came from therefore it is necessary to query each relevant property
+ * to update the respective dbusmenuitem property inorder to keep the UI in sync
+ * Please also note due to some race condition in the depths of gdbus
+ * a timeout is needed between receiving the prop update and query the respective property.
+ * This can be seen at various points below.
+ */
public void property_changed_cb ( string interface_source,
HashTable<string, Variant?> changed_properties,
string[] invalid )
{
- //debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name);
if ( changed_properties == null ||
interface_source.has_prefix ( MPRIS_PREFIX ) == false ){
warning("Property-changed hash is null or this is an interface that doesn't concern us");
@@ -73,31 +79,18 @@ public class Mpris2Controller : GLib.Object
}
Variant? play_v = changed_properties.lookup("PlaybackStatus");
if(play_v != null){
- // Race condition sometimes appears with the playback status
- // 200ms timeout ensures we have the correct playback status at all times.
string state = this.player.PlaybackStatus;
- //debug("in the property update and the playback status = %s and update = %s", state, (string)play_v);
Timeout.add ( 200, ensure_correct_playback_status );
Transport.State p = (Transport.State)this.determine_play_state(state);
(this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
}
Variant? meta_v = changed_properties.lookup("Metadata");
- if(meta_v != null){
- GLib.HashTable<string, Variant?> changed_updates = clean_metadata();
- PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA];
- metadata.reset (MetadataMenuitem.relevant_attributes_for_ui());
- metadata.update ( changed_updates,
- MetadataMenuitem.relevant_attributes_for_ui());
- MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem;
- bool collapsing = !metadata.populated(MetadataMenuitem.relevant_attributes_for_ui());
- md.should_collapse(collapsing);
-
- debug ("Should metadata collapse %s", collapsing.to_string());
+ if(meta_v != null)
+ {
+ Timeout.add ( 200, ensure_correct_metadata );
}
Variant? playlist_v = changed_properties.lookup("ActivePlaylist");
if ( playlist_v != null && this.owner.use_playlists == true ){
- // Once again A GDBus race condition, the property_changed signal is sent
- // before the value is set on the respective property.
Timeout.add (300, this.fetch_active_playlist);
}
Variant? playlist_count_v = changed_properties.lookup("PlaylistCount");
@@ -116,9 +109,23 @@ public class Mpris2Controller : GLib.Object
md.alter_label (this.mpris2_root.Identity);
}
}
-
- private bool ensure_correct_playback_status(){
- //debug("TEST playback status = %s", this.player.PlaybackStatus);
+
+ private bool ensure_correct_metadata ()
+ {
+ GLib.HashTable<string, Variant?> changed_updates = clean_metadata();
+ PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA];
+ metadata.reset (MetadataMenuitem.relevant_attributes_for_ui());
+ metadata.update ( changed_updates,
+ MetadataMenuitem.relevant_attributes_for_ui());
+ MetadataMenuitem md = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem;
+ bool collapsing = !metadata.populated(MetadataMenuitem.relevant_attributes_for_ui());
+ md.should_collapse(collapsing);
+
+ return false;
+ }
+
+ private bool ensure_correct_playback_status()
+ {
Transport.State p = (Transport.State)this.determine_play_state(this.player.PlaybackStatus);
(this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
return false;
@@ -130,19 +137,16 @@ public class Mpris2Controller : GLib.Object
Variant? artist_v = this.player.Metadata.lookup("xesam:artist");
if(artist_v != null){
- Variant? v_artists = this.player.Metadata.lookup("xesam:artist");
- //debug("artists is of type %s", v_artists.get_type_string ());
string display_artists;
- if(v_artists.get_type_string() == "s"){
- //debug("SPOTIFY is that you ?");
- display_artists = v_artists.get_string();
+ // Accomodate Spotify (should return 'as' and not 's')
+ if(artist_v.get_type_string() == "s"){
+ display_artists = artist_v.get_string();
}
else{
- string[] artists = v_artists.dup_strv();
+ string[] artists = artist_v.dup_strv();
display_artists = string.joinv(", ", artists);
}
changed_updates.replace("xesam:artist", display_artists);
- //debug("artist : %s", (string)changed_updates.lookup("xesam:artist"));
}
return changed_updates;
}
@@ -181,7 +185,6 @@ public class Mpris2Controller : GLib.Object
public void transport_update(Transport.Action command)
{
- //debug("transport_event input = %i", (int)command);
if(command == Transport.Action.PLAY_PAUSE){
this.player.PlayPause.begin();
}
@@ -192,11 +195,9 @@ public class Mpris2Controller : GLib.Object
this.player.Next.begin();
}
else if(command == Transport.Action.REWIND){
- //debug("transport_event rewind = %i", (int)command);
this.player.Seek.begin(-500000);
}
else if(command == Transport.Action.FORWIND){
- //debug("transport_event input = %i", (int)command);
this.player.Seek.begin(400000);
}
}
@@ -230,12 +231,10 @@ public class Mpris2Controller : GLib.Object
false);
}
catch (IOError e){
- //debug("Could not fetch playlists because %s", e.message);
return;
}
if( current_playlists != null ){
- //debug( "Size of the playlist array = %i", current_playlists.length );
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.update(current_playlists);
}
@@ -248,7 +247,8 @@ public class Mpris2Controller : GLib.Object
private bool fetch_active_playlist()
{
if (this.playlists.ActivePlaylist.valid == false){
- //debug(" We don't have an active playlist");
+ // TODO
+ // What happens here ?
}
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details );
@@ -261,7 +261,7 @@ public class Mpris2Controller : GLib.Object
this.playlists.ActivatePlaylist.begin(path);
}
catch(IOError e){
- //debug("Could not activate playlist %s because %s", (string)path, e.message);
+ warning ("Could not activate playlist %s because %s", (string)path, e.message);
}
}
}
diff --git a/src/player-item.c b/src/player-item.c
index 3c9cbeb..89c291d 100644
--- a/src/player-item.c
+++ b/src/player-item.c
@@ -56,6 +56,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_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define TYPE_METADATA_MENUITEM (metadata_menuitem_get_type ())
#define METADATA_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_METADATA_MENUITEM, MetadataMenuitem))
@@ -66,7 +67,6 @@ typedef struct _PlayerControllerClass PlayerControllerClass;
typedef struct _MetadataMenuitem MetadataMenuitem;
typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
-#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
@@ -237,6 +237,13 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu
_tmp6_ = g_hash_table_lookup (data, search_key);
_tmp7_ = _g_variant_ref0 ((GVariant*) _tmp6_);
v = _tmp7_;
+ if (v == NULL) {
+ _g_variant_unref0 (v);
+ _g_free0 (search_key);
+ input_keys = (_vala_array_free (input_keys, input_keys_length1, (GDestroyNotify) g_free), NULL);
+ _g_free0 (property);
+ continue;
+ }
_tmp8_ = g_variant_is_of_type (v, G_VARIANT_TYPE_STRING);
if (_tmp8_) {
const gchar* _tmp9_ = NULL;
diff --git a/src/player-item.vala b/src/player-item.vala
index 162dbea..7867653 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -61,6 +61,8 @@ public class PlayerItem : Dbusmenu.Menuitem
//debug("search key = %s", search_key);
Variant? v = data.lookup(search_key);
+ if (v == null) continue;
+
if (v.is_of_type ( VariantType.STRING )){
string update = v.get_string().strip();
//debug("with value : %s", update);