src/ui/gui/psppire-dialog-action-kmeans.h \
src/ui/gui/psppire-dialog-action-reliability.c \
src/ui/gui/psppire-dialog-action-reliability.h \
+ src/ui/gui/psppire-dialog-action-sort.c \
+ src/ui/gui/psppire-dialog-action-sort.h \
src/ui/gui/psppire-dialog-action-var-info.c \
src/ui/gui/psppire-dialog-action-var-info.h \
src/ui/gui/psppire-dialog-action-roc.c \
src/ui/gui/runs-dialog.h \
src/ui/gui/select-cases-dialog.c \
src/ui/gui/select-cases-dialog.h \
- src/ui/gui/sort-cases-dialog.c \
- src/ui/gui/sort-cases-dialog.h \
src/ui/gui/split-file-dialog.c \
src/ui/gui/split-file-dialog.h \
src/ui/gui/text-data-import-dialog.c \
</object>
</child>
<child>
- <object class="GtkAction" id="data_sort-cases">
+ <object class="PsppireDialogActionSort" id="data_sort-cases">
<property name="label" translatable="yes">_Sort Cases...</property>
<property name="name">data_sort-cases</property>
+ <property name="manager">uimanager1</property>
<property name="stock-id">gtk-sort-ascending</property>
<property name="tooltip" translatable="yes">Sort cases in the active dataset</property>
</object>
#include "ui/gui/recode-dialog.h"
#include "ui/gui/regression-dialog.h"
#include "ui/gui/select-cases-dialog.h"
-#include "ui/gui/sort-cases-dialog.h"
#include "ui/gui/split-file-dialog.h"
#include "ui/gui/t-test-independent-samples-dialog.h"
#include "ui/gui/t-test-one-sample.h"
connect_action (de, "data_select-cases", G_CALLBACK (select_cases_dialog));
- connect_action (de, "data_sort-cases", G_CALLBACK (sort_cases_dialog));
-
connect_action (de, "data_aggregate", G_CALLBACK (aggregate_dialog));
connect_action (de, "transform_compute", G_CALLBACK (compute_dialog));
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+
+#include "psppire-dialog-action-sort.h"
+
+#include "psppire-var-view.h"
+
+#include "psppire-dialog.h"
+#include "builder-wrapper.h"
+
+static void psppire_dialog_action_sort_init (PsppireDialogActionSort *act);
+static void psppire_dialog_action_sort_class_init (PsppireDialogActionSortClass *class);
+
+G_DEFINE_TYPE (PsppireDialogActionSort, psppire_dialog_action_sort, PSPPIRE_TYPE_DIALOG_ACTION);
+
+static char *
+generate_syntax (PsppireDialogAction *act)
+{
+ PsppireDialogActionSort *scd = PSPPIRE_DIALOG_ACTION_SORT (act);
+ gchar *text;
+ GString *string = g_string_new ("SORT CASES BY ");
+
+ gint n_vars = psppire_var_view_append_names (scd->variables, 0, string);
+
+ if ( n_vars == 0 )
+ {
+ g_string_assign (string, "");
+ }
+ else
+ {
+ const char up_down =
+ gtk_toggle_button_get_active (scd->ascending) ? 'A' : 'D';
+ g_string_append_printf (string, "(%c)", up_down);
+ g_string_append (string, ".");
+ }
+
+ text = string->str;
+
+ g_string_free (string, FALSE);
+
+ return text;
+}
+
+static void
+reset (PsppireDialogAction *act)
+{
+ PsppireDialogActionSort *scd = PSPPIRE_DIALOG_ACTION_SORT (act);
+
+ GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (scd->variables));
+
+ gtk_list_store_clear (GTK_LIST_STORE (liststore));
+
+ gtk_toggle_button_set_active (scd->ascending, TRUE);
+}
+
+
+
+
+static gboolean
+dialog_state_valid (PsppireDialogAction *act)
+{
+ PsppireDialogActionSort *scd = PSPPIRE_DIALOG_ACTION_SORT (act);
+ GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (scd->variables));
+
+ gint n_rows = gtk_tree_model_iter_n_children (model, NULL);
+
+ if ( n_rows == 0 )
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static void
+psppire_dialog_action_sort_activate (GtkAction *a)
+{
+ PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a);
+ PsppireDialogActionSort *act = PSPPIRE_DIALOG_ACTION_SORT (a);
+
+ GtkBuilder *xml = builder_new ("sort.ui");
+ pda->dialog = get_widget_assert (xml, "sort-cases-dialog");
+ pda->source = get_widget_assert (xml, "sort-cases-treeview1");
+
+ act->variables = get_widget_assert (xml, "sort-cases-treeview2");
+ act->ascending = get_widget_assert (xml, "sort-cases-radiobutton0");
+
+ psppire_dialog_action_set_refresh (pda, reset);
+
+ psppire_dialog_action_set_valid_predicate (pda,
+ dialog_state_valid);
+
+ if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_sort_parent_class)->activate)
+ PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_sort_parent_class)->activate (pda);
+}
+
+static void
+psppire_dialog_action_sort_class_init (PsppireDialogActionSortClass *class)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (class);
+ PsppireDialogActionClass *pdac = PSPPIRE_DIALOG_ACTION_CLASS (class);
+
+ action_class->activate = psppire_dialog_action_sort_activate;
+
+ pdac->generate_syntax = generate_syntax;
+}
+
+
+static void
+psppire_dialog_action_sort_init (PsppireDialogActionSort *act)
+{
+}
+
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-dialog-action.h"
+
+#ifndef __PSPPIRE_DIALOG_ACTION_SORT_H__
+#define __PSPPIRE_DIALOG_ACTION_SORT_H__
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_DIALOG_ACTION_SORT (psppire_dialog_action_sort_get_type ())
+
+#define PSPPIRE_DIALOG_ACTION_SORT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_SORT, PsppireDialogActionSort))
+
+#define PSPPIRE_DIALOG_ACTION_SORT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ PSPPIRE_TYPE_DIALOG_ACTION_SORT, \
+ PsppireDialogActionSortClass))
+
+
+#define PSPPIRE_IS_DIALOG_ACTION_SORT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_DIALOG_ACTION_SORT))
+
+#define PSPPIRE_IS_DIALOG_ACTION_SORT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_DIALOG_ACTION_SORT))
+
+
+#define PSPPIRE_DIALOG_ACTION_SORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ PSPPIRE_TYPE_DIALOG_ACTION_SORT, \
+ PsppireDialogActionSortClass))
+
+typedef struct _PsppireDialogActionSort PsppireDialogActionSort;
+typedef struct _PsppireDialogActionSortClass PsppireDialogActionSortClass;
+
+
+struct _PsppireDialogActionSort
+{
+ PsppireDialogAction parent;
+
+ /*< private >*/
+ gboolean dispose_has_run ;
+
+ GtkWidget *variables;
+ GtkWidget *ascending;
+};
+
+
+struct _PsppireDialogActionSortClass
+{
+ PsppireDialogActionClass parent_class;
+};
+
+
+GType psppire_dialog_action_sort_get_type (void) ;
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_DIALOG_ACTION_SORT_H__ */
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2010, 2011, 2012 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 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.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-#include <gtk/gtk.h>
-#include "sort-cases-dialog.h"
-#include "executor.h"
-#include "psppire-dialog.h"
-#include "psppire-data-window.h"
-#include "psppire-var-store.h"
-#include "dialog-common.h"
-#include "psppire-selector.h"
-#include "dict-display.h"
-#include "psppire-var-view.h"
-
-#include "builder-wrapper.h"
-#include "helper.h"
-
-
-static void
-refresh (PsppireDialog *dialog, GtkTreeView *dest)
-{
- GtkTreeModel *liststore = gtk_tree_view_get_model (dest);
-
- gtk_list_store_clear (GTK_LIST_STORE (liststore));
-}
-
-
-struct sort_cases_dialog
-{
- PsppireVarView *tv;
- PsppireDict *dict;
- GtkToggleButton *ascending;
-};
-
-
-static gboolean
-dialog_state_valid (gpointer data)
-{
- struct sort_cases_dialog *scd = data;
- GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (scd->tv));
-
- gint n_rows = gtk_tree_model_iter_n_children (model, NULL);
-
- if ( n_rows == 0 )
- return FALSE;
-
- return TRUE;
-}
-
-static char *
-generate_syntax (const struct sort_cases_dialog *scd)
-{
- gchar *text;
- GString *string = g_string_new ("SORT CASES BY ");
-
- gint n_vars = psppire_var_view_append_names (scd->tv, 0, string);
-
- if ( n_vars == 0 )
- g_string_assign (string, "");
- else
- {
- const char up_down =
- gtk_toggle_button_get_active (scd->ascending) ? 'A' : 'D';
- g_string_append_printf (string, "(%c)", up_down);
- g_string_append (string, ".");
- }
-
-
- text = string->str;
-
- g_string_free (string, FALSE);
-
- return text;
-}
-
-
-/* Pops up the Sort Cases dialog box */
-void
-sort_cases_dialog (PsppireDataWindow *de)
-{
- gint response;
-
- struct sort_cases_dialog scd;
-
- GtkBuilder *xml = builder_new ("sort.ui");
-
- GtkWidget *dialog = get_widget_assert (xml, "sort-cases-dialog");
-
-
- GtkWidget *source = get_widget_assert (xml, "sort-cases-treeview1");
- GtkWidget *dest = get_widget_assert (xml, "sort-cases-treeview2");
- PsppireVarStore *vs = NULL;
-
- g_object_get (de->data_editor, "var-store", &vs, NULL);
-
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de));
-
- g_object_get (vs, "dictionary", &scd.dict, NULL);
- g_object_set (source, "model", scd.dict, NULL);
-
- g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), dest);
-
- scd.tv = PSPPIRE_VAR_VIEW (dest);
- scd.ascending =
- GTK_TOGGLE_BUTTON (get_widget_assert (xml, "sort-cases-radiobutton0"));
-
-
- psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog),
- dialog_state_valid, &scd);
-
-
- response = psppire_dialog_run (PSPPIRE_DIALOG (dialog));
-
-
- switch (response)
- {
- case GTK_RESPONSE_OK:
- g_free (execute_syntax_string (de, generate_syntax (&scd)));
- break;
- case PSPPIRE_RESPONSE_PASTE:
- g_free (paste_syntax_to_window (generate_syntax (&scd)));
- break;
- default:
- break;
- }
-
- g_object_unref (xml);
-}
-
+++ /dev/null
-/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007 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 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.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef __SORT_CASES_DIALOG_H
-#define __SORT_CASES_DIALOG_H
-
-#include "psppire-data-window.h"
-
-void sort_cases_dialog (PsppireDataWindow * data);
-
-#endif
#include "psppire-dialog-action-kmeans.h"
#include "psppire-dialog-action-reliability.h"
#include "psppire-dialog-action-roc.h"
+#include "psppire-dialog-action-sort.h"
#include "psppire-dialog-action-var-info.h"
psppire_dialog_action_var_info_get_type ();
psppire_dialog_action_reliability_get_type ();
psppire_dialog_action_roc_get_type ();
+ psppire_dialog_action_sort_get_type ();
}