Compilation: don't compile dialogs separately.
[gnumeric.git] / src / dialogs / dao-gui-utils.c
blob5d46a7dfa512d71b16a1e59c6769eba7caa89603
1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 /*
4 * dao-gui-utils.c:
6 * Authors:
7 * Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
8 * Andreas J. Guelzow <aguelzow@taliesin.ca>
10 * (C) Copyright 2000, 2001 by Jukka-Pekka Iivonen <jiivonen@hutcs.cs.hut.fi>
11 * (C) Copyright 2001, 2002 by Andreas J. Guelzow <aguelzow@taliesin.ca>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see <https://www.gnu.org/licenses/>.
27 #include <gnumeric-config.h>
28 #include <glib/gi18n-lib.h>
29 #include "dao-gui-utils.h"
31 #include "value.h"
32 #include "gui-util.h"
33 #include "selection.h"
34 #include <widgets/gnm-dao.h>
36 #include <gtk/gtk.h>
38 /**
39 * dialog__tool_preset_to_range:
40 * @state:
42 * Load selection into range and switch to output range
44 **/
46 void
47 dialog_tool_preset_to_range (GnmGenericToolState *state)
49 GnmRange const *sel;
50 GtkWidget *w;
52 g_return_if_fail (state != NULL);
53 g_return_if_fail (state->gdao != NULL);
55 sel = selection_first_range (state->sv, NULL, NULL);
56 gnm_dao_load_range (GNM_DAO (state->gdao), sel);
57 gnm_dao_focus_output_range (GNM_DAO (state->gdao));
59 w = go_gtk_builder_get_widget (state->gui, "notebook1");
60 g_return_if_fail (w && GTK_IS_NOTEBOOK (w));
61 gtk_notebook_set_current_page (GTK_NOTEBOOK(w), 0);
65 /**
66 * dialog_tool_init_outputs: (skip)
67 * @state:
68 * @sensitivity_cb:
70 * Setup the standard output information
72 **/
73 void
74 dialog_tool_init_outputs (GnmGenericToolState *state, GCallback sensitivity_cb)
76 GtkWidget *dao_box;
78 dao_box = go_gtk_builder_get_widget (state->gui, "dao");
80 if (dao_box == NULL) {
81 state->gdao = NULL;
82 return;
85 state->gdao = gnm_dao_new (state->wbcg, NULL);
86 gtk_box_pack_start (GTK_BOX (dao_box), state->gdao,
87 TRUE, TRUE, 0);
88 gtk_widget_show (state->gdao);
89 g_signal_connect_after (G_OBJECT (state->gdao),
90 "readiness-changed",
91 G_CALLBACK (sensitivity_cb), state);
92 gnm_editable_enters (GTK_WINDOW (state->dialog),
93 GTK_WIDGET (state->gdao));
96 /**
97 * parse_output: (skip)
98 * @state:
99 * @dao:
101 * fill dao with information from the standard output section of a dialog
103 data_analysis_output_t *
104 parse_output (GnmGenericToolState *state, data_analysis_output_t *dao)
106 data_analysis_output_t *this_dao = dao;
108 gnm_dao_get_data (GNM_DAO (state->gdao), &this_dao);
109 if (this_dao->type == InPlaceOutput) {
110 GnmValue *output_range
111 = gnm_expr_entry_parse_as_value (
112 state->input_entry, state->sheet);
113 dao_load_from_value (this_dao, output_range);
114 value_release (output_range);
116 return this_dao;