pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src data/dictionary.c ui/gui/data-editor.c...


From: John Darrington
Subject: [Pspp-cvs] pspp/src data/dictionary.c ui/gui/data-editor.c...
Date: Thu, 28 Dec 2006 04:21:08 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Changes by:     John Darrington <jmd>   06/12/28 04:21:08

Modified files:
        src/data       : dictionary.c 
        src/ui/gui     : data-editor.c data-editor.glade data-sheet.c 
                         psppire-data-store.c psppire-dict.c 
                         psppire-var-store.c 

Log message:
        Re-added Data->Insert_Variable menu item

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/dictionary.c?cvsroot=pspp&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/data-editor.c?cvsroot=pspp&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/data-editor.glade?cvsroot=pspp&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/data-sheet.c?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-data-store.c?cvsroot=pspp&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-dict.c?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-var-store.c?cvsroot=pspp&r1=1.20&r2=1.21

Patches:
Index: data/dictionary.c
===================================================================
RCS file: /sources/pspp/pspp/src/data/dictionary.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- data/dictionary.c   23 Dec 2006 06:11:33 -0000      1.25
+++ data/dictionary.c   28 Dec 2006 04:21:07 -0000      1.26
@@ -400,8 +400,12 @@
 set_var_dict_index (struct variable *v, int dict_index)
 {
   struct vardict_info vdi = *var_get_vardict (v);
+  struct dictionary *d = vdi.dict;
   vdi.dict_index = dict_index;
   var_set_vardict (v, &vdi);
+
+  if ( d->callbacks && d->callbacks->var_changed )
+    d->callbacks->var_changed (d, dict_index, d->cb_data);
 }
 
 /* Sets the case_index in V's vardict to DICT_INDEX. */

Index: ui/gui/data-editor.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-editor.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- ui/gui/data-editor.c        28 Dec 2006 00:44:45 -0000      1.6
+++ ui/gui/data-editor.c        28 Dec 2006 04:21:08 -0000      1.7
@@ -41,6 +41,9 @@
 #include "psppire-var-store.h"
 
 
+static void insert_variable (GtkCheckMenuItem *m, gpointer data);
+
+
 /* Switch between the VAR SHEET and the DATA SHEET */
 enum {PAGE_DATA_SHEET = 0, PAGE_VAR_SHEET};
 
@@ -145,6 +148,11 @@
                    de);
 
 
+  g_signal_connect (get_widget_assert (de->xml,"data_insert-variable"),
+                   "activate",
+                   G_CALLBACK (insert_variable),
+                   de);
+
 
   g_signal_connect (get_widget_assert (de->xml,"help_about"),
                    "activate",
@@ -297,7 +305,7 @@
 static void
 select_sheet (struct data_editor *de, guint page_num)
 {
-  GtkWidget *insert_variable = get_widget_assert (de->xml, "insert-variable");
+  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");
@@ -314,8 +322,9 @@
     case PAGE_DATA_SHEET:
       gtk_widget_show (view_variables);
       gtk_widget_hide (view_data);
-      gtk_widget_set_sensitive (insert_variable, FALSE);
+#if 0
       gtk_widget_set_sensitive (insert_cases, TRUE);
+#endif
       break;
     default:
       g_assert_not_reached ();
@@ -579,3 +588,49 @@
        g_assert_not_reached ();
     }
 }
+
+
+/* Insert a new variable before the current row in the variable sheet,
+   or before the current column in the data sheet, whichever is selected */
+static void
+insert_variable (GtkCheckMenuItem *m, gpointer data)
+{
+  struct data_editor *de = data;
+  gint posn;
+
+  GtkWidget *notebook = get_widget_assert (de->xml, "notebook");
+
+  GtkSheet *var_sheet =
+    GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+
+
+
+  PsppireVarStore *vs = PSPPIRE_VAR_STORE
+    (gtk_sheet_get_model (var_sheet) );
+
+
+  switch ( gtk_notebook_get_current_page ( GTK_NOTEBOOK (notebook)) )
+    {
+    case PAGE_VAR_SHEET:
+      posn = var_sheet->active_cell.row;
+      break;
+    case PAGE_DATA_SHEET:
+      {
+       GtkSheet *data_sheet =
+         GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
+
+       if ( data_sheet->state == GTK_SHEET_COLUMN_SELECTED )
+         posn = data_sheet->range.col0;
+       else
+         posn = data_sheet->active_cell.col;
+      }
+      break;
+    default:
+      g_assert_not_reached ();
+    }
+
+  psppire_dict_insert_variable (vs->dict, posn, NULL);
+
+}
+
+

Index: ui/gui/data-editor.glade
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-editor.glade,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ui/gui/data-editor.glade    28 Dec 2006 00:44:45 -0000      1.4
+++ ui/gui/data-editor.glade    28 Dec 2006 04:21:08 -0000      1.5
@@ -207,7 +207,7 @@
                      <property name="use_underline">True</property>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image44">
+                       <widget class="GtkImage" id="image47">
                          <property name="visible">True</property>
                          <property name="stock">gtk-find</property>
                          <property name="icon_size">1</property>
@@ -308,17 +308,16 @@
          </child>
 
          <child>
-           <widget class="GtkMenuItem" id="menuitem4">
+           <widget class="GtkMenuItem" id="data">
              <property name="visible">True</property>
-             <property name="sensitive">False</property>
              <property name="label" translatable="yes">_Data</property>
              <property name="use_underline">True</property>
 
              <child>
-               <widget class="GtkMenu" id="menuitem4_menu">
+               <widget class="GtkMenu" id="data_menu">
 
                  <child>
