aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-04-23 12:01:33 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2014-04-23 12:01:33 +0200
commit3c5e4d8c433a7998f5b6693cdaf20592385e4e1f (patch)
tree3f6aa448cb1119802435957b95c6c68c6a915a50
parent560f93326a73ecfd8f0a907fe7264c2e641d1260 (diff)
downloadayatana-ido-3c5e4d8c433a7998f5b6693cdaf20592385e4e1f.tar.gz
ayatana-ido-3c5e4d8c433a7998f5b6693cdaf20592385e4e1f.tar.bz2
ayatana-ido-3c5e4d8c433a7998f5b6693cdaf20592385e4e1f.zip
idomediaplayermenuitem: don't hardcode width
To ensure a sane width and avoid changing width when the track changes, give track info labels a natural and maximum width of 25 characters.
-rw-r--r--src/idomediaplayermenuitem.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/idomediaplayermenuitem.c b/src/idomediaplayermenuitem.c
index 9b96d37..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);