From 1117cd37d71e294069a670bdf0851041575e0d5f Mon Sep 17 00:00:00 2001 From: Nathan Samson Date: Sun, 4 Sep 2011 18:54:12 +0200 Subject: Use a pane so the dive list can be made wider or smaller to the users wishes Signed-off-by: Nathan Samson --- main.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index c9cda2b47..b748f693b 100644 --- a/main.c +++ b/main.c @@ -174,7 +174,8 @@ int main(int argc, char **argv) int i; GtkWidget *win; GtkWidget *divelist; - GtkWidget *table; + GtkWidget *paned; + GtkWidget *info_box; GtkWidget *notebook; GtkWidget *frame; GtkWidget *menubar; @@ -206,25 +207,25 @@ int main(int argc, char **argv) menubar = get_menubar_menu(win); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); - /* Table for the list of dives, cairo window, and dive info */ - table = gtk_table_new(2, 2, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(table), 5); - gtk_box_pack_end(GTK_BOX(vbox), table, TRUE, TRUE, 0); - gtk_widget_show(table); + /* HPane for left the dive list, and right the dive info */ + paned = gtk_hpaned_new(); + gtk_box_pack_end(GTK_BOX(vbox), paned, TRUE, TRUE, 0); /* Create the atual divelist */ divelist = create_dive_list(); - gtk_table_attach(GTK_TABLE(table), divelist, 0, 1, 0, 2, - 0, GTK_FILL | GTK_SHRINK | GTK_EXPAND, 0, 0); + gtk_paned_add1(GTK_PANED(paned), divelist); + + /* VBox for dive info, and tabs */ + info_box = gtk_vbox_new(FALSE, 5); + gtk_paned_add2(GTK_PANED(paned), info_box); /* Frame for minimal dive info */ frame = dive_info_frame(); - gtk_table_attach(GTK_TABLE(table), frame, 1, 2, 0, 1, - GTK_FILL | GTK_SHRINK | GTK_EXPAND, 0, 0, 0); + gtk_box_pack_start(GTK_BOX(info_box), frame, FALSE, TRUE, 5); /* Notebook for dive info vs profile vs .. */ notebook = gtk_notebook_new(); - gtk_table_attach_defaults(GTK_TABLE(table), notebook, 1, 2, 1, 2); + gtk_box_pack_start(GTK_BOX(info_box), notebook, TRUE, TRUE, 5); /* Frame for dive profile */ frame = dive_profile_frame(); -- cgit v1.2.3-70-g09d2 From 6138d151e9156bdf15843b1b54104428c5124e38 Mon Sep 17 00:00:00 2001 From: Nathan Samson Date: Sun, 4 Sep 2011 19:01:30 +0200 Subject: Remove the redundant frames in the notebook. Closes #9 Signed-off-by: Nathan Samson --- display.h | 4 ++-- info.c | 9 ++------- main.c | 10 +++++----- profile.c | 8 ++------ 4 files changed, 11 insertions(+), 20 deletions(-) (limited to 'main.c') diff --git a/display.h b/display.h index f336bd5ec..96fa29a5d 100644 --- a/display.h +++ b/display.h @@ -8,9 +8,9 @@ extern int selected_dive; #define current_dive (get_dive(selected_dive)) -extern GtkWidget *dive_profile_frame(void); +extern GtkWidget *dive_profile_widget(void); extern GtkWidget *dive_info_frame(void); -extern GtkWidget *extended_dive_info_frame(void); +extern GtkWidget *extended_dive_info_widget(void); extern GtkWidget *create_dive_list(void); extern void update_dive_info(struct dive *dive); extern void repaint_dive(void); diff --git a/info.c b/info.c index 55708bedf..4275ad6ff 100644 --- a/info.c +++ b/info.c @@ -164,21 +164,16 @@ static GtkTextBuffer *text_entry(GtkWidget *box, const char *label, gboolean exp return buffer; } -GtkWidget *extended_dive_info_frame(void) +GtkWidget *extended_dive_info_widget(void) { - GtkWidget *frame; GtkWidget *vbox; - frame = gtk_frame_new("Extended dive info"); - gtk_widget_show(frame); - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(frame), vbox); location = text_entry(vbox, "Location", FALSE); notes = text_entry(vbox, "Notes", TRUE); /* Add extended info here: name, description, yadda yadda */ update_dive_info(current_dive); - return frame; + return vbox; } diff --git a/main.c b/main.c index b748f693b..57c8f70e6 100644 --- a/main.c +++ b/main.c @@ -178,6 +178,7 @@ int main(int argc, char **argv) GtkWidget *info_box; GtkWidget *notebook; GtkWidget *frame; + GtkWidget *dive_info; GtkWidget *menubar; GtkWidget *vbox; @@ -228,13 +229,12 @@ int main(int argc, char **argv) gtk_box_pack_start(GTK_BOX(info_box), notebook, TRUE, TRUE, 5); /* Frame for dive profile */ - frame = dive_profile_frame(); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame, gtk_label_new("Dive Profile")); - dive_profile = frame; + dive_profile = dive_profile_widget(); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dive_profile, gtk_label_new("Dive Profile")); /* Frame for extended dive info */ - frame = extended_dive_info_frame(); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame, gtk_label_new("Extended dive Info")); + dive_info = extended_dive_info_widget(); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dive_info, gtk_label_new("Extended dive Info")); gtk_widget_set_app_paintable(win, TRUE); gtk_widget_show_all(win); diff --git a/profile.c b/profile.c index 7a0a20828..070e6fa70 100644 --- a/profile.c +++ b/profile.c @@ -195,17 +195,13 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer return FALSE; } -GtkWidget *dive_profile_frame(void) +GtkWidget *dive_profile_widget(void) { - GtkWidget *frame; GtkWidget *da; - frame = gtk_frame_new("Dive profile"); - gtk_widget_show(frame); da = gtk_drawing_area_new(); gtk_widget_set_size_request(da, 450, 350); g_signal_connect(da, "expose_event", G_CALLBACK(expose_event), NULL); - gtk_container_add(GTK_CONTAINER(frame), da); - return frame; + return da; } -- cgit v1.2.3-70-g09d2