2
* Copyright (C) 2009 Nick Schermer <nick@xfce.org>
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 2 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 along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
#include <common/panel-private.h>
28
#include <wrapper/wrapper-module.h>
32
static void wrapper_module_dispose (GObject *object);
33
static gboolean wrapper_module_load (GTypeModule *type_module);
34
static void wrapper_module_unload (GTypeModule *type_module);
39
struct _WrapperModuleClass
41
GTypeModuleClass __parent__;
46
GTypeModule __parent__;
54
G_DEFINE_TYPE (WrapperModule, wrapper_module, G_TYPE_TYPE_MODULE)
59
wrapper_module_class_init (WrapperModuleClass *klass)
61
GObjectClass *gobject_class;
62
GTypeModuleClass *gtype_module_class;
64
gobject_class = G_OBJECT_CLASS (klass);
65
gobject_class->dispose = wrapper_module_dispose;
67
gtype_module_class = G_TYPE_MODULE_CLASS (klass);
68
gtype_module_class->load = wrapper_module_load;
69
gtype_module_class->unload = wrapper_module_unload;
75
wrapper_module_init (WrapperModule *module)
83
wrapper_module_dispose (GObject *object)
91
wrapper_module_load (GTypeModule *type_module)
99
wrapper_module_unload (GTypeModule *type_module)
107
wrapper_module_new (GModule *library)
109
WrapperModule *module;
111
module = g_object_new (WRAPPER_TYPE_MODULE, NULL);
112
module->library = library;
120
wrapper_module_new_provider (WrapperModule *module,
124
const gchar *display_name,
125
const gchar *comment,
128
GtkWidget *plugin = NULL;
129
PluginConstructFunc construct_func;
130
PluginInitFunc init_func;
133
panel_return_val_if_fail (WRAPPER_IS_MODULE (module), NULL);
134
panel_return_val_if_fail (module->library != NULL, NULL);
136
g_type_module_use (G_TYPE_MODULE (module));
138
/* try to link the contruct or init function */
139
if (g_module_symbol (module->library, "xfce_panel_module_init",
140
(gpointer) &init_func) && init_func != NULL)
142
/* initialize the plugin */
143
type = (init_func) (G_TYPE_MODULE (module), NULL);
145
/* create the object */
146
plugin = g_object_new (type,
148
"unique-id", unique_id,
149
"display-name", display_name,
151
"arguments", arguments, NULL);
153
else if (g_module_symbol (module->library, "xfce_panel_module_construct",
154
(gpointer) &construct_func) && construct_func != NULL)
156
/* create a new panel plugin */
157
plugin = (*construct_func) (name, unique_id,
158
display_name, comment,
163
/* print critical warning */
164
g_critical ("Plugin \"%s\" lacks a plugin register function.", name);