Implemented uiComboboxSetSelected() on GTK+.
This commit is contained in:
parent
581cbaecc9
commit
843ea0d46c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue