aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/music-player-bridge.vala4
-rw-r--r--src/play-button.c14
-rw-r--r--src/player-controller.vala5
-rw-r--r--src/title-menu-item.vala7
-rw-r--r--src/title-widget.c53
-rw-r--r--src/transport-menu-item.vala1
-rw-r--r--src/transport-widget.c47
7 files changed, 74 insertions, 57 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index ec4fb25..2f87b2d 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -52,7 +52,7 @@ public class MusicPlayerBridge : GLib.Object
warning("App string in keyfile is null therefore moving on to next player");
continue;
}
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
+ DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
if(info == null){
warning("Could not create a desktopappinfo instance from app: %s", app);
continue;
@@ -65,7 +65,7 @@ public class MusicPlayerBridge : GLib.Object
ctrl.set("app_info", app_info);
this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
debug("Created a player controller for %s which was found in the cache file", app_info.get_name().down().strip());
- count += 1;
+ count += 1;
}
break;
}
diff --git a/src/play-button.c b/src/play-button.c
index 2fddbcf..d6d243c 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -29,7 +29,7 @@ Uses code from ctk
#define RECT_WIDTH 130.0f
#define Y 15.0f
-#define X 22.0f
+#define X 37.0f
#define INNER_RADIUS 12.5
#define MIDDLE_RADIUS 13.5f
#define OUTER_RADIUS 14.5f
@@ -41,16 +41,16 @@ Uses code from ctk
#define TRI_WIDTH 11.0f
#define TRI_HEIGHT 13.0f
#define TRI_OFFSET 6.0f
-#define PREV_X 20.0f
+#define PREV_X 35.0f
#define PREV_Y 21.0f
-#define NEXT_X 98.0f
+#define NEXT_X 113.0f
#define NEXT_Y 21.0f //prev_y
#define PAUSE_WIDTH 21.0f
#define PAUSE_HEIGHT 27.0f
#define BAR_WIDTH 4.5f
#define BAR_HEIGHT 24.0f
#define BAR_OFFSET 10.0f
-#define PAUSE_X 62.0f
+#define PAUSE_X 77.0f
#define PAUSE_Y 15.0f
// Transport events
@@ -363,15 +363,15 @@ determine_button_event(GtkWidget* button, GdkEventButton* event)
g_debug("event y coordinate = %f", event->y);
gint result = 0;
// For now very simple rectangular collision detection
- if(event->x > 40 && event->x < 80
+ if(event->x > 55 && event->x < 95
&& event->y > 22 && event->y < 46){
result = PREVIOUS;
}
- else if(event->x > 86 && event->x < 118
+ else if(event->x > 101 && event->x < 133
&& event->y > 20 && event->y < 47){
result = PLAY_PAUSE;
}
- else if(event->x > 122 && event->x < 164
+ else if(event->x > 137 && event->x < 179
&& event->y > 22 && event->y < 46){
result = NEXT;
}
diff --git a/src/player-controller.vala b/src/player-controller.vala
index d7fd422..d272d14 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -59,7 +59,7 @@ public class PlayerController : GLib.Object
public void update_state(state new_state)
{
- debug("update_state : new state %i", new_state);
+ debug("update_state - player controller %s : new state %i", this.name, new_state);
this.current_state = new_state;
}
@@ -77,6 +77,7 @@ public class PlayerController : GLib.Object
*/
public void instantiate()
{
+ debug("instantiate in player controller for %s", this.name);
try{
this.app_info.launch(null, null);
this.update_state(state.INSTANTIATING);
@@ -140,7 +141,7 @@ public class PlayerController : GLib.Object
this.custom_items.add(new PlayerItem(CLIENT_TYPES_SEPARATOR));
// Title item
- TitleMenuitem title_menu_item = new TitleMenuitem(this, this.name);
+ TitleMenuitem title_menu_item = new TitleMenuitem(this);
this.custom_items.add(title_menu_item);
// Metadata item
diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala
index 612d279..8183821 100644
--- a/src/title-menu-item.vala
+++ b/src/title-menu-item.vala
@@ -23,15 +23,16 @@ using Gee;
public class TitleMenuitem : PlayerItem
{
- public TitleMenuitem(PlayerController parent, string name)
+ public TitleMenuitem(PlayerController parent)
{
Object(item_type: MENUITEM_TYPE, owner: parent);
- this.property_set(MENUITEM_TEXT_NAME, name);
+ this.property_set(MENUITEM_TEXT_NAME, parent.name);
}
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
{
- debug("handle_event with bool value %s", input_value.get_boolean().to_string());
+ debug("handle_event for owner %s with owner state = %i and title menu name %s", this.owner.name, this.owner.current_state, property_get(MENUITEM_TEXT_NAME));
+
if(this.owner.current_state == PlayerController.state.OFFLINE)
{
this.owner.instantiate();
diff --git a/src/title-widget.c b/src/title-widget.c
index 1b57fe9..7e48940 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -27,7 +27,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include <libindicator/indicator-image-helper.h>
-static DbusmenuMenuitem* twin_item;
typedef struct _TitleWidgetPrivate TitleWidgetPrivate;
@@ -36,6 +35,7 @@ struct _TitleWidgetPrivate
GtkWidget* hbox;
GtkWidget* name;
GtkWidget* player_icon;
+ DbusmenuMenuitem* twin_item;
};
#define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate))
@@ -57,7 +57,10 @@ static gboolean title_widget_expose_event(GtkWidget* widget,
// Dbusmenuitem properties update callback
static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata);
-static void style_name_text(TitleWidget* self);
+static void title_widget_set_twin_item( TitleWidget* self,
+ DbusmenuMenuitem* twin_item);
+static void title_widget_style_name_text(TitleWidget* self);
+
G_DEFINE_TYPE (TitleWidget, title_widget, GTK_TYPE_MENU_ITEM);
@@ -90,22 +93,9 @@ title_widget_init (TitleWidget *self)
hbox = gtk_hbox_new(FALSE, 0);
priv->hbox = hbox;
- g_signal_connect(G_OBJECT(twin_item), "property-changed",
- G_CALLBACK(title_widget_property_update), self);
priv->player_icon = indicator_image_helper("sound_icon");
gtk_box_pack_start(GTK_BOX (priv->hbox), priv->player_icon, FALSE, FALSE, 0);
-
- priv->name = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
- DBUSMENU_TITLE_MENUITEM_TEXT_NAME));
- gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0);
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0);
-
- style_name_text(self);
-
- gtk_widget_show_all (priv->hbox);
- gtk_container_add (GTK_CONTAINER (self), hbox);
-
}
static void
@@ -126,12 +116,13 @@ title_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
g_debug("TitleWidget::menu_press_event");
-
+ TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(menuitem);
+
GValue value = {0};
g_value_init(&value, G_TYPE_BOOLEAN);
g_value_set_boolean(&value, TRUE);
- dbusmenu_menuitem_handle_event (twin_item, "Title menu event", &value, 0);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
return TRUE;
}
@@ -163,12 +154,31 @@ title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(g_ascii_strcasecmp(DBUSMENU_TITLE_MENUITEM_TEXT_NAME, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->name), g_value_get_string(value));
- style_name_text(mitem);
+ title_widget_style_name_text(mitem);
}
}
static void
-style_name_text(TitleWidget* self)
+title_widget_set_twin_item(TitleWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(twin_item), "property-changed",
+ G_CALLBACK(title_widget_property_update), self);
+ priv->name = gtk_label_new(dbusmenu_menuitem_property_get(priv->twin_item,
+ DBUSMENU_TITLE_MENUITEM_TEXT_NAME));
+ gtk_misc_set_padding(GTK_MISC(priv->name), 10, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->name, FALSE, FALSE, 0);
+
+ title_widget_style_name_text(self);
+
+ gtk_widget_show_all (priv->hbox);
+ gtk_container_add (GTK_CONTAINER (self), priv->hbox);
+}
+
+static void
+title_widget_style_name_text(TitleWidget* self)
{
TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(self);
@@ -186,7 +196,8 @@ style_name_text(TitleWidget* self)
GtkWidget*
title_widget_new(DbusmenuMenuitem *item)
{
- twin_item = item;
- return g_object_new(TITLE_WIDGET_TYPE, NULL);
+ GtkWidget* widget = g_object_new(TITLE_WIDGET_TYPE, NULL);
+ title_widget_set_twin_item((TitleWidget*)widget, item);
+ return widget;
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 33f1d9d..8e837c2 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -43,7 +43,6 @@ public class TransportMenuitem : PlayerItem
{
int input = input_value.get_int();
debug("handle_event with value %s", input.to_string());
- // Fire and forgot - the widget would not have sent it over it didn't think it was relevant.
debug("transport owner name = %s", this.owner.name);
this.owner.mpris_adaptor.transport_event((action)input);
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 9852b50..f02200e 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -27,15 +27,13 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gtk/gtk.h>
#include "play-button.h"
-
-static DbusmenuMenuitem* twin_item;
-
typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
struct _TransportWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* play_button;
+ DbusmenuMenuitem* twin_item;
};
#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
@@ -45,18 +43,24 @@ static void transport_widget_class_init (TransportWidgetClass *klass);
static void transport_widget_init (TransportWidget *self);
static void transport_widget_dispose (GObject *object);
static void transport_widget_finalize (GObject *object);
-static gboolean transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event);
+
+static void transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item);
+
+static gboolean transport_widget_expose_event(GtkWidget* widget,
+ GdkEventExpose* event);
/* UI and dbusmenu callbacks */
-static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
- GdkEventButton *event);
-static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event);
+static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
+ GdkEventButton *event);
+static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
+ GdkEventButton *event);
static void transport_widget_property_update(DbusmenuMenuitem* item,
gchar * property,
GValue * value,
gpointer userdata);
+
G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
static void
@@ -93,8 +97,6 @@ transport_widget_init (TransportWidget *self)
play_button_set_style(priv->play_button, style);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->play_button, FALSE, FALSE, 0);
-
- g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_property_update), self);
gtk_container_add (GTK_CONTAINER (self), priv->hbox);
@@ -120,14 +122,21 @@ transport_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
//gtk_container_propagate_expose(GTK_CONTAINER(widget),priv->play_button, event);
return TRUE;
}
-
+
+static void transport_widget_set_twin_item(TransportWidget* self,
+ DbusmenuMenuitem* twin_item)
+{
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
+ priv->twin_item = twin_item;
+ g_signal_connect(G_OBJECT(priv->twin_item), "property-changed",
+ G_CALLBACK(transport_widget_property_update), self);
+}
/* keyevents */
static gboolean
transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportWidget::menu_press_event");
if(IS_TRANSPORT_WIDGET(menuitem) == FALSE){
return FALSE;
}
@@ -136,20 +145,15 @@ transport_widget_button_press_event (GtkWidget *menuitem,
GtkWidget *parent;
- // can we block emissions of "grab-notify" on parent??
parent = gtk_widget_get_parent (GTK_WIDGET (menuitem));
- gint result = determine_button_event(priv->play_button, event);
- //GTK_OBJECT_FLAGS (scale) |= GTK_HAS_GRAB;
- //gtk_widget_event (scale,
- //((GdkEvent *)(void*)(event)));
- //GTK_OBJECT_FLAGS (scale) &= ~(GTK_HAS_GRAB);
+ gint result = determine_button_event(priv->play_button, event);
GValue value = {0};
g_value_init(&value, G_TYPE_INT);
g_debug("TransportWidget::menu_press_event - going to send value %i", result);
g_value_set_int(&value, result);
- dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0);
+ dbusmenu_menuitem_handle_event (priv->twin_item, "Transport state change", &value, 0);
return TRUE;
}
@@ -191,7 +195,8 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
GtkWidget*
transport_widget_new(DbusmenuMenuitem *item)
{
- twin_item = item;
- return g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ GtkWidget* widget = g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
+ transport_widget_set_twin_item((TransportWidget*)widget, item);
+ return widget;
}