void dialog_scenario_add (WBCGtk *wbcg) { ScenariosState *state; WorkbookControl *wbc; GtkWidget *comment_view; char const *error_str = _("Could not create the Scenario Add dialog."); GString *buf; if (wbcg == NULL) return; wbc = WORKBOOK_CONTROL (wbcg); /* Only pop up one copy per workbook */ if (gnumeric_dialog_raise_if_exists (wbcg, "ScenarioAdd")) return; state = g_new (ScenariosState, 1); if (dialog_tool_init (&state->base, wbcg, wb_control_cur_sheet (wbc), GNUMERIC_HELP_LINK_SCENARIOS_ADD, "scenario-add.ui", "ScenarioAdd", error_str, "ScenarioAdd", G_CALLBACK (scenario_add_ok_clicked_cb), NULL, G_CALLBACK (scenario_add_update_sensitivity_cb), GNM_EE_SHEET_OPTIONAL)) { g_free (state); return; } state->name_entry = go_gtk_builder_get_widget (state->base.gui, "name_entry"); if (state->name_entry == NULL) return; comment_view = go_gtk_builder_get_widget (state->base.gui, "comment_view"); if (comment_view == NULL) return; buf = g_string_new (NULL); g_string_append_printf (buf, _("Created on ")); dao_append_date (buf); gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view)), buf->str, strlen (buf->str)); g_string_free (buf, FALSE); state->base.gdao = NULL; gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->base.dialog), wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_editable_enters (GTK_WINDOW (state->base.dialog), GTK_WIDGET (state->name_entry)); scenario_add_update_sensitivity_cb (NULL, state); tool_load_selection ((GenericToolState *)state, TRUE); }
/** * stf_dialog_editables_enter * @pagedata: mother struct * * Make <Ret> in text fields activate default. * * returns: nothing **/ static void stf_dialog_editables_enter (StfDialogData *pagedata) { #if 0 gnumeric_editable_enters (pagedata->window, GTK_WIDGET (&pagedata->main.main_startrow->entry)); gnumeric_editable_enters (pagedata->window, GTK_WIDGET (&pagedata->main.main_stoprow->entry)); gnumeric_editable_enters (pagedata->window, GTK_WIDGET (pagedata->csv.csv_customseparator)); gnumeric_combo_enters (pagedata->window, pagedata->csv.csv_textindicator); gnumeric_editable_enters (pagedata->window, GTK_WIDGET (&pagedata->fixed.fixed_colend->entry)); go_format_sel_editable_enters (pagedata->format.format_selector, pagedata->window); #endif }
/** * dialog_tool_init_outputs: * @state: * @sensitivity_cb: * * Setup the standard output information * **/ void dialog_tool_init_outputs (GenericToolState *state, GCallback sensitivity_cb) { GtkWidget *dao_box; dao_box = glade_xml_get_widget (state->gui, "dao"); if (dao_box == NULL) { state->gdao = NULL; return; } state->gdao = gnm_dao_new (state->wbcg, NULL); gtk_box_pack_start (GTK_BOX (dao_box), state->gdao, TRUE, TRUE, 0); gtk_widget_show (state->gdao); g_signal_connect_after (G_OBJECT (state->gdao), "readiness-changed", G_CALLBACK (sensitivity_cb), state); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->gdao)); return; }
void dialog_new_view (WBCGtk *wbcg) { ViewState *state; GtkBuilder *gui; if (gnumeric_dialog_raise_if_exists (wbcg, VIEW_DIALOG_KEY)) return; gui = gnm_gtk_builder_new ("view.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new (ViewState, 1); state->wbcg = wbcg; state->gui = gui; state->dialog = go_gtk_builder_get_widget (gui, "View"); state->location_elsewhere = GTK_RADIO_BUTTON (go_gtk_builder_get_widget (gui, "location_elsewhere")); state->location_display_name = GTK_ENTRY (go_gtk_builder_get_widget (gui, "location_display_name")); g_return_if_fail (state->dialog != NULL); { GdkScreen *this_screen = gtk_window_get_screen (wbcg_toplevel (wbcg)); GdkDisplay *this_display = gdk_screen_get_display (this_screen); int n_screens = gdk_display_get_n_screens (this_display); GtkBox *box = GTK_BOX (go_gtk_builder_get_widget (gui, "location_screens_vbox")); int i; for (i = 0; i < n_screens; i++) { /* Get this for every screen -- it might change. */ GSList *group = gtk_radio_button_get_group (state->location_elsewhere); GdkScreen *screen = gdk_display_get_screen (this_display, i); char *label = screen == this_screen ? (n_screens == 1 ? g_strdup (_("This screen")) : g_strdup_printf (_("Screen %d [This screen]"), i)) : g_strdup_printf (_("Screen %d"), i); GtkWidget *button = gtk_radio_button_new_with_label (group, label); g_free (label); if (screen == this_screen) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_object_set_data (G_OBJECT (button), "screen", screen); gtk_box_pack_start (box, button, TRUE, TRUE, 0); } } g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "ok_button")), "clicked", G_CALLBACK (cb_view_ok_clicked), state); g_signal_connect (G_OBJECT (go_gtk_builder_get_widget (gui, "cancel_button")), "clicked", G_CALLBACK (cb_view_cancel_clicked), state); gnm_link_button_and_entry (GTK_WIDGET (state->location_elsewhere), GTK_WIDGET (state->location_display_name)); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->location_display_name)); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_VIEW); gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), VIEW_DIALOG_KEY); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_view_destroy); gtk_widget_show_all (state->dialog); }
void dialog_search (WBCGtk *wbcg) { GtkBuilder *gui; GtkDialog *dialog; DialogState *dd; GtkGrid *grid; g_return_if_fail (wbcg != NULL); /* Only one guru per workbook. */ if (wbc_gtk_get_guru (wbcg)) return; gui = gnm_gtk_builder_load ("search.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; dialog = GTK_DIALOG (gtk_builder_get_object (gui, "search_dialog")); dd = g_new (DialogState, 1); dd->wbcg = wbcg; dd->gui = gui; dd->dialog = dialog; dd->matches = g_ptr_array_new (); dd->prev_button = go_gtk_builder_get_widget (gui, "prev_button"); dd->next_button = go_gtk_builder_get_widget (gui, "next_button"); dd->notebook = GTK_NOTEBOOK (gtk_builder_get_object (gui, "notebook")); dd->notebook_matches_page = gtk_notebook_page_num (dd->notebook, go_gtk_builder_get_widget (gui, "matches_tab")); dd->rangetext = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (dd->rangetext, 0, GNM_EE_MASK); grid = GTK_GRID (gtk_builder_get_object (gui, "normal-grid")); gtk_widget_set_hexpand (GTK_WIDGET (dd->rangetext), TRUE); gtk_grid_attach (grid, GTK_WIDGET (dd->rangetext), 1, 6, 1, 1); { char *selection_text = selection_to_string ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), TRUE); gnm_expr_entry_load_from_text (dd->rangetext, selection_text); g_free (selection_text); } dd->gentry = GTK_ENTRY (gtk_entry_new ()); gtk_widget_set_hexpand (GTK_WIDGET (dd->gentry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (dd->gentry), 1, 0, 1, 1); gtk_widget_grab_focus (GTK_WIDGET (dd->gentry)); gnumeric_editable_enters (GTK_WINDOW (dialog), GTK_WIDGET (dd->gentry)); dd->matches_table = make_matches_table (dd); { GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (dd->matches_table)); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (gui, "matches_vbox")), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); } /* Set sensitivity of buttons. */ cursor_change (dd->matches_table, dd); #define SETW(w,f) gtk_toggle_button_set_active \ (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, w)), f()) SETW("search_expr", gnm_conf_get_searchreplace_change_cell_expressions); SETW("search_other", gnm_conf_get_searchreplace_change_cell_other); SETW("search_string", gnm_conf_get_searchreplace_change_cell_strings); SETW("search_comments", gnm_conf_get_searchreplace_change_comments); SETW("search_expr_results", gnm_conf_get_searchreplace_search_results); SETW("ignore_case", gnm_conf_get_searchreplace_ignore_case); SETW("match_words", gnm_conf_get_searchreplace_whole_words_only); #undef SETW gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, search_type_group[gnm_conf_get_searchreplace_regex ()])), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, direction_group [gnm_conf_get_searchreplace_columnmajor () ? 1 : 0])), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (gui, scope_group[gnm_conf_get_searchreplace_scope ()])), TRUE); g_signal_connect (G_OBJECT (dd->matches_table), "cursor_changed", G_CALLBACK (cursor_change), dd); g_signal_connect (G_OBJECT (dd->matches_table), "select_cursor_row", G_CALLBACK (cb_next), dd); go_gtk_builder_signal_connect (gui, "search_button", "clicked", G_CALLBACK (search_clicked), dd); g_signal_connect (G_OBJECT (dd->prev_button), "clicked", G_CALLBACK (prev_clicked), dd); g_signal_connect (G_OBJECT (dd->next_button), "clicked", G_CALLBACK (next_clicked), dd); go_gtk_builder_signal_connect_swapped (gui, "close_button", "clicked", G_CALLBACK (gtk_widget_destroy), dd->dialog); g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry (dd->rangetext)), "focus-in-event", G_CALLBACK (range_focused), dd); go_gtk_builder_signal_connect (gui, "scope_range", "toggled", G_CALLBACK (cb_focus_on_entry), dd->rangetext); wbc_gtk_attach_guru_with_unfocused_rs (wbcg, GTK_WIDGET (dialog), dd->rangetext); g_object_set_data_full (G_OBJECT (dialog), "state", dd, (GDestroyNotify) free_state); gnm_dialog_setup_destroy_handlers (dialog, wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_SEARCH); gnumeric_restore_window_geometry (GTK_WINDOW (dialog), SEARCH_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog)); gtk_widget_show_all (GTK_WIDGET (dialog)); }
/** * 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; }
void dialog_merge (WBCGtk *wbcg) { MergeState *state; GtkBuilder *gui; GtkGrid *grid; GtkWidget *scrolled; GtkTreeViewColumn *column; GtkTreeSelection *selection; GnmRange const *r; g_return_if_fail (wbcg != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, MERGE_KEY)) return; gui = gnm_gtk_builder_load ("merge.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new0 (MergeState, 1); state->gui = gui; state->wbcg = wbcg; state->sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (state->wbcg)); state->dialog = go_gtk_builder_get_widget (gui, "Merge"); state->warning_dialog = NULL; state->add_btn = go_gtk_builder_get_widget (gui, "add_button"); state->delete_btn = go_gtk_builder_get_widget (gui, "remove_button"); state->merge_btn = go_gtk_builder_get_widget (gui, "merge_button"); state->change_btn = go_gtk_builder_get_widget (gui, "change_button"); state->cancel_btn = go_gtk_builder_get_widget (gui, "cancel_button"); gtk_widget_set_size_request (state->delete_btn, 100, -1); gtk_button_set_alignment (GTK_BUTTON (state->add_btn), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->delete_btn), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->change_btn), 0., .5); grid = GTK_GRID (go_gtk_builder_get_widget (gui, "main-grid")); state->zone = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->zone, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->zone)); gtk_label_set_mnemonic_widget (GTK_LABEL (go_gtk_builder_get_widget (gui, "var1-label")), GTK_WIDGET (state->zone)); gtk_widget_set_hexpand (GTK_WIDGET (state->zone), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->zone), 1, 0, 2, 1); r = selection_first_range ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), NULL, NULL); if (r != NULL) gnm_expr_entry_load_from_range (state->zone, state->sheet, r); state->data = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->data, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->data), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->data), 0, 5, 1, 1); state->field = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->field, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->field), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->field), 1, 5, 1, 1); scrolled = go_gtk_builder_get_widget (state->gui, "scrolled"); state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING); state->list = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); selection = gtk_tree_view_get_selection (state->list); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); column = gtk_tree_view_column_new_with_attributes (_("Input Data"), gtk_cell_renderer_text_new (), "text", DATA_RANGE, NULL); gtk_tree_view_column_set_sort_column_id (column, DATA_RANGE); gtk_tree_view_column_set_min_width (column, 150); gtk_tree_view_append_column (state->list, column); column = gtk_tree_view_column_new_with_attributes (_("Merge Field"), gtk_cell_renderer_text_new (), "text", FIELD_LOCATION, NULL); gtk_tree_view_column_set_sort_column_id (column, FIELD_LOCATION); gtk_tree_view_column_set_min_width (column, 100); gtk_tree_view_append_column (state->list, column); gtk_tree_view_set_headers_clickable (state->list, TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->list)); cb_merge_update_buttons (NULL, state); g_signal_connect (selection, "changed", G_CALLBACK (cb_merge_selection_changed), state); g_signal_connect_after (G_OBJECT (state->zone), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect_after (G_OBJECT (state->data), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect_after (G_OBJECT (state->field), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect (G_OBJECT (state->add_btn), "clicked", G_CALLBACK (cb_merge_add_clicked), state); g_signal_connect (G_OBJECT (state->change_btn), "clicked", G_CALLBACK (cb_merge_change_clicked), state); g_signal_connect (G_OBJECT (state->delete_btn), "clicked", G_CALLBACK (cb_merge_delete_clicked), state); g_signal_connect (G_OBJECT (state->merge_btn), "clicked", G_CALLBACK (cb_merge_merge_clicked), state); g_signal_connect (G_OBJECT (state->cancel_btn), "clicked", G_CALLBACK (cb_merge_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_DATA_MERGE); gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), MERGE_KEY); /* a candidate for merging into attach guru */ g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_merge_destroy); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); wbc_gtk_attach_guru (state->wbcg, GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog)); }
/** * dialog_init: * @state: * * Create the dialog (guru). * **/ static gboolean dialog_init (GoalSeekState *state) { GtkTable *table; state->dialog = glade_xml_get_widget (state->gui, "GoalSeek"); if (state->dialog == NULL) return TRUE; state->close_button = glade_xml_get_widget (state->gui, "closebutton"); g_signal_connect (G_OBJECT (state->close_button), "clicked", G_CALLBACK (cb_dialog_close_clicked), state); state->cancel_button = glade_xml_get_widget (state->gui, "cancelbutton"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_cancel_clicked), state); state->apply_button = glade_xml_get_widget (state->gui, "applybutton"); g_signal_connect (G_OBJECT (state->apply_button), "clicked", G_CALLBACK (cb_dialog_apply_clicked), state); gnumeric_init_help_button ( glade_xml_get_widget (state->gui, "helpbutton"), GNUMERIC_HELP_LINK_GOAL_SEEK); state->to_value_entry = glade_xml_get_widget (state->gui, "to_value_entry"); state->at_least_entry = glade_xml_get_widget (state->gui, "at_least-entry"); state->at_most_entry = glade_xml_get_widget (state->gui, "at_most-entry"); state->target_value_label = glade_xml_get_widget (state->gui, "target-value"); gtk_label_set_justify (GTK_LABEL (state->target_value_label), GTK_JUSTIFY_RIGHT); state->current_value_label = glade_xml_get_widget (state->gui, "current-value"); gtk_label_set_justify (GTK_LABEL (state->current_value_label), GTK_JUSTIFY_RIGHT); state->solution_label = glade_xml_get_widget (state->gui, "solution"); gtk_label_set_justify (GTK_LABEL (state->solution_label), GTK_JUSTIFY_RIGHT); state->result_label = glade_xml_get_widget (state->gui, "result-label"); state->result_table = glade_xml_get_widget (state->gui, "result-table"); table = GTK_TABLE (glade_xml_get_widget (state->gui, "goal-table")); state->set_cell_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->set_cell_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->set_cell_entry), 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->set_cell_entry)); dialog_preload_selection (state, state->set_cell_entry); gtk_widget_show (GTK_WIDGET (state->set_cell_entry)); state->change_cell_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->change_cell_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->change_cell_entry), 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->change_cell_entry)); dialog_preload_selection (state, state->change_cell_entry); gtk_widget_show (GTK_WIDGET (state->change_cell_entry)); g_signal_connect (G_OBJECT (state->dialog), "realize", G_CALLBACK (dialog_realized), state); state->old_value = NULL; state->old_cell = NULL; wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_destroy); gnm_expr_entry_grab_focus (state->set_cell_entry, FALSE); return FALSE; }
void dialog_zoom (WBCGtk *wbcg, Sheet *sheet) { ZoomState *state; GSList *l, *sheets; int i, row, cur_row; gboolean is_custom = TRUE; GtkRadioButton *radio; GtkWidget *focus_target; GladeXML *gui; GtkTreeViewColumn *column; g_return_if_fail (wbcg != NULL); g_return_if_fail (sheet != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, ZOOM_DIALOG_KEY)) return; gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg), "dialog-zoom.glade", NULL, NULL); if (gui == NULL) return; state = g_new (ZoomState, 1); state->wbcg = wbcg; state->gui = gui; state->dialog = glade_xml_get_widget (state->gui, "Zoom"); g_return_if_fail (state->dialog != NULL); /* Get the list of sheets */ state->sheet_list_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); state->sheet_list = GTK_TREE_VIEW (glade_xml_get_widget (state->gui, "sheet_list")); gtk_tree_view_set_headers_visible (state->sheet_list, FALSE); gtk_tree_view_set_model (state->sheet_list, GTK_TREE_MODEL (state->sheet_list_model)); state->sheet_list_selection = gtk_tree_view_get_selection (state->sheet_list); gtk_tree_selection_set_mode (state->sheet_list_selection, GTK_SELECTION_MULTIPLE); column = gtk_tree_view_column_new_with_attributes (_("Name"), gtk_cell_renderer_text_new (), "text", 0, NULL); gtk_tree_view_column_set_sort_column_id (column, COL_SHEET_NAME); gtk_tree_view_append_column (GTK_TREE_VIEW (state->sheet_list), column); sheets = workbook_sheets (wb_control_get_workbook (WORKBOOK_CONTROL (wbcg))); cur_row = row = 0; for (l = sheets; l; l = l->next) { GtkTreeIter iter; Sheet *this_sheet = l->data; gtk_list_store_append (state->sheet_list_model, &iter); gtk_list_store_set (state->sheet_list_model, &iter, COL_SHEET_NAME, this_sheet->name_unquoted, COL_SHEET_PTR, this_sheet, -1); if (this_sheet == sheet) cur_row = row; row++; } g_slist_free (sheets); { GtkTreePath *path = gtk_tree_path_new_from_indices (cur_row, -1); gtk_tree_view_set_cursor (state->sheet_list, path, NULL, FALSE); gtk_tree_path_free (path); } state->zoom = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "zoom")); g_return_if_fail (state->zoom != NULL); state->custom = GTK_RADIO_BUTTON (glade_xml_get_widget (state->gui, "radio_custom")); g_return_if_fail (state->custom != NULL); focus_target = GTK_WIDGET (state->custom); g_signal_connect (G_OBJECT (state->custom), "clicked", G_CALLBACK (focus_to_custom), (gpointer) state); g_signal_connect (G_OBJECT (state->zoom), "focus_in_event", G_CALLBACK (custom_selected), state); for (i = 0; buttons[i].name != NULL; i++) { radio = GTK_RADIO_BUTTON (glade_xml_get_widget (state->gui, buttons[i].name)); g_return_if_fail (radio != NULL); g_object_set_data (G_OBJECT (radio), ZOOM_DIALOG_FACTOR_KEY, GINT_TO_POINTER(buttons[i].factor)); g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (radio_toggled), state); if (((int)(sheet->last_zoom_factor_used * 100. + .5)) == buttons[i].factor) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); is_custom = FALSE; focus_target = GTK_WIDGET (radio); } } if (is_custom) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->custom), TRUE); gtk_spin_button_set_value (state->zoom, (int)(sheet->last_zoom_factor_used * 100. + .5)); } state->ok_button = glade_xml_get_widget (state->gui, "ok_button"); g_signal_connect (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_zoom_ok_clicked), state); state->cancel_button = glade_xml_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_zoom_cancel_clicked), state); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (&state->zoom->entry)); gnumeric_init_help_button ( glade_xml_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_ZOOM); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), ZOOM_DIALOG_KEY); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_zoom_destroy); wbc_gtk_attach_guru (state->wbcg, state->dialog); gtk_widget_show (state->dialog); gtk_widget_grab_focus (focus_target); }
static void dialog_init (SortFlowState *state) { GtkTable *table; GtkWidget *scrolled; GtkTreeViewColumn *column; GtkCellRenderer *renderer; gboolean col_rb; GnmRange const *range; table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "cell_sort_options_table")); /* setup range entry */ state->range_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->range_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->range_entry), 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->range_entry)); gnm_expr_entry_set_update_policy (state->range_entry, GTK_UPDATE_DISCONTINUOUS); gtk_widget_show (GTK_WIDGET (state->range_entry)); g_signal_connect_swapped (G_OBJECT (state->range_entry), "changed", G_CALLBACK (cb_update_to_new_range), state); state->locale_selector = GO_LOCALE_SEL (go_locale_sel_new ()); gtk_widget_show_all (GTK_WIDGET (state->locale_selector)); gtk_table_attach (table, GTK_WIDGET (state->locale_selector), 2, 3, 5, 6, GTK_EXPAND | GTK_FILL, 0, 0, 0); table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "cell_sort_spec_table")); /* setup add entry */ state->add_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->add_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->add_entry), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->add_entry)); gtk_widget_show (GTK_WIDGET (state->add_entry)); /* Set-up tree view */ scrolled = go_gtk_builder_get_widget (state->gui, "scrolled_cell_sort_list"); state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT); state->treeview = GTK_TREE_VIEW ( gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); state->selection = gtk_tree_view_get_selection (state->treeview); gtk_tree_selection_set_mode (state->selection, GTK_SELECTION_BROWSE); g_signal_connect_swapped (state->selection, "changed", G_CALLBACK (cb_sort_selection_changed), state); state->header_column = gtk_tree_view_column_new_with_attributes (_("Header"), gtk_cell_renderer_text_new (), "text", ITEM_HEADER, NULL); gtk_tree_view_append_column (state->treeview, state->header_column); column = gtk_tree_view_column_new_with_attributes (_("Row/Column"), gtk_cell_renderer_text_new (), "text", ITEM_NAME, NULL); gtk_tree_view_append_column (state->treeview, column); renderer = gnumeric_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_descending), state); column = gtk_tree_view_column_new_with_attributes ("", renderer, "active", ITEM_DESCENDING, "pixbuf", ITEM_DESCENDING_IMAGE, NULL); gtk_tree_view_append_column (state->treeview, column); renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_case_sensitive), state); column = gtk_tree_view_column_new_with_attributes (_("Case Sensitive"), renderer, "active", ITEM_CASE_SENSITIVE, NULL); gtk_tree_view_append_column (state->treeview, column); gtk_tree_view_columns_autosize (state->treeview); g_signal_connect (G_OBJECT (state->treeview), "key_press_event", G_CALLBACK (cb_treeview_keypress), state); g_signal_connect (G_OBJECT (state->treeview), "button_press_event", G_CALLBACK (cb_treeview_button_press), state); #if 0 /* We are currently not supporting `by-value' vs not. */ renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_sort_by_value), state); column = gtk_tree_view_column_new_with_attributes (_("By Value"), renderer, "active", ITEM_SORT_BY_VALUE, NULL); gtk_tree_view_append_column (state->treeview, column); #endif gtk_tree_view_set_reorderable (state->treeview,TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->treeview)); gtk_widget_show (GTK_WIDGET (state->treeview)); /* Set-up other widgets */ state->cell_sort_row_rb = go_gtk_builder_get_widget (state->gui, "cell_sort_row_rb"); state->cell_sort_col_rb = go_gtk_builder_get_widget (state->gui, "cell_sort_col_rb"); g_signal_connect_swapped (G_OBJECT (state->cell_sort_row_rb), "toggled", G_CALLBACK (cb_update_to_new_range), state); state->cell_sort_header_check = go_gtk_builder_get_widget (state->gui, "cell_sort_header_check"); g_signal_connect_swapped (G_OBJECT (state->cell_sort_header_check), "toggled", G_CALLBACK (cb_sort_header_check), state); state->retain_format_check = go_gtk_builder_get_widget (state->gui, "retain_format_button"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->retain_format_check), gnm_conf_get_core_sort_default_retain_formats ()); /* Set-up buttons */ state->up_button = go_gtk_builder_get_widget (state->gui, "up_button"); g_signal_connect_swapped (G_OBJECT (state->up_button), "clicked", G_CALLBACK (cb_up), state); state->down_button = go_gtk_builder_get_widget (state->gui, "down_button"); g_signal_connect_swapped (G_OBJECT (state->down_button), "clicked", G_CALLBACK (cb_down), state); state->add_button = go_gtk_builder_get_widget (state->gui, "add_button"); g_signal_connect_swapped (G_OBJECT (state->add_button), "clicked", G_CALLBACK (cb_add_clicked), state); gtk_widget_set_sensitive (state->add_button, TRUE); state->delete_button = go_gtk_builder_get_widget (state->gui, "delete_button"); g_signal_connect (G_OBJECT (state->delete_button), "clicked", G_CALLBACK (cb_delete_clicked), state); gtk_widget_set_sensitive (state->delete_button, FALSE); state->clear_button = go_gtk_builder_get_widget (state->gui, "clear_button"); g_signal_connect_swapped (G_OBJECT (state->clear_button), "clicked", G_CALLBACK (cb_clear_clicked), state); gtk_widget_set_sensitive (state->clear_button, FALSE); gtk_button_set_alignment (GTK_BUTTON (state->up_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->down_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->add_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->delete_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->clear_button), 0., .5); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_CELL_SORT); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect_swapped (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_dialog_ok_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); /* Finish dialog signals */ wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_destroy); range = dialog_load_selection (state, &col_rb); cb_sort_selection_changed (state); gnm_expr_entry_grab_focus(GNM_EXPR_ENTRY (state->add_entry), TRUE); }
void dialog_search (WBCGtk *wbcg) { GtkBuilder *gui; GtkDialog *dialog; DialogState *dd; GtkTable *table; char *f; g_return_if_fail (wbcg != NULL); #ifdef USE_GURU /* Only one guru per workbook. */ if (wbc_gtk_get_guru (wbcg)) return; #endif f = g_build_filename (gnm_sys_data_dir (), "ui", "search.ui", NULL); gui = go_gtk_builder_new (f, NULL, GO_CMD_CONTEXT (wbcg)); g_free (f); if (gui == NULL) return; dialog = GTK_DIALOG (gtk_builder_get_object (gui, "search_dialog")); dd = g_new (DialogState, 1); dd->wbcg = wbcg; dd->gui = gui; dd->dialog = dialog; dd->matches = g_ptr_array_new (); dd->prev_button = go_gtk_builder_get_widget (gui, "prev_button"); dd->next_button = go_gtk_builder_get_widget (gui, "next_button"); dd->notebook = GTK_NOTEBOOK (gtk_builder_get_object (gui, "notebook")); dd->notebook_matches_page = gtk_notebook_page_num (dd->notebook, go_gtk_builder_get_widget (gui, "matches_tab")); dd->rangetext = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (dd->rangetext, 0, GNM_EE_MASK); table = GTK_TABLE (gtk_builder_get_object (gui, "page1-table")); gtk_table_attach (table, GTK_WIDGET (dd->rangetext), 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, 0, 0, 0); { char *selection_text = selection_to_string ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), TRUE); gnm_expr_entry_load_from_text (dd->rangetext, selection_text); g_free (selection_text); } dd->gentry = GTK_ENTRY (gtk_entry_new ()); gtk_table_attach (table, GTK_WIDGET (dd->gentry), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_grab_focus (GTK_WIDGET (dd->gentry)); gnumeric_editable_enters (GTK_WINDOW (dialog), GTK_WIDGET (dd->gentry)); dd->matches_table = make_matches_table (dd); { GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (dd->matches_table)); gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (gui, "matches_vbox")), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); } /* Set sensitivity of buttons. */ cursor_change (dd->matches_table, dd); g_signal_connect (G_OBJECT (dd->matches_table), "cursor_changed", G_CALLBACK (cursor_change), dd); g_signal_connect (G_OBJECT (dd->matches_table), "select_cursor_row", G_CALLBACK (cb_next), dd); go_gtk_builder_signal_connect (gui, "search_button", "clicked", G_CALLBACK (search_clicked), dd); g_signal_connect (G_OBJECT (dd->prev_button), "clicked", G_CALLBACK (prev_clicked), dd); g_signal_connect (G_OBJECT (dd->next_button), "clicked", G_CALLBACK (next_clicked), dd); go_gtk_builder_signal_connect_swapped (gui, "close_button", "clicked", G_CALLBACK (gtk_widget_destroy), dd->dialog); g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry (dd->rangetext)), "focus-in-event", G_CALLBACK (range_focused), dd); go_gtk_builder_signal_connect (gui, "scope_range", "toggled", G_CALLBACK (cb_focus_on_entry), dd->rangetext); #ifdef USE_GURU wbc_gtk_attach_guru_with_unfocused_rs (wbcg, GTK_WIDGET (dialog), dd->rangetext); #endif g_object_set_data_full (G_OBJECT (dialog), "state", dd, (GDestroyNotify) free_state); gnm_dialog_setup_destroy_handlers (dialog, wbcg, GNM_DIALOG_DESTROY_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_SEARCH); gnumeric_restore_window_geometry (GTK_WINDOW (dialog), SEARCH_KEY); go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog)); gtk_widget_show_all (GTK_WIDGET (dialog)); }