Remove old plugin system and docs for it

Adapted from:
3860e7b99f (diff-c949f93d03f44a4217d7a138f9e2e54a)
This commit is contained in:
JosephMcc 2016-12-26 18:49:12 -08:00
parent 89758101cc
commit f314622cf0
25 changed files with 3 additions and 3057 deletions

View File

@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = xed pixmaps po data plugin-loaders plugins docs help SUBDIRS = xed pixmaps po data plugins docs help
if ENABLE_TESTS if ENABLE_TESTS
SUBDIRS += tests SUBDIRS += tests

View File

@ -221,10 +221,8 @@ AC_ARG_ENABLE([tests],
AM_CONDITIONAL(ENABLE_TESTS, test x$enable_tests = xyes) AM_CONDITIONAL(ENABLE_TESTS, test x$enable_tests = xyes)
PLUGIN_LIBTOOL_FLAGS="-module -avoid-version" PLUGIN_LIBTOOL_FLAGS="-module -avoid-version"
LOADER_LIBTOOL_FLAGS="-module -avoid-version"
AC_SUBST(PLUGIN_LIBTOOL_FLAGS) AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
AC_SUBST(LOADER_LIBTOOL_FLAGS)
XED_PLUGINS_DATA_DIR="$datadir/xed/plugins" XED_PLUGINS_DATA_DIR="$datadir/xed/plugins"
AC_SUBST(XED_PLUGINS_DATA_DIR) AC_SUBST(XED_PLUGINS_DATA_DIR)
@ -248,8 +246,6 @@ xed/smclient/Makefile
xed/Makefile xed/Makefile
help/Makefile help/Makefile
pixmaps/Makefile pixmaps/Makefile
plugin-loaders/Makefile
plugin-loaders/c/Makefile
plugins/Makefile plugins/Makefile
plugins/changecase/Makefile plugins/changecase/Makefile
plugins/docinfo/Makefile plugins/docinfo/Makefile

1
debian/control vendored
View File

@ -13,6 +13,7 @@ Build-Depends: autotools-dev,
libglib2.0-dev, libglib2.0-dev,
libgtk-3-dev, libgtk-3-dev,
libgtksourceview-3.0-dev, libgtksourceview-3.0-dev,
libpeas-dev,
libsm-dev, libsm-dev,
libx11-dev, libx11-dev,
libxml2-dev, libxml2-dev,

1
debian/rules vendored
View File

@ -6,7 +6,6 @@ DHFLAGS=--parallel
dh $@ $(DHFLAGS) dh $@ $(DHFLAGS)
override_dh_install: override_dh_install:
rm -rfv debian/tmp/usr/lib/*/xed/plugin-loaders/*.la
rm -rfv debian/tmp/usr/lib/*/xed/plugins/*.la rm -rfv debian/tmp/usr/lib/*/xed/plugins/*.la
dh_install --fail-missing dh_install --fail-missing

1
debian/xed.install vendored
View File

@ -1,5 +1,4 @@
usr/bin/ usr/bin/
usr/lib/*/xed/plugin-loaders/*.so
usr/lib/*/xed/plugins/ usr/lib/*/xed/plugins/
usr/lib/xed/xed-bugreport.sh usr/lib/xed/xed-bugreport.sh
usr/share/applications/ usr/share/applications/

View File

@ -46,8 +46,6 @@ IGNORE_HFILES= \
xed-documents-panel.h \ xed-documents-panel.h \
xed-io-error-message-area.h \ xed-io-error-message-area.h \
xed-languages-manager.h \ xed-languages-manager.h \
xed-object-module.h \
xed-plugin-manager.h \
xed-plugins-engine.h \ xed-plugins-engine.h \
xed-prefs-manager-private.h \ xed-prefs-manager-private.h \
xed-session.h \ xed-session.h \

View File

@ -17,7 +17,6 @@
<xi:include href="xml/xed-message.xml"/> <xi:include href="xml/xed-message.xml"/>
<xi:include href="xml/xed-notebook.xml"/> <xi:include href="xml/xed-notebook.xml"/>
<xi:include href="xml/xed-panel.xml"/> <xi:include href="xml/xed-panel.xml"/>
<xi:include href="xml/xed-plugin.xml"/>
<xi:include href="xml/xed-print-job-preview.xml"/> <xi:include href="xml/xed-print-job-preview.xml"/>
<xi:include href="xml/xed-print.xml"/> <xi:include href="xml/xed-print.xml"/>
<xi:include href="xml/xed-progress-message-area.xml"/> <xi:include href="xml/xed-progress-message-area.xml"/>

View File

@ -236,30 +236,6 @@ XED_IS_PANEL_CLASS
XED_PANEL_GET_CLASS XED_PANEL_GET_CLASS
</SECTION> </SECTION>
<SECTION>
<FILE>xed-plugin</FILE>
<TITLE>XedPlugin</TITLE>
XedPlugin
xed_plugin_activate
xed_plugin_deactivate
xed_plugin_update_ui
xed_plugin_is_configurable
xed_plugin_create_configure_dialog
XED_PLUGIN_REGISTER_TYPE
<SUBSECTION Standard>
XED_PLUGIN
XED_IS_PLUGIN
XED_TYPE_PLUGIN
xed_plugin_get_type
XED_PLUGIN_CLASS
XED_IS_PLUGIN_CLASS
XED_PLUGIN_GET_CLASS
XED_PLUGIN_REGISTER_TYPE_WITH_CODE
XED_PLUGIN_REGISTER_TYPE
XED_PLUGIN_DEFINE_TYPE_WITH_CODE
XED_PLUGIN_DEFINE_TYPE
</SECTION>
<SECTION> <SECTION>
<FILE>xed-print-job-preview</FILE> <FILE>xed-print-job-preview</FILE>
XedPrintJobPreviewPrivate XedPrintJobPreviewPrivate

View File

@ -8,7 +8,6 @@
#include "xed-message-type.h" #include "xed-message-type.h"
#include "xed-notebook.h" #include "xed-notebook.h"
#include "xed-panel.h" #include "xed-panel.h"
#include "xed-plugin.h"
#include "xed-progress-message-area.h" #include "xed-progress-message-area.h"
#include "xed-statusbar.h" #include "xed-statusbar.h"
#include "xed-tab.h" #include "xed-tab.h"
@ -24,7 +23,6 @@ xed_message_bus_get_type
xed_message_type_get_type xed_message_type_get_type
xed_notebook_get_type xed_notebook_get_type
xed_panel_get_type xed_panel_get_type
xed_plugin_get_type
xed_progress_message_area_get_type xed_progress_message_area_get_type
xed_statusbar_get_type xed_statusbar_get_type
xed_tab_get_type xed_tab_get_type

View File

@ -1,3 +0,0 @@
SUBDIRS = c
-include $(top_srcdir)/git.mk

View File

@ -1,24 +0,0 @@
# C plugin loader
loaderdir = $(libdir)/xed/plugin-loaders
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(XED_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
-DXED_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
loader_LTLIBRARIES = libcloader.la
NOINST_H_FILES = \
xed-plugin-loader-c.h
libcloader_la_SOURCES = \
xed-plugin-loader-c.c \
$(NOINST_H_FILES)
libcloader_la_LDFLAGS = $(LOADER_LIBTOOL_FLAGS)
libcloader_la_LIBADD = $(XED_LIBS)
-include $(top_srcdir)/git.mk

View File

@ -1,182 +0,0 @@
/*
* xed-plugin-loader-c.c
* This file is part of xed
*
* 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 "xed-plugin-loader-c.h"
#include <xed/xed-object-module.h>
#define XED_PLUGIN_LOADER_C_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), XED_TYPE_PLUGIN_LOADER_C, XedPluginLoaderCPrivate))
struct _XedPluginLoaderCPrivate
{
GHashTable *loaded_plugins;
};
static void xed_plugin_loader_iface_init (gpointer g_iface, gpointer iface_data);
XED_PLUGIN_LOADER_REGISTER_TYPE (XedPluginLoaderC, xed_plugin_loader_c, G_TYPE_OBJECT, xed_plugin_loader_iface_init);
static const gchar *
xed_plugin_loader_iface_get_id (void)
{
return "C";
}
static XedPlugin *
xed_plugin_loader_iface_load (XedPluginLoader *loader,
XedPluginInfo *info,
const gchar *path)
{
XedPluginLoaderC *cloader = XED_PLUGIN_LOADER_C (loader);
XedObjectModule *module;
const gchar *module_name;
XedPlugin *result;
module = (XedObjectModule *)g_hash_table_lookup (cloader->priv->loaded_plugins, info);
module_name = xed_plugin_info_get_module_name (info);
if (module == NULL)
{
/* For now we force all modules to be resident */
module = xed_object_module_new (module_name,
path,
"register_xed_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", xed_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 = (XedPlugin *)xed_object_module_new_object (module,
"install-dir", path,
"data-dir-name", module_name,
NULL);
if (!result)
{
g_warning ("Could not create plugin object: %s", xed_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
xed_plugin_loader_iface_unload (XedPluginLoader *loader,
XedPluginInfo *info)
{
//XedPluginLoaderC *cloader = XED_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
xed_plugin_loader_iface_init (gpointer g_iface,
gpointer iface_data)
{
XedPluginLoaderInterface *iface = (XedPluginLoaderInterface *)g_iface;
iface->get_id = xed_plugin_loader_iface_get_id;
iface->load = xed_plugin_loader_iface_load;
iface->unload = xed_plugin_loader_iface_unload;
}
static void
xed_plugin_loader_c_finalize (GObject *object)
{
XedPluginLoaderC *cloader = XED_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)
{
XedPluginInfo *info = (XedPluginInfo *)item->data;
if (xed_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 (xed_plugin_loader_c_parent_class)->finalize (object);
}
static void
xed_plugin_loader_c_class_init (XedPluginLoaderCClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = xed_plugin_loader_c_finalize;
g_type_class_add_private (object_class, sizeof (XedPluginLoaderCPrivate));
}
static void
xed_plugin_loader_c_class_finalize (XedPluginLoaderCClass *klass)
{
}
static void
xed_plugin_loader_c_init (XedPluginLoaderC *self)
{
self->priv = XED_PLUGIN_LOADER_C_GET_PRIVATE (self);
/* loaded_plugins maps XedPluginInfo to a XedObjectModule */
self->priv->loaded_plugins = g_hash_table_new (g_direct_hash,
g_direct_equal);
}
XedPluginLoaderC *
xed_plugin_loader_c_new ()
{
GObject *loader = g_object_new (XED_TYPE_PLUGIN_LOADER_C, NULL);
return XED_PLUGIN_LOADER_C (loader);
}

View File

@ -1,60 +0,0 @@
/*
* xed-plugin-loader-c.h
* This file is part of xed
*
* 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 __XED_PLUGIN_LOADER_C_H__
#define __XED_PLUGIN_LOADER_C_H__
#include <xed/xed-plugin-loader.h>
G_BEGIN_DECLS
#define XED_TYPE_PLUGIN_LOADER_C (xed_plugin_loader_c_get_type ())
#define XED_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_PLUGIN_LOADER_C, XedPluginLoaderC))
#define XED_PLUGIN_LOADER_C_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_PLUGIN_LOADER_C, XedPluginLoaderC const))
#define XED_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_PLUGIN_LOADER_C, XedPluginLoaderCClass))
#define XED_IS_PLUGIN_LOADER_C(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_PLUGIN_LOADER_C))
#define XED_IS_PLUGIN_LOADER_C_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PLUGIN_LOADER_C))
#define XED_PLUGIN_LOADER_C_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_PLUGIN_LOADER_C, XedPluginLoaderCClass))
typedef struct _XedPluginLoaderC XedPluginLoaderC;
typedef struct _XedPluginLoaderCClass XedPluginLoaderCClass;
typedef struct _XedPluginLoaderCPrivate XedPluginLoaderCPrivate;
struct _XedPluginLoaderC {
GObject parent;
XedPluginLoaderCPrivate *priv;
};
struct _XedPluginLoaderCClass {
GObjectClass parent_class;
};
GType xed_plugin_loader_c_get_type (void) G_GNUC_CONST;
XedPluginLoaderC *xed_plugin_loader_c_new(void);
/* All the loaders must implement this function */
G_MODULE_EXPORT GType register_xed_plugin_loader (GTypeModule * module);
G_END_DECLS
#endif /* __XED_PLUGIN_LOADER_C_H__ */

View File

@ -27,7 +27,6 @@ xed/xed-help.c
xed/xed-io-error-message-area.c xed/xed-io-error-message-area.c
xed/xed-notebook.c xed/xed-notebook.c
xed/xed-panel.c xed/xed-panel.c
xed/xed-plugin-manager.c
xed/xed-plugins-engine.c xed/xed-plugins-engine.c
xed/xed-prefs-manager.c xed/xed-prefs-manager.c
xed/xed-print-job.c xed/xed-print-job.c

View File

@ -1,343 +0,0 @@
/*
* xed-object-module.c
* This file is part of xed
*
* 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 xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id: xed-module.c 6314 2008-06-05 12:57:53Z pborelli $
*/
#include "config.h"
#include "xed-object-module.h"
#include "xed-debug.h"
typedef GType (*XedObjectModuleRegisterFunc) (GTypeModule *);
enum {
PROP_0,
PROP_MODULE_NAME,
PROP_PATH,
PROP_TYPE_REGISTRATION,
PROP_RESIDENT
};
struct _XedObjectModulePrivate
{
GModule *library;
GType type;
gchar *path;
gchar *module_name;
gchar *type_registration;
gboolean resident;
};
G_DEFINE_TYPE (XedObjectModule, xed_object_module, G_TYPE_TYPE_MODULE);
static gboolean
xed_object_module_load (GTypeModule *gmodule)
{
XedObjectModule *module = XED_OBJECT_MODULE (gmodule);
XedObjectModuleRegisterFunc register_func;
gchar *path;
xed_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);
xed_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 *) &register_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
xed_object_module_unload (GTypeModule *gmodule)
{
XedObjectModule *module = XED_OBJECT_MODULE (gmodule);
xed_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
xed_object_module_init (XedObjectModule *module)
{
xed_debug_message (DEBUG_PLUGINS, "XedObjectModule %p initialising", module);
module->priv = G_TYPE_INSTANCE_GET_PRIVATE (module,
XED_TYPE_OBJECT_MODULE,
XedObjectModulePrivate);
}
static void
xed_object_module_finalize (GObject *object)
{
XedObjectModule *module = XED_OBJECT_MODULE (object);
xed_debug_message (DEBUG_PLUGINS, "XedObjectModule %p finalising", module);
g_free (module->priv->path);
g_free (module->priv->module_name);
g_free (module->priv->type_registration);
G_OBJECT_CLASS (xed_object_module_parent_class)->finalize (object);
}
static void
xed_object_module_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
XedObjectModule *module = XED_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
xed_object_module_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
XedObjectModule *module = XED_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
xed_object_module_class_init (XedObjectModuleClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
object_class->set_property = xed_object_module_set_property;
object_class->get_property = xed_object_module_get_property;
object_class->finalize = xed_object_module_finalize;
module_class->load = xed_object_module_load;
module_class->unload = xed_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 (XedObjectModulePrivate));
}
XedObjectModule *
xed_object_module_new (const gchar *module_name,
const gchar *path,
const gchar *type_registration,
gboolean resident)
{
return (XedObjectModule *)g_object_new (XED_TYPE_OBJECT_MODULE,
"module-name",
module_name,
"path",
path,
"type-registration",
type_registration,
"resident",
resident,
NULL);
}
GObject *
xed_object_module_new_object (XedObjectModule *module,
const gchar *first_property_name,
...)
{
va_list var_args;
GObject *result;
g_return_val_if_fail (module->priv->type != 0, NULL);
xed_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 *
xed_object_module_get_path (XedObjectModule *module)
{
g_return_val_if_fail (XED_IS_OBJECT_MODULE (module), NULL);
return module->priv->path;
}
const gchar *
xed_object_module_get_module_name (XedObjectModule *module)
{
g_return_val_if_fail (XED_IS_OBJECT_MODULE (module), NULL);
return module->priv->module_name;
}
const gchar *
xed_object_module_get_type_registration (XedObjectModule *module)
{
g_return_val_if_fail (XED_IS_OBJECT_MODULE (module), NULL);
return module->priv->type_registration;
}
GType
xed_object_module_get_object_type (XedObjectModule *module)
{
g_return_val_if_fail (XED_IS_OBJECT_MODULE (module), 0);
return module->priv->type;
}

View File

@ -1,94 +0,0 @@
/*
* xed-object-module.h
* This file is part of xed
*
* 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 xed-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 xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id: xed-module.h 6263 2008-05-05 10:52:10Z sfre $
*/
#ifndef __XED_OBJECT_MODULE_H__
#define __XED_OBJECT_MODULE_H__
#include <glib-object.h>
#include <gmodule.h>
#include <stdarg.h>
G_BEGIN_DECLS
#define XED_TYPE_OBJECT_MODULE (xed_object_module_get_type ())
#define XED_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_OBJECT_MODULE, XedObjectModule))
#define XED_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_OBJECT_MODULE, XedObjectModuleClass))
#define XED_IS_OBJECT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_OBJECT_MODULE))
#define XED_IS_OBJECT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_OBJECT_MODULE))
#define XED_OBJECT_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_OBJECT_MODULE, XedObjectModuleClass))
typedef struct _XedObjectModule XedObjectModule;
typedef struct _XedObjectModulePrivate XedObjectModulePrivate;
struct _XedObjectModule
{
GTypeModule parent;
XedObjectModulePrivate *priv;
};
typedef struct _XedObjectModuleClass XedObjectModuleClass;
struct _XedObjectModuleClass
{
GTypeModuleClass parent_class;
/* Virtual class methods */
void (* garbage_collect) ();
};
GType xed_object_module_get_type (void) G_GNUC_CONST;
XedObjectModule *xed_object_module_new (const gchar *module_name,
const gchar *path,
const gchar *type_registration,
gboolean resident);
GObject *xed_object_module_new_object (XedObjectModule *module,
const gchar *first_property_name,
...);
GType xed_object_module_get_object_type (XedObjectModule *module);
const gchar *xed_object_module_get_path (XedObjectModule *module);
const gchar *xed_object_module_get_module_name (XedObjectModule *module);
const gchar *xed_object_module_get_type_registration (XedObjectModule *module);
G_END_DECLS
#endif

View File

@ -1,67 +0,0 @@
/*
* xed-plugin-info-priv.h
* This file is part of xed
*
* 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 xed Team, 2002-2007. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_PLUGIN_INFO_PRIV_H__
#define __XED_PLUGIN_INFO_PRIV_H__
#include "xed-plugin-info.h"
#include "xed-plugin.h"
struct _XedPluginInfo
{
gint refcount;
XedPlugin *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;
};
XedPluginInfo *_xed_plugin_info_new (const gchar *file);
void _xed_plugin_info_ref (XedPluginInfo *info);
void _xed_plugin_info_unref (XedPluginInfo *info);
#endif /* __XED_PLUGIN_INFO_PRIV_H__ */

View File

@ -1,396 +0,0 @@
/*
* xed-plugin-info.c
* This file is part of xed
*
* 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 xed Team, 2002-2007. See the AUTHORS file for a
* list of people on the xed 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 "xed-plugin-info.h"
#include "xed-plugin-info-priv.h"
#include "xed-debug.h"
#include "xed-plugin.h"
void
_xed_plugin_info_ref (XedPluginInfo *info)
{
g_atomic_int_inc (&info->refcount);
}
static XedPluginInfo *
xed_plugin_info_copy (XedPluginInfo *info)
{
_xed_plugin_info_ref (info);
return info;
}
void
_xed_plugin_info_unref (XedPluginInfo *info)
{
if (!g_atomic_int_dec_and_test (&info->refcount))
return;
if (info->plugin != NULL)
{
xed_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);
}
/**
* xed_plugin_info_get_type:
*
* Retrieves the #GType object which is associated with the #XedPluginInfo
* class.
*
* Return value: the GType associated with #XedPluginInfo.
**/
GType
xed_plugin_info_get_type (void)
{
static GType the_type = 0;
if (G_UNLIKELY (!the_type))
the_type = g_boxed_type_register_static (
"XedPluginInfo",
(GBoxedCopyFunc) xed_plugin_info_copy,
(GBoxedFreeFunc) _xed_plugin_info_unref);
return the_type;
}
/**
* xed_plugin_info_new:
* @filename: the filename where to read the plugin information
*
* Creates a new #XedPluginInfo from a file on the disk.
*
* Return value: a newly created #XedPluginInfo.
*/
XedPluginInfo *
_xed_plugin_info_new (const gchar *file)
{
XedPluginInfo *info;
GKeyFile *plugin_file = NULL;
gchar *str;
g_return_val_if_fail (file != NULL, NULL);
xed_debug_message (DEBUG_PLUGINS, "Loading plugin: %s", file);
info = g_new0 (XedPluginInfo, 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,
"Xed Plugin",
"IAge",
NULL))
{
xed_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,
"Xed Plugin",
"IAge",
NULL) != 2)
{
xed_debug_message (DEBUG_PLUGINS,
"Wrong IAge in file: %s", file);
goto error;
}
/* Get module name */
str = g_key_file_get_string (plugin_file,
"Xed 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,
"Xed Plugin",
"Depends",
NULL,
NULL);
if (info->dependencies == NULL)
{
xed_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,
"Xed 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,
"Xed 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,
"Xed Plugin",
"Description",
NULL, NULL);
if (str)
info->desc = str;
else
xed_debug_message (DEBUG_PLUGINS, "Could not find 'Description' in %s", file);
/* Get Icon */
str = g_key_file_get_locale_string (plugin_file,
"Xed Plugin",
"Icon",
NULL, NULL);
if (str)
info->icon_name = str;
else
xed_debug_message (DEBUG_PLUGINS, "Could not find 'Icon' in %s, using 'xed-plugin'", file);
/* Get Authors */
info->authors = g_key_file_get_string_list (plugin_file,
"Xed Plugin",
"Authors",
NULL,
NULL);
if (info->authors == NULL)
xed_debug_message (DEBUG_PLUGINS, "Could not find 'Authors' in %s", file);
/* Get Copyright */
str = g_key_file_get_string (plugin_file,
"Xed Plugin",
"Copyright",
NULL);
if (str)
info->copyright = str;
else
xed_debug_message (DEBUG_PLUGINS, "Could not find 'Copyright' in %s", file);
/* Get Website */
str = g_key_file_get_string (plugin_file,
"Xed Plugin",
"Website",
NULL);
if (str)
info->website = str;
else
xed_debug_message (DEBUG_PLUGINS, "Could not find 'Website' in %s", file);
/* Get Version */
str = g_key_file_get_string (plugin_file,
"Xed Plugin",
"Version",
NULL);
if (str)
info->version = str;
else
xed_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
xed_plugin_info_is_active (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, FALSE);
return info->available && info->plugin != NULL;
}
gboolean
xed_plugin_info_is_available (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, FALSE);
return info->available != FALSE;
}
gboolean
xed_plugin_info_is_configurable (XedPluginInfo *info)
{
xed_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 xed_plugin_is_configurable (info->plugin);
}
const gchar *
xed_plugin_info_get_module_name (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->module_name;
}
const gchar *
xed_plugin_info_get_name (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->name;
}
const gchar *
xed_plugin_info_get_description (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->desc;
}
const gchar *
xed_plugin_info_get_icon_name (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
/* use the xed-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 "xed-plugin";
}
const gchar **
xed_plugin_info_get_authors (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, (const gchar **)NULL);
return (const gchar **) info->authors;
}
const gchar *
xed_plugin_info_get_website (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->website;
}
const gchar *
xed_plugin_info_get_copyright (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->copyright;
}
const gchar *
xed_plugin_info_get_version (XedPluginInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->version;
}

View File

@ -1,63 +0,0 @@
/*
* xed-plugin-info.h
* This file is part of xed
*
* 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 xed Team, 2002-2007. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_PLUGIN_INFO_H__
#define __XED_PLUGIN_INFO_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define XED_TYPE_PLUGIN_INFO (xed_plugin_info_get_type ())
#define XED_PLUGIN_INFO(obj) ((XedPluginInfo *) (obj))
typedef struct _XedPluginInfo XedPluginInfo;
GType xed_plugin_info_get_type (void) G_GNUC_CONST;
gboolean xed_plugin_info_is_active (XedPluginInfo *info);
gboolean xed_plugin_info_is_available (XedPluginInfo *info);
gboolean xed_plugin_info_is_configurable (XedPluginInfo *info);
const gchar *xed_plugin_info_get_module_name (XedPluginInfo *info);
const gchar *xed_plugin_info_get_name (XedPluginInfo *info);
const gchar *xed_plugin_info_get_description (XedPluginInfo *info);
const gchar *xed_plugin_info_get_icon_name (XedPluginInfo *info);
const gchar **xed_plugin_info_get_authors (XedPluginInfo *info);
const gchar *xed_plugin_info_get_website (XedPluginInfo *info);
const gchar *xed_plugin_info_get_copyright (XedPluginInfo *info);
const gchar *xed_plugin_info_get_version (XedPluginInfo *info);
G_END_DECLS
#endif /* __XED_PLUGIN_INFO_H__ */

View File

@ -1,131 +0,0 @@
/*
* xed-plugin-loader.c
* This file is part of xed
*
* 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 "xed-plugin-loader.h"
static void
xed_plugin_loader_base_init (gpointer g_class)
{
static gboolean initialized = FALSE;
if (G_UNLIKELY (!initialized))
{
/* create interface signals here. */
initialized = TRUE;
}
}
GType
xed_plugin_loader_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0))
{
static const GTypeInfo info =
{
sizeof (XedPluginLoaderInterface),
xed_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, "XedPluginLoader", &info, 0);
}
return type;
}
const gchar *
xed_plugin_loader_type_get_id (GType type)
{
GTypeClass *klass;
XedPluginLoaderInterface *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, XED_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 ();
}
XedPlugin *
xed_plugin_loader_load (XedPluginLoader *loader,
XedPluginInfo *info,
const gchar *path)
{
XedPluginLoaderInterface *iface;
g_return_val_if_fail (XED_IS_PLUGIN_LOADER (loader), NULL);
iface = XED_PLUGIN_LOADER_GET_INTERFACE (loader);
g_return_val_if_fail (iface->load != NULL, NULL);
return iface->load (loader, info, path);
}
void
xed_plugin_loader_unload (XedPluginLoader *loader,
XedPluginInfo *info)
{
XedPluginLoaderInterface *iface;
g_return_if_fail (XED_IS_PLUGIN_LOADER (loader));
iface = XED_PLUGIN_LOADER_GET_INTERFACE (loader);
g_return_if_fail (iface->unload != NULL);
iface->unload (loader, info);
}
void
xed_plugin_loader_garbage_collect (XedPluginLoader *loader)
{
XedPluginLoaderInterface *iface;
g_return_if_fail (XED_IS_PLUGIN_LOADER (loader));
iface = XED_PLUGIN_LOADER_GET_INTERFACE (loader);
if (iface->garbage_collect != NULL)
iface->garbage_collect (loader);
}

