diff --git a/test/drawtests.c b/test/drawtests.c index 5e105b10..bf8f80e4 100644 --- a/test/drawtests.c +++ b/test/drawtests.c @@ -235,6 +235,6 @@ void populateComboboxWithTests(uiCombobox *c) { size_t i; - for (i = 0; test[i].name != NULL; i++) + for (i = 0; tests[i].name != NULL; i++) uiComboboxAppend(c, tests[i].name); } diff --git a/test/page6.c b/test/page6.c index 41a45d6e..cd94cf9e 100644 --- a/test/page6.c +++ b/test/page6.c @@ -80,7 +80,7 @@ static void onAmountChanged(uiSpinbox *s, void *data) static void shouldntHappen(uiCombobox *c, void *data) { - fprintf(stderr, "YOU SHOULD NOT SEE THIS. If you do, uiComboboxSetSelected() is triggering uiComboboxOnSelected(), which it should not."); + fprintf(stderr, "YOU SHOULD NOT SEE THIS. If you do, uiComboboxSetSelected() is triggering uiComboboxOnSelected(), which it should not.\n"); } static void redraw(uiCombobox *c, void *data) diff --git a/unix/combobox.c b/unix/combobox.c index b4ef2598..c1fc0db1 100644 --- a/unix/combobox.c +++ b/unix/combobox.c @@ -8,6 +8,7 @@ struct uiCombobox { GtkComboBoxText *comboboxText; void (*onSelected)(uiCombobox *, void *); void *onSelectedData; + gulong onSelectedSignal; }; uiUnixDefineControl( @@ -38,6 +39,14 @@ intmax_t uiComboboxSelected(uiCombobox *c) return gtk_combo_box_get_active(c->combobox); } +void uiComboboxSetSelected(uiCombobox *c, intmax_t n) +{ + // we need to inhibit sending of ::changed because this WILL send a ::changed otherwise + g_signal_handler_block(c->combobox, c->onSelectedSignal); + gtk_combo_box_set_active(c->combobox, n); + g_signal_handler_unblock(c->combobox, c->onSelectedSignal); +} + void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data) { c->onSelected = f; @@ -54,7 +63,7 @@ static uiCombobox *finishNewCombobox(GtkWidget *(*newfunc)(void)) c->combobox = GTK_COMBO_BOX(c->widget); c->comboboxText = GTK_COMBO_BOX_TEXT(c->widget); - g_signal_connect(c->widget, "changed", G_CALLBACK(onChanged), c); + c->onSelectedSignal = g_signal_connect(c->widget, "changed", G_CALLBACK(onChanged), c); uiComboboxOnSelected(c, defaultOnSelected, NULL); uiUnixFinishNewControl(c, uiCombobox);