X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fweight-cases-dialog.c;h=066c5e54e1b27d9a2e5d2278d56f4cd7a82a5cf3;hb=a2979bf95f3eb83e88a3bd723c09f22548775de5;hp=1a637f3c660d0cbbb5ff0a9548ad4b567c3d9333;hpb=1d5a97ba2afec23855a8294ff2814ab052f6777a;p=pspp
diff --git a/src/ui/gui/weight-cases-dialog.c b/src/ui/gui/weight-cases-dialog.c
index 1a637f3c66..066c5e54e1 100644
--- a/src/ui/gui/weight-cases-dialog.c
+++ b/src/ui/gui/weight-cases-dialog.c
@@ -1,59 +1,63 @@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2007 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2007, 2010 Free Software Foundation
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
#include
#include "weight-cases-dialog.h"
#include "psppire-selector.h"
#include "psppire-dialog.h"
-#include "helper.h"
-#include "data-editor.h"
+#include "executor.h"
+#include "psppire-data-window.h"
#include "dict-display.h"
-#include
-#include "syntax-editor.h"
+#include "helper.h"
#include
-#include
#include
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-/* FIXME: These shouldn't be here */
-#include
#include "psppire-var-store.h"
+struct weight_cases_dialog
+{
+ PsppireDict *dict;
+ GtkEntry *entry;
+ GtkLabel *status;
+ GtkToggleButton *off;
+ GtkToggleButton *on;
+};
+
static void
on_select (PsppireSelector *sel, gpointer data)
{
- GtkRadioButton *radiobutton2 = data;
+ struct weight_cases_dialog *wcd = data;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton2), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wcd->on), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (wcd->on), TRUE);
}
static void
on_deselect (PsppireSelector *sel, gpointer data)
{
- GtkRadioButton *radiobutton1 = data;
+ struct weight_cases_dialog *wcd = data;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton1), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wcd->off), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (wcd->on), FALSE);
}
@@ -65,15 +69,6 @@ on_toggle (GtkToggleButton *button, gpointer data)
gtk_entry_set_text (entry, "");
}
-struct weight_cases_dialog
-{
- PsppireDict *dict;
- GtkEntry *entry;
- GtkLabel *status;
- GtkToggleButton *off;
- GtkToggleButton *on;
-};
-
static void
refresh (PsppireDialog *dialog, const struct weight_cases_dialog *wcd)
{
@@ -106,52 +101,43 @@ static gchar * generate_syntax (const struct weight_cases_dialog *wcd);
/* Pops up the Weight Cases dialog box */
void
-weight_cases_dialog (GObject *o, gpointer data)
+weight_cases_dialog (PsppireDataWindow *de)
{
gint response;
- struct data_editor *de = data;
struct weight_cases_dialog wcd;
- GladeXML *xml = XML_NEW ("psppire.glade");
+ GtkBuilder *xml = builder_new ("psppire.ui");
GtkWidget *dialog = get_widget_assert (xml, "weight-cases-dialog");
GtkWidget *source = get_widget_assert (xml, "weight-cases-treeview");
GtkWidget *entry = get_widget_assert (xml, "weight-cases-entry");
- GtkWidget *selector = get_widget_assert (xml, "weight-cases-selector");
GtkWidget *radiobutton1 = get_widget_assert (xml,
"weight-cases-radiobutton1");
GtkWidget *radiobutton2 = get_widget_assert (xml, "radiobutton2");
GtkWidget *status = get_widget_assert (xml, "weight-status-label");
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
-
- PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
+ GtkWidget *selector = get_widget_assert (xml, "weight-cases-selector");
- gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window);
+ PsppireVarStore *vs = NULL;
- g_signal_connect (radiobutton1, "toggled", G_CALLBACK (on_toggle), entry);
- g_signal_connect (selector, "selected", G_CALLBACK (on_select),
- radiobutton2);
+ g_object_get (de->data_editor, "var-store", &vs, NULL);
+ g_object_get (vs, "dictionary", &wcd.dict, NULL);
- g_signal_connect (selector, "de-selected", G_CALLBACK (on_deselect),
- radiobutton1);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
- attach_dictionary_to_treeview (GTK_TREE_VIEW (source),
- vs->dict,
- GTK_SELECTION_SINGLE,
- var_is_numeric
- );
+ g_signal_connect (radiobutton1, "toggled", G_CALLBACK (on_toggle), entry);
- psppire_selector_set_subjects (PSPPIRE_SELECTOR (selector),
- source,
- entry,
- insert_source_row_into_entry,
- is_currently_in_entry
- );
+ g_signal_connect (selector, "selected", G_CALLBACK (on_select), &wcd);
+ g_signal_connect (selector, "de-selected", G_CALLBACK (on_deselect), &wcd);
+
+ g_object_set (source, "model", wcd.dict,
+ "selection-mode", GTK_SELECTION_SINGLE,
+ "predicate", var_is_numeric,
+ NULL);
+ psppire_selector_set_filter_func (PSPPIRE_SELECTOR (selector),
+ is_currently_in_entry);
- wcd.dict = vs->dict;
wcd.entry = GTK_ENTRY (entry);
wcd.status = GTK_LABEL (status);
wcd.off = GTK_TOGGLE_BUTTON (radiobutton1);
@@ -166,25 +152,10 @@ weight_cases_dialog (GObject *o, gpointer data)
switch (response)
{
case GTK_RESPONSE_OK:
- {
- gchar *syntax = generate_syntax (&wcd);
- struct getl_interface *sss = create_syntax_string_source (syntax);
- execute_syntax (sss);
-
- g_free (syntax);
- }
+ g_free (execute_syntax_string (generate_syntax (&wcd)));
break;
case PSPPIRE_RESPONSE_PASTE:
- {
- gchar *syntax = generate_syntax (&wcd);
-
- struct syntax_editor *se =
- (struct syntax_editor *) window_create (WINDOW_SYNTAX, NULL);
-
- gtk_text_buffer_insert_at_cursor (se->buffer, syntax, -1);
-
- g_free (syntax);
- }
+ g_free (paste_syntax_to_window (generate_syntax (&wcd)));
break;
default:
break;