Update Spanish translation
[gnumeric.git] / src / dialogs / dao-gui-utils.c
blob9db7ad9b82b4db352524bd3ec6d19237e047da44
2 /*
3 * dao-gui-utils.c:
5 * Authors:
6 * Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
7 * Andreas J. Guelzow <aguelzow@taliesin.ca>
9 * (C) Copyright 2000, 2001 by Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
10 * (C) Copyright 2001, 2002 by Andreas J. Guelzow <aguelzow@taliesin.ca>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses/>.
26 #include <gnumeric-config.h>
27 #include <glib/gi18n-lib.h>
28 #include <dialogs/dao-gui-utils.h>
30 #include <value.h>
31 #include <gui-util.h>
32 #include <selection.h>
33 #include <widgets/gnm-dao.h>
34 #include <dialogs/tool-dialogs.h>
37 /**
38 * dialog__tool_preset_to_range:
39 * @state:
41 * Load selection into range and switch to output range
43 **/
45 void
46 dialog_tool_preset_to_range (GnmGenericToolState *state)
48 GnmRange const *sel;
49 GtkWidget *w;
51 g_return_if_fail (state != NULL);
52 g_return_if_fail (state->gdao != NULL);
54 sel = selection_first_range (state->sv, NULL, NULL);
55 gnm_dao_load_range (GNM_DAO (state->gdao), sel);
56 gnm_dao_focus_output_range (GNM_DAO (state->gdao));
58 w = go_gtk_builder_get_widget (state->gui, "notebook1");
59 g_return_if_fail (w && GTK_IS_NOTEBOOK (w));
60 gtk_notebook_set_current_page (GTK_NOTEBOOK(w), 0);
64 /**
65 * dialog_tool_init_outputs: (skip)
66 * @state:
67 * @sensitivity_cb:
69 * Setup the standard output information
71 **/
72 void
73 dialog_tool_init_outputs (GnmGenericToolState *state, GCallback sensitivity_cb)
75 GtkWidget *dao_box;
77 dao_box = go_gtk_builder_get_widget (state->gui, "dao");
79 if (dao_box == NULL) {
80 state->gdao = NULL;
81 return;
84 state->gdao = gnm_dao_new (state->wbcg, NULL);
85 gtk_box_pack_start (GTK_BOX (dao_box), state->gdao,
86 TRUE, TRUE, 0);
87 gtk_widget_show (state->gdao);
88 g_signal_connect_after (G_OBJECT (state->gdao),
89 "readiness-changed",
90 G_CALLBACK (sensitivity_cb), state);
91 gnm_editable_enters (GTK_WINDOW (state->dialog),
92 GTK_WIDGET (state->gdao));
95 /**
96 * parse_output: (skip)
97 * @state:
98 * @dao:
100 * fill dao with information from the standard output section of a dialog
102 data_analysis_output_t *
103 parse_output (GnmGenericToolState *state, data_analysis_output_t *dao)
105 data_analysis_output_t *this_dao = dao;
107 gnm_dao_get_data (GNM_DAO (state->gdao), &this_dao);
108 if (this_dao->type == InPlaceOutput) {
109 GnmValue *output_range
110 = gnm_expr_entry_parse_as_value (
111 state->input_entry, state->sheet);
112 dao_load_from_value (this_dao, output_range);
113 value_release (output_range);
115 return this_dao;