pspp-cvs
[Top][All Lists]
Advanced

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

[Pspp-cvs] pspp/src/ui/gui ChangeLog psppire-var-store.c p...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp/src/ui/gui ChangeLog psppire-var-store.c p...
Date: Wed, 20 Feb 2008 05:06:49 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Changes by:     Ben Pfaff <blp> 08/02/20 05:06:48

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

Log message:
        Patch #6426.  Reviewed by John Darrington.
        
        Add "trailing-rows", "format-type" properties to PsppireVarStore.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/ChangeLog?cvsroot=pspp&r1=1.113&r2=1.114
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-var-store.c?cvsroot=pspp&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire-var-store.h?cvsroot=pspp&r1=1.10&r2=1.11

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/ChangeLog,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -b -r1.113 -r1.114
--- ChangeLog   20 Feb 2008 04:24:30 -0000      1.113
+++ ChangeLog   20 Feb 2008 05:06:48 -0000      1.114
@@ -1,5 +1,12 @@
 2008-02-19  Ben Pfaff  <address@hidden>
 
+       Patch #6426.  Reviewed by John Darrington.
+       
+       * psppire-var-store.c: Add "trailing-rows", "format-type"
+       properties to PsppireVarStore.
+
+2008-02-19  Ben Pfaff  <address@hidden>
+
        * message-dialog.c (popup_messages): Always destroy `msg' and
        `lead' strings, avoiding a memory leak.  Thanks to John Darrington
        for reporting the problem.

Index: psppire-var-store.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/psppire-var-store.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- psppire-var-store.c 21 Sep 2007 01:53:58 -0000      1.28
+++ psppire-var-store.c 20 Feb 2008 05:06:48 -0000      1.29
@@ -41,7 +41,11 @@
 
 #include "var-display.h"
 
-#define TRAILING_ROWS 40
+enum
+  {
+    PSPPIRE_VAR_STORE_TRAILING_ROWS = 1,
+    PSPPIRE_VAR_STORE_FORMAT_TYPE
+  };
 
 static void         psppire_var_store_init            (PsppireVarStore      
*var_store);
 static void         psppire_var_store_class_init      (PsppireVarStoreClass 
*class);
@@ -73,6 +77,30 @@
 static GObjectClass *parent_class = NULL;
 
 GType
+psppire_var_store_format_type_get_type (void)
+{
+  static GType etype = 0;
+  if (etype == 0)
+    {
+      static const GEnumValue values[] =
+       {
+         { PSPPIRE_VAR_STORE_INPUT_FORMATS,
+            "PSPPIRE_VAR_STORE_INPUT_FORMATS",
+            "input" },
+         { PSPPIRE_VAR_STORE_OUTPUT_FORMATS,
+            "PSPPIRE_VAR_STORE_OUTPUT_FORMATS",
+            "output" },
+         { 0, NULL, NULL }
+       };
+
+      etype = g_enum_register_static
+       (g_intern_static_string ("PsppireVarStoreFormatType"), values);
+
+    }
+  return etype;
+}
+
+GType
 psppire_var_store_get_type (void)
 {
   static GType var_store_type = 0;
@@ -123,16 +151,92 @@
 }
 
 static void
