Added initial Spanish translation
[anjuta-git-plugin.git] / libanjuta / anjuta-glue-cpp.c
blob3a6e4cfabb71e872bdae500db1159524be69f26a
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta-glue-cpp.c (c) 2006 Johannes Schmid
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.
8 *
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 Library 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, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
19 /**
20 * SECTION:anjuta-glue-cpp
21 * @title: AnjutaAnjutaGlueCpp
22 * @short_description: C++ Anjuta glue code
23 * @see_also:
24 * @stability: Unstable
25 * @include: libanjuta/anjuta-glue-cpp.h
29 #include "anjuta-glue-cpp.h"
31 #include <string.h>
32 #include <gmodule.h>
34 typedef GObject* (*AnjutaGlue_constructor)();
36 GObject*
37 anjuta_glue_cpp_load_plugin(AnjutaGlueFactory* factory, const gchar* component_name, const gchar* type_name)
39 GList* p = anjuta_glue_factory_get_path(factory);
40 gchar *plugin_name;
42 plugin_name = g_module_build_path (NULL, component_name);
44 AnjutaGlue_constructor constructor;
46 while (p)
48 const gchar *file_name;
49 PathEntry *entry = p->data;
50 GDir *dir;
51 GObject* plugin;
53 dir = g_dir_open (entry->path, 0, NULL);
55 if (dir == NULL)
56 continue;
58 do {
59 file_name = g_dir_read_name (dir);
61 if (file_name && strcmp (file_name, plugin_name) == 0) {
62 GModule *module;
63 gchar *plugin_path;
65 /* We have found a matching module */
66 plugin_path = g_module_build_path (entry->path, plugin_name);
67 module = g_module_open (plugin_path, 0);
68 if (module == NULL)
70 g_warning ("Could not open module: %s\n", g_module_error ());
71 goto move_to_next_dir;
74 if (!g_module_symbol (module, "anjuta_glue_constructor", (gpointer *)&constructor))
76 g_module_close (module);
77 goto move_to_next_dir;
79 /* Create the object */
80 plugin = (*constructor)();
81 return plugin;
83 } while (file_name != NULL);
84 move_to_next_dir:
85 g_dir_close (dir);
87 p = p->next;
90 return NULL;