View File

@ -1,106 +0,0 @@
/*
* xed-plugin-loader.h
* This file is part of xed
*
* 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 __XED_PLUGIN_LOADER_H__
#define __XED_PLUGIN_LOADER_H__
#include <glib-object.h>
#include <xed/xed-plugin.h>
#include <xed/xed-plugin-info.h>
G_BEGIN_DECLS
#define XED_TYPE_PLUGIN_LOADER (xed_plugin_loader_get_type ())
#define XED_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_PLUGIN_LOADER, XedPluginLoader))
#define XED_IS_PLUGIN_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_PLUGIN_LOADER))
#define XED_PLUGIN_LOADER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), XED_TYPE_PLUGIN_LOADER, XedPluginLoaderInterface))
typedef struct _XedPluginLoader XedPluginLoader; /* dummy object */
typedef struct _XedPluginLoaderInterface XedPluginLoaderInterface;
struct _XedPluginLoaderInterface {
GTypeInterface parent;
const gchar *(*get_id) (void);
XedPlugin *(*load) (XedPluginLoader *loader,
XedPluginInfo *info,
const gchar *path);
void (*unload) (XedPluginLoader *loader,
XedPluginInfo *info);
void (*garbage_collect) (XedPluginLoader *loader);
};
GType xed_plugin_loader_get_type (void);
const gchar *xed_plugin_loader_type_get_id (GType type);
XedPlugin *xed_plugin_loader_load (XedPluginLoader *loader,
XedPluginInfo *info,
const gchar *path);
void xed_plugin_loader_unload (XedPluginLoader *loader,
XedPluginInfo *info);
void xed_plugin_loader_garbage_collect (XedPluginLoader *loader);
/**
* XED_PLUGIN_LOADER_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
*
* Utility macro used to register interfaces for gobject types in plugin loaders.
*/
#define XED_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);
/**
* XED_PLUGIN_LOADER_REGISTER_TYPE(PluginLoaderName, plugin_loader_name, PARENT_TYPE, loader_interface_init):
*
* Utility macro used to register plugin loaders.
*/
#define XED_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, \
XED_PLUGIN_LOADER_IMPLEMENT_INTERFACE(XED_TYPE_PLUGIN_LOADER, loader_iface_init)); \
\
\
G_MODULE_EXPORT GType \
register_xed_plugin_loader (GTypeModule *type_module) \
{ \
plugin_loader_name##_register_type (type_module); \
\
return plugin_loader_name##_get_type(); \
}
G_END_DECLS
#endif /* __XED_PLUGIN_LOADER_H__ */

