[libpeas] Drop application-specific naming in the info file format.
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Drop application-specific naming in the info file format.
- Date: Sat, 2 Oct 2010 23:17:03 +0000 (UTC)
commit 8c6be99ec8d6b0ac2ce826e1d298c2cafc77ba94
Author: Steve Frécinaux <code istique net>
Date: Sat Oct 2 13:21:54 2010 +0200
Drop application-specific naming in the info file format.
There were previously two places where the application name were used
in the plugin info format:
- the file extension was .appname-plugin
- the INI section was [AppName Plugin]
This patch drop those and uses a more generic naming:
- the file extension is now .plugin
- the INI section is now [Plugin]
This makes one less (rather useless) value to provide to the engine,
and besides it is consistent with what others do in the same field
(Mozilla, for instance, uses a single .xpi extension for all the
applications using XPInstall).
https://bugzilla.gnome.org/show_bug.cgi?id=631165
libpeas/peas-engine.c | 61 ++-----------------
libpeas/peas-engine.h | 2 +-
libpeas/peas-plugin-info-priv.h | 1 -
libpeas/peas-plugin-info.c | 54 +++++++-----------
peas-demo/peas-demo.c | 2 +-
peas-demo/plugins/helloworld/Makefile.am | 2 +-
...elloworld.peasdemo-plugin => helloworld.plugin} | 2 +-
peas-demo/plugins/pythonhello/Makefile.am | 2 +-
...honhello.peasdemo-plugin => pythonhello.plugin} | 2 +-
peas-demo/plugins/secondtime/Makefile.am | 2 +-
...econdtime.peasdemo-plugin => secondtime.plugin} | 2 +-
peas-demo/plugins/seedhello/Makefile.am | 2 +-
...{seedhello.peasdemo-plugin => seedhello.plugin} | 2 +-
13 files changed, 38 insertions(+), 98 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index fa92e32..ef13770 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -69,7 +69,6 @@ static guint signals[LAST_SIGNAL];
/* Properties */
enum {
PROP_0,
- PROP_APP_NAME,
PROP_PLUGIN_LIST,
PROP_LOADED_PLUGINS
};
@@ -87,8 +86,6 @@ typedef struct _SearchPath {
} SearchPath;
struct _PeasEnginePrivate {
- gchar *app_name;
- gchar *file_ext;
GList *search_paths;
GList *plugin_list;
@@ -110,12 +107,14 @@ load_plugin_info (PeasEngine *engine,
const gchar *module_name;
info = _peas_plugin_info_new (filename,
- engine->priv->app_name,
module_dir,
data_dir);
if (info == NULL)
- return;
+ {
+ g_warning ("Error loading '%s'", filename);
+ return;
+ }
/* If a plugin with this name has already been loaded
* drop this one (user plugins override system plugins) */
@@ -136,7 +135,7 @@ load_dir_real (PeasEngine *engine,
GDir *d;
const gchar *dirent;
- g_debug ("Loading %s/*%s...", module_dir, engine->priv->file_ext);
+ g_debug ("Loading %s/*.plugin...", module_dir);
d = g_dir_open (module_dir, 0, &error);
@@ -151,7 +150,7 @@ load_dir_real (PeasEngine *engine,
{
gchar *filename = g_build_filename (module_dir, dirent, NULL);
- if (g_str_has_suffix (dirent, engine->priv->file_ext))
+ if (g_str_has_suffix (dirent, ".plugin"))
load_plugin_info (engine, filename, module_dir, data_dir);
else if (recursions > 0 && g_file_test (filename, G_FILE_TEST_IS_DIR))
@@ -340,20 +339,6 @@ peas_engine_garbage_collect (PeasEngine *engine)
NULL);
}
-static gchar *
-compute_file_extension (const gchar *app_name)
-{
- gchar *ext;
- guint i;
-
- /* Compute the extension of the plugin files. */
- ext = g_strdup_printf (".%s-plugin", app_name);
- for (i = 0; ext[i] != '\0'; ++i)
- ext[i] = g_ascii_tolower (ext[i]);
-
- return ext;
-}
-
static void
peas_engine_set_property (GObject *object,
guint prop_id,
@@ -364,10 +349,6 @@ peas_engine_set_property (GObject *object,
switch (prop_id)
{
- case PROP_APP_NAME:
- engine->priv->app_name = g_value_dup_string (value);
- engine->priv->file_ext = compute_file_extension (engine->priv->app_name);
- break;
case PROP_LOADED_PLUGINS:
peas_engine_set_loaded_plugins (engine,
(const gchar **) g_value_get_boxed (value));
@@ -388,9 +369,6 @@ peas_engine_get_property (GObject *object,
switch (prop_id)
{
- case PROP_APP_NAME:
- g_value_set_string (value, engine->priv->app_name);
- break;
case PROP_PLUGIN_LIST:
g_value_set_pointer (value,
(gpointer) peas_engine_get_plugin_list (engine));
@@ -439,8 +417,6 @@ peas_engine_finalize (GObject *object)
g_list_free (engine->priv->plugin_list);
g_list_free (engine->priv->search_paths);
- g_free (engine->priv->file_ext);
- g_free (engine->priv->app_name);
G_OBJECT_CLASS (peas_engine_parent_class)->finalize (object);
}
@@ -460,26 +436,6 @@ peas_engine_class_init (PeasEngineClass *klass)
klass->unload_plugin = peas_engine_unload_plugin_real;
/**
- * PeasEngine:app-name:
- *
- * The application name. Filename extension and section header for
- * #PeasPluginInfo files are actually derived from this value.
- *
- * For instance, if app-name is "Gedit", then info files will have
- * the .gedit-plugin extension, and the engine will look for a
- * "Gedit Plugin" section in it to load the plugin data.
- */
- g_object_class_install_property (object_class,
- PROP_APP_NAME,
- g_param_spec_string ("app-name",
- "Application Name",
- "The application name",
- "Peas",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
* PeasEngine:plugin-list:
*
* The list of found plugins.
@@ -1138,17 +1094,14 @@ peas_engine_set_loaded_plugins (PeasEngine *engine,
/**
* peas_engine_new:
- * @app_name: (allow-none): The name of the application
*
* Returns a new #PeasEngine object.
- * See the properties description for more information about the parameters.
*
* Returns: a newly created #PeasEngine object.
*/
PeasEngine *
-peas_engine_new (const gchar *app_name)
+peas_engine_new (void)
{
return PEAS_ENGINE (g_object_new (PEAS_TYPE_ENGINE,
- "app-name", app_name,
NULL));
}
diff --git a/libpeas/peas-engine.h b/libpeas/peas-engine.h
index 4a47405..1194b69 100644
--- a/libpeas/peas-engine.h
+++ b/libpeas/peas-engine.h
@@ -68,7 +68,7 @@ struct _PeasEngineClass {
};
GType peas_engine_get_type (void) G_GNUC_CONST;
-PeasEngine *peas_engine_new (const gchar *app_name);
+PeasEngine *peas_engine_new (void);
void peas_engine_add_search_path (PeasEngine *engine,
const gchar *plugin_dir,
diff --git a/libpeas/peas-plugin-info-priv.h b/libpeas/peas-plugin-info-priv.h
index ef4e6cf..6240e59 100644
--- a/libpeas/peas-plugin-info-priv.h
+++ b/libpeas/peas-plugin-info-priv.h
@@ -58,7 +58,6 @@ struct _PeasPluginInfo {
};
PeasPluginInfo *_peas_plugin_info_new (const gchar *filename,
- const gchar *app_name,
const gchar *module_dir,
const gchar *data_dir);
PeasPluginInfo *_peas_plugin_info_ref (PeasPluginInfo *info);
diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c
index eefab3a..5bc0a79 100644
--- a/libpeas/peas-plugin-info.c
+++ b/libpeas/peas-plugin-info.c
@@ -115,7 +115,6 @@ value_free (GValue *value)
static void
parse_extra_keys (PeasPluginInfo *info,
GKeyFile *plugin_file,
- const gchar *section_header,
const gchar **keys)
{
guint i;
@@ -143,13 +142,13 @@ parse_extra_keys (PeasPluginInfo *info,
g_str_equal (keys[i], "Builtin"))
continue;
- b = g_key_file_get_boolean (plugin_file, section_header, keys[i], &error);
+ b = g_key_file_get_boolean (plugin_file, "Plugin", keys[i], &error);
if (b == FALSE && error != NULL)
{
gchar *str;
g_error_free (error);
error = NULL;
- str = g_key_file_get_string (plugin_file, section_header, keys[i], NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", keys[i], NULL);
if (str != NULL)
{
value = g_new0 (GValue, 1);
@@ -181,7 +180,6 @@ parse_extra_keys (PeasPluginInfo *info,
/*
* _peas_plugin_info_new:
* @filename: The filename where to read the plugin information.
- * @app_name: The application name.
* @module_dir: The module directory.
* @data_dir: The data directory.
*
@@ -191,13 +189,11 @@ parse_extra_keys (PeasPluginInfo *info,
*/
PeasPluginInfo *
_peas_plugin_info_new (const gchar *filename,
- const gchar *app_name,
const gchar *module_dir,
const gchar *data_dir)
{
PeasPluginInfo *info;
GKeyFile *plugin_file = NULL;
- gchar *section_header;
gchar *str;
gchar **keys;
gint integer;
@@ -205,14 +201,11 @@ _peas_plugin_info_new (const gchar *filename,
GError *error = NULL;
g_return_val_if_fail (filename != NULL, NULL);
- g_return_val_if_fail (app_name != NULL, NULL);
info = g_new0 (PeasPluginInfo, 1);
info->refcount = 1;
info->file = g_strdup (filename);
- section_header = g_strdup_printf ("%s Plugin", app_name);
-
plugin_file = g_key_file_new ();
if (!g_key_file_load_from_file (plugin_file, filename, G_KEY_FILE_NONE, NULL))
{
@@ -220,14 +213,14 @@ _peas_plugin_info_new (const gchar *filename,
goto error;
}
- if (!g_key_file_has_key (plugin_file, section_header, "IAge", NULL))
+ if (!g_key_file_has_key (plugin_file, "Plugin", "IAge", NULL))
goto error;
- integer = g_key_file_get_integer (plugin_file, section_header, "IAge", NULL);
+ integer = g_key_file_get_integer (plugin_file, "Plugin", "IAge", NULL);
info->iage = integer <= 0 ? 0 : integer;
/* Get module name */
- str = g_key_file_get_string (plugin_file, section_header, "Module", NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", "Module", NULL);
if ((str != NULL) && (*str != '\0'))
{
@@ -241,13 +234,13 @@ _peas_plugin_info_new (const gchar *filename,
/* Get the dependency list */
info->dependencies = g_key_file_get_string_list (plugin_file,
- section_header,
+ "Plugin",
"Depends", NULL, NULL);
if (info->dependencies == NULL)
info->dependencies = g_new0 (gchar *, 1);
/* Get the loader for this plugin */
- str = g_key_file_get_string (plugin_file, section_header, "Loader", NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", "Loader", NULL);
if ((str != NULL) && (*str != '\0'))
{
@@ -260,8 +253,8 @@ _peas_plugin_info_new (const gchar *filename,
}
/* Get Name */
- str = g_key_file_get_locale_string (plugin_file,
- section_header, "Name", NULL, NULL);
+ str = g_key_file_get_locale_string (plugin_file, "Plugin",
+ "Name", NULL, NULL);
if (str)
info->name = str;
else
@@ -271,63 +264,59 @@ _peas_plugin_info_new (const gchar *filename,
}
/* Get Description */
- str = g_key_file_get_locale_string (plugin_file,
- section_header,
+ str = g_key_file_get_locale_string (plugin_file, "Plugin",
"Description", NULL, NULL);
if (str)
info->desc = str;
/* Get Icon */
- str = g_key_file_get_locale_string (plugin_file,
- section_header, "Icon", NULL, NULL);
+ str = g_key_file_get_locale_string (plugin_file, "Plugin",
+ "Icon", NULL, NULL);
if (str)
info->icon_name = str;
/* Get Authors */
- info->authors = g_key_file_get_string_list (plugin_file,
- section_header,
+ info->authors = g_key_file_get_string_list (plugin_file, "Plugin",
"Authors", NULL, NULL);
/* Get Copyright */
- str = g_key_file_get_string (plugin_file,
- section_header, "Copyright", NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", "Copyright", NULL);
if (str)
info->copyright = str;
/* Get Website */
- str = g_key_file_get_string (plugin_file, section_header, "Website", NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", "Website", NULL);
if (str)
info->website = str;
/* Get Version */
- str = g_key_file_get_string (plugin_file, section_header, "Version", NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", "Version", NULL);
if (str)
info->version = str;
/* Get Help URI */
- str = g_key_file_get_string (plugin_file, section_header, OS_HELP_KEY, NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", OS_HELP_KEY, NULL);
if (str)
info->help_uri = str;
else
{
- str = g_key_file_get_string (plugin_file, section_header, "Help", NULL);
+ str = g_key_file_get_string (plugin_file, "Plugin", "Help", NULL);
if (str)
info->help_uri = str;
}
/* Get Builtin */
- b = g_key_file_get_boolean (plugin_file, section_header, "Builtin", &error);
+ b = g_key_file_get_boolean (plugin_file, "Plugin", "Builtin", &error);
if (error != NULL)
g_clear_error (&error);
else
info->builtin = b;
/* Get extra keys */
- keys = g_key_file_get_keys (plugin_file, section_header, NULL, NULL);
- parse_extra_keys (info, plugin_file, section_header, (const gchar **) keys);
+ keys = g_key_file_get_keys (plugin_file, "Plugin", NULL, NULL);
+ parse_extra_keys (info, plugin_file, (const gchar **) keys);
g_strfreev (keys);
- g_free (section_header);
g_key_file_free (plugin_file);
info->module_dir = g_strdup (module_dir);
@@ -345,7 +334,6 @@ error:
g_free (info->name);
g_free (info->loader);
g_free (info);
- g_free (section_header);
g_key_file_free (plugin_file);
return NULL;
diff --git a/peas-demo/peas-demo.c b/peas-demo/peas-demo.c
index 264b468..55fcc6b 100644
--- a/peas-demo/peas-demo.c
+++ b/peas-demo/peas-demo.c
@@ -151,7 +151,7 @@ main (int argc,
g_irepository_require (g_irepository_get_default (), "PeasGtk", "1.0", 0, NULL);
- engine = peas_engine_new ("PeasDemo");
+ engine = peas_engine_new ();
plugin_dir = g_build_filename (g_get_user_config_dir (), "peas-demo/plugins", NULL);
peas_engine_add_search_path (engine, plugin_dir, plugin_dir);
diff --git a/peas-demo/plugins/helloworld/Makefile.am b/peas-demo/plugins/helloworld/Makefile.am
index da6db19..a7b151c 100644
--- a/peas-demo/plugins/helloworld/Makefile.am
+++ b/peas-demo/plugins/helloworld/Makefile.am
@@ -16,6 +16,6 @@ libhelloworld_la_SOURCES = \
libhelloworld_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
libhelloworld_la_LIBADD = $(PEAS_LIBS) $(PEAS_GTK_LIBS)
-plugin_DATA = helloworld.peasdemo-plugin
+plugin_DATA = helloworld.plugin
EXTRA_DIST = $(plugin_DATA)
diff --git a/peas-demo/plugins/helloworld/helloworld.peasdemo-plugin b/peas-demo/plugins/helloworld/helloworld.plugin
similarity index 93%
rename from peas-demo/plugins/helloworld/helloworld.peasdemo-plugin
rename to peas-demo/plugins/helloworld/helloworld.plugin
index 65fa56b..f24dfaf 100644
--- a/peas-demo/plugins/helloworld/helloworld.peasdemo-plugin
+++ b/peas-demo/plugins/helloworld/helloworld.plugin
@@ -1,4 +1,4 @@
-[PeasDemo Plugin]
+[Plugin]
Module=helloworld
IAge=2
Name=Hello World
diff --git a/peas-demo/plugins/pythonhello/Makefile.am b/peas-demo/plugins/pythonhello/Makefile.am
index ba08e5e..d488628 100644
--- a/peas-demo/plugins/pythonhello/Makefile.am
+++ b/peas-demo/plugins/pythonhello/Makefile.am
@@ -3,6 +3,6 @@ plugindir = $(libdir)/peas-demo/plugins/pythonhello
plugin_PYTHON = \
pythonhello.py
-plugin_DATA = pythonhello.peasdemo-plugin
+plugin_DATA = pythonhello.plugin
EXTRA_DIST = $(plugin_DATA)
diff --git a/peas-demo/plugins/pythonhello/pythonhello.peasdemo-plugin b/peas-demo/plugins/pythonhello/pythonhello.plugin
similarity index 96%
rename from peas-demo/plugins/pythonhello/pythonhello.peasdemo-plugin
rename to peas-demo/plugins/pythonhello/pythonhello.plugin
index 6318953..aa5b3f2 100644
--- a/peas-demo/plugins/pythonhello/pythonhello.peasdemo-plugin
+++ b/peas-demo/plugins/pythonhello/pythonhello.plugin
@@ -1,4 +1,4 @@
-[PeasDemo Plugin]
+[Plugin]
Module=pythonhello
Loader=python
IAge=2
diff --git a/peas-demo/plugins/secondtime/Makefile.am b/peas-demo/plugins/secondtime/Makefile.am
index 0149e8f..a20e76c 100644
--- a/peas-demo/plugins/secondtime/Makefile.am
+++ b/peas-demo/plugins/secondtime/Makefile.am
@@ -14,6 +14,6 @@ libsecondtime_la_SOURCES = \
libsecondtime_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
libsecondtime_la_LIBADD = $(PEAS_LIBS) $(PEAS_GTK_LIBS)
-plugin_DATA = secondtime.peasdemo-plugin
+plugin_DATA = secondtime.plugin
EXTRA_DIST = $(plugin_DATA)
diff --git a/peas-demo/plugins/secondtime/secondtime.peasdemo-plugin b/peas-demo/plugins/secondtime/secondtime.plugin
similarity index 93%
rename from peas-demo/plugins/secondtime/secondtime.peasdemo-plugin
rename to peas-demo/plugins/secondtime/secondtime.plugin
index 22c798e..8509afa 100644
--- a/peas-demo/plugins/secondtime/secondtime.peasdemo-plugin
+++ b/peas-demo/plugins/secondtime/secondtime.plugin
@@ -1,4 +1,4 @@
-[PeasDemo Plugin]
+[Plugin]
Module=secondtime
Depends=helloworld
IAge=2
diff --git a/peas-demo/plugins/seedhello/Makefile.am b/peas-demo/plugins/seedhello/Makefile.am
index 640b84c..7180673 100644
--- a/peas-demo/plugins/seedhello/Makefile.am
+++ b/peas-demo/plugins/seedhello/Makefile.am
@@ -2,6 +2,6 @@ plugindir = $(libdir)/peas-demo/plugins/seedhello
plugin_DATA = \
seedhello.js \
- seedhello.peasdemo-plugin
+ seedhello.plugin
EXTRA_DIST = $(plugin_DATA)
diff --git a/peas-demo/plugins/seedhello/seedhello.peasdemo-plugin b/peas-demo/plugins/seedhello/seedhello.plugin
similarity index 93%
rename from peas-demo/plugins/seedhello/seedhello.peasdemo-plugin
rename to peas-demo/plugins/seedhello/seedhello.plugin
index 7b4a6f5..86c63c0 100644
--- a/peas-demo/plugins/seedhello/seedhello.peasdemo-plugin
+++ b/peas-demo/plugins/seedhello/seedhello.plugin
@@ -1,4 +1,4 @@
-[PeasDemo Plugin]
+[Plugin]
Module=seedhello
Loader=seed
IAge=2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]