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
22 #include <gtk/gtksignal.h>
23 #include "psppire-dialog.h"
25 static void psppire_dialog_class_init (PsppireDialogClass *);
26 static void psppire_dialog_init (PsppireDialog *);
32 static guint signal [n_SIGNALS];
36 psppire_dialog_get_type (void)
38 static GType dialog_type = 0;
42 static const GTypeInfo dialog_info =
44 sizeof (PsppireDialogClass),
46 NULL, /* base_finalize */
47 (GClassInitFunc) psppire_dialog_class_init,
48 NULL, /* class_finalize */
49 NULL, /* class_data */
50 sizeof (PsppireDialog),
52 (GInstanceInitFunc) psppire_dialog_init,
55 dialog_type = g_type_register_static (GTK_TYPE_WINDOW,
56 "PsppireDialog", &dialog_info, 0);
64 static GObjectClass *parent_class = NULL;
68 psppire_dialog_finalize (GObject *object)
70 PsppireDialog *dialog ;
72 g_return_if_fail (object != NULL);
73 g_return_if_fail (PSPPIRE_IS_DIALOG (object));
75 dialog = PSPPIRE_DIALOG (object);
77 if (G_OBJECT_CLASS (parent_class)->finalize)
78 G_OBJECT_CLASS (parent_class)->finalize (object);
83 psppire_dialog_class_init (PsppireDialogClass *class)
85 GObjectClass *object_class = (GObjectClass *) class;
87 signal [DIALOG_REFRESH] =
88 g_signal_new ("refresh",
89 G_TYPE_FROM_CLASS (class),
93 g_cclosure_marshal_VOID__VOID,
98 object_class->finalize = psppire_dialog_finalize;
105 close_dialog (GtkWidget *w, gpointer data)
107 PsppireDialog *dialog = data;
109 psppire_dialog_close (dialog);
113 psppire_dialog_close (PsppireDialog *dialog)
115 g_main_loop_quit (dialog->loop);
116 gtk_widget_hide (GTK_WIDGET (dialog));
121 delete_event_callback (GtkWidget *w, GdkEvent *e, gpointer data)
123 close_dialog (w, data);
128 psppire_dialog_init (PsppireDialog *dialog)
130 dialog->box = gtk_hbox_new (FALSE, 5);
133 gtk_container_add (GTK_CONTAINER (dialog), dialog->box);
136 g_signal_connect (G_OBJECT (dialog), "delete-event",
137 G_CALLBACK (delete_event_callback),
140 gtk_widget_show_all (dialog->box);
145 psppire_dialog_new (void)
147 PsppireDialog *dialog ;
149 dialog = g_object_new (psppire_dialog_get_type (), NULL);
151 return GTK_WIDGET (dialog) ;
155 psppire_dialog_run (PsppireDialog *dialog)
157 dialog->loop = g_main_loop_new (NULL, FALSE);
159 gtk_widget_show (GTK_WIDGET (dialog));
161 g_main_loop_run (dialog->loop);
163 return dialog->response;
168 psppire_dialog_reload (PsppireDialog *dialog, gpointer data)
170 g_signal_emit (dialog, signal [DIALOG_REFRESH], 0, data);