View File

@ -1,893 +0,0 @@
/*
* xed-plugin-manager.c
* This file is part of xed
*
* 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 xed Team, 1998-2006. See the AUTHORS file for a
* list of people on the xed 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 "xed-plugin-manager.h"
#include "xed-utils.h"
#include "xed-plugins-engine.h"
#include "xed-plugin.h"
#include "xed-debug.h"
enum
{
ACTIVE_COLUMN,
AVAILABLE_COLUMN,
INFO_COLUMN,
N_COLUMNS
};
#define PLUGIN_MANAGER_NAME_TITLE _("Plugin")
#define PLUGIN_MANAGER_ACTIVE_TITLE _("Enabled")
#define XED_PLUGIN_MANAGER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_PLUGIN_MANAGER, XedPluginManagerPrivate))
struct _XedPluginManagerPrivate
{
GtkWidget *tree;
GtkWidget *about_button;
GtkWidget *configure_button;
XedPluginsEngine *engine;
GtkWidget *about;
GtkWidget *popup_menu;
};
G_DEFINE_TYPE(XedPluginManager, xed_plugin_manager, GTK_TYPE_BOX)
static XedPluginInfo *plugin_manager_get_selected_plugin (XedPluginManager *pm);
static void plugin_manager_toggle_active (XedPluginManager *pm, GtkTreeIter *iter, GtkTreeModel *model);
static void xed_plugin_manager_finalize (GObject *object);
static void
xed_plugin_manager_class_init (XedPluginManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = xed_plugin_manager_finalize;
g_type_class_add_private (object_class, sizeof (XedPluginManagerPrivate));
}
static void
about_button_cb (GtkWidget *button,
XedPluginManager *pm)
{
XedPluginInfo *info;
xed_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", xed_plugin_info_get_name (info),
"copyright", xed_plugin_info_get_copyright (info),
"authors", xed_plugin_info_get_authors (info),
"comments", xed_plugin_info_get_description (info),
"website", xed_plugin_info_get_website (info),
"logo-icon-name", xed_plugin_info_get_icon_name (info),
"version", xed_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,
XedPluginManager *pm)
{
XedPluginInfo *info;
GtkWindow *toplevel;
xed_debug (DEBUG_PLUGINS);
info = plugin_manager_get_selected_plugin (pm);
g_return_if_fail (info != NULL);
xed_debug_message (DEBUG_PLUGINS, "Configuring: %s\n",
xed_plugin_info_get_name (info));
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET(pm)));
xed_plugins_engine_configure_plugin (pm->priv->engine,
info, toplevel);
xed_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)
{
XedPluginInfo *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",
xed_plugin_info_get_name (info),
xed_plugin_info_get_description (info));
g_object_set (G_OBJECT (cell),
"markup", text,
"sensitive", xed_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)
{
XedPluginInfo *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", xed_plugin_info_get_icon_name (info),
"sensitive", xed_plugin_info_is_available (info),
NULL);
}
static void
active_toggled_cb (GtkCellRendererToggle *cell,
gchar *path_str,
XedPluginManager *pm)
{
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModel *model;
xed_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)
{
XedPluginManager *pm = data;
XedPluginInfo *info;
xed_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) &&
xed_plugin_info_is_configurable (info));
}
static void
row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer data)
{
XedPluginManager *pm = data;
GtkTreeIter iter;
GtkTreeModel *model;
xed_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 (XedPluginManager *pm)
{
const GList *plugins;
GtkListStore *model;
GtkTreeIter iter;
xed_debug (DEBUG_PLUGINS);
plugins = xed_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)
{
XedPluginInfo *info;
info = (XedPluginInfo *)plugins->data;
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
ACTIVE_COLUMN, xed_plugin_info_is_active (info),
AVAILABLE_COLUMN, xed_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;
XedPluginInfo* 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),
xed_plugin_info_is_configurable (info));
}
}
static gboolean
plugin_manager_set_active (XedPluginManager *pm,
GtkTreeIter *iter,
GtkTreeModel *model,
gboolean active)
{
XedPluginInfo *info;
gboolean res = TRUE;
xed_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 (!xed_plugins_engine_activate_plugin (pm->priv->engine, info)) {
xed_debug_message (DEBUG_PLUGINS, "Could not activate %s.\n",
xed_plugin_info_get_name (info));
res = FALSE;
}
}
else
{
/* deactivate the plugin */
if (!xed_plugins_engine_deactivate_plugin (pm->priv->engine, info)) {
xed_debug_message (DEBUG_PLUGINS, "Could not deactivate %s.\n",
xed_plugin_info_get_name (info));
res = FALSE;
}
}
return res;
}
static void
plugin_manager_toggle_active (XedPluginManager *pm,
GtkTreeIter *iter,
GtkTreeModel *model)
{
gboolean active;
xed_debug (DEBUG_PLUGINS);
gtk_tree_model_get (model, iter, ACTIVE_COLUMN, &active, -1);
active ^= 1;
plugin_manager_set_active (pm, iter, model, active);
}
static XedPluginInfo *
plugin_manager_get_selected_plugin (XedPluginManager *pm)
{
XedPluginInfo *info = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeSelection *selection;
xed_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 (XedPluginManager *pm,
gboolean active)
{
GtkTreeModel *model;
GtkTreeIter iter;
xed_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)
{
XedPluginInfo *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 (xed_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,
XedPluginManager *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,
XedPluginManager *pm)
{
plugin_manager_set_active_all (pm, TRUE);
}
static void
disable_all_menu_cb (GtkMenu *menu,
XedPluginManager *pm)
{
plugin_manager_set_active_all (pm, FALSE);
}
static GtkWidget *
create_tree_popup_menu (XedPluginManager *pm)
{
GtkWidget *menu;
GtkWidget *item;
GtkWidget *image;
XedPluginInfo *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, xed_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, xed_plugin_info_is_available (info));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
xed_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 (XedPluginManager *pm,
GtkMenu *menu)
{
pm->priv->popup_menu = NULL;
}
static void
show_tree_popup_menu (GtkTreeView *tree,
XedPluginManager *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,
xed_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,
XedPluginManager *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,
XedPluginManager *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)
{
XedPluginInfo *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 (xed_plugin_info_get_name (info1),
xed_plugin_info_get_name (info2));
}
static void
plugin_manager_construct_tree (XedPluginManager *pm)
{
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
GtkListStore *model;
xed_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_rules_hint (GTK_TREE_VIEW (pm->priv->tree), TRUE);
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 (XedPluginsEngine *engine,
XedPluginInfo *info,
XedPluginManager *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! */
XedPluginInfo *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
{
XedPluginInfo *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 ("XedPluginManager: plugin '%s' not found in the tree model",
xed_plugin_info_get_name (info));
return;
}
gtk_list_store_set (GTK_LIST_STORE (model), &iter, ACTIVE_COLUMN, xed_plugin_info_is_active (info), -1);
}
static void
xed_plugin_manager_init (XedPluginManager *pm)
{
GtkWidget *label;
GtkWidget *viewport;
GtkWidget *hbuttonbox;
xed_debug (DEBUG_PLUGINS);
pm->priv = XED_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
*/
xed_plugins_engine_rescan_plugins (xed_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);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
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 = xed_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 = xed_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 = xed_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 (xed_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
xed_plugin_manager_finalize (GObject *object)
{
XedPluginManager *pm = XED_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 (xed_plugin_manager_parent_class)->finalize (object);
}
GtkWidget *xed_plugin_manager_new (void)
{
return g_object_new (XED_TYPE_PLUGIN_MANAGER,0);
}

View File

@ -1,83 +0,0 @@
/*
* xed-plugin-manager.h
* This file is part of xed
*
* 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 xed Team, 2002-2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_PLUGIN_MANAGER_H__
#define __XED_PLUGIN_MANAGER_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define XED_TYPE_PLUGIN_MANAGER (xed_plugin_manager_get_type())
#define XED_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PLUGIN_MANAGER, XedPluginManager))
#define XED_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_PLUGIN_MANAGER, XedPluginManagerClass))
#define XED_IS_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_PLUGIN_MANAGER))
#define XED_IS_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PLUGIN_MANAGER))
#define XED_PLUGIN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_PLUGIN_MANAGER, XedPluginManagerClass))
/* Private structure type */
typedef struct _XedPluginManagerPrivate XedPluginManagerPrivate;
/*
* Main object structure
*/
typedef struct _XedPluginManager XedPluginManager;
struct _XedPluginManager
{
GtkBox vbox;
/*< private > */
XedPluginManagerPrivate *priv;
};
/*
* Class definition
*/
typedef struct _XedPluginManagerClass XedPluginManagerClass;
struct _XedPluginManagerClass
{
GtkBoxClass parent_class;
};
/*
* Public methods
*/
GType xed_plugin_manager_get_type (void) G_GNUC_CONST;
GtkWidget *xed_plugin_manager_new (void);
G_END_DECLS
#endif /* __XED_PLUGIN_MANAGER_H__ */

View File

@ -1,334 +0,0 @@
/*
* xed-plugin.h
* This file is part of xed
*
* 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 xed Team, 2002-2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xed-plugin.h"
#include "xed-dirs.h"
/* properties */
enum {
PROP_0,
PROP_INSTALL_DIR,
PROP_DATA_DIR_NAME,
PROP_DATA_DIR
};
typedef struct _XedPluginPrivate XedPluginPrivate;
struct _XedPluginPrivate
{
gchar *install_dir;
gchar *data_dir_name;
};
#define XED_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_PLUGIN, XedPluginPrivate))
G_DEFINE_TYPE(XedPlugin, xed_plugin, G_TYPE_OBJECT)
static void
dummy (XedPlugin *plugin, XedWindow *window)
{
/* Empty */
}
static GtkWidget *
create_configure_dialog (XedPlugin *plugin)
{
return NULL;
}
static gboolean
is_configurable (XedPlugin *plugin)
{
return (XED_PLUGIN_GET_CLASS (plugin)->create_configure_dialog !=
create_configure_dialog);
}
static void
xed_plugin_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
switch (prop_id)
{
case PROP_INSTALL_DIR:
g_value_take_string (value, xed_plugin_get_install_dir (XED_PLUGIN (object)));
break;
case PROP_DATA_DIR:
g_value_take_string (value, xed_plugin_get_data_dir (XED_PLUGIN (object)));
break;
default:
g_return_if_reached ();
}
}
static void
xed_plugin_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
XedPluginPrivate *priv = XED_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
xed_plugin_finalize (GObject *object)
{
XedPluginPrivate *priv = XED_PLUGIN_GET_PRIVATE (object);
g_free (priv->install_dir);
g_free (priv->data_dir_name);
G_OBJECT_CLASS (xed_plugin_parent_class)->finalize (object);
}
static void
xed_plugin_class_init (XedPluginClass *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 = xed_plugin_get_property;
object_class->set_property = xed_plugin_set_property;
object_class->finalize = xed_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 (XedPluginPrivate));
}
static void
xed_plugin_init (XedPlugin *plugin)
{
/* Empty */
}
/**
* xed_plugin_get_install_dir:
* @plugin: a #XedPlugin
*
* 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 *
xed_plugin_get_install_dir (XedPlugin *plugin)
{
g_return_val_if_fail (XED_IS_PLUGIN (plugin), NULL);
return g_strdup (XED_PLUGIN_GET_PRIVATE (plugin)->install_dir);
}
/**
* xed_plugin_get_data_dir:
* @plugin: a #XedPlugin
*
* 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 *
xed_plugin_get_data_dir (XedPlugin *plugin)
{
XedPluginPrivate *priv;
gchar *xed_lib_dir;
gchar *data_dir;
g_return_val_if_fail (XED_IS_PLUGIN (plugin), NULL);
priv = XED_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 xed_data_dir,
* so it's under $prefix/share/xed/plugins/data_dir_name
* where data_dir_name usually it's the name of the plugin
*/
xed_lib_dir = xed_dirs_get_xed_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, xed_lib_dir))
{
gchar *xed_data_dir;
xed_data_dir = xed_dirs_get_xed_data_dir ();
data_dir = g_build_filename (xed_data_dir,
"plugins",
priv->data_dir_name,
NULL);
g_free (xed_data_dir);
}
else
{
data_dir = g_build_filename (priv->install_dir,
priv->data_dir_name,
NULL);
}
g_free (xed_lib_dir);
return data_dir;
}
/**
* xed_plugin_activate:
* @plugin: a #XedPlugin
* @window: a #XedWindow
*
* Activates the plugin.
*/
void
xed_plugin_activate (XedPlugin *plugin,
XedWindow *window)
{
g_return_if_fail (XED_IS_PLUGIN (plugin));
g_return_if_fail (XED_IS_WINDOW (window));
XED_PLUGIN_GET_CLASS (plugin)->activate (plugin, window);
}
/**
* xed_plugin_deactivate:
* @plugin: a #XedPlugin
* @window: a #XedWindow
*
* Deactivates the plugin.
*/
void
xed_plugin_deactivate (XedPlugin *plugin,
XedWindow *window)
{
g_return_if_fail (XED_IS_PLUGIN (plugin));
g_return_if_fail (XED_IS_WINDOW (window));
XED_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window);
}
/**
* xed_plugin_update_ui:
* @plugin: a #XedPlugin
* @window: a #XedWindow
*
* Triggers an update of the user interface to take into account state changes
* caused by the plugin.
*/
void
xed_plugin_update_ui (XedPlugin *plugin,
XedWindow *window)
{
g_return_if_fail (XED_IS_PLUGIN (plugin));
g_return_if_fail (XED_IS_WINDOW (window));
XED_PLUGIN_GET_CLASS (plugin)->update_ui (plugin, window);
}
/**
* xed_plugin_is_configurable:
* @plugin: a #XedPlugin
*
* Whether the plugin is configurable.
*
* Returns: TRUE if the plugin is configurable:
*/
gboolean
xed_plugin_is_configurable (XedPlugin *plugin)
{
g_return_val_if_fail (XED_IS_PLUGIN (plugin), FALSE);
return XED_PLUGIN_GET_CLASS (plugin)->is_configurable (plugin);
}
/**
* xed_plugin_create_configure_dialog:
* @plugin: a #XedPlugin
*
* Creates the configure dialog widget for the plugin.
*
* Returns: the configure dialog widget for the plugin.
*/
GtkWidget *
xed_plugin_create_configure_dialog (XedPlugin *plugin)
{
g_return_val_if_fail (XED_IS_PLUGIN (plugin), NULL);
return XED_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin);
}

