summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk-gui.c21
-rw-r--r--info.c20
-rw-r--r--save-xml.c2
-rw-r--r--windows.c53
4 files changed, 55 insertions, 41 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 0bce10c17..c438be43d 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -330,6 +330,8 @@ void save_window_geometry(void)
gtk_window_get_size(GTK_WINDOW (main_window), &window_width, &window_height);
subsurface_set_conf_int("window_width", window_width);
subsurface_set_conf_int("window_height", window_height);
+ subsurface_set_conf_int("vpane_position", gtk_paned_get_position(GTK_PANED(vpane)));
+ subsurface_set_conf_int("hpane_position", gtk_paned_get_position(GTK_PANED(hpane)));
subsurface_flush_conf();
}
@@ -344,6 +346,8 @@ void restore_window_geometry(void)
window_height == -1 ? window_height = 300 : window_height;
window_width == -1 ? window_width = 700 : window_width;
+ gtk_paned_set_position(GTK_PANED(vpane), subsurface_get_conf_int("vpane_position"));
+ gtk_paned_set_position(GTK_PANED(hpane), subsurface_get_conf_int("hpane_position"));
gtk_window_resize (GTK_WINDOW (main_window), window_width, window_height);
}
@@ -1176,12 +1180,25 @@ static void view_three(GtkWidget *w, gpointer data)
GtkAllocation alloc;
GtkRequisition requisition;
+ int vpane_position = subsurface_get_conf_int("vpane_position");
+ int hpane_position = subsurface_get_conf_int("hpane_position");
+
gtk_widget_get_allocation(hpane, &alloc);
- gtk_paned_set_position(GTK_PANED(hpane), alloc.width/2);
+
+ if(hpane_position && hpane_position != 65535)
+ gtk_paned_set_position(GTK_PANED(hpane), hpane_position);
+ else
+ gtk_paned_set_position(GTK_PANED(hpane), alloc.width/2);
+
gtk_widget_get_allocation(vpane, &alloc);
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);
+ if(vpane_position && vpane_position != 65535)
+ gtk_paned_set_position(GTK_PANED(vpane), vpane_position);
+ else
+ gtk_paned_set_position(GTK_PANED(vpane), requisition.height + 6);
+
+
}
static void toggle_zoom(GtkWidget *w, gpointer data)
diff --git a/info.c b/info.c
index 1a04563ab..c0cbd3e70 100644
--- a/info.c
+++ b/info.c
@@ -868,6 +868,7 @@ static void dive_info_widget(GtkWidget *obox, struct dive *dive, struct dive_inf
info->notes = NULL;
} else {
info->notes = text_view(box, _("Notes"), READ_WRITE);
+ gtk_widget_set_size_request(GTK_WIDGET(info->notes), -1, 128);
if (dive->notes && *dive->notes)
gtk_text_buffer_set_text(gtk_text_view_get_buffer(info->notes), dive->notes, -1);
}
@@ -1046,11 +1047,15 @@ static void update_time_depth(struct dive *dive, struct dive *edited)
int edit_multi_dive_info(struct dive *single_dive)
{
int success;
- GtkWidget *dialog, *vbox;
+ GtkWidget *dialog, *vbox, *scrolled_window, *viewport;
+ GtkRequisition size;
struct dive_info info;
struct dive *master;
gboolean multi;
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
dialog = gtk_dialog_new_with_buttons(_("Dive Info"),
GTK_WINDOW(main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1059,6 +1064,9 @@ int edit_multi_dive_info(struct dive *single_dive)
NULL);
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
+ vbox = g_object_new(GTK_TYPE_VBOX, NULL);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), vbox);
master = single_dive;
if (!master)
master = current_dive;
@@ -1084,9 +1092,17 @@ int edit_multi_dive_info(struct dive *single_dive)
memcpy(&edit_dive, master, sizeof(struct dive));
dive_info_widget(vbox, &edit_dive, &info, multi);
- show_dive_equipment(&edit_dive, W_IDX_SECONDARY);
save_equipment_data(&edit_dive);
gtk_widget_show_all(dialog);
+ viewport = gtk_widget_get_ancestor(vbox, GTK_TYPE_VIEWPORT);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_get_preferred_size(viewport, NULL, &size);
+#else
+ gtk_widget_size_request(viewport, &size);
+#endif
+ gtk_widget_set_size_request(scrolled_window, size.width, size.height);
+ /* add the equipment post the "blank" layout estimate */
+ show_dive_equipment(&edit_dive, W_IDX_SECONDARY);
success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
if (success) {
mark_divelist_changed(TRUE);
diff --git a/save-xml.c b/save-xml.c
index 0685c9fd1..a23fb10a3 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -366,7 +366,7 @@ static void save_sample(FILE *f, struct sample *sample, struct sample *old)
}
if (sample->po2 != old->po2) {
- fprintf(f, " po2='%u.%2u bar'", FRACTION(sample->po2, 1000));
+ show_milli(f, " po2='", sample->po2, " bar", "'");
old->po2 = sample->po2;
}
fprintf(f, " />\n");
diff --git a/windows.c b/windows.c
index 948b1f701..2eed74143 100644
--- a/windows.c
+++ b/windows.c
@@ -9,20 +9,6 @@ const char system_divelist_default_font[] = "Sans 8";
static HKEY hkey;
-/* Return "boolean" 0/1, or -1 if nonexistent */
-static int get_from_registry(HKEY hkey, const char *key)
-{
- DWORD value;
- DWORD len = 4;
- LONG success;
-
- success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL,
- (LPBYTE) &value, (LPDWORD)&len);
- if (success != ERROR_SUCCESS)
- return -1;
- return value != 0;
-}
-
void subsurface_open_conf(void)
{
LONG success;
@@ -36,12 +22,7 @@ void subsurface_open_conf(void)
void subsurface_unset_conf(char *name)
{
- wchar_t *wname;
-
- wname = (wchar_t *)g_utf8_to_utf16(name, -1, NULL, NULL, NULL);
- if (!wname)
- return;
- RegDeleteKey(hkey, (LPCTSTR)wname);
+ RegDeleteKey(hkey, (LPCTSTR)name);
}
void subsurface_set_conf(char *name, const char *value)
@@ -71,22 +52,14 @@ void subsurface_set_conf(char *name, const char *value)
free(wname);
}
-void subsurface_set_conf_bool(char *name, int value)
+void subsurface_set_conf_int(char *name, int value)
{
- wchar_t *wname;
-
- wname = (wchar_t *)g_utf8_to_utf16(name, -1, NULL, NULL, NULL);
- if (!wname)
- return;
-
- /* we simply store the value as DWORD */
- RegSetValueExW(hkey, (LPCWSTR)wname, 0, REG_DWORD, (const BYTE *)&value, 4);
- free(wname);
+ RegSetValueEx(hkey, (LPCTSTR)name, 0, REG_DWORD, (const BYTE *)&value, 4);
}
-void subsurface_set_conf_int(char *name, int value)
+void subsurface_set_conf_bool(char *name, int value)
{
- /* call to set registry key to value here? */
+ subsurface_set_conf_int(name, value);
}
const void *subsurface_get_conf(char *name)
@@ -127,14 +100,22 @@ const void *subsurface_get_conf(char *name)
return utf8_string;
}
-int subsurface_get_conf_bool(char *name)
+int subsurface_get_conf_int(char *name)
{
- return get_from_registry(hkey, name);
+ DWORD value = -1, len = 4;
+ LONG ret = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL,
+ (LPBYTE)&value, (LPDWORD)&len);
+ if (ret != ERROR_SUCCESS)
+ return -1;
+ return value;
}
-int subsurface_get_conf_int(char *name)
+int subsurface_get_conf_bool(char *name)
{
- return -1; /* windows registry call here? */
+ int ret = subsurface_get_conf_int(name);
+ if (ret == -1)
+ return ret;
+ return ret != 0;
}
void subsurface_flush_conf(void)