X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fui%2Fgui%2Fdata-editor.c;h=d6cf50b395bf2e6d8737f3df71de31b0a2cc8bda;hb=d52355bcda20563736bd83aed3ab58e534672cb5;hp=12bfa67c92b4f5120ee26976338aeaa692bf1781;hpb=1ef647e1f18761552b1acce7b94547ae2abec49a;p=pspp
diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c
index 12bfa67c92..d6cf50b395 100644
--- a/src/ui/gui/data-editor.c
+++ b/src/ui/gui/data-editor.c
@@ -1,21 +1,18 @@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2006, 2007 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2006, 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 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
@@ -36,6 +33,7 @@
#include "transpose-dialog.h"
#include "sort-cases-dialog.h"
#include "compute-dialog.h"
+#include "goto-case-dialog.h"
#include "comments-dialog.h"
#include "variable-info-dialog.h"
#include "dict-display.h"
@@ -61,6 +59,9 @@ static void register_data_editor_actions (struct data_editor *de);
static void insert_variable (GtkAction *, gpointer data);
+static void insert_case (GtkAction *a, gpointer data);
+
+
/* Switch between the VAR SHEET and the DATA SHEET */
@@ -132,7 +133,6 @@ static void
on_recent_data_select (GtkMenuShell *menushell, gpointer user_data)
{
gchar *file;
-
struct data_editor *de = user_data;
gchar *uri =
@@ -259,6 +259,48 @@ new_data_editor (void)
get_widget_assert (de->xml, "data_insert-variable")
);
+
+ de->insert_case =
+ gtk_action_new ("insert-case",
+ _("Insert Case"),
+ _("Create a new case at the current position"),
+ "pspp-insert-case");
+
+ g_signal_connect (de->insert_case, "activate",
+ G_CALLBACK (insert_case), de);
+
+
+ gtk_action_connect_proxy (de->insert_case,
+ get_widget_assert (de->xml, "button-insert-case")
+ );
+
+
+ gtk_action_connect_proxy (de->insert_case,
+ get_widget_assert (de->xml, "data_insert-case")
+ );
+
+
+
+ de->invoke_goto_dialog =
+ gtk_action_new ("goto-case-dialog",
+ _("Goto Case"),
+ _("Jump to a Case in the Data Sheet"),
+ "gtk-jump-to");
+
+
+ gtk_action_connect_proxy (de->invoke_goto_dialog,
+ get_widget_assert (de->xml, "button-goto-case")
+ );
+
+ gtk_action_connect_proxy (de->invoke_goto_dialog,
+ get_widget_assert (de->xml, "data_goto-case")
+ );
+
+
+ g_signal_connect (de->invoke_goto_dialog, "activate",
+ G_CALLBACK (goto_case_dialog), de);
+
+
de->invoke_weight_cases_dialog =
gtk_action_new ("weight-cases-dialog",
_("Weights"),
@@ -347,11 +389,16 @@ new_data_editor (void)
GtkRecentManager *rm = gtk_recent_manager_get_default ();
GtkWidget *recent_data = get_widget_assert (de->xml, "file_recent-data");
GtkWidget *recent_files = get_widget_assert (de->xml, "file_recent-files");
+ GtkWidget *recent_separator = get_widget_assert (de->xml, "file_separator1");
GtkWidget *menu = gtk_recent_chooser_menu_new_for_manager (rm);
GtkRecentFilter *filter = gtk_recent_filter_new ();
+ gtk_widget_show (recent_data);
+ gtk_widget_show (recent_files);
+ gtk_widget_show (recent_separator);
+
gtk_recent_filter_add_pattern (filter, "*.sav");
gtk_recent_filter_add_pattern (filter, "*.SAV");
@@ -447,17 +494,27 @@ new_data_editor (void)
G_CALLBACK (reference_manual),
e->window);
- g_signal_connect (get_widget_assert (de->xml,"data_sheet"),
+ g_signal_connect (data_sheet,
"double-click-column",
G_CALLBACK (click2column),
de);
- g_signal_connect (get_widget_assert (de->xml, "variable_sheet"),
+ g_signal_connect (data_sheet,
+ "select-row",
+ GTK_SIGNAL_FUNC (enable_edit_clear),
+ de);
+
+ g_signal_connect (data_sheet,
+ "activate",
+ GTK_SIGNAL_FUNC (disable_edit_clear),
+ de);
+
+ g_signal_connect (var_sheet,
"double-click-row",
GTK_SIGNAL_FUNC (click2row),
de);
- g_signal_connect (get_widget_assert (de->xml, "variable_sheet"),
+ g_signal_connect (var_sheet,
"select-row",
GTK_SIGNAL_FUNC (enable_edit_clear),
de);
@@ -609,9 +666,6 @@ new_data_window (GtkMenuItem *menuitem, gpointer parent)
static void
select_sheet (struct data_editor *de, guint page_num)
{
- GtkWidget *insert_variable = get_widget_assert (de->xml, "data_insert-variable");
- GtkWidget *insert_cases = get_widget_assert (de->xml, "insert-cases");
-
GtkWidget *view_data = get_widget_assert (de->xml, "view_data");
GtkWidget *view_variables = get_widget_assert (de->xml, "view_variables");
@@ -620,15 +674,15 @@ select_sheet (struct data_editor *de, guint page_num)
case PAGE_VAR_SHEET:
gtk_widget_hide (view_variables);
gtk_widget_show (view_data);
- gtk_widget_set_sensitive (insert_variable, TRUE);
- gtk_widget_set_sensitive (insert_cases, FALSE);
+ gtk_action_set_sensitive (de->insert_variable, TRUE);
+ gtk_action_set_sensitive (de->insert_case, FALSE);
+ gtk_action_set_sensitive (de->invoke_goto_dialog, FALSE);
break;
case PAGE_DATA_SHEET:
gtk_widget_show (view_variables);
gtk_widget_hide (view_data);
-#if 0
- gtk_widget_set_sensitive (insert_cases, TRUE);
-#endif
+ gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE);
+ gtk_action_set_sensitive (de->insert_case, TRUE);
break;
default:
g_assert_not_reached ();
@@ -800,44 +854,88 @@ file_quit (GtkCheckMenuItem *menuitem, gpointer data)
}
-
/* Callback for when the Clear item in the edit menu is activated */
static void
on_clear_activate (GtkMenuItem *menuitem, gpointer data)
{
struct data_editor *de = data;
+ GtkSheet *sheet = NULL;
+ GtkSheetRange range ;
+
GtkNotebook *notebook = GTK_NOTEBOOK (get_widget_assert (de->xml,
"notebook"));
- switch ( gtk_notebook_get_current_page (notebook) )
+ const gint page = gtk_notebook_get_current_page (notebook);
+
+ sheet = GTK_SHEET
+ (get_widget_assert (de->xml,
+ (page == PAGE_VAR_SHEET) ? "variable_sheet" : "data_sheet"));
+
+ /* This shouldn't be able to happen, because the menuitem
+ should be disabled */
+ g_return_if_fail (gtk_sheet_get_state (sheet) == GTK_SHEET_ROW_SELECTED );
+
+
+ gtk_sheet_get_selected_range (sheet, &range);
+
+ switch ( page )
{
case PAGE_VAR_SHEET:
{
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
-
PsppireVarStore *vs = PSPPIRE_VAR_STORE
- (gtk_sheet_get_model (var_sheet) );
+ (gtk_sheet_get_model (sheet) );
- /* This shouldn't be able to happen, because the menuitem
- should be disabled */
- g_return_if_fail (var_sheet->state == GTK_SHEET_ROW_SELECTED );
psppire_dict_delete_variables (vs->dict,
- var_sheet->range.row0,
+ range.row0,
1 +
- var_sheet->range.rowi -
- var_sheet->range.row0 );
+ range.rowi -
+ range.row0 );
}
break;
- case PAGE_DATA_SHEET:
- break;
- default:
- g_assert_not_reached ();
+ case PAGE_DATA_SHEET:
+ {
+ PsppireDataStore *data_store = PSPPIRE_DATA_STORE
+ (gtk_sheet_get_model (sheet) );
+
+
+ /* This shouldn't be able to happen, because the menuitem
+ should be disabled */
+ g_return_if_fail (gtk_sheet_get_state (sheet)
+ == GTK_SHEET_ROW_SELECTED );
+
+
+ psppire_data_store_delete_cases (data_store, range.row0,
+ 1 + range.rowi - range.row0);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
+
+ gtk_sheet_unselect_range (sheet);
}
+static void
+insert_case (GtkAction *action, gpointer data)
+{
+ gint current_row ;
+ struct data_editor *de = data;
+
+ GtkSheet *data_sheet =
+ GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
+
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE
+ (gtk_sheet_get_model (data_sheet) );
+
+
+ gtk_sheet_get_active_cell (data_sheet, ¤t_row, NULL);
+
+ if (current_row < 0) current_row = 0;
+
+ psppire_data_store_insert_new_case (ds, current_row);
+}
/* Insert a new variable before the current row in the variable sheet,
or before the current column in the data sheet, whichever is selected */
@@ -1307,7 +1405,7 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
if ( var )
{
- gchar *text = g_strdup_printf ("%d: %s", row,
+ gchar *text = g_strdup_printf ("%d: %s", row + FIRST_CASE_NUMBER,
var_get_name (var));
gchar *s = pspp_locale_to_utf8 (text, -1, 0);