work on docs
[pspp] / src / ui / gui / psppire-data-editor.c
index 181e5cbf3d40a1124463a8631e5d63532cb13959..1928e10820106cef76636baa2f5767618cfd8e18 100644 (file)
 #include <gettext.h>
 #define _(msgid) gettext (msgid)
 
-static void psppire_data_editor_class_init          (PsppireDataEditorClass *klass);
-static void psppire_data_editor_init                (PsppireDataEditor      *de);
-
 static void refresh_entry (PsppireDataEditor *);
 
-GType
-psppire_data_editor_get_type (void)
-{
-  static GType de_type = 0;
-
-  if (!de_type)
-    {
-      static const GTypeInfo de_info =
-      {
-       sizeof (PsppireDataEditorClass),
-       NULL, /* base_init */
-        NULL, /* base_finalize */
-       (GClassInitFunc) psppire_data_editor_class_init,
-        NULL, /* class_finalize */
-       NULL, /* class_data */
-        sizeof (PsppireDataEditor),
-       0,
-       (GInstanceInitFunc) psppire_data_editor_init,
-      };
-
-      de_type = g_type_register_static (GTK_TYPE_NOTEBOOK, "PsppireDataEditor",
-                                       &de_info, 0);
-    }
-
-  return de_type;
-}
+G_DEFINE_TYPE (PsppireDataEditor, psppire_data_editor, GTK_TYPE_NOTEBOOK)
 
 static GObjectClass * parent_class = NULL;
 
 static void
 psppire_data_editor_finalize (GObject *obj)
 {
+  PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (obj);
+  if (de->font)
+    pango_font_description_free (de->font);
+
   /* Chain up to the parent class */
   G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
@@ -90,25 +66,15 @@ psppire_data_editor_finalize (GObject *obj)
 static void
 psppire_data_editor_dispose (GObject *obj)
 {
-  PsppireDataEditor *de = (PsppireDataEditor *) obj;
+  PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (obj);
 
-  if (de->data_store)
-    {
-      g_object_unref (de->data_store);
-      de->data_store = NULL;
-    }
+  if (de->dispose_has_run)
+    return;
 
-  if (de->dict)
-    {
-      g_object_unref (de->dict);
-      de->dict = NULL;
-    }
+  de->dispose_has_run = TRUE;
 
-  if (de->font != NULL)
-    {
-      pango_font_description_free (de->font);
-      de->font = NULL;
-    }
+  g_object_unref (de->data_store);
+  g_object_unref (de->dict);
 
   /* Chain up to the parent class */
   G_OBJECT_CLASS (parent_class)->dispose (obj);
@@ -179,6 +145,7 @@ psppire_data_editor_set_property (GObject         *object,
     case PROP_VALUE_LABELS:
       {
        gboolean l = g_value_get_boolean (value);
+       de->use_value_labels = l;
        g_object_set (de->data_sheet, "forward-conversion",
                      l ?
                      psppire_data_store_value_to_string_with_labels :
@@ -213,6 +180,7 @@ psppire_data_editor_get_property (GObject         *object,
       g_value_set_pointer (value, de->dict);
       break;
     case PROP_VALUE_LABELS:
+      g_value_set_boolean (value, de->use_value_labels);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -491,6 +459,8 @@ psppire_data_editor_init (PsppireDataEditor *de)
   GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (de));
   gtk_style_context_add_class (context, "psppire-data-editor");
 
+  de->dispose_has_run = FALSE;
+
   de->font = NULL;
 
   g_object_set (de, "tab-pos", GTK_POS_BOTTOM, NULL);
@@ -508,6 +478,7 @@ psppire_data_editor_init (PsppireDataEditor *de)
   gtk_box_pack_start (GTK_BOX (hbox), de->datum_entry, TRUE, TRUE, 0);
 
   de->split = FALSE;
+  de->use_value_labels = FALSE;
   de->data_sheet = psppire_data_sheet_new ();
 
   GtkWidget *data_button = ssw_sheet_get_button (SSW_SHEET (de->data_sheet));