diff options
-rw-r--r-- | src/common-defs.h | 18 | ||||
-rw-r--r-- | src/metadata-menu-item.vala | 4 | ||||
-rw-r--r-- | src/metadata-widget.c | 45 | ||||
-rw-r--r-- | src/metadata-widget.c~ | 47 | ||||
-rw-r--r-- | src/player-controller.vala | 2 |
5 files changed, 37 insertions, 79 deletions
diff --git a/src/common-defs.h b/src/common-defs.h index e38b15f..014d864 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -25,12 +25,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define SIGNAL_SINK_AVAILABLE_UPDATE "SinkAvailableUpdate" /* 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" - -#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"; +#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" + +#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_PATH "x-canonical-metadata-image" diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 0f6d7d5..c9daee6 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -8,7 +8,7 @@ public class MetadataMenuitem : Dbusmenu.Menuitem 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"; + const string DBUSMENU_METADATA_MENUITEM_IMAGE_PATH = "x-canonical-metadata-image"; public MetadataMenuitem() { @@ -16,7 +16,7 @@ public class MetadataMenuitem : Dbusmenu.Menuitem 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, ""); + this.property_set(DBUSMENU_METADATA_MENUITEM_IMAGE_PATH, "/home/ronoc/Desktop/Sonnamble/Sonnamble_CD.jpg"); } public override void handle_event(string name, GLib.Value input_value, uint timestamp) diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 5e20f15..b414969 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -26,10 +26,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "common-defs.h" #include <gtk/gtk.h> -// TODO: think about leakage: ted ! - - - static DbusmenuMenuitem* twin_item; typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; @@ -37,6 +33,8 @@ typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; struct _MetadataWidgetPrivate { GtkWidget* hbox; + GtkWidget* album_art; + gchar* our_path; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -90,7 +88,16 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_hbox_new(TRUE, 2); - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); + const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH); + + g_debug("MetadataWidget:init - path = %s", path); + + priv->our_path = g_strdup(path); + + priv->album_art = gtk_image_new_from_file(priv->our_path); + + 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); @@ -100,10 +107,6 @@ metadata_widget_init (MetadataWidget *self) 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); } @@ -134,36 +137,12 @@ metadata_widget_button_release_event (GtkWidget *menuitem, //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); - } /** diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~ index 39a42db..81c6f75 100644 --- a/src/metadata-widget.c~ +++ b/src/metadata-widget.c~ @@ -26,10 +26,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "common-defs.h" #include <gtk/gtk.h> -// TODO: think about leakage: ted ! - - - static DbusmenuMenuitem* twin_item; typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; @@ -37,6 +33,8 @@ typedef struct _MetadataWidgetPrivate MetadataWidgetPrivate; struct _MetadataWidgetPrivate { GtkWidget* hbox; + GtkWidget* album_art; + gchar* our_path; }; #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate)) @@ -70,7 +68,7 @@ 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_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)); @@ -90,7 +88,16 @@ metadata_widget_init (MetadataWidget *self) hbox = gtk_hbox_new(TRUE, 2); - g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(metadata_widget_update_state), self); + const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE); + + g_debug("MetadataWidget:init - path = %s", path); + + priv->our_path = g_strdup(path); + + priv->album_art = gtk_image_new_from_file(priv->our_path); + + 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); @@ -100,10 +107,6 @@ metadata_widget_init (MetadataWidget *self) 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); } @@ -134,36 +137,12 @@ metadata_widget_button_release_event (GtkWidget *menuitem, //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); - } /** diff --git a/src/player-controller.vala b/src/player-controller.vala index 26ad1ff..dcb428b 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -34,7 +34,7 @@ public class PlayerController : GLib.Object // Title item Dbusmenu.Menuitem title_item = new Dbusmenu.Menuitem(); - title_item.property_set(MENUITEM_PROP_LABEL, this.name.concat("")); + title_item.property_set(MENUITEM_PROP_LABEL, this.name); title_item.property_set(MENUITEM_PROP_ICON_NAME, "applications-multimedia"); this.custom_items.add(title_item); |