Clean up gtk combo box handling

This cleans up our handling of combo boxes and all the duplicated
completion logic, and simplifies the code.

In particular, we get rid of the deprecated GtkComboBoxEntry.  While it
made some things easier, it made other things harder.  Just using
GtkComboBox and setting that up correctly ends up being simpler, and
also makes the logic work with gtk-3.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2013-01-27 16:40:01 -08:00 committed by Dirk Hohndel
parent 32e497b574
commit 77ece3fccb
6 changed files with 84 additions and 99 deletions

View file

@ -330,7 +330,7 @@ static GtkComboBox *dc_device_selector(GtkWidget *vbox)
frame = gtk_frame_new(_("Device or mount point"));
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
combo_box = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
combo_box = combo_box_with_model_and_entry(model);
gtk_container_add(GTK_CONTAINER(frame), combo_box);
renderer = gtk_cell_renderer_text_new();
@ -340,8 +340,7 @@ static GtkComboBox *dc_device_selector(GtkWidget *vbox)
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), default_index);
else
if (default_dive_computer_device)
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box))),
default_dive_computer_device);
set_active_text(GTK_COMBO_BOX(combo_box), default_dive_computer_device);
return GTK_COMBO_BOX(combo_box);
}
@ -430,7 +429,7 @@ repeat:
set_default_dive_computer(vendor, product);
/* get the device name from the combo box entry and set as default */
devname = strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(device)))));
devname = strdup(get_active_text(device));
set_default_dive_computer_device(devname);
/* clear leading and trailing white space from the device name and also
* everything after (and including) the first '(' char. */