[libpeas] Replaced invisible plugins with builtin plugins



commit 7d4e464c00168caa4893185a12e45af1b80c99a2
Author: Garrett Regier <alias301 gmail com>
Date:   Wed Jul 14 01:23:58 2010 -0700

    Replaced invisible plugins with builtin plugins
    
    "Visible" plugins are replaced by "builtin" ones. The "builtin" value
    is read from the plugin info file.
    
    A builtin plugin has the same behaviour as previous invisible plugins:
    they cannot be enabled or disabled by the user, and they are hidden in
    the plugin manager. The application can still do what it wants with
    builtin plugins, as libpeas doesn't handle autoloading them.
    
    It means that totem can drop the "set visibility" code and just load the
    plugin straight away when a "builtin" plugin is found. It also means
    that anjuta can handle loading and unloading them as required.
    
    A later patch is planned to introduces a "show-builtins" property in
    the plugin manager, effectively allowing to show or hide those plugins
    without the weird "show-invisible" naming.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=621858

 libpeas/peas-plugin-info-priv.h |    3 +-
 libpeas/peas-plugin-info.c      |   65 +++++++++++++++++----------------------
 libpeas/peas-plugin-info.h      |    4 +--
 3 files changed, 31 insertions(+), 41 deletions(-)
---
diff --git a/libpeas/peas-plugin-info-priv.h b/libpeas/peas-plugin-info-priv.h
index a54c4d7..10de82c 100644
--- a/libpeas/peas-plugin-info-priv.h
+++ b/libpeas/peas-plugin-info-priv.h
@@ -45,7 +45,6 @@ struct _PeasPluginInfo {
   gchar *website;
   gchar *version;
   guint iage;
-  gboolean visible;
   GHashTable *keys;
 
   gint loaded : 1;
@@ -53,6 +52,8 @@ struct _PeasPluginInfo {
      due to an error loading the plugin module (e.g. for Python plugins
      when the interpreter has not been correctly initializated) */
   gint available : 1;
+
+  guint builtin : 1;
 };
 
 PeasPluginInfo *_peas_plugin_info_new   (const gchar    *filename,
diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c
index 4fca6f0..540ab10 100644
--- a/libpeas/peas-plugin-info.c
+++ b/libpeas/peas-plugin-info.c
@@ -123,7 +123,8 @@ parse_extra_keys (PeasPluginInfo   *info,
           g_str_equal (keys[i], "Authors") ||
           g_str_equal (keys[i], "Copyright") ||
           g_str_equal (keys[i], "Website") ||
-          g_str_equal (keys[i], "Version"))
+          g_str_equal (keys[i], "Version") ||
+          g_str_equal (keys[i], "Builtin"))
         continue;
 
       b = g_key_file_get_boolean (plugin_file, section_header, keys[i], &error);
@@ -184,13 +185,14 @@ _peas_plugin_info_new (const gchar *filename,
   gchar *str;
   gchar **keys;
   gint integer;
+  gboolean b;
+  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->visible = TRUE;
   info->file = g_strdup (filename);
 
   section_header = g_strdup_printf ("%s Plugin", app_name);
@@ -286,6 +288,13 @@ _peas_plugin_info_new (const gchar *filename,
   if (str)
     info->version = str;
 
+  /* Get Builtin */
+  b = g_key_file_get_boolean (plugin_file, section_header, "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);
@@ -350,6 +359,23 @@ peas_plugin_info_is_available (const PeasPluginInfo *info)
 }
 
 /**
+ * peas_plugin_info_is_builtin:
+ * @info: A #PeasPluginInfo.
+ *
+ * Gets is the plugin is a builtin plugin.
+ *
+ * Returns: %TRUE if the plugin is a builtin plugin, %FALSE
+ * if not.
+ **/
+gboolean
+peas_plugin_info_is_builtin (const PeasPluginInfo *info)
+{
+  g_return_val_if_fail (info != NULL, TRUE);
+
+  return info->builtin;
+}
+
+/**
  * peas_plugin_info_get_module_name:
  * @info: A #PeasPluginInfo.
  *
@@ -529,38 +555,3 @@ peas_plugin_info_get_keys (const PeasPluginInfo *info)
 
   return info->keys;
 }
-
-/**
- * peas_plugin_info_set_visible:
- * @info: A #PeasPluginInfo.
- * @visible: visibility of the plugin
- *
- * Sets whether the plugin should be visible in the
- * plugin manager.
- *
- **/
-void
-peas_plugin_info_set_visible (PeasPluginInfo *info,
-                              gboolean        visible)
-{
-  g_return_if_fail (info != NULL);
-
-  info->visible = visible;
-}
-
-/**
- * peas_plugin_info_get_visible:
- * @info: A #PeasPluginInfo.
- *
- * Gets the visibility of the plugin.
- *
- * Returns: %TRUE if the plugin should be visible, %FALSE
- * if not.
- **/
-gboolean
-peas_plugin_info_get_visible (const PeasPluginInfo *info)
-{
-  g_return_val_if_fail (info != NULL, TRUE);
-
-  return info->visible;
-}
diff --git a/libpeas/peas-plugin-info.h b/libpeas/peas-plugin-info.h
index c00a8e4..1a47ee3 100644
--- a/libpeas/peas-plugin-info.h
+++ b/libpeas/peas-plugin-info.h
@@ -41,6 +41,7 @@ GType         peas_plugin_info_get_type         (void) G_GNUC_CONST;
 
 gboolean      peas_plugin_info_is_loaded        (const PeasPluginInfo *info);
 gboolean      peas_plugin_info_is_available     (const PeasPluginInfo *info);
+gboolean      peas_plugin_info_is_builtin       (const PeasPluginInfo *info);
 
 const gchar  *peas_plugin_info_get_module_name  (const PeasPluginInfo *info);
 const gchar  *peas_plugin_info_get_module_dir   (const PeasPluginInfo *info);
@@ -56,9 +57,6 @@ const gchar  *peas_plugin_info_get_version      (const PeasPluginInfo *info);
 gint          peas_plugin_info_get_iage         (const PeasPluginInfo *info);
 const GHashTable *
               peas_plugin_info_get_keys         (const PeasPluginInfo *info);
-void          peas_plugin_info_set_visible      (PeasPluginInfo       *info,
-                                                 gboolean              visible);
-gboolean      peas_plugin_info_get_visible      (const PeasPluginInfo *info);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]