/** * dialog_advanced_filter: * @wbcg: * @sheet: * * Show the dialog (guru). * **/ void dialog_advanced_filter (WBCGtk *wbcg) { AdvancedFilterState *state; WorkbookControl *wbc; g_return_if_fail (wbcg != NULL); wbc = WORKBOOK_CONTROL (wbcg); /* Only pop up one copy per workbook */ if (gnumeric_dialog_raise_if_exists (wbcg, ADVANCED_FILTER_KEY)) return; state = g_new (AdvancedFilterState, 1); if (dialog_tool_init (state, wbcg, wb_control_cur_sheet (wbc), GNUMERIC_HELP_LINK_ADVANCED_FILTER, "advanced-filter.ui", "Filter", _("Could not create the Advanced Filter dialog."), ADVANCED_FILTER_KEY, G_CALLBACK (advanced_filter_ok_clicked_cb), NULL, G_CALLBACK (advanced_filter_update_sensitivity_cb), 0)) return; gnm_dao_set_inplace (GNM_DAO (state->gdao), _("Filter _in-place")); gnm_dao_set_put (GNM_DAO (state->gdao), FALSE, FALSE); advanced_filter_update_sensitivity_cb (NULL, state); tool_load_selection ((GenericToolState *)state, TRUE); return; }
GtkWidget * gnm_dao_new (WBCGtk *wbcg, gchar *inplace_str) { GnmDao *gdao = GNM_DAO (g_object_new (GNM_DAO_TYPE, NULL)); GtkGrid *grid; g_return_val_if_fail (wbcg != NULL, NULL); gdao->wbcg = wbcg; /* Create the output range expression entry */ grid = GTK_GRID (go_gtk_builder_get_widget (gdao->gui, "output-grid")); gdao->output_entry = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (gdao->output_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (gdao->output_entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (gdao->output_entry), 1, 3, 1, 1); go_atk_setup_label (gdao->output_range, GTK_WIDGET (gdao->output_entry)); gtk_widget_show (GTK_WIDGET (gdao->output_entry)); /* Finished creating the output range expression entry */ gnm_dao_set_inplace (gdao, inplace_str); gnm_dao_setup_signals (gdao); cb_set_sensitivity (NULL, gdao); return GTK_WIDGET (gdao); }
GtkWidget * gnm_dao_new (WBCGtk *wbcg, gchar *inplace_str) { GnmDao *gdao = GNM_DAO (g_object_new (GNM_DAO_TYPE, NULL)); GtkTable *table; g_return_val_if_fail (wbcg != NULL, NULL); gdao->wbcg = wbcg; /* Create the output range expression entry */ table = GTK_TABLE (glade_xml_get_widget (gdao->gui, "output-table")); gdao->output_entry = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (gdao->output_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (gdao->output_entry), 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); go_atk_setup_label (gdao->output_range, GTK_WIDGET (gdao->output_entry)); gtk_widget_show (GTK_WIDGET (gdao->output_entry)); /* Finished creating the output range expression entry */ gnm_dao_set_inplace (gdao, inplace_str); gnm_dao_setup_signals (gdao); cb_set_sensitivity (NULL, gdao); return GTK_WIDGET (gdao); }
void dialog_fill_series (WBCGtk *wbcg) { FillSeriesState *state; WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg); SheetView *sv = wb_control_cur_sheet_view (wbc); g_return_if_fail (wbcg != NULL); /* Only pop up one copy per workbook */ if (gnumeric_dialog_raise_if_exists (wbcg, FILL_SERIES_KEY)) { return; } state = g_new (FillSeriesState, 1); if (dialog_tool_init ((GenericToolState *)state, wbcg, sv_sheet (sv), GNUMERIC_HELP_LINK_FILL_SERIES, "fill-series.ui", "Fill_series", _("Could not create the Fill Series dialog."), FILL_SERIES_KEY, G_CALLBACK (cb_fill_series_ok_clicked), NULL, G_CALLBACK (cb_fill_series_update_sensitivity), 0)) return; gnm_dao_set_put (GNM_DAO (state->base.gdao), FALSE, FALSE); dialog_fill_series_tool_init (state); gtk_widget_show (state->base.dialog); return; }
void dialog_tool_preset_to_range (GenericToolState *state) { GnmRange const *sel; GtkWidget *w; g_return_if_fail (state != NULL); g_return_if_fail (state->gdao != NULL); sel = selection_first_range (state->sv, NULL, NULL); gnm_dao_load_range (GNM_DAO (state->gdao), sel); gnm_dao_focus_output_range (GNM_DAO (state->gdao)); w = glade_xml_get_widget (state->gui, "notebook1"); g_return_if_fail (w && GTK_IS_NOTEBOOK (w)); gtk_notebook_set_current_page (GTK_NOTEBOOK(w), 0); }
static void gnm_dao_destroy (GtkWidget *widget) { GnmDao *gdao = GNM_DAO (widget); g_clear_object (&gdao->gui); ((GtkWidgetClass *)(gnm_dao_parent_class))->destroy (widget); }
static void gnm_dao_destroy (GtkObject *object) { GnmDao *gdao = GNM_DAO (object); if (gdao->gui) { g_object_unref (G_OBJECT (gdao->gui)); gdao->gui = NULL; } ((GtkObjectClass *)gnm_dao_parent_class)->destroy (object); }
static void cb_fill_series_update_sensitivity (G_GNUC_UNUSED GtkWidget *dummy, FillSeriesState *state) { gboolean ready; gboolean step, stop; gnm_float a_float; step = !entry_to_float (GTK_ENTRY (state->step_entry), &a_float, FALSE); stop = !entry_to_float (GTK_ENTRY (state->stop_entry), &a_float,FALSE); ready = gnm_dao_is_ready (GNM_DAO (state->base.gdao)) && !entry_to_float (GTK_ENTRY (state->start_entry), &a_float, FALSE) && ((gnm_dao_is_finite (GNM_DAO (state->base.gdao)) && (step || stop)) || (step && stop)); gtk_widget_set_sensitive (state->base.ok_button, ready); }
/** * parse_output: * * @state: * @dao: * * fill dao with information from the standard output section of a dialog */ data_analysis_output_t * parse_output (GenericToolState *state, data_analysis_output_t *dao) { data_analysis_output_t *this_dao = dao; gnm_dao_get_data (GNM_DAO (state->gdao), &this_dao); if (this_dao->type == InPlaceOutput) { GnmValue *output_range = gnm_expr_entry_parse_as_value ( state->input_entry, state->sheet); dao_load_from_value (this_dao, output_range); value_release (output_range); } return this_dao; }
/** * random_cor_tool_update_sensitivity_cb: * @dummy: * @state: * * Update the dialog widgets sensitivity if the only items of interest * are the standard input (one range) and output items. **/ static void random_cor_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy, RandomCorToolState *state) { GnmValue *input_range; gint height, width, count; input_range = gnm_expr_entry_parse_as_value (GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet); if (input_range == NULL) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The matrix range is not valid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } height = input_range->v_range.cell.b.row - input_range->v_range.cell.a.row; width = input_range->v_range.cell.b.col - input_range->v_range.cell.a.col; value_release (input_range); if (height != width || height == 0) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The matrix must be symmetric positive-definite.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } if (!gnm_dao_is_ready (GNM_DAO (state->base.gdao))) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The output specification " "is invalid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } if (entry_to_int (GTK_ENTRY (state->count_entry), &count, FALSE) != 0 || count <= 0) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The number of random numbers requested is invalid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } gtk_label_set_text (GTK_LABEL (state->base.warning), ""); gtk_widget_set_sensitive (state->base.ok_button, TRUE); }
/** * advanced_filter_update_sensitivity_cb: * @dummy: * @state: * * Update the dialog widgets sensitivity **/ static void advanced_filter_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy, AdvancedFilterState *state) { GnmValue *input_range = NULL; GnmValue *criteria_range = NULL; input_range = gnm_expr_entry_parse_as_value ( GNM_EXPR_ENTRY (state->input_entry), state->sheet); if (input_range == NULL) { gtk_label_set_text (GTK_LABEL (state->warning), _("The list range is invalid.")); gtk_widget_set_sensitive (state->ok_button, FALSE); return; } else value_release (input_range); criteria_range = gnm_expr_entry_parse_as_value (state->input_entry_2, state->sheet); if (criteria_range == NULL) { gtk_label_set_text (GTK_LABEL (state->warning), _("The criteria range is invalid.")); gtk_widget_set_sensitive (state->ok_button, FALSE); return; } else value_release (criteria_range); if (!gnm_dao_is_ready (GNM_DAO (state->gdao))) { gtk_label_set_text (GTK_LABEL (state->warning), _("The output range is invalid.")); gtk_widget_set_sensitive (state->ok_button, FALSE); return; } gtk_label_set_text (GTK_LABEL (state->warning), ""); gtk_widget_set_sensitive (state->ok_button, TRUE); return; }
/** * dialog_random_cor_tool: * @wbcg: * @sheet: * * Show the dialog (guru). * **/ int dialog_random_cor_tool (WBCGtk *wbcg, Sheet *sheet) { RandomCorToolState *state; if (wbcg == NULL) { return 1; } /* Only pop up one copy per workbook */ if (gnm_dialog_raise_if_exists (wbcg, RANDOM_COR_KEY)) { return 0; } state = g_new (RandomCorToolState, 1); if (dialog_tool_init ((GnmGenericToolState *)state, wbcg, sheet, GNUMERIC_HELP_LINK_RANDOM_GENERATOR_COR, "res:ui/random-generation-cor.ui", "CorRandom", _("Could not create the Correlated Random Tool dialog."), RANDOM_COR_KEY, G_CALLBACK (random_cor_tool_ok_clicked_cb), NULL, G_CALLBACK (random_cor_tool_update_sensitivity_cb), 0)) return 0; gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE); dialog_random_cor_tool_init (state); tool_load_selection ((GnmGenericToolState *)state, TRUE); gtk_widget_show_all (state->base.dialog); return 0; }
/** * kaplan_meier_tool_update_sensitivity_cb: * @dummy: * @state: * * Update the dialog widgets sensitivity **/ static void kaplan_meier_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy, KaplanMeierToolState *state) { gboolean censorship; gboolean groups; GnmValue *input_range; GnmValue *input_range_2 = NULL; int height, width; censorship = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (state->censorship_button)); groups = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (state->groups_check)); gtk_widget_set_sensitive (state->tick_button, censorship); input_range = gnm_expr_entry_parse_as_value (GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet); if (input_range == NULL) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The time column is not valid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } height = input_range->v_range.cell.b.row - input_range->v_range.cell.a.row; width = input_range->v_range.cell.b.col - input_range->v_range.cell.a.col; value_release (input_range); if (width != 0) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The time column should be part of a single column.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } if (censorship) { input_range_2 = gnm_expr_entry_parse_as_value (GNM_EXPR_ENTRY (state->base.input_entry_2), state->base.sheet); if (input_range_2 == NULL) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The censorship column is not valid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } if (input_range_2->v_range.cell.b.col != input_range_2->v_range.cell.a.col) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The censorship column should be part of a single column.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); value_release (input_range_2); return; } if (input_range_2->v_range.cell.b.row - input_range_2->v_range.cell.a.row != height) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The censorship and time columns should have the same height.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); value_release (input_range_2); return; } value_release (input_range_2); } if (groups) { input_range_2 = gnm_expr_entry_parse_as_value (GNM_EXPR_ENTRY (state->groups_input), state->base.sheet); if (input_range_2 == NULL) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The groups column is not valid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } if (input_range_2->v_range.cell.b.col != input_range_2->v_range.cell.a.col) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The groups column should be part of a single column.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); value_release (input_range_2); return; } if (input_range_2->v_range.cell.b.row - input_range_2->v_range.cell.a.row != height) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The groups and time columns should have the same height.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); value_release (input_range_2); return; } value_release (input_range_2); } if (!gnm_dao_is_ready (GNM_DAO (state->base.gdao))) { gtk_label_set_text (GTK_LABEL (state->base.warning), _("The output specification " "is invalid.")); gtk_widget_set_sensitive (state->base.ok_button, FALSE); return; } gtk_label_set_text (GTK_LABEL (state->base.warning), ""); gtk_widget_set_sensitive (state->base.ok_button, TRUE); return; }
/** * dialog_kaplan_meier_tool: * @wbcg: * @sheet: * * Show the dialog (guru). * **/ int dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet) { KaplanMeierToolState *state; GtkWidget *widget; char const * plugins[] = { "Gnumeric_fnstat", "Gnumeric_fnlookup", "Gnumeric_fnmath", "Gnumeric_fninfo", "Gnumeric_fnlogical", NULL}; if ((wbcg == NULL) || gnm_check_for_plugins_missing (plugins, wbcg_toplevel (wbcg))) return 1; /* Only pop up one copy per workbook */ if (gnumeric_dialog_raise_if_exists (wbcg, KAPLAN_MEIER_KEY)) return 0; state = g_new0 (KaplanMeierToolState, 1); if (dialog_tool_init (&state->base, wbcg, sheet, GNUMERIC_HELP_LINK_KAPLAN_MEIER, "kaplan-meier.glade", "KaplanMeier", _("Could not create the Kaplan Meier Tool dialog."), KAPLAN_MEIER_KEY, G_CALLBACK (kaplan_meier_tool_ok_clicked_cb), NULL, G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), 0)) return 0; state->censorship_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "censor-button")); state->censor_spin_from = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "censored-spinbutton1")); gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_from), 0.,G_MAXSHORT); state->censor_spin_to = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "censored-spinbutton2")); gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_to), 0.,G_MAXSHORT); state->graph_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "graph-button")); state->tick_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "tick-button")); state->add_group_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "add-button")); state->remove_group_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "remove-button")); state->std_error_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "std-error-button")); state->logrank_button = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "logrank-button")); state->groups_check = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "groups-check")); state->groups_table = GTK_WIDGET (glade_xml_get_widget (state->base.gui, "groups-table")); state->groups_input = gnm_expr_entry_new (state->base.wbcg, TRUE); gnm_expr_entry_set_flags (state->groups_input, GNM_EE_FORCE_ABS_REF, GNM_EE_MASK); gtk_table_attach (GTK_TABLE (state->groups_table), GTK_WIDGET (state->groups_input), 1, 3, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); dialog_kaplan_meier_tool_setup_treeview (state); g_signal_connect_after (G_OBJECT (state->groups_check), "toggled", G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state); g_signal_connect_after (G_OBJECT (state->censorship_button), "toggled", G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state); g_signal_connect_after (G_OBJECT (state->graph_button), "toggled", G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state); g_signal_connect_after (G_OBJECT (state->std_error_button), "toggled", G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state); g_signal_connect_after (G_OBJECT (state->groups_input), "changed", G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state); g_signal_connect_after (G_OBJECT (state->groups_check), "toggled", G_CALLBACK (kaplan_meier_tool_update_groups_sensitivity_cb), state); g_signal_connect_after (G_OBJECT (state->tick_button), "toggled", G_CALLBACK (kaplan_meier_tool_set_graph_cb), state); g_signal_connect_after (G_OBJECT (state->add_group_button), "clicked", G_CALLBACK (kaplan_meier_tool_add_group_cb), state); g_signal_connect_after (G_OBJECT (state->remove_group_button), "clicked", G_CALLBACK (kaplan_meier_tool_remove_group_cb), state); g_signal_connect_after (G_OBJECT (state->censor_spin_from), "value-changed", G_CALLBACK (kaplan_meier_tool_set_censor_from_cb), state); g_signal_connect_after (G_OBJECT (state->censor_spin_to), "value-changed", G_CALLBACK (kaplan_meier_tool_set_censor_cb), state); g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry ( GNM_EXPR_ENTRY (state->base.input_entry_2))), "focus-in-event", G_CALLBACK (kaplan_meier_tool_set_censorship_cb), state); g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry ( GNM_EXPR_ENTRY (state->groups_input))), "focus-in-event", G_CALLBACK (kaplan_meier_tool_set_groups_cb), state); gnumeric_editable_enters (GTK_WINDOW (state->base.dialog), GTK_WIDGET (state->groups_input)); widget = glade_xml_get_widget (state->base.gui, "groups-label"); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (state->groups_input)); go_atk_setup_label (widget, GTK_WIDGET (state->groups_input)); gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE); kaplan_meier_tool_update_sensitivity_cb (NULL, state); kaplan_meier_tool_update_groups_sensitivity_cb (NULL, state); tool_load_selection ((GenericToolState *)state, TRUE); gtk_widget_show_all (GTK_WIDGET (state->base.dialog)); /* And to hide the in-place button again */ gnm_dao_set_inplace ( GNM_DAO (state->base.gdao), NULL); return 0; }