1507
|
1 /* Paranormal - A highly customizable audio visualization library
|
|
2 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com>
|
|
3 *
|
|
4 * This library is free software; you can redistribute it and/or
|
|
5 * modify it under the terms of the GNU Library General Public
|
|
6 * License as published by the Free Software Foundation; either
|
|
7 * version 2 of the License, or (at your option) any later version.
|
|
8 *
|
|
9 * This library 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 GNU
|
|
12 * Library General Public License for more details.
|
|
13 *
|
|
14 * You should have received a copy of the GNU Library General Public
|
|
15 * License along with this library; if not, write to the Free
|
|
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17 */
|
|
18
|
|
19 #include <config.h>
|
|
20
|
|
21 #include <glib.h>
|
|
22 #include "pnoption.h"
|
|
23
|
|
24 static void pn_option_class_init (PnOptionClass *class);
|
|
25 static void pn_option_init (PnOption *option,
|
|
26 PnOptionClass *class);
|
|
27
|
|
28 /* GObject signals */
|
|
29 static void pn_option_finalize (GObject *gobject);
|
|
30
|
|
31 static PnUserObjectClass *parent_class = NULL;
|
|
32
|
|
33 GType
|
|
34 pn_option_get_type (void)
|
|
35 {
|
|
36 static GType option_type = 0;
|
|
37
|
|
38 if (! option_type)
|
|
39 {
|
|
40 static const GTypeInfo option_info =
|
|
41 {
|
|
42 sizeof (PnOptionClass),
|
|
43 NULL, /* base_init */
|
|
44 NULL, /* base_finalize */
|
|
45 (GClassInitFunc) pn_option_class_init,
|
|
46 NULL, /* class_finalize */
|
|
47 NULL, /* class_data */
|
|
48 sizeof (PnOption),
|
|
49 0, /* n_preallocs */
|
|
50 (GInstanceInitFunc) pn_option_init
|
|
51 };
|
|
52
|
|
53 /* FIXME: should this be dynamic? */
|
|
54 option_type = g_type_register_static (PN_TYPE_USER_OBJECT,
|
|
55 "PnOption",
|
|
56 &option_info,
|
|
57 G_TYPE_FLAG_ABSTRACT);
|
|
58 }
|
|
59 return option_type;
|
|
60 }
|
|
61
|
|
62 static void
|
|
63 pn_option_class_init (PnOptionClass *class)
|
|
64 {
|
|
65 GObjectClass *gobject_class;
|
|
66 PnObjectClass *object_class;
|
|
67 PnUserObjectClass *user_object_class;
|
|
68
|
|
69
|
|
70 parent_class = g_type_class_peek_parent (class);
|
|
71
|
|
72 gobject_class = (GObjectClass *) class;
|
|
73 object_class = (PnObjectClass *) class;
|
|
74 user_object_class = (PnUserObjectClass *) class;
|
|
75
|
|
76 /* GObject signals */
|
|
77 gobject_class->finalize = pn_option_finalize;
|
|
78 }
|
|
79
|
|
80 static void
|
|
81 pn_option_init (PnOption *option, PnOptionClass *class)
|
|
82 {
|
|
83 }
|
|
84
|
|
85 static void
|
|
86 pn_option_finalize (GObject *gobject)
|
|
87 {
|
|
88 PnOption *option;
|
|
89
|
|
90 option = (PnOption *) gobject;
|
|
91
|
|
92 if (G_OBJECT_CLASS (parent_class)->finalize)
|
|
93 (* G_OBJECT_CLASS (parent_class)->finalize) (gobject);
|
|
94 }
|
|
95
|
|
96 PnOptionWidget*
|
|
97 pn_option_new_widget (PnOption *option)
|
|
98 {
|
|
99 PnOptionClass *class;
|
|
100
|
|
101 g_return_val_if_fail (option != NULL, NULL);
|
|
102 g_return_val_if_fail (PN_IS_OPTION (option), NULL);
|
|
103
|
|
104 class = PN_OPTION_GET_CLASS (option);
|
|
105
|
|
106 #ifndef PN_NO_GTK
|
|
107 if (class->widget_type)
|
|
108 return PN_OPTION_WIDGET (g_object_new (class->widget_type, NULL));
|
|
109 #endif /* PN_NO_GTK */
|
|
110
|
|
111 return NULL;
|
|
112 }
|