diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2014-04-23 17:03:27 +0000 |
---|---|---|
committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-04-23 17:03:27 +0000 |
commit | bc444da6f7a8b1047f435cb8781f744908940953 (patch) | |
tree | 3cae52953e3446e373522bca2ccc056a4779d1dd /src/idomediaplayermenuitem.c | |
parent | c734bb8957cc463709f92bb2b9832f365b0f70d0 (diff) | |
parent | 82c094a569863dfd8600f2a5c596706450fa4d48 (diff) | |
download | ayatana-ido-bc444da6f7a8b1047f435cb8781f744908940953.tar.gz ayatana-ido-bc444da6f7a8b1047f435cb8781f744908940953.tar.bz2 ayatana-ido-bc444da6f7a8b1047f435cb8781f744908940953.zip |
Make long track infos better readable
By (a) making the width of the menu slightly larger and (b) reducing the font size.
Also removes the hard-coded width of 200px in favor of a width based on font size (25 characters) and center the playback widget horizontally. Fixes: 1080076
Diffstat (limited to 'src/idomediaplayermenuitem.c')
-rw-r--r-- | src/idomediaplayermenuitem.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/src/idomediaplayermenuitem.c b/src/idomediaplayermenuitem.c index 7e6e9d3..7ed9d6d 100644 --- a/src/idomediaplayermenuitem.c +++ b/src/idomediaplayermenuitem.c @@ -102,14 +102,6 @@ ido_media_player_menu_item_draw (GtkWidget *widget, } static void -ido_media_player_menu_item_get_preferred_width (GtkWidget *widget, - gint *minimum, - gint *natural) -{ - *minimum = *natural = 200; -} - -static void ido_media_player_menu_item_class_init (IdoMediaPlayerMenuItemClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -117,10 +109,24 @@ ido_media_player_menu_item_class_init (IdoMediaPlayerMenuItemClass *klass) object_class->dispose = ido_media_player_menu_item_dispose; - widget_class->get_preferred_width = ido_media_player_menu_item_get_preferred_width; widget_class->draw = ido_media_player_menu_item_draw; } +static GtkWidget * +track_info_label_new () +{ + GtkWidget *label; + + label = gtk_label_new (NULL); + gtk_label_set_width_chars (GTK_LABEL (label), 25); + gtk_label_set_max_width_chars (GTK_LABEL (label), 25); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE); + + return label; +} + static void ido_media_player_menu_item_init (IdoMediaPlayerMenuItem *self) { @@ -140,19 +146,12 @@ ido_media_player_menu_item_init (IdoMediaPlayerMenuItem *self) gtk_widget_set_size_request (self->album_art, ALBUM_ART_SIZE, ALBUM_ART_SIZE); gtk_widget_set_margin_right (self->album_art, 8); - self->artist_label = gtk_label_new (NULL); - gtk_widget_set_halign (self->artist_label, GTK_ALIGN_START); - gtk_label_set_ellipsize (GTK_LABEL (self->artist_label), PANGO_ELLIPSIZE_MIDDLE); + self->artist_label = track_info_label_new (); + self->piece_label = track_info_label_new (); - self->piece_label = gtk_label_new (NULL); - gtk_widget_set_halign (self->piece_label, GTK_ALIGN_START); - gtk_label_set_ellipsize (GTK_LABEL (self->piece_label), PANGO_ELLIPSIZE_MIDDLE); - - self->container_label = gtk_label_new (NULL); - gtk_widget_set_halign (self->container_label, GTK_ALIGN_START); - gtk_widget_set_valign (self->container_label, GTK_ALIGN_START); + self->container_label = track_info_label_new (); gtk_widget_set_vexpand (self->container_label, TRUE); - gtk_label_set_ellipsize (GTK_LABEL (self->container_label), PANGO_ELLIPSIZE_MIDDLE); + gtk_widget_set_valign (self->container_label, GTK_ALIGN_START); self->metadata_widget = gtk_grid_new (); gtk_grid_attach (GTK_GRID (self->metadata_widget), self->album_art, 0, 0, 1, 4); @@ -274,6 +273,22 @@ ido_media_player_menu_item_set_album_art (IdoMediaPlayerMenuItem *self, } static void +gtk_label_set_markup_printf_escaped (GtkLabel *label, + const gchar *format, + ...) +{ + va_list args; + gchar *str; + + va_start (args, format); + str = g_markup_vprintf_escaped (format, args); + gtk_label_set_markup (label, str); + va_end (args); + + g_free (str); +} + +static void ido_media_player_menu_item_set_metadata (IdoMediaPlayerMenuItem *self, const gchar *title, const gchar *artist, @@ -293,9 +308,9 @@ ido_media_player_menu_item_set_metadata (IdoMediaPlayerMenuItem *self, } else { - gtk_label_set_label (GTK_LABEL (self->piece_label), title); - gtk_label_set_label (GTK_LABEL (self->artist_label), artist); - gtk_label_set_label (GTK_LABEL (self->container_label), album); + gtk_label_set_markup_printf_escaped (GTK_LABEL (self->piece_label), "<small>%s</small>", title); + gtk_label_set_markup_printf_escaped (GTK_LABEL (self->artist_label), "<small>%s</small>", artist); + gtk_label_set_markup_printf_escaped (GTK_LABEL (self->container_label), "<small>%s</small>", album); ido_media_player_menu_item_set_album_art (self, art_url); gtk_widget_show (self->metadata_widget); } |