X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=gtk-gui.c;h=bdf2952f074faf5a7c2efaf767f3696421dad7a7;hb=618a20ba5f2a9adc0e5a35117535f8eaa9fd34a4;hp=23848f8923c11c16c3d48dfe51a9f20c615db51c;hpb=11db04b350382c021edf83e2f91b3cace090989b;p=ext%2Fsubsurface.git
diff --git a/gtk-gui.c b/gtk-gui.c
index 23848f8..bdf2952 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -31,21 +31,43 @@ static GtkWidget *dive_profile;
visible_cols_t visible_cols = {TRUE, FALSE};
-static const char *default_dive_computer;
+static const char *default_dive_computer_vendor;
+static const char *default_dive_computer_product;
+static const char *default_dive_computer_device;
-static int is_default_dive_computer(const char *name)
+static int is_default_dive_computer(const char *vendor, const char *product)
{
- return default_dive_computer && !strcmp(name, default_dive_computer);
+ return default_dive_computer_vendor && !strcmp(vendor, default_dive_computer_vendor) &&
+ default_dive_computer_product && !strcmp(product, default_dive_computer_product);
}
-static void set_default_dive_computer(const char *name)
+static int is_default_dive_computer_device(const char *name)
+{
+ return default_dive_computer_device && !strcmp(name, default_dive_computer_device);
+}
+
+static void set_default_dive_computer(const char *vendor, const char *product)
+{
+ if (!vendor || !*vendor)
+ return;
+ if (!product || !*product)
+ return;
+ if (is_default_dive_computer(vendor, product))
+ return;
+ default_dive_computer_vendor = vendor;
+ default_dive_computer_product = product;
+ subsurface_set_conf("dive_computer_vendor", PREF_STRING, vendor);
+ subsurface_set_conf("dive_computer_product", PREF_STRING, product);
+}
+
+static void set_default_dive_computer_device(const char *name)
{
if (!name || !*name)
return;
- if (is_default_dive_computer(name))
+ if (is_default_dive_computer_device(name))
return;
- default_dive_computer = name;
- subsurface_set_conf("dive_computer", PREF_STRING, name);
+ default_dive_computer_device = name;
+ subsurface_set_conf("dive_computer_device", PREF_STRING, name);
}
void repaint_dive(void)
@@ -587,11 +609,13 @@ static void view_info(GtkWidget *w, gpointer data)
gtk_paned_set_position(GTK_PANED(hpane), 65535);
}
-/* Ooh. I don't know how to get the half-way size. So I'm just using random numbers */
static void view_three(GtkWidget *w, gpointer data)
{
- gtk_paned_set_position(GTK_PANED(hpane), 400);
- gtk_paned_set_position(GTK_PANED(vpane), 200);
+ GtkAllocation alloc;
+ 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);
}
static GtkActionEntry menu_items[] = {
@@ -604,6 +628,7 @@ static GtkActionEntry menu_items[] = {
{ "SaveFile", GTK_STOCK_SAVE, NULL, CTRLCHAR "S", NULL, G_CALLBACK(file_save) },
{ "Print", GTK_STOCK_PRINT, NULL, CTRLCHAR "P", NULL, G_CALLBACK(do_print) },
{ "Import", NULL, "Import", NULL, NULL, G_CALLBACK(import_dialog) },
+ { "AddDive", NULL, "Add Dive", NULL, NULL, G_CALLBACK(add_dive_cb) },
{ "Preferences", NULL, "Preferences", PREFERENCE_ACCEL, NULL, G_CALLBACK(preferences_dialog) },
{ "Renumber", NULL, "Renumber", NULL, NULL, G_CALLBACK(renumber_dialog) },
{ "SelectEvents", NULL, "SelectEvents", NULL, NULL, G_CALLBACK(selectevents_dialog) },
@@ -630,6 +655,7 @@ static const gchar* ui_string = " \
\