]> git.tdb.fi Git - ext/subsurface.git/blobdiff - gtk-gui.c
Fix an off-by-one error in buffer allocation
[ext/subsurface.git] / gtk-gui.c
index 4e5b9edfb8b00405508727176bbabd6b564d8874..ac80a47f41b5f2f848f08949e0f715e7fa7fa962 100644 (file)
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -21,6 +21,8 @@ GtkWidget *main_vbox;
 GtkWidget *error_info_bar;
 GtkWidget *error_label;
 GtkWidget *vpane, *hpane;
+GtkWidget *notebook;
+
 int        error_count;
 
 const char *divelist_font;
@@ -221,7 +223,7 @@ static gboolean ask_save_changes()
                label = gtk_label_new (
                        "You have unsaved changes\nWould you like to save those before exiting the program?");
        } else {
-               char *label_text = (char*) malloc(sizeof(char) * (92 + strlen(existing_filename)));
+               char *label_text = (char*) malloc(sizeof(char) * (93 + strlen(existing_filename)));
                sprintf(label_text,
                        "You have unsaved changes to file: %s \nWould you like to save those before exiting the program?",
                        existing_filename);
@@ -662,10 +664,14 @@ static void view_info(GtkWidget *w, gpointer data)
 static void view_three(GtkWidget *w, gpointer data)
 {
        GtkAllocation alloc;
+       GtkRequisition requisition;
+
        gtk_widget_get_allocation(hpane, &alloc);
        gtk_paned_set_position(GTK_PANED(hpane), alloc.width/2);
        gtk_widget_get_allocation(vpane, &alloc);
-       gtk_paned_set_position(GTK_PANED(vpane), alloc.height/2);
+       gtk_widget_size_request(notebook, &requisition);
+       /* pick the requested size for the notebook plus 6 pixels for frame */
+       gtk_paned_set_position(GTK_PANED(vpane), requisition.height + 6);
 }
 
 static GtkActionEntry menu_items[] = {
@@ -750,7 +756,6 @@ static void switch_page(GtkNotebook *notebook, gint arg1, gpointer user_data)
 void init_ui(int *argcp, char ***argvp)
 {
        GtkWidget *win;
-       GtkWidget *notebook;
        GtkWidget *nb_page;
        GtkWidget *dive_list;
        GtkWidget *menubar;