diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/music-player-bridge.vala | 11 | ||||
-rw-r--r-- | src/transport-bar.c | 42 |
2 files changed, 45 insertions, 8 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index dc66101..92f9dc5 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -48,10 +48,15 @@ public class MusicPlayerBridge : GLib.Object if(server_is_not_of_interest(type)) return; string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ + Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem(); + client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); TransportMenuItem transport_item = new TransportMenuItem(); - //client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered")); - registered_clients.set(client_name, transport_item); + root_menu.child_append(client_item); root_menu.child_append(transport_item); + + registered_clients.set(client_name, client_item); + // hackery -> need to wrap player sections into its own object + registered_clients.set("transport", transport_item); debug("client of name %s has successfully registered with us", client_name); } } @@ -63,7 +68,9 @@ public class MusicPlayerBridge : GLib.Object string client_name = type.split(".")[1]; if (root_menu != null && client_name != null){ root_menu.child_delete(registered_clients[client_name]); + root_menu.child_delete(registered_clients["transport"]); registered_clients.remove(client_name); + registered_clients.remove("transport"); debug("Successively removed menu_item for client %s from registered_clients", client_name); } } diff --git a/src/transport-bar.c b/src/transport-bar.c index 34f590e..bafd917 100644 --- a/src/transport-bar.c +++ b/src/transport-bar.c @@ -44,17 +44,29 @@ static void transport_bar_init (TransportBar *self); static void transport_bar_dispose (GObject *object); static void transport_bar_finalize (GObject *object); + +static gboolean transport_bar_button_press_event (GtkWidget *menuitem, + GdkEventButton *event); +static gboolean transport_bar_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); + + G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM); static void transport_bar_class_init (TransportBarClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + //GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + widget_class->button_press_event = transport_bar_button_press_event; + widget_class->button_release_event = transport_bar_button_release_event; + g_type_class_add_private (klass, sizeof (TransportBarPrivate)); - object_class->dispose = transport_bar_dispose; - object_class->finalize = transport_bar_finalize; + gobject_class->dispose = transport_bar_dispose; + gobject_class->finalize = transport_bar_finalize; } static void @@ -66,9 +78,9 @@ transport_bar_init (TransportBar *self) GtkWidget *hbox; hbox = gtk_hbox_new(TRUE, 2); - priv->previous_button = gtk_button_new_with_label("Previous"); - priv->next_button = gtk_button_new_with_label("Next"); - priv->play_button = gtk_button_new_with_label("Play"); + priv->previous_button = gtk_button_new_with_label("<<"); + priv->next_button = gtk_button_new_with_label(">>"); + priv->play_button = gtk_button_new_with_label(">"); gtk_box_pack_start (GTK_BOX (hbox), priv->previous_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0); @@ -77,6 +89,7 @@ transport_bar_init (TransportBar *self) priv->hbox = hbox; gtk_widget_show_all (priv->hbox); + gtk_widget_set_sensitive(GTK_WIDGET(self), FALSE); gtk_container_add (GTK_CONTAINER (self), hbox); } @@ -92,6 +105,23 @@ transport_bar_finalize (GObject *object) G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object); } +/* keyevents */ +static gboolean +transport_bar_button_press_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("TransportBar::button_press_event"); + return TRUE; +} + +static gboolean +transport_bar_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + g_debug("TransportBar::button_release_event"); + return TRUE; +} + /** * transport_new: * @returns: a new #TransportBar. |