static gboolean xydenoise_dialog(XYdenoiseArgs *args) { GtkWidget *dialog, *table, *chooser; gint row, response; gboolean ok = FALSE; dialog = gtk_dialog_new_with_buttons(_("XY Denoising"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); table = gtk_table_new(9, 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 4); row = 0; /* Correlate with */ chooser = gwy_data_chooser_new_channels(); g_object_set_data(G_OBJECT(chooser), "dialog", dialog); gwy_data_chooser_set_filter(GWY_DATA_CHOOSER(chooser), xydenoise_data_filter, &args->op1, NULL); g_signal_connect(chooser, "changed", G_CALLBACK(xydenoise_data_cb), &args->op2); xydenoise_data_cb(GWY_DATA_CHOOSER(chooser), &args->op2); gwy_table_attach_hscale(table, row, _("Second direction:"), NULL, GTK_OBJECT(chooser), GWY_HSCALE_WIDGET); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); row++; gtk_widget_show_all(dialog); do { response = gtk_dialog_run(GTK_DIALOG(dialog)); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_NONE: gtk_widget_destroy(dialog); return FALSE; break; case GTK_RESPONSE_OK: ok = TRUE; break; default: g_assert_not_reached(); break; } } while (!ok); gtk_widget_destroy(dialog); return TRUE; }
static void target_graph_changed(ProfControls *controls) { GwyDataChooser *chooser = GWY_DATA_CHOOSER(controls->target_graph); gwy_data_chooser_get_active_id(chooser, &controls->args->target_graph); }
static void merge_direction_changed(GtkWidget *combo, MergeControls *controls) { MergeArgs *args = controls->args; args->direction = gwy_enum_combo_box_get_active(GTK_COMBO_BOX(combo)); gwy_data_chooser_refilter(GWY_DATA_CHOOSER(controls->op2)); }
static void merge_mode_changed(GtkWidget *combo, MergeControls *controls) { MergeArgs *args = controls->args; args->mode = gwy_enum_combo_box_get_active(GTK_COMBO_BOX(combo)); gwy_data_chooser_refilter(GWY_DATA_CHOOSER(controls->op2)); update_sensitivity(controls); }
static void target_graph_changed(CurvatureControls *controls) { GwyDataChooser *chooser = GWY_DATA_CHOOSER(controls->target_graph); GwyAppDataId *target = &controls->args->target_graph; gwy_data_chooser_get_active_id(chooser, target); }
static void tip_blind_dialog(TipBlindArgs *args) { GtkWidget *dialog, *table, *hbox, *vbox, *label; GwyContainer *data; GwyGraphModel *gmodel; GwyGraphArea *area; TipBlindControls controls; GwyPixmapLayer *layer; GwyDataField *dfield; GQuark quark; GwySIUnit *unit; gint response, row; dialog = gtk_dialog_new_with_buttons(_("Blind Tip Estimation"), NULL, 0, _("Run _Partial"), RESPONSE_ESTIMATE, _("Run _Full"), RESPONSE_REFINE, _("_Reset Tip"), RESPONSE_RESET, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); controls.args = args; controls.in_update = TRUE; controls.good_tip = FALSE; controls.dialog = dialog; gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, controls.good_tip); hbox = gtk_hbox_new(FALSE, 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 4); controls.vxres = 240; controls.vyres = 240; controls.oldnstripes = args->nstripes; /* set initial tip properties */ data = gwy_app_data_browser_get(args->source.datano); quark = gwy_app_get_data_key_for_id(args->source.id); dfield = GWY_DATA_FIELD(gwy_container_get_object(data, quark)); controls.tip = gwy_data_field_new_alike(dfield, TRUE); gwy_data_field_resample(controls.tip, args->xres, args->yres, GWY_INTERPOLATION_NONE); gwy_data_field_clear(controls.tip); /* set up data of rescaled image of the tip */ controls.vtip = gwy_container_new(); gwy_app_sync_data_items(data, controls.vtip, args->source.id, 0, FALSE, GWY_DATA_ITEM_PALETTE, 0); dfield = gwy_data_field_new_alike(controls.tip, TRUE); gwy_data_field_resample(dfield, controls.vxres, controls.vyres, GWY_INTERPOLATION_ROUND); gwy_container_set_object_by_name(controls.vtip, "/0/data", dfield); g_object_unref(dfield); /* set up rescaled image of the tip */ vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 4); controls.view = gwy_data_view_new(controls.vtip); layer = gwy_layer_basic_new(); gwy_pixmap_layer_set_data_key(layer, "/0/data"); gwy_layer_basic_set_gradient_key(GWY_LAYER_BASIC(layer), "/0/base/palette"); gwy_data_view_set_base_layer(GWY_DATA_VIEW(controls.view), layer); /* set up tip estimation controls */ gtk_box_pack_start(GTK_BOX(vbox), controls.view, FALSE, FALSE, 0); gmodel = gwy_graph_model_new(); controls.graph = gwy_graph_new(gmodel); g_object_unref(gmodel); gwy_axis_set_visible(gwy_graph_get_axis(GWY_GRAPH(controls.graph), GTK_POS_LEFT), FALSE); gwy_axis_set_visible(gwy_graph_get_axis(GWY_GRAPH(controls.graph), GTK_POS_BOTTOM), FALSE); area = GWY_GRAPH_AREA(gwy_graph_get_area(GWY_GRAPH(controls.graph))); gtk_widget_set_no_show_all(gwy_graph_area_get_label(area), TRUE); g_signal_connect_after(gwy_graph_area_get_label(area), "map", G_CALLBACK(gtk_widget_hide), NULL); gtk_box_pack_start(GTK_BOX(vbox), controls.graph, TRUE, TRUE, 0); table = gtk_table_new(13, 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 4); row = 0; controls.data = gwy_data_chooser_new_channels(); gwy_data_chooser_set_filter(GWY_DATA_CHOOSER(controls.data), tip_blind_source_filter, &args->orig, NULL); gwy_data_chooser_set_active_id(GWY_DATA_CHOOSER(controls.data), &args->source); g_signal_connect(controls.data, "changed", G_CALLBACK(data_changed), &args->source); gwy_table_attach_hscale(table, row, _("Related _data:"), NULL, GTK_OBJECT(controls.data), GWY_HSCALE_WIDGET); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); row++; label = gtk_label_new(_("Estimated Tip Size")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 4, row, row+1, GTK_FILL, 0, 0, 0); row++; controls.xres = gtk_adjustment_new(args->xres, MIN_RES, MAX_RES, 1, 10, 0); gwy_table_attach_hscale(table, row, _("_Width:"), "px", controls.xres, 0); g_object_set_data(G_OBJECT(controls.xres), "controls", &controls); g_signal_connect(controls.xres, "value-changed", G_CALLBACK(width_changed), &controls); row++; controls.yres = gtk_adjustment_new(args->yres, MIN_RES, MAX_RES, 1, 10, 0); gwy_table_attach_hscale(table, row, _("_Height:"), "px", controls.yres, 0); g_object_set_data(G_OBJECT(controls.yres), "controls", &controls); g_signal_connect(controls.yres, "value-changed", G_CALLBACK(height_changed), &controls); row++; controls.same_resolution = gtk_check_button_new_with_mnemonic(_("_Same resolution")); gtk_table_attach(GTK_TABLE(table), controls.same_resolution, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.same_resolution), args->same_resolution); g_signal_connect(controls.same_resolution, "toggled", G_CALLBACK(same_resolution_changed), &controls); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); row++; gtk_table_attach(GTK_TABLE(table), gwy_label_new_header(_("Options")), 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); row++; controls.threshold = gtk_adjustment_new(1.0, 0.01, 1000.0, 0.01, 1.0, 0.0); controls.threshold_spin = gtk_spin_button_new(GTK_ADJUSTMENT(controls.threshold), 0.1, 2); gtk_table_attach(GTK_TABLE(table), controls.threshold_spin, 2, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); label = gtk_label_new_with_mnemonic(_("Noise suppression t_hreshold:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_label_set_mnemonic_widget(GTK_LABEL(label), controls.threshold_spin); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); unit = gwy_data_field_get_si_unit_z(dfield); controls.threshold_unit = gwy_combo_box_metric_unit_new(G_CALLBACK(thresh_changed), &controls, -12, -3, unit, -9); gtk_table_attach(GTK_TABLE(table), controls.threshold_unit, 3, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect(controls.threshold, "value-changed", G_CALLBACK(thresh_changed), &controls); sci_entry_set_value(GTK_ADJUSTMENT(controls.threshold), GTK_COMBO_BOX(controls.threshold_unit), args->thresh); row++; controls.boundaries = gtk_check_button_new_with_mnemonic(_("Use _boundaries")); gtk_table_attach(GTK_TABLE(table), controls.boundaries, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.boundaries), args->use_boundaries); g_signal_connect(controls.boundaries, "toggled", G_CALLBACK(bound_changed), args); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); row++; gtk_table_attach(GTK_TABLE(table), gwy_label_new_header(_("Stripes")), 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); row++; controls.nstripes = gtk_adjustment_new(args->nstripes, MIN_STRIPES, MAX_STRIPES, 1, 10, 0); gwy_table_attach_hscale(table, row, _("_Split to stripes:"), NULL, controls.nstripes, GWY_HSCALE_CHECK); controls.split_to_stripes = gwy_table_hscale_get_check(controls.nstripes); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.split_to_stripes), !args->split_to_stripes); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.split_to_stripes), args->split_to_stripes); g_signal_connect(controls.split_to_stripes, "toggled", G_CALLBACK(split_to_stripes_changed), &controls); g_signal_connect(controls.nstripes, "value-changed", G_CALLBACK(nstripes_changed), &controls); row++; controls.stripeno = gtk_adjustment_new(1, 1, args->nstripes, 1, 10, 0); gwy_table_attach_hscale(table, row, _("_Preview stripe:"), NULL, controls.stripeno, GWY_HSCALE_DEFAULT); g_signal_connect(controls.stripeno, "value-changed", G_CALLBACK(stripeno_changed), &controls); row++; controls.plot_size_graph = gtk_check_button_new_with_mnemonic(_("Plot size _graph")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.plot_size_graph), args->plot_size_graph); gtk_table_attach(GTK_TABLE(table), controls.plot_size_graph, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect(controls.plot_size_graph, "toggled", G_CALLBACK(plot_size_graph_changed), &controls); row++; controls.create_images = gtk_check_button_new_with_mnemonic(_("Create tip i_mages")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.create_images), args->create_images); gtk_table_attach(GTK_TABLE(table), controls.create_images, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect(controls.create_images, "toggled", G_CALLBACK(create_images_changed), &controls); row++; controls.tipdone = FALSE; controls.in_update = FALSE; split_to_stripes_changed(GTK_TOGGLE_BUTTON(controls.split_to_stripes), &controls); gtk_widget_show_all(dialog); do { response = gtk_dialog_run(GTK_DIALOG(dialog)); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: gtk_widget_destroy(dialog); case GTK_RESPONSE_NONE: tip_blind_dialog_abandon(&controls); tip_blind_save_args(gwy_app_settings_get(), args); return; break; case GTK_RESPONSE_OK: tip_blind_save_args(gwy_app_settings_get(), args); tip_blind_do(&controls, args); break; case RESPONSE_RESET: reset(&controls, args); break; case RESPONSE_ESTIMATE: tip_blind_run(&controls, args, FALSE); break; case RESPONSE_REFINE: tip_blind_run(&controls, args, TRUE); break; default: g_assert_not_reached(); break; } } while (response != GTK_RESPONSE_OK); gtk_widget_destroy(dialog); tip_blind_dialog_abandon(&controls); return; }
static void update_target_graphs(ProfControls *controls) { GwyDataChooser *chooser = GWY_DATA_CHOOSER(controls->target_graph); gwy_data_chooser_refilter(chooser); }
static void prof_dialog(ProfArgs *args, GwyContainer *data, GwyDataField *dfield, gint id) { GtkWidget *hbox, *hbox2, *vbox, *label; GwyDataChooser *chooser; GtkTable *table; GtkDialog *dialog; GwyGraph *graph; GwyGraphArea *area; ProfControls controls; gint response; gint row; controls.args = args; controls.psdffield = prof_psdf(dfield, args); controls.modfield = prof_sqrt(controls.psdffield); controls.hx = gwy_data_field_get_xmeasure(dfield)/(2*G_PI); controls.hy = gwy_data_field_get_xmeasure(dfield)/(2*G_PI); controls.dialog = gtk_dialog_new_with_buttons(_("Radial PSDF Section"), NULL, 0, GTK_STOCK_CLEAR, RESPONSE_CLEAR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); dialog = GTK_DIALOG(controls.dialog); gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK); gtk_dialog_set_response_sensitive(dialog, GTK_RESPONSE_OK, FALSE); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); hbox = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 4); controls.mydata = gwy_container_new(); gwy_container_set_object_by_name(controls.mydata, "/0/data", controls.modfield); g_object_unref(controls.modfield); gwy_container_set_string_by_name(controls.mydata, "/0/base/palette", g_strdup("DFit")); gwy_container_set_enum_by_name(controls.mydata, "/0/base/range-type", GWY_LAYER_BASIC_RANGE_AUTO); gwy_app_sync_data_items(data, controls.mydata, id, 0, FALSE, GWY_DATA_ITEM_REAL_SQUARE, 0); controls.view = create_preview(controls.mydata, 0, PREVIEW_SIZE, FALSE); controls.selection = create_vector_layer(GWY_DATA_VIEW(controls.view), 0, "Point", TRUE); gwy_selection_set_max_objects(controls.selection, NLINES); g_object_set(gwy_data_view_get_top_layer(GWY_DATA_VIEW(controls.view)), "draw-as-vector", TRUE, NULL); g_signal_connect_swapped(controls.selection, "changed", G_CALLBACK(prof_selection_changed), &controls); gtk_box_pack_start(GTK_BOX(hbox), controls.view, FALSE, FALSE, 4); vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 4); controls.gmodel = gwy_graph_model_new(); g_object_set(controls.gmodel, "title", _("PSDF Section"), "axis-label-bottom", "k", "axis-label-left", "W", NULL); init_graph_model_units(controls.gmodel, controls.psdffield); controls.line = gwy_data_line_new(1, 1.0, FALSE); controls.graph = gwy_graph_new(controls.gmodel); graph = GWY_GRAPH(controls.graph); gtk_widget_set_size_request(controls.graph, GRAPH_WIDTH, -1); gwy_graph_set_axis_visible(graph, GTK_POS_LEFT, FALSE); gwy_graph_set_axis_visible(graph, GTK_POS_RIGHT, FALSE); gwy_graph_set_axis_visible(graph, GTK_POS_TOP, FALSE); gwy_graph_set_axis_visible(graph, GTK_POS_BOTTOM, FALSE); gwy_graph_enable_user_input(graph, FALSE); area = GWY_GRAPH_AREA(gwy_graph_get_area(graph)); gwy_graph_area_enable_user_input(area, FALSE); gtk_box_pack_start(GTK_BOX(vbox), controls.graph, TRUE, TRUE, 0); table = GTK_TABLE(gtk_table_new(4, 4, FALSE)); gtk_table_set_row_spacings(table, 2); gtk_table_set_col_spacings(table, 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(table), FALSE, FALSE, 0); row = 0; controls.resolution = gtk_adjustment_new(controls.args->resolution, MIN_RESOLUTION, MAX_RESOLUTION, 1, 10, 0); gwy_table_attach_hscale(GTK_WIDGET(table), row, _("_Fix res.:"), NULL, controls.resolution, GWY_HSCALE_CHECK | GWY_HSCALE_SQRT); g_signal_connect_swapped(controls.resolution, "value-changed", G_CALLBACK(prof_resolution_changed), &controls); controls.fixres = gwy_table_hscale_get_check(controls.resolution); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.fixres), controls.args->fixres); g_signal_connect_swapped(controls.fixres, "toggled", G_CALLBACK(prof_fixres_changed), &controls); gwy_table_hscale_set_sensitive(controls.resolution, controls.args->fixres); row++; controls.separate = gtk_check_button_new_with_mnemonic(_("_Separate curves")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.separate), args->separate); gtk_table_attach(table, controls.separate, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); g_signal_connect_swapped(controls.separate, "toggled", G_CALLBACK(prof_separate_changed), &controls); row++; hbox2 = gtk_hbox_new(FALSE, 6); gtk_table_attach(table, hbox2, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); label = gtk_label_new_with_mnemonic(_("_Interpolation type:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); controls.interpolation = gwy_enum_combo_box_new(gwy_interpolation_type_get_enum(), -1, G_CALLBACK(prof_interpolation_changed), &controls, controls.args->interpolation, TRUE); gtk_label_set_mnemonic_widget(GTK_LABEL(label), controls.interpolation); gtk_box_pack_end(GTK_BOX(hbox2), controls.interpolation, FALSE, FALSE, 0); row++; controls.target_hbox = hbox2 = gtk_hbox_new(FALSE, 6); gtk_widget_set_sensitive(hbox2, !args->separate); gtk_table_attach(GTK_TABLE(table), hbox2, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); label = gtk_label_new_with_mnemonic(_("Target _graph:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); controls.target_graph = gwy_data_chooser_new_graphs(); chooser = GWY_DATA_CHOOSER(controls.target_graph); gwy_data_chooser_set_none(chooser, _("New graph")); gwy_data_chooser_set_active(chooser, NULL, -1); gwy_data_chooser_set_filter(chooser, filter_target_graphs, &controls, NULL); gwy_data_chooser_set_active_id(chooser, &args->target_graph); gwy_data_chooser_get_active_id(chooser, &args->target_graph); gtk_label_set_mnemonic_widget(GTK_LABEL(label), controls.target_graph); gtk_box_pack_end(GTK_BOX(hbox2), controls.target_graph, FALSE, FALSE, 0); g_signal_connect_swapped(controls.target_graph, "changed", G_CALLBACK(target_graph_changed), &controls); row++; gtk_widget_show_all(controls.dialog); do { response = gtk_dialog_run(dialog); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: gtk_widget_destroy(controls.dialog); case GTK_RESPONSE_NONE: goto finalize; break; case GTK_RESPONSE_OK: break; case RESPONSE_CLEAR: gwy_selection_clear(controls.selection); break; default: g_assert_not_reached(); break; } } while (response != GTK_RESPONSE_OK); gtk_widget_destroy(controls.dialog); prof_execute(&controls, data); finalize: g_object_unref(controls.psdffield); g_object_unref(controls.mydata); g_object_unref(controls.gmodel); g_object_unref(controls.line); }
static void presentation_attach(GwyContainer *data, GwyRunType run) { GtkWidget *dialog, *table, *label, *chooser; GwyAppDataId target; gint row, response; g_return_if_fail(run & PRESENTATION_ATTACH_RUN_MODES); gwy_app_data_browser_get_current(GWY_APP_CONTAINER_ID, &target.datano, GWY_APP_DATA_FIELD_ID, &target.id, 0); gwy_app_data_id_verify_channel(&attach_source_id); dialog = gtk_dialog_new_with_buttons(_("Attach Presentation"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); table = gtk_table_new(1, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 4); row = 0; label = gtk_label_new_with_mnemonic(_("_Data to attach:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); chooser = gwy_data_chooser_new_channels(); gwy_data_chooser_set_filter(GWY_DATA_CHOOSER(chooser), &presentation_attach_filter, &target, NULL); gwy_data_chooser_set_active_id(GWY_DATA_CHOOSER(chooser), &attach_source_id); gtk_table_attach(GTK_TABLE(table), chooser, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_label_set_mnemonic_widget(GTK_LABEL(label), chooser); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); row++; gtk_widget_show_all(dialog); do { response = gtk_dialog_run(GTK_DIALOG(dialog)); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: gtk_widget_destroy(dialog); case GTK_RESPONSE_NONE: return; break; case GTK_RESPONSE_OK: gwy_data_chooser_get_active_id(GWY_DATA_CHOOSER(chooser), &attach_source_id); /* The data must be always compatible at least with itself */ g_assert(attach_source_id.datano); presentation_attach_do(&attach_source_id, &target); gwy_app_channel_log_add_proc(data, target.id, target.id); break; default: g_assert_not_reached(); break; } } while (response != GTK_RESPONSE_OK); gtk_widget_destroy(dialog); }
static gboolean immerse_dialog(ImmerseArgs *args) { ImmerseControls controls; GwyContainer *data; GtkDialog *dialog; GtkWidget *table, *chooser, *hbox, *alignment, *label, *button, *vbox; GtkTooltips *tooltips; GdkDisplay *display; GwyDataField *dfield; gint response, row, id; gboolean ok; memset(&controls, 0, sizeof(ImmerseControls)); controls.args = args; tooltips = gwy_app_get_tooltips(); controls.dialog = gtk_dialog_new_with_buttons(_("Immerse Detail"), NULL, 0, NULL); dialog = GTK_DIALOG(controls.dialog); button = gtk_dialog_add_button(dialog, _("_Locate"), RESPONSE_ESTIMATE); gtk_tooltips_set_tip(tooltips, button, _("Locate detail by full image correlation search"), NULL); button = gtk_dialog_add_button(dialog, _("_Improve"), RESPONSE_REFINE); gtk_tooltips_set_tip(tooltips, button, _("Improve detail position by " "correlation search in neighborhood"), NULL); gtk_dialog_add_button(dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button(dialog, GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_dialog_set_default_response(dialog, GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); hbox = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(dialog->vbox), hbox, FALSE, FALSE, 4); /* Preview */ data = gwy_app_data_browser_get(args->image.datano); id = args->image.id; dfield = gwy_container_get_object(data, gwy_app_get_data_key_for_id(id)); controls.vf = gwy_data_field_get_value_format_xy(dfield, GWY_SI_UNIT_FORMAT_VFMARKUP, NULL); controls.mydata = gwy_container_new(); gwy_container_set_object_by_name(controls.mydata, "/0/data", dfield); gwy_app_sync_data_items(data, controls.mydata, id, 0, FALSE, GWY_DATA_ITEM_PALETTE, GWY_DATA_ITEM_MASK_COLOR, GWY_DATA_ITEM_RANGE, 0); gwy_container_set_boolean_by_name(controls.mydata, "/0/data/realsquare", TRUE); controls.view = create_preview(controls.mydata, 0, PREVIEW_SIZE, FALSE); alignment = GTK_WIDGET(gtk_alignment_new(0.5, 0, 0, 0)); gtk_container_add(GTK_CONTAINER(alignment), controls.view); gtk_box_pack_start(GTK_BOX(hbox), alignment, FALSE, FALSE, 4); g_signal_connect_after(controls.view, "expose-event", G_CALLBACK(immerse_view_expose), &controls); g_signal_connect(controls.view, "button-press-event", G_CALLBACK(immerse_view_button_press), &controls); g_signal_connect(controls.view, "button-release-event", G_CALLBACK(immerse_view_button_release), &controls); g_signal_connect(controls.view, "motion-notify-event", G_CALLBACK(immerse_view_motion_notify), &controls); vbox = gtk_vbox_new(FALSE, 8); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 4); /* Parameters table */ table = gtk_table_new(8, 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 4); row = 0; /* Detail to immerse */ chooser = gwy_data_chooser_new_channels(); gwy_data_chooser_set_active_id(GWY_DATA_CHOOSER(chooser), &args->detail); gwy_data_chooser_set_filter(GWY_DATA_CHOOSER(chooser), immerse_data_filter, &args->image, NULL); gwy_data_chooser_get_active_id(GWY_DATA_CHOOSER(chooser), &args->detail); g_signal_connect(chooser, "changed", G_CALLBACK(immerse_detail_cb), &controls); gwy_table_attach_hscale(table, row, _("_Detail image:"), NULL, GTK_OBJECT(chooser), GWY_HSCALE_WIDGET_NO_EXPAND); row++; /* Detail position */ label = gtk_label_new(_("Position:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0); controls.pos = gtk_label_new(NULL); gtk_misc_set_alignment(GTK_MISC(controls.pos), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), controls.pos, 1, 3, row, row+1, GTK_FILL, 0, 0, 0); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); row++; /* Sampling */ label = gtk_label_new(_("Result Sampling")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); row++; controls.sampling = gwy_radio_buttons_createl(G_CALLBACK(immerse_sampling_changed), &controls, args->sampling, _("_Upsample large image"), GWY_IMMERSE_SAMPLING_UP, _("_Downsample detail"), GWY_IMMERSE_SAMPLING_DOWN, NULL); row = gwy_radio_buttons_attach_to_table(controls.sampling, GTK_TABLE(table), 4, row); gtk_table_set_row_spacing(GTK_TABLE(table), row-1, 8); /* Leveling */ label = gtk_label_new(_("Detail Leveling")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); row++; controls.leveling = gwy_radio_buttons_createl(G_CALLBACK(immerse_leveling_changed), &controls, args->leveling, gwy_sgettext("levelling|_None"), GWY_IMMERSE_LEVEL_NONE, _("_Mean value"), GWY_IMMERSE_LEVEL_MEAN, NULL); row = gwy_radio_buttons_attach_to_table(controls.leveling, GTK_TABLE(table), 4, row); gtk_table_set_row_spacing(GTK_TABLE(table), row-1, 8); /* Draw frame */ controls.draw_frame = gtk_check_button_new_with_mnemonic(_("Show _frame")); gtk_table_attach(GTK_TABLE(table), controls.draw_frame, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.draw_frame), args->draw_frame); g_signal_connect(controls.draw_frame, "toggled", G_CALLBACK(immerse_frame_toggled), &controls); gtk_widget_show_all(controls.dialog); display = gtk_widget_get_display(controls.dialog); controls.near_cursor = gdk_cursor_new_for_display(display, GDK_FLEUR); controls.move_cursor = gdk_cursor_new_for_display(display, GDK_CROSS); immerse_detail_cb(GWY_DATA_CHOOSER(chooser), &controls); ok = FALSE; do { response = gtk_dialog_run(dialog); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_NONE: immerse_controls_destroy(&controls); immerse_save_args(gwy_app_settings_get(), args); return FALSE; break; case RESPONSE_ESTIMATE: case RESPONSE_REFINE: immerse_search(&controls, response); break; case GTK_RESPONSE_OK: ok = TRUE; break; default: g_assert_not_reached(); break; } } while (!ok); immerse_controls_destroy(&controls); immerse_save_args(gwy_app_settings_get(), args); return TRUE; }
static gboolean grain_cross_dialog(GrainCrossArgs *args, GwyDataField *dfield) { GrainCrossControls controls; GtkWidget *dialog, *hbox2, *label; GwyDataChooser *chooser; GtkTable *table; GwyGraphModel *gmodel; gint response; controls.args = args; controls.dfield = dfield; dialog = gtk_dialog_new_with_buttons(_("Grain Correlations"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); controls.dialog = GTK_DIALOG(dialog); gtk_dialog_set_default_response(controls.dialog, GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); gtk_window_set_default_size(GTK_WINDOW(dialog), 720, 480); table = GTK_TABLE(gtk_table_new(3, 3, FALSE)); gtk_table_set_row_spacings(table, 2); gtk_table_set_col_spacings(table, 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(controls.dialog->vbox), GTK_WIDGET(table), TRUE, TRUE, 0); gmodel = create_corr_graph(args, dfield); controls.graph = gwy_graph_new(gmodel); gtk_widget_set_size_request(controls.graph, 320, -1); g_object_unref(gmodel); gtk_table_attach(GTK_TABLE(table), controls.graph, 0, 1, 0, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); controls.abscissa = attach_axis_list(table, _("_Abscissa"), 1, args->abscissa, args->abscissa_expanded, &controls); controls.ordinate = attach_axis_list(table, _("O_rdinate"), 2, args->ordinate, args->ordinate_expanded, &controls); hbox2 = gtk_hbox_new(FALSE, 6); gtk_table_attach(GTK_TABLE(table), hbox2, 1, 3, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); label = gtk_label_new_with_mnemonic(_("Target _graph:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); controls.target_graph = gwy_data_chooser_new_graphs(); chooser = GWY_DATA_CHOOSER(controls.target_graph); gwy_data_chooser_set_none(chooser, _("New graph")); gwy_data_chooser_set_active(chooser, NULL, -1); gwy_data_chooser_set_filter(chooser, filter_target_graphs, &controls, NULL); gwy_data_chooser_set_active_id(chooser, &args->target_graph); gwy_data_chooser_get_active_id(chooser, &args->target_graph); gtk_label_set_mnemonic_widget(GTK_LABEL(label), controls.target_graph); gtk_box_pack_end(GTK_BOX(hbox2), controls.target_graph, TRUE, TRUE, 0); g_signal_connect_swapped(controls.target_graph, "changed", G_CALLBACK(target_graph_changed), &controls); axis_quantity_changed(&controls); gtk_widget_show_all(dialog); do { response = gtk_dialog_run(controls.dialog); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: gtk_widget_destroy(dialog); case GTK_RESPONSE_NONE: return FALSE; break; case GTK_RESPONSE_OK: break; default: g_assert_not_reached(); break; } } while (response != GTK_RESPONSE_OK); gtk_widget_destroy(dialog); return TRUE; }
static gboolean merge_dialog(MergeArgs *args) { MergeControls controls; GtkWidget *dialog, *table, *combo, *check; GwyDataChooser *chooser; gint response, row; gboolean ok; gwy_clear(&controls, 1); controls.args = args; dialog = gtk_dialog_new_with_buttons(_("Merge Data"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); controls.dialog = dialog; gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); table = gtk_table_new(6, 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 4); row = 0; /* Merge with */ controls.op2 = gwy_data_chooser_new_channels(); chooser = GWY_DATA_CHOOSER(controls.op2); g_object_set_data(G_OBJECT(chooser), "dialog", dialog); gwy_data_chooser_set_active_id(chooser, &args->op2); gwy_data_chooser_set_filter(chooser, merge_data_filter, args, NULL); gwy_data_chooser_get_active_id(chooser, &args->op2); g_signal_connect_swapped(chooser, "changed", G_CALLBACK(merge_data_changed), &controls); merge_data_changed(&controls, chooser); gwy_table_attach_hscale(table, row, _("_Merge with:"), NULL, GTK_OBJECT(chooser), GWY_HSCALE_WIDGET); row++; /* Parameters */ combo = gwy_enum_combo_box_new(directions, G_N_ELEMENTS(directions), G_CALLBACK(merge_direction_changed), &controls, args->direction, TRUE); gwy_table_attach_hscale(table, row, _("_Put second operand:"), NULL, GTK_OBJECT(combo), GWY_HSCALE_WIDGET); row++; combo = gwy_enum_combo_box_new(modes, G_N_ELEMENTS(modes), G_CALLBACK(merge_mode_changed), &controls, args->mode, TRUE); gwy_table_attach_hscale(table, row, _("_Align second operand:"), NULL, GTK_OBJECT(combo), GWY_HSCALE_WIDGET); row++; combo = gwy_enum_combo_box_new(boundaries, G_N_ELEMENTS(boundaries), G_CALLBACK(merge_boundary_changed), &controls, args->boundary, TRUE); controls.boundary = combo; gwy_table_attach_hscale(table, row, _("_Boundary treatment:"), NULL, GTK_OBJECT(combo), GWY_HSCALE_WIDGET); row++; check = gtk_check_button_new_with_mnemonic(_("Crop result to _avoid " "outside pixels")); controls.crop_to_rectangle = check; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), args->crop_to_rectangle); gtk_table_attach(GTK_TABLE(table), check, 0, 3, row, row+1, GTK_FILL, 0, 0, 0); g_signal_connect_swapped(check, "toggled", G_CALLBACK(crop_to_rectangle_changed), &controls); row++; check = gtk_check_button_new_with_mnemonic(_("Add _mask of outside pixels")); controls.create_mask = check; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), args->create_mask); gtk_table_attach(GTK_TABLE(table), check, 0, 3, row, row+1, GTK_FILL, 0, 0, 0); g_signal_connect_swapped(check, "toggled", G_CALLBACK(create_mask_changed), &controls); row++; update_sensitivity(&controls); gtk_widget_show_all(dialog); do { response = gtk_dialog_run(GTK_DIALOG(dialog)); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_NONE: gtk_widget_destroy(dialog); return FALSE; break; case GTK_RESPONSE_OK: ok = TRUE; break; default: g_assert_not_reached(); break; } } while (!ok); gtk_widget_destroy(dialog); return TRUE; }
static gboolean curvature_dialog(CurvatureArgs *args, GwyContainer *data, GwyDataField *dfield, GwyDataField *mfield, gint id) { enum { RESPONSE_RESET = 1 }; GtkWidget *dialog, *table, *label, *hbox, *vbox, *treeview, *button, *hbox2; GwyDataChooser *chooser; GtkTreeSelection *selection; GtkTreeViewColumn *column; GtkCellRenderer *renderer; GwyPixmapLayer *player; GwyVectorLayer *vlayer; CurvatureControls controls; gint response; gint row; controls.args = args; controls.unit = gwy_data_field_get_si_unit_xy(dfield); gwy_clear(controls.params, PARAM_NPARAMS); controls.gmodel = gwy_graph_model_new(); init_graph_model_units(controls.gmodel, dfield); dialog = gtk_dialog_new_with_buttons(_("Curvature"), NULL, 0, _("_Reset"), RESPONSE_RESET, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); controls.dialog = dialog; hbox = gtk_hbox_new(FALSE, 8); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); controls.data = gwy_container_new(); gwy_container_set_object_by_name(controls.data, "/0/data", dfield); if (mfield) gwy_container_set_object_by_name(controls.data, "/0/mask", mfield); gwy_app_sync_data_items(data, controls.data, id, 0, FALSE, GWY_DATA_ITEM_PALETTE, GWY_DATA_ITEM_MASK_COLOR, GWY_DATA_ITEM_RANGE, GWY_DATA_ITEM_REAL_SQUARE, 0); controls.view = gwy_data_view_new(controls.data); player = gwy_layer_basic_new(); g_object_set(player, "data-key", "/0/data", "gradient-key", "/0/base/palette", "range-type-key", "/0/base/range-type", "min-max-key", "/0/base", NULL); gwy_data_view_set_data_prefix(GWY_DATA_VIEW(controls.view), "/0/data"); gwy_data_view_set_base_layer(GWY_DATA_VIEW(controls.view), player); gwy_set_data_preview_size(GWY_DATA_VIEW(controls.view), PREVIEW_SIZE); vlayer = g_object_new(g_type_from_name("GwyLayerLine"), NULL); gwy_vector_layer_set_selection_key(vlayer, "/0/select/line"); gwy_vector_layer_set_editable(vlayer, FALSE); gwy_data_view_set_top_layer(GWY_DATA_VIEW(controls.view), GWY_VECTOR_LAYER(vlayer)); controls.selection = gwy_vector_layer_ensure_selection(vlayer); g_object_set(controls.selection, "max-objects", 2, NULL); gtk_box_pack_start(GTK_BOX(vbox), controls.view, FALSE, FALSE, 4); table = gtk_table_new(5 + (mfield ? 4 : 0), 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); row = 0; label = gwy_label_new_header(_("Output Type")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); row++; controls.set_selection = gtk_check_button_new_with_mnemonic(_("_Set selection")); gtk_table_attach(GTK_TABLE(table), controls.set_selection, 0, 4, row, row+1, GTK_FILL, 0, 0, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.set_selection), args->set_selection); g_signal_connect(controls.set_selection, "toggled", G_CALLBACK(curvature_set_selection_changed), &controls); row++; controls.plot_graph = gtk_check_button_new_with_mnemonic(_("_Plot graph")); gtk_table_attach(GTK_TABLE(table), controls.plot_graph, 0, 4, row, row+1, GTK_FILL, 0, 0, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.plot_graph), args->plot_graph); g_signal_connect(controls.plot_graph, "toggled", G_CALLBACK(curvature_plot_graph_changed), &controls); row++; gtk_table_set_row_spacing(GTK_TABLE(table), row-1, 8); controls.target_hbox = hbox2 = gtk_hbox_new(FALSE, 6); gtk_widget_set_sensitive(controls.target_hbox, args->plot_graph); gtk_table_attach(GTK_TABLE(table), hbox2, 0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); label = gtk_label_new_with_mnemonic(_("Target _graph:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); controls.target_graph = gwy_data_chooser_new_graphs(); chooser = GWY_DATA_CHOOSER(controls.target_graph); gwy_data_chooser_set_none(chooser, _("New graph")); gwy_data_chooser_set_active(chooser, NULL, -1); gwy_data_chooser_set_filter(chooser, filter_target_graphs, &controls, NULL); gwy_data_chooser_set_active_id(chooser, &args->target_graph); gwy_data_chooser_get_active_id(chooser, &args->target_graph); gtk_label_set_mnemonic_widget(GTK_LABEL(label), controls.target_graph); gtk_box_pack_end(GTK_BOX(hbox2), controls.target_graph, FALSE, FALSE, 0); g_signal_connect_swapped(controls.target_graph, "changed", G_CALLBACK(target_graph_changed), &controls); row++; if (mfield) { gtk_table_set_row_spacing(GTK_TABLE(table), row-1, 8); label = gwy_label_new_header(_("Masking Mode")); gtk_table_attach(GTK_TABLE(table), label, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); row++; controls.masking_group = gwy_radio_buttons_create(gwy_masking_type_get_enum(), -1, G_CALLBACK(curvature_masking_changed), &controls, args->masking); row = gwy_radio_buttons_attach_to_table(controls.masking_group, GTK_TABLE(table), 3, row); gtk_table_set_row_spacing(GTK_TABLE(table), row, 8); } else controls.masking_group = NULL; controls.warning = gtk_label_new(NULL); gtk_misc_set_alignment(GTK_MISC(controls.warning), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), controls.warning, 0, 3, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); controls.graph = gwy_graph_new(controls.gmodel); gtk_widget_set_size_request(controls.graph, 320, 260); g_object_unref(controls.gmodel); gtk_box_pack_start(GTK_BOX(vbox), controls.graph, TRUE, TRUE, 4); controls.paramstore = gwy_null_store_new(PARAM_NPARAMS); treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(controls.paramstore)); g_object_unref(controls.paramstore); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); gtk_box_pack_start(GTK_BOX(vbox), treeview, FALSE, FALSE, 4); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Parameter"), renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, render_name, param_names, NULL); gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(_("Symbol"), renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, render_symbol, param_symbols, NULL); gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); renderer = gtk_cell_renderer_text_new(); g_object_set(renderer, "xalign", 1.0, NULL); column = gtk_tree_view_column_new_with_attributes(_("Value"), renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, render_value, &controls, NULL); gtk_tree_view_column_set_expand(column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); button = curvature_add_aux_button(hbox, GTK_STOCK_SAVE, _("Save table to a file")); g_signal_connect_swapped(button, "clicked", G_CALLBACK(curvature_save), &controls); button = curvature_add_aux_button(hbox, GTK_STOCK_COPY, _("Copy table to clipboard")); g_signal_connect_swapped(button, "clicked", G_CALLBACK(curvature_copy), &controls); curvature_update_preview(&controls, args); gtk_widget_show_all(dialog); do { response = gtk_dialog_run(GTK_DIALOG(dialog)); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: gtk_widget_destroy(dialog); case GTK_RESPONSE_NONE: return FALSE; break; case GTK_RESPONSE_OK: break; case RESPONSE_RESET: *args = curvature_defaults; curvature_dialog_update(&controls, args); break; default: g_assert_not_reached(); break; } } while (response != GTK_RESPONSE_OK); gtk_widget_destroy(dialog); return TRUE; }
static gboolean maskcor_dialog(MaskcorArgs *args) { MaskcorControls controls; GtkWidget *dialog, *table, *chooser, *spin, *combo, *method; GtkObject *adj; gint row, response; gboolean ok; controls.args = args; dialog = gtk_dialog_new_with_buttons(_("Mask by Correlation"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT); table = gtk_table_new(5, 4, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_table_set_col_spacings(GTK_TABLE(table), 6); gtk_container_set_border_width(GTK_CONTAINER(table), 4); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 4); row = 0; /* Kernel */ chooser = gwy_data_chooser_new_channels(); g_object_set_data(G_OBJECT(chooser), "dialog", dialog); gwy_data_chooser_set_active(GWY_DATA_CHOOSER(chooser), NULL, -1); gwy_data_chooser_set_filter(GWY_DATA_CHOOSER(chooser), maskcor_kernel_filter, &args->data, NULL); gwy_data_chooser_set_active_id(GWY_DATA_CHOOSER(chooser), &args->kernel); gwy_data_chooser_get_active_id(GWY_DATA_CHOOSER(chooser), &args->kernel); g_signal_connect(chooser, "changed", G_CALLBACK(maskcor_kernel_changed), &args->kernel); gwy_table_attach_hscale(table, row, _("Correlation _kernel:"), NULL, GTK_OBJECT(chooser), GWY_HSCALE_WIDGET); row++; /* Result */ combo = gwy_enum_combo_box_newl(G_CALLBACK(maskcor_operation_changed), &controls, args->result, _("Objects marked"), GWY_MASKCOR_OBJECTS, _("Correlation maxima"), GWY_MASKCOR_MAXIMA, _("Correlation score"), GWY_MASKCOR_SCORE, NULL); gwy_table_attach_row(table, row, _("Output _type:"), NULL, combo); row++; /* Parameters */ method = gwy_enum_combo_box_new(gwy_correlation_type_get_enum(), -1, G_CALLBACK(gwy_enum_combo_box_update_int), &args->method, args->method, TRUE); gwy_table_attach_row(table, row, _("Correlation _method:"), NULL, method); row++; adj = gtk_adjustment_new(args->threshold, -1.0, 1.0, 0.01, 0.1, 0); controls.threshold = adj; spin = gwy_table_attach_hscale(table, row, _("T_hreshold:"), NULL, adj, 0); gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 3); gwy_table_hscale_set_sensitive(adj, args->result != GWY_MASKCOR_SCORE); g_signal_connect(adj, "value-changed", G_CALLBACK(maskcor_threshold_changed), &args->threshold); row++; gtk_widget_show_all(dialog); do { response = gtk_dialog_run(GTK_DIALOG(dialog)); switch (response) { case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: gtk_widget_destroy(dialog); case GTK_RESPONSE_NONE: return FALSE; break; case GTK_RESPONSE_OK: gtk_widget_destroy(dialog); ok = TRUE; break; default: g_assert_not_reached(); break; } } while (!ok); return ok; }