ocarina: Pack tag labels into a scrolled window

I don't like the main window resizing, so we allow the users to scroll
if the tags take up too much space.
This commit is contained in:
Bryan Schumaker 2011-11-07 19:43:09 -05:00
parent 30246df924
commit 3fe03734a1
2 changed files with 24 additions and 10 deletions

View File

@ -37,8 +37,8 @@ static void make_controls()
controls = gtk_vbox_new(FALSE, 0);
gtk_widget_show(controls);
box_pack_start(controls, make_top_row(), FALSE, FALSE, 0);
box_pack_start(controls, make_bottom_row(), FALSE, FALSE, 0);
box_pack_start(controls, make_top_row(), TRUE, FALSE, 0);
box_pack_start(controls, make_bottom_row(), TRUE, FALSE, 0);
}
GtkWidget *get_controls()

View File

@ -37,10 +37,24 @@ static GtkWidget *align(GtkWidget *label)
return alignment;
}
static void make_nowplaying()
static GtkWidget *setup_window()
{
GtkWidget *tag_box = gtk_vbox_new(FALSE, 0);
now_playing = gtk_hbox_new(FALSE, 0);
GtkWidget *viewport = gtk_viewport_new(NULL, NULL);
now_playing = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(now_playing),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER);
gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
container_add(now_playing, viewport);
return viewport;
}
static void make_now_playing()
{
GtkWidget *tag_box = gtk_vbox_new(FALSE, 0);
GtkWidget *container = setup_window();
title = gtk_label_new("");
artist = gtk_label_new("");
@ -50,18 +64,18 @@ static void make_nowplaying()
set_artist(" ");
set_album(" ");
box_pack_start(tag_box, align(title), FALSE, FALSE, 0);
box_pack_start(tag_box, align(artist), FALSE, FALSE, 0);
box_pack_start(tag_box, align(album), FALSE, FALSE, 0);
box_pack_start(tag_box, align(title), TRUE, FALSE, 0);
box_pack_start(tag_box, align(artist), TRUE, FALSE, 0);
box_pack_start(tag_box, align(album), TRUE, FALSE, 0);
box_pack_start(now_playing, tag_box, FALSE, FALSE, 0);
container_add(container, tag_box);
gtk_widget_show_all(now_playing);
}
GtkWidget *get_nowplaying()
{
if (now_playing == NULL)
make_nowplaying();
make_now_playing();
return now_playing;
}