-                   <widget class="GtkMenuItem" id="insert-variable">
+                   <widget class="GtkMenuItem" id="data_insert-variable">
                      <property name="visible">True</property>
                      <property name="sensitive">False</property>
                      <property name="label" translatable="yes">Insert 
Variable</property>
@@ -330,6 +329,7 @@
                  <child>
                    <widget class="GtkMenuItem" id="insert-cases">
                      <property name="visible">True</property>
+                     <property name="sensitive">False</property>
                      <property name="label" translatable="yes">Insert 
Cases</property>
                      <property name="use_underline">True</property>
                      <signal name="activate" handler="on_insert_cases" 
last_modification_time="Sat, 01 Jul 2006 08:40:06 GMT"/>
@@ -339,12 +339,13 @@
                  <child>
                    <widget class="GtkImageMenuItem" id="go_to_case">
                      <property name="visible">True</property>
+                     <property name="sensitive">False</property>
                      <property name="label" translatable="yes">Go To 
Case</property>
                      <property name="use_underline">True</property>
                      <signal name="activate" handler="on_go_to_case_activate" 
last_modification_time="Mon, 19 Jun 2006 10:29:37 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image45">
+                       <widget class="GtkImage" id="image48">
                          <property name="visible">True</property>
                          <property name="stock">gtk-jump-to</property>
                          <property name="icon_size">1</property>
@@ -360,12 +361,14 @@
                  <child>
                    <widget class="GtkSeparatorMenuItem" id="separator4">
                      <property name="visible">True</property>
+                     <property name="sensitive">False</property>
                    </widget>
                  </child>
 
                  <child>
                    <widget class="GtkMenuItem" id="sort_cases">
                      <property name="visible">True</property>
+                     <property name="sensitive">False</property>
                      <property name="label" translatable="yes">Sort 
Cases</property>
                      <property name="use_underline">True</property>
                      <signal name="activate" handler="on_sort_cases_activate" 
last_modification_time="Tue, 20 Jun 2006 10:27:11 GMT"/>
@@ -411,6 +414,7 @@
                  <child>
                    <widget class="GtkSeparatorMenuItem" id="separator5">
                      <property name="visible">True</property>
+                     <property name="sensitive">False</property>
                    </widget>
                  </child>
 

Index: ui/gui/data-sheet.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/data-sheet.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- ui/gui/data-sheet.c 24 Dec 2006 23:08:25 -0000      1.18
+++ ui/gui/data-sheet.c 28 Dec 2006 04:21:08 -0000      1.19
@@ -156,6 +156,8 @@
   ds->width_of_m = calc_m_width (sheet, ds->font_desc);
 }
 
+
+
 GtkWidget*
 psppire_data_sheet_create (gchar *widget_name, gchar *string1, gchar *string2,
                           gint int1, gint int2)
@@ -180,7 +182,6 @@
 
   gtk_sheet_set_active_cell (GTK_SHEET (sheet), -1, -1);
 
-
   gtk_sheet_set_model (GTK_SHEET (sheet), G_SHEET_MODEL (the_data_store));
 
   gtk_widget_show (sheet);

Index: ui/gui/psppire-data-store.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-data-store.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- ui/gui/psppire-data-store.c 24 Dec 2006 23:08:25 -0000      1.29
+++ ui/gui/psppire-data-store.c 28 Dec 2006 04:21:08 -0000      1.30
@@ -286,6 +286,25 @@
                                   var_num, -1);
 }
 
+
+static void
+variable_changed_callback (GObject *obj, gint var_num, gpointer data)
+{
+  PsppireDataStore *store;
+
+  g_return_if_fail (data);
+
+  store  = PSPPIRE_DATA_STORE (data);
+
+  g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
+                                 var_num, 1);
+
+
+  g_sheet_model_range_changed (G_SHEET_MODEL (store),
+                              -1, var_num,
+                              -1, var_num);
+}
+
 static void
 insert_variable_callback (GObject *obj, gint var_num, gpointer data)
 {
@@ -398,6 +417,11 @@
                   G_CALLBACK (delete_variables_callback),
                   data_store);
 
+  g_signal_connect (dict, "variable-changed",
+                  G_CALLBACK (variable_changed_callback),
+                  data_store);
+
+
   g_signal_connect (dict, "dict-size-changed",
                    G_CALLBACK (dict_size_change_callback),
                    data_store);

Index: ui/gui/psppire-dict.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-dict.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- ui/gui/psppire-dict.c       25 Dec 2006 02:29:11 -0000      1.18
+++ ui/gui/psppire-dict.c       28 Dec 2006 04:21:08 -0000      1.19
@@ -243,10 +243,10 @@
 psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name)
 {
   struct variable *var ;
+  g_return_if_fail (idx >= 0);
   g_return_if_fail (d);
   g_return_if_fail (G_IS_PSPPIRE_DICT (d));
 
-
   if ( ! name )
     name = auto_generate_var_name (d);
 

Index: ui/gui/psppire-var-store.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-var-store.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- ui/gui/psppire-var-store.c  24 Dec 2006 23:08:25 -0000      1.20
+++ ui/gui/psppire-var-store.c  28 Dec 2006 04:21:08 -0000      1.21
@@ -263,6 +263,7 @@
 var_change_callback (GtkWidget *w, gint n, gpointer data)
 {
   GSheetModel *model = G_SHEET_MODEL (data);
+
   g_sheet_model_range_changed (model,
                                 n, 0, n, n_COLS);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]