1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2008 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "psppire-window-register.h"
21 static void psppire_window_register_init (PsppireWindowRegister *window_register);
22 static void psppire_window_register_class_init (PsppireWindowRegisterClass *class);
24 static void psppire_window_register_finalize (GObject *object);
25 static void psppire_window_register_dispose (GObject *object);
27 static GObjectClass *parent_class = NULL;
36 static guint signals [n_SIGNALS];
39 psppire_window_register_get_type (void)
41 static GType window_register_type = 0;
43 if (!window_register_type)
45 static const GTypeInfo window_register_info =
47 sizeof (PsppireWindowRegisterClass),
49 NULL, /* base_finalize */
50 (GClassInitFunc) psppire_window_register_class_init,
51 NULL, /* class_finalize */
52 NULL, /* class_data */
53 sizeof (PsppireWindowRegister),
55 (GInstanceInitFunc) psppire_window_register_init,
58 window_register_type = g_type_register_static (G_TYPE_OBJECT,
59 "PsppireWindowRegister",
60 &window_register_info, 0);
63 return window_register_type;
68 psppire_window_register_finalize (GObject *object)
73 psppire_window_register_dispose (GObject *object)
77 static PsppireWindowRegister *the_instance = NULL;
80 psppire_window_register_construct (GType type,
81 guint n_construct_params,
82 GObjectConstructParam *construct_params)
88 object = G_OBJECT_CLASS (parent_class)->constructor (type,
91 the_instance = PSPPIRE_WINDOW_REGISTER (object);
94 object = g_object_ref (G_OBJECT (the_instance));
100 psppire_window_register_class_init (PsppireWindowRegisterClass *class)
102 GObjectClass *object_class;
104 parent_class = g_type_class_peek_parent (class);
105 object_class = (GObjectClass*) class;
107 object_class->finalize = psppire_window_register_finalize;
108 object_class->dispose = psppire_window_register_dispose;
109 object_class->constructor = psppire_window_register_construct;
112 g_signal_new ("inserted",
113 G_TYPE_FROM_CLASS (class),
117 g_cclosure_marshal_VOID__POINTER,
123 g_signal_new ("removed",
124 G_TYPE_FROM_CLASS (class),
128 g_cclosure_marshal_VOID__POINTER,
135 psppire_window_register_init (PsppireWindowRegister *window_register)
137 window_register->dispose_has_run = FALSE;
138 window_register->name_table = g_hash_table_new (g_str_hash, g_str_equal);
142 psppire_window_register_insert (PsppireWindowRegister *wr, PsppireWindow *window, const gchar *name)
144 g_hash_table_insert (wr->name_table, (gpointer) name, window);
146 g_signal_emit (wr, signals[INSERTED], 0, name);
150 psppire_window_register_remove (PsppireWindowRegister *wr, const gchar *name)
152 g_hash_table_remove (wr->name_table, (gpointer) name);
153 g_signal_emit (wr, signals[REMOVED], 0, name);
157 psppire_window_register_lookup (PsppireWindowRegister *wr, const gchar *name)
159 return g_hash_table_lookup (wr->name_table, name);
163 psppire_window_register_foreach (PsppireWindowRegister *wr,
164 GHFunc func, gpointer data)
166 g_hash_table_foreach (wr->name_table, func, data);
169 PsppireWindowRegister *
170 psppire_window_register_new (void)
172 return g_object_new (psppire_window_register_get_type (), NULL);
177 psppire_window_register_n_items (PsppireWindowRegister *wr)
179 return g_hash_table_size (wr->name_table);