Implemented the "Insert Case" button and menuitem.
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 9 Jul 2007 05:21:12 +0000 (05:21 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 9 Jul 2007 05:21:12 +0000 (05:21 +0000)
lib/gtksheet/ChangeLog
lib/gtksheet/gtksheet.c
lib/gtksheet/gtksheet.h
src/ui/gui/ChangeLog
src/ui/gui/data-editor.c
src/ui/gui/data-editor.glade
src/ui/gui/data-editor.h

index 5e96837c3b1507861e228222250a806f46412016..7e4626b7d00929f9b7ab8ed3ece4f774f3642f8a 100644 (file)
@@ -1,3 +1,8 @@
+09 July 2007 John Darrington <john@darrington.wattle.id.au>
+
+       * gtksheet.c gtksheet.h (gtk_sheet_get_active_cell): Allowed row,
+       column  to be NULL.
+
 07 July 2007 John Darrington <john@darrington.wattle.id.au>
         
        * gsheet-column-iface.c gsheet-column-iface.h gsheet-row-iface.c
index 82a839a7cddaefae538c46043f46240ffe189440..73c245c3be87a829082188ee514fa8ed752900e1 100644 (file)
@@ -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
index da1b0d621bc0757b56c3bd35957830c108727710..9b8525309255c16dd7a134e88bd3d0593b30ccdd 100644 (file)
@@ -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);
index a9d7c532f4f2077b9db5f6406d5f595af70d8386..703719dfc492d0010c2996b9f2b069b3e85de992 100644 (file)
@@ -1,3 +1,8 @@
+2007-07-08  John Darrington <john@darrington.wattle.id.au>
+
+       * data-editor.c data-editor.glade data-editor.h: Implemented 
+       the "Insert Case" button/dialog.
+
 2007-07-08  John Darrington <john@darrington.wattle.id.au>
 
        * goto-case-dialog.c goto-case-dialog.h (new files)
index fd800de68e3b77e7817069e143c2d193db29f3c3..d75ea5c9145d603cb46cec6baf9beb62fa1afe44 100644 (file)
@@ -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, &current_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 */
index 148219c2250c591c3752542b4f6ca208d38e1844..f5ccaf372a34749c44e9d2f81364860285cfb73b 100644 (file)
                       </widget>
                     </child>
                     <child>
-                      <widget class="GtkMenuItem" id="insert-cases">
+                      <widget class="GtkMenuItem" id="data_insert-case">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
                         <property name="label" translatable="yes">Insert Cases</property>
index bc4a01ad4cf6fc93ea18352e8fa620b16c6d0aab..27dff55e9fc6af9e1f6bafbaaf08ee66326197c5 100644 (file)
@@ -41,6 +41,7 @@ struct data_editor
   GtkAction *invoke_variable_info_dialog;
 
   GtkAction *insert_variable;
+  GtkAction *insert_case;
 
   GladeXML *xml;