static void combo_opt_changed (GtkComboBox *box, combo_opts *opts) { gchar *s = combo_box_get_active_text(box); int i; for (i=0; opts->strs[i] != NULL; i++) { if (!strcmp(s, _(opts->strs[i]))) { *opts->optp |= opts->vals[i]; } else { *opts->optp &= ~opts->vals[i]; } } g_free(s); }
/* is actually placed inside the submenu there */ void style_select(GtkWidget *parent, appdata_t *appdata) { printf("select style\n"); /* ------------------ style dialog ---------------- */ GtkWidget *dialog = misc_dialog_new(MISC_DIALOG_NOSIZE,_("Select style"), GTK_WINDOW(parent), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); GtkWidget *cbox = style_select_widget(appdata); GtkWidget *hbox = gtk_hbox_new(FALSE, 8); gtk_box_pack_start_defaults(GTK_BOX(hbox), gtk_label_new(_("Style:"))); gtk_box_pack_start_defaults(GTK_BOX(hbox), cbox); gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox); gtk_widget_show_all(dialog); if(GTK_RESPONSE_ACCEPT != gtk_dialog_run(GTK_DIALOG(dialog))) { printf("user clicked cancel\n"); gtk_widget_destroy(dialog); return; } const char *ptr = combo_box_get_active_text(cbox); printf("user clicked ok on %s\n", ptr); gtk_widget_destroy(dialog); style_change(appdata, ptr); }
static void set_sys_method (GtkComboBox *box, dialog_t *d) { gchar *str = combo_box_get_active_text(box); char *s, mstr[8] = {0}; s = strrchr(str, '('); if (s != NULL) { GtkWidget *bt, *bv; sscanf(s + 1, "%7[^)]", mstr); d->opt = system_method_from_string(mstr); bt = g_object_get_data(G_OBJECT(box), "bt"); bv = g_object_get_data(G_OBJECT(box), "bv"); if (d->opt == 0 || d->opt == 1 || d->opt == 6) { /* SUR, 3SLS, WLS */ gtk_widget_set_sensitive(bt, TRUE); gtk_widget_set_sensitive(bv, TRUE); } else if (d->opt == 2) { /* FIML */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bt), TRUE); gtk_widget_set_sensitive(bt, FALSE); gtk_widget_set_sensitive(bv, TRUE); } else { /* LIML, OLS, TSLS */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bt), FALSE); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bt), FALSE); gtk_widget_set_sensitive(bt, FALSE); gtk_widget_set_sensitive(bv, FALSE); } } g_free(str); }