From b4d305f16bae6804dcf2acf8b9ecc4629807c150 Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Wed, 18 Aug 2010 15:51:01 +0200 Subject: Import upstream version 0.4.0 --- src/mpris-controller.c | 99 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 30 deletions(-) (limited to 'src/mpris-controller.c') diff --git a/src/mpris-controller.c b/src/mpris-controller.c index 14a462b..1f891f7 100644 --- a/src/mpris-controller.c +++ b/src/mpris-controller.c @@ -1,4 +1,4 @@ -/* mpris-controller.c generated by valac, the Vala compiler +/* mpris-controller.c generated by valac 0.9.5, the Vala compiler * generated from mpris-controller.vala, do not modify */ /* @@ -74,6 +74,16 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate; typedef struct _PlayerItem PlayerItem; typedef struct _PlayerItemClass PlayerItemClass; +#define TYPE_MPRIS_BRIDGE (mpris_bridge_get_type ()) +#define MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_BRIDGE, MprisBridge)) +#define MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_BRIDGE, MprisBridgeClass)) +#define IS_MPRIS_BRIDGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_BRIDGE)) +#define IS_MPRIS_BRIDGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_BRIDGE)) +#define MPRIS_BRIDGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_BRIDGE, MprisBridgeClass)) + +typedef struct _MprisBridge MprisBridge; +typedef struct _MprisBridgeClass MprisBridgeClass; + #define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ()) #define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ()) @@ -128,7 +138,7 @@ struct _PlayerController { PlayerControllerPrivate * priv; gint current_state; GeeArrayList* custom_items; - MprisController* mpris_adaptor; + MprisBridge* mpris_bridge; }; struct _PlayerControllerClass { @@ -140,8 +150,7 @@ 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_PLAYLIST + PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT } PlayerControllerwidget_order; typedef enum { @@ -171,6 +180,7 @@ static void mpris_controller_status_free (MprisControllerstatus* self); static void _dynamic_GetStatus0 (DBusGProxy* self, MprisControllerstatus* result, GError** error); PlayerController* mpris_controller_get_owner (MprisController* self); GType player_item_get_type (void) G_GNUC_CONST; +GType mpris_bridge_get_type (void) G_GNUC_CONST; GType player_controller_widget_order_get_type (void) G_GNUC_CONST; GType transport_menuitem_get_type (void) G_GNUC_CONST; void transport_menuitem_change_play_state (TransportMenuitem* self, gint state); @@ -197,8 +207,10 @@ gboolean mpris_controller_connected (MprisController* self); GeeHashSet* transport_menuitem_attributes_format (void); static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* mpris_client, MprisControllerstatus* st); void player_item_reset (PlayerItem* self, GeeHashSet* attrs); -static GHashTable* _dynamic_GetMetadata10 (DBusGProxy* self, GError** error); -static gint32 _dynamic_PositionGet11 (DBusGProxy* self, GError** error); +static void _dynamic_GetStatus10 (DBusGProxy* self, MprisControllerstatus* result, GError** error); +void scrub_menuitem_update_playstate (ScrubMenuitem* self, gint state); +static GHashTable* _dynamic_GetMetadata11 (DBusGProxy* self, GError** error); +static gint32 _dynamic_PositionGet12 (DBusGProxy* self, GError** error); static void mpris_controller_onTrackChange (MprisController* self, DBusGProxy* mpris_client, GHashTable* ht); static void mpris_controller_set_mpris_player (MprisController* self, DBusGProxy* value); static void mpris_controller_set_owner (MprisController* self, PlayerController* value); @@ -365,9 +377,9 @@ void mpris_controller_transport_event (MprisController* self, TransportMenuitema GError * _inner_error_; g_return_if_fail (self != NULL); _inner_error_ = NULL; - g_debug ("mpris-controller.vala:73: transport_event input = %i", (gint) command); + g_debug ("mpris-controller.vala:72: transport_event input = %i", (gint) command); if (command == TRANSPORT_MENUITEM_ACTION_PLAY_PAUSE) { - g_debug ("mpris-controller.vala:75: transport_event PLAY_PAUSE"); + g_debug ("mpris-controller.vala:74: transport_event PLAY_PAUSE"); _dynamic_Pause4 (self->priv->_mpris_player, &_inner_error_); if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -445,7 +457,7 @@ void mpris_controller_set_position (MprisController* self, double position) { gint32 _tmp1_; g_return_if_fail (self != NULL); _inner_error_ = NULL; - g_debug ("mpris-controller.vala:88: Set position with pos (0-100) %f", position); + g_debug ("mpris-controller.vala:87: Set position with pos (0-100) %f", position); data = _dynamic_GetMetadata7 (self->priv->_mpris_player, &_inner_error_); if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); @@ -454,16 +466,16 @@ void mpris_controller_set_position (MprisController* self, double position) { } time_value = __g_value_dup0 ((GValue*) g_hash_table_lookup (data, "time")); if (time_value == NULL) { - g_warning ("mpris-controller.vala:92: Can't fetch the duration of the track theref" \ + g_warning ("mpris-controller.vala:91: Can't fetch the duration of the track theref" \ "ore cant set the position"); _g_free0 (time_value); _g_hash_table_unref0 (data); return; } total_time = (guint32) g_value_get_uint (time_value); - g_debug ("mpris-controller.vala:96: total time of track = %i", (gint) total_time); + g_debug ("mpris-controller.vala:95: total time of track = %i", (gint) total_time); new_time_position = (total_time * position) / 100.0; - g_debug ("mpris-controller.vala:98: new position = %f", new_time_position * 1000); + g_debug ("mpris-controller.vala:97: new position = %f", new_time_position * 1000); _dynamic_PositionSet8 (self->priv->_mpris_player, (gint32) new_time_position, &_inner_error_); if (_inner_error_ != NULL) { _g_free0 (time_value); @@ -509,11 +521,11 @@ static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* PlayerItem* _tmp2_; g_return_if_fail (self != NULL); g_return_if_fail (mpris_client != NULL); - g_debug ("mpris-controller.vala:111: onStatusChange - signal received"); + g_debug ("mpris-controller.vala:110: onStatusChange - signal received"); status = st; ar = (GValueArray*) status; play_state = g_value_get_int (g_value_array_get_nth (ar, (guint) 0)); - g_debug ("mpris-controller.vala:115: onStatusChange - play state %i", play_state); + g_debug ("mpris-controller.vala:114: onStatusChange - play state %i", play_state); ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); g_value_init (&v, G_TYPE_INT); g_value_set_int (&v, play_state); @@ -529,7 +541,20 @@ static void mpris_controller_onStatusChange (MprisController* self, DBusGProxy* } -static GHashTable* _dynamic_GetMetadata10 (DBusGProxy* self, GError** error) { +static void _dynamic_GetStatus10 (DBusGProxy* self, MprisControllerstatus* result, GError** error) { + GValueArray* dbus_result; + dbus_g_proxy_call (self, "GetStatus", error, G_TYPE_INVALID, dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID), &dbus_result, G_TYPE_INVALID); + if (*error) { + return; + } + result->playback = g_value_get_int (&dbus_result->values[0]); + result->shuffle = g_value_get_int (&dbus_result->values[1]); + result->repeat = g_value_get_int (&dbus_result->values[2]); + result->endless = g_value_get_int (&dbus_result->values[3]); +} + + +static GHashTable* _dynamic_GetMetadata11 (DBusGProxy* self, GError** error) { GHashTable* result; dbus_g_proxy_call (self, "GetMetadata", error, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &result, G_TYPE_INVALID); if (*error) { @@ -539,7 +564,7 @@ static GHashTable* _dynamic_GetMetadata10 (DBusGProxy* self, GError** error) { } -static gint32 _dynamic_PositionGet11 (DBusGProxy* self, GError** error) { +static gint32 _dynamic_PositionGet12 (DBusGProxy* self, GError** error) { gint32 result; dbus_g_proxy_call (self, "PositionGet", error, G_TYPE_INVALID, G_TYPE_INT, &result, G_TYPE_INVALID); if (*error) { @@ -555,33 +580,43 @@ static void mpris_controller_onTrackChange (MprisController* self, DBusGProxy* m PlayerItem* _tmp0_; GeeHashSet* _tmp3_; PlayerItem* _tmp2_; - GeeHashSet* _tmp5_; - PlayerItem* _tmp4_; + MprisControllerstatus _tmp4_ = {0}; + MprisControllerstatus st; + gint play_state; + PlayerItem* _tmp5_; + ScrubMenuitem* scrub; GHashTable* _tmp6_; GeeHashSet* _tmp9_; GHashTable* _tmp8_; PlayerItem* _tmp7_; + GeeHashSet* _tmp11_; PlayerItem* _tmp10_; - ScrubMenuitem* scrub; - gint32 _tmp11_; + gint32 _tmp12_; g_return_if_fail (self != NULL); g_return_if_fail (mpris_client != NULL); g_return_if_fail (ht != NULL); _inner_error_ = NULL; - g_debug ("mpris-controller.vala:126: onTrackChange"); + g_debug ("mpris-controller.vala:125: onTrackChange"); player_item_reset (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp1_ = metadata_menuitem_attributes_format ()); _g_object_unref0 (_tmp1_); _g_object_unref0 (_tmp0_); player_item_reset (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), _tmp3_ = scrub_menuitem_attributes_format ()); _g_object_unref0 (_tmp3_); _g_object_unref0 (_tmp2_); - player_item_update (_tmp4_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), ht, _tmp5_ = metadata_menuitem_attributes_format ()); - _g_object_unref0 (_tmp5_); - _g_object_unref0 (_tmp4_); - g_debug ("mpris-controller.vala:131: about to update the duration on the scrub b" \ -"ar"); - _tmp6_ = _dynamic_GetMetadata10 (self->priv->_mpris_player, &_inner_error_); + st = (_dynamic_GetStatus10 (self->priv->_mpris_player, &_tmp4_, &_inner_error_), _tmp4_); + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return; + } + play_state = (gint) st.playback; + g_debug ("mpris-controller.vala:133: GetStatusChange, about to update scrub with" \ +" play state - %i", play_state); + scrub = (_tmp5_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), IS_SCRUB_MENUITEM (_tmp5_) ? ((ScrubMenuitem*) _tmp5_) : NULL); + scrub_menuitem_update_playstate (scrub, play_state); + _tmp6_ = _dynamic_GetMetadata11 (self->priv->_mpris_player, &_inner_error_); if (_inner_error_ != NULL) { + _g_object_unref0 (scrub); 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; @@ -590,15 +625,19 @@ static void mpris_controller_onTrackChange (MprisController* self, DBusGProxy* m _g_object_unref0 (_tmp9_); _g_hash_table_unref0 (_tmp8_); _g_object_unref0 (_tmp7_); - scrub = (_tmp10_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), IS_SCRUB_MENUITEM (_tmp10_) ? ((ScrubMenuitem*) _tmp10_) : NULL); - _tmp11_ = _dynamic_PositionGet11 (self->priv->_mpris_player, &_inner_error_); + player_item_update (_tmp10_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), ht, _tmp11_ = metadata_menuitem_attributes_format ()); + _g_object_unref0 (_tmp11_); + _g_object_unref0 (_tmp10_); + g_debug ("mpris-controller.vala:141: about to update the duration on the scrub b" \ +"ar"); + _tmp12_ = _dynamic_PositionGet12 (self->priv->_mpris_player, &_inner_error_); if (_inner_error_ != NULL) { _g_object_unref0 (scrub); 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, _tmp11_); + scrub_menuitem_update_position (scrub, _tmp12_); _g_object_unref0 (scrub); } -- cgit v1.2.3