New abstract class PsppireDialogAction
[pspp-builds.git] / src / ui / gui / psppire-dialog.c
index cea5134630c8483e095c365e95693b595fddb47e..c365ab4b8eb47b2d237c9875db4eb92f2664435a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007  Free Software Foundation
+   Copyright (C) 2007, 2010, 2011, 2012  Free Software Foundation
 
    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 <config.h>
 
 #include <gtk/gtk.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbuildable.h>
 #include "psppire-dialog.h"
 #include "psppire-buttonbox.h"
 #include "psppire-selector.h"
 #include "psppire-conf.h"
 #include <string.h>
+#include "builder-wrapper.h"
+#include "help-menu.h"
 
 static void psppire_dialog_class_init          (PsppireDialogClass *);
 static void psppire_dialog_init                (PsppireDialog      *);
 
 
 enum  {DIALOG_REFRESH,
+       RESPONSE,
        VALIDITY_CHANGED,
+       DIALOG_HELP,
        n_SIGNALS};
 
 static guint signals [n_SIGNALS];
@@ -224,8 +226,6 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                          FALSE,
                          G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
 
-
-
   object_class->set_property = psppire_dialog_set_property;
   object_class->get_property = psppire_dialog_get_property;
 
@@ -238,8 +238,6 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                                    PROP_SLIDING,
                                    sliding_spec);
 
-
-
   signals [DIALOG_REFRESH] =
     g_signal_new ("refresh",
                  G_TYPE_FROM_CLASS (class),
@@ -251,6 +249,18 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                  0);
 
 
+  signals [RESPONSE] =
+    g_signal_new ("response",
+                 G_TYPE_FROM_CLASS (class),
+                 G_SIGNAL_RUN_FIRST,
+                 0,
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__INT,
+                 G_TYPE_NONE,
+                 1,
+                 G_TYPE_INT);
+
+
   signals [VALIDITY_CHANGED] =
     g_signal_new ("validity-changed",
                  G_TYPE_FROM_CLASS (class),
@@ -263,6 +273,18 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                  G_TYPE_BOOLEAN);
 
 
+  signals [DIALOG_HELP] =
+    g_signal_new ("help",
+                 G_TYPE_FROM_CLASS (class),
+                 G_SIGNAL_RUN_FIRST,
+                 0,
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__STRING,
+                 G_TYPE_NONE,
+                 1,
+                 G_TYPE_STRING);
+
+
   object_class->finalize = psppire_dialog_finalize;
 }
 
@@ -296,16 +318,16 @@ static gboolean
 configure_event_callback (GtkDialog *dialog,
                          GdkEvent *event, gpointer data)
 {
-  gchar *base = NULL;
+  const gchar *base;
 
   PsppireConf *conf = psppire_conf_new ();
 
-  if ( ! GTK_WIDGET_MAPPED (dialog))
+  if ( ! gtk_widget_get_mapped (GTK_WIDGET (dialog)))
     return FALSE;
 
-  g_object_get (dialog, "name", &base, NULL);
+  base = gtk_buildable_get_name (GTK_BUILDABLE (dialog));
 
-  psppire_conf_save_window_geometry (conf, base, event);
+  psppire_conf_save_window_geometry (conf, base, GTK_WINDOW (dialog));
 
   return FALSE;
 }
@@ -316,9 +338,7 @@ on_realize (GtkWindow *dialog, gpointer data)
 {
   PsppireConf *conf = psppire_conf_new ();
 
-  const gchar *base = NULL;
-
-  g_object_get (dialog, "name", &base, NULL);
+  const gchar *base = gtk_buildable_get_name (GTK_BUILDABLE (dialog));
 
   psppire_conf_set_window_geometry (conf, base, dialog);
 }
@@ -358,7 +378,7 @@ psppire_dialog_init (PsppireDialog *dialog)
   gtk_window_set_type_hint (GTK_WINDOW (dialog),
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
-  g_object_set (dialog, "icon-name", "psppicon", NULL);
+  g_object_set (dialog, "icon-name", "pspp", NULL);
 }
 
 
@@ -396,8 +416,6 @@ connect_notify_signal (GtkWidget *w, gpointer data)
   if ( PSPPIRE_IS_BUTTONBOX (w))
     return;
 
-
-
   if ( GTK_IS_CONTAINER (w))
     {
       gtk_container_foreach (GTK_CONTAINER (w),
@@ -481,7 +499,7 @@ connect_notify_signal (GtkWidget *w, gpointer data)
 
       while ((col = gtk_tree_view_get_column (tv, i++)))
        {
-         GList *renderers = gtk_tree_view_column_get_cell_renderers (col);
+         GList *renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
          GList *start = renderers;
          while (renderers)
            {
@@ -519,6 +537,8 @@ psppire_dialog_run (PsppireDialog *dialog)
 
   g_main_loop_unref (dialog->loop);
 
+  g_signal_emit (dialog, signals [RESPONSE], 0, dialog->response);
+
   return dialog->response;
 }
 
@@ -530,6 +550,16 @@ psppire_dialog_reload (PsppireDialog *dialog)
 }
 
 
+void
+psppire_dialog_help (PsppireDialog *dialog)
+{
+  char *name = NULL;
+  g_object_get (dialog, "name", &name, NULL);
+
+  online_help (name);
+
+  g_signal_emit (dialog, signals [DIALOG_HELP], 0, name);
+}
 
 
 GType