summaryrefslogtreecommitdiff
path: root/pluma
diff options
context:
space:
mode:
authorVadim Barkov <[email protected]>2016-12-19 23:24:10 +0300
committerVadim Barkov <[email protected]>2016-12-19 23:24:10 +0300
commit98c44e3c9455581f90c4f6a70fc42adf986d8206 (patch)
treee9de2a70895a7f28d47eb12b12f9e3d33c64faa3 /pluma
parent2314b3828cbe540d65ba517c32872476417501a6 (diff)
parent38c20e460232c5f4ec7bf616180ff777b5d6b3a0 (diff)
downloadpluma-98c44e3c9455581f90c4f6a70fc42adf986d8206.tar.bz2
pluma-98c44e3c9455581f90c4f6a70fc42adf986d8206.tar.xz
Merge branch 'master' of https://github.com/mate-desktop/pluma
Diffstat (limited to 'pluma')
-rw-r--r--pluma/Makefile.am51
-rwxr-xr-xpluma/dialogs/pluma-preferences-dialog.c4
-rw-r--r--pluma/pluma-app.c8
-rw-r--r--pluma/pluma-commands-file.c4
-rw-r--r--pluma/pluma-dirs.c14
-rw-r--r--pluma/pluma-dirs.h3
-rw-r--r--pluma/pluma-document.c23
-rw-r--r--pluma/pluma-file-chooser-dialog.c2
-rw-r--r--pluma/pluma-message-bus.c15
-rw-r--r--pluma/pluma-message-type.c9
-rw-r--r--pluma/pluma-message.c7
-rw-r--r--pluma/pluma-object-module.c343
-rw-r--r--pluma/pluma-object-module.h94
-rw-r--r--pluma/pluma-plugin-info-priv.h67
-rw-r--r--pluma/pluma-plugin-info.c396
-rw-r--r--pluma/pluma-plugin-info.h63
-rw-r--r--pluma/pluma-plugin-loader.c131
-rw-r--r--pluma/pluma-plugin-loader.h106
-rw-r--r--pluma/pluma-plugin-manager.c895
-rw-r--r--pluma/pluma-plugin-manager.h83
-rw-r--r--pluma/pluma-plugin.c334
-rw-r--r--pluma/pluma-plugin.h240
-rw-r--r--pluma/pluma-plugins-engine.c808
-rw-r--r--pluma/pluma-plugins-engine.h45
-rw-r--r--pluma/pluma-prefs-manager-app.c26
-rw-r--r--pluma/pluma-status-combo-box.c6
-rw-r--r--pluma/pluma-tab.c6
-rw-r--r--pluma/pluma-utils.c27
-rw-r--r--pluma/pluma-utils.h2
-rw-r--r--pluma/pluma-window-private.h11
-rw-r--r--pluma/pluma-window.c126
-rw-r--r--pluma/pluma-window.h3
-rw-r--r--pluma/pluma.c10
33 files changed, 234 insertions, 3728 deletions
diff --git a/pluma/Makefile.am b/pluma/Makefile.am
index 01914351..5a213037 100644
--- a/pluma/Makefile.am
+++ b/pluma/Makefile.am
@@ -11,6 +11,7 @@ AM_CPPFLAGS = \
-I$(srcdir)/smclient \
$(PLUMA_CFLAGS) \
$(WARN_CFLAGS) \
+ $(INTROSPECTION_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\"
@@ -18,7 +19,7 @@ AM_CPPFLAGS = \
pluma_SOURCES = \
pluma.c
-pluma_LDADD = libpluma.la $(PLUMA_LIBS) $(EGG_SMCLIENT_LIBS)
+pluma_LDADD = libpluma.la $(PLUMA_LIBS) $(EGG_SMCLIENT_LIBS) $(INTROSPECTION_LIBS)
pluma_LDFLAGS = -export-dynamic -no-undefined -export-symbols-regex "^[[^_]].*"
@@ -46,16 +47,12 @@ NOINST_H_FILES = \
pluma-document-output-stream.h \
pluma-document-saver.h \
pluma-documents-panel.h \
+ pluma-file-chooser-dialog.h \
pluma-gio-document-loader.h \
pluma-gio-document-saver.h \
pluma-history-entry.h \
pluma-io-error-message-area.h \
pluma-language-manager.h \
- pluma-object-module.h \
- pluma-plugin-info.h \
- pluma-plugin-info-priv.h \
- pluma-plugin-loader.h \
- pluma-plugin-manager.h \
pluma-plugins-engine.h \
pluma-prefs-manager-private.h \
pluma-print-job.h \
@@ -75,14 +72,12 @@ INST_H_FILES = \
pluma-document.h \
pluma-encodings.h \
pluma-encodings-combo-box.h \
- pluma-file-chooser-dialog.h \
pluma-help.h \
pluma-message-bus.h \
pluma-message-type.h \
pluma-message.h \
pluma-notebook.h \
pluma-panel.h \
- pluma-plugin.h \
pluma-prefs-manager-app.h \
pluma-prefs-manager.h \
pluma-progress-message-area.h \
@@ -102,11 +97,7 @@ headerdir = $(prefix)/include/pluma
header_DATA = \
$(INST_H_FILES)
-
-libpluma_la_SOURCES = \
- $(BUILT_SOURCES) \
- $(BACON_FILES) \
- $(POSIXIO_FILES) \
+libpluma_c_files = \
pluma-app.c \
pluma-close-button.c \
pluma-commands-documents.c \
@@ -136,13 +127,8 @@ libpluma_la_SOURCES = \
pluma-message-bus.c \
pluma-message-type.c \
pluma-message.c \
- pluma-object-module.c \
pluma-notebook.c \
pluma-panel.c \
- pluma-plugin-info.c \
- pluma-plugin.c \
- pluma-plugin-loader.c \
- pluma-plugin-manager.c \
pluma-plugins-engine.c \
pluma-prefs-manager-app.c \
pluma-prefs-manager.c \
@@ -160,7 +146,13 @@ libpluma_la_SOURCES = \
pluma-utils.c \
pluma-view.c \
pluma-window.c \
- plumatextregion.c \
+ plumatextregion.c
+
+libpluma_la_SOURCES = \
+ $(libpluma_c_files) \
+ $(BUILT_SOURCES) \
+ $(BACON_FILES) \
+ $(POSIXIO_FILES) \
$(NOINST_H_FILES) \
$(INST_H_FILES)
@@ -195,6 +187,27 @@ EXTRA_DIST = \
CLEANFILES = $(BUILT_SOURCES)
+if HAVE_INTROSPECTION
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS = Pluma-1.0.gir
+INTROSPECTION_SCANNER_ARGS = -I$(top_srcdir) --warn-all
+
+Pluma-1.0.gir: pluma
+Pluma_1_0_gir_INCLUDES = Gtk-3.0 GtkSource-3.0
+Pluma_1_0_gir_FILES = $(INST_H_FILES) $(libpluma_c_files) $(BUILT_SOURCES)
+Pluma_1_0_gir_VERSION = 1.0
+Pluma_1_0_gir_PROGRAM = $(builddir)/pluma
+Pluma_1_0_gir_NAMESPACE = Pluma
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+endif
+
dist-hook:
cd $(distdir); rm -f $(BUILT_SOURCES)
diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c
index 3bacd273..be13d59d 100755
--- a/pluma/dialogs/pluma-preferences-dialog.c
+++ b/pluma/dialogs/pluma-preferences-dialog.c
@@ -39,6 +39,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gtksourceview/gtksource.h>
+#include <libpeas-gtk/peas-gtk-plugin-manager.h>
#include <pluma/pluma-prefs-manager.h>
@@ -47,7 +48,6 @@
#include "pluma-debug.h"
#include "pluma-document.h"
#include "pluma-style-scheme-manager.h"
-#include "pluma-plugin-manager.h"
#include "pluma-help.h"
#include "pluma-dirs.h"
@@ -1047,7 +1047,7 @@ setup_plugins_page (PlumaPreferencesDialog *dlg)
pluma_debug (DEBUG_PREFS);
- page_content = pluma_plugin_manager_new ();
+ page_content = peas_gtk_plugin_manager_new (NULL);
g_return_if_fail (page_content != NULL);
gtk_box_pack_start (GTK_BOX (dlg->priv->plugin_manager_place_holder),
diff --git a/pluma/pluma-app.c b/pluma/pluma-app.c
index d9e713e4..90ed1b64 100644
--- a/pluma/pluma-app.c
+++ b/pluma/pluma-app.c
@@ -350,7 +350,7 @@ app_weak_notify (gpointer data,
* Returns the #PlumaApp object. This object is a singleton and
* represents the running pluma instance.
*
- * Return value: the #PlumaApp pointer
+ * Return value: (transfer none): the #PlumaApp pointer
*/
PlumaApp *
pluma_app_get_default (void)
@@ -555,7 +555,7 @@ pluma_app_create_window_real (PlumaApp *app,
*
* Create a new #PlumaWindow part of @app.
*
- * Return value: the new #PlumaWindow
+ * Return value: (transfer none): the new #PlumaWindow
*/
PlumaWindow *
pluma_app_create_window (PlumaApp *app,
@@ -592,7 +592,7 @@ _pluma_app_restore_window (PlumaApp *app,
*
* Returns all the windows currently present in #PlumaApp.
*
- * Return value: (transfer none): the list of #PlumaWindows objects.
+ * Return value: (element-type Pluma.Window) (transfer none): the list of #PlumaWindows objects.
* The list should not be freed
*/
const GList *
@@ -609,7 +609,7 @@ pluma_app_get_windows (PlumaApp *app)
*
* Retrives the #PlumaWindow currently active.
*
- * Return value: the active #PlumaWindow
+ * Return value: (transfer none): the active #PlumaWindow
*/
PlumaWindow *
pluma_app_get_active_window (PlumaApp *app)
diff --git a/pluma/pluma-commands-file.c b/pluma/pluma-commands-file.c
index 5407c212..c2cfb6cf 100644
--- a/pluma/pluma-commands-file.c
+++ b/pluma/pluma-commands-file.c
@@ -310,8 +310,6 @@ load_uri_list (PlumaWindow *window,
* @line_pos:
*
* Do nothing if uri does not exist
- *
- * Returns: (transfer container):
*/
void
pluma_commands_load_uri (PlumaWindow *window,
@@ -343,7 +341,7 @@ pluma_commands_load_uri (PlumaWindow *window,
*
* Ignore non-existing URIs
*
- * Returns: (transfer container):
+ * Returns:
*/
gint
pluma_commands_load_uris (PlumaWindow *window,
diff --git a/pluma/pluma-dirs.c b/pluma/pluma-dirs.c
index 929b8bd2..aebf5150 100644
--- a/pluma/pluma-dirs.c
+++ b/pluma/pluma-dirs.c
@@ -95,17 +95,17 @@ gchar* pluma_dirs_get_pluma_plugins_dir(void)
return plugin_dir;
}
-gchar* pluma_dirs_get_pluma_plugin_loaders_dir(void)
+gchar* pluma_dirs_get_pluma_plugins_data_dir(void)
{
- gchar* lib_dir;
- gchar* loader_dir;
+ gchar* data_dir;
+ gchar* plugin_data_dir;
- lib_dir = pluma_dirs_get_pluma_lib_dir();
+ data_dir = pluma_dirs_get_pluma_data_dir();
- loader_dir = g_build_filename(lib_dir, "plugin-loaders", NULL);
- g_free(lib_dir);
+ plugin_data_dir = g_build_filename(data_dir, "plugins", NULL);
+ g_free(data_dir);
- return loader_dir;
+ return plugin_data_dir;
}
gchar* pluma_dirs_get_ui_file(const gchar* file)
diff --git a/pluma/pluma-dirs.h b/pluma/pluma-dirs.h
index 529f18ee..a9c74d85 100644
--- a/pluma/pluma-dirs.h
+++ b/pluma/pluma-dirs.h
@@ -44,8 +44,7 @@ gchar *pluma_dirs_get_pluma_lib_dir (void);
gchar *pluma_dirs_get_pluma_plugins_dir (void);
-gchar *pluma_dirs_get_pluma_plugin_loaders_dir
- (void);
+gchar *pluma_dirs_get_pluma_plugins_data_dir (void);
gchar *pluma_dirs_get_ui_file (const gchar *file);
diff --git a/pluma/pluma-document.c b/pluma/pluma-document.c
index 3fe939f5..8634636f 100644
--- a/pluma/pluma-document.c
+++ b/pluma/pluma-document.c
@@ -545,8 +545,6 @@ pluma_document_class_init (PlumaDocumentClass *klass)
* @create: whether the document should be created if it doesn't exist.
*
* The "load" signal is emitted when a document is loaded.
- *
- * Since: 2.22
*/
document_signals[LOAD] =
g_signal_new ("load",
@@ -596,8 +594,6 @@ pluma_document_class_init (PlumaDocumentClass *klass)
* @flags: the #PlumaDocumentSaveFlags for the save operation.
*
* The "save" signal is emitted when the document is saved.
- *
- * Since: 2.20
*/
document_signals[SAVE] =
g_signal_new ("save",
@@ -1039,6 +1035,13 @@ set_uri (PlumaDocument *doc,
}
}
+
+/**
+ * pluma_document_get_location:
+ * @doc: a #PlumaDocument
+ *
+ * Returns: (allow-none) (transfer full): a new #GFile
+ */
GFile *
pluma_document_get_location (PlumaDocument *doc)
{
@@ -1777,7 +1780,7 @@ compute_num_of_lines (const gchar *text)
}
/**
- * pluma_document_set_search_text"
+ * pluma_document_set_search_text:
* @doc:
* @text: (allow-none):
* @flags:
@@ -1876,7 +1879,7 @@ pluma_document_get_can_search_again (PlumaDocument *doc)
* @start: (allow-none):
* @end: (allow-none):
* @match_start: (allow-none):
- * @match_end: (allow=none):
+ * @match_end: (allow-none):
**/
gboolean
pluma_document_search_forward (PlumaDocument *doc,
@@ -1964,7 +1967,7 @@ pluma_document_search_forward (PlumaDocument *doc,
* @start: (allow-none):
* @end: (allow-none):
* @match_start: (allow-none):
- * @match_end: (allow=none):
+ * @match_end: (allow-none):
**/
gboolean
pluma_document_search_backward (PlumaDocument *doc,
@@ -2191,6 +2194,12 @@ pluma_document_set_language (PlumaDocument *doc,
set_language (doc, lang, TRUE);
}
+/**
+ * pluma_document_get_language:
+ * @doc:
+ *
+ * Return value: (transfer none):
+ */
GtkSourceLanguage *
pluma_document_get_language (PlumaDocument *doc)
{
diff --git a/pluma/pluma-file-chooser-dialog.c b/pluma/pluma-file-chooser-dialog.c
index f23a4c0a..76c11d8a 100644
--- a/pluma/pluma-file-chooser-dialog.c
+++ b/pluma/pluma-file-chooser-dialog.c
@@ -463,7 +463,7 @@ pluma_file_chooser_dialog_new_valist (const gchar *title,
* @action: Open or save mode for the dialog
* @first_button_text: (allow-none): stock ID or text to go in
* the first button, or %NULL
- * @Varargs: (allow-none): response ID for the first button, then
+ * @...: (allow-none): response ID for the first button, then
* additional (button, id) pairs, ending with %NULL
*
* Creates a new #PlumaFileChooserDialog. This function is analogous to
diff --git a/pluma/pluma-message-bus.c b/pluma/pluma-message-bus.c
index 84551bff..4cda5693 100644
--- a/pluma/pluma-message-bus.c
+++ b/pluma/pluma-message-bus.c
@@ -88,9 +88,6 @@
* NULL);
* </programlisting>
* </example>
- *
- * Since: 2.25.3
- *
*/
#define PLUMA_MESSAGE_BUS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), PLUMA_TYPE_MESSAGE_BUS, PlumaMessageBusPrivate))
@@ -523,7 +520,7 @@ pluma_message_bus_init (PlumaMessageBus *self)
*
* Get the default application #PlumaMessageBus.
*
- * Return value: the default #PlumaMessageBus
+ * Return value: (transfer none): the default #PlumaMessageBus
*
*/
PlumaMessageBus *
@@ -794,7 +791,7 @@ foreach_type (const gchar *key,
/**
* pluma_message_bus_foreach:
* @bus: the #PlumaMessagebus
- * @func: the callback function
+ * @func: (scope call): the callback function
* @userdata: the user data to supply to the callback function
*
* Calls @func for each message type registered on the bus
@@ -872,7 +869,7 @@ pluma_message_bus_disconnect (PlumaMessageBus *bus,
* @bus: a #PlumaMessageBus
* @object_path: the object path
* @method: the method
- * @callback: the connected callback
+ * @callback: (scope call): the connected callback
* @userdata: the userdata with which the callback was connected
*
* Disconnects a previously connected message callback by matching the
@@ -915,7 +912,7 @@ pluma_message_bus_block (PlumaMessageBus *bus,
* @bus: a #PlumaMessageBus
* @object_path: the object path
* @method: the method
- * @callback: the callback to block
+ * @callback: (scope call): the callback to block
* @userdata: the userdata with which the callback was connected
*
* Blocks evoking the callback that matches provided @callback and @userdata.
@@ -956,7 +953,7 @@ pluma_message_bus_unblock (PlumaMessageBus *bus,
* @bus: a #PlumaMessageBus
* @object_path: the object path
* @method: the method
- * @callback: the callback to block
+ * @callback: (scope call): the callback to block
* @userdata: the userdata with which the callback was connected
*
* Unblocks the callback that matches provided @callback and @userdata.
@@ -1131,7 +1128,7 @@ pluma_message_bus_send (PlumaMessageBus *bus,
* specifies key (string) value pairs used to construct the message
* arguments. To send a message asynchronously use pluma_message_bus_send().
*
- * Return value: the constructed #PlumaMessage. The caller owns a reference
+ * Return value: (transfer full): the constructed #PlumaMessage. The caller owns a reference
* to the #PlumaMessage and should call g_object_unref() when
* it is no longer needed
*/
diff --git a/pluma/pluma-message-type.c b/pluma/pluma-message-type.c
index f399887b..7ca880f0 100644
--- a/pluma/pluma-message-type.c
+++ b/pluma/pluma-message-type.c
@@ -33,9 +33,6 @@
* NULL);
* </programlisting>
* </example>
- *
- * Since: 2.25.3
- *
*/
typedef struct
{
@@ -398,7 +395,7 @@ pluma_message_type_set_valist (PlumaMessageType *message_type,
* Instantiate a new message from the message type with specific values
* for the message arguments.
*
- * Return value: the newly created message
+ * Return value: (transfer full): the newly created message
*
*/
PlumaMessage *
@@ -423,7 +420,7 @@ pluma_message_type_instantiate_valist (PlumaMessageType *message_type,
* Instantiate a new message from the message type with specific values
* for the message arguments.
*
- * Return value: the newly created message
+ * Return value: (transfer full): the newly created message
*
*/
PlumaMessage *
@@ -509,7 +506,7 @@ foreach_gtype (const gchar *key,
/**
* pluma_message_type_foreach:
* @message_type: the #PlumaMessageType
- * @func: the callback function
+ * @func: (scope call): the callback function
* @user_data: user data supplied to the callback function
*
* Calls @func for each argument in the message type.
diff --git a/pluma/pluma-message.c b/pluma/pluma-message.c
index 0e138b04..4d8f7a4b 100644
--- a/pluma/pluma-message.c
+++ b/pluma/pluma-message.c
@@ -17,9 +17,6 @@
* A message can be seen as a method call, or signal emission depending on
* who is the sender and who is the receiver. There is no explicit distinction
* between methods and signals.
- *
- * Since: 2.25.3
- *
*/
#define PLUMA_MESSAGE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), PLUMA_TYPE_MESSAGE, PlumaMessagePrivate))
@@ -367,8 +364,8 @@ pluma_message_set_value (PlumaMessage *message,
/**
* pluma_message_set_valuesv:
* @message: the #PlumaMessage
- * @keys: (array-length=n_values): keys to set values for
- * @values: (array-length=n_values): values to set
+ * @keys: (array length=n_values): keys to set values for
+ * @values: (array length=n_values): values to set
* @n_values: number of arguments to set values for
*
* Set message argument values.
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 *) &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
-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/pluma/pluma-plugins-engine.c b/pluma/pluma-plugins-engine.c
index 27f71dd9..fcedd86f 100644
--- a/pluma/pluma-plugins-engine.c
+++ b/pluma/pluma-plugins-engine.c
@@ -35,459 +35,107 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <girepository.h>
#include "pluma-plugins-engine.h"
-#include "pluma-plugin-info-priv.h"
-#include "pluma-plugin.h"
#include "pluma-debug.h"
#include "pluma-app.h"
#include "pluma-prefs-manager.h"
-#include "pluma-plugin-loader.h"
-#include "pluma-object-module.h"
#include "pluma-dirs.h"
-#define PLUMA_PLUGINS_ENGINE_BASE_KEY "/apps/pluma/plugins"
-#define PLUMA_PLUGINS_ENGINE_KEY PLUMA_PLUGINS_ENGINE_BASE_KEY "/active-plugins"
-
-#define PLUGIN_EXT ".pluma-plugin"
-#define LOADER_EXT G_MODULE_SUFFIX
-
-typedef struct
-{
- PlumaPluginLoader *loader;
- PlumaObjectModule *module;
-} LoaderInfo;
-
-/* Signals */
-enum
-{
- ACTIVATE_PLUGIN,
- DEACTIVATE_PLUGIN,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(PlumaPluginsEngine, pluma_plugins_engine, G_TYPE_OBJECT)
+G_DEFINE_TYPE (PlumaPluginsEngine, pluma_plugins_engine, PEAS_TYPE_ENGINE)
struct _PlumaPluginsEnginePrivate
{
- GList *plugin_list;
- GHashTable *loaders;
-
- gboolean activate_from_prefs;
+ GSettings *plugin_settings;
};
PlumaPluginsEngine *default_engine = NULL;
-static void pluma_plugins_engine_activate_plugin_real (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info);
-static void pluma_plugins_engine_deactivate_plugin_real (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info);
-
-typedef gboolean (*LoadDirCallback)(PlumaPluginsEngine *engine, const gchar *filename, gpointer userdata);
-
-static gboolean
-load_dir_real (PlumaPluginsEngine *engine,
- const gchar *dir,
- const gchar *suffix,
- LoadDirCallback callback,
- gpointer userdata)
+static void
+pluma_plugins_engine_init (PlumaPluginsEngine *engine)
{
+ gchar *private_path;
GError *error = NULL;
- GDir *d;
- const gchar *dirent;
- gboolean ret = TRUE;
-
- g_return_val_if_fail (dir != NULL, TRUE);
-
- pluma_debug_message (DEBUG_PLUGINS, "DIR: %s", dir);
-
- d = g_dir_open (dir, 0, &error);
- if (!d)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- return TRUE;
- }
- while ((dirent = g_dir_read_name (d)))
- {
- gchar *filename;
-
- if (!g_str_has_suffix (dirent, suffix))
- continue;
-
- filename = g_build_filename (dir, dirent, NULL);
-
- ret = callback (engine, filename, userdata);
-
- g_free (filename);
-
- if (!ret)
- break;
- }
-
- g_dir_close (d);
- return ret;
-}
+ pluma_debug (DEBUG_PLUGINS);
-static gboolean
-load_plugin_info (PlumaPluginsEngine *engine,
- const gchar *filename,
- gpointer userdata)
-{
- PlumaPluginInfo *info;
+ engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
+ PLUMA_TYPE_PLUGINS_ENGINE,
+ PlumaPluginsEnginePrivate);
- info = _pluma_plugin_info_new (filename);
+ engine->priv->plugin_settings = g_settings_new (PLUMA_SCHEMA);
- if (info == NULL)
- return TRUE;
+ peas_engine_enable_loader (PEAS_ENGINE (engine), "python");
- /* If a plugin with this name has already been loaded
- * drop this one (user plugins override system plugins) */
- if (pluma_plugins_engine_get_plugin_info (engine, pluma_plugin_info_get_module_name (info)) != NULL)
+ /* This should be moved to libpeas */
+ if (!g_irepository_require (g_irepository_get_default (),
+ "Peas", "1.0", 0, &error))
{
- pluma_debug_message (DEBUG_PLUGINS, "Two or more plugins named '%s'. "
- "Only the first will be considered.\n",
- pluma_plugin_info_get_module_name (info));
-
- _pluma_plugin_info_unref (info);
-
- return TRUE;
+ g_warning ("Could not load Peas repository: %s", error->message);
+ g_error_free (error);
+ error = NULL;
}
- engine->priv->plugin_list = g_list_prepend (engine->priv->plugin_list, info);
-
- pluma_debug_message (DEBUG_PLUGINS, "Plugin %s loaded", info->name);
- return TRUE;
-}
-
-static void
-load_all_plugins (PlumaPluginsEngine *engine)
-{
- gchar *plugin_dir;
- const gchar *pdirs_env = NULL;
-
- /* load user plugins */
- plugin_dir = pluma_dirs_get_user_plugins_dir ();
- if (g_file_test (plugin_dir, G_FILE_TEST_IS_DIR))
+ if (!g_irepository_require (g_irepository_get_default (),
+ "PeasGtk", "1.0", 0, &error))
{
- load_dir_real (engine,
- plugin_dir,
- PLUGIN_EXT,
- load_plugin_info,
- NULL);
-
+ g_warning ("Could not load PeasGtk repository: %s", error->message);
+ g_error_free (error);
+ error = NULL;
}
- g_free (plugin_dir);
-
- /* load system plugins */
- pdirs_env = g_getenv ("PLUMA_PLUGINS_PATH");
-
- pluma_debug_message (DEBUG_PLUGINS, "PLUMA_PLUGINS_PATH=%s", pdirs_env);
-
- if (pdirs_env != NULL)
- {
- gchar **pdirs;
- gint i;
- pdirs = g_strsplit (pdirs_env, G_SEARCHPATH_SEPARATOR_S, 0);
+ private_path = g_build_filename (LIBDIR, "girepository-1.0", NULL);
- for (i = 0; pdirs[i] != NULL; i++)
- {
- if (!load_dir_real (engine,
- pdirs[i],
- PLUGIN_EXT,
- load_plugin_info,
- NULL))
- {
- break;
- }
- }
-
- g_strfreev (pdirs);
- }
- else
+ if (!g_irepository_require_private (g_irepository_get_default (),
+ private_path, "Pluma", "1.0", 0, &error))
{
- plugin_dir = pluma_dirs_get_pluma_plugins_dir ();
-
- load_dir_real (engine,
- plugin_dir,
- PLUGIN_EXT,
- load_plugin_info,
- NULL);
-
- g_free (plugin_dir);
- }
-}
-
-static guint
-hash_lowercase (gconstpointer data)
-{
- gchar *lowercase;
- guint ret;
-
- lowercase = g_ascii_strdown ((const gchar *)data, -1);
- ret = g_str_hash (lowercase);
- g_free (lowercase);
-
- return ret;
-}
-
-static gboolean
-equal_lowercase (gconstpointer a, gconstpointer b)
-{
- return g_ascii_strcasecmp ((const gchar *)a, (const gchar *)b) == 0;
-}
-
-static void
-loader_destroy (LoaderInfo *info)
-{
- if (!info)
- return;
-
- if (info->loader)
- g_object_unref (info->loader);
-
- g_free (info);
-}
-
-static void
-add_loader (PlumaPluginsEngine *engine,
- const gchar *loader_id,
- PlumaObjectModule *module)
-{
- LoaderInfo *info;
-
- info = g_new (LoaderInfo, 1);
- info->loader = NULL;
- info->module = module;
-
- g_hash_table_insert (engine->priv->loaders, g_strdup (loader_id), info);
-}
-
-static void
-pluma_plugins_engine_init (PlumaPluginsEngine *engine)
-{
- pluma_debug (DEBUG_PLUGINS);
-
- if (!g_module_supported ())
- {
- g_warning ("pluma is not able to initialize the plugins engine.");
- return;
+ g_warning ("Could not load Pluma repository: %s", error->message);
+ g_error_free (error);
+ error = NULL;
}
- engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
- PLUMA_TYPE_PLUGINS_ENGINE,
- PlumaPluginsEnginePrivate);
-
- load_all_plugins (engine);
+ g_free (private_path);
- /* make sure that the first reactivation will read active plugins
- from the prefs */
- engine->priv->activate_from_prefs = TRUE;
+ peas_engine_add_search_path (PEAS_ENGINE (engine),
+ pluma_dirs_get_user_plugins_dir (),
+ pluma_dirs_get_user_plugins_dir ());
- /* mapping from loadername -> loader object */
- engine->priv->loaders = g_hash_table_new_full (hash_lowercase,
- equal_lowercase,
- (GDestroyNotify)g_free,
- (GDestroyNotify)loader_destroy);
-}
+ peas_engine_add_search_path (PEAS_ENGINE (engine),
+ pluma_dirs_get_pluma_plugins_dir (),
+ pluma_dirs_get_pluma_plugins_data_dir ());
-static void
-loader_garbage_collect (const char *id, LoaderInfo *info)
-{
- if (info->loader)
- pluma_plugin_loader_garbage_collect (info->loader);
-}
-
-void
-pluma_plugins_engine_garbage_collect (PlumaPluginsEngine *engine)
-{
- g_hash_table_foreach (engine->priv->loaders,
- (GHFunc) loader_garbage_collect,
- NULL);
+ g_settings_bind (engine->priv->plugin_settings,
+ GPM_ACTIVE_PLUGINS,
+ engine,
+ "loaded-plugins",
+ G_SETTINGS_BIND_DEFAULT);
}
static void
-pluma_plugins_engine_finalize (GObject *object)
+pluma_plugins_engine_dispose (GObject *object)
{
PlumaPluginsEngine *engine = PLUMA_PLUGINS_ENGINE (object);
- GList *item;
-
- pluma_debug (DEBUG_PLUGINS);
-
- /* Firs deactivate all plugins */
- for (item = engine->priv->plugin_list; item; item = item->next)
- {
- PlumaPluginInfo *info = PLUMA_PLUGIN_INFO (item->data);
-
- if (pluma_plugin_info_is_active (info))
- pluma_plugins_engine_deactivate_plugin_real (engine, info);
- }
- /* unref the loaders */
- g_hash_table_destroy (engine->priv->loaders);
-
- /* and finally free the infos */
- for (item = engine->priv->plugin_list; item; item = item->next)
+ if (engine->priv->plugin_settings != NULL)
{
- PlumaPluginInfo *info = PLUMA_PLUGIN_INFO (item->data);
-
- _pluma_plugin_info_unref (info);
+ g_object_unref (engine->priv->plugin_settings);
+ engine->priv->plugin_settings = NULL;
}
- g_list_free (engine->priv->plugin_list);
-
- G_OBJECT_CLASS (pluma_plugins_engine_parent_class)->finalize (object);
+ G_OBJECT_CLASS (pluma_plugins_engine_parent_class)->dispose (object);
}
static void
pluma_plugins_engine_class_init (PlumaPluginsEngineClass *klass)
{
- GType the_type = G_TYPE_FROM_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = pluma_plugins_engine_finalize;
- klass->activate_plugin = pluma_plugins_engine_activate_plugin_real;
- klass->deactivate_plugin = pluma_plugins_engine_deactivate_plugin_real;
-
- signals[ACTIVATE_PLUGIN] =
- g_signal_new ("activate-plugin",
- the_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PlumaPluginsEngineClass, activate_plugin),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- 1,
- PLUMA_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- signals[DEACTIVATE_PLUGIN] =
- g_signal_new ("deactivate-plugin",
- the_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PlumaPluginsEngineClass, deactivate_plugin),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE,
- 1,
- PLUMA_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
+ object_class->dispose = pluma_plugins_engine_dispose;
g_type_class_add_private (klass, sizeof (PlumaPluginsEnginePrivate));
}
-static gboolean
-load_loader (PlumaPluginsEngine *engine,
- const gchar *filename,
- gpointer data)
-{
- PlumaObjectModule *module;
- gchar *base;
- gchar *path;
- const gchar *id;
- GType type;
-
- /* try to load in the module */
- path = g_path_get_dirname (filename);
- base = g_path_get_basename (filename);
-
- /* for now they are all resident */
- module = pluma_object_module_new (base,
- path,
- "register_pluma_plugin_loader",
- TRUE);
-
- g_free (base);
- g_free (path);
-
- /* make sure to load the type definition */
- if (!g_type_module_use (G_TYPE_MODULE (module)))
- {
- g_object_unref (module);
- g_warning ("Plugin loader module `%s' could not be loaded", filename);
-
- return TRUE;
- }
-
- /* get the exported type and check the name as exported by the
- * loader interface */
- type = pluma_object_module_get_object_type (module);
- id = pluma_plugin_loader_type_get_id (type);
-
- add_loader (engine, id, module);
- g_type_module_unuse (G_TYPE_MODULE (module));
-
- return TRUE;
-}
-
-static void
-ensure_loader (LoaderInfo *info)
-{
- if (info->loader == NULL && info->module != NULL)
- {
- /* create a new loader object */
- PlumaPluginLoader *loader;
- loader = (PlumaPluginLoader *)pluma_object_module_new_object (info->module, NULL);
-
- if (loader == NULL || !PLUMA_IS_PLUGIN_LOADER (loader))
- {
- g_warning ("Loader object is not a valid PlumaPluginLoader instance");
-
- if (loader != NULL && G_IS_OBJECT (loader))
- g_object_unref (loader);
- }
- else
- {
- info->loader = loader;
- }
- }
-}
-
-static PlumaPluginLoader *
-get_plugin_loader (PlumaPluginsEngine *engine, PlumaPluginInfo *info)
-{
- const gchar *loader_id;
- LoaderInfo *loader_info;
-
- loader_id = info->loader;
-
- loader_info = (LoaderInfo *)g_hash_table_lookup (
- engine->priv->loaders,
- loader_id);
-
- if (loader_info == NULL)
- {
- gchar *loader_dir;
-
- loader_dir = pluma_dirs_get_pluma_plugin_loaders_dir ();
-
- /* loader could not be found in the hash, try to find it by
- scanning */
- load_dir_real (engine,
- loader_dir,
- LOADER_EXT,
- (LoadDirCallback)load_loader,
- NULL);
- g_free (loader_dir);
-
- loader_info = (LoaderInfo *)g_hash_table_lookup (
- engine->priv->loaders,
- loader_id);
- }
-
- if (loader_info == NULL)
- {
- /* cache non-existent so we don't scan again */
- add_loader (engine, loader_id, NULL);
- return NULL;
- }
-
- ensure_loader (loader_info);
- return loader_info->loader;
-}
-
PlumaPluginsEngine *
pluma_plugins_engine_get_default (void)
{
@@ -496,366 +144,8 @@ pluma_plugins_engine_get_default (void)
default_engine = PLUMA_PLUGINS_ENGINE (g_object_new (PLUMA_TYPE_PLUGINS_ENGINE, NULL));
g_object_add_weak_pointer (G_OBJECT (default_engine),
- (gpointer) &default_engine);
- return default_engine;
-}
-
-const GList *
-pluma_plugins_engine_get_plugin_list (PlumaPluginsEngine *engine)
-{
- pluma_debug (DEBUG_PLUGINS);
-
- return engine->priv->plugin_list;
-}
-
-static gint
-compare_plugin_info_and_name (PlumaPluginInfo *info,
- const gchar *module_name)
-{
- return strcmp (pluma_plugin_info_get_module_name (info), module_name);
-}
+ (gpointer) &default_engine);
-PlumaPluginInfo *
-pluma_plugins_engine_get_plugin_info (PlumaPluginsEngine *engine,
- const gchar *name)
-{
- GList *l = g_list_find_custom (engine->priv->plugin_list,
- name,
- (GCompareFunc) compare_plugin_info_and_name);
-
- return l == NULL ? NULL : (PlumaPluginInfo *) l->data;
-}
-
-static void
-save_active_plugin_list (PlumaPluginsEngine *engine)
-{
- GSList *active_plugins = NULL;
- GList *l;
-
- for (l = engine->priv->plugin_list; l != NULL; l = l->next)
- {
- PlumaPluginInfo *info = (PlumaPluginInfo *) l->data;
-
- if (pluma_plugin_info_is_active (info))
- {
- active_plugins = g_slist_prepend (active_plugins,
- (gpointer)pluma_plugin_info_get_module_name (info));
- }
- }
-
- pluma_prefs_manager_set_active_plugins (active_plugins);
-
- g_slist_free (active_plugins);
-}
-
-static gboolean
-load_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info)
-{
- PlumaPluginLoader *loader;
- gchar *path;
-
- if (pluma_plugin_info_is_active (info))
- return TRUE;
-
- if (!pluma_plugin_info_is_available (info))
- return FALSE;
-
- loader = get_plugin_loader (engine, info);
-
- if (loader == NULL)
- {
- g_warning ("Could not find loader `%s' for plugin `%s'", info->loader, info->name);
- info->available = FALSE;
- return FALSE;
- }
-
- path = g_path_get_dirname (info->file);
- g_return_val_if_fail (path != NULL, FALSE);
-
- info->plugin = pluma_plugin_loader_load (loader, info, path);
-
- g_free (path);
-
- if (info->plugin == NULL)
- {
- g_warning ("Error loading plugin '%s'", info->name);
- info->available = FALSE;
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-pluma_plugins_engine_activate_plugin_real (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info)
-{
- const GList *wins;
-
- if (!load_plugin (engine, info))
- return;
-
- for (wins = pluma_app_get_windows (pluma_app_get_default ());
- wins != NULL;
- wins = wins->next)
- {
- pluma_plugin_activate (info->plugin, PLUMA_WINDOW (wins->data));
- }
-}
-
-gboolean
-pluma_plugins_engine_activate_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info)
-{
- pluma_debug (DEBUG_PLUGINS);
-
- g_return_val_if_fail (info != NULL, FALSE);
-
- if (!pluma_plugin_info_is_available (info))
- return FALSE;
-
- if (pluma_plugin_info_is_active (info))
- return TRUE;
-
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
-
- if (pluma_plugin_info_is_active (info))
- save_active_plugin_list (engine);
-
- return pluma_plugin_info_is_active (info);
-}
-
-static void
-call_plugin_deactivate (PlumaPlugin *plugin,
- PlumaWindow *window)
-{
- pluma_plugin_deactivate (plugin, window);
-
- /* ensure update of ui manager, because we suspect it does something
- with expected static strings in the type module (when unloaded the
- strings don't exist anymore, and ui manager updates in an idle
- func) */
- gtk_ui_manager_ensure_update (pluma_window_get_ui_manager (window));
-}
-
-static void
-pluma_plugins_engine_deactivate_plugin_real (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info)
-{
- const GList *wins;
- PlumaPluginLoader *loader;
-
- if (!pluma_plugin_info_is_active (info) ||
- !pluma_plugin_info_is_available (info))
- return;
-
- for (wins = pluma_app_get_windows (pluma_app_get_default ());
- wins != NULL;
- wins = wins->next)
- {
- call_plugin_deactivate (info->plugin, PLUMA_WINDOW (wins->data));
- }
-
- /* first unref the plugin (the loader still has one) */
- g_object_unref (info->plugin);
-
- /* find the loader and tell it to gc and unload the plugin */
- loader = get_plugin_loader (engine, info);
-
- pluma_plugin_loader_garbage_collect (loader);
- pluma_plugin_loader_unload (loader, info);
-
- info->plugin = NULL;
-}
-
-gboolean
-pluma_plugins_engine_deactivate_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info)
-{
- pluma_debug (DEBUG_PLUGINS);
-
- g_return_val_if_fail (info != NULL, FALSE);
-
- if (!pluma_plugin_info_is_active (info))
- return TRUE;
-
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
- if (!pluma_plugin_info_is_active (info))
- save_active_plugin_list (engine);
-
- return !pluma_plugin_info_is_active (info);
-}
-
-void
-pluma_plugins_engine_activate_plugins (PlumaPluginsEngine *engine,
- PlumaWindow *window)
-{
- GSList *active_plugins = NULL;
- GList *pl;
-
- pluma_debug (DEBUG_PLUGINS);
-
- g_return_if_fail (PLUMA_IS_PLUGINS_ENGINE (engine));
- g_return_if_fail (PLUMA_IS_WINDOW (window));
-
- /* the first time, we get the 'active' plugins from GSettings */
- if (engine->priv->activate_from_prefs)
- {
- active_plugins = pluma_prefs_manager_get_active_plugins ();
- }
-
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;
-
- if (engine->priv->activate_from_prefs &&
- g_slist_find_custom (active_plugins,
- pluma_plugin_info_get_module_name (info),
- (GCompareFunc)strcmp) == NULL)
- continue;
-
- /* If plugin is not active, don't try to activate/load it */
- if (!engine->priv->activate_from_prefs &&
- !pluma_plugin_info_is_active (info))
- continue;
-
- if (load_plugin (engine, info))
- pluma_plugin_activate (info->plugin,
- window);
- }
-
- if (engine->priv->activate_from_prefs)
- {
- g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
- g_slist_free (active_plugins);
- engine->priv->activate_from_prefs = FALSE;
- }
-
- pluma_debug_message (DEBUG_PLUGINS, "End");
-
- /* also call update_ui after activation */
- pluma_plugins_engine_update_plugins_ui (engine, window);
-}
-
-void
-pluma_plugins_engine_deactivate_plugins (PlumaPluginsEngine *engine,
- PlumaWindow *window)
-{
- GList *pl;
-
- pluma_debug (DEBUG_PLUGINS);
-
- g_return_if_fail (PLUMA_IS_PLUGINS_ENGINE (engine));
- g_return_if_fail (PLUMA_IS_WINDOW (window));
-
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;
-
- /* check if the plugin is actually active */
- if (!pluma_plugin_info_is_active (info))
- continue;
-
- /* call deactivate for the plugin for this window */
- pluma_plugin_deactivate (info->plugin, window);
- }
-
- pluma_debug_message (DEBUG_PLUGINS, "End");
-}
-
-void
-pluma_plugins_engine_update_plugins_ui (PlumaPluginsEngine *engine,
- PlumaWindow *window)
-{
- GList *pl;
-
- pluma_debug (DEBUG_PLUGINS);
-
- g_return_if_fail (PLUMA_IS_PLUGINS_ENGINE (engine));
- g_return_if_fail (PLUMA_IS_WINDOW (window));
-
- /* call update_ui for all active plugins */
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;
-
- if (!pluma_plugin_info_is_active (info))
- continue;
-
- pluma_debug_message (DEBUG_PLUGINS, "Updating UI of %s", info->name);
- pluma_plugin_update_ui (info->plugin, window);
- }
-}
-
-void
-pluma_plugins_engine_configure_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info,
- GtkWindow *parent)
-{
- GtkWidget *conf_dlg;
-
- GtkWindowGroup *wg;
-
- pluma_debug (DEBUG_PLUGINS);
-
- g_return_if_fail (info != NULL);
-
- conf_dlg = pluma_plugin_create_configure_dialog (info->plugin);
- g_return_if_fail (conf_dlg != NULL);
- gtk_window_set_transient_for (GTK_WINDOW (conf_dlg),
- parent);
-
- wg = gtk_window_get_group (parent);
- if (wg == NULL)
- {
- wg = gtk_window_group_new ();
- gtk_window_group_add_window (wg, parent);
- }
-
- gtk_window_group_add_window (wg,
- GTK_WINDOW (conf_dlg));
-
- gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);
- gtk_widget_show (conf_dlg);
-}
-
-void
-pluma_plugins_engine_active_plugins_changed (PlumaPluginsEngine *engine)
-{
- gboolean to_activate;
- GSList *active_plugins;
- GList *pl;
-
- pluma_debug (DEBUG_PLUGINS);
-
- active_plugins = pluma_prefs_manager_get_active_plugins ();
-
- for (pl = engine->priv->plugin_list; pl; pl = pl->next)
- {
- PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;
-
- if (!pluma_plugin_info_is_available (info))
- continue;
-
- to_activate = (g_slist_find_custom (active_plugins,
- pluma_plugin_info_get_module_name (info),
- (GCompareFunc)strcmp) != NULL);
-
- if (!pluma_plugin_info_is_active (info) && to_activate)
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
- else if (pluma_plugin_info_is_active (info) && !to_activate)
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
- }
-
- g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
- g_slist_free (active_plugins);
+ return default_engine;
}
-void
-pluma_plugins_engine_rescan_plugins (PlumaPluginsEngine *engine)
-{
- pluma_debug (DEBUG_PLUGINS);
-
- load_all_plugins (engine);
-}
diff --git a/pluma/pluma-plugins-engine.h b/pluma/pluma-plugins-engine.h
index 6a58f213..2cf20004 100644
--- a/pluma/pluma-plugins-engine.h
+++ b/pluma/pluma-plugins-engine.h
@@ -32,9 +32,7 @@
#define __PLUMA_PLUGINS_ENGINE_H__
#include <glib.h>
-#include "pluma-window.h"
-#include "pluma-plugin-info.h"
-#include "pluma-plugin.h"
+#include <libpeas/peas-engine.h>
G_BEGIN_DECLS
@@ -50,7 +48,7 @@ typedef struct _PlumaPluginsEnginePrivate PlumaPluginsEnginePrivate;
struct _PlumaPluginsEngine
{
- GObject parent;
+ PeasEngine parent;
PlumaPluginsEnginePrivate *priv;
};
@@ -58,50 +56,13 @@ typedef struct _PlumaPluginsEngineClass PlumaPluginsEngineClass;
struct _PlumaPluginsEngineClass
{
- GObjectClass parent_class;
-
- void (* activate_plugin) (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info);
-
- void (* deactivate_plugin) (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info);
+ PeasEngineClass parent_class;
};
GType pluma_plugins_engine_get_type (void) G_GNUC_CONST;
PlumaPluginsEngine *pluma_plugins_engine_get_default (void);
-void pluma_plugins_engine_garbage_collect (PlumaPluginsEngine *engine);
-
-const GList *pluma_plugins_engine_get_plugin_list (PlumaPluginsEngine *engine);
-
-PlumaPluginInfo *pluma_plugins_engine_get_plugin_info (PlumaPluginsEngine *engine,
- const gchar *name);
-
-/* plugin load and unloading (overall, for all windows) */
-gboolean pluma_plugins_engine_activate_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info);
-gboolean pluma_plugins_engine_deactivate_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info);
-
-void pluma_plugins_engine_configure_plugin (PlumaPluginsEngine *engine,
- PlumaPluginInfo *info,
- GtkWindow *parent);
-
-/* plugin activation/deactivation per window, private to PlumaWindow */
-void pluma_plugins_engine_activate_plugins (PlumaPluginsEngine *engine,
- PlumaWindow *window);
-void pluma_plugins_engine_deactivate_plugins (PlumaPluginsEngine *engine,
- PlumaWindow *window);
-void pluma_plugins_engine_update_plugins_ui (PlumaPluginsEngine *engine,
- PlumaWindow *window);
-
-/* private for GSettings notification */
-void pluma_plugins_engine_active_plugins_changed
- (PlumaPluginsEngine *engine);
-
-void pluma_plugins_engine_rescan_plugins (PlumaPluginsEngine *engine);
-
G_END_DECLS
#endif /* __PLUMA_PLUGINS_ENGINE_H__ */
diff --git a/pluma/pluma-prefs-manager-app.c b/pluma/pluma-prefs-manager-app.c
index 34a666eb..76d3942e 100644
--- a/pluma/pluma-prefs-manager-app.c
+++ b/pluma/pluma-prefs-manager-app.c
@@ -112,10 +112,6 @@ static void pluma_prefs_manager_auto_save_changed (GSettings *settings,
gchar *key,
gpointer user_data);
-static void pluma_prefs_manager_active_plugins_changed (GSettings *settings,
- gchar *key,
- gpointer user_data);
-
static void pluma_prefs_manager_lockdown_changed (GSettings *settings,
gchar *key,
gpointer user_data);
@@ -713,11 +709,6 @@ pluma_prefs_manager_app_init (void)
G_CALLBACK (pluma_prefs_manager_auto_save_changed),
NULL);
- g_signal_connect (pluma_prefs_manager->settings,
- "changed::" GPM_ACTIVE_PLUGINS,
- G_CALLBACK (pluma_prefs_manager_active_plugins_changed),
- NULL);
-
g_signal_connect (pluma_prefs_manager->lockdown_settings,
"changed",
G_CALLBACK (pluma_prefs_manager_lockdown_changed),
@@ -1415,23 +1406,6 @@ pluma_prefs_manager_auto_save_changed (GSettings *settings,
}
static void
-pluma_prefs_manager_active_plugins_changed (GSettings *settings,
- gchar *key,
- gpointer user_data)
-{
- pluma_debug (DEBUG_PREFS);
-
- if (strcmp (key, GPM_ACTIVE_PLUGINS) == 0)
- {
- PlumaPluginsEngine *engine;
-
- engine = pluma_plugins_engine_get_default ();
-
- pluma_plugins_engine_active_plugins_changed (engine);
- }
-}
-
-static void
pluma_prefs_manager_lockdown_changed (GSettings *settings,
gchar *key,
gpointer user_data)
diff --git a/pluma/pluma-status-combo-box.c b/pluma/pluma-status-combo-box.c
index e446b371..8b8d0004 100644
--- a/pluma/pluma-status-combo-box.c
+++ b/pluma/pluma-status-combo-box.c
@@ -409,6 +409,12 @@ pluma_status_combo_box_remove_item (PlumaStatusComboBox *combo,
GTK_WIDGET (item));
}
+/**
+ * pluma_status_combo_box_get_items:
+ * @combo:
+ *
+ * Returns: (element-type Gtk.Widget) (transfer container):
+ */
GList *
pluma_status_combo_box_get_items (PlumaStatusComboBox *combo)
{
diff --git a/pluma/pluma-tab.c b/pluma/pluma-tab.c
index 02fc2582..79339a90 100644
--- a/pluma/pluma-tab.c
+++ b/pluma/pluma-tab.c
@@ -1619,7 +1619,7 @@ _pluma_tab_new_from_uri (const gchar *uri,
*
* Gets the #PlumaView inside @tab.
*
- * Returns: the #PlumaView inside @tab
+ * Returns: (transfer none): the #PlumaView inside @tab
*/
PlumaView *
pluma_tab_get_view (PlumaTab *tab)
@@ -1633,7 +1633,7 @@ pluma_tab_get_view (PlumaTab *tab)
*
* Gets the #PlumaDocument associated to @tab.
*
- * Returns: the #PlumaDocument associated to @tab
+ * Returns: (transfer none): the #PlumaDocument associated to @tab
*/
PlumaDocument *
pluma_tab_get_document (PlumaTab *tab)
@@ -1958,7 +1958,7 @@ _pluma_tab_get_icon (PlumaTab *tab)
*
* Gets the #PlumaTab associated with @doc.
*
- * Returns: the #PlumaTab associated with @doc
+ * Returns: (transfer none): the #PlumaTab associated with @doc
*/
PlumaTab *
pluma_tab_get_from_document (PlumaDocument *doc)
diff --git a/pluma/pluma-utils.c b/pluma/pluma-utils.c
index 868a5bd8..ff872e09 100644
--- a/pluma/pluma-utils.c
+++ b/pluma/pluma-utils.c
@@ -202,15 +202,13 @@ pluma_utils_menu_position_under_tree_view (GtkMenu *menu,
}
}
-/* FIXME: remove this with gtk 2.12, it has gdk_color_to_string */
-gchar *
-pluma_gdk_color_to_string (GdkColor color)
-{
- return g_strdup_printf ("#%04x%04x%04x",
- color.red,
- color.green,
- color.blue);
-}
+/**
+ * pluma_gtk_button_new_with_stock_icon:
+ * @label:
+ * @stock_id:
+ *
+ * Returns: (transfer full):
+ */
GtkWidget *
pluma_gtk_button_new_with_stock_icon (const gchar *label,
@@ -226,6 +224,15 @@ pluma_gtk_button_new_with_stock_icon (const gchar *label,
return button;
}
+/**
+ * pluma_dialog_add_button:
+ * @dialog:
+ * @text:
+ * @stock_id:
+ * @response_id:
+ *
+ * Returns: (transfer none):
+ */
GtkWidget *
pluma_dialog_add_button (GtkDialog *dialog,
const gchar *text,
@@ -1383,7 +1390,7 @@ pluma_utils_uri_for_display (const gchar *uri)
*
* Create a list of valid uri's from a uri-list drop.
*
- * Return value: a string array which will hold the uris or %NULL if there
+ * Return value: (transfer full): a string array which will hold the uris or %NULL if there
* were no valid uris. g_strfreev should be used when the
* string array is no longer used
*/
diff --git a/pluma/pluma-utils.h b/pluma/pluma-utils.h
index be54f786..e9dd0a5b 100644
--- a/pluma/pluma-utils.h
+++ b/pluma/pluma-utils.h
@@ -64,8 +64,6 @@ void pluma_utils_menu_position_under_tree_view
gboolean *push_in,
gpointer user_data);
-gchar *pluma_gdk_color_to_string (GdkColor color);
-
GtkWidget *pluma_gtk_button_new_with_stock_icon (const gchar *label,
const gchar *stock_id);
diff --git a/pluma/pluma-window-private.h b/pluma/pluma-window-private.h
index e575a59e..3c36a499 100644
--- a/pluma/pluma-window-private.h
+++ b/pluma/pluma-window-private.h
@@ -31,6 +31,8 @@
#ifndef __PLUMA_WINDOW_PRIVATE_H__
#define __PLUMA_WINDOW_PRIVATE_H__
+#include <libpeas/peas-extension-set.h>
+
#include "pluma/pluma-window.h"
#include "pluma-prefs-manager.h"
#include "pluma-message-bus.h"
@@ -51,8 +53,9 @@ struct _PlumaWindowPrivate
GtkWidget *tab_width_combo;
GtkWidget *language_combo;
-
- PlumaMessageBus *message_bus;
+
+ PlumaMessageBus *message_bus;
+ PeasExtensionSet *extensions;
/* Widgets for fullscreen mode */
GtkWidget *fullscreen_controls;
@@ -60,7 +63,7 @@ struct _PlumaWindowPrivate
gboolean fullscreen_animation_enter;
/* statusbar and context ids for statusbar messages */
- GtkWidget *statusbar;
+ GtkWidget *statusbar;
guint generic_message_cid;
guint tip_message_cid;
guint tab_width_id;
@@ -93,7 +96,7 @@ struct _PlumaWindowPrivate
gint num_tabs_with_error;
gint width;
- gint height;
+ gint height;
GdkWindowState window_state;
gint side_panel_size;
diff --git a/pluma/pluma-window.c b/pluma/pluma-window.c
index 2432aeaf..8bff1509 100644
--- a/pluma/pluma-window.c
+++ b/pluma/pluma-window.c
@@ -40,6 +40,8 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <gtksourceview/gtksource.h>
+#include <libpeas/peas-activatable.h>
+#include <libpeas/peas-extension-set.h>
#include "pluma-ui.h"
#include "pluma-window.h"
@@ -175,7 +177,7 @@ pluma_window_dispose (GObject *object)
/* First of all, force collection so that plugins
* really drop some of the references.
*/
- pluma_plugins_engine_garbage_collect (pluma_plugins_engine_get_default ());
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
/* save the panes position and make sure to deactivate plugins
* for this window, but only once */
@@ -183,8 +185,12 @@ pluma_window_dispose (GObject *object)
{
save_panes_state (window);
- pluma_plugins_engine_deactivate_plugins (pluma_plugins_engine_get_default (),
- window);
+ /* Note that unreffing the extensions will automatically remove
+ all extensions which in turn will deactivate the extension */
+ g_object_unref (window->priv->extensions);
+
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
+
window->priv->dispose_has_run = TRUE;
}
@@ -232,7 +238,7 @@ pluma_window_dispose (GObject *object)
/* Now that there have broken some reference loops,
* force collection again.
*/
- pluma_plugins_engine_garbage_collect (pluma_plugins_engine_get_default ());
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
G_OBJECT_CLASS (pluma_window_parent_class)->dispose (object);
}
@@ -322,7 +328,7 @@ static void
pluma_window_tab_removed (PlumaWindow *window,
PlumaTab *tab)
{
- pluma_plugins_engine_garbage_collect (pluma_plugins_engine_get_default ());
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
}
static void
@@ -824,8 +830,7 @@ set_sensitivity_according_to_tab (PlumaWindow *window,
update_next_prev_doc_sensitivity (window, tab);
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
static void
@@ -2685,8 +2690,7 @@ sync_name (PlumaTab *tab,
g_free (escaped_name);
g_free (tip);
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
static PlumaWindow *
@@ -3077,8 +3081,7 @@ selection_changed (PlumaDocument *doc,
editable &&
gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
static void
@@ -3087,8 +3090,7 @@ sync_languages_menu (PlumaDocument *doc,
PlumaWindow *window)
{
update_languages_menu (window);
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
static void
@@ -3100,8 +3102,7 @@ readonly_changed (PlumaDocument *doc,
sync_name (window->priv->active_tab, NULL, window);
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
static void
@@ -3109,8 +3110,7 @@ editable_changed (PlumaView *view,
GParamSpec *arg1,
PlumaWindow *window)
{
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
static void
@@ -3322,8 +3322,7 @@ notebook_tab_removed (PlumaNotebook *notebook,
if (window->priv->num_tabs == 0)
{
- pluma_plugins_engine_update_plugins_ui (pluma_plugins_engine_get_default (),
- window);
+ peas_extension_set_call (window->priv->extensions, "update_state", window);
}
update_window_state (window);
@@ -3812,6 +3811,30 @@ add_notebook (PlumaWindow *window,
}
static void
+on_extension_added (PeasExtensionSet *extensions,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ PlumaWindow *window)
+{
+ peas_extension_call (exten, "activate", window);
+}
+
+static void
+on_extension_removed (PeasExtensionSet *extensions,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ PlumaWindow *window)
+{
+ peas_extension_call (exten, "deactivate", window);
+
+ /* Ensure update of ui manager, because we suspect it does something
+ * with expected static strings in the type module (when unloaded the
+ * strings don't exist anymore, and ui manager updates in an idle
+ * func) */
+ gtk_ui_manager_ensure_update (window->priv->manager);
+}
+
+static void
pluma_window_init (PlumaWindow *window)
{
GtkWidget *main_box;
@@ -3936,8 +3959,19 @@ pluma_window_init (PlumaWindow *window)
pluma_debug_message (DEBUG_WINDOW, "Update plugins ui");
- pluma_plugins_engine_activate_plugins (pluma_plugins_engine_get_default (),
- window);
+ window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()),
+ PEAS_TYPE_ACTIVATABLE, "object", window, NULL);
+
+ peas_extension_set_call (window->priv->extensions, "activate");
+
+ g_signal_connect (window->priv->extensions,
+ "extension-added",
+ G_CALLBACK (on_extension_added),
+ window);
+ g_signal_connect (window->priv->extensions,
+ "extension-removed",
+ G_CALLBACK (on_extension_removed),
+ window);
/* set visibility of panes.
* This needs to be done after plugins activatation */
@@ -3954,7 +3988,7 @@ pluma_window_init (PlumaWindow *window)
*
* Gets the active #PlumaView.
*
- * Returns: the active #PlumaView
+ * Returns: (transfer none): the active #PlumaView
*/
PlumaView *
pluma_window_get_active_view (PlumaWindow *window)
@@ -3977,7 +4011,7 @@ pluma_window_get_active_view (PlumaWindow *window)
*
* Gets the active #PlumaDocument.
*
- * Returns: the active #PlumaDocument
+ * Returns: (transfer none): the active #PlumaDocument
*/
PlumaDocument *
pluma_window_get_active_document (PlumaWindow *window)
@@ -4009,7 +4043,7 @@ _pluma_window_get_notebook (PlumaWindow *window)
* Creates a new #PlumaTab and adds the new tab to the #PlumaNotebook.
* In case @jump_to is %TRUE the #PlumaNotebook switches to that new #PlumaTab.
*
- * Returns: a new #PlumaTab
+ * Returns: (transfer none): a new #PlumaTab
*/
PlumaTab *
pluma_window_create_tab (PlumaWindow *window,
@@ -4049,7 +4083,7 @@ pluma_window_create_tab (PlumaWindow *window,
* Whether @create is %TRUE, creates a new empty document if location does
* not refer to an existing file
*
- * Returns: a new #PlumaTab
+ * Returns: (transfer none): a new #PlumaTab
*/
PlumaTab *
pluma_window_create_tab_from_uri (PlumaWindow *window,
@@ -4093,7 +4127,7 @@ pluma_window_create_tab_from_uri (PlumaWindow *window,
*
* Gets the active #PlumaTab in the @window.
*
- * Returns: the active #PlumaTab in the @window.
+ * Returns: (transfer none): the active #PlumaTab in the @window.
*/
PlumaTab *
pluma_window_get_active_tab (PlumaWindow *window)
@@ -4303,7 +4337,7 @@ pluma_window_set_active_tab (PlumaWindow *window,
*
* Gets the #GtkWindowGroup in which @window resides.
*
- * Returns: the #GtkWindowGroup
+ * Returns: (transfer none): the #GtkWindowGroup
*/
GtkWindowGroup *
pluma_window_get_group (PlumaWindow *window)
@@ -4327,7 +4361,7 @@ _pluma_window_is_removing_tabs (PlumaWindow *window)
*
* Gets the #GtkUIManager associated with the @window.
*
- * Returns: the #GtkUIManager of the @window.
+ * Returns: (transfer none): the #GtkUIManager of the @window.
*/
GtkUIManager *
pluma_window_get_ui_manager (PlumaWindow *window)
@@ -4343,7 +4377,7 @@ pluma_window_get_ui_manager (PlumaWindow *window)
*
* Gets the side #PlumaPanel of the @window.
*
- * Returns: the side #PlumaPanel.
+ * Returns: (transfer none): the side #PlumaPanel.
*/
PlumaPanel *
pluma_window_get_side_panel (PlumaWindow *window)
@@ -4359,7 +4393,7 @@ pluma_window_get_side_panel (PlumaWindow *window)
*
* Gets the bottom #PlumaPanel of the @window.
*
- * Returns: the bottom #PlumaPanel.
+ * Returns: (transfer none): the bottom #PlumaPanel.
*/
PlumaPanel *
pluma_window_get_bottom_panel (PlumaWindow *window)
@@ -4375,7 +4409,7 @@ pluma_window_get_bottom_panel (PlumaWindow *window)
*
* Gets the #PlumaStatusbar of the @window.
*
- * Returns: the #PlumaStatusbar of the @window.
+ * Returns: (transfer none): the #PlumaStatusbar of the @window.
*/
GtkWidget *
pluma_window_get_statusbar (PlumaWindow *window)
@@ -4587,7 +4621,7 @@ _pluma_window_is_fullscreen (PlumaWindow *window)
*
* Gets the #PlumaTab that matches with the given @location.
*
- * Returns: the #PlumaTab that matches with the given @location.
+ * Returns: (transfer none): the #PlumaTab that matches with the given @location.
*/
PlumaTab *
pluma_window_get_tab_from_location (PlumaWindow *window,
@@ -4648,31 +4682,3 @@ pluma_window_get_message_bus (PlumaWindow *window)
return window->priv->message_bus;
}
-
-/**
- * pluma_window_get_tab_from_uri:
- * @window: a #PlumaWindow
- * @uri: the uri to get the #PlumaTab
- *
- * Gets the #PlumaTab that matches @uri.
- *
- * Returns: the #PlumaTab associated with @uri.
- *
- * Deprecated: 2.24: Use pluma_window_get_tab_from_location() instead.
- */
-PlumaTab *
-pluma_window_get_tab_from_uri (PlumaWindow *window,
- const gchar *uri)
-{
- GFile *f;
- PlumaTab *tab;
-
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- g_return_val_if_fail (uri != NULL, NULL);
-
- f = g_file_new_for_uri (uri);
- tab = pluma_window_get_tab_from_location (window, f);
- g_object_unref (f);
-
- return tab;
-}
diff --git a/pluma/pluma-window.h b/pluma/pluma-window.h
index 8baf2cb2..b90baa32 100644
--- a/pluma/pluma-window.h
+++ b/pluma/pluma-window.h
@@ -154,9 +154,6 @@ PlumaWindowState pluma_window_get_state (PlumaWindow *window);
PlumaTab *pluma_window_get_tab_from_location (PlumaWindow *window,
GFile *location);
-PlumaTab *pluma_window_get_tab_from_uri (PlumaWindow *window,
- const gchar *uri);
-
/* Message bus */
PlumaMessageBus *pluma_window_get_message_bus (PlumaWindow *window);
diff --git a/pluma/pluma.c b/pluma/pluma.c
index 4fb5a752..6f12a051 100644
--- a/pluma/pluma.c
+++ b/pluma/pluma.c
@@ -42,6 +42,10 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#ifdef HAVE_INTROSPECTION
+#include <girepository.h>
+#endif
+
#include "pluma-app.h"
#include "pluma-commands.h"
#include "pluma-debug.h"
@@ -519,10 +523,12 @@ main (int argc, char *argv[])
/* Setup command line options */
context = g_option_context_new (_("- Edit text files"));
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
- g_option_context_add_group (context, gtk_get_option_group (FALSE));
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
g_option_context_add_group (context, egg_sm_client_get_option_group ());
- gtk_init (&argc, &argv);
+#ifdef HAVE_INTROSPECTION
+ g_option_context_add_group (context, g_irepository_get_option_group ());
+#endif
if (!g_option_context_parse (context, &argc, &argv, &error))
{