From 5ded9cba8563f336939400303d6a841d5089b107 Mon Sep 17 00:00:00 2001 From: Perberos Date: Mon, 7 Nov 2011 19:52:18 -0300 Subject: renaming from gedit to pluma --- plugin-loaders/c/Makefile.am | 12 +- plugin-loaders/c/gedit-plugin-loader-c.c | 182 ------------------------------- plugin-loaders/c/gedit-plugin-loader-c.h | 60 ---------- plugin-loaders/c/pluma-plugin-loader-c.c | 182 +++++++++++++++++++++++++++++++ plugin-loaders/c/pluma-plugin-loader-c.h | 60 ++++++++++ 5 files changed, 248 insertions(+), 248 deletions(-) delete mode 100755 plugin-loaders/c/gedit-plugin-loader-c.c delete mode 100755 plugin-loaders/c/gedit-plugin-loader-c.h create mode 100755 plugin-loaders/c/pluma-plugin-loader-c.c create mode 100755 plugin-loaders/c/pluma-plugin-loader-c.h (limited to 'plugin-loaders/c') diff --git a/plugin-loaders/c/Makefile.am b/plugin-loaders/c/Makefile.am index 7760aefe..37df5cd3 100755 --- a/plugin-loaders/c/Makefile.am +++ b/plugin-loaders/c/Makefile.am @@ -1,24 +1,24 @@ # C plugin loader -loaderdir = $(libdir)/gedit-2/plugin-loaders +loaderdir = $(libdir)/pluma-2/plugin-loaders INCLUDES = \ -I$(top_srcdir) \ - $(GEDIT_CFLAGS) \ + $(PLUMA_CFLAGS) \ $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ - -DGEDIT_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" + -DPLUMA_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" loader_LTLIBRARIES = libcloader.la NOINST_H_FILES = \ - gedit-plugin-loader-c.h + pluma-plugin-loader-c.h libcloader_la_SOURCES = \ - gedit-plugin-loader-c.c \ + pluma-plugin-loader-c.c \ $(NOINST_H_FILES) libcloader_la_LDFLAGS = $(LOADER_LIBTOOL_FLAGS) -libcloader_la_LIBADD = $(GEDIT_LIBS) +libcloader_la_LIBADD = $(PLUMA_LIBS) -include $(top_srcdir)/git.mk diff --git a/plugin-loaders/c/gedit-plugin-loader-c.c b/plugin-loaders/c/gedit-plugin-loader-c.c deleted file mode 100755 index 37b3d059..00000000 --- a/plugin-loaders/c/gedit-plugin-loader-c.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * gedit-plugin-loader-c.c - * This file is part of gedit - * - * Copyright (C) 2008 - Jesse van den Kieboom - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "gedit-plugin-loader-c.h" -#include - -#define GEDIT_PLUGIN_LOADER_C_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_PLUGIN_LOADER_C, GeditPluginLoaderCPrivate)) - -struct _GeditPluginLoaderCPrivate -{ - GHashTable *loaded_plugins; -}; - -static void gedit_plugin_loader_iface_init (gpointer g_iface, gpointer iface_data); - -GEDIT_PLUGIN_LOADER_REGISTER_TYPE (GeditPluginLoaderC, gedit_plugin_loader_c, G_TYPE_OBJECT, gedit_plugin_loader_iface_init); - - -static const gchar * -gedit_plugin_loader_iface_get_id (void) -{ - return "C"; -} - -static GeditPlugin * -gedit_plugin_loader_iface_load (GeditPluginLoader *loader, - GeditPluginInfo *info, - const gchar *path) -{ - GeditPluginLoaderC *cloader = GEDIT_PLUGIN_LOADER_C (loader); - GeditObjectModule *module; - const gchar *module_name; - GeditPlugin *result; - - module = (GeditObjectModule *)g_hash_table_lookup (cloader->priv->loaded_plugins, info); - module_name = gedit_plugin_info_get_module_name (info); - - if (module == NULL) - { - /* For now we force all modules to be resident */ - module = gedit_object_module_new (module_name, - path, - "register_gedit_plugin", - TRUE); - - /* Infos are available for all the lifetime of the loader. - * If this changes, we should use weak refs or something */ - - g_hash_table_insert (cloader->priv->loaded_plugins, info, module); - } - - if (!g_type_module_use (G_TYPE_MODULE (module))) - { - g_warning ("Could not load plugin module: %s", gedit_plugin_info_get_name (info)); - - return NULL; - } - - /* TODO: for now we force data-dir-name = module-name... if needed we can - * add a datadir field to the plugin descriptor file. - */ - result = (GeditPlugin *)gedit_object_module_new_object (module, - "install-dir", path, - "data-dir-name", module_name, - NULL); - - if (!result) - { - g_warning ("Could not create plugin object: %s", gedit_plugin_info_get_name (info)); - g_type_module_unuse (G_TYPE_MODULE (module)); - - return NULL; - } - - g_type_module_unuse (G_TYPE_MODULE (module)); - - return result; -} - -static void -gedit_plugin_loader_iface_unload (GeditPluginLoader *loader, - GeditPluginInfo *info) -{ - //GeditPluginLoaderC *cloader = GEDIT_PLUGIN_LOADER_C (loader); - - /* this is a no-op, since the type module will be properly unused as - the last reference to the plugin dies. When the plugin is activated - again, the library will be reloaded */ -} - -static void -gedit_plugin_loader_iface_init (gpointer g_iface, - gpointer iface_data) -{ - GeditPluginLoaderInterface *iface = (GeditPluginLoaderInterface *)g_iface; - - iface->get_id = gedit_plugin_loader_iface_get_id; - iface->load = gedit_plugin_loader_iface_load; - iface->unload = gedit_plugin_loader_iface_unload; -} - -static void -gedit_plugin_loader_c_finalize (GObject *object) -{ - GeditPluginLoaderC *cloader = GEDIT_PLUGIN_LOADER_C (object); - GList *infos; - GList *item; - - /* FIXME: this sanity check it's not efficient. Let's remove it - * once we are confident with the code */ - - infos = g_hash_table_get_keys (cloader->priv->loaded_plugins); - - for (item = infos; item; item = item->next) - { - GeditPluginInfo *info = (GeditPluginInfo *)item->data; - - if (gedit_plugin_info_is_active (info)) - { - g_warning ("There are still C plugins loaded during destruction"); - break; - } - } - - g_list_free (infos); - - g_hash_table_destroy (cloader->priv->loaded_plugins); - - G_OBJECT_CLASS (gedit_plugin_loader_c_parent_class)->finalize (object); -} - -static void -gedit_plugin_loader_c_class_init (GeditPluginLoaderCClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gedit_plugin_loader_c_finalize; - - g_type_class_add_private (object_class, sizeof (GeditPluginLoaderCPrivate)); -} - -static void -gedit_plugin_loader_c_class_finalize (GeditPluginLoaderCClass *klass) -{ -} - -static void -gedit_plugin_loader_c_init (GeditPluginLoaderC *self) -{ - self->priv = GEDIT_PLUGIN_LOADER_C_GET_PRIVATE (self); - - /* loaded_plugins maps GeditPluginInfo to a GeditObjectModule */ - self->priv->loaded_plugins = g_hash_table_new (g_direct_hash, - g_direct_equal); -} - -GeditPluginLoaderC * -gedit_plugin_loader_c_new () -{ - GObject *loader = g_object_new (GEDIT_TYPE_PLUGIN_LOADER_C, NULL); - - return GEDIT_PLUGIN_LOADER_C (loader); -} diff --git a/plugin-loaders/c/gedit-plugin-loader-c.h b/plugin-loaders/c/gedit-plugin-loader-c.h deleted file mode 100755 index 70420546..00000000 --- a/plugin-loaders/c/gedit-plugin-loader-c.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * gedit-plugin-loader-c.h - * This file is part of gedit - * - * Copyright (C) 2008 - Jesse van den Kieboom - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GEDIT_PLUGIN_LOADER_C_H__ -#define __GEDIT_PLUGIN_LOADER_C_H__ - -#include - -G_BEGIN_DECLS - -#define GEDIT_TYPE_PLUGIN_LOADER_C (gedit_plugin_loader_c_get_type ()) -#define GEDIT_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_PLUGIN_LOADER_C, GeditPluginLoaderC)) -#define GEDIT_PLUGIN_LOADER_C_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_PLUGIN_LOADER_C, GeditPluginLoaderC const)) -#define GEDIT_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_PLUGIN_LOADER_C, GeditPluginLoaderCClass)) -#define GEDIT_IS_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_PLUGIN_LOADER_C)) -#define GEDIT_IS_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_PLUGIN_LOADER_C)) -#define GEDIT_PLUGIN_LOADER_C_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_PLUGIN_LOADER_C, GeditPluginLoaderCClass)) - -typedef struct _GeditPluginLoaderC GeditPluginLoaderC; -typedef struct _GeditPluginLoaderCClass GeditPluginLoaderCClass; -typedef struct _GeditPluginLoaderCPrivate GeditPluginLoaderCPrivate; - -struct _GeditPluginLoaderC { - GObject parent; - - GeditPluginLoaderCPrivate *priv; -}; - -struct _GeditPluginLoaderCClass { - GObjectClass parent_class; -}; - -GType gedit_plugin_loader_c_get_type (void) G_GNUC_CONST; -GeditPluginLoaderC *gedit_plugin_loader_c_new(void); - -/* All the loaders must implement this function */ -G_MODULE_EXPORT GType register_gedit_plugin_loader (GTypeModule * module); - -G_END_DECLS - -#endif /* __GEDIT_PLUGIN_LOADER_C_H__ */ diff --git a/plugin-loaders/c/pluma-plugin-loader-c.c b/plugin-loaders/c/pluma-plugin-loader-c.c new file mode 100755 index 00000000..09f0cccd --- /dev/null +++ b/plugin-loaders/c/pluma-plugin-loader-c.c @@ -0,0 +1,182 @@ +/* + * pluma-plugin-loader-c.c + * This file is part of pluma + * + * Copyright (C) 2008 - Jesse van den Kieboom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "pluma-plugin-loader-c.h" +#include + +#define PLUMA_PLUGIN_LOADER_C_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), PLUMA_TYPE_PLUGIN_LOADER_C, PlumaPluginLoaderCPrivate)) + +struct _PlumaPluginLoaderCPrivate +{ + GHashTable *loaded_plugins; +}; + +static void pluma_plugin_loader_iface_init (gpointer g_iface, gpointer iface_data); + +PLUMA_PLUGIN_LOADER_REGISTER_TYPE (PlumaPluginLoaderC, pluma_plugin_loader_c, G_TYPE_OBJECT, pluma_plugin_loader_iface_init); + + +static const gchar * +pluma_plugin_loader_iface_get_id (void) +{ + return "C"; +} + +static PlumaPlugin * +pluma_plugin_loader_iface_load (PlumaPluginLoader *loader, + PlumaPluginInfo *info, + const gchar *path) +{ + PlumaPluginLoaderC *cloader = PLUMA_PLUGIN_LOADER_C (loader); + PlumaObjectModule *module; + const gchar *module_name; + PlumaPlugin *result; + + module = (PlumaObjectModule *)g_hash_table_lookup (cloader->priv->loaded_plugins, info); + module_name = pluma_plugin_info_get_module_name (info); + + if (module == NULL) + { + /* For now we force all modules to be resident */ + module = pluma_object_module_new (module_name, + path, + "register_pluma_plugin", + TRUE); + + /* Infos are available for all the lifetime of the loader. + * If this changes, we should use weak refs or something */ + + g_hash_table_insert (cloader->priv->loaded_plugins, info, module); + } + + if (!g_type_module_use (G_TYPE_MODULE (module))) + { + g_warning ("Could not load plugin module: %s", pluma_plugin_info_get_name (info)); + + return NULL; + } + + /* TODO: for now we force data-dir-name = module-name... if needed we can + * add a datadir field to the plugin descriptor file. + */ + result = (PlumaPlugin *)pluma_object_module_new_object (module, + "install-dir", path, + "data-dir-name", module_name, + NULL); + + if (!result) + { + g_warning ("Could not create plugin object: %s", pluma_plugin_info_get_name (info)); + g_type_module_unuse (G_TYPE_MODULE (module)); + + return NULL; + } + + g_type_module_unuse (G_TYPE_MODULE (module)); + + return result; +} + +static void +pluma_plugin_loader_iface_unload (PlumaPluginLoader *loader, + PlumaPluginInfo *info) +{ + //PlumaPluginLoaderC *cloader = PLUMA_PLUGIN_LOADER_C (loader); + + /* this is a no-op, since the type module will be properly unused as + the last reference to the plugin dies. When the plugin is activated + again, the library will be reloaded */ +} + +static void +pluma_plugin_loader_iface_init (gpointer g_iface, + gpointer iface_data) +{ + PlumaPluginLoaderInterface *iface = (PlumaPluginLoaderInterface *)g_iface; + + iface->get_id = pluma_plugin_loader_iface_get_id; + iface->load = pluma_plugin_loader_iface_load; + iface->unload = pluma_plugin_loader_iface_unload; +} + +static void +pluma_plugin_loader_c_finalize (GObject *object) +{ + PlumaPluginLoaderC *cloader = PLUMA_PLUGIN_LOADER_C (object); + GList *infos; + GList *item; + + /* FIXME: this sanity check it's not efficient. Let's remove it + * once we are confident with the code */ + + infos = g_hash_table_get_keys (cloader->priv->loaded_plugins); + + for (item = infos; item; item = item->next) + { + PlumaPluginInfo *info = (PlumaPluginInfo *)item->data; + + if (pluma_plugin_info_is_active (info)) + { + g_warning ("There are still C plugins loaded during destruction"); + break; + } + } + + g_list_free (infos); + + g_hash_table_destroy (cloader->priv->loaded_plugins); + + G_OBJECT_CLASS (pluma_plugin_loader_c_parent_class)->finalize (object); +} + +static void +pluma_plugin_loader_c_class_init (PlumaPluginLoaderCClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = pluma_plugin_loader_c_finalize; + + g_type_class_add_private (object_class, sizeof (PlumaPluginLoaderCPrivate)); +} + +static void +pluma_plugin_loader_c_class_finalize (PlumaPluginLoaderCClass *klass) +{ +} + +static void +pluma_plugin_loader_c_init (PlumaPluginLoaderC *self) +{ + self->priv = PLUMA_PLUGIN_LOADER_C_GET_PRIVATE (self); + + /* loaded_plugins maps PlumaPluginInfo to a PlumaObjectModule */ + self->priv->loaded_plugins = g_hash_table_new (g_direct_hash, + g_direct_equal); +} + +PlumaPluginLoaderC * +pluma_plugin_loader_c_new () +{ + GObject *loader = g_object_new (PLUMA_TYPE_PLUGIN_LOADER_C, NULL); + + return PLUMA_PLUGIN_LOADER_C (loader); +} diff --git a/plugin-loaders/c/pluma-plugin-loader-c.h b/plugin-loaders/c/pluma-plugin-loader-c.h new file mode 100755 index 00000000..1877039f --- /dev/null +++ b/plugin-loaders/c/pluma-plugin-loader-c.h @@ -0,0 +1,60 @@ +/* + * pluma-plugin-loader-c.h + * This file is part of pluma + * + * Copyright (C) 2008 - Jesse van den Kieboom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __PLUMA_PLUGIN_LOADER_C_H__ +#define __PLUMA_PLUGIN_LOADER_C_H__ + +#include + +G_BEGIN_DECLS + +#define PLUMA_TYPE_PLUGIN_LOADER_C (pluma_plugin_loader_c_get_type ()) +#define PLUMA_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_PLUGIN_LOADER_C, PlumaPluginLoaderC)) +#define PLUMA_PLUGIN_LOADER_C_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_PLUGIN_LOADER_C, PlumaPluginLoaderC const)) +#define PLUMA_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLUMA_TYPE_PLUGIN_LOADER_C, PlumaPluginLoaderCClass)) +#define PLUMA_IS_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLUMA_TYPE_PLUGIN_LOADER_C)) +#define PLUMA_IS_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_PLUGIN_LOADER_C)) +#define PLUMA_PLUGIN_LOADER_C_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLUMA_TYPE_PLUGIN_LOADER_C, PlumaPluginLoaderCClass)) + +typedef struct _PlumaPluginLoaderC PlumaPluginLoaderC; +typedef struct _PlumaPluginLoaderCClass PlumaPluginLoaderCClass; +typedef struct _PlumaPluginLoaderCPrivate PlumaPluginLoaderCPrivate; + +struct _PlumaPluginLoaderC { + GObject parent; + + PlumaPluginLoaderCPrivate *priv; +}; + +struct _PlumaPluginLoaderCClass { + GObjectClass parent_class; +}; + +GType pluma_plugin_loader_c_get_type (void) G_GNUC_CONST; +PlumaPluginLoaderC *pluma_plugin_loader_c_new(void); + +/* All the loaders must implement this function */ +G_MODULE_EXPORT GType register_pluma_plugin_loader (GTypeModule * module); + +G_END_DECLS + +#endif /* __PLUMA_PLUGIN_LOADER_C_H__ */ -- cgit v1.2.1