diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-01-06 16:34:25 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-06 09:55:34 -0800 |
commit | c607f09f402ccd0b6463c6e7630ee2d162d78579 (patch) | |
tree | 7a78943f26c57f198bb329c0f5ac5551d921abd1 /gtk-gui.c | |
parent | 6d10aab04960e464e8806b9dfdb7bae6317378ae (diff) | |
download | subsurface-c607f09f402ccd0b6463c6e7630ee2d162d78579.tar.gz |
Planner: hook the gas combo box to a "focus-out" event handler
GTK's logic might be a bit flawed (or complicated) in terms of
"focus-out-event" and GtkComboBoxEntry objects as it does not work
by attaching said signal type directly to the GtkComboBoxEntry.
Perhaps it only makes sense for text input.
Since "focus-out-event" works for GtkEntry, we can retrieve the child
GtkEntry from the combo using gtk_bin_get_child(GTK_BIN(combo)
and attach the event handler to that.
This change should make it possible to update gas_model (GtkListStore)
when changing the widget focus with both the keyboard and mouse clicks.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -1475,19 +1475,15 @@ GtkWidget *entry_depth[MAX_WAYPOINTS], *entry_duration[MAX_WAYPOINTS], *entry_ga int nr_waypoints = 0; static GtkListStore *gas_model = NULL; -static gboolean gas_changed_cb(GtkComboBox *combo, GdkEventKey *event, gpointer data) +static gboolean gas_focus_out_cb(GtkWidget *entry, gpointer data) { char *gastext; int o2, he; - GtkWidget *entry; - if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) { - entry = gtk_bin_get_child(GTK_BIN(combo)); - gastext = strdup(gtk_entry_get_text(GTK_ENTRY(entry))); - if (validate_gas(gastext, &o2, &he)) - add_string_list_entry(gastext, gas_model); - free(gastext); - } + gastext = strdup(gtk_entry_get_text(GTK_ENTRY(entry))); + if (validate_gas(gastext, &o2, &he)) + add_string_list_entry(gastext, gas_model); + free(gastext); return FALSE; } @@ -1505,7 +1501,7 @@ static GtkWidget *add_gas_combobox_to_box(GtkWidget *box, const char *label) } combo = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(gas_model), 0); gtk_widget_add_events(combo, GDK_FOCUS_CHANGE_MASK); - g_signal_connect(G_OBJECT(combo), "event", G_CALLBACK(gas_changed_cb), NULL); + g_signal_connect(gtk_bin_get_child(GTK_BIN(combo)), "focus-out-event", G_CALLBACK(gas_focus_out_cb), NULL); if (label) { frame = gtk_frame_new(label); |