View File

@ -1,240 +0,0 @@
/*
* xed-plugin.h
* This file is part of xed
*
* 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 xed Team, 2002-2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_PLUGIN_H__
#define __XED_PLUGIN_H__
#include <glib-object.h>
#include <xed/xed-window.h>
#include <xed/xed-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 XED_TYPE_PLUGIN (xed_plugin_get_type())
#define XED_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_PLUGIN, XedPlugin))
#define XED_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_PLUGIN, XedPluginClass))
#define XED_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_PLUGIN))
#define XED_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_PLUGIN))
#define XED_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_PLUGIN, XedPluginClass))
/*
* Main object structure
*/
typedef struct _XedPlugin XedPlugin;
struct _XedPlugin
{
GObject parent;
};
/*
* Class definition
*/
typedef struct _XedPluginClass XedPluginClass;
struct _XedPluginClass
{
GObjectClass parent_class;
/* Virtual public methods */
void (*activate) (XedPlugin *plugin,
XedWindow *window);
void (*deactivate) (XedPlugin *plugin,
XedWindow *window);
void (*update_ui) (XedPlugin *plugin,
XedWindow *window);
GtkWidget *(*create_configure_dialog)
(XedPlugin *plugin);
/* Plugins should not override this, it's handled automatically by
the XedPluginClass */
gboolean (*is_configurable)
(XedPlugin *plugin);
/* Padding for future expansion */
void (*_xed_reserved1) (void);
void (*_xed_reserved2) (void);
void (*_xed_reserved3) (void);
void (*_xed_reserved4) (void);
};
/*
* Public methods
*/
GType xed_plugin_get_type (void) G_GNUC_CONST;
gchar *xed_plugin_get_install_dir (XedPlugin *plugin);
gchar *xed_plugin_get_data_dir (XedPlugin *plugin);
void xed_plugin_activate (XedPlugin *plugin,
XedWindow *window);
void xed_plugin_deactivate (XedPlugin *plugin,
XedWindow *window);
void xed_plugin_update_ui (XedPlugin *plugin,
XedWindow *window);
gboolean xed_plugin_is_configurable (XedPlugin *plugin);
GtkWidget *xed_plugin_create_configure_dialog
(XedPlugin *plugin);
/**
* XED_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE):
*
* Utility macro used to register plugins with additional code.
*/
#define XED_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE) \
G_DEFINE_DYNAMIC_TYPE_EXTENDED (PluginName, \
plugin_name, \
XED_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_xed_plugin (GTypeModule *type_module) \
{ \
plugin_name##_register_type (type_module); \
\
return plugin_name##_get_type(); \
}
/**
* XED_PLUGIN_REGISTER_TYPE(PluginName, plugin_name):
*
* Utility macro used to register plugins.
*/
#define XED_PLUGIN_REGISTER_TYPE(PluginName, plugin_name) \
XED_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, ;)
/**
* XED_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 XED_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; \
}
/**
* XED_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE):
*
* Utility macro used to register gobject types in plugins.
*
* Deprecated: use G_DEFINE_DYNAMIC instead
*/
#define XED_PLUGIN_DEFINE_TYPE(ObjectName, object_name, PARENT_TYPE) \
XED_PLUGIN_DEFINE_TYPE_WITH_CODE(ObjectName, object_name, PARENT_TYPE, ;)
/**
* XED_PLUGIN_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init):
*
* Utility macro used to register interfaces for gobject types in plugins.
*/
#define XED_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 /* __XED_PLUGIN_H__ */