passing -1 to gtk_combo_box_set_active behaves different than docs state
- From: Christian Neumair <chris gnome-de org>
- To: gtk-devel-list gtk org
- Subject: passing -1 to gtk_combo_box_set_active behaves different than docs state
- Date: Sat, 13 Mar 2004 11:26:36 +0100
I've attached a sample that demonstrates that gtk_combo_box_set_active
selects the last item in the ComboBox if -1 is passed. [1] states that
-1 tells the ComboBox to have no active item at all. Is there any way to
select nothing at all (empty ComboBox, user can select an entry)?
I can verify this problem with custom cell renderers as well.
[1]
http://developer.gnome.org/doc/API/2.2/gtk/GtkComboBox.html#gtk-combo-box-set-active
all:
gcc `pkg-config --cflags --libs gtk+-2.0 glib-2.0` testcombo.c -o testcombo
#include <gtk/gtk.h>
const char* menu_entries [] = {
"foo",
"test!",
"last one..."
};
static void
button_clicked_cb (G_GNUC_UNUSED GtkButton *button, GtkComboBox *combo) {
g_warning ("trying to set active combobox item to -1");
gtk_combo_box_set_active (combo, -1);
}
int
main (int argc, char **argv) {
GtkWidget *window, *vbox, *combo, *button;
guint i;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (window), vbox);
/* create the combobox */
combo = gtk_combo_box_new_text ();
for (i = 0; i < G_N_ELEMENTS (menu_entries); i++) {
gtk_combo_box_append_text (GTK_COMBO_BOX (combo),
menu_entries[i]);
}
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
gtk_container_add (GTK_CONTAINER (vbox), combo);
button = gtk_button_new_with_label ("set active combobox item to -1");
g_signal_connect (G_OBJECT (button),
"clicked", G_CALLBACK (button_clicked_cb),
G_OBJECT (combo));
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]