Documentation add subsections for each GRAPH type
[pspp] / src / ui / gui / psppire-acr.c
index f11283ba69c485362cfc0ae374fbb9cb8f6f385a..a2ee6af55913ad63114c07a2713014da716f2a06 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include "psppire-acr.h"
 #include "helper.h"
 
-static void psppire_acr_init (PsppireAcr *);
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
 
-GType
-psppire_acr_get_type (void)
-{
-  static GType acr_type = 0;
+G_DEFINE_TYPE (PsppireAcr, psppire_acr, GTK_TYPE_BOX);
 
-  if (!acr_type)
-    {
-      static const GTypeInfo acr_info =
-      {
-       sizeof (PsppireAcrClass),
-       NULL, /* base_init */
-        NULL, /* base_finalize */
-       NULL, /* class_init */
-        NULL, /* class_finalize */
-       NULL, /* class_data */
-        sizeof (PsppireAcr),
-       0,
-       (GInstanceInitFunc) psppire_acr_init,
-      };
-
-      acr_type = g_type_register_static (GTK_TYPE_HBOX, "PsppireAcr",
-                                       &acr_info, 0);
-    }
+static void
+psppire_acr_dispose (GObject *obj)
+{
+  PsppireAcr *acr = PSPPIRE_ACR (obj);
+  psppire_acr_set_model (acr, NULL);
 
-  return acr_type;
+  G_OBJECT_CLASS (psppire_acr_parent_class)->dispose (obj);
 }
 
+static void
+psppire_acr_class_init (PsppireAcrClass *class)
+{
+  G_OBJECT_CLASS (class)->dispose = psppire_acr_dispose;
+}
 
 static gboolean row_is_selected (const PsppireAcr *acr);
 
@@ -261,19 +252,20 @@ psppire_acr_set_enabled (PsppireAcr *acr, gboolean status)
                            && row_is_selected (acr));
 }
 
-
 static void
 psppire_acr_init (PsppireAcr *acr)
 {
-  GtkWidget *bb  = gtk_vbutton_box_new ();
+  GtkWidget *bb  = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
 
   GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
 
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (acr), GTK_ORIENTATION_HORIZONTAL);
+
   acr->tv = GTK_TREE_VIEW (gtk_tree_view_new ());
 
-  acr->add_button = gtk_button_new_from_stock (GTK_STOCK_ADD);
-  acr->change_button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
-  acr->remove_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+  acr->add_button = gtk_button_new_with_label (_("Add"));
+  acr->change_button = gtk_button_new_with_label (_("Edit"));
+  acr->remove_button = gtk_button_new_with_label (_("Remove"));
 
   acr->get_value = NULL;
   acr->get_value_data = NULL;
@@ -347,10 +339,16 @@ psppire_acr_new (void)
 
 
 
-/* Set the widget's treemodel */
+/* Set the widget's treemodel to LISTSTORE.  LISTSTORE ownership is not
+   transferred. */
 void
 psppire_acr_set_model (PsppireAcr *acr, GtkListStore *liststore)
 {
+  if (acr->list_store)
+    g_object_unref (acr->list_store);
+  if (liststore)
+    g_object_ref (liststore);
+
   acr->list_store = liststore;
 
   gtk_tree_view_set_model (GTK_TREE_VIEW (acr->tv),