From 8c40e5a3cb30d168600068f83fa8abd564f2b3ef Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 9 Jul 2007 05:21:12 +0000 Subject: [PATCH 1/1] Implemented the "Insert Case" button and menuitem. --- lib/gtksheet/ChangeLog | 5 ++++ lib/gtksheet/gtksheet.c | 4 +-- lib/gtksheet/gtksheet.h | 4 +++ src/ui/gui/ChangeLog | 5 ++++ src/ui/gui/data-editor.c | 57 +++++++++++++++++++++++++++++------- src/ui/gui/data-editor.glade | 2 +- src/ui/gui/data-editor.h | 1 + 7 files changed, 65 insertions(+), 13 deletions(-) diff --git a/lib/gtksheet/ChangeLog b/lib/gtksheet/ChangeLog index 5e96837c..7e4626b7 100644 --- a/lib/gtksheet/ChangeLog +++ b/lib/gtksheet/ChangeLog @@ -1,3 +1,8 @@ +09 July 2007 John Darrington + + * gtksheet.c gtksheet.h (gtk_sheet_get_active_cell): Allowed row, + column to be NULL. + 07 July 2007 John Darrington * gsheet-column-iface.c gsheet-column-iface.h gsheet-row-iface.c diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index 82a839a7..73c245c3 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -3925,8 +3925,8 @@ gtk_sheet_get_active_cell (GtkSheet *sheet, gint *row, gint *column) g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_IS_SHEET (sheet)); - *row = sheet->active_cell.row; - *column = sheet->active_cell.col; + if ( row ) *row = sheet->active_cell.row; + if (column) *column = sheet->active_cell.col; } static void diff --git a/lib/gtksheet/gtksheet.h b/lib/gtksheet/gtksheet.h index da1b0d62..9b852530 100644 --- a/lib/gtksheet/gtksheet.h +++ b/lib/gtksheet/gtksheet.h @@ -532,6 +532,10 @@ void gtk_sheet_unselect_range (GtkSheet *sheet); gboolean gtk_sheet_set_active_cell (GtkSheet *sheet, gint row, gint column); + +/* Sets *ROW and *COLUMN to be the coordinates of the active cell. + ROW and/or COLUMN may be null if the caller is not interested in their + values */ void gtk_sheet_get_active_cell (GtkSheet *sheet, gint *row, gint *column); diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index a9d7c532..703719df 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,8 @@ +2007-07-08 John Darrington + + * data-editor.c data-editor.glade data-editor.h: Implemented + the "Insert Case" button/dialog. + 2007-07-08 John Darrington * goto-case-dialog.c goto-case-dialog.h (new files) diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index fd800de6..d75ea5c9 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -59,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 */ @@ -248,11 +251,6 @@ new_data_editor (void) G_CALLBACK (insert_variable), de); - - g_signal_connect (de->insert_variable, "activate", - G_CALLBACK (insert_variable), de); - - gtk_action_connect_proxy (de->insert_variable, get_widget_assert (de->xml, "button-insert-variable") ); @@ -261,6 +259,28 @@ 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"), @@ -636,9 +656,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"); @@ -647,14 +664,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); gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE); + gtk_action_set_sensitive (de->insert_case, TRUE); break; default: g_assert_not_reached (); @@ -864,6 +882,25 @@ on_clear_activate (GtkMenuItem *menuitem, gpointer data) } } +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 */ diff --git a/src/ui/gui/data-editor.glade b/src/ui/gui/data-editor.glade index 148219c2..f5ccaf37 100644 --- a/src/ui/gui/data-editor.glade +++ b/src/ui/gui/data-editor.glade @@ -280,7 +280,7 @@ - + True False Insert Cases diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/data-editor.h index bc4a01ad..27dff55e 100644 --- a/src/ui/gui/data-editor.h +++ b/src/ui/gui/data-editor.h @@ -41,6 +41,7 @@ struct data_editor GtkAction *invoke_variable_info_dialog; GtkAction *insert_variable; + GtkAction *insert_case; GladeXML *xml; -- 2.30.2