]> git.tdb.fi Git - ext/subsurface.git/blobdiff - gtk-gui.c
Some simple test dives for the trips code
[ext/subsurface.git] / gtk-gui.c
index 5bc46d2190248be4c7a7c68b121c2766258b9f0b..f9cc8e674914cdec2985ce9f91b049d7d34d4f50 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;
@@ -173,7 +175,7 @@ static void file_open(GtkWidget *w, gpointer data)
 static void file_save_as(GtkWidget *w, gpointer data)
 {
        GtkWidget *dialog;
-       char *filename;
+       char *filename = NULL;
        dialog = gtk_file_chooser_dialog_new("Save File As",
                GTK_WINDOW(main_window),
                GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -387,6 +389,7 @@ OPTIONCALLBACK(temperature_toggle, visible_cols.temperature)
 OPTIONCALLBACK(totalweight_toggle, visible_cols.totalweight)
 OPTIONCALLBACK(suit_toggle, visible_cols.suit)
 OPTIONCALLBACK(cylinder_toggle, visible_cols.cylinder)
+OPTIONCALLBACK(autogroup_toggle, autogroup)
 
 static void event_toggle(GtkWidget *w, gpointer _data)
 {
@@ -482,8 +485,22 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(suit_toggle), NULL);
 
+       frame = gtk_frame_new("Divelist Font");
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
+
        font = gtk_font_button_new_with_font(divelist_font);
-       gtk_box_pack_start(GTK_BOX(vbox), font, FALSE, FALSE, 5);
+       gtk_container_add(GTK_CONTAINER(frame),font);
+
+       frame = gtk_frame_new("Misc. Options");
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
+
+       box = gtk_hbox_new(FALSE, 6);
+       gtk_container_add(GTK_CONTAINER(frame), box);
+
+       button = gtk_check_button_new_with_label("Automatically group dives in trips");
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), autogroup);
+       gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
+       g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(autogroup_toggle), NULL);
 
        gtk_widget_show_all(dialog);
        result = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -512,6 +529,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
                subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac));
                subsurface_set_conf("OTU", PREF_BOOL, BOOL_TO_PTR(visible_cols.otu));
                subsurface_set_conf("divelist_font", PREF_STRING, divelist_font);
+               subsurface_set_conf("autogroup", PREF_BOOL, BOOL_TO_PTR(autogroup));
 
                /* Flush the changes out to the system */
                subsurface_flush_conf();
@@ -662,10 +680,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,11 +772,11 @@ 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;
        GtkWidget *vbox;
+       GtkWidget *scrolled;
        GdkScreen *screen;
        GtkIconTheme *icon_theme=NULL;
        GtkSettings *settings;
@@ -788,6 +810,8 @@ void init_ui(int *argcp, char ***argvp)
 
        divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);
 
+       autogroup = PTR_TO_BOOL(subsurface_get_conf("autogroup", PREF_BOOL));
+
        default_dive_computer_vendor = subsurface_get_conf("dive_computer_vendor", PREF_STRING);
        default_dive_computer_product = subsurface_get_conf("dive_computer_product", PREF_STRING);
        default_dive_computer_device = subsurface_get_conf("dive_computer_device", PREF_STRING);
@@ -826,13 +850,16 @@ void init_ui(int *argcp, char ***argvp)
 
        vpane = gtk_vpaned_new();
        gtk_box_pack_start(GTK_BOX(vbox), vpane, TRUE, TRUE, 3);
-
        hpane = gtk_hpaned_new();
        gtk_paned_add1(GTK_PANED(vpane), hpane);
+       g_signal_connect_after(G_OBJECT(vbox), "realize", G_CALLBACK(view_three), NULL);
 
        /* Notebook for dive info vs profile vs .. */
        notebook = gtk_notebook_new();
-       gtk_paned_add1(GTK_PANED(hpane), notebook);
+       scrolled = gtk_scrolled_window_new(NULL, NULL);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+       gtk_paned_add1(GTK_PANED(hpane), scrolled);
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), notebook);
        g_signal_connect(notebook, "switch-page", G_CALLBACK(switch_page), NULL);
 
        /* Create the actual divelist */