diff options
author | Sebastien Bacher <seb128@ubuntu.com> | 2010-08-18 15:51:01 +0200 |
---|---|---|
committer | Sebastien Bacher <seb128@ubuntu.com> | 2010-08-18 15:51:01 +0200 |
commit | b4d305f16bae6804dcf2acf8b9ecc4629807c150 (patch) | |
tree | defa24d440ac7380e17acdee738674022001f6e2 /src/player-controller.c | |
parent | 986fc648fc6544aaa3bb40a17e1345e0247a4b57 (diff) | |
download | ayatana-indicator-sound-b4d305f16bae6804dcf2acf8b9ecc4629807c150.tar.gz ayatana-indicator-sound-b4d305f16bae6804dcf2acf8b9ecc4629807c150.tar.bz2 ayatana-indicator-sound-b4d305f16bae6804dcf2acf8b9ecc4629807c150.zip |
Import upstream version 0.4.0
Diffstat (limited to 'src/player-controller.c')
-rw-r--r-- | src/player-controller.c | 194 |
1 files changed, 70 insertions, 124 deletions
diff --git a/src/player-controller.c b/src/player-controller.c index 55b097f..39189f3 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -1,4 +1,4 @@ -/* player-controller.c generated by valac, the Vala compiler +/* player-controller.c generated by valac 0.9.5, the Vala compiler * generated from player-controller.vala, do not modify */ /* @@ -54,15 +54,15 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate; typedef struct _PlayerItem PlayerItem; typedef struct _PlayerItemClass PlayerItemClass; -#define TYPE_MPRIS_CONTROLLER (mpris_controller_get_type ()) -#define MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CONTROLLER, MprisController)) -#define MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CONTROLLER, MprisControllerClass)) -#define IS_MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CONTROLLER)) -#define IS_MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CONTROLLER)) -#define MPRIS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CONTROLLER, MprisControllerClass)) +#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 _MprisController MprisController; -typedef struct _MprisControllerClass MprisControllerClass; +typedef struct _MprisBridge MprisBridge; +typedef struct _MprisBridgeClass MprisBridgeClass; #define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ()) @@ -116,7 +116,7 @@ struct _PlayerController { PlayerControllerPrivate * priv; gint current_state; GeeArrayList* custom_items; - MprisController* mpris_adaptor; + MprisBridge* mpris_bridge; }; struct _PlayerControllerClass { @@ -135,8 +135,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 { @@ -152,7 +151,7 @@ static gpointer player_controller_parent_class = NULL; GType player_controller_get_type (void) G_GNUC_CONST; GType player_item_get_type (void) G_GNUC_CONST; -GType mpris_controller_get_type (void) G_GNUC_CONST; +GType mpris_bridge_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, @@ -162,7 +161,7 @@ enum { }; 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 +#define PLAYER_CONTROLLER_WIDGET_QUANTITY 5 static char* player_controller_format_client_name (const char* client_name); void player_controller_set_name (PlayerController* self, const char* value); void player_controller_set_menu_offset (PlayerController* self, gint value); @@ -176,13 +175,16 @@ void player_controller_update_state (PlayerController* self, PlayerControllersta void player_controller_activate (PlayerController* self); GAppInfo* player_controller_get_app_info (PlayerController* self); void player_controller_instantiate (PlayerController* self); -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); +MprisBridge* mpris_bridge_new (PlayerController* ctrl); +MprisBridge* mpris_bridge_construct (GType object_type, PlayerController* ctrl); +void player_controller_determine_state (PlayerController* self); void player_controller_vanish (PlayerController* self); -gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); +void player_item_reset (PlayerItem* self, GeeHashSet* attrs); +GeeHashSet* transport_menuitem_attributes_format (void); GeeHashSet* metadata_menuitem_attributes_format (void); GeeHashSet* scrub_menuitem_attributes_format (void); +void player_controller_hibernate (PlayerController* self); +gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); PlayerItem* player_item_new (const char* type); PlayerItem* player_item_construct (GType object_type, const char* type); TitleMenuitem* title_menuitem_new (PlayerController* parent); @@ -197,20 +199,19 @@ 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) G_GNUC_CONST; -static PlayerItem* player_controller_create_playlist (PlayerController* self); gint player_controller_get_menu_offset (PlayerController* self); +gboolean mpris_bridge_connected (MprisBridge* self); void player_controller_set_app_info (PlayerController* self, GAppInfo* value); static void player_controller_finalize (GObject* obj); static void player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); static void player_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); -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"}, {PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST, "PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLIST", "playlist"}, {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"}, {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); @@ -277,7 +278,7 @@ PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* cli void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) { g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:69: update_state - player controller %s : new s" \ + g_debug ("player-controller.vala:67: 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); @@ -285,11 +286,8 @@ void player_controller_update_state (PlayerController* self, PlayerControllersta void player_controller_activate (PlayerController* self) { - PlayerItem* _tmp0_; g_return_if_fail (self != NULL); player_controller_establish_mpris_connection (self); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - _g_object_unref0 (_tmp0_); } @@ -297,7 +295,7 @@ void player_controller_instantiate (PlayerController* self) { GError * _inner_error_; g_return_if_fail (self != NULL); _inner_error_ = NULL; - g_debug ("player-controller.vala:88: instantiate in player controller for %s", self->priv->_name); + g_debug ("player-controller.vala:85: 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) { @@ -312,7 +310,7 @@ void player_controller_instantiate (PlayerController* self) { _error_ = _inner_error_; _inner_error_ = NULL; { - g_warning ("player-controller.vala:94: Failed to launch app %s with error message:" \ + g_warning ("player-controller.vala:91: Failed to launch app %s with error message:" \ " %s", self->priv->_name, _error_->message); _g_error_free0 (_error_); } @@ -327,26 +325,15 @@ void player_controller_instantiate (PlayerController* self) { static void player_controller_establish_mpris_connection (PlayerController* self) { + MprisBridge* _tmp0_; g_return_if_fail (self != NULL); if (self->current_state != PLAYER_CONTROLLER_STATE_READY) { - g_debug ("player-controller.vala:101: establish_mpris_connection - Not ready to " \ -"connect"); + g_debug ("player-controller.vala:98: establish_mpris_connection - Not ready to c" \ +"onnect"); return; } - if (_vala_strcmp0 (self->priv->_name, "Vlc") == 0) { - MprisController* _tmp0_; - 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:114: yup I'm connected"); - player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED); - } else { - player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED); - } + self->mpris_bridge = (_tmp0_ = mpris_bridge_new (self), _g_object_unref0 (self->mpris_bridge), _tmp0_); + player_controller_determine_state (self); } @@ -369,69 +356,58 @@ void player_controller_vanish (PlayerController* self) { } -static char* bool_to_string (gboolean self) { - char* result = NULL; - if (self) { - result = g_strdup ("true"); - return result; - } else { - result = g_strdup ("false"); - return result; - } +void player_controller_hibernate (PlayerController* self) { + GeeHashSet* _tmp1_; + PlayerItem* _tmp0_; + GeeHashSet* _tmp3_; + PlayerItem* _tmp2_; + GeeHashSet* _tmp5_; + PlayerItem* _tmp4_; + g_return_if_fail (self != NULL); + player_controller_update_state (self, PLAYER_CONTROLLER_STATE_OFFLINE); + player_item_reset (_tmp0_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT), _tmp1_ = transport_menuitem_attributes_format ()); + _g_object_unref0 (_tmp1_); + _g_object_unref0 (_tmp0_); + player_item_reset (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA), _tmp3_ = metadata_menuitem_attributes_format ()); + _g_object_unref0 (_tmp3_); + _g_object_unref0 (_tmp2_); + player_item_reset (_tmp4_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), _tmp5_ = scrub_menuitem_attributes_format ()); + _g_object_unref0 (_tmp5_); + _g_object_unref0 (_tmp4_); } void player_controller_update_layout (PlayerController* self) { - char* _tmp6_; GeeHashSet* _tmp5_; PlayerItem* _tmp4_; - GeeHashSet* _tmp9_; - PlayerItem* _tmp8_; + PlayerItem* _tmp3_; + GeeHashSet* _tmp8_; PlayerItem* _tmp7_; - char* _tmp12_; - GeeHashSet* _tmp11_; - PlayerItem* _tmp10_; - GeeHashSet* _tmp15_; - PlayerItem* _tmp14_; - PlayerItem* _tmp13_; - PlayerItem* _tmp16_; - PlayerItem* _tmp17_; + PlayerItem* _tmp6_; + PlayerItem* _tmp9_; g_return_if_fail (self != NULL); if (self->current_state != PLAYER_CONTROLLER_STATE_CONNECTED) { 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: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_); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp3_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, 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_object_unref0 (_tmp5_); _g_object_unref0 (_tmp4_); - 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 (_tmp3_); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp6_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB)), DBUSMENU_MENUITEM_PROP_VISIBLE, player_item_populated (_tmp7_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB), _tmp8_ = scrub_menuitem_attributes_format ())); _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_); + _g_object_unref0 (_tmp6_); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp9_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT)), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + _g_object_unref0 (_tmp9_); } @@ -441,7 +417,6 @@ 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_); @@ -453,8 +428,6 @@ 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); @@ -476,32 +449,6 @@ static void player_controller_construct_widgets (PlayerController* self) { } -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; -} - - static char* string_slice (const char* self, glong start, glong end) { char* result = NULL; glong string_length; @@ -547,7 +494,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:212: PlayerController->format_client_name - : %" \ + g_debug ("player-controller.vala:171: PlayerController->format_client_name - : %" \ "s", formatted); } result = formatted; @@ -555,6 +502,16 @@ static char* player_controller_format_client_name (const char* client_name) { } +void player_controller_determine_state (PlayerController* self) { + g_return_if_fail (self != NULL); + if (mpris_bridge_connected (self->mpris_bridge) == TRUE) { + player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED); + } else { + player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED); + } +} + + const char* player_controller_get_name (PlayerController* self) { const char* result; g_return_val_if_fail (self != NULL, NULL); @@ -626,7 +583,7 @@ static void player_controller_finalize (GObject* obj) { _g_object_unref0 (self->priv->root_menu); _g_free0 (self->priv->_name); _g_object_unref0 (self->custom_items); - _g_object_unref0 (self->mpris_adaptor); + _g_object_unref0 (self->mpris_bridge); _g_object_unref0 (self->priv->_app_info); G_OBJECT_CLASS (player_controller_parent_class)->finalize (obj); } @@ -684,16 +641,5 @@ static void player_controller_set_property (GObject * object, guint property_id, } -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); -} - - |