diff options
Diffstat (limited to 'src/player-controller.c')
-rw-r--r-- | src/player-controller.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/src/player-controller.c b/src/player-controller.c index ab05cb3..3eee29a 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -118,6 +118,7 @@ struct _PlayerControllerClass { struct _PlayerControllerPrivate { DbusmenuMenuitem* root_menu; char* _name; + char* _mpris_name; GAppInfo* _app_info; gint _menu_offset; }; @@ -152,16 +153,18 @@ GType mpris2_controller_get_type (void) G_GNUC_CONST; enum { PLAYER_CONTROLLER_DUMMY_PROPERTY, PLAYER_CONTROLLER_NAME, + PLAYER_CONTROLLER_MPRIS_NAME, PLAYER_CONTROLLER_APP_INFO, PLAYER_CONTROLLER_MENU_OFFSET }; 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 4 -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); +PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state); 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_mpris_name (PlayerController* self, const char* value); 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); @@ -196,6 +199,7 @@ gint player_controller_get_menu_offset (PlayerController* self); gboolean mpris2_controller_connected (Mpris2Controller* self); GType transport_menuitem_state_get_type (void) G_GNUC_CONST; void transport_menuitem_change_play_state (TransportMenuitem* self, TransportMenuitemstate update); +const char* player_controller_get_mpris_name (PlayerController* self); void player_controller_set_app_info (PlayerController* self, GAppInfo* value); static void player_controller_finalize (GObject* obj); static void player_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); @@ -243,7 +247,7 @@ static char* string_strip (const char* self) { } -PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state) { +PlayerController* player_controller_construct (GType object_type, DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state) { PlayerController * self; DbusmenuMenuitem* _tmp0_; char* _tmp1_; @@ -251,11 +255,13 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit GeeArrayList* _tmp3_; g_return_val_if_fail (root != NULL, NULL); g_return_val_if_fail (client_name != NULL, NULL); + g_return_val_if_fail (mpris_name != NULL, NULL); self = (PlayerController*) g_object_new (object_type, NULL); self->priv->root_menu = (_tmp0_ = _g_object_ref0 (root), _g_object_unref0 (self->priv->root_menu), _tmp0_); player_controller_set_name (self, _tmp2_ = player_controller_format_client_name (_tmp1_ = string_strip (client_name))); _g_free0 (_tmp2_); _g_free0 (_tmp1_); + player_controller_set_mpris_name (self, mpris_name); 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_); self->current_state = (gint) initial_state; player_controller_set_menu_offset (self, offset); @@ -266,14 +272,14 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit } -PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, gint offset, PlayerControllerstate initial_state) { - return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, client_name, offset, initial_state); +PlayerController* player_controller_new (DbusmenuMenuitem* root, const char* client_name, const char* mpris_name, gint offset, PlayerControllerstate initial_state) { + return player_controller_construct (TYPE_PLAYER_CONTROLLER, root, client_name, mpris_name, offset, initial_state); } void player_controller_update_state (PlayerController* self, PlayerControllerstate new_state) { g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:69: update_state - player controller %s : new s" \ + g_debug ("player-controller.vala:72: 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); @@ -289,7 +295,7 @@ void player_controller_activate (PlayerController* self) { void player_controller_instantiate (PlayerController* self) { GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); - g_debug ("player-controller.vala:87: instantiate in player controller for %s", self->priv->_name); + g_debug ("player-controller.vala:90: 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) { @@ -304,7 +310,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:96: Failed to launch app %s with error message:" \ " %s", self->priv->_name, _error_->message); _g_error_free0 (_error_); } @@ -322,7 +328,7 @@ static void player_controller_establish_mpris_connection (PlayerController* self Mpris2Controller* _tmp0_; 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:103: establish_mpris_connection - Not ready to " \ "connect"); return; } @@ -482,7 +488,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, string_get_length (client_name)), NULL), _g_free0 (formatted), _tmp2_); _g_free0 (_tmp1_); _g_free0 (_tmp0_); - g_debug ("player-controller.vala:165: PlayerController->format_client_name - : %" \ + g_debug ("player-controller.vala:168: PlayerController->format_client_name - : %" \ "s", formatted); } result = formatted; @@ -526,6 +532,22 @@ void player_controller_set_name (PlayerController* self, const char* value) { } +const char* player_controller_get_mpris_name (PlayerController* self) { + const char* result; + g_return_val_if_fail (self != NULL, NULL); + result = self->priv->_mpris_name; + return result; +} + + +void player_controller_set_mpris_name (PlayerController* self, const char* value) { + char* _tmp0_; + g_return_if_fail (self != NULL); + self->priv->_mpris_name = (_tmp0_ = g_strdup (value), _g_free0 (self->priv->_mpris_name), _tmp0_); + g_object_notify ((GObject *) self, "mpris-name"); +} + + GAppInfo* player_controller_get_app_info (PlayerController* self) { GAppInfo* result; g_return_val_if_fail (self != NULL, NULL); @@ -564,6 +586,7 @@ static void player_controller_class_init (PlayerControllerClass * klass) { G_OBJECT_CLASS (klass)->set_property = player_controller_set_property; G_OBJECT_CLASS (klass)->finalize = player_controller_finalize; g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MPRIS_NAME, g_param_spec_string ("mpris-name", "mpris-name", "mpris-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_APP_INFO, g_param_spec_object ("app-info", "app-info", "app-info", G_TYPE_APP_INFO, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PLAYER_CONTROLLER_MENU_OFFSET, g_param_spec_int ("menu-offset", "menu-offset", "menu-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); } @@ -580,6 +603,7 @@ static void player_controller_finalize (GObject* obj) { self = PLAYER_CONTROLLER (obj); _g_object_unref0 (self->priv->root_menu); _g_free0 (self->priv->_name); + _g_free0 (self->priv->_mpris_name); _g_object_unref0 (self->custom_items); _g_object_unref0 (self->mpris_bridge); _g_object_unref0 (self->priv->_app_info); @@ -606,6 +630,9 @@ static void player_controller_get_property (GObject * object, guint property_id, case PLAYER_CONTROLLER_NAME: g_value_set_string (value, player_controller_get_name (self)); break; + case PLAYER_CONTROLLER_MPRIS_NAME: + g_value_set_string (value, player_controller_get_mpris_name (self)); + break; case PLAYER_CONTROLLER_APP_INFO: g_value_set_object (value, player_controller_get_app_info (self)); break; @@ -626,6 +653,9 @@ static void player_controller_set_property (GObject * object, guint property_id, case PLAYER_CONTROLLER_NAME: player_controller_set_name (self, g_value_get_string (value)); break; + case PLAYER_CONTROLLER_MPRIS_NAME: + player_controller_set_mpris_name (self, g_value_get_string (value)); + break; case PLAYER_CONTROLLER_APP_INFO: player_controller_set_app_info (self, g_value_get_object (value)); break; |