From e18c4734744e56b738ca2918dffe071f95f4c14b Mon Sep 17 00:00:00 2001 From: Richard Kettlewell Date: Sun, 20 Apr 2008 10:34:52 +0100 Subject: [PATCH] Put a frame around user management window (and the other popups) and improve internal spacing a bit. --- disobedience/disobedience.h | 2 ++ disobedience/login.c | 2 +- disobedience/misc.c | 18 ++++++++++++++++++ disobedience/properties.c | 2 +- disobedience/settings.c | 2 +- disobedience/users.c | 15 +++++++++------ 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/disobedience/disobedience.h b/disobedience/disobedience.h index 4885c8e..ccb9acc 100644 --- a/disobedience/disobedience.h +++ b/disobedience/disobedience.h @@ -143,6 +143,8 @@ void properties_reset(void); GtkWidget *scroll_widget(GtkWidget *child); /* Wrap a widget up for scrolling */ +GtkWidget *frame_widget(GtkWidget *w, const char *title); + GdkPixbuf *find_image(const char *name); /* Get the pixbuf for an image. Returns a null pointer if it cannot be * found. */ diff --git a/disobedience/login.c b/disobedience/login.c index f5ef053..18afce4 100644 --- a/disobedience/login.c +++ b/disobedience/login.c @@ -234,7 +234,7 @@ void login_box(void) { TRUE/*expand*/, TRUE/*fill*/, 1/*padding*/); gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE/*expand*/, FALSE/*fill*/, 1/*padding*/); - gtk_container_add(GTK_CONTAINER(login_window), vbox); + gtk_container_add(GTK_CONTAINER(login_window), frame_widget(vbox, NULL)); gtk_window_set_transient_for(GTK_WINDOW(login_window), GTK_WINDOW(toplevel)); gtk_widget_show_all(login_window); diff --git a/disobedience/misc.c b/disobedience/misc.c index ce58ab4..1e5ee22 100644 --- a/disobedience/misc.c +++ b/disobedience/misc.c @@ -73,6 +73,24 @@ GtkWidget *scroll_widget(GtkWidget *child) { return scroller; } +/** @brief Put a frame round a widget + * @param w Widget + * @param label Label or NULL + * @return Frame widget + */ +GtkWidget *frame_widget(GtkWidget *w, const char *label) { + GtkWidget *const frame = gtk_frame_new(label); + GtkWidget *const hbox = gtk_hbox_new(FALSE, 0); + GtkWidget *const vbox = gtk_vbox_new(FALSE, 0); + /* We want 4 pixels outside the frame boundary... */ + gtk_container_set_border_width(GTK_CONTAINER(frame), 4); + /* ...and 4 pixels inside */ + gtk_box_pack_start(GTK_BOX(hbox), w, TRUE/*expand*/, TRUE/*fill*/, 4); + gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE/*expand*/, TRUE/*fill*/, 4); + gtk_container_add(GTK_CONTAINER(frame), vbox); + return frame; +} + /** @brief Find an image * @param name Relative path to image * @return pixbuf containing image diff --git a/disobedience/properties.c b/disobedience/properties.c index 24612c7..96d5c48 100644 --- a/disobedience/properties.c +++ b/disobedience/properties.c @@ -271,7 +271,7 @@ void properties(int ntracks, const char **tracks) { scroll_widget(properties_table), TRUE, TRUE, 1); gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, FALSE, 1); - gtk_container_add(GTK_CONTAINER(properties_window), vbox); + gtk_container_add(GTK_CONTAINER(properties_window), frame_widget(vbox, NULL)); /* The table only really wants to be vertically scrollable */ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(GTK_WIDGET(properties_table)->parent->parent), GTK_POLICY_NEVER, diff --git a/disobedience/settings.c b/disobedience/settings.c index ae8990e..3cc4180 100644 --- a/disobedience/settings.c +++ b/disobedience/settings.c @@ -338,7 +338,7 @@ void popup_settings(void) { 1, 1); } } - gtk_container_add(GTK_CONTAINER(settings_window), table); + gtk_container_add(GTK_CONTAINER(settings_window), frame_widget(table, NULL)); gtk_widget_show_all(settings_window); /* TODO: save settings TODO: web browser diff --git a/disobedience/users.c b/disobedience/users.c index f4a0fbe..d162e14 100644 --- a/disobedience/users.c +++ b/disobedience/users.c @@ -641,7 +641,7 @@ void manage_users(void) { users_delete_button = users_buttons[1].widget; /* Buttons live below the list */ - vbox = gtk_vbox_new(FALSE, 2); + vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), scroll_widget(tree), TRUE/*expand*/, TRUE/*fill*/, 0); gtk_box_pack_start(GTK_BOX(vbox), buttons, FALSE/*expand*/, FALSE, 0); @@ -662,11 +662,14 @@ void manage_users(void) { gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE/*expand*/, FALSE, 0); - /* User details are to the right of the list */ - hbox = gtk_hbox_new(FALSE, 2); - gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE/*expand*/, FALSE, 2); - gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE/*expand*/, TRUE/*fill*/, 2); - gtk_container_add(GTK_CONTAINER(users_window), hbox); + /* User details are to the right of the list. We put in a pointless event + * box as as spacer, so that the longest label in the user details isn't + * cuddled up to the user list. */ + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE/*expand*/, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), gtk_event_box_new(), FALSE/*expand*/, FALSE, 2); + gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE/*expand*/, TRUE/*fill*/, 0); + gtk_container_add(GTK_CONTAINER(users_window), frame_widget(hbox, NULL)); } /* -- 2.11.0