+psppire_var_store_set_property (GObject      *object,
+                                guint         property_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  PsppireVarStore *self = (PsppireVarStore *) object;
+
+  switch (property_id)
+    {
+    case PSPPIRE_VAR_STORE_TRAILING_ROWS:
+      self->trailing_rows = g_value_get_int (value);
+      break;
+
+    case PSPPIRE_VAR_STORE_FORMAT_TYPE:
+      self->format_type = g_value_get_enum (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+psppire_var_store_get_property (GObject      *object,
+                        guint         property_id,
+                        GValue       *value,
+                        GParamSpec   *pspec)
+{
+  PsppireVarStore *self = (PsppireVarStore *) object;
+
+  switch (property_id)
+    {
+    case PSPPIRE_VAR_STORE_TRAILING_ROWS:
+      g_value_set_int (value, self->trailing_rows);
+      break;
+
+    case PSPPIRE_VAR_STORE_FORMAT_TYPE:
+      g_value_set_enum (value, self->format_type);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+      break;
+    }
+}
+
+
+static void
 psppire_var_store_class_init (PsppireVarStoreClass *class)
 {
   GObjectClass *object_class;
+  GParamSpec *pspec;
 
   parent_class = g_type_class_peek_parent (class);
   object_class = (GObjectClass*) class;
 
   object_class->finalize = psppire_var_store_finalize;
-}
+  object_class->set_property = psppire_var_store_set_property;
+  object_class->get_property = psppire_var_store_get_property;
 
+  /* The minimum value for trailing-rows is 1 to prevent the
+     var-store from ever having 0 rows, which breaks invariants
+     in gtksheet. */
+  pspec = g_param_spec_int ("trailing-rows",
+                            "Trailing rows",
+                            "Number of rows displayed after last variable",
+                            1  /* minimum value */,
+                            100 /* maximum value */,
+                            40  /* default value */,
+                            G_PARAM_READWRITE);
+  g_object_class_install_property (object_class,
+                                   PSPPIRE_VAR_STORE_TRAILING_ROWS,
+                                   pspec);
+
+  pspec = g_param_spec_enum ("format-type",
+                             "Variable format type",
+                             ("Whether variables have input or output "
+                              "formats"),
+                             G_TYPE_PSPPIRE_VAR_STORE_FORMAT_TYPE,
+                             PSPPIRE_VAR_STORE_OUTPUT_FORMATS,
+                             G_PARAM_READWRITE);
+  g_object_class_install_property (object_class,
+                                   PSPPIRE_VAR_STORE_FORMAT_TYPE,
+                                   pspec);
+}
 
 static void
 psppire_var_store_init (PsppireVarStore *var_store)
@@ -144,6 +248,8 @@
   gdk_colormap_alloc_color (colormap, &var_store->disabled, FALSE, TRUE);
 
   var_store->dict = 0;
+  var_store->trailing_rows = 40;
+  var_store->format_type = PSPPIRE_VAR_STORE_OUTPUT_FORMATS;
 }
 
 static gboolean
@@ -421,15 +527,17 @@
            var_set_width (pv, width);
        else
          {
+            bool for_input
+              = var_store->format_type == PSPPIRE_VAR_STORE_INPUT_FORMATS;
            struct fmt_spec fmt ;
            fmt = *var_get_write_format (pv);
-           if ( width < fmt_min_output_width (fmt.type)
+           if ( width < fmt_min_width (fmt.type, for_input)
                 ||
-                width > fmt_max_output_width (fmt.type))
+                width > fmt_max_width (fmt.type, for_input))
              return FALSE;
 
            fmt.w = width;
-           fmt.d = MIN (fmt_max_output_decimals (fmt.type, width), fmt.d);
+           fmt.d = MIN (fmt_max_decimals (fmt.type, width, for_input), fmt.d);
 
            var_set_both_formats (pv, &fmt);
          }
@@ -439,14 +547,17 @@
       break;
     case COL_DECIMALS:
       {
+        bool for_input
+          = var_store->format_type == PSPPIRE_VAR_STORE_INPUT_FORMATS;
        int decimals;
        struct fmt_spec fmt;
        if ( ! text) return FALSE;
        decimals = atoi (text);
        fmt = *var_get_write_format (pv);
        if ( decimals >
-            fmt_max_output_decimals (fmt.type,
-                                     fmt.w
+            fmt_max_decimals (fmt.type,
+                               fmt.w,
+                               for_input
                                      ))
          return FALSE;
 
@@ -693,7 +804,7 @@
   if (vs->dict)
     rows =  psppire_dict_get_var_cnt (vs->dict);
 
-  return rows + TRAILING_ROWS;
+  return rows + vs->trailing_rows;
 }
 
 
@@ -725,7 +836,7 @@
 static gchar *
 geometry_get_button_label (const GSheetRow *geom, glong unit, gpointer data)
 {
-  gchar *label = g_strdup_printf (_("%ld"), unit);
+  gchar *label = g_strdup_printf (_("%ld"), unit + 1);
 
   return label;
 }

Index: psppire-var-store.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/psppire-var-store.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- psppire-var-store.h 8 Jul 2007 10:49:31 -0000       1.10
+++ psppire-var-store.h 20 Feb 2008 05:06:48 -0000      1.11
@@ -21,10 +21,24 @@
 #include "psppire-dict.h"
 #include <gdk/gdk.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
 
+/* PSPPIRE variable store format type, to determine whether a
+   PSPPIRE variable store contains variable input formats or
+   variable output formats.  */
+GType psppire_var_store_format_type_get_type (void);
+
+typedef enum
+  {
+    PSPPIRE_VAR_STORE_INPUT_FORMATS,
+    PSPPIRE_VAR_STORE_OUTPUT_FORMATS
+  }
+PsppireVarStoreFormatType;
+
+#define G_TYPE_PSPPIRE_VAR_STORE_FORMAT_TYPE \
+        (psppire_var_store_format_type_get_type ())
+
+/* PSPPIRE variable store. */
 #define GTK_TYPE_VAR_STORE            (psppire_var_store_get_type ())
 
 #define PSPPIRE_VAR_STORE(obj)        (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
@@ -53,6 +67,8 @@
   PsppireDict *dict;
   GdkColor disabled;
   const PangoFontDescription *font_desc;
+  gint trailing_rows;
+  PsppireVarStoreFormatType format_type;
 };
 
 struct _PsppireVarStoreClass
@@ -80,9 +96,6 @@
 void psppire_var_store_set_font (PsppireVarStore *store, const 
PangoFontDescription *fd);
 
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
+G_END_DECLS
 
 #endif /* __PSPPIRE_VAR_STORE_H__ */




reply via email to

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