aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rwxr-xr-xsrc/indicator-sound.c6
-rw-r--r--src/metadata-widget.c52
-rw-r--r--src/metadata-widget.c~57
-rw-r--r--src/transport-bar.c92
-rw-r--r--src/transport-bar.h28
6 files changed, 144 insertions, 95 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b28903b..2a19c3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,8 +9,8 @@ soundmenulib_LTLIBRARIES = libsoundmenu.la
libsoundmenu_la_SOURCES = \
common-defs.h \
indicator-sound.h \
- transport-bar.c \
- transport-bar.h \
+ transport-widget.c \
+ transport-widget.h \
metadata-widget.c \
metadata-widget.h \
indicator-sound.c \
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index af2a6f9..ebafd9a 100755
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -38,7 +38,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator-image-helper.h>
#include "indicator-sound.h"
-#include "transport-bar.h"
+#include "transport-widget.h"
#include "metadata-widget.h"
#include "dbus-shared-names.h"
#include "sound-service-client.h"
@@ -314,7 +314,7 @@ new_slider_item(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC
}
static gboolean
-new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
+new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
g_debug("indicator-sound: new_transport_bar() called ");
@@ -323,7 +323,7 @@ new_transport_bar(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmen
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
- bar = transport_bar_new(newitem);
+ bar = transport_widget_new(newitem);
GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, menu_transport_bar, parent);
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index 70542e9..a451ad7 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -34,7 +34,10 @@ struct _MetadataWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* album_art;
- gchar* our_path;
+ gchar* our_path;
+ GtkWidget* artist_label;
+ GtkWidget* piece_label;
+ GtkWidget* container_label;
};
#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
@@ -49,13 +52,11 @@ 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
+// Dbusmenuitem properties update callback
static void metadata_widget_update_state(gchar * property,
GValue * value,
gpointer userdata);
-
+//static void update_content(
G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
@@ -84,22 +85,47 @@ 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);
+ GtkWidget *hbox;
+ hbox = gtk_hbox_new(TRUE, 0);
+ priv->hbox = hbox;
+
+ // image
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);
+ GdkPixbuf* pixbuf;
+ pixbuf=gdk_pixbuf_new_from_file(path, NULL);
+ pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR);
+ priv->album_art = gtk_image_new_from_pixbuf(pixbuf);
+ g_object_unref(pixbuf);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0);
+ GtkWidget* vbox = gtk_vbox_new(TRUE, 0);
+
+ // artist
+ GtkWidget* artist;
+ artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST));
+ priv->artist_label = artist;
+ gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0);
+
+ // piece
+ GtkWidget* piece;
+ piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE));
+ priv->piece_label = piece;
+ gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0);
- priv->album_art = gtk_image_new_from_file(priv->our_path);
+ // container
+ GtkWidget* container;
+ container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER));
+ priv->container_label = container;
+ gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0);
+
g_signal_connect(G_OBJECT(twin_item), "property-changed",
G_CALLBACK(metadata_widget_update_state), self);
-
- gtk_widget_show_all (priv->hbox);
+ gtk_widget_show_all (priv->hbox);
gtk_container_add (GTK_CONTAINER (self), hbox);
}
@@ -133,8 +159,6 @@ metadata_widget_button_release_event (GtkWidget *menuitem,
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)
{
g_debug("metadata_widget_update_state - with property %s", property);
diff --git a/src/metadata-widget.c~ b/src/metadata-widget.c~
index df58de5..add3c36 100644
--- a/src/metadata-widget.c~
+++ b/src/metadata-widget.c~
@@ -34,7 +34,10 @@ struct _MetadataWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* album_art;
- gchar* our_path;
+ gchar* our_path;
+ GtkWidget* artist_label;
+ GtkWidget* piece_label;
+ GtkWidget* container_label;
};
#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
@@ -49,13 +52,11 @@ 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
+// Dbusmenuitem properties update callback
static void metadata_widget_update_state(gchar * property,
GValue * value,
gpointer userdata);
-
+//static void update_content(
G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
@@ -84,22 +85,48 @@ 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);
-
- //const gchar* path = dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_IMAGE_PATH);
-
- //g_debug("MetadataWidget:init - path = %s", path);
+ GtkWidget *hbox;
+ hbox = gtk_hbox_new(TRUE, 0);
+ priv->hbox = hbox;
+
+ // image
+ 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);
+ GdkPixbuf* pixbuf;
+ pixbuf=gdk_pixbuf_new_from_file(path, NULL);
+ pixbuf=gdk_pixbuf_scale_simple(pixbuf,60,60,GDK_INTERP_BILINEAR);
+ priv->album_art = gtk_image_new_from_pixbuf(pixbuf);
+ g_object_unref(pixbuf);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0);
+ GtkWidget* vbox = gtk_vbox_new(TRUE, 0);
+
+ // artist
+ GtkWidget* artist;
+ artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_ARTIST));
+ priv->artist_label = artist;
+ gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0);
+
+
+ // piece
+ GtkWidget* piece;
+ piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_PIECE));
+ priv->piece_label = piece;
+ gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0);
- priv->album_art = gtk_image_new_from_file(priv->our_path);
+ // container
+ GtkWidget* container;
+ container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_TEXT_CONTAINER));
+ priv->container_label = container;
+ gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), vbox, FALSE, FALSE, 0);
+
g_signal_connect(G_OBJECT(twin_item), "property-changed",
G_CALLBACK(metadata_widget_update_state), self);
-
- gtk_widget_show_all (priv->hbox);
+ gtk_widget_show_all (priv->hbox);
gtk_container_add (GTK_CONTAINER (self), hbox);
}
@@ -133,8 +160,6 @@ metadata_widget_button_release_event (GtkWidget *menuitem,
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)
{
g_debug("metadata_widget_update_state - with property %s", property);
diff --git a/src/transport-bar.c b/src/transport-bar.c
index 96ae287..bc2ee40 100644
--- a/src/transport-bar.c
+++ b/src/transport-bar.c
@@ -30,9 +30,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
static DbusmenuMenuitem* twin_item;
-typedef struct _TransportBarPrivate TransportBarPrivate;
+typedef struct _TransportWidgetPrivate TransportWidgetPrivate;
-struct _TransportBarPrivate
+struct _TransportWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* previous_button;
@@ -50,46 +50,46 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-#define TRANSPORT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_BAR_TYPE, TransportBarPrivate))
+#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
/* Gobject boiler plate */
-static void transport_bar_class_init (TransportBarClass *klass);
-static void transport_bar_init (TransportBar *self);
-static void transport_bar_dispose (GObject *object);
-static void transport_bar_finalize (GObject *object);
+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);
/* UI and dbus callbacks */
-static gboolean transport_bar_button_press_event (GtkWidget *menuitem,
+static gboolean transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
-static gboolean transport_bar_button_release_event (GtkWidget *menuitem,
+static gboolean transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event);
-static gboolean transport_bar_play_button_trigger (GtkWidget *widget,
+static gboolean transport_widget_play_button_trigger (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
-static void transport_bar_update_state(DbusmenuMenuitem* item,
+static void transport_widget_update_state(DbusmenuMenuitem* item,
gchar * property,
GValue * value,
gpointer userdata);
// utility methods
-static gchar* transport_bar_determine_play_label(gchar* state);
+static gchar* transport_widget_determine_play_label(gchar* state);
-G_DEFINE_TYPE (TransportBar, transport_bar, GTK_TYPE_MENU_ITEM);
+G_DEFINE_TYPE (TransportWidget, transport_widget, GTK_TYPE_MENU_ITEM);
static void
-transport_bar_class_init (TransportBarClass *klass)
+transport_widget_class_init (TransportWidgetClass *klass)
{
GObjectClass *gobject_class = G_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;
+ widget_class->button_press_event = transport_widget_button_press_event;
+ widget_class->button_release_event = transport_widget_button_release_event;
- g_type_class_add_private (klass, sizeof (TransportBarPrivate));
+ g_type_class_add_private (klass, sizeof (TransportWidgetPrivate));
- gobject_class->dispose = transport_bar_dispose;
- gobject_class->finalize = transport_bar_finalize;
+ gobject_class->dispose = transport_widget_dispose;
+ gobject_class->finalize = transport_widget_finalize;
signals[PLAY] = g_signal_new ("play",
G_OBJECT_CLASS_TYPE (gobject_class),
@@ -126,11 +126,11 @@ transport_bar_class_init (TransportBarClass *klass)
}
static void
-transport_bar_init (TransportBar *self)
+transport_widget_init (TransportWidget *self)
{
- g_debug("TransportBar::transport_bar_init");
+ g_debug("TransportWidget::transport_widget_init");
- TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(self);
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
GtkWidget *hbox;
hbox = gtk_hbox_new(TRUE, 2);
@@ -142,10 +142,10 @@ transport_bar_init (TransportBar *self)
gtk_box_pack_start (GTK_BOX (hbox), priv->play_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), priv->next_button, FALSE, FALSE, 0);
- g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_bar_play_button_trigger), NULL);
+ g_signal_connect(priv->play_button, "button-press-event", G_CALLBACK(transport_widget_play_button_trigger), NULL);
priv->hbox = hbox;
- g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_bar_update_state), self);
+ g_signal_connect(G_OBJECT(twin_item), "property-changed", G_CALLBACK(transport_widget_update_state), self);
gtk_widget_show_all (priv->hbox);
gtk_container_add (GTK_CONTAINER (self), hbox);
@@ -153,67 +153,67 @@ transport_bar_init (TransportBar *self)
}
static void
-transport_bar_dispose (GObject *object)
+transport_widget_dispose (GObject *object)
{
//if(IS_TRANSPORT_BAR(object) == TRUE){
- // TransportBarPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object));
+ // TransportWidgetPrivate * priv = TRANSPORT_BAR_GET_PRIVATE(TRANSPORT_BAR(object));
// g_object_unref(priv->previous_button);
//}
- G_OBJECT_CLASS (transport_bar_parent_class)->dispose (object);
+ G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object);
}
static void
-transport_bar_finalize (GObject *object)
+transport_widget_finalize (GObject *object)
{
- G_OBJECT_CLASS (transport_bar_parent_class)->finalize (object);
+ G_OBJECT_CLASS (transport_widget_parent_class)->finalize (object);
}
/* keyevents */
static gboolean
-transport_bar_button_press_event (GtkWidget *menuitem,
+transport_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportBar::menu_press_event");
+ g_debug("TransportWidget::menu_press_event");
return FALSE;
}
static gboolean
-transport_bar_button_release_event (GtkWidget *menuitem,
+transport_widget_button_release_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("TransportBar::menu_release_event");
+ g_debug("TransportWidget::menu_release_event");
return FALSE;
}
/* Individual keyevents on the buttons */
static gboolean
-transport_bar_play_button_trigger(GtkWidget* widget,
+transport_widget_play_button_trigger(GtkWidget* widget,
GdkEventButton *event,
gpointer user_data)
{
- g_debug("TransportBar::PLAY button_press_event");
+ g_debug("TransportWidget::PLAY button_press_event");
return FALSE;
}
/**
-* transport_bar_update_state()
+* transport_widget_update_state()
* Callback for updates from the other side of dbus
**/
-static void transport_bar_update_state(DbusmenuMenuitem* item, gchar* property,
+static void transport_widget_update_state(DbusmenuMenuitem* item, gchar* property,
GValue* value, gpointer userdata)
{
- g_debug("transport_bar_update_state - with property %s", property);
+ g_debug("transport_widget_update_state - with property %s", property);
gchar* input = g_strdup(g_value_get_string(value));
- g_debug("transport_bar_update_state - with value %s", input);
+ g_debug("transport_widget_update_state - with value %s", input);
- TransportBar* bar = (TransportBar*)userdata;
- TransportBarPrivate *priv = TRANSPORT_BAR_GET_PRIVATE(bar);
+ TransportWidget* bar = (TransportWidget*)userdata;
+ TransportWidgetPrivate *priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
- gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_bar_determine_play_label(property)));
+ gtk_button_set_label(GTK_BUTTON(priv->play_button), g_strdup(transport_widget_determine_play_label(property)));
}
// will be needed for image swapping
-static gchar* transport_bar_determine_play_label(gchar* state)
+static gchar* transport_widget_determine_play_label(gchar* state)
{
gchar* label = ">";
if(g_strcmp0(state, "pause") == 0){
@@ -227,12 +227,12 @@ static gchar* transport_bar_determine_play_label(gchar* state)
/**
* transport_new:
- * @returns: a new #TransportBar.
+ * @returns: a new #TransportWidget.
**/
GtkWidget*
-transport_bar_new(DbusmenuMenuitem *item)
+transport_widget_new(DbusmenuMenuitem *item)
{
twin_item = item;
- return g_object_new(TRANSPORT_BAR_TYPE, NULL);
+ return g_object_new(TRANSPORT_WIDGET_TYPE, NULL);
}
diff --git a/src/transport-bar.h b/src/transport-bar.h
index 8a791ff..1d1aa6e 100644
--- a/src/transport-bar.h
+++ b/src/transport-bar.h
@@ -16,34 +16,34 @@ 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 __TRANSPORT_BAR_H__
-#define __TRANSPORT_BAR_H__
+#ifndef __TRANSPORT_WIDGET_H__
+#define __TRANSPORT_WIDGET_H__
#include <gtk/gtkmenuitem.h>
#include <libdbusmenu-gtk/menu.h>
G_BEGIN_DECLS
-#define TRANSPORT_BAR_TYPE (transport_bar_get_type ())
-#define TRANSPORT_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_BAR_TYPE, TransportBar))
-#define TRANSPORT_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_BAR_TYPE, TransportBarClass))
-#define IS_TRANSPORT_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_BAR_TYPE))
-#define IS_TRANSPORT_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_BAR_TYPE))
-#define TRANSPORT_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_BAR_TYPE, TransportBarClass))
+#define TRANSPORT_WIDGET_TYPE (transport_widget_get_type ())
+#define TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRANSPORT_WIDGET_TYPE, TransportWidget))
+#define TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRANSPORT_WIDGET_TYPE, TransportWidgetClass))
+#define IS_TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRANSPORT_WIDGET_TYPE))
+#define IS_TRANSPORT_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRANSPORT_WIDGET_TYPE))
+#define TRANSPORT_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRANSPORT_WIDGET_TYPE, TransportWidgetClass))
-typedef struct _TransportBar TransportBar;
-typedef struct _TransportBarClass TransportBarClass;
+typedef struct _TransportWidget TransportWidget;
+typedef struct _TransportWidgetClass TransportWidgetClass;
-struct _TransportBarClass {
+struct _TransportWidgetClass {
GtkMenuItemClass parent_class;
};
-struct _TransportBar {
+struct _TransportWidget {
GtkMenuItem parent;
};
-GType transport_bar_get_type (void);
-GtkWidget* transport_bar_new(DbusmenuMenuitem *twin_item);
+GType transport_widget_get_type (void);
+GtkWidget* transport_widget_new(DbusmenuMenuitem *twin_item);
G_END_DECLS