1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2015 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "psppire-dialog-action-scatterplot.h"
22 #include "psppire-var-view.h"
24 #include "psppire-dialog.h"
25 #include "builder-wrapper.h"
30 #define _(msgid) gettext (msgid)
31 #define N_(msgid) msgid
34 static void psppire_dialog_action_scatterplot_init (PsppireDialogActionScatterplot *act);
35 static void psppire_dialog_action_scatterplot_class_init (PsppireDialogActionScatterplotClass *class);
37 G_DEFINE_TYPE (PsppireDialogActionScatterplot, psppire_dialog_action_scatterplot, PSPPIRE_TYPE_DIALOG_ACTION);
41 generate_syntax (PsppireDialogAction *act)
43 PsppireDialogActionScatterplot *ow = PSPPIRE_DIALOG_ACTION_SCATTERPLOT (act);
47 ds_init_cstr (&dss, "GRAPH SCATTERPLOT(BIVARIATE) = ");
49 ds_put_cstr (&dss, gtk_entry_get_text (GTK_ENTRY (ow->y_axis)));
51 ds_put_cstr (&dss, " WITH ");
53 ds_put_cstr (&dss, gtk_entry_get_text (GTK_ENTRY (ow->x_axis)));
55 ds_put_cstr (&dss, ".\n");
57 text = ds_steal_cstr (&dss);
65 dialog_state_valid (gpointer data)
67 PsppireDialogActionScatterplot *ow = PSPPIRE_DIALOG_ACTION_SCATTERPLOT (data);
69 const char *xvar = gtk_entry_get_text (GTK_ENTRY (ow->x_axis));
70 const char *yvar = gtk_entry_get_text (GTK_ENTRY (ow->y_axis));
72 if ( 0 == strcmp ("", xvar))
75 if ( 0 == strcmp ("", yvar))
83 refresh (PsppireDialogAction *rd_)
85 PsppireDialogActionScatterplot *ow = PSPPIRE_DIALOG_ACTION_SCATTERPLOT (rd_);
87 gtk_entry_set_text (GTK_ENTRY (ow->x_axis), "");
88 gtk_entry_set_text (GTK_ENTRY (ow->y_axis), "");
94 psppire_dialog_action_scatterplot_activate (PsppireDialogAction *a)
96 PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
97 PsppireDialogActionScatterplot *act = PSPPIRE_DIALOG_ACTION_SCATTERPLOT (a);
99 GHashTable *thing = psppire_dialog_action_get_hash_table (pda);
100 GtkBuilder *xml = g_hash_table_lookup (thing, a);
103 xml = builder_new ("scatterplot.ui");
104 g_hash_table_insert (thing, a, xml);
107 pda->dialog = get_widget_assert (xml, "scatterplot-dialog");
108 pda->source = get_widget_assert (xml, "scatterplot-treeview1");
110 act->y_axis = get_widget_assert (xml, "scatterplot-y-axis");
111 act->x_axis = get_widget_assert (xml, "scatterplot-x-axis");
113 psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid);
114 psppire_dialog_action_set_refresh (pda, refresh);
116 if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_scatterplot_parent_class)->activate)
117 PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_scatterplot_parent_class)->activate (pda);
121 psppire_dialog_action_scatterplot_class_init (PsppireDialogActionScatterplotClass *class)
123 psppire_dialog_action_set_activation (class, psppire_dialog_action_scatterplot_activate);
125 PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax;
130 psppire_dialog_action_scatterplot_init (PsppireDialogActionScatterplot *act)