]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Merge hbonse's UI tweaks, but fixing the compile warnings. Also bringing it up to...
authorNathan Samson <nathansamson@gmail.com>
Sun, 4 Sep 2011 20:15:55 +0000 (22:15 +0200)
committerNathan Samson <nathansamson@gmail.com>
Sun, 4 Sep 2011 20:15:55 +0000 (22:15 +0200)
Signed-off-by: Nathan Samson <nathansamson@gmail.com>
1  2 
info.c
main.c

diff --combined info.c
index beadda0a5d679e856a0c79099bac3f7cfe9828ce,62a72e1405815ba958eac8a1b1e3db4b0f47a4c7..c3b51409155c8d42202be54a9b88d46a1f371376
--- 1/info.c
--- 2/info.c
+++ b/info.c
@@@ -7,7 -7,8 +7,8 @@@
  #include "display.h"
  
  static GtkWidget *divedate, *divetime, *depth, *duration, *temperature, *locationnote;
- static GtkTextBuffer *location, *notes;
+ static GtkEntry *location;
+ static GtkTextBuffer *notes;
  static int location_changed = 1, notes_changed = 1;
  static struct dive *buffered_dive;
  
@@@ -38,7 -39,7 +39,7 @@@ void flush_dive_info_changes(void
  
        if (location_changed) {
                g_free(dive->location);
-               dive->location = get_text(location);
+               dive->location = gtk_editable_get_chars(GTK_EDITABLE(location), 0, -1);
        }
  
        if (notes_changed) {
@@@ -94,7 -95,7 +95,7 @@@ void update_dive_info(struct dive *dive
        gtk_label_set_text(GTK_LABEL(temperature), buffer);
  
        text = dive->location ? : "";
-       gtk_text_buffer_set_text(location, text, -1);
+       gtk_entry_set_text(location, text);
        gtk_label_set_text(GTK_LABEL(locationnote), text);
  
        text = dive->notes ? : "";
@@@ -118,15 -119,15 +119,15 @@@ GtkWidget *dive_info_frame(void
        frame = gtk_frame_new("Dive info");
        gtk_widget_show(frame);
  
--      vbox = gtk_vbox_new(TRUE, 5);
++      vbox = gtk_vbox_new(TRUE, 6);
        gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
  
--      hbox = gtk_hbox_new(TRUE, 5);
++      hbox = gtk_hbox_new(TRUE, 6);
        gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
        gtk_container_add(GTK_CONTAINER(vbox), hbox);
  
--      hbox2 = gtk_hbox_new(FALSE, 0);
++      hbox2 = gtk_hbox_new(FALSE, 6);
        gtk_container_set_border_width(GTK_CONTAINER(hbox2), 3);
        gtk_container_add(GTK_CONTAINER(vbox), hbox2);
  
        return frame;
  }
  
- static GtkTextBuffer *text_entry(GtkWidget *box, const char *label, gboolean expand)
+ static GtkEntry *text_entry(GtkWidget *box, const char *label)
+ {
+       GtkWidget *entry;
+       GtkWidget *frame = gtk_frame_new(label);
+       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
+       entry = gtk_entry_new ();
+       gtk_container_add(GTK_CONTAINER(frame), entry);
+       return GTK_ENTRY(entry);
+ }
+ static GtkTextBuffer *text_view(GtkWidget *box, const char *label, gboolean expand)
  {
        GtkWidget *view;
        GtkTextBuffer *buffer;
        gtk_box_pack_start(GTK_BOX(box), frame, expand, expand, 0);
  
        GtkWidget* scrolled_window = gtk_scrolled_window_new (0, 0);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN);
        gtk_widget_show(scrolled_window);
  
        view = gtk_text_view_new ();
+       gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
        gtk_container_add(GTK_CONTAINER(scrolled_window), view);
  
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
        return buffer;
  }
  
- GtkWidget *extended_dive_info_box(void)
+ GtkWidget *extended_dive_info_widget(void)
  {
        GtkWidget *vbox;
 -      vbox = gtk_vbox_new(FALSE, 5);
 +      vbox = gtk_vbox_new(FALSE, 6);
  
-       location = text_entry(vbox, "Location", FALSE);
+       location = text_entry(vbox, "Location");
 +      gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
-       notes = text_entry(vbox, "Notes", TRUE);
+       notes = text_view(vbox, "Notes", TRUE);
  
        /* Add extended info here: name, description, yadda yadda */
        update_dive_info(current_dive);
diff --combined main.c
index 99c4b6f2a104f0838ff07fe9a7b210b23206f02a,57c8f70e66a92a67c22c263a9c2ca737e378313a..b2fa6173e1f84542e8a290038f941fc394242b3b
--- 1/main.c
--- 2/main.c
+++ b/main.c
@@@ -134,7 -134,7 +134,7 @@@ static void quit(GtkWidget *w, gpointe
  }
  
  static GtkActionEntry menu_items[] = {
 -      { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
 +      { "FileMenuAction", GTK_STOCK_FILE, "Log", NULL, NULL, NULL},
        { "OpenFile",       GTK_STOCK_OPEN, NULL,   "<control>O", NULL, G_CALLBACK(file_open) },
        { "SaveFile",       GTK_STOCK_SAVE, NULL,   "<control>S", NULL, G_CALLBACK(file_save) },
        { "Quit",           GTK_STOCK_QUIT, NULL,   "<control>Q", NULL, G_CALLBACK(quit) },
@@@ -147,7 -147,6 +147,7 @@@ static const gchar* ui_string = " 
                        <menu name=\"FileMenu\" action=\"FileMenuAction\"> \
                                <menuitem name=\"Open\" action=\"OpenFile\" /> \
                                <menuitem name=\"Save\" action=\"SaveFile\" /> \
 +                              <separator name=\"Seperator\"/> \
                                <menuitem name=\"Quit\" action=\"Quit\" /> \
                        </menu> \
                </menubar> \
@@@ -175,10 -174,11 +175,11 @@@ int main(int argc, char **argv
        int i;
        GtkWidget *win;
        GtkWidget *divelist;
-       GtkWidget *table;
+       GtkWidget *paned;
+       GtkWidget *info_box;
        GtkWidget *notebook;
-       GtkWidget *box;
        GtkWidget *frame;
+       GtkWidget *dive_info;
        GtkWidget *menubar;
        GtkWidget *vbox;
  
        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_table_set_col_spacings(GTK_TABLE(table), 6);
-       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);
++      info_box = gtk_vbox_new(FALSE, 6);
+       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, 6, 6);
 -      gtk_box_pack_start(GTK_BOX(info_box), frame, FALSE, TRUE, 5);
++      gtk_box_pack_start(GTK_BOX(info_box), frame, FALSE, TRUE, 6);
  
        /* Notebook for dive info vs profile vs .. */
        notebook = gtk_notebook_new();
-       gtk_table_attach(GTK_TABLE(table), notebook, 1, 2, 1, 2,
-               GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 6, 6);
 -      gtk_box_pack_start(GTK_BOX(info_box), notebook, TRUE, TRUE, 5);
++      gtk_box_pack_start(GTK_BOX(info_box), notebook, TRUE, TRUE, 6);
  
        /* 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 */
-       box = extended_dive_info_box();
-       gtk_notebook_append_page(GTK_NOTEBOOK(notebook), box, 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_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);