Split data-editor.glade into two files.
[pspp-builds.git] / src / ui / gui / psppire-var-sheet.c
index d914866658b67ca6982505d4aa72f888e5899482..bffcfd1dd922bedf016d2e36c2b2d8d865a63a86 100644 (file)
@@ -18,7 +18,6 @@
 #include "psppire-var-sheet.h"
 #include <ui/gui/sheet/psppire-axis-impl.h>
 
-#include <glade/glade.h>
 #include "helper.h"
 
 #include "customentry.h"
@@ -32,6 +31,9 @@
 
 static void psppire_var_sheet_class_init  (PsppireVarSheetClass *klass);
 static void psppire_var_sheet_init        (PsppireVarSheet      *vs);
+static void psppire_var_sheet_realize     (GtkWidget *w);
+static void psppire_var_sheet_unrealize   (GtkWidget *w);
+
 
 enum
   {
@@ -122,9 +124,7 @@ create_label_list (const gchar *const *labels)
   gint i = 0;
   GtkTreeIter iter;
 
-  GtkListStore *list_store;
-  list_store = gtk_list_store_new (1, G_TYPE_STRING);
-
+  GtkListStore *list_store = gtk_list_store_new (1, G_TYPE_STRING);
 
   while ( (s = labels[i++]))
     {
@@ -179,17 +179,19 @@ psppire_var_sheet_get_property (GObject      *object,
 }
 
 
-
 static void
 psppire_var_sheet_class_init (PsppireVarSheetClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_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;
+  widget_class->realize = psppire_var_sheet_realize;
+  widget_class->unrealize = psppire_var_sheet_unrealize;
   object_class->set_property = psppire_var_sheet_set_property;
   object_class->get_property = psppire_var_sheet_get_property;
 
@@ -333,7 +335,7 @@ var_sheet_change_active_cell (PsppireVarSheet *vs,
 
        gtk_combo_box_entry_set_text_column (cbe, 0);
 
-       g_signal_connect (G_OBJECT (cbe),"changed",
+       g_signal_connect (cbe, "changed",
                         G_CALLBACK (change_alignment), var);
       }
       break;
@@ -351,7 +353,7 @@ var_sheet_change_active_cell (PsppireVarSheet *vs,
 
        gtk_combo_box_entry_set_text_column (cbe, 0);
 
-       g_signal_connect (G_OBJECT (cbe),"changed",
+       g_signal_connect (cbe, "changed",
                          G_CALLBACK (change_measure), var);
       }
       break;
@@ -483,16 +485,44 @@ var_sheet_change_active_cell (PsppireVarSheet *vs,
 }
 
 
+static void
+psppire_var_sheet_realize (GtkWidget *w)
+{
+  PsppireVarSheet *vs = PSPPIRE_VAR_SHEET (w);
+
+  GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (vs));
+
+  vs->val_labs_dialog = val_labs_dialog_create (GTK_WINDOW (toplevel));
+  vs->missing_val_dialog = missing_val_dialog_create (GTK_WINDOW (toplevel));
+  vs->var_type_dialog = var_type_dialog_create (GTK_WINDOW (toplevel));
+
+  /* Chain up to the parent class */
+  GTK_WIDGET_CLASS (parent_class)->realize (w);
+}
+
+static void
+psppire_var_sheet_unrealize (GtkWidget *w)
+{
+  PsppireVarSheet *vs = PSPPIRE_VAR_SHEET (w);
+
+  g_free (vs->val_labs_dialog);
+  g_free (vs->missing_val_dialog);
+  g_free (vs->var_type_dialog);
+
+  /* Chain up to the parent class */
+  GTK_WIDGET_CLASS (parent_class)->unrealize (w);
+}
+
+
+
 static void
 psppire_var_sheet_init (PsppireVarSheet *vs)
 {
-  GladeXML *xml = XML_NEW ("data-editor.glade");
+  GtkBuilder *builder = builder_new ("data-editor.ui");
 
-  vs->val_labs_dialog = val_labs_dialog_create (xml);
-  vs->missing_val_dialog = missing_val_dialog_create (xml);
-  vs->var_type_dialog = var_type_dialog_create (xml);
+  connect_help (builder);
 
-  g_object_unref (xml);
+  g_object_unref (builder);
 
   vs->dispose_has_run = FALSE;
   vs->may_create_vars = TRUE;