pspp-cvs
[Top][All Lists]
Advanced

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

[Pspp-cvs] pspp/src/ui/gui psppire-var-sheet.h psppire-var...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp/src/ui/gui psppire-var-sheet.h psppire-var...
Date: Fri, 07 Mar 2008 06:20:02 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Changes by:     Ben Pfaff <blp> 08/03/07 06:20:01

Modified files:
        src/ui/gui     : psppire-var-sheet.h psppire-var-sheet.c 
                         ChangeLog 

Log message:
        Add "may-create-vars" property to var sheet that controls whether the
        user can create new variables in the dictionary.  Needed by upcoming
        patch #6358.  Reviewed by John Darrington.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-var-sheet.h?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-var-sheet.c?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/ChangeLog?cvsroot=pspp&r1=1.117&r2=1.118

Patches:
Index: psppire-var-sheet.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/psppire-var-sheet.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- psppire-var-sheet.h 29 Feb 2008 09:13:53 -0000      1.1
+++ psppire-var-sheet.h 7 Mar 2008 06:20:00 -0000       1.2
@@ -43,6 +43,7 @@
   GtkSheet parent;
 
   gboolean dispose_has_run;
+  gboolean may_create_vars;
 
   struct val_labs_dialog *val_labs_dialog ;
   struct missing_val_dialog *missing_val_dialog ;

Index: psppire-var-sheet.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/psppire-var-sheet.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- psppire-var-sheet.c 29 Feb 2008 09:13:53 -0000      1.1
+++ psppire-var-sheet.c 7 Mar 2008 06:20:01 -0000       1.2
@@ -33,6 +33,10 @@
 static void psppire_var_sheet_class_init  (PsppireVarSheetClass *klass);
 static void psppire_var_sheet_init        (PsppireVarSheet      *vs);
 
+enum 
+  {
+    PSPPIRE_VAR_SHEET_MAY_CREATE_VARS = 1
+  };
 
 GType
 psppire_var_sheet_get_type (void)
@@ -148,18 +152,69 @@
 }
 
 
+static void
+psppire_var_sheet_set_property (GObject      *object,
+                                guint         property_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  PsppireVarSheet *self = (PsppireVarSheet *) object;
+
+  switch (property_id)
+    {
+    case PSPPIRE_VAR_SHEET_MAY_CREATE_VARS:
+      self->may_create_vars = g_value_get_boolean (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+psppire_var_sheet_get_property (GObject      *object,
+                                guint         property_id,
+                                GValue       *value,
+                                GParamSpec   *pspec)
+{
+  PsppireVarSheet *self = (PsppireVarSheet *) object;
+
+  switch (property_id)
+    {
+    case PSPPIRE_VAR_SHEET_MAY_CREATE_VARS:
+      g_value_set_boolean (value, self->may_create_vars);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+      break;
+    }
+}
+
 
 
 static void
 psppire_var_sheet_class_init (PsppireVarSheetClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GParamSpec *pspec;
 
   parent_class = g_type_class_peek_parent (klass);
 
   object_class->dispose = psppire_var_sheet_dispose;
   object_class->finalize = psppire_var_sheet_finalize;
+  object_class->set_property = psppire_var_sheet_set_property;
+  object_class->get_property = psppire_var_sheet_get_property;
 
+  pspec = g_param_spec_boolean ("may-create-vars",
+                                "May create variables",
+                                "Whether the user may create more variables",
+                                TRUE,
+                                G_PARAM_READWRITE);
+  g_object_class_install_property (object_class,
+                                   PSPPIRE_VAR_SHEET_MAY_CREATE_VARS,
+                                   pspec);
 
   klass->measure_list = create_label_list (measures);
   klass->alignment_list = create_label_list (alignments);
@@ -203,10 +258,14 @@
                        gint *new_row, gint *new_column
                        )
 {
+  PsppireVarSheet *var_sheet = PSPPIRE_VAR_SHEET (sheet);
   PsppireVarStore *var_store = PSPPIRE_VAR_STORE (gtk_sheet_get_model (sheet));
 
   gint n_vars = psppire_var_store_get_var_cnt (var_store);
 
+  if (*new_row >= n_vars && !var_sheet->may_create_vars)
+    return FALSE;
+
   if ( row == n_vars && *new_row >= n_vars)
     {
       GtkEntry *entry = GTK_ENTRY (gtk_sheet_get_entry (sheet));
@@ -224,8 +283,8 @@
   /* If the destination cell is outside the current  variables, then
      automatically create variables for the new rows.
   */
-  if ( (*new_row > n_vars) ||
-       (*new_row == n_vars && *new_column != PSPPIRE_VAR_STORE_COL_NAME) )
+  if ( ((*new_row > n_vars) ||
+        (*new_row == n_vars && *new_column != PSPPIRE_VAR_STORE_COL_NAME)) )
     {
       gint i;
       for ( i = n_vars ; i <= *new_row; ++i )

Index: ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/ChangeLog,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -b -r1.117 -r1.118
--- ChangeLog   5 Mar 2008 06:30:33 -0000       1.117
+++ ChangeLog   7 Mar 2008 06:20:01 -0000       1.118
@@ -1,3 +1,10 @@
+2008-03-06  Ben Pfaff  <address@hidden>
+
+       * psppire-var-sheet.c psppire-var-sheet.h: Add "may-create-vars"
+       property to var sheet that controls whether the user can create
+       new variables in the dictionary.  Needed by upcoming patch #6358.
+       Reviewed by John Darrington.
+
 2008-03-04  Ben Pfaff  <address@hidden>
 
        Patch #6427.  Reviewed by John Darrington.




reply via email to

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