From cd9b7cc0ef5cb9c181446ddd48fa352791169590 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Fri, 3 Feb 2012 23:34:15 +0000 Subject: [PATCH] Update alert tab packing Set then number of rows to three instead of having a fix number of columns. Hopefully this will be more space efficient. However, it could cause the window to be very wide at times. --- src/plugins/alert.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/plugins/alert.c b/src/plugins/alert.c index 8ac35e0..f4e7c85 100644 --- a/src/plugins/alert.c +++ b/src/plugins/alert.c @@ -25,6 +25,7 @@ #include "alert-info.h" #define MSG_INDEX "http://alerts.weather.gov/cap/us.php?x=0" +#define CONFIG_HEIGHT 3 /* Format for single cap alert: * "http://alerts.weather.gov/cap/wwacapget.php?x=" @@ -684,11 +685,9 @@ static gboolean _update_buttons(GritsPluginAlert *alert) GtkWidget *table = g_object_get_data(G_OBJECT(alerts), alert_info[i].category); GList *kids = gtk_container_get_children(GTK_CONTAINER(table)); - gint nkids = g_list_length(kids); - guint rows, cols; - gtk_table_get_size(GTK_TABLE(table), &rows, &cols); - gint x = nkids % cols; - gint y = nkids / cols; + gint nkids = g_list_length(kids); + gint x = nkids / CONFIG_HEIGHT; + gint y = nkids % CONFIG_HEIGHT; g_list_free(kids); GtkWidget *button = _button_new(&alert_info[i]); @@ -801,11 +800,10 @@ static GtkWidget *_make_config(void) gchar *labels[] = {"Warnings", "Watches", "Advisories", "Other"}; gchar *keys[] = {"warning", "watch", "advisory", "other"}; - gint cols[] = {2, 2, 3, 2}; GtkWidget *alerts = gtk_hbox_new(FALSE, 10); for (int i = 0; i < G_N_ELEMENTS(labels); i++) { GtkWidget *frame = gtk_frame_new(labels[i]); - GtkWidget *table = gtk_table_new(1, cols[i], TRUE); + GtkWidget *table = gtk_table_new(1, 1, TRUE); GtkWidget *label = gtk_frame_get_label_widget(GTK_FRAME(frame)); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); -- 2.43.2