diff options
author | monsta <[email protected]> | 2016-12-05 18:42:03 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-12-05 18:42:03 +0300 |
commit | 3860e7b99fc652c7d193cf81f565ea56b507b51a (patch) | |
tree | 5e5c45b591ea066e749786cea9f3f236523d8e15 | |
parent | e1fbe56adf49a5f4d3a3bb493933d9ae5a5c081f (diff) | |
download | pluma-3860e7b99fc652c7d193cf81f565ea56b507b51a.tar.bz2 pluma-3860e7b99fc652c7d193cf81f565ea56b507b51a.tar.xz |
remove old plugin system and docs for it
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | docs/reference/Makefile.am | 2 | ||||
-rw-r--r-- | docs/reference/pluma-docs.sgml | 1 | ||||
-rw-r--r-- | docs/reference/pluma-sections.txt | 24 | ||||
-rw-r--r-- | docs/reference/pluma.types | 2 | ||||
-rw-r--r-- | plugin-loaders/Makefile.am | 3 | ||||
-rw-r--r-- | plugin-loaders/c/Makefile.am | 24 | ||||
-rw-r--r-- | plugin-loaders/c/pluma-plugin-loader-c.c | 182 | ||||
-rw-r--r-- | plugin-loaders/c/pluma-plugin-loader-c.h | 60 | ||||
-rw-r--r-- | pluma/pluma-object-module.c | 343 | ||||
-rw-r--r-- | pluma/pluma-object-module.h | 94 | ||||
-rw-r--r-- | pluma/pluma-plugin-info-priv.h | 67 | ||||
-rw-r--r-- | pluma/pluma-plugin-info.c | 396 | ||||
-rw-r--r-- | pluma/pluma-plugin-info.h | 63 | ||||
-rw-r--r-- | pluma/pluma-plugin-loader.c | 131 | ||||
-rw-r--r-- | pluma/pluma-plugin-loader.h | 106 | ||||
-rw-r--r-- | pluma/pluma-plugin-manager.c | 895 | ||||
-rw-r--r-- | pluma/pluma-plugin-manager.h | 83 | ||||
-rw-r--r-- | pluma/pluma-plugin.c | 334 | ||||
-rw-r--r-- | pluma/pluma-plugin.h | 240 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
22 files changed, 1 insertions, 3056 deletions
diff --git a/Makefile.am b/Makefile.am index d472aea3..44bcacd4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -SUBDIRS = pluma pixmaps po data plugin-loaders plugins docs help +SUBDIRS = pluma pixmaps po data plugins docs help if ENABLE_TESTS SUBDIRS += tests diff --git a/configure.ac b/configure.ac index 08f83a5a..cf145e37 100644 --- a/configure.ac +++ b/configure.ac @@ -224,10 +224,8 @@ AC_ARG_ENABLE([tests], AM_CONDITIONAL(ENABLE_TESTS, test x$enable_tests = xyes) PLUGIN_LIBTOOL_FLAGS="-module -avoid-version" -LOADER_LIBTOOL_FLAGS="-module -avoid-version" AC_SUBST(PLUGIN_LIBTOOL_FLAGS) -AC_SUBST(LOADER_LIBTOOL_FLAGS) PLUMA_PLUGINS_DATA_DIR="$datadir/pluma/plugins" AC_SUBST(PLUMA_PLUGINS_DATA_DIR) @@ -251,8 +249,6 @@ pluma/smclient/Makefile pluma/Makefile help/Makefile pixmaps/Makefile -plugin-loaders/Makefile -plugin-loaders/c/Makefile plugins/Makefile plugins/changecase/Makefile plugins/docinfo/Makefile diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index f52aba90..e85d2228 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -46,8 +46,6 @@ IGNORE_HFILES= \ pluma-documents-panel.h \ pluma-io-error-message-area.h \ pluma-languages-manager.h \ - pluma-object-module.h \ - pluma-plugin-manager.h \ pluma-plugins-engine.h \ pluma-prefs-manager-private.h \ pluma-session.h \ diff --git a/docs/reference/pluma-docs.sgml b/docs/reference/pluma-docs.sgml index cf349af0..19bda5a5 100644 --- a/docs/reference/pluma-docs.sgml +++ b/docs/reference/pluma-docs.sgml @@ -17,7 +17,6 @@ <xi:include href="xml/pluma-message.xml"/> <xi:include href="xml/pluma-notebook.xml"/> <xi:include href="xml/pluma-panel.xml"/> - <xi:include href="xml/pluma-plugin.xml"/> <xi:include href="xml/pluma-print-job-preview.xml"/> <xi:include href="xml/pluma-print.xml"/> <xi:include href="xml/pluma-progress-message-area.xml"/> diff --git a/docs/reference/pluma-sections.txt b/docs/reference/pluma-sections.txt index 4c7963d4..db6fc66f 100644 --- a/docs/reference/pluma-sections.txt +++ b/docs/reference/pluma-sections.txt @@ -239,30 +239,6 @@ PLUMA_PANEL_GET_CLASS </SECTION> <SECTION> -<FILE>pluma-plugin</FILE> -<TITLE>PlumaPlugin</TITLE> -PlumaPlugin -pluma_plugin_activate -pluma_plugin_deactivate -pluma_plugin_update_ui -pluma_plugin_is_configurable -pluma_plugin_create_configure_dialog -PLUMA_PLUGIN_REGISTER_TYPE -<SUBSECTION Standard> -PLUMA_PLUGIN -PLUMA_IS_PLUGIN -PLUMA_TYPE_PLUGIN -pluma_plugin_get_type -PLUMA_PLUGIN_CLASS -PLUMA_IS_PLUGIN_CLASS -PLUMA_PLUGIN_GET_CLASS -PLUMA_PLUGIN_REGISTER_TYPE_WITH_CODE -PLUMA_PLUGIN_REGISTER_TYPE -PLUMA_PLUGIN_DEFINE_TYPE_WITH_CODE -PLUMA_PLUGIN_DEFINE_TYPE -</SECTION> - -<SECTION> <FILE>pluma-print-job-preview</FILE> PlumaPrintJobPreviewPrivate <TITLE>PlumaPrintJobPreview</TITLE> diff --git a/docs/reference/pluma.types b/docs/reference/pluma.types index 0dc5633e..0eeea1a2 100644 --- a/docs/reference/pluma.types +++ b/docs/reference/pluma.types @@ -8,7 +8,6 @@ #include "pluma-message-type.h" #include "pluma-notebook.h" #include "pluma-panel.h" -#include "pluma-plugin.h" #include "pluma-progress-message-area.h" #include "pluma-statusbar.h" #include "pluma-tab.h" @@ -24,7 +23,6 @@ pluma_message_bus_get_type pluma_message_type_get_type pluma_notebook_get_type pluma_panel_get_type -pluma_plugin_get_type pluma_progress_message_area_get_type pluma_statusbar_get_type pluma_tab_get_type diff --git a/plugin-loaders/Makefile.am b/plugin-loaders/Makefile.am deleted file mode 100644 index 2573ec31..00000000 --- a/plugin-loaders/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = c - --include $(top_srcdir)/git.mk diff --git a/plugin-loaders/c/Makefile.am b/plugin-loaders/c/Makefile.am deleted file mode 100644 index 571c79d4..00000000 --- a/plugin-loaders/c/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# C plugin loader - -loaderdir = $(libdir)/pluma/plugin-loaders - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - $(PLUMA_CFLAGS) \ - $(WARN_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - -DPLUMA_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" - -loader_LTLIBRARIES = libcloader.la - -NOINST_H_FILES = \ - pluma-plugin-loader-c.h - -libcloader_la_SOURCES = \ - pluma-plugin-loader-c.c \ - $(NOINST_H_FILES) - -libcloader_la_LDFLAGS = $(LOADER_LIBTOOL_FLAGS) -libcloader_la_LIBADD = $(PLUMA_LIBS) - --include $(top_srcdir)/git.mk diff --git a/plugin-loaders/c/pluma-plugin-loader-c.c b/plugin-loaders/c/pluma-plugin-loader-c.c deleted file mode 100644 index 1ecca185..00000000 --- a/plugin-loaders/c/pluma-plugin-loader-c.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "pluma-plugin-loader-c.h" -#include <pluma/pluma-object-module.h> - -#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 deleted file mode 100644 index 431befb5..00000000 --- a/plugin-loaders/c/pluma-plugin-loader-c.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PLUMA_PLUGIN_LOADER_C_H__ -#define __PLUMA_PLUGIN_LOADER_C_H__ - -#include <pluma/pluma-plugin-loader.h> - -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__ */ diff --git a/pluma/pluma-object-module.c b/pluma/pluma-object-module.c deleted file mode 100644 index 7870d413..00000000 --- a/pluma/pluma-object-module.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * pluma-object-module.c - * This file is part of pluma - * - * Copyright (C) 2005 - Paolo Maggi - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* This is a modified version of ephy-module.c from Epiphany source code. - * Here the original copyright assignment: - * - * Copyright (C) 2003 Marco Pesenti Gritti - * Copyright (C) 2003, 2004 Christian Persch - * - */ - -/* - * Modified by the pluma Team, 2005. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id: pluma-module.c 6314 2008-06-05 12:57:53Z pborelli $ - */ - -#include "config.h" - -#include "pluma-object-module.h" -#include "pluma-debug.h" - -typedef GType (*PlumaObjectModuleRegisterFunc) (GTypeModule *); - -enum { - PROP_0, - PROP_MODULE_NAME, - PROP_PATH, - PROP_TYPE_REGISTRATION, - PROP_RESIDENT -}; - -struct _PlumaObjectModulePrivate -{ - GModule *library; - - GType type; - gchar *path; - gchar *module_name; - gchar *type_registration; - - gboolean resident; -}; - -G_DEFINE_TYPE (PlumaObjectModule, pluma_object_module, G_TYPE_TYPE_MODULE); - -static gboolean -pluma_object_module_load (GTypeModule *gmodule) -{ - PlumaObjectModule *module = PLUMA_OBJECT_MODULE (gmodule); - PlumaObjectModuleRegisterFunc register_func; - gchar *path; - - pluma_debug_message (DEBUG_PLUGINS, "Loading %s module from %s", - module->priv->module_name, module->priv->path); - - path = g_module_build_path (module->priv->path, module->priv->module_name); - g_return_val_if_fail (path != NULL, FALSE); - pluma_debug_message (DEBUG_PLUGINS, "Module filename: %s", path); - - module->priv->library = g_module_open (path, - G_MODULE_BIND_LAZY); - g_free (path); - - if (module->priv->library == NULL) - { - g_warning ("%s: %s", module->priv->module_name, g_module_error()); - - return FALSE; - } - - /* extract symbols from the lib */ - if (!g_module_symbol (module->priv->library, module->priv->type_registration, - (void *) ®ister_func)) - { - g_warning ("%s: %s", module->priv->module_name, g_module_error()); - g_module_close (module->priv->library); - - return FALSE; - } - - /* symbol can still be NULL even though g_module_symbol - * returned TRUE */ - if (register_func == NULL) - { - g_warning ("Symbol '%s' should not be NULL", module->priv->type_registration); - g_module_close (module->priv->library); - - return FALSE; - } - - module->priv->type = register_func (gmodule); - - if (module->priv->type == 0) - { - g_warning ("Invalid object contained by module %s", module->priv->module_name); - return FALSE; - } - - if (module->priv->resident) - { - g_module_make_resident (module->priv->library); - } - - return TRUE; -} - -static void -pluma_object_module_unload (GTypeModule *gmodule) -{ - PlumaObjectModule *module = PLUMA_OBJECT_MODULE (gmodule); - - pluma_debug_message (DEBUG_PLUGINS, "Unloading %s", module->priv->path); - - g_module_close (module->priv->library); - - module->priv->library = NULL; - module->priv->type = 0; -} - -static void -pluma_object_module_init (PlumaObjectModule *module) -{ - pluma_debug_message (DEBUG_PLUGINS, "PlumaObjectModule %p initialising", module); - - module->priv = G_TYPE_INSTANCE_GET_PRIVATE (module, - PLUMA_TYPE_OBJECT_MODULE, - PlumaObjectModulePrivate); -} - -static void -pluma_object_module_finalize (GObject *object) -{ - PlumaObjectModule *module = PLUMA_OBJECT_MODULE (object); - - pluma_debug_message (DEBUG_PLUGINS, "PlumaObjectModule %p finalising", module); - - g_free (module->priv->path); - g_free (module->priv->module_name); - g_free (module->priv->type_registration); - - G_OBJECT_CLASS (pluma_object_module_parent_class)->finalize (object); -} - -static void -pluma_object_module_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - PlumaObjectModule *module = PLUMA_OBJECT_MODULE (object); - - switch (prop_id) - { - case PROP_MODULE_NAME: - g_value_set_string (value, module->priv->module_name); - break; - case PROP_PATH: - g_value_set_string (value, module->priv->path); - break; - case PROP_TYPE_REGISTRATION: - g_value_set_string (value, module->priv->type_registration); - break; - case PROP_RESIDENT: - g_value_set_boolean (value, module->priv->resident); - break; - default: - g_return_if_reached (); - } -} - -static void -pluma_object_module_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PlumaObjectModule *module = PLUMA_OBJECT_MODULE (object); - - switch (prop_id) - { - case PROP_MODULE_NAME: - module->priv->module_name = g_value_dup_string (value); - g_type_module_set_name (G_TYPE_MODULE (object), - module->priv->module_name); - break; - case PROP_PATH: - module->priv->path = g_value_dup_string (value); - break; - case PROP_TYPE_REGISTRATION: - module->priv->type_registration = g_value_dup_string (value); - break; - case PROP_RESIDENT: - module->priv->resident = g_value_get_boolean (value); - break; - default: - g_return_if_reached (); - } -} - -static void -pluma_object_module_class_init (PlumaObjectModuleClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass); - - object_class->set_property = pluma_object_module_set_property; - object_class->get_property = pluma_object_module_get_property; - object_class->finalize = pluma_object_module_finalize; - - module_class->load = pluma_object_module_load; - module_class->unload = pluma_object_module_unload; - - g_object_class_install_property (object_class, - PROP_MODULE_NAME, - g_param_spec_string ("module-name", - "Module Name", - "The module to load for this object", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, - PROP_PATH, - g_param_spec_string ("path", - "Path", - "The path to use when loading this module", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, - PROP_TYPE_REGISTRATION, - g_param_spec_string ("type-registration", - "Type Registration", - "The name of the type registration function", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, - PROP_RESIDENT, - g_param_spec_boolean ("resident", - "Resident", - "Whether the module is resident", - FALSE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (klass, sizeof (PlumaObjectModulePrivate)); -} - -PlumaObjectModule * -pluma_object_module_new (const gchar *module_name, - const gchar *path, - const gchar *type_registration, - gboolean resident) -{ - return (PlumaObjectModule *)g_object_new (PLUMA_TYPE_OBJECT_MODULE, - "module-name", - module_name, - "path", - path, - "type-registration", - type_registration, - "resident", - resident, - NULL); -} - -GObject * -pluma_object_module_new_object (PlumaObjectModule *module, - const gchar *first_property_name, - ...) -{ - va_list var_args; - GObject *result; - - g_return_val_if_fail (module->priv->type != 0, NULL); - - pluma_debug_message (DEBUG_PLUGINS, "Creating object of type %s", - g_type_name (module->priv->type)); - - va_start (var_args, first_property_name); - result = g_object_new_valist (module->priv->type, first_property_name, var_args); - va_end (var_args); - - return result; -} - -const gchar * -pluma_object_module_get_path (PlumaObjectModule *module) -{ - g_return_val_if_fail (PLUMA_IS_OBJECT_MODULE (module), NULL); - - return module->priv->path; -} - -const gchar * -pluma_object_module_get_module_name (PlumaObjectModule *module) -{ - g_return_val_if_fail (PLUMA_IS_OBJECT_MODULE (module), NULL); - - return module->priv->module_name; -} - -const gchar * -pluma_object_module_get_type_registration (PlumaObjectModule *module) -{ - g_return_val_if_fail (PLUMA_IS_OBJECT_MODULE (module), NULL); - - return module->priv->type_registration; -} - -GType -pluma_object_module_get_object_type (PlumaObjectModule *module) -{ - g_return_val_if_fail (PLUMA_IS_OBJECT_MODULE (module), 0); - - return module->priv->type; -} diff --git a/pluma/pluma-object-module.h b/pluma/pluma-object-module.h deleted file mode 100644 index f67ed7cf..00000000 --- a/pluma/pluma-object-module.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * pluma-object-module.h - * This file is part of pluma - * - * Copyright (C) 2005 - Paolo Maggi - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* This is a modified version of pluma-module.h from Epiphany source code. - * Here the original copyright assignment: - * - * Copyright (C) 2003 Marco Pesenti Gritti - * Copyright (C) 2003, 2004 Christian Persch - * - */ - -/* - * Modified by the pluma Team, 2005. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id: pluma-module.h 6263 2008-05-05 10:52:10Z sfre $ - */ - -#ifndef __PLUMA_OBJECT_MODULE_H__ -#define __PLUMA_OBJECT_MODULE_H__ - -#include <glib-object.h> -#include <gmodule.h> -#include <stdarg.h> - -G_BEGIN_DECLS - -#define PLUMA_TYPE_OBJECT_MODULE (pluma_object_module_get_type ()) -#define PLUMA_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_OBJECT_MODULE, PlumaObjectModule)) -#define PLUMA_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLUMA_TYPE_OBJECT_MODULE, PlumaObjectModuleClass)) -#define PLUMA_IS_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLUMA_TYPE_OBJECT_MODULE)) -#define PLUMA_IS_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_OBJECT_MODULE)) -#define PLUMA_OBJECT_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_OBJECT_MODULE, PlumaObjectModuleClass)) - -typedef struct _PlumaObjectModule PlumaObjectModule; -typedef struct _PlumaObjectModulePrivate PlumaObjectModulePrivate; - -struct _PlumaObjectModule -{ - GTypeModule parent; - - PlumaObjectModulePrivate *priv; -}; - -typedef struct _PlumaObjectModuleClass PlumaObjectModuleClass; - -struct _PlumaObjectModuleClass -{ - GTypeModuleClass parent_class; - - /* Virtual class methods */ - void (* garbage_collect) (); -}; - -GType pluma_object_module_get_type (void) G_GNUC_CONST; - -PlumaObjectModule *pluma_object_module_new (const gchar *module_name, - const gchar *path, - const gchar *type_registration, - gboolean resident); - -GObject *pluma_object_module_new_object (PlumaObjectModule *module, - const gchar *first_property_name, - ...); - -GType pluma_object_module_get_object_type (PlumaObjectModule *module); -const gchar *pluma_object_module_get_path (PlumaObjectModule *module); -const gchar *pluma_object_module_get_module_name (PlumaObjectModule *module); -const gchar *pluma_object_module_get_type_registration (PlumaObjectModule *module); - -G_END_DECLS - -#endif diff --git a/pluma/pluma-plugin-info-priv.h b/pluma/pluma-plugin-info-priv.h deleted file mode 100644 index f69e2334..00000000 --- a/pluma/pluma-plugin-info-priv.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * pluma-plugin-info-priv.h - * This file is part of pluma - * - * Copyright (C) 2002-2005 - Paolo Maggi - * Copyright (C) 2007 - Paolo Maggi, Steve Frécinaux - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 2002-2007. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifndef __PLUMA_PLUGIN_INFO_PRIV_H__ -#define __PLUMA_PLUGIN_INFO_PRIV_H__ - -#include "pluma-plugin-info.h" -#include "pluma-plugin.h" - -struct _PlumaPluginInfo -{ - gint refcount; - - PlumaPlugin *plugin; - gchar *file; - - gchar *module_name; - gchar *loader; - gchar **dependencies; - - gchar *name; - gchar *desc; - gchar *icon_name; - gchar **authors; - gchar *copyright; - gchar *website; - gchar *version; - - /* A plugin is unavailable if it is not possible to activate it - due to an error loading the plugin module */ - gint available : 1; -}; - -PlumaPluginInfo *_pluma_plugin_info_new (const gchar *file); -void _pluma_plugin_info_ref (PlumaPluginInfo *info); -void _pluma_plugin_info_unref (PlumaPluginInfo *info); - - -#endif /* __PLUMA_PLUGIN_INFO_PRIV_H__ */ diff --git a/pluma/pluma-plugin-info.c b/pluma/pluma-plugin-info.c deleted file mode 100644 index ef8ab684..00000000 --- a/pluma/pluma-plugin-info.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * pluma-plugin-info.c - * This file is part of pluma - * - * Copyright (C) 2002-2005 - Paolo Maggi - * Copyright (C) 2007 - Paolo Maggi, Steve Frécinaux - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 2002-2007. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <glib/gi18n.h> -#include <glib.h> - -#include "pluma-plugin-info.h" -#include "pluma-plugin-info-priv.h" -#include "pluma-debug.h" -#include "pluma-plugin.h" - -void -_pluma_plugin_info_ref (PlumaPluginInfo *info) -{ - g_atomic_int_inc (&info->refcount); -} - -static PlumaPluginInfo * -pluma_plugin_info_copy (PlumaPluginInfo *info) -{ - _pluma_plugin_info_ref (info); - return info; -} - -void -_pluma_plugin_info_unref (PlumaPluginInfo *info) -{ - if (!g_atomic_int_dec_and_test (&info->refcount)) - return; - - if (info->plugin != NULL) - { - pluma_debug_message (DEBUG_PLUGINS, "Unref plugin %s", info->name); - - g_object_unref (info->plugin); - } - - g_free (info->file); - g_free (info->module_name); - g_strfreev (info->dependencies); - g_free (info->name); - g_free (info->desc); - g_free (info->icon_name); - g_free (info->website); - g_free (info->copyright); - g_free (info->loader); - g_free (info->version); - g_strfreev (info->authors); - - g_free (info); -} - -/** - * pluma_plugin_info_get_type: - * - * Retrieves the #GType object which is associated with the #PlumaPluginInfo - * class. - * - * Return value: the GType associated with #PlumaPluginInfo. - **/ -GType -pluma_plugin_info_get_type (void) -{ - static GType the_type = 0; - - if (G_UNLIKELY (!the_type)) - the_type = g_boxed_type_register_static ( - "PlumaPluginInfo", - (GBoxedCopyFunc) pluma_plugin_info_copy, - (GBoxedFreeFunc) _pluma_plugin_info_unref); - - return the_type; -} - -/** - * pluma_plugin_info_new: - * @filename: the filename where to read the plugin information - * - * Creates a new #PlumaPluginInfo from a file on the disk. - * - * Return value: a newly created #PlumaPluginInfo. - */ -PlumaPluginInfo * -_pluma_plugin_info_new (const gchar *file) -{ - PlumaPluginInfo *info; - GKeyFile *plugin_file = NULL; - gchar *str; - - g_return_val_if_fail (file != NULL, NULL); - - pluma_debug_message (DEBUG_PLUGINS, "Loading plugin: %s", file); - - info = g_new0 (PlumaPluginInfo, 1); - info->refcount = 1; - info->file = g_strdup (file); - - plugin_file = g_key_file_new (); - if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL)) - { - g_warning ("Bad plugin file: %s", file); - goto error; - } - - if (!g_key_file_has_key (plugin_file, - "Pluma Plugin", - "IAge", - NULL)) - { - pluma_debug_message (DEBUG_PLUGINS, - "IAge key does not exist in file: %s", file); - goto error; - } - - /* Check IAge=2 */ - if (g_key_file_get_integer (plugin_file, - "Pluma Plugin", - "IAge", - NULL) != 2) - { - pluma_debug_message (DEBUG_PLUGINS, - "Wrong IAge in file: %s", file); - goto error; - } - - /* Get module name */ - str = g_key_file_get_string (plugin_file, - "Pluma Plugin", - "Module", - NULL); - - if ((str != NULL) && (*str != '\0')) - { - info->module_name = str; - } - else - { - g_warning ("Could not find 'Module' in %s", file); - g_free (str); - goto error; - } - - /* Get the dependency list */ - info->dependencies = g_key_file_get_string_list (plugin_file, - "Pluma Plugin", - "Depends", - NULL, - NULL); - if (info->dependencies == NULL) - { - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Depends' in %s", file); - info->dependencies = g_new0 (gchar *, 1); - } - - /* Get the loader for this plugin */ - str = g_key_file_get_string (plugin_file, - "Pluma Plugin", - "Loader", - NULL); - - if ((str != NULL) && (*str != '\0')) - { - info->loader = str; - } - else - { - /* default to the C loader */ - info->loader = g_strdup("c"); - g_free (str); - } - - /* Get Name */ - str = g_key_file_get_locale_string (plugin_file, - "Pluma Plugin", - "Name", - NULL, NULL); - if (str) - info->name = str; - else - { - g_warning ("Could not find 'Name' in %s", file); - goto error; - } - - /* Get Description */ - str = g_key_file_get_locale_string (plugin_file, - "Pluma Plugin", - "Description", - NULL, NULL); - if (str) - info->desc = str; - else - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Description' in %s", file); - - /* Get Icon */ - str = g_key_file_get_locale_string (plugin_file, - "Pluma Plugin", - "Icon", - NULL, NULL); - if (str) - info->icon_name = str; - else - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Icon' in %s, using 'pluma-plugin'", file); - - - /* Get Authors */ - info->authors = g_key_file_get_string_list (plugin_file, - "Pluma Plugin", - "Authors", - NULL, - NULL); - if (info->authors == NULL) - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Authors' in %s", file); - - - /* Get Copyright */ - str = g_key_file_get_string (plugin_file, - "Pluma Plugin", - "Copyright", - NULL); - if (str) - info->copyright = str; - else - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Copyright' in %s", file); - - /* Get Website */ - str = g_key_file_get_string (plugin_file, - "Pluma Plugin", - "Website", - NULL); - if (str) - info->website = str; - else - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Website' in %s", file); - - /* Get Version */ - str = g_key_file_get_string (plugin_file, - "Pluma Plugin", - "Version", - NULL); - if (str) - info->version = str; - else - pluma_debug_message (DEBUG_PLUGINS, "Could not find 'Version' in %s", file); - - g_key_file_free (plugin_file); - - /* If we know nothing about the availability of the plugin, - set it as available */ - info->available = TRUE; - - return info; - -error: - g_free (info->file); - g_free (info->module_name); - g_free (info->name); - g_free (info->loader); - g_free (info); - g_key_file_free (plugin_file); - - return NULL; -} - -gboolean -pluma_plugin_info_is_active (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, FALSE); - - return info->available && info->plugin != NULL; -} - -gboolean -pluma_plugin_info_is_available (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, FALSE); - - return info->available != FALSE; -} - -gboolean -pluma_plugin_info_is_configurable (PlumaPluginInfo *info) -{ - pluma_debug_message (DEBUG_PLUGINS, "Is '%s' configurable?", info->name); - - g_return_val_if_fail (info != NULL, FALSE); - - if (info->plugin == NULL || !info->available) - return FALSE; - - return pluma_plugin_is_configurable (info->plugin); -} - -const gchar * -pluma_plugin_info_get_module_name (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - return info->module_name; -} - -const gchar * -pluma_plugin_info_get_name (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - return info->name; -} - -const gchar * -pluma_plugin_info_get_description (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - return info->desc; -} - -const gchar * -pluma_plugin_info_get_icon_name (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - /* use the pluma-plugin icon as a default if the plugin does not - have its own */ - if (info->icon_name != NULL && - gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), - info->icon_name)) - return info->icon_name; - else - return "pluma-plugin"; -} - -const gchar ** -pluma_plugin_info_get_authors (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, (const gchar **)NULL); - - return (const gchar **) info->authors; -} - -const gchar * -pluma_plugin_info_get_website (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - return info->website; -} - -const gchar * -pluma_plugin_info_get_copyright (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - return info->copyright; -} - -const gchar * -pluma_plugin_info_get_version (PlumaPluginInfo *info) -{ - g_return_val_if_fail (info != NULL, NULL); - - return info->version; -} diff --git a/pluma/pluma-plugin-info.h b/pluma/pluma-plugin-info.h deleted file mode 100644 index 9a5fb024..00000000 --- a/pluma/pluma-plugin-info.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * pluma-plugin-info.h - * This file is part of pluma - * - * Copyright (C) 2002-2005 - Paolo Maggi - * Copyright (C) 2007 - Paolo Maggi, Steve Frécinaux - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 2002-2007. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifndef __PLUMA_PLUGIN_INFO_H__ -#define __PLUMA_PLUGIN_INFO_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define PLUMA_TYPE_PLUGIN_INFO (pluma_plugin_info_get_type ()) -#define PLUMA_PLUGIN_INFO(obj) ((PlumaPluginInfo *) (obj)) - -typedef struct _PlumaPluginInfo PlumaPluginInfo; - -GType pluma_plugin_info_get_type (void) G_GNUC_CONST; - -gboolean pluma_plugin_info_is_active (PlumaPluginInfo *info); -gboolean pluma_plugin_info_is_available (PlumaPluginInfo *info); -gboolean pluma_plugin_info_is_configurable (PlumaPluginInfo *info); - -const gchar *pluma_plugin_info_get_module_name (PlumaPluginInfo *info); - -const gchar *pluma_plugin_info_get_name (PlumaPluginInfo *info); -const gchar *pluma_plugin_info_get_description (PlumaPluginInfo *info); -const gchar *pluma_plugin_info_get_icon_name (PlumaPluginInfo *info); -const gchar **pluma_plugin_info_get_authors (PlumaPluginInfo *info); -const gchar *pluma_plugin_info_get_website (PlumaPluginInfo *info); -const gchar *pluma_plugin_info_get_copyright (PlumaPluginInfo *info); -const gchar *pluma_plugin_info_get_version (PlumaPluginInfo *info); - -G_END_DECLS - -#endif /* __PLUMA_PLUGIN_INFO_H__ */ - diff --git a/pluma/pluma-plugin-loader.c b/pluma/pluma-plugin-loader.c deleted file mode 100644 index 5da3e21c..00000000 --- a/pluma/pluma-plugin-loader.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * pluma-plugin-loader.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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "pluma-plugin-loader.h" - -static void -pluma_plugin_loader_base_init (gpointer g_class) -{ - static gboolean initialized = FALSE; - - if (G_UNLIKELY (!initialized)) - { - /* create interface signals here. */ - initialized = TRUE; - } -} - -GType -pluma_plugin_loader_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo info = - { - sizeof (PlumaPluginLoaderInterface), - pluma_plugin_loader_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL /* instance_init */ - }; - - type = g_type_register_static (G_TYPE_INTERFACE, "PlumaPluginLoader", &info, 0); - } - - return type; -} - -const gchar * -pluma_plugin_loader_type_get_id (GType type) -{ - GTypeClass *klass; - PlumaPluginLoaderInterface *iface; - - klass = g_type_class_ref (type); - - if (klass == NULL) - { - g_warning ("Could not get class info for plugin loader"); - return NULL; - } - - iface = g_type_interface_peek (klass, PLUMA_TYPE_PLUGIN_LOADER); - - if (iface == NULL) - { - g_warning ("Could not get plugin loader interface"); - g_type_class_unref (klass); - - return NULL; - } - - g_return_val_if_fail (iface->get_id != NULL, NULL); - return iface->get_id (); -} - -PlumaPlugin * -pluma_plugin_loader_load (PlumaPluginLoader *loader, - PlumaPluginInfo *info, - const gchar *path) -{ - PlumaPluginLoaderInterface *iface; - - g_return_val_if_fail (PLUMA_IS_PLUGIN_LOADER (loader), NULL); - - iface = PLUMA_PLUGIN_LOADER_GET_INTERFACE (loader); - g_return_val_if_fail (iface->load != NULL, NULL); - - return iface->load (loader, info, path); -} - -void -pluma_plugin_loader_unload (PlumaPluginLoader *loader, - PlumaPluginInfo *info) -{ - PlumaPluginLoaderInterface *iface; - - g_return_if_fail (PLUMA_IS_PLUGIN_LOADER (loader)); - - iface = PLUMA_PLUGIN_LOADER_GET_INTERFACE (loader); - g_return_if_fail (iface->unload != NULL); - - iface->unload (loader, info); -} - -void -pluma_plugin_loader_garbage_collect (PlumaPluginLoader *loader) -{ - PlumaPluginLoaderInterface *iface; - - g_return_if_fail (PLUMA_IS_PLUGIN_LOADER (loader)); - - iface = PLUMA_PLUGIN_LOADER_GET_INTERFACE (loader); - - if (iface->garbage_collect != NULL) - iface->garbage_collect (loader); -} diff --git a/pluma/pluma-plugin-loader.h b/pluma/pluma-plugin-loader.h deleted file mode 100644 index 47a5cb16..00000000 --- a/pluma/pluma-plugin-loader.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * pluma-plugin-loader.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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PLUMA_PLUGIN_LOADER_H__ -#define __PLUMA_PLUGIN_LOADER_H__ - -#include <glib-object.h> -#include <pluma/pluma-plugin.h> -#include <pluma/pluma-plugin-info.h> - -G_BEGIN_DECLS - -#define PLUMA_TYPE_PLUGIN_LOADER (pluma_plugin_loader_get_type ()) -#define PLUMA_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_PLUGIN_LOADER, PlumaPluginLoader)) -#define PLUMA_IS_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLUMA_TYPE_PLUGIN_LOADER)) -#define PLUMA_PLUGIN_LOADER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), PLUMA_TYPE_PLUGIN_LOADER, PlumaPluginLoaderInterface)) - -typedef struct _PlumaPluginLoader PlumaPluginLoader; /* dummy object */ -typedef struct _PlumaPluginLoaderInterface PlumaPluginLoaderInterface; - -struct _PlumaPluginLoaderInterface { - GTypeInterface parent; - - const gchar *(*get_id) (void); - - PlumaPlugin *(*load) (PlumaPluginLoader *loader, - PlumaPluginInfo *info, - const gchar *path); - - void (*unload) (PlumaPluginLoader *loader, - PlumaPluginInfo *info); - - void (*garbage_collect) (PlumaPluginLoader *loader); -}; - -GType pluma_plugin_loader_get_type (void); - -const gchar *pluma_plugin_loader_type_get_id (GType type); -PlumaPlugin *pluma_plugin_loader_load (PlumaPluginLoader *loader, - PlumaPluginInfo *info, - const gchar *path); -void pluma_plugin_loader_unload (PlumaPluginLoader *loader, - PlumaPluginInfo *info); -void pluma_plugin_loader_garbage_collect (PlumaPluginLoader *loader); - -/** - * PLUMA_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init): - * - * Utility macro used to register interfaces for gobject types in plugin loaders. - */ -#define PLUMA_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) \ - const GInterfaceInfo g_implement_interface_info = \ - { \ - (GInterfaceInitFunc) iface_init, \ - NULL, \ - NULL \ - }; \ - \ - g_type_module_add_interface (type_module, \ - g_define_type_id, \ - TYPE_IFACE, \ - &g_implement_interface_info); - -/** - * PLUMA_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_interface_init): - * - * Utility macro used to register plugin loaders. - */ -#define PLUMA_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_iface_init) \ - G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginLoaderName, \ - plugin_loader_name, \ - PARENT_TYPE, \ - 0, \ - PLUMA_PLUGIN_LOADER_IMPLEMENT_INTERFACE(PLUMA_TYPE_PLUGIN_LOADER, loader_iface_init)); \ - \ - \ -G_MODULE_EXPORT GType \ -register_pluma_plugin_loader (GTypeModule *type_module) \ -{ \ - plugin_loader_name##_register_type (type_module); \ - \ - return plugin_loader_name##_get_type(); \ -} - -G_END_DECLS - -#endif /* __PLUMA_PLUGIN_LOADER_H__ */ diff --git a/pluma/pluma-plugin-manager.c b/pluma/pluma-plugin-manager.c deleted file mode 100644 index ce3e73c6..00000000 --- a/pluma/pluma-plugin-manager.c +++ /dev/null @@ -1,895 +0,0 @@ -/* - * pluma-plugin-manager.c - * This file is part of pluma - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * Copyright (C) 2003-2006 Paolo Maggi - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 1998-2006. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <glib/gi18n.h> - -#include "pluma-plugin-manager.h" -#include "pluma-utils.h" -#include "pluma-plugins-engine.h" -#include "pluma-plugin.h" -#include "pluma-debug.h" - -enum -{ - ACTIVE_COLUMN, - AVAILABLE_COLUMN, - INFO_COLUMN, - N_COLUMNS -}; - -#define PLUGIN_MANAGER_NAME_TITLE _("Plugin") -#define PLUGIN_MANAGER_ACTIVE_TITLE _("Enabled") - -#define PLUMA_PLUGIN_MANAGER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_PLUGIN_MANAGER, PlumaPluginManagerPrivate)) - -struct _PlumaPluginManagerPrivate -{ - GtkWidget *tree; - - GtkWidget *about_button; - GtkWidget *configure_button; - - PlumaPluginsEngine *engine; - - GtkWidget *about; - - GtkWidget *popup_menu; -}; - -G_DEFINE_TYPE(PlumaPluginManager, pluma_plugin_manager, GTK_TYPE_BOX) - -static PlumaPluginInfo *plugin_manager_get_selected_plugin (PlumaPluginManager *pm); -static void plugin_manager_toggle_active (PlumaPluginManager *pm, GtkTreeIter *iter, GtkTreeModel *model); -static void pluma_plugin_manager_finalize (GObject *object); - -static void -pluma_plugin_manager_class_init (PlumaPluginManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = pluma_plugin_manager_finalize; - - g_type_class_add_private (object_class, sizeof (PlumaPluginManagerPrivate)); -} - -static void -about_button_cb (GtkWidget *button, - PlumaPluginManager *pm) -{ - PlumaPluginInfo *info; - - pluma_debug (DEBUG_PLUGINS); - - info = plugin_manager_get_selected_plugin (pm); - - g_return_if_fail (info != NULL); - - /* if there is another about dialog already open destroy it */ - if (pm->priv->about) - gtk_widget_destroy (pm->priv->about); - - pm->priv->about = g_object_new (GTK_TYPE_ABOUT_DIALOG, - "program-name", pluma_plugin_info_get_name (info), - "copyright", pluma_plugin_info_get_copyright (info), - "authors", pluma_plugin_info_get_authors (info), - "comments", pluma_plugin_info_get_description (info), - "website", pluma_plugin_info_get_website (info), - "logo-icon-name", pluma_plugin_info_get_icon_name (info), - "version", pluma_plugin_info_get_version (info), - NULL); - - gtk_window_set_destroy_with_parent (GTK_WINDOW (pm->priv->about), - TRUE); - - g_signal_connect (pm->priv->about, - "response", - G_CALLBACK (gtk_widget_destroy), - NULL); - g_signal_connect (pm->priv->about, - "destroy", - G_CALLBACK (gtk_widget_destroyed), - &pm->priv->about); - - gtk_window_set_transient_for (GTK_WINDOW (pm->priv->about), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(pm)))); - gtk_widget_show (pm->priv->about); -} - -static void -configure_button_cb (GtkWidget *button, - PlumaPluginManager *pm) -{ - PlumaPluginInfo *info; - GtkWindow *toplevel; - - pluma_debug (DEBUG_PLUGINS); - - info = plugin_manager_get_selected_plugin (pm); - - g_return_if_fail (info != NULL); - - pluma_debug_message (DEBUG_PLUGINS, "Configuring: %s\n", - pluma_plugin_info_get_name (info)); - - toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(pm))); - - pluma_plugins_engine_configure_plugin (pm->priv->engine, - info, toplevel); - - pluma_debug_message (DEBUG_PLUGINS, "Done"); -} - -static void -plugin_manager_view_info_cell_cb (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) -{ - PlumaPluginInfo *info; - gchar *text; - - g_return_if_fail (tree_model != NULL); - g_return_if_fail (tree_column != NULL); - - gtk_tree_model_get (tree_model, iter, INFO_COLUMN, &info, -1); - - if (info == NULL) - return; - - text = g_markup_printf_escaped ("<b>%s</b>\n%s", - pluma_plugin_info_get_name (info), - pluma_plugin_info_get_description (info)); - g_object_set (G_OBJECT (cell), - "markup", text, - "sensitive", pluma_plugin_info_is_available (info), - NULL); - - g_free (text); -} - -static void -plugin_manager_view_icon_cell_cb (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) -{ - PlumaPluginInfo *info; - - g_return_if_fail (tree_model != NULL); - g_return_if_fail (tree_column != NULL); - - gtk_tree_model_get (tree_model, iter, INFO_COLUMN, &info, -1); - - if (info == NULL) - return; - - g_object_set (G_OBJECT (cell), - "icon-name", pluma_plugin_info_get_icon_name (info), - "sensitive", pluma_plugin_info_is_available (info), - NULL); -} - - -static void -active_toggled_cb (GtkCellRendererToggle *cell, - gchar *path_str, - PlumaPluginManager *pm) -{ - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeModel *model; - - pluma_debug (DEBUG_PLUGINS); - - path = gtk_tree_path_new_from_string (path_str); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)); - g_return_if_fail (model != NULL); - - gtk_tree_model_get_iter (model, &iter, path); - - if (&iter != NULL) - plugin_manager_toggle_active (pm, &iter, model); - - gtk_tree_path_free (path); -} - -static void -cursor_changed_cb (GtkTreeView *view, - gpointer data) -{ - PlumaPluginManager *pm = data; - PlumaPluginInfo *info; - - pluma_debug (DEBUG_PLUGINS); - - info = plugin_manager_get_selected_plugin (pm); - - gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->about_button), - info != NULL); - gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->configure_button), - (info != NULL) && - pluma_plugin_info_is_configurable (info)); -} - -static void -row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer data) -{ - PlumaPluginManager *pm = data; - GtkTreeIter iter; - GtkTreeModel *model; - - pluma_debug (DEBUG_PLUGINS); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)); - - g_return_if_fail (model != NULL); - - gtk_tree_model_get_iter (model, &iter, path); - - g_return_if_fail (&iter != NULL); - - plugin_manager_toggle_active (pm, &iter, model); -} - -static void -plugin_manager_populate_lists (PlumaPluginManager *pm) -{ - const GList *plugins; - GtkListStore *model; - GtkTreeIter iter; - - pluma_debug (DEBUG_PLUGINS); - - plugins = pluma_plugins_engine_get_plugin_list (pm->priv->engine); - - model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree))); - - while (plugins) - { - PlumaPluginInfo *info; - info = (PlumaPluginInfo *)plugins->data; - - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, - ACTIVE_COLUMN, pluma_plugin_info_is_active (info), - AVAILABLE_COLUMN, pluma_plugin_info_is_available (info), - INFO_COLUMN, info, - -1); - - plugins = plugins->next; - } - - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter)) - { - GtkTreeSelection *selection; - PlumaPluginInfo* info; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree)); - g_return_if_fail (selection != NULL); - - gtk_tree_selection_select_iter (selection, &iter); - - gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, - INFO_COLUMN, &info, -1); - - gtk_widget_set_sensitive (GTK_WIDGET (pm->priv->configure_button), - pluma_plugin_info_is_configurable (info)); - } -} - -static gboolean -plugin_manager_set_active (PlumaPluginManager *pm, - GtkTreeIter *iter, - GtkTreeModel *model, - gboolean active) -{ - PlumaPluginInfo *info; - gboolean res = TRUE; - - pluma_debug (DEBUG_PLUGINS); - - gtk_tree_model_get (model, iter, INFO_COLUMN, &info, -1); - - g_return_val_if_fail (info != NULL, FALSE); - - if (active) - { - /* activate the plugin */ - if (!pluma_plugins_engine_activate_plugin (pm->priv->engine, info)) { - pluma_debug_message (DEBUG_PLUGINS, "Could not activate %s.\n", - pluma_plugin_info_get_name (info)); - - res = FALSE; - } - } - else - { - /* deactivate the plugin */ - if (!pluma_plugins_engine_deactivate_plugin (pm->priv->engine, info)) { - pluma_debug_message (DEBUG_PLUGINS, "Could not deactivate %s.\n", - pluma_plugin_info_get_name (info)); - - res = FALSE; - } - } - - return res; -} - -static void -plugin_manager_toggle_active (PlumaPluginManager *pm, - GtkTreeIter *iter, - GtkTreeModel *model) -{ - gboolean active; - - pluma_debug (DEBUG_PLUGINS); - - gtk_tree_model_get (model, iter, ACTIVE_COLUMN, &active, -1); - - active ^= 1; - - plugin_manager_set_active (pm, iter, model, active); -} - -static PlumaPluginInfo * -plugin_manager_get_selected_plugin (PlumaPluginManager *pm) -{ - PlumaPluginInfo *info = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreeSelection *selection; - - pluma_debug (DEBUG_PLUGINS); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)); - g_return_val_if_fail (model != NULL, NULL); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree)); - g_return_val_if_fail (selection != NULL, NULL); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - gtk_tree_model_get (model, &iter, INFO_COLUMN, &info, -1); - } - - return info; -} - -static void -plugin_manager_set_active_all (PlumaPluginManager *pm, - gboolean active) -{ - GtkTreeModel *model; - GtkTreeIter iter; - - pluma_debug (DEBUG_PLUGINS); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)); - - g_return_if_fail (model != NULL); - - gtk_tree_model_get_iter_first (model, &iter); - - do { - plugin_manager_set_active (pm, &iter, model, active); - } - while (gtk_tree_model_iter_next (model, &iter)); -} - -/* Callback used as the interactive search comparison function */ -static gboolean -name_search_cb (GtkTreeModel *model, - gint column, - const gchar *key, - GtkTreeIter *iter, - gpointer data) -{ - PlumaPluginInfo *info; - gchar *normalized_string; - gchar *normalized_key; - gchar *case_normalized_string; - gchar *case_normalized_key; - gint key_len; - gboolean retval; - - gtk_tree_model_get (model, iter, INFO_COLUMN, &info, -1); - if (!info) - return FALSE; - - normalized_string = g_utf8_normalize (pluma_plugin_info_get_name (info), -1, G_NORMALIZE_ALL); - normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); - case_normalized_string = g_utf8_casefold (normalized_string, -1); - case_normalized_key = g_utf8_casefold (normalized_key, -1); - - key_len = strlen (case_normalized_key); - - /* Oddly enough, this callback must return whether to stop the search - * because we found a match, not whether we actually matched. - */ - retval = (strncmp (case_normalized_key, case_normalized_string, key_len) != 0); - - g_free (normalized_key); - g_free (normalized_string); - g_free (case_normalized_key); - g_free (case_normalized_string); - - return retval; -} - -static void -enable_plugin_menu_cb (GtkMenu *menu, - PlumaPluginManager *pm) -{ - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreeSelection *selection; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (pm->priv->tree)); - g_return_if_fail (model != NULL); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree)); - g_return_if_fail (selection != NULL); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - plugin_manager_toggle_active (pm, &iter, model); -} - -static void -enable_all_menu_cb (GtkMenu *menu, - PlumaPluginManager *pm) -{ - plugin_manager_set_active_all (pm, TRUE); -} - -static void -disable_all_menu_cb (GtkMenu *menu, - PlumaPluginManager *pm) -{ - plugin_manager_set_active_all (pm, FALSE); -} - -static GtkWidget * -create_tree_popup_menu (PlumaPluginManager *pm) -{ - GtkWidget *menu; - GtkWidget *item; - GtkWidget *image; - PlumaPluginInfo *info; - - info = plugin_manager_get_selected_plugin (pm); - - menu = gtk_menu_new (); - - item = gtk_image_menu_item_new_with_mnemonic (_("_About")); - image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - g_signal_connect (item, "activate", - G_CALLBACK (about_button_cb), pm); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_image_menu_item_new_with_mnemonic (_("C_onfigure")); - image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, - GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - g_signal_connect (item, "activate", - G_CALLBACK (configure_button_cb), pm); - gtk_widget_set_sensitive (item, pluma_plugin_info_is_configurable (info)); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_check_menu_item_new_with_mnemonic (_("A_ctivate")); - gtk_widget_set_sensitive (item, pluma_plugin_info_is_available (info)); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - pluma_plugin_info_is_active (info)); - g_signal_connect (item, "toggled", - G_CALLBACK (enable_plugin_menu_cb), pm); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_menu_item_new_with_mnemonic (_("Ac_tivate All")); - g_signal_connect (item, "activate", - G_CALLBACK (enable_all_menu_cb), pm); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_menu_item_new_with_mnemonic (_("_Deactivate All")); - g_signal_connect (item, "activate", - G_CALLBACK (disable_all_menu_cb), pm); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - gtk_widget_show_all (menu); - - return menu; -} - -static void -tree_popup_menu_detach (PlumaPluginManager *pm, - GtkMenu *menu) -{ - pm->priv->popup_menu = NULL; -} - -static void -show_tree_popup_menu (GtkTreeView *tree, - PlumaPluginManager *pm, - GdkEventButton *event) -{ - if (pm->priv->popup_menu) - gtk_widget_destroy (pm->priv->popup_menu); - - pm->priv->popup_menu = create_tree_popup_menu (pm); - - gtk_menu_attach_to_widget (GTK_MENU (pm->priv->popup_menu), - GTK_WIDGET (pm), - (GtkMenuDetachFunc) tree_popup_menu_detach); - - if (event != NULL) - { - gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL, - NULL, NULL, - event->button, event->time); - } - else - { - gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL, - pluma_utils_menu_position_under_tree_view, tree, - 0, gtk_get_current_event_time ()); - - gtk_menu_shell_select_first (GTK_MENU_SHELL (pm->priv->popup_menu), - FALSE); - } -} - -static gboolean -button_press_event_cb (GtkWidget *tree, - GdkEventButton *event, - PlumaPluginManager *pm) -{ - /* We want the treeview selection to be updated before showing the menu. - * This code is evil, thanks to Federico Mena Quintero's black magic. - * See: http://mail.gnome.org/archives/gtk-devel-list/2006-February/msg00168.html - * FIXME: Let's remove it asap. - */ - - static gboolean in_press = FALSE; - gboolean handled; - - if (in_press) - return FALSE; /* we re-entered */ - - if (GDK_BUTTON_PRESS != event->type || 3 != event->button) - return FALSE; /* let the normal handler run */ - - in_press = TRUE; - handled = gtk_widget_event (tree, (GdkEvent *) event); - in_press = FALSE; - - if (!handled) - return FALSE; - - /* The selection is fully updated by now */ - show_tree_popup_menu (GTK_TREE_VIEW (tree), pm, event); - return TRUE; -} - -static gboolean -popup_menu_cb (GtkTreeView *tree, - PlumaPluginManager *pm) -{ - show_tree_popup_menu (tree, pm, NULL); - return TRUE; -} - -static gint -model_name_sort_func (GtkTreeModel *model, - GtkTreeIter *iter1, - GtkTreeIter *iter2, - gpointer user_data) -{ - PlumaPluginInfo *info1, *info2; - - gtk_tree_model_get (model, iter1, INFO_COLUMN, &info1, -1); - gtk_tree_model_get (model, iter2, INFO_COLUMN, &info2, -1); - - return g_utf8_collate (pluma_plugin_info_get_name (info1), - pluma_plugin_info_get_name (info2)); -} - -static void -plugin_manager_construct_tree (PlumaPluginManager *pm) -{ - GtkTreeViewColumn *column; - GtkCellRenderer *cell; - GtkListStore *model; - - pluma_debug (DEBUG_PLUGINS); - - model = gtk_list_store_new (N_COLUMNS, - G_TYPE_BOOLEAN, - G_TYPE_BOOLEAN, - G_TYPE_POINTER); - - gtk_tree_view_set_model (GTK_TREE_VIEW (pm->priv->tree), - GTK_TREE_MODEL (model)); - g_object_unref (model); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pm->priv->tree), FALSE); - - /* first column */ - cell = gtk_cell_renderer_toggle_new (); - g_object_set (cell, "xpad", 6, NULL); - g_signal_connect (cell, - "toggled", - G_CALLBACK (active_toggled_cb), - pm); - column = gtk_tree_view_column_new_with_attributes (PLUGIN_MANAGER_ACTIVE_TITLE, - cell, - "active", - ACTIVE_COLUMN, - "activatable", - AVAILABLE_COLUMN, - "sensitive", - AVAILABLE_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column); - - /* second column */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, PLUGIN_MANAGER_NAME_TITLE); - gtk_tree_view_column_set_resizable (column, TRUE); - - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, cell, FALSE); - g_object_set (cell, "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL); - gtk_tree_view_column_set_cell_data_func (column, cell, - plugin_manager_view_icon_cell_cb, - pm, NULL); - - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, cell, TRUE); - g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - gtk_tree_view_column_set_cell_data_func (column, cell, - plugin_manager_view_info_cell_cb, - pm, NULL); - - - gtk_tree_view_column_set_spacing (column, 6); - gtk_tree_view_append_column (GTK_TREE_VIEW (pm->priv->tree), column); - - /* Sort on the plugin names */ - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model), - model_name_sort_func, - NULL, - NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), - GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, - GTK_SORT_ASCENDING); - - /* Enable search for our non-string column */ - gtk_tree_view_set_search_column (GTK_TREE_VIEW (pm->priv->tree), - INFO_COLUMN); - gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (pm->priv->tree), - name_search_cb, - NULL, - NULL); - - g_signal_connect (pm->priv->tree, - "cursor_changed", - G_CALLBACK (cursor_changed_cb), - pm); - g_signal_connect (pm->priv->tree, - "row_activated", - G_CALLBACK (row_activated_cb), - pm); - - g_signal_connect (pm->priv->tree, - "button-press-event", - G_CALLBACK (button_press_event_cb), - pm); - g_signal_connect (pm->priv->tree, - "popup-menu", - G_CALLBACK (popup_menu_cb), - pm); - gtk_widget_show (pm->priv->tree); -} - -static void -plugin_toggled_cb (PlumaPluginsEngine *engine, - PlumaPluginInfo *info, - PlumaPluginManager *pm) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean info_found = FALSE; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pm->priv->tree)); - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - /* There is an item selected: it's probably the one we want! */ - PlumaPluginInfo *tinfo; - gtk_tree_model_get (model, &iter, INFO_COLUMN, &tinfo, -1); - info_found = info == tinfo; - } - - if (!info_found) - { - gtk_tree_model_get_iter_first (model, &iter); - - do - { - PlumaPluginInfo *tinfo; - gtk_tree_model_get (model, &iter, INFO_COLUMN, &tinfo, -1); - info_found = info == tinfo; - } - while (!info_found && gtk_tree_model_iter_next (model, &iter)); - } - - if (!info_found) - { - g_warning ("PlumaPluginManager: plugin '%s' not found in the tree model", - pluma_plugin_info_get_name (info)); - return; - } - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, ACTIVE_COLUMN, pluma_plugin_info_is_active (info), -1); -} - -static void -pluma_plugin_manager_init (PlumaPluginManager *pm) -{ - GtkWidget *label; - GtkWidget *viewport; - GtkWidget *hbuttonbox; - - pluma_debug (DEBUG_PLUGINS); - - pm->priv = PLUMA_PLUGIN_MANAGER_GET_PRIVATE (pm); - - gtk_orientable_set_orientation (GTK_ORIENTABLE (pm), - GTK_ORIENTATION_VERTICAL); - - /* - * Always we create the manager, firstly we rescan the plugins directory - */ - pluma_plugins_engine_rescan_plugins (pluma_plugins_engine_get_default ()); - - gtk_box_set_spacing (GTK_BOX (pm), 6); - - label = gtk_label_new_with_mnemonic (_("Active _Plugins:")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); -#if GTK_CHECK_VERSION (3, 16, 0) - gtk_label_set_xalign (GTK_LABEL (label), 0.0); -#else - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); -#endif - - gtk_box_pack_start (GTK_BOX (pm), label, FALSE, TRUE, 0); - - viewport = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (viewport), - GTK_SHADOW_IN); - - gtk_box_pack_start (GTK_BOX (pm), viewport, TRUE, TRUE, 0); - - pm->priv->tree = gtk_tree_view_new (); - gtk_container_add (GTK_CONTAINER (viewport), pm->priv->tree); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), pm->priv->tree); - - hbuttonbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - gtk_box_pack_start (GTK_BOX (pm), hbuttonbox, FALSE, FALSE, 0); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END); - gtk_box_set_spacing (GTK_BOX (hbuttonbox), 8); - - pm->priv->about_button = pluma_gtk_button_new_with_stock_icon (_("_About Plugin"), - GTK_STOCK_ABOUT); - gtk_container_add (GTK_CONTAINER (hbuttonbox), pm->priv->about_button); - - pm->priv->configure_button = pluma_gtk_button_new_with_stock_icon (_("C_onfigure Plugin"), - GTK_STOCK_PREFERENCES); - gtk_container_add (GTK_CONTAINER (hbuttonbox), pm->priv->configure_button); - - /* setup a window of a sane size. */ - gtk_widget_set_size_request (GTK_WIDGET (viewport), 270, 100); - - g_signal_connect (pm->priv->about_button, - "clicked", - G_CALLBACK (about_button_cb), - pm); - g_signal_connect (pm->priv->configure_button, - "clicked", - G_CALLBACK (configure_button_cb), - pm); - - plugin_manager_construct_tree (pm); - - /* get the plugin engine and populate the treeview */ - pm->priv->engine = pluma_plugins_engine_get_default (); - - g_signal_connect_after (pm->priv->engine, - "activate-plugin", - G_CALLBACK (plugin_toggled_cb), - pm); - g_signal_connect_after (pm->priv->engine, - "deactivate-plugin", - G_CALLBACK (plugin_toggled_cb), - pm); - - if (pluma_plugins_engine_get_plugin_list (pm->priv->engine) != NULL) - { - plugin_manager_populate_lists (pm); - } - else - { - gtk_widget_set_sensitive (pm->priv->about_button, FALSE); - gtk_widget_set_sensitive (pm->priv->configure_button, FALSE); - } -} - -static void -pluma_plugin_manager_finalize (GObject *object) -{ - PlumaPluginManager *pm = PLUMA_PLUGIN_MANAGER (object); - - g_signal_handlers_disconnect_by_func (pm->priv->engine, - plugin_toggled_cb, - pm); - - if (pm->priv->popup_menu) - gtk_widget_destroy (pm->priv->popup_menu); - - G_OBJECT_CLASS (pluma_plugin_manager_parent_class)->finalize (object); - -} - -GtkWidget *pluma_plugin_manager_new (void) -{ - return g_object_new (PLUMA_TYPE_PLUGIN_MANAGER,0); -} diff --git a/pluma/pluma-plugin-manager.h b/pluma/pluma-plugin-manager.h deleted file mode 100644 index abdab625..00000000 --- a/pluma/pluma-plugin-manager.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * pluma-plugin-manager.h - * This file is part of pluma - * - * Copyright (C) 2002-2005 Paolo Maggi - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 2002-2005. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifndef __PLUMA_PLUGIN_MANAGER_H__ -#define __PLUMA_PLUGIN_MANAGER_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PLUMA_TYPE_PLUGIN_MANAGER (pluma_plugin_manager_get_type()) -#define PLUMA_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PLUMA_TYPE_PLUGIN_MANAGER, PlumaPluginManager)) -#define PLUMA_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PLUMA_TYPE_PLUGIN_MANAGER, PlumaPluginManagerClass)) -#define PLUMA_IS_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PLUMA_TYPE_PLUGIN_MANAGER)) -#define PLUMA_IS_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_PLUGIN_MANAGER)) -#define PLUMA_PLUGIN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_PLUGIN_MANAGER, PlumaPluginManagerClass)) - -/* Private structure type */ -typedef struct _PlumaPluginManagerPrivate PlumaPluginManagerPrivate; - -/* - * Main object structure - */ -typedef struct _PlumaPluginManager PlumaPluginManager; - -struct _PlumaPluginManager -{ - GtkBox vbox; - - /*< private > */ - PlumaPluginManagerPrivate *priv; -}; - -/* - * Class definition - */ -typedef struct _PlumaPluginManagerClass PlumaPluginManagerClass; - -struct _PlumaPluginManagerClass -{ - GtkBoxClass parent_class; -}; - -/* - * Public methods - */ -GType pluma_plugin_manager_get_type (void) G_GNUC_CONST; - -GtkWidget *pluma_plugin_manager_new (void); - -G_END_DECLS - -#endif /* __PLUMA_PLUGIN_MANAGER_H__ */ diff --git a/pluma/pluma-plugin.c b/pluma/pluma-plugin.c deleted file mode 100644 index da2689d6..00000000 --- a/pluma/pluma-plugin.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * pluma-plugin.h - * This file is part of pluma - * - * Copyright (C) 2002-2005 Paolo Maggi - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 2002-2005. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "pluma-plugin.h" -#include "pluma-dirs.h" - -/* properties */ -enum { - PROP_0, - PROP_INSTALL_DIR, - PROP_DATA_DIR_NAME, - PROP_DATA_DIR -}; - -typedef struct _PlumaPluginPrivate PlumaPluginPrivate; - -struct _PlumaPluginPrivate -{ - gchar *install_dir; - gchar *data_dir_name; -}; - -#define PLUMA_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_PLUGIN, PlumaPluginPrivate)) - -G_DEFINE_TYPE(PlumaPlugin, pluma_plugin, G_TYPE_OBJECT) - -static void -dummy (PlumaPlugin *plugin, PlumaWindow *window) -{ - /* Empty */ -} - -static GtkWidget * -create_configure_dialog (PlumaPlugin *plugin) -{ - return NULL; -} - -static gboolean -is_configurable (PlumaPlugin *plugin) -{ - return (PLUMA_PLUGIN_GET_CLASS (plugin)->create_configure_dialog != - create_configure_dialog); -} - -static void -pluma_plugin_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) - { - case PROP_INSTALL_DIR: - g_value_take_string (value, pluma_plugin_get_install_dir (PLUMA_PLUGIN (object))); - break; - case PROP_DATA_DIR: - g_value_take_string (value, pluma_plugin_get_data_dir (PLUMA_PLUGIN (object))); - break; - default: - g_return_if_reached (); - } -} - -static void -pluma_plugin_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - PlumaPluginPrivate *priv = PLUMA_PLUGIN_GET_PRIVATE (object); - - switch (prop_id) - { - case PROP_INSTALL_DIR: - priv->install_dir = g_value_dup_string (value); - break; - case PROP_DATA_DIR_NAME: - priv->data_dir_name = g_value_dup_string (value); - break; - default: - g_return_if_reached (); - } -} - -static void -pluma_plugin_finalize (GObject *object) -{ - PlumaPluginPrivate *priv = PLUMA_PLUGIN_GET_PRIVATE (object); - - g_free (priv->install_dir); - g_free (priv->data_dir_name); - - G_OBJECT_CLASS (pluma_plugin_parent_class)->finalize (object); -} - -static void -pluma_plugin_class_init (PlumaPluginClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - klass->activate = dummy; - klass->deactivate = dummy; - klass->update_ui = dummy; - - klass->create_configure_dialog = create_configure_dialog; - klass->is_configurable = is_configurable; - - object_class->get_property = pluma_plugin_get_property; - object_class->set_property = pluma_plugin_set_property; - object_class->finalize = pluma_plugin_finalize; - - g_object_class_install_property (object_class, - PROP_INSTALL_DIR, - g_param_spec_string ("install-dir", - "Install Directory", - "The directory where the plugin is installed", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - /* the basename of the data dir is set at construction time by the plugin loader - * while the full path is constructed on the fly to take into account relocability - * that's why we have a writeonly prop and a readonly prop */ - g_object_class_install_property (object_class, - PROP_DATA_DIR_NAME, - g_param_spec_string ("data-dir-name", - "Basename of the data directory", - "The basename of the directory where the plugin should look for its data files", - NULL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - PROP_DATA_DIR, - g_param_spec_string ("data-dir", - "Data Directory", - "The full path of the directory where the plugin should look for its data files", - NULL, - G_PARAM_READABLE)); - - g_type_class_add_private (klass, sizeof (PlumaPluginPrivate)); -} - -static void -pluma_plugin_init (PlumaPlugin *plugin) -{ - /* Empty */ -} - -/** - * pluma_plugin_get_install_dir: - * @plugin: a #PlumaPlugin - * - * Get the path of the directory where the plugin is installed. - * - * Return value: a newly allocated string with the path of the - * directory where the plugin is installed - */ -gchar * -pluma_plugin_get_install_dir (PlumaPlugin *plugin) -{ - g_return_val_if_fail (PLUMA_IS_PLUGIN (plugin), NULL); - - return g_strdup (PLUMA_PLUGIN_GET_PRIVATE (plugin)->install_dir); -} - -/** - * pluma_plugin_get_data_dir: - * @plugin: a #PlumaPlugin - * - * Get the path of the directory where the plugin should look for - * its data files. - * - * Return value: a newly allocated string with the path of the - * directory where the plugin should look for its data files - */ -gchar * -pluma_plugin_get_data_dir (PlumaPlugin *plugin) -{ - PlumaPluginPrivate *priv; - gchar *pluma_lib_dir; - gchar *data_dir; - - g_return_val_if_fail (PLUMA_IS_PLUGIN (plugin), NULL); - - priv = PLUMA_PLUGIN_GET_PRIVATE (plugin); - - /* If it's a "user" plugin the data dir is - * install_dir/data_dir_name if instead it's a - * "system" plugin the data dir is under pluma_data_dir, - * so it's under $prefix/share/pluma/plugins/data_dir_name - * where data_dir_name usually it's the name of the plugin - */ - pluma_lib_dir = pluma_dirs_get_pluma_lib_dir (); - - /* CHECK: is checking the prefix enough or should we be more - * careful about normalizing paths etc? */ - if (g_str_has_prefix (priv->install_dir, pluma_lib_dir)) - { - gchar *pluma_data_dir; - - pluma_data_dir = pluma_dirs_get_pluma_data_dir (); - - data_dir = g_build_filename (pluma_data_dir, - "plugins", - priv->data_dir_name, - NULL); - - g_free (pluma_data_dir); - } - else - { - data_dir = g_build_filename (priv->install_dir, - priv->data_dir_name, - NULL); - } - - g_free (pluma_lib_dir); - - return data_dir; -} - -/** - * pluma_plugin_activate: - * @plugin: a #PlumaPlugin - * @window: a #PlumaWindow - * - * Activates the plugin. - */ -void -pluma_plugin_activate (PlumaPlugin *plugin, - PlumaWindow *window) -{ - g_return_if_fail (PLUMA_IS_PLUGIN (plugin)); - g_return_if_fail (PLUMA_IS_WINDOW (window)); - - PLUMA_PLUGIN_GET_CLASS (plugin)->activate (plugin, window); -} - -/** - * pluma_plugin_deactivate: - * @plugin: a #PlumaPlugin - * @window: a #PlumaWindow - * - * Deactivates the plugin. - */ -void -pluma_plugin_deactivate (PlumaPlugin *plugin, - PlumaWindow *window) -{ - g_return_if_fail (PLUMA_IS_PLUGIN (plugin)); - g_return_if_fail (PLUMA_IS_WINDOW (window)); - - PLUMA_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window); -} - -/** - * pluma_plugin_update_ui: - * @plugin: a #PlumaPlugin - * @window: a #PlumaWindow - * - * Triggers an update of the user interface to take into account state changes - * caused by the plugin. - */ -void -pluma_plugin_update_ui (PlumaPlugin *plugin, - PlumaWindow *window) -{ - g_return_if_fail (PLUMA_IS_PLUGIN (plugin)); - g_return_if_fail (PLUMA_IS_WINDOW (window)); - - PLUMA_PLUGIN_GET_CLASS (plugin)->update_ui (plugin, window); -} - -/** - * pluma_plugin_is_configurable: - * @plugin: a #PlumaPlugin - * - * Whether the plugin is configurable. - * - * Returns: TRUE if the plugin is configurable: - */ -gboolean -pluma_plugin_is_configurable (PlumaPlugin *plugin) -{ - g_return_val_if_fail (PLUMA_IS_PLUGIN (plugin), FALSE); - - return PLUMA_PLUGIN_GET_CLASS (plugin)->is_configurable (plugin); -} - -/** - * pluma_plugin_create_configure_dialog: - * @plugin: a #PlumaPlugin - * - * Creates the configure dialog widget for the plugin. - * - * Returns: the configure dialog widget for the plugin. - */ -GtkWidget * -pluma_plugin_create_configure_dialog (PlumaPlugin *plugin) -{ - g_return_val_if_fail (PLUMA_IS_PLUGIN (plugin), NULL); - - return PLUMA_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin); -} diff --git a/pluma/pluma-plugin.h b/pluma/pluma-plugin.h deleted file mode 100644 index 39cd19d0..00000000 --- a/pluma/pluma-plugin.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * pluma-plugin.h - * This file is part of pluma - * - * Copyright (C) 2002-2005 - Paolo Maggi - * - * 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* - * Modified by the pluma Team, 2002-2005. See the AUTHORS file for a - * list of people on the pluma Team. - * See the ChangeLog files for a list of changes. - * - * $Id$ - */ - -#ifndef __PLUMA_PLUGIN_H__ -#define __PLUMA_PLUGIN_H__ - -#include <glib-object.h> - -#include <pluma/pluma-window.h> -#include <pluma/pluma-debug.h> - -/* TODO: add a .h file that includes all the .h files normally needed to - * develop a plugin */ - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PLUMA_TYPE_PLUGIN (pluma_plugin_get_type()) -#define PLUMA_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PLUMA_TYPE_PLUGIN, PlumaPlugin)) -#define PLUMA_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PLUMA_TYPE_PLUGIN, PlumaPluginClass)) -#define PLUMA_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PLUMA_TYPE_PLUGIN)) -#define PLUMA_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_PLUGIN)) -#define PLUMA_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PLUMA_TYPE_PLUGIN, PlumaPluginClass)) - -/* - * Main object structure - */ -typedef struct _PlumaPlugin PlumaPlugin; - -struct _PlumaPlugin -{ - GObject parent; -}; - -/* - * Class definition - */ -typedef struct _PlumaPluginClass PlumaPluginClass; - -struct _PlumaPluginClass -{ - GObjectClass parent_class; - - /* Virtual public methods */ - - void (*activate) (PlumaPlugin *plugin, - PlumaWindow *window); - void (*deactivate) (PlumaPlugin *plugin, - PlumaWindow *window); - - void (*update_ui) (PlumaPlugin *plugin, - PlumaWindow *window); - - GtkWidget *(*create_configure_dialog) - (PlumaPlugin *plugin); - - /* Plugins should not override this, it's handled automatically by - the PlumaPluginClass */ - gboolean (*is_configurable) - (PlumaPlugin *plugin); - - /* Padding for future expansion */ - void (*_pluma_reserved1) (void); - void (*_pluma_reserved2) (void); - void (*_pluma_reserved3) (void); - void (*_pluma_reserved4) (void); -}; - -/* - * Public methods - */ -GType pluma_plugin_get_type (void) G_GNUC_CONST; - -gchar *pluma_plugin_get_install_dir (PlumaPlugin *plugin); -gchar *pluma_plugin_get_data_dir (PlumaPlugin *plugin); - -void pluma_plugin_activate (PlumaPlugin *plugin, - PlumaWindow *window); -void pluma_plugin_deactivate (PlumaPlugin *plugin, - PlumaWindow *window); - -void pluma_plugin_update_ui (PlumaPlugin *plugin, - PlumaWindow *window); - -gboolean pluma_plugin_is_configurable (PlumaPlugin *plugin); -GtkWidget *pluma_plugin_create_configure_dialog - (PlumaPlugin *plugin); - -/** - * PLUMA_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE): - * - * Utility macro used to register plugins with additional code. - */ -#define PLUMA_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE) \ - G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginName, \ - plugin_name, \ - PLUMA_TYPE_PLUGIN, \ - 0, \ - GTypeModule *module G_GNUC_UNUSED = type_module; /* back compat */ \ - CODE) \ - \ -/* This is not very nice, but G_DEFINE_DYNAMIC wants it and our old macro \ - * did not support it */ \ -static void \ -plugin_name##_class_finalize (PluginName##Class *klass) \ -{ \ -} \ - \ - \ -G_MODULE_EXPORT GType \ -register_pluma_plugin (GTypeModule *type_module) \ -{ \ - plugin_name##_register_type (type_module); \ - \ - return plugin_name##_get_type(); \ -} - -/** - * PLUMA_PLUGIN_REGISTER_TYPE(PluginName, plugin_name): - * - * Utility macro used to register plugins. - */ -#define PLUMA_PLUGIN_REGISTER_TYPE(PluginName, plugin_name) \ - PLUMA_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, ;) - -/** - * PLUMA_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE): - * - * Utility macro used to register gobject types in plugins with additional code. - * - * Deprecated: use G_DEFINE_DYNAMIC_TYPE_EXTENDED instead - */ -#define PLUMA_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, CODE) \ - \ -static GType g_define_type_id = 0; \ - \ -GType \ -object_name##_get_type (void) \ -{ \ - return g_define_type_id; \ -} \ - \ -static void object_name##_init (ObjectName *self); \ -static void object_name##_class_init (ObjectName##Class *klass); \ -static gpointer object_name##_parent_class = NULL; \ -static void object_name##_class_intern_init (gpointer klass) \ -{ \ - object_name##_parent_class = g_type_class_peek_parent (klass); \ - object_name##_class_init ((ObjectName##Class *) klass); \ -} \ - \ -GType \ -object_name##_register_type (GTypeModule *type_module) \ -{ \ - GTypeModule *module G_GNUC_UNUSED = type_module; /* back compat */ \ - static const GTypeInfo our_info = \ - { \ - sizeof (ObjectName##Class), \ - NULL, /* base_init */ \ - NULL, /* base_finalize */ \ - (GClassInitFunc) object_name##_class_intern_init, \ - NULL, \ - NULL, /* class_data */ \ - sizeof (ObjectName), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc) object_name##_init \ - }; \ - \ - g_define_type_id = g_type_module_register_type (type_module, \ - PARENT_TYPE, \ - #ObjectName, \ - &our_info, \ - 0); \ - \ - CODE \ - \ - return g_define_type_id; \ -} - - -/** - * PLUMA_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE): - * - * Utility macro used to register gobject types in plugins. - * - * Deprecated: use G_DEFINE_DYNAMIC instead - */ -#define PLUMA_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE) \ - PLUMA_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;) - -/** - * PLUMA_PLUGIN_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init): - * - * Utility macro used to register interfaces for gobject types in plugins. - */ -#define PLUMA_PLUGIN_IMPLEMENT_INTERFACE(object_name, TYPE_IFACE, iface_init) \ - const GInterfaceInfo object_name##_interface_info = \ - { \ - (GInterfaceInitFunc) iface_init, \ - NULL, \ - NULL \ - }; \ - \ - g_type_module_add_interface (type_module, \ - g_define_type_id, \ - TYPE_IFACE, \ - &object_name##_interface_info); - -G_END_DECLS - -#endif /* __PLUMA_PLUGIN_H__ */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 309f7bd1..906e0515 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -29,7 +29,6 @@ pluma/pluma-help.c pluma/pluma-io-error-message-area.c pluma/pluma-notebook.c pluma/pluma-panel.c -pluma/pluma-plugin-manager.c pluma/pluma-plugins-engine.c pluma/pluma-prefs-manager.c pluma/pluma-print-job.c |