3 * This file is part of Evince
5 * Copyright (C) 2005 - Paolo Maggi
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* This is a modified version of ephy-module.c from Epiphany source code.
24 * Here the original copyright assignment:
26 * Copyright (C) 2003 Marco Pesenti Gritti
27 * Copyright (C) 2003, 2004 Christian Persch
32 * Modified by the gedit Team, 2005. See the AUTHORS file for a
33 * list of people on the gedit Team.
34 * See the ChangeLog files for a list of changes.
36 * $Id: gedit-module.c 5367 2006-12-17 14:29:49Z pborelli $
39 /* Modified by evince team */
43 #include "ev-module.h"
47 typedef struct _EvModuleClass EvModuleClass;
49 struct _EvModuleClass {
50 GTypeModuleClass parent_class;
54 GTypeModule parent_instance;
63 typedef GType (*EvModuleRegisterFunc) (GTypeModule *);
65 static void ev_module_init (EvModule *action);
66 static void ev_module_class_init (EvModuleClass *class);
68 G_DEFINE_TYPE (EvModule, ev_module, G_TYPE_TYPE_MODULE)
71 ev_module_load (GTypeModule *gmodule)
73 EvModule *module = EV_MODULE (gmodule);
74 EvModuleRegisterFunc register_func;
76 module->library = g_module_open (module->path, 0);
78 if (!module->library) {
79 g_warning ("%s", g_module_error ());
84 /* extract symbols from the lib */
85 if (!g_module_symbol (module->library, "register_evince_backend",
86 (void *) ®ister_func)) {
87 g_warning ("%s", g_module_error ());
88 g_module_close (module->library);
93 /* symbol can still be NULL even though g_module_symbol
96 g_warning ("Symbol 'register_evince_backend' should not be NULL");
97 g_module_close (module->library);
102 module->type = register_func (gmodule);
104 if (module->type == 0) {
105 g_warning ("Invalid evince backend contained by module %s", module->path);
110 if (module->resident)
111 g_module_make_resident (module->library);
117 ev_module_unload (GTypeModule *gmodule)
119 EvModule *module = EV_MODULE (gmodule);
121 g_module_close (module->library);
123 module->library = NULL;
128 ev_module_get_path (EvModule *module)
130 g_return_val_if_fail (EV_IS_MODULE (module), NULL);
136 ev_module_new_object (EvModule *module)
138 g_return_val_if_fail (EV_IS_MODULE (module), NULL);
140 if (module->type == 0)
143 return g_object_new (module->type, NULL);
147 ev_module_get_object_type (EvModule *module)
149 g_return_val_if_fail (EV_IS_MODULE (module), 0);
155 ev_module_init (EvModule *module)
160 ev_module_finalize (GObject *object)
162 EvModule *module = EV_MODULE (object);
164 g_free (module->path);
166 G_OBJECT_CLASS (ev_module_parent_class)->finalize (object);
170 ev_module_class_init (EvModuleClass *class)
172 GObjectClass *object_class = G_OBJECT_CLASS (class);
173 GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
175 object_class->finalize = ev_module_finalize;
177 module_class->load = ev_module_load;
178 module_class->unload = ev_module_unload;
182 ev_module_new (const gchar *path,
187 g_return_val_if_fail (path != NULL && path[0] != '\0', NULL);
189 result = g_object_new (EV_TYPE_MODULE, NULL);
191 g_type_module_set_name (G_TYPE_MODULE (result), path);
192 result->path = g_strdup (path);
193 result->resident = resident;