data-out: Make binary output buffer big enough for a null terminator.
[pspp] / src / ui / gui / psppire-dialog.c
index b006222a6199495a44eb29aecc0eb1409581161c..99f6d228249f0bc5ca97dcf9b221c282edefd8b2 100644 (file)
@@ -52,42 +52,8 @@ psppire_dialog_finalize (GObject *object)
     G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
     G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-static void
-psppire_dialog_base_init (PsppireDialogClass *class)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-  object_class->finalize = psppire_dialog_finalize;
-}
-
-GType
-psppire_dialog_get_type (void)
-{
-  static GType dialog_type = 0;
-
-  if (!dialog_type)
-    {
-      static const GTypeInfo dialog_info =
-      {
-       sizeof (PsppireDialogClass),
-       (GBaseInitFunc) psppire_dialog_base_init,
-        NULL, /* base_finalize */
-       (GClassInitFunc) psppire_dialog_class_init,
-        NULL, /* class_finalize */
-       NULL, /* class_data */
-        sizeof (PsppireDialog),
-       0,
-       (GInstanceInitFunc) psppire_dialog_init,
-      };
-
-      dialog_type = g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE,
-                                           "PsppireDialog", &dialog_info, 0);
-    }
-
-  return dialog_type;
-}
-
 
 
+G_DEFINE_TYPE (PsppireDialog, psppire_dialog, PSPPIRE_TYPE_WINDOW_BASE);
 
 /* Properties */
 enum
 
 /* Properties */
 enum
