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_finalize (GObject *object);
22 static void psppire_window_register_dispose (GObject *object);
24 static GObjectClass *parent_class = NULL;
33 static guint signals [n_SIGNALS];
35 G_DEFINE_TYPE (PsppireWindowRegister, psppire_window_register, G_TYPE_OBJECT)
38 psppire_window_register_finalize (GObject *object)
43 psppire_window_register_dispose (GObject *object)
47 static PsppireWindowRegister *the_instance = NULL;
50 psppire_window_register_construct (GType type,
51 guint n_construct_params,
52 GObjectConstructParam *construct_params)
58 object = G_OBJECT_CLASS (parent_class)->constructor (type,
61 the_instance = PSPPIRE_WINDOW_REGISTER (object);
64 object = g_object_ref (G_OBJECT (the_instance));
70 psppire_window_register_class_init (PsppireWindowRegisterClass *class)
72 GObjectClass *object_class;
74 parent_class = g_type_class_peek_parent (class);
75 object_class = G_OBJECT_CLASS (class);
77 object_class->finalize = psppire_window_register_finalize;
78 object_class->dispose = psppire_window_register_dispose;
79 object_class->constructor = psppire_window_register_construct;
82 g_signal_new ("inserted",
83 G_TYPE_FROM_CLASS (class),
87 g_cclosure_marshal_VOID__POINTER,
93 g_signal_new ("removed",
94 G_TYPE_FROM_CLASS (class),
98 g_cclosure_marshal_VOID__POINTER,
105 psppire_window_register_init (PsppireWindowRegister *window_register)
107 window_register->name_table = g_hash_table_new (g_str_hash, g_str_equal);
111 psppire_window_register_insert (PsppireWindowRegister *wr, PsppireWindow *window, const gchar *name)
113 g_hash_table_insert (wr->name_table, (gpointer) name, window);
115 g_signal_emit (wr, signals[INSERTED], 0, name);
119 psppire_window_register_remove (PsppireWindowRegister *wr, const gchar *name)
121 g_hash_table_remove (wr->name_table, (gpointer) name);
122 g_signal_emit (wr, signals[REMOVED], 0, name);
126 psppire_window_register_lookup (PsppireWindowRegister *wr, const gchar *name)
128 return g_hash_table_lookup (wr->name_table, name);
132 psppire_window_register_foreach (PsppireWindowRegister *wr,
133 GHFunc func, gpointer data)
135 g_hash_table_foreach (wr->name_table, func, data);
138 PsppireWindowRegister *
139 psppire_window_register_new (void)
141 return g_object_new (psppire_window_register_get_type (), NULL);
146 psppire_window_register_n_items (PsppireWindowRegister *wr)
148 return g_hash_table_size (wr->name_table);