aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/common-defs.h8
-rw-r--r--src/metadata-menu-item.vala26
-rw-r--r--src/metadata-widget.c179
-rw-r--r--src/metadata-widget.c~179
-rw-r--r--src/metadata-widget.h51
-rw-r--r--src/metadata-widget.h~51
-rw-r--r--src/player-controller.vala17
-rw-r--r--src/transport-bar.c51
-rw-r--r--src/transport-bar.h3
-rw-r--r--src/transport-menu-item.vala10
11 files changed, 551 insertions, 27 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3479cb9..b28903b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,8 @@ libsoundmenu_la_SOURCES = \
indicator-sound.h \
transport-bar.c \
transport-bar.h \
+ metadata-widget.c \
+ metadata-widget.h \
indicator-sound.c \
dbus-shared-names.h \
sound-service-client.h
@@ -51,6 +53,7 @@ sound-service-server.h: $(srcdir)/sound-service.xml
music_bridge_VALASOURCES = \
music-player-bridge.vala \
transport-menu-item.vala \
+ metadata-menu-item.vala \
player-controller.vala
music_bridge_VALAFLAGS = \
diff --git a/src/common-defs.h b/src/common-defs.h
index 5393400..e38b15f 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -27,4 +27,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
/* DBUS Custom Items */
#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item"
#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-transport-bar"
-#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state" \ No newline at end of file
+#define DBUSMENU_TRANSPORT_MENUITEM_STATE "x-canonical-transport-state"
+
+#define DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item";
+#define DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist";
+#define DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece";
+#define DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container";
+#define DBUSMENU_METADATA_MENUITEM_IMAGE = "x-canonical-metadata-image";
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
new file mode 100644
index 0000000..0f6d7d5
--- /dev/null
+++ b/src/metadata-menu-item.vala
@@ -0,0 +1,26 @@
+using Dbusmenu;
+using Gee;
+
+public class MetadataMenuitem : Dbusmenu.Menuitem
+{
+ /* Not ideal duplicate definition of const - see common-defs/h */
+ const string DBUSMENU_METADATA_MENUITEM_TYPE = "x-canonical-metadata-menu-item";
+ const string DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST = "x-canonical-metadata-text-artist";
+ const string DBUSMENU_METADATA_MENUITEM_TEXT_PIECE = "x-canonical-metadata-text-piece";
+ const string DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER = "x-canonical-metadata-text-container";
+ const string DBUSMENU_METADATA_MENUITEM_IMAGE = "x-canonical-metadata-image";
+
+ public MetadataMenuitem()
+ {
+ this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_METADATA_MENUITEM_TYPE);
+ this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST, "Sonnamble");
+ this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_PIECE, "Nocturne");
+ this.property_set(DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER, "Seven Months in E minor");
+ this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE, "");
+ }
+
+ public override void handle_event(string name, GLib.Value input_value, uint timestamp)
+ {
+ debug("MetadataItem -> handle event caught!");
+ }
+} \ No newline at end of file
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
new file mode 100644
index 0000000..5e20f15
--- /dev/null
+++ b/src/metadata-widget.c
@@ -0,0 +1,179 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gi18n.h>
+#include "metadata-widget.h"
+#include "common-defs.h"
+#include <gtk/gtk.h>
+
+// TODO: think about leakage: ted !
+
+
+
+static DbusmenuMenuitem* twin_item;
+
+typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate;
+
+struct _MetadataWidgetPrivate
+{
+ GtkWidget* hbox;
+};
+
+#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
+
+/* Prototypes */
+static void metadata_widget_class_init (MetadataWidgetClass *klass);
+static void metadata_widget_init (MetadataWidget *self);
+static void metadata_widget_dispose (GObject *object);
+static void metadata_widget_finalize (GObject *object);
+// keyevent consumers
+static gboolean metadata_widget_button_press_event (GtkWidget *menuitem,
+ GdkEventButton *event);
+static gboolean metadata_widget_button_release_event (GtkWidget *menuitem,
+ GdkEventButton *event);
+
+
+// Dbusmenuitem update callback
+static void metadata_widget_update_state(gchar * property,
+ GValue * value,
+ gpointer userdata);
+
+
+
+G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
+
+
+
+static void
+metadata_widget_class_init (MetadataWidgetClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->button_press_event = metadata_widget_button_press_event;
+ widget_class->button_release_event = metadata_widget_button_release_event;
+
+ g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate));
+
+ gobject_class->dispose = metadata_widget_dispose;
+ gobject_class->finalize = metadata_widget_finalize;
+
+}
+
+static void
+metadata_widget_init (MetadataWidget *self)
+{
+ g_debug("MetadataWidget::metadata_widget_init");
+
+ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
+ GtkWidget *hbox;
+
+ hbox = gtk_hbox_new(TRUE, 2);
+
+ g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self);
+
+ gtk_widget_show_all (priv->hbox);
+ gtk_container_add (GTK_CONTAINER (self), hbox);
+
+}
+
+static void
+metadata_widget_dispose (GObject *object)
+{
+ //if(IS_METADATA_WIDGET(object) == TRUE){
+ // MetadataWidget * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object));
+ // g_object_unref(priv->previous_button);
+ //}
+ G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object);
+}
+
+static void
+metadata_widget_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object);
+}
+
+/* Suppress/consume keyevents */
+static gboolean
+metadata_widget_button_press_event (GtkWidget *menuitem,
+ GdkEventButton *event)
+{
+ g_debug("MetadataWidget::menu_press_event");
+ return TRUE;
+}
+
+static gboolean
+metadata_widget_button_release_event (GtkWidget *menuitem,
+ GdkEventButton *event)
+{
+ g_debug("MetadataWidget::menu_release_event");
+ return TRUE;
+}
+
+
+//TODO figure out why the userdata is not what I expect it to be.
+static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata)
+{
+ //MetadataWidget* bar = (MetadataWidget*)userdata;
+ // TODO problem line
+ //if(IS_METADATA_WIDGET(bar)){
+ //g_debug("after line 1!!");
+
+ //MetadataWidget *priv = METADATA_WIDGET_GET_PRIVATE(bar);
+ //g_debug("after line 2!!");
+ //gchar* label = "changed";
+ //g_debug("after line 3!!");
+ //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
+ //}
+ //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){
+
+ // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
+ // g_debug("its a button");
+ //}
+ //else{
+ //g_debug("No Goddamn button!!");
+ //}
+ //}
+ g_debug("metadata_widget_update_state - with property %s", property);
+
+ if (value == NULL){
+ g_debug("value is null");
+ return;
+ }
+ // TODO problem line
+ //gchar* input = g_strdup(g_value_get_string(value));
+ //g_debug("metadata_widget_update_state - with value %s", input);
+
+}
+
+ /**
+ * transport_new:
+ * @returns: a new #MetadataWidget.
+ **/
+GtkWidget*
+metadata_widget_new(DbusmenuMenuitem *item)
+{
+ twin_item = item;
+ return g_object_new(METADATA_WIDGET_TYPE, NULL);
+}
+
diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~
new file mode 100644
index 0000000..39a42db
--- /dev/null
+++ b/src/metadata-widget.c~
@@ -0,0 +1,179 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gi18n.h>
+#include "metadata-widget.h"
+#include "common-defs.h"
+#include <gtk/gtk.h>
+
+// TODO: think about leakage: ted !
+
+
+
+static DbusmenuMenuitem* twin_item;
+
+typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate;
+
+struct _MetadataWidgetPrivate
+{
+ GtkWidget* hbox;
+};
+
+#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
+
+/* Prototypes */
+static void metadata_widget_class_init (MetadataWidgetClass *klass);
+static void metadata_widget_init (MetadataWidget *self);
+static void metadata_widget_dispose (GObject *object);
+static void metadata_widget_finalize (GObject *object);
+// keyevent consumers
+static gboolean metadata_widget_button_press_event (GtkWidget *menuitem,
+ GdkEventButton *event);
+static gboolean metadata_widget_button_release_event (GtkWidget *menuitem,
+ GdkEventButton *event);
+
+
+// Dbusmenuitem update callback
+static void metadata_widget_update_state(gchar * property,
+ GValue * value,
+ gpointer userdata);
+
+
+
+G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
+
+
+
+static void
+metadata_widget_class_init (MetadataWidgetClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->button_press_event = metadata_widget_press_event;
+ widget_class->button_release_event = metadata_widget_button_release_event;
+
+ g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate));
+
+ gobject_class->dispose = metadata_widget_dispose;
+ gobject_class->finalize = metadata_widget_finalize;
+
+}
+
+static void
+metadata_widget_init (MetadataWidget *self)
+{
+ g_debug("MetadataWidget::metadata_widget_init");
+
+ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
+ GtkWidget *hbox;
+
+ hbox = gtk_hbox_new(TRUE, 2);
+
+ g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self);
+
+ gtk_widget_show_all (priv->hbox);
+ gtk_container_add (GTK_CONTAINER (self), hbox);
+
+}
+
+static void
+metadata_widget_dispose (GObject *object)
+{
+ //if(IS_METADATA_WIDGET(object) == TRUE){
+ // MetadataWidget * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object));
+ // g_object_unref(priv->previous_button);
+ //}
+ G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object);
+}
+
+static void
+metadata_widget_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object);
+}
+
+/* Suppress/consume keyevents */
+static gboolean
+metadata_widget_button_press_event (GtkWidget *menuitem,
+ GdkEventButton *event)
+{
+ g_debug("MetadataWidget::menu_press_event");
+ return TRUE;
+}
+
+static gboolean
+metadata_widget_button_release_event (GtkWidget *menuitem,
+ GdkEventButton *event)
+{
+ g_debug("MetadataWidget::menu_release_event");
+ return TRUE;
+}
+
+
+//TODO figure out why the userdata is not what I expect it to be.
+static void metadata_widget_update_state(gchar *property, GValue *value, gpointer userdata)
+{
+ //MetadataWidget* bar = (MetadataWidget*)userdata;
+ // TODO problem line
+ //if(IS_METADATA_WIDGET(bar)){
+ //g_debug("after line 1!!");
+
+ //MetadataWidget *priv = METADATA_WIDGET_GET_PRIVATE(bar);
+ //g_debug("after line 2!!");
+ //gchar* label = "changed";
+ //g_debug("after line 3!!");
+ //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
+ //}
+ //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){
+
+ // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
+ // g_debug("its a button");
+ //}
+ //else{
+ //g_debug("No Goddamn button!!");
+ //}
+ //}
+ g_debug("metadata_widget_update_state - with property %s", property);
+
+ if (value == NULL){
+ g_debug("value is null");
+ return;
+ }
+ // TODO problem line
+ //gchar* input = g_strdup(g_value_get_string(value));
+ //g_debug("metadata_widget_update_state - with value %s", input);
+
+}
+
+ /**
+ * transport_new:
+ * @returns: a new #MetadataWidget.
+ **/
+GtkWidget*
+metadata_widget_new(DbusmenuMenuitem *item)
+{
+ twin_item = item;
+ return g_object_new(METADATA_WIDGET_TYPE, NULL);
+}
+
diff --git a/src/metadata-widget.h b/src/metadata-widget.h
new file mode 100644
index 0000000..ce7df5f
--- /dev/null
+++ b/src/metadata-widget.h
@@ -0,0 +1,51 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __METADATA_WIDGET_H__
+#define __METADATA_WIDGET_H__
+
+#include <gtk/gtkmenuitem.h>
+#include <libdbusmenu-gtk/menu.h>
+
+G_BEGIN_DECLS
+
+#define METADATA_WIDGET_TYPE (metadata_widget_get_type ())
+#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, TransportBar))
+#define METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), METADATA_WIDGET_TYPE, MetadataWidgetClass))
+#define IS_METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), METADATA_WIDGET_TYPE))
+#define IS_METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), METADATA_WIDGET_TYPE))
+#define METADATA_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), METADATA_WIDGET_TYPE, MetadataWidgetClass))
+
+typedef struct _MetadataWidget MetadataWidget;
+typedef struct _MetadataWidgetClass MetadataWidgetClass;
+
+struct _MetadataWidgetClass {
+ GtkMenuItemClass parent_class;
+};
+
+struct _MetadataWidget {
+ GtkMenuItem parent;
+};
+
+GType metadata_widget_get_type (void);
+GtkWidget* metadata_widget_new(DbusmenuMenuitem *twin_item);
+
+G_END_DECLS
+
+#endif
+
diff --git a/src/metadata-widget.h~ b/src/metadata-widget.h~
new file mode 100644
index 0000000..edffdf2
--- /dev/null
+++ b/src/metadata-widget.h~
@@ -0,0 +1,51 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __METADATA_WIDGET_H__
+#define __METADATA_WIDGET_H__
+
+#include <gtk/gtkmenuitem.h>
+#include <libdbusmenu-gtk/menu.h>
+
+G_BEGIN_DECLS
+
+#define METADATA_WIDGET_TYPE (metadata_widget_get_type ())
+#define METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_WIDGET_TYPE, TransportBar))
+#define METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), METADATA_WIDGET_TYPE, TransportBarClass))
+#define IS_METADATA_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), METADATA_WIDGET_TYPE))
+#define IS_METADATA_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), METADATA_WIDGET_TYPE))
+#define METADATA_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), METADATA_WIDGET_TYPE, TransportBarClass))
+
+typedef struct _TransportBar TransportBar;
+typedef struct _TransportBarClass TransportBarClass;
+
+struct _TransportBarClass {
+ GtkMenuItemClass parent_class;
+};
+
+struct _TransportBar {
+ GtkMenuItem parent;
+};
+
+GType metadata_widget_get_type (void);
+GtkWidget* metadata_widget_new(DbusmenuMenuitem *twin_item);
+
+G_END_DECLS
+
+#endif
+
diff --git a/src/player-controller.vala b/src/player-controller.vala
index a92d8bf..26ad1ff 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -8,7 +8,7 @@ public class PlayerController : GLib.Object
private bool is_active;
private ArrayList<Dbusmenu.Menuitem> custom_items;
- // TODO: pass in the appropriate position for the menu
+ // TODO: pass in the appropriate position for the menu (to handle multiple players)
public PlayerController(Dbusmenu.Menuitem root, string client_name, bool active)
{
this.root_menu = root;
@@ -38,8 +38,12 @@ public class PlayerController : GLib.Object
title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia");
this.custom_items.add(title_item);
+ // Metadata item
+ MetadataMenuitem metadata_item = new MetadataMenuitem();
+ this.custom_items.add(metadata_item);
+
// Transport item
- TransportMenuItem transport_item = new TransportMenuItem();
+ TransportMenuitem transport_item = new TransportMenuitem();
this.custom_items.add(transport_item);
int offset = 2;
@@ -48,12 +52,6 @@ public class PlayerController : GLib.Object
}
return true;
}
-// if(!root_menu.child_add_position(client_item, 2) ||
-// !root_menu.child_add_position(transport_item, 3)){
-// //TODO raise here!
-// return false;
-// }
-// return true;
private static string format_client_name(string client_name)
@@ -62,8 +60,7 @@ public class PlayerController : GLib.Object
if(formatted.len() > 1){
formatted = client_name.up(1).concat(client_name.slice(1, client_name.len()));
debug("PlayerController->format_client_name - : %s", formatted);
- }
-
+ }
return formatted;
}
diff --git a/src/transport-bar.c b/src/transport-bar.c
index 46611dc..02d9a45 100644
--- a/src/transport-bar.c
+++ b/src/transport-bar.c
@@ -29,6 +29,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
// TODO: think about leakage: ted !
+
+static DbusmenuMenuitem* twin_item;
+
typedef struct _TransportBarPrivate TransportBarPrivate;
struct _TransportBarPrivate
@@ -66,10 +69,13 @@ static gboolean transport_bar_play_button_trigger (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
static void transport_bar_update_state(gchar * property,
- GValue * value);
+ GValue * value,
+ gpointer userdata);
G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM);
+
+
static void
transport_bar_class_init (TransportBarClass *klass)
{
@@ -138,7 +144,7 @@ transport_bar_init (TransportBar *self)
g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL);
priv->hbox = hbox;
- g_signal_connect(DBUSMENU_MENUITEM(self), "property-changed", G_CALLBACK(transport_bar_update_state), NULL);
+ g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_bar_update_state), self);
gtk_widget_show_all (priv->hbox);
gtk_container_add (GTK_CONTAINER (self), hbox);
@@ -188,22 +194,49 @@ transport_bar_play_button_trigger(GtkWidget* widget,
return FALSE;
}
-static void transport_bar_update_state(gchar *property, GValue *value)
-{
- g_debug("transport_bar_update_state - %s", property);
-}
-
-void transport_bar_connect_with_other_half(TransportBar *self, DbusmenuMenuitem *twin_item)
+//TODO figure out why the userdata is not what I expect it to be.
+static void transport_bar_update_state(gchar *property, GValue *value, gpointer userdata)
{
+ //TransportBar* bar = (TransportBar*)userdata;
+ // TODO problem line
+ //if(IS_TRANSPORT_BAR(bar)){
+ //g_debug("after line 1!!");
+
+ //TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar);
+ //g_debug("after line 2!!");
+ //gchar* label = "changed";
+ //g_debug("after line 3!!");
+ //gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
+ //}
+ //if(GTK_IS_BUTTON(GTK_BUTTON(priv->play_button))){
+ // gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(label));
+ // g_debug("its a button");
+ //}
+ //else{
+ //g_debug("No Goddamn button!!");
+ //}
+ //}
+ g_debug("transport_bar_update_state - with property %s", property);
+
+ if (value == NULL){
+ g_debug("value is null");
+ return;
+ }
+ // TODO problem line
+ //gchar* input = g_strdup(g_value_get_string(value));
+ //g_debug("transport_bar_update_state - with value %s", input);
+
}
+
/**
* transport_new:
* @returns: a new #TransportBar.
**/
GtkWidget*
-transport_bar_new()
+transport_bar_new(DbusmenuMenuitem *item)
{
+ twin_item = item;
return g_object_new(TRANSPORT_BAR_TYPE, NULL);
}
diff --git a/src/transport-bar.h b/src/transport-bar.h
index 93136e1..8a791ff 100644
--- a/src/transport-bar.h
+++ b/src/transport-bar.h
@@ -43,8 +43,7 @@ struct _TransportBar {
};
GType transport_bar_get_type (void);
-GtkWidget* transport_bar_new();
-void connect_with_other_half(DbusmenuMenuitem *twin_item);
+GtkWidget* transport_bar_new(DbusmenuMenuitem *twin_item);
G_END_DECLS
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index 9af52d1..0ecc9b1 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -1,21 +1,21 @@
using Dbusmenu;
using Gee;
-public class TransportMenuItem : Dbusmenu.Menuitem
+public class TransportMenuitem : Dbusmenu.Menuitem
{
/* Not ideal duplicate definition of const - see common-defs/h */
const string DBUSMENU_TRANSPORT_MENUITEM_TYPE = "x-canonical-transport-bar";
const string DBUSMENU_TRANSPORT_MENUITEM_STATE = "x-canonical-transport-state";
- public TransportMenuItem()
+ public TransportMenuitem()
{
this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE);
- this.property_set(MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_STATE);
+ this.property_set(DBUSMENU_TRANSPORT_MENUITEM_STATE, "play");
}
public override void handle_event(string name, GLib.Value input_value, uint timestamp)
{
+ this.property_set(DBUSMENU_TRANSPORT_MENUITEM_STATE, "1");
debug("TransportItem -> handle event caught!");
- }
-
+ }
} \ No newline at end of file