diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-08 08:48:13 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-08 08:48:13 -0800 |
commit | bf395ebf45626eece9163dd387bce3dbbeb56a68 (patch) | |
tree | 4299200dbe328cc85741ba89255e413bc4b77d76 /planner.c | |
parent | 7a18edddbbbfa82ba44035557618c92e4535a6de (diff) | |
download | subsurface-bf395ebf45626eece9163dd387bce3dbbeb56a68.tar.gz |
Avoid pointless calls to dive planner
Stupid Gtk. Seriously. So in order to get a notification if the user
selects the drop down for the gas with the mouse I need to connect to the
"changed" signal for the combobox. But that also fires whenever the user
types something into the GtkEntry. Which means we once again get called
for all kinds of silly partial names.
Instead we want to handle the manual entry in the "focus-out" callback
(the user has hit tab or something else to move away from the GtkEntry -
let's assume that this is the text he wants us to use) and only respond to
the changed signal on the combobox if the user selected something from the
dropdown.
The easiest way to do that (I think) is to check the text with the strings
stored in the model. If this indeed matches a string stored in the model
then most likely this is something the user selected from the dropdown.
But more importantly if it isn't in the model, then we KNOW that this is
just a partial string that was typed in. And we can ignore that one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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 |