@@ -147,13 +113,15 @@ psppire_dialog_set_property (GObject         *object,
 static void
 psppire_dialog_class_init (PsppireDialogClass *class)
 {
 static void
 psppire_dialog_class_init (PsppireDialogClass *class)
 {
-  GObjectClass *object_class = (GObjectClass *) class;
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->finalize = psppire_dialog_finalize;
 
   GParamSpec *sliding_spec ;
   GParamSpec *help_page_spec ;
 
 
   GParamSpec *sliding_spec ;
   GParamSpec *help_page_spec ;
 
-  help_page_spec = 
-    g_param_spec_string ("help-page", 
+  help_page_spec =
+    g_param_spec_string ("help-page",
                         "Help Page",
                         "The section of the manual to load when the Help button is clicked",
                         NULL,
                         "Help Page",
                         "The section of the manual to load when the Help button is clicked",
                         NULL,
@@ -269,7 +237,7 @@ psppire_dialog_init (PsppireDialog *dialog)
   gtk_window_set_type_hint (GTK_WINDOW (dialog),
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
   gtk_window_set_type_hint (GTK_WINDOW (dialog),
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
-  g_object_set (dialog, "icon-name", "pspp", NULL);
+  g_object_set (dialog, "icon-name", "org.gnu.pspp", NULL);
 }
 
 GtkWidget*
 }
 
 GtkWidget*
@@ -287,7 +255,7 @@ psppire_dialog_new (void)
 void
 psppire_dialog_notify_change (PsppireDialog *dialog)
 {
 void
 psppire_dialog_notify_change (PsppireDialog *dialog)
 {
-  if ( dialog->contents_are_valid )
+  if (dialog->contents_are_valid)
     {
       gboolean valid = dialog->contents_are_valid (dialog->validity_data);
 
     {
       gboolean valid = dialog->contents_are_valid (dialog->validity_data);
 
@@ -296,13 +264,6 @@ psppire_dialog_notify_change (PsppireDialog *dialog)
 }
 
 
 }
 
 
-static void
-remove_notify_handlers (PsppireDialog *dialog, GObject *sel)
-{
-  g_signal_handlers_disconnect_by_data (sel, dialog);
-}
-
-
 /* Descend the widget tree, connecting appropriate signals to the
    psppire_dialog_notify_change callback */
 static void
 /* Descend the widget tree, connecting appropriate signals to the
    psppire_dialog_notify_change callback */
 static void
@@ -310,10 +271,10 @@ connect_notify_signal (GtkWidget *w, gpointer data)
 {
   PsppireDialog *dialog = data;
 
 {
   PsppireDialog *dialog = data;
 
-  if ( PSPPIRE_IS_BUTTONBOX (w))
+  if (PSPPIRE_IS_BUTTON_BOX (w))
     return;
 
     return;
 
-  if ( GTK_IS_CONTAINER (w))
+  if (GTK_IS_CONTAINER (w))
     {
       gtk_container_foreach (GTK_CONTAINER (w),
                             connect_notify_signal,
     {
       gtk_container_foreach (GTK_CONTAINER (w),
                             connect_notify_signal,
@@ -325,14 +286,14 @@ connect_notify_signal (GtkWidget *w, gpointer data)
      "user-modified-state-changed" signal.  Instead, we have to try and
      predict what widgets and signals are likely to exist in our dialogs. */
 
      "user-modified-state-changed" signal.  Instead, we have to try and
      predict what widgets and signals are likely to exist in our dialogs. */
 
-  if ( GTK_IS_TOGGLE_BUTTON (w))
+  if (GTK_IS_TOGGLE_BUTTON (w))
     {
       g_signal_connect_swapped (w, "toggled",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
     }
 
     {
       g_signal_connect_swapped (w, "toggled",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
     }
 
-  if ( PSPPIRE_IS_SELECTOR (w))
+  if (PSPPIRE_IS_SELECTOR (w))
     {
       g_signal_connect_swapped (w, "selected",
                                G_CALLBACK (psppire_dialog_notify_change),
     {
       g_signal_connect_swapped (w, "selected",
                                G_CALLBACK (psppire_dialog_notify_change),
@@ -341,23 +302,25 @@ connect_notify_signal (GtkWidget *w, gpointer data)
       g_signal_connect_swapped (w, "de-selected",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
       g_signal_connect_swapped (w, "de-selected",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
+
+      psppire_selector_update_subjects (PSPPIRE_SELECTOR (w));
     }
 
     }
 
-  if ( GTK_IS_EDITABLE (w))
+  if (GTK_IS_EDITABLE (w))
     {
       g_signal_connect_swapped (w, "changed",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
     }
 
     {
       g_signal_connect_swapped (w, "changed",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
     }
 
-  if ( GTK_IS_CELL_EDITABLE (w))
+  if (GTK_IS_CELL_EDITABLE (w))
     {
       g_signal_connect_swapped (w, "editing-done",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
     }
 
     {
       g_signal_connect_swapped (w, "editing-done",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
     }
 
-  if ( GTK_IS_TEXT_VIEW (w))
+  if (GTK_IS_TEXT_VIEW (w))
     {
       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
 
     {
       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
 
@@ -366,7 +329,7 @@ connect_notify_signal (GtkWidget *w, gpointer data)
                                dialog);
     }
 
                                dialog);
     }
 
-  if ( GTK_IS_TREE_VIEW (w))
+  if (GTK_IS_TREE_VIEW (w))
     {
       gint i = 0;
       GtkTreeView *tv = GTK_TREE_VIEW (w);
     {
       gint i = 0;
       GtkTreeView *tv = GTK_TREE_VIEW (w);
@@ -375,7 +338,7 @@ connect_notify_signal (GtkWidget *w, gpointer data)
       GtkTreeViewColumn *col;
       GtkTreeModel *model = gtk_tree_view_get_model (tv);
 
       GtkTreeViewColumn *col;
       GtkTreeModel *model = gtk_tree_view_get_model (tv);
 
-      if ( model)
+      if (model)
        {
          g_signal_connect_swapped (model, "row-changed",
                                    G_CALLBACK (psppire_dialog_notify_change),
        {
          g_signal_connect_swapped (model, "row-changed",
                                    G_CALLBACK (psppire_dialog_notify_change),
@@ -389,10 +352,8 @@ connect_notify_signal (GtkWidget *w, gpointer data)
                                    G_CALLBACK (psppire_dialog_notify_change),
                                    dialog);
 
                                    G_CALLBACK (psppire_dialog_notify_change),
                                    dialog);
 
-         g_signal_connect (dialog, "destroy", G_CALLBACK (remove_notify_handlers),
-                           model);
        }
        }
-      
+
       g_signal_connect_swapped (selection, "changed",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
       g_signal_connect_swapped (selection, "changed",
                                G_CALLBACK (psppire_dialog_notify_change),
                                dialog);
@@ -403,7 +364,7 @@ connect_notify_signal (GtkWidget *w, gpointer data)
          GList *start = renderers;
          while (renderers)
            {
          GList *start = renderers;
          while (renderers)
            {
-             if ( GTK_IS_CELL_RENDERER_TOGGLE (renderers->data))
+             if (GTK_IS_CELL_RENDERER_TOGGLE (renderers->data))
                g_signal_connect_swapped (renderers->data, "toggled",
                                          G_CALLBACK (psppire_dialog_notify_change), dialog);
              renderers = renderers->next;
                g_signal_connect_swapped (renderers->data, "toggled",
                                          G_CALLBACK (psppire_dialog_notify_change), dialog);
              renderers = renderers->next;
@@ -422,8 +383,8 @@ psppire_dialog_run (PsppireDialog *dialog)
 
   if (title == NULL)
     g_warning ("PsppireDialog %s has no title", gtk_widget_get_name (GTK_WIDGET (dialog)));
 
   if (title == NULL)
     g_warning ("PsppireDialog %s has no title", gtk_widget_get_name (GTK_WIDGET (dialog)));
-  
-  if ( dialog->contents_are_valid != NULL )
+
+  if (dialog->contents_are_valid != NULL)
     gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child(GTK_BIN(dialog))),
                           connect_notify_signal,
                           dialog);
     gtk_container_foreach (GTK_CONTAINER (gtk_bin_get_child(GTK_BIN(dialog))),
                           connect_notify_signal,
                           dialog);
@@ -431,20 +392,16 @@ psppire_dialog_run (PsppireDialog *dialog)
   dialog->loop = g_main_loop_new (NULL, FALSE);
 
   gtk_widget_show (GTK_WIDGET (dialog));
   dialog->loop = g_main_loop_new (NULL, FALSE);
 
   gtk_widget_show (GTK_WIDGET (dialog));
+  psppire_dialog_notify_change (dialog);
 
 
-  if ( dialog->contents_are_valid != NULL)
-    g_signal_emit (dialog, signals [VALIDITY_CHANGED], 0, FALSE);
-
-  g_signal_emit (dialog, signals [DIALOG_REFRESH], 0);
-
-  gdk_threads_leave ();
   g_main_loop_run (dialog->loop);
   g_main_loop_run (dialog->loop);
-  gdk_threads_enter ();
 
   g_main_loop_unref (dialog->loop);
 
   g_signal_emit (dialog, signals [RESPONSE], 0, dialog->response);
 
 
   g_main_loop_unref (dialog->loop);
 
   g_signal_emit (dialog, signals [RESPONSE], 0, dialog->response);
 
+  g_free (title);
+
   return dialog->response;
 }
 
   return dialog->response;
 }