2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2007 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <gtk/gtksignal.h>
25 #include "psppire-dialog.h"
27 static void psppire_dialog_class_init (PsppireDialogClass *);
28 static void psppire_dialog_init (PsppireDialog *);
34 static guint signals [n_SIGNALS];
38 psppire_dialog_get_type (void)
40 static GType dialog_type = 0;
44 static const GTypeInfo dialog_info =
46 sizeof (PsppireDialogClass),
48 NULL, /* base_finalize */
49 (GClassInitFunc) psppire_dialog_class_init,
50 NULL, /* class_finalize */
51 NULL, /* class_data */
52 sizeof (PsppireDialog),
54 (GInstanceInitFunc) psppire_dialog_init,
57 dialog_type = g_type_register_static (GTK_TYPE_WINDOW,
58 "PsppireDialog", &dialog_info, 0);
66 static GObjectClass *parent_class = NULL;
70 psppire_dialog_finalize (GObject *object)
72 PsppireDialog *dialog ;
74 g_return_if_fail (object != NULL);
75 g_return_if_fail (PSPPIRE_IS_DIALOG (object));
77 dialog = PSPPIRE_DIALOG (object);
79 if (G_OBJECT_CLASS (parent_class)->finalize)
80 G_OBJECT_CLASS (parent_class)->finalize (object);
85 psppire_dialog_class_init (PsppireDialogClass *class)
87 GObjectClass *object_class = (GObjectClass *) class;
89 signals [DIALOG_REFRESH] =
90 g_signal_new ("refresh",
91 G_TYPE_FROM_CLASS (class),
95 g_cclosure_marshal_VOID__VOID,
100 object_class->finalize = psppire_dialog_finalize;
107 close_dialog (GtkWidget *w, gpointer data)
109 PsppireDialog *dialog = data;
111 psppire_dialog_close (dialog);
115 psppire_dialog_close (PsppireDialog *dialog)
117 g_main_loop_quit (dialog->loop);
118 gtk_widget_hide (GTK_WIDGET (dialog));
123 delete_event_callback (GtkWidget *w, GdkEvent *e, gpointer data)
125 close_dialog (w, data);
130 psppire_dialog_init (PsppireDialog *dialog)
132 dialog->box = gtk_hbox_new (FALSE, 5);
135 gtk_container_add (GTK_CONTAINER (dialog), dialog->box);
138 g_signal_connect (G_OBJECT (dialog), "delete-event",
139 G_CALLBACK (delete_event_callback),
142 gtk_widget_show_all (dialog->box);
147 psppire_dialog_new (void)
149 PsppireDialog *dialog ;
151 dialog = g_object_new (psppire_dialog_get_type (), NULL);
153 return GTK_WIDGET (dialog) ;
157 psppire_dialog_run (PsppireDialog *dialog)
159 dialog->loop = g_main_loop_new (NULL, FALSE);
161 gtk_widget_show (GTK_WIDGET (dialog));
163 g_main_loop_run (dialog->loop);
165 return dialog->response;
170 psppire_dialog_reload (PsppireDialog *dialog, gpointer data)
172 g_signal_emit (dialog, signals [DIALOG_REFRESH], 0, data);