From 8e18c860a98b79ba109ad3d133c9db84593f071f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 14 May 2013 10:56:42 -0400 Subject: [PATCH] Arrange tags in a table for dive edit dialog This makes things look nicer and also reduces vertical size of the edit dialog - which should now fit on a 600px display again. Signed-off-by: Dirk Hohndel --- info-gtk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/info-gtk.c b/info-gtk.c index 39325f6f3..cb9d87b7b 100644 --- a/info-gtk.c +++ b/info-gtk.c @@ -611,17 +611,19 @@ static void dive_info_widget(GtkWidget *obox, struct dive *dive, struct dive_inf if (*show_tags) { /* check boxes for the (currently fixed) list of tags; * let's do 5 per row */ + const int cols = 5; + int rows = DTAG_NR / cols + (DTAG_NR % cols) ? 1 : 0; + GtkWidget *table = gtk_table_new(rows, cols, TRUE); for (i = 0; i < DTAG_NR; i++) { - if (i % 5 == 0) { - sbox = gtk_hbox_new(FALSE, 6); - gtk_box_pack_start(GTK_BOX(framebox), sbox, TRUE, FALSE, 3); - } + int x = i % cols; + int y = i / cols; button = gtk_check_button_new_with_label(_(dtag_names[i])); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), dive->dive_tags & (1 << i)); - gtk_box_pack_start(GTK_BOX(sbox), button, FALSE, FALSE, 6); + gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(divetag_toggle_cb), GINT_TO_POINTER(1 << i)); } + gtk_box_pack_start(GTK_BOX(framebox), table, TRUE, FALSE, 3); } else { sbox = gtk_label_new(_("Tags are only shown if they are identical for all edited dives")); gtk_box_pack_start(GTK_BOX(framebox), sbox, TRUE, FALSE, 3);