aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c6
-rw-r--r--src/metadata-widget.c6
-rw-r--r--src/mpris-controller.vala29
-rw-r--r--src/play-button.c23
-rw-r--r--src/play-button.h2
-rw-r--r--src/player-controller.vala1
-rw-r--r--src/transport-menu-item.vala10
-rw-r--r--src/transport-widget.c23
8 files changed, 77 insertions, 23 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 10333fe..8be97b4 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -328,10 +328,9 @@ new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbus
bar = transport_widget_new(newitem);
GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
+ gtk_widget_show_all(bar);
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent);
- gtk_widget_show_all(bar);
-
return TRUE;
}
@@ -348,10 +347,9 @@ new_metadata_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
metadata = metadata_widget_new (newitem);
GtkMenuItem *menu_metadata_widget = GTK_MENU_ITEM(metadata);
+ gtk_widget_show_all(metadata);
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_metadata_widget, parent);
- gtk_widget_show_all(metadata);
-
return TRUE;
}
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index bb9c8a8..8235725 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -112,7 +112,7 @@ metadata_widget_init (MetadataWidget *self)
DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST));
gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(artist), 20);
+ gtk_label_set_width_chars(GTK_LABEL(artist), 15);
gtk_label_set_ellipsize(GTK_LABEL(artist), PANGO_ELLIPSIZE_MIDDLE);
priv->artist_label = artist;
// Style it up.
@@ -123,7 +123,7 @@ metadata_widget_init (MetadataWidget *self)
piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
DBUSMENU_METADATA_MENUITEM_TEXT_TITLE));
gtk_misc_set_alignment(GTK_MISC(piece), (gfloat)0, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(piece), 16);
+ gtk_label_set_width_chars(GTK_LABEL(piece), 12);
gtk_label_set_ellipsize(GTK_LABEL(piece), PANGO_ELLIPSIZE_MIDDLE);
priv->piece_label = piece;
// Style it up.
@@ -134,7 +134,7 @@ metadata_widget_init (MetadataWidget *self)
container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
DBUSMENU_METADATA_MENUITEM_TEXT_ALBUM));
gtk_misc_set_alignment(GTK_MISC(container), (gfloat)0, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(container), 20);
+ gtk_label_set_width_chars(GTK_LABEL(container), 15);
gtk_label_set_ellipsize(GTK_LABEL(container), PANGO_ELLIPSIZE_MIDDLE);
priv->container_label = container;
// Style it up.
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index b1e66f3..61c96e7 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -65,16 +65,29 @@ public class MprisController : GLib.Object
* TRUE => Playing
* FALSE => Paused
**/
- public void toggle_playback(bool state)
+ public void transport_event(int command)
{
- if(state == true){
- debug("about to play");
- this.mpris_player.Play();
+ if(command == 2){
+ status st = this.mpris_player.GetStatus();
+ bool play_state = st.playback == 1;
+ debug("toggle_playback - initial play state %i", (int)play_state);
+ bool new_play_state = !play_state;
+ debug("toggle_playback - new play state %i", (int)new_play_state);
+ if(new_play_state == true){
+ debug("about to play");
+ this.mpris_player.Play();
+ }
+ else{
+ debug("about to pause");
+ this.mpris_player.Pause();
+ }
+ }
+ else if(command == 1){
+ this.mpris_player.previous();
+ }
+ else if(command == 3){
+ this.mpris_player.next();
}
- else{
- debug("about to pause");
- this.mpris_player.Pause();
- }
}
public bool connected()
diff --git a/src/play-button.c b/src/play-button.c
index 136f25d..afb46d8 100644
--- a/src/play-button.c
+++ b/src/play-button.c
@@ -349,6 +349,29 @@ play_button_expose (GtkWidget *button, GdkEventExpose *event)
}
+gint
+determine_button_event(GtkWidget* button, GdkEventButton* event)
+{
+ g_debug("event x coordinate = %f", event->x);
+ 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
+ && event->y > 22 && event->y < 46){
+ result = 1;
+ }
+ else if(event->x > 86 && event->x < 118
+ && event->y > 20 && event->y < 47){
+ result = 2;
+ }
+ else if(event->x > 122 && event->x < 164
+ && event->y > 22 && event->y < 46){
+ result = 3;
+ }
+
+ return result;
+}
+
void
play_button_set_style(GtkWidget* button, GtkStyle* style)
{
diff --git a/src/play-button.h b/src/play-button.h
index 6c6aee3..3eaabcc 100644
--- a/src/play-button.h
+++ b/src/play-button.h
@@ -43,6 +43,8 @@ struct _PlayButton {
GType play_button_get_type (void);
void play_button_set_style(GtkWidget* button, GtkStyle* style);
+gint determine_button_event(GtkWidget* button, GdkEventButton* event);
+
GtkWidget* play_button_new();
G_END_DECLS
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 88dc3a7..dfbf6d3 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -110,6 +110,7 @@ public class PlayerController : GLib.Object
if(this.current_state != CONNECTED){
visibility = false;
}
+ debug("about the set the visibility on both the transport and metadata widget to %s", visibility.to_string());
this.custom_items[TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
this.custom_items[METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, visibility);
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 7a1bb4a..7e7bedc 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -36,8 +36,14 @@ public class TransportMenuitem : PlayerItem
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());
- this.owner.mpris_adaptor.toggle_playback(input_value.get_boolean());
+ int input = input_value.get_int();
+ debug("handle_event with value %s", input.to_string());
+ if(input > 0){
+ this.owner.mpris_adaptor.transport_event(input);
+ }
+ else{
+ debug("A mouse event I'm not interested in");
+ }
}
public static HashSet<string> attributes_format()
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 6d39a03..9852b50 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -132,13 +132,24 @@ transport_widget_button_press_event (GtkWidget *menuitem,
return FALSE;
}
- //TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(TRANSPORT_WIDGET(menuitem));
- //GValue value = {0};
- //g_value_init(&value, G_TYPE_BOOLEAN);
- //g_debug("TransportWidget::menu_press_event - going to send value %i", state);
- //g_value_set_boolean(&value, state);
- //dbusmenu_menuitem_handle_event (twin_item, "Transport state change", &value, 0);
+ 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);
+
+ 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);
return TRUE;
}