aboutsummaryrefslogtreecommitdiff
path: root/src/player-controller.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/player-controller.c')
-rw-r--r--src/player-controller.c112
1 files changed, 79 insertions, 33 deletions
diff --git a/src/player-controller.c b/src/player-controller.c
index ca1485e..acb2da2 100644
--- a/src/player-controller.c
+++ b/src/player-controller.c
@@ -64,11 +64,23 @@ typedef struct _PlayerItemClass PlayerItemClass;
typedef struct _MprisController MprisController;
typedef struct _MprisControllerClass MprisControllerClass;
+#define PLAYER_CONTROLLER_TYPE_WIDGET_ORDER (player_controller_widget_order_get_type ())
+
#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ())
#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_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))
@@ -79,15 +91,15 @@ typedef struct _MprisControllerClass MprisControllerClass;
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))
+#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))
+#define IS_SCRUB_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SCRUB_MENUITEM))
+#define IS_SCRUB_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SCRUB_MENUITEM))
+#define SCRUB_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SCRUB_MENUITEM, ScrubMenuitemClass))
-typedef struct _MetadataMenuitem MetadataMenuitem;
-typedef struct _MetadataMenuitemClass MetadataMenuitemClass;
+typedef struct _ScrubMenuitem ScrubMenuitem;
+typedef struct _ScrubMenuitemClass ScrubMenuitemClass;
#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ())
#define TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitem))
@@ -119,6 +131,14 @@ struct _PlayerControllerPrivate {
};
typedef enum {
+ PLAYER_CONTROLLER_WIDGET_ORDER_SEPARATOR,
+ PLAYER_CONTROLLER_WIDGET_ORDER_TITLE,
+ PLAYER_CONTROLLER_WIDGET_ORDER_METADATA,
+ PLAYER_CONTROLLER_WIDGET_ORDER_SCRUB,
+ PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT
+} PlayerControllerwidget_order;
+
+typedef enum {
PLAYER_CONTROLLER_STATE_OFFLINE,
PLAYER_CONTROLLER_STATE_INSTANTIATING,
PLAYER_CONTROLLER_STATE_READY,
@@ -139,16 +159,16 @@ 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_METADATA 2
-#define PLAYER_CONTROLLER_TRANSPORT 3
+#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_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);
-static void player_controller_update_layout (PlayerController* self);
+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);
@@ -159,6 +179,7 @@ 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);
PlayerItem* player_item_new (const char* type);
PlayerItem* player_item_construct (GType object_type, const char* type);
TitleMenuitem* title_menuitem_new (PlayerController* parent);
@@ -166,7 +187,9 @@ TitleMenuitem* title_menuitem_construct (GType object_type, PlayerController* pa
GType title_menuitem_get_type (void);
MetadataMenuitem* metadata_menuitem_new (void);
MetadataMenuitem* metadata_menuitem_construct (GType object_type);
-GType metadata_menuitem_get_type (void);
+ScrubMenuitem* scrub_menuitem_new (PlayerController* parent);
+ScrubMenuitem* scrub_menuitem_construct (GType object_type, PlayerController* parent);
+GType scrub_menuitem_get_type (void);
TransportMenuitem* transport_menuitem_new (PlayerController* parent);
TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent);
GType transport_menuitem_get_type (void);
@@ -179,6 +202,18 @@ 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}};
+ 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);
+ }
+ return player_controller_widget_order_type_id__volatile;
+}
+
+
GType player_controller_state_get_type (void) {
static volatile gsize player_controller_state_type_id__volatile = 0;
if (g_once_init_enter (&player_controller_state_type_id__volatile)) {
@@ -223,7 +258,6 @@ PlayerController* player_controller_construct (GType object_type, DbusmenuMenuit
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);
player_controller_set_menu_offset (self, offset);
- g_debug ("player-controller.vala:54: offset = %i", offset);
player_controller_construct_widgets (self);
player_controller_establish_mpris_connection (self);
player_controller_update_layout (self);
@@ -238,7 +272,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:62: update_state - player controller %s : new s" \
+ g_debug ("player-controller.vala:68: update_state - player controller %s : new s" \
"tate %i", self->priv->_name, (gint) new_state);
self->current_state = (gint) new_state;
}
@@ -248,7 +282,7 @@ 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, PLAYER_CONTROLLER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ 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_);
}
@@ -257,7 +291,7 @@ void player_controller_instantiate (PlayerController* self) {
GError * _inner_error_;
g_return_if_fail (self != NULL);
_inner_error_ = NULL;
- g_debug ("player-controller.vala:80: instantiate in player controller for %s", self->priv->_name);
+ g_debug ("player-controller.vala:87: 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) {
@@ -272,7 +306,7 @@ void player_controller_instantiate (PlayerController* self) {
_error_ = _inner_error_;
_inner_error_ = NULL;
{
- g_warning ("player-controller.vala:86: Failed to launch app %s with error message:" \
+ g_warning ("player-controller.vala:93: Failed to launch app %s with error message:" \
" %s", self->priv->_name, _error_->message);
_g_error_free0 (_error_);
}
@@ -289,20 +323,20 @@ 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:93: establish_mpris_connection - Not ready to c" \
-"onnect");
+ g_debug ("player-controller.vala:100: establish_mpris_connection - Not ready to " \
+"connect");
return;
}
if (_vala_strcmp0 (self->priv->_name, "Vlc") == 0) {
MprisController* _tmp0_;
- g_debug ("player-controller.vala:98: establishing a vlc mpris controller");
+ g_debug ("player-controller.vala:105: 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:106: yup I'm connected");
+ g_debug ("player-controller.vala:113: yup I'm connected");
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_CONNECTED);
} else {
player_controller_update_state (self, PLAYER_CONTROLLER_STATE_DISCONNECTED);
@@ -342,26 +376,34 @@ static char* bool_to_string (gboolean self) {
}
-static void player_controller_update_layout (PlayerController* self) {
+void player_controller_update_layout (PlayerController* self) {
gboolean visibility;
- char* _tmp0_;
- PlayerItem* _tmp1_;
+ PlayerItem* _tmp0_;
+ MetadataMenuitem* meta_item;
+ char* _tmp1_;
PlayerItem* _tmp2_;
+ PlayerItem* _tmp3_;
+ PlayerItem* _tmp4_;
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;
}
- g_debug ("player-controller.vala:128: about the set the visibility on both the t" \
-"ransport and metadata widget to %s", _tmp0_ = bool_to_string (visibility));
- _g_free0 (_tmp0_);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp1_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, PLAYER_CONTROLLER_TRANSPORT)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
- _g_object_unref0 (_tmp1_);
- dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) (_tmp2_ = (PlayerItem*) gee_abstract_list_get ((GeeAbstractList*) self->custom_items, PLAYER_CONTROLLER_METADATA)), DBUSMENU_MENUITEM_PROP_VISIBLE, visibility);
+ 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_);
- if (self->mpris_adaptor == NULL) {
- g_warning ("player-controller.vala:133: Why is the mpris object null");
+ 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_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);
}
@@ -369,6 +411,7 @@ static void player_controller_construct_widgets (PlayerController* self) {
PlayerItem* _tmp0_;
TitleMenuitem* title_menu_item;
MetadataMenuitem* metadata_item;
+ ScrubMenuitem* scrub_item;
TransportMenuitem* transport_item;
g_return_if_fail (self != NULL);
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, _tmp0_ = player_item_new (DBUSMENU_CLIENT_TYPES_SEPARATOR));
@@ -377,6 +420,8 @@ static void player_controller_construct_widgets (PlayerController* self) {
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) title_menu_item);
metadata_item = metadata_menuitem_new ();
gee_abstract_collection_add ((GeeAbstractCollection*) self->custom_items, (PlayerItem*) metadata_item);
+ scrub_item = scrub_menuitem_new (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);
{
@@ -395,6 +440,7 @@ static void player_controller_construct_widgets (PlayerController* self) {
}
_g_object_unref0 (title_menu_item);
_g_object_unref0 (metadata_item);
+ _g_object_unref0 (scrub_item);
_g_object_unref0 (transport_item);
}
@@ -444,7 +490,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:165: PlayerController->format_client_name - : %" \
+ g_debug ("player-controller.vala:179: PlayerController->format_client_name - : %" \
"s", formatted);
}
result = formatted;