summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--display-gtk.h8
-rw-r--r--info.c7
-rw-r--r--planner.c8
3 files changed, 17 insertions, 6 deletions
diff --git a/display-gtk.h b/display-gtk.h
index 2613a20b6..303eff564 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -94,8 +94,16 @@ extern int process_ui_events(void);
extern void update_progressbar(progressbar_t *progress, double value);
extern void update_progressbar_text(progressbar_t *progress, const char *text);
+// info.c
+enum {
+ MATCH_EXACT,
+ MATCH_PREPEND,
+ MATCH_AFTER
+} found_string_entry;
+
extern GtkWidget *create_date_time_widget(struct tm *time, GtkWidget **cal, GtkWidget **h, GtkWidget **m);
extern void add_string_list_entry(const char *string, GtkListStore *list);
+extern int match_list(GtkListStore *list, const char *string);
extern GtkWidget *dive_profile_widget(void);
extern GtkWidget *dive_info_frame(void);
diff --git a/info.c b/info.c
index 21e13e3e3..26b664f3e 100644
--- a/info.c
+++ b/info.c
@@ -312,11 +312,6 @@ static GtkTextView *text_view(GtkWidget *box, const char *label, enum writable w
return GTK_TEXT_VIEW(view);
}
-static enum {
- MATCH_EXACT,
- MATCH_PREPEND,
- MATCH_AFTER
-} found_string_entry;
static GtkTreeIter string_entry_location;
static gboolean match_string_entry(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
@@ -345,7 +340,7 @@ static gboolean match_string_entry(GtkTreeModel *model, GtkTreePath *path, GtkTr
return FALSE;
}
-static int match_list(GtkListStore *list, const char *string)
+int match_list(GtkListStore *list, const char *string)
{
found_string_entry = MATCH_PREPEND;
gtk_tree_model_foreach(GTK_TREE_MODEL(list), match_string_entry, (void *)string);
diff --git a/planner.c b/planner.c
index 683fbef42..0066bbcec 100644
--- a/planner.c
+++ b/planner.c
@@ -563,6 +563,14 @@ static void gas_changed_cb(GtkWidget *combo, gpointer data)
int idx = data - NULL;
gastext = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
+ /* stupidly this gets called for two reasons:
+ * a) any keystroke into the entry field
+ * b) mouse selection of a dropdown
+ * we only care about b) (a) is handled much better with the focus-out event)
+ * so let's check that the text returned is actually in our model before going on
+ */
+ if (match_list(gas_model, gastext) != MATCH_EXACT)
+ return;
o2 = he = 0;
if (!validate_gas(gastext, &o2, &he)) {
/* this should never happen as only validated texts should be