aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-08-24 17:59:15 +0100
committerConor Curran <conor.curran@canonical.com>2010-08-24 17:59:15 +0100
commit5c225cc9608267ce25d599c279271eb5b7ee7a19 (patch)
tree547bd11cfb363a8b4f4ff68d986c425fd348ae40
parent6c2b00b21e60c5b667bb3d82639190af58d3c847 (diff)
parentfeed9f62a8779febde16e4f4461967a2b2a33e72 (diff)
downloadayatana-indicator-sound-5c225cc9608267ce25d599c279271eb5b7ee7a19.tar.gz
ayatana-indicator-sound-5c225cc9608267ce25d599c279271eb5b7ee7a19.tar.bz2
ayatana-indicator-sound-5c225cc9608267ce25d599c279271eb5b7ee7a19.zip
merged the UI polishes, more to follow ...
-rw-r--r--src/common-defs.h10
-rw-r--r--src/indicator-sound.c8
-rw-r--r--src/metadata-menu-item.vala3
-rw-r--r--src/metadata-widget.c219
-rw-r--r--src/mpris2-controller.vala61
-rw-r--r--src/player-item.vala11
-rw-r--r--src/scrub-menu-item.vala2
-rw-r--r--src/title-widget.c25
8 files changed, 203 insertions, 136 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index e3b4552..e554c11 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -34,16 +34,16 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type"
-#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-artist"
-#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-title"
-#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-album"
-#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-arturl"
+#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist"
+#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title"
+#define DBUSMENU_METADATA_MENUITEM_ALBUM "x-canonical-sound-menu-player-metadata-xesam:album"
+#define DBUSMENU_METADATA_MENUITEM_ARTURL "x-canonical-sound-menu-player-metadata-mpris:artUrl"
#define DBUSMENU_TITLE_MENUITEM_TYPE "x-canonical-sound-menu-player-title-type"
#define DBUSMENU_TITLE_MENUITEM_NAME "x-canonical-sound-menu-player-title-name"
#define DBUSMENU_SCRUB_MENUITEM_TYPE "x-canonical-sound-menu-player-scrub-type"
-#define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-time"
+#define DBUSMENU_SCRUB_MENUITEM_DURATION "x-canonical-sound-menu-player-scrub-mpris:length"
#define DBUSMENU_SCRUB_MENUITEM_POSITION "x-canonical-sound-menu-player-scrub-position"
#define DBUSMENU_SCRUB_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-scrub-play-state"
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 3a7abe9..63ad72d 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -375,8 +375,6 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u
g_return_if_fail(IS_INDICATOR_SOUND(userdata));
- // Ensure we are in a coherent state with the service at start up.
- // Preserve ordering!
}
}
return;
@@ -464,12 +462,7 @@ tidy_up_hash()
static void
update_state(const gint state)
{
- /* g_debug("update state beginning - previous_state = %i", previous_state);*/
-
previous_state = current_state;
-
- /* g_debug("update state 3rd line - previous_state = %i", previous_state);*/
-
current_state = state;
gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
indicator_image_helper_update(speaker_image, image_name);
@@ -479,7 +472,6 @@ update_state(const gint state)
void
determine_state_from_volume(gdouble volume_percent)
{
- /* g_debug("determine_state_from_volume - previous_state = %i", previous_state);*/
if (device_available == FALSE)
return;
gint state = previous_state;
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 3818b1c..0bb4a85 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -29,6 +29,7 @@ public class MetadataMenuitem : PlayerItem
reset(attributes_format());
}
+
public static HashSet<string> attributes_format()
{
HashSet<string> attrs = new HashSet<string>();
@@ -39,4 +40,4 @@ public class MetadataMenuitem : PlayerItem
return attrs;
}
-} \ No newline at end of file
+}
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index aaf71e2..aeef670 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -34,10 +34,12 @@ struct _MetadataWidgetPrivate
{
GtkWidget* hbox;
GtkWidget* album_art;
- gchar* image_path;
+ GString* image_path;
GtkWidget* artist_label;
GtkWidget* piece_label;
GtkWidget* container_label;
+ GdkColor bevel_colour;
+ GdkColor eight_note_colour;
};
#define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
@@ -47,25 +49,26 @@ 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);
-static gboolean metadata_widget_expose_event(GtkWidget* widget, GdkEventExpose* event);
+static gboolean metadata_image_expose (GtkWidget *image, GdkEventExpose *event, gpointer user_data);
// 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 properties update callback
-static void metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
- GValue* value, gpointer userdata);
+static void metadata_widget_property_update (DbusmenuMenuitem* item,
+ gchar* property,
+ GValue* value,
+ gpointer userdata);
-static void update_album_art(MetadataWidget* self);
-static void style_artist_text(MetadataWidget* self);
-static void style_title_text(MetadataWidget* self);
-static void style_album_text(MetadataWidget* self);
+static void metadata_widget_update_album_art(MetadataWidget* self);
+static void metadata_widget_style_title_text(MetadataWidget* self);
+static void metadata_widget_style_artist_and_album_label(MetadataWidget* self,
+ GtkLabel* label);
+void metadata_widget_set_style(GtkWidget* button, GtkStyle* style);
-G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
+G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
static void
@@ -75,8 +78,7 @@ metadata_widget_class_init (MetadataWidgetClass *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;
- widget_class->expose_event = metadata_widget_expose_event;
+
g_type_class_add_private (klass, sizeof (MetadataWidgetPrivate));
gobject_class->dispose = metadata_widget_dispose;
@@ -98,49 +100,51 @@ metadata_widget_init (MetadataWidget *self)
// image
priv->album_art = gtk_image_new();
- priv->image_path = g_strdup(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL));
- update_album_art(self);
+ priv->image_path = g_string_new(dbusmenu_menuitem_property_get(twin_item, DBUSMENU_METADATA_MENUITEM_ARTURL));
+ g_debug("Metadata::At startup and image path = %s", priv->image_path->str);
+
+ metadata_widget_update_album_art(self);
+ g_signal_connect(priv->album_art, "expose-event", G_CALLBACK(metadata_image_expose), GTK_WIDGET(self));
+ gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
+
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0);
-
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
+
// artist
GtkWidget* artist;
artist = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
DBUSMENU_METADATA_MENUITEM_ARTIST));
-
gtk_misc_set_alignment(GTK_MISC(artist), (gfloat)0, (gfloat)0);
+ gtk_misc_set_padding (GTK_MISC(artist), (gfloat)10, (gfloat)0);
gtk_label_set_width_chars(GTK_LABEL(artist), 15);
gtk_label_set_ellipsize(GTK_LABEL(artist), PANGO_ELLIPSIZE_MIDDLE);
+ metadata_widget_style_artist_and_album_label(self, GTK_LABEL(artist));
priv->artist_label = artist;
- // Style it up.
- style_artist_text(self);
- // piece
+ // title
GtkWidget* piece;
piece = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
DBUSMENU_METADATA_MENUITEM_TITLE));
gtk_misc_set_alignment(GTK_MISC(piece), (gfloat)0, (gfloat)0);
- gtk_label_set_width_chars(GTK_LABEL(piece), 12);
+ gtk_misc_set_padding (GTK_MISC(piece), (gfloat)10, (gfloat)0);
+ gtk_label_set_width_chars(GTK_LABEL(piece), 15);
gtk_label_set_ellipsize(GTK_LABEL(piece), PANGO_ELLIPSIZE_MIDDLE);
priv->piece_label = piece;
- // Style it up.
- style_title_text(self);
+ metadata_widget_style_title_text(self);
// container
GtkWidget* container;
container = gtk_label_new(dbusmenu_menuitem_property_get(twin_item,
DBUSMENU_METADATA_MENUITEM_ALBUM));
gtk_misc_set_alignment(GTK_MISC(container), (gfloat)0, (gfloat)0);
+ gtk_misc_set_padding (GTK_MISC(container), (gfloat)10, (gfloat)0);
gtk_label_set_width_chars(GTK_LABEL(container), 15);
gtk_label_set_ellipsize(GTK_LABEL(container), PANGO_ELLIPSIZE_MIDDLE);
+ metadata_widget_style_artist_and_album_label(self, GTK_LABEL(container));
priv->container_label = container;
- // Style it up.
- style_album_text(self);
- // Pack in the right order
gtk_box_pack_start (GTK_BOX (vbox), priv->piece_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->artist_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->container_label, FALSE, FALSE, 0);
@@ -150,19 +154,13 @@ metadata_widget_init (MetadataWidget *self)
g_signal_connect(G_OBJECT(twin_item), "property-changed",
G_CALLBACK(metadata_widget_property_update), self);
gtk_widget_show_all (priv->hbox);
+
+ g_signal_connect(self, "style-set", G_CALLBACK(metadata_widget_set_style), GTK_WIDGET(self));
+
gtk_widget_set_size_request(GTK_WIDGET(self), 200, 60);
gtk_container_add (GTK_CONTAINER (self), hbox);
}
-static gboolean
-metadata_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
-{
- MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget);
-
- gtk_container_propagate_expose(GTK_CONTAINER(widget), priv->hbox, event);
- return TRUE;
-}
-
static void
metadata_widget_dispose (GObject *object)
{
@@ -175,21 +173,97 @@ metadata_widget_finalize (GObject *object)
G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object);
}
-/* Suppress/consume keyevents */
+/**
+ * We override the expose method to enable primitive drawing of the
+ * empty album art image (and soon rounded rectangles on the album art)
+ */
static gboolean
-metadata_widget_button_press_event (GtkWidget *menuitem,
- GdkEventButton *event)
+metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user_data)
{
- g_debug("MetadataWidget::menu_press_event");
+ g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE);
+ MetadataWidget* widget = METADATA_WIDGET(user_data);
+ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget);
+
+ if(priv->image_path->len > 0){
+ return FALSE;
+ }
+
+ cairo_t *cr;
+ cr = gdk_cairo_create (metadata->window);
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (metadata, &alloc);
+
+ cairo_rectangle (cr,
+ alloc.x, alloc.y,
+ alloc.width, alloc.height);
+ cairo_clip(cr);
+
+ cairo_move_to (cr, alloc.x , alloc.y);
+ cairo_line_to(cr, alloc.x + alloc.width,
+ alloc.y);
+ cairo_line_to(cr, alloc.x + alloc.width,
+ alloc.y + alloc.height);
+ cairo_line_to(cr, alloc.x, alloc.y + alloc.height);
+ cairo_line_to(cr, alloc.x, alloc.y);
+
+ cairo_close_path (cr);
+
+ cairo_set_source_rgba (cr, 123.0f / 255.0f, 123.0f / 255.0f, 120.0f / 255.0f, .8f);
+ cairo_set_line_width (cr, 2.0);
+
+ cairo_stroke (cr);
+
+ // Draw the eight note
+ PangoLayout *layout;
+ PangoFontDescription *desc;
+ layout = pango_cairo_create_layout(cr);
+ PangoContext* pcontext = pango_cairo_create_context(cr);
+ pango_cairo_context_set_resolution (pcontext, 96);
+
+ GString* string = g_string_new("");
+ gssize size = -1;
+ gunichar code = g_utf8_get_char_validated("\342\231\253", size);
+ g_string_append_unichar (string, code);
+
+ pango_layout_set_text(layout, string->str, -1);
+ desc = pango_font_description_from_string("Sans Bold 30");
+ pango_layout_set_font_description(layout, desc);
+ pango_font_description_free(desc);
+
+ cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.8);
+ pango_cairo_update_layout(cr, layout);
+ cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y);
+ pango_cairo_show_layout(cr, layout);
+
+ g_object_unref(layout);
+ g_object_unref(pcontext);
+ g_string_free (string, TRUE);
+ cairo_destroy (cr);
+
return TRUE;
}
+/* Suppress/consume keyevents */
static gboolean
-metadata_widget_button_release_event (GtkWidget *menuitem,
+metadata_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event)
{
- g_debug("MetadataWidget::menu_release_event");
- return TRUE;
+ GtkClipboard* board = gtk_clipboard_get (GDK_NONE);
+ gchar* title = g_strdup(dbusmenu_menuitem_property_get(twin_item,
+ DBUSMENU_METADATA_MENUITEM_TITLE));
+ gchar* artist = g_strdup(dbusmenu_menuitem_property_get(twin_item,
+ DBUSMENU_METADATA_MENUITEM_ARTIST));
+ gchar* album = g_strdup(dbusmenu_menuitem_property_get(twin_item,
+ DBUSMENU_METADATA_MENUITEM_ALBUM));
+ gchar* contents = g_strdup_printf("artist: %s \ntitle: %s \nalbum: %s", artist, title, album);
+ g_debug("contents to be copied will be : %s", contents);
+ gtk_clipboard_set_text (board, contents, -1);
+ gtk_clipboard_store (board);
+ g_free(contents);
+ g_free(title);
+ g_free(artist);
+ g_free(album);
+ return FALSE;
}
// TODO: Manage empty/mangled music details <unknown artist> etc.
@@ -212,72 +286,73 @@ metadata_widget_property_update(DbusmenuMenuitem* item, gchar* property,
if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTIST, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->artist_label), g_value_get_string(value));
- style_artist_text(mitem);
+ metadata_widget_style_artist_and_album_label(mitem, GTK_LABEL(priv->artist_label));
}
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_TITLE, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->piece_label), g_value_get_string(value));
- style_title_text(mitem);
+ metadata_widget_style_title_text(mitem);
}
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ALBUM, property) == 0){
gtk_label_set_text(GTK_LABEL(priv->container_label), g_value_get_string(value));
- style_album_text(mitem);
+ metadata_widget_style_artist_and_album_label(mitem, GTK_LABEL(priv->container_label));
}
else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){
- if(priv->image_path != NULL){
- g_free(priv->image_path);
- }
- priv->image_path = g_value_dup_string(value);
- if(priv->image_path != NULL){
- update_album_art(mitem);
- }
+ g_string_erase(priv->image_path, 0, -1);
+ g_string_overwrite(priv->image_path, 0, g_value_get_string (value));
+ metadata_widget_update_album_art(mitem);
}
}
static void
-update_album_art(MetadataWidget* self){
+metadata_widget_update_album_art(MetadataWidget* self){
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
GdkPixbuf* pixbuf;
- pixbuf = gdk_pixbuf_new_from_file(priv->image_path, NULL);
+ pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
+ g_debug("metadata_widget_update_album_art -> pixbuf from %s",
+ priv->image_path->str);
pixbuf = gdk_pixbuf_scale_simple(pixbuf,60, 60, GDK_INTERP_BILINEAR);
- g_debug("attempting to set the image with path %s", priv->image_path);
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->album_art), pixbuf);
g_object_unref(pixbuf);
}
// TODO refactor next 3 methods into one once the style has been
-// "signed off" by design
static void
-style_artist_text(MetadataWidget* self)
+metadata_widget_style_artist_and_album_label(MetadataWidget* self, GtkLabel* label)
{
- MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
char* markup;
markup = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
- gtk_label_get_text(GTK_LABEL(priv->artist_label)));
- gtk_label_set_markup (GTK_LABEL (priv->artist_label), markup);
- g_free(markup);
+ gtk_label_get_text(GTK_LABEL(label)));
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ g_free(markup);
}
static void
-style_title_text(MetadataWidget* self)
+metadata_widget_style_title_text(MetadataWidget* self)
{
MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
char* markup;
- markup = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>",
+ markup = g_markup_printf_escaped ("<span weight=\"bold\" size=\"small\">%s</span>",
gtk_label_get_text(GTK_LABEL(priv->piece_label)));
gtk_label_set_markup (GTK_LABEL (priv->piece_label), markup);
g_free(markup);
}
-static void
-style_album_text(MetadataWidget* self)
+void
+metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style)
{
- MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
- char* markup;
- markup = g_markup_printf_escaped ("<span size=\"small\">%s</span>",
- gtk_label_get_text(GTK_LABEL(priv->container_label)));
- gtk_label_set_markup (GTK_LABEL (priv->container_label), markup);
- g_free(markup);
+ g_return_if_fail(IS_METADATA_WIDGET(metadata));
+ MetadataWidget* widg = METADATA_WIDGET(metadata);
+ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widg);
+ if(style == NULL){
+ g_warning("metadata_widget_set_style -> style is NULL!");
+ return;
+ }
+ else{
+ g_debug("metadata_widget: about to set the style colours");
+ priv->eight_note_colour = style->fg[GTK_STATE_NORMAL];
+ priv->bevel_colour = style->bg[GTK_STATE_NORMAL];
+ }
}
/**
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 65d881a..166d7f4 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -19,6 +19,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using DBus;
+
[DBus (name = "org.mpris.MediaPlayer2")]
public interface MprisRoot : DBus.Object {
// properties
@@ -89,7 +90,7 @@ public class Mpris2Controller : GLib.Object
this.properties_interface.PropertiesChanged += property_changed_cb;
} catch (DBus.Error e) {
- error("Problems connecting to the session bus - %s", e.message);
+ error("Problems connecting to the session bus - %s", e.message);
}
}
@@ -118,21 +119,40 @@ public class Mpris2Controller : GLib.Object
Value? meta_v = changed_properties.lookup("Metadata");
if(meta_v != null){
- debug("metadata is not empty");
- debug("artist : %s", this.player.Metadata.lookup("artist").get_string());
- this.owner.custom_items[PlayerController.widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
- this.owner.custom_items[PlayerController.widget_order.METADATA].update(this.player.Metadata,
+ GLib.HashTable<string, Value?> changed_updates = clean_metadata();
+
+ //MetadataMenuitem meta = this.owner.custom_items[PlayerController.widget_order.METADATA] as MetadataMenuitem;
+ //meta.reset(MetadataMenuitem.attributes_format());
+ this.owner.custom_items[PlayerController.widget_order.METADATA].reset(MetadataMenuitem.attributes_format());
+ this.owner.custom_items[PlayerController.widget_order.METADATA].update(changed_updates,
MetadataMenuitem.attributes_format());
this.owner.custom_items[PlayerController.widget_order.SCRUB].reset(ScrubMenuitem.attributes_format());
- if((int)this.player.Metadata.lookup("artist").get_string().len() > 0 ||
- (int)this.player.Metadata.lookup("artist").get_string().len() > 0){
- this.owner.custom_items[PlayerController.widget_order.SCRUB].update(this.player.Metadata,
- ScrubMenuitem.attributes_format());
- }
+ this.owner.custom_items[PlayerController.widget_order.SCRUB].update(changed_updates,
+ ScrubMenuitem.attributes_format());
+
(this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem).update_playstate(this.determine_play_state(this.player.PlaybackStatus));
}
}
+
+ private GLib.HashTable<string, Value?> clean_metadata()
+ {
+ GLib.HashTable<string, Value?> changed_updates = this.player.Metadata;
+ Value? artist_v = this.player.Metadata.lookup("xesam:artist");
+ if(artist_v != null){
+ string[] artists = (string[])this.player.Metadata.lookup("xesam:artist");
+ string display_artists = string.joinv(", ", artists);
+ changed_updates.replace("xesam:artist", display_artists);
+ debug("artist : %s", display_artists);
+ }
+ Value? length_v = this.player.Metadata.lookup("mpris:length");
+ if(length_v != null){
+ int64 duration = this.player.Metadata.lookup("mpris:length").get_int64();
+ changed_updates.replace("mpris:length", duration/1000000);
+ }
+ return changed_updates;
+ }
+
private int determine_play_state(string status){
if(status == null)
@@ -157,9 +177,10 @@ public class Mpris2Controller : GLib.Object
debug("initial update - play state %i", status);
(this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(status);
- this.owner.custom_items[PlayerController.widget_order.METADATA].update(this.player.Metadata,
+ GLib.HashTable<string, Value?> cleaned_metadata = this.clean_metadata();
+ this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
MetadataMenuitem.attributes_format());
- this.owner.custom_items[PlayerController.widget_order.SCRUB].update(this.player.Metadata,
+ this.owner.custom_items[PlayerController.widget_order.SCRUB].update(cleaned_metadata,
ScrubMenuitem.attributes_format());
}
@@ -202,25 +223,25 @@ public class Mpris2Controller : GLib.Object
public void set_position(double position)
{
debug("Set position with pos (0-100) %f", position);
- HashTable<string, Value?> data = this.player.Metadata;
- Value? time_value = data.lookup("time");
+ Value? time_value = this.player.Metadata.lookup("mpris:length");
if(time_value == null){
warning("Can't fetch the duration of the track therefore cant set the position");
return;
}
- // work in microseconds (scale up by 10 TTP-of 3)
- uint32 total_time = time_value.get_uint() * 1000;
+ // work in microseconds (scale up by 10 TTP-of 6)
+ int64 total_time = time_value.get_int64();
debug("total time of track = %i", (int)total_time);
- double new_time_position = total_time * position/100.0;
+ double new_time_position = total_time * (position/100.0);
debug("new position = %f", (new_time_position));
- Value? v = this.player.Metadata.lookup("trackid");
+ Value? v = this.player.Metadata.lookup("mpris:trackid");
if(v != null){
if(v.holds (typeof (string))){
- debug("the trackid = %s", v.get_string());
DBus.ObjectPath path = new ObjectPath(v.get_string());
try{
- //this.player.SetPosition(path, (int64)(new_time_position));
+ this.player.SetPosition(path, (int64)(new_time_position));
+ ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
+ scrub.update_position(((int32)new_time_position) / 1000);
}
catch(DBus.Error e){
error("DBus Error calling the player objects SetPosition method %s",
diff --git a/src/player-item.vala b/src/player-item.vala
index e5d8bfc..fbfacbd 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -60,7 +60,7 @@ public class PlayerItem : Dbusmenu.Menuitem
string update = v.get_string().strip();
debug("with value : %s", update);
// Special case for the arturl URI's.
- if(property.contains("arturl")){
+ if(property.contains("mpris:artUrl")){
try{
update = Filename.from_uri(update.strip());
}
@@ -74,9 +74,9 @@ public class PlayerItem : Dbusmenu.Menuitem
debug("with value : %i", v.get_int());
this.property_set_int(property, v.get_int());
}
- else if (v.holds (typeof (uint))){
- debug("with value : %i", (int)v.get_uint());
- this.property_set_int(property, (int)v.get_uint());
+ else if (v.holds (typeof (int64))){
+ debug("with value : %i", (int)v.get_int64());
+ this.property_set_int(property, (int)v.get_int64());
}
else if(v.holds (typeof (bool))){
debug("with value : %s", v.get_boolean().to_string());
@@ -92,8 +92,9 @@ public class PlayerItem : Dbusmenu.Menuitem
public bool populated(HashSet<string> attrs)
{
foreach(string prop in attrs){
+ debug("populated ? - prop: %s", prop);
int value_int = property_get_int(prop);
- debug("populate - prop %s and value %i", prop, value_int);
+ debug("populated ? - prop %s and value %i", prop, value_int);
if(property_get_int(prop) != EMPTY){
return true;
}
diff --git a/src/scrub-menu-item.vala b/src/scrub-menu-item.vala
index 7368a0c..d7b60a0 100644
--- a/src/scrub-menu-item.vala
+++ b/src/scrub-menu-item.vala
@@ -42,7 +42,7 @@ public class ScrubMenuitem : PlayerItem
public void update_playstate(int state)
{
- this.property_set_int(MENUITEM_PLAY_STATE, state);
+ this.property_set_int(MENUITEM_PLAY_STATE, state);
}
public static HashSet<string> attributes_format()
diff --git a/src/title-widget.c b/src/title-widget.c
index 8037eb7..7e73f7e 100644
--- a/src/title-widget.c
+++ b/src/title-widget.c
@@ -49,10 +49,6 @@ static void title_widget_finalize (GObject *object);
// keyevent consumers
static gboolean title_widget_button_press_event (GtkWidget *menuitem,
GdkEventButton *event);
-static gboolean title_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event);
-static gboolean title_widget_expose_event(GtkWidget* widget,
- GdkEventExpose* event);
// Dbusmenuitem properties update callback
static void title_widget_property_update(DbusmenuMenuitem* item, gchar* property,
@@ -72,8 +68,6 @@ title_widget_class_init (TitleWidgetClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->button_press_event = title_widget_button_press_event;
- widget_class->button_release_event = title_widget_button_release_event;
- widget_class->expose_event = title_widget_expose_event;
g_type_class_add_private (klass, sizeof (TitleWidgetPrivate));
@@ -124,24 +118,7 @@ title_widget_button_press_event (GtkWidget *menuitem,
g_value_set_boolean(&value, TRUE);
dbusmenu_menuitem_handle_event (priv->twin_item, "Title menu event", &value, 0);
- return TRUE;
-}
-
-static gboolean
-title_widget_button_release_event (GtkWidget *menuitem,
- GdkEventButton *event)
-{
- g_debug("TitleWidget::menu_release_event");
- return TRUE;
-}
-
-static gboolean
-title_widget_expose_event(GtkWidget* widget, GdkEventExpose* event)
-{
- TitleWidgetPrivate * priv = TITLE_WIDGET_GET_PRIVATE(widget);
-
- gtk_container_propagate_expose(GTK_CONTAINER(widget), priv->hbox, event);
- return TRUE;
+ return FALSE;
}
static void