Rank Dialog: Cosmetic Improvements
[pspp] / src / ui / gui / psppire-selector.c
index a021d92190eba329705f1fca38713351d46c7c98..678c2a749f240af62e12219cb58b4006ae15af8f 100644 (file)
 #include "psppire-dict.h"
 #include "psppire-select-dest.h"
 #include "psppire-means-layer.h"
+#include "helper.h"
 
 #include <gtk/gtk.h>
 
 #include "psppire-selector.h"
 
-static void psppire_selector_class_init    (PsppireSelectorClass *class);
-static void psppire_selector_init          (PsppireSelector      *selector);
-
+G_DEFINE_TYPE (PsppireSelector, psppire_selector, GTK_TYPE_BUTTON)
 
 static void set_direction (PsppireSelector *, enum psppire_selector_dir);
 
@@ -100,39 +99,9 @@ on_row_inserted (PsppireSelector *selector)
   g_signal_emit (selector, signals [DE_SELECTED], 0);
 }
 
-
-GType
-psppire_selector_get_type (void)
-{
-  static GType psppire_selector_type = 0;
-
-  if (!psppire_selector_type)
-    {
-      static const GTypeInfo psppire_selector_info =
-      {
-       sizeof (PsppireSelectorClass),
-       (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-       (GClassInitFunc)psppire_selector_class_init,
-       (GClassFinalizeFunc) NULL,
-       NULL,
-        sizeof (PsppireSelector),
-       0,
-       (GInstanceInitFunc) psppire_selector_init,
-      };
-
-      psppire_selector_type =
-       g_type_register_static (GTK_TYPE_BUTTON, "PsppireSelector",
-                               &psppire_selector_info, 0);
-    }
-
-  return psppire_selector_type;
-}
-
 static GObjectClass * parent_class = NULL;
 
-
-
+#if DEBUG
 static void
 dump_hash_entry (gpointer key, gpointer value, gpointer obj)
 {
@@ -157,7 +126,7 @@ psppire_selector_show_map (PsppireSelector *obj)
   g_print ("%s %p\n", __FUNCTION__, obj);
   g_hash_table_foreach (class->source_hash, dump_hash_entry, obj);
 }
-
+#endif
 
 
 static void
@@ -188,8 +157,11 @@ psppire_selector_dispose (GObject *obj)
       sel->source_litem = NULL;
     }
 
-  g_object_unref (sel->dest);
-  g_object_unref (sel->source);
+  if (sel->dest)
+    g_object_unref (sel->dest);
+
+  if (sel->source)
+    g_object_unref (sel->source);
 
   /* Chain up to the parent class */
   G_OBJECT_CLASS (parent_class)->dispose (obj);
@@ -604,7 +576,7 @@ de_select_tree_model (GtkTreeSelection *selection, GtkTreeModel *model)
     }
 
   /* Delete list of RowRefs and its contents */
-  g_list_foreach (selected_rows, (GFunc) gtk_tree_row_reference_free, NULL);
+  g_list_foreach (selected_rows, GFUNC_COMPAT_CAST (gtk_tree_row_reference_free), NULL);
   g_list_free (selected_rows);
 }
 
@@ -691,7 +663,7 @@ select_selection (PsppireSelector *selector)
                        );
     }
 
-  g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
+  g_list_foreach (selected_rows, GFUNC_COMPAT_CAST (gtk_tree_path_free), NULL);
   g_list_free (selected_rows);
 
   refilter (selector);