Commit 3d643fa8 authored by Sebastien Granjoux's avatar Sebastien Granjoux

libanjuta: Replace AnjutaPluginDescription by AnjutaPluginHandle in API

parent 4853cd7e
This diff is collapsed.
......@@ -23,7 +23,7 @@
#include <glib-object.h>
#include <libanjuta/anjuta-status.h>
#include <libanjuta/anjuta-plugin-description.h>
#include <libanjuta/anjuta-plugin-handle.h>
G_BEGIN_DECLS
......@@ -57,10 +57,10 @@ struct _AnjutaPluginManagerClass
/* Signals */
void(* plugin_activated) (AnjutaPluginManager *self,
AnjutaPluginDescription* plugin_desc,
AnjutaPluginHandle* handle,
GObject *plugin);
void(* plugin_deactivated) (AnjutaPluginManager *self,
AnjutaPluginDescription* plugin_desc,
AnjutaPluginHandle* handle,
GObject *plugin);
};
......@@ -81,12 +81,12 @@ gboolean anjuta_plugin_manager_is_active_plugin (AnjutaPluginManager *plugin_man
const gchar *iface_name);
GObject* anjuta_plugin_manager_get_plugin (AnjutaPluginManager *plugin_manager,
const gchar *iface_name);
GObject* anjuta_plugin_manager_get_plugin_by_id (AnjutaPluginManager *plugin_manager,
const gchar *plugin_id);
GObject* anjuta_plugin_manager_get_plugin_by_handle (AnjutaPluginManager *plugin_manager,
AnjutaPluginHandle *handle);
gboolean anjuta_plugin_manager_unload_plugin (AnjutaPluginManager *plugin_manager,
GObject *plugin_object);
gboolean anjuta_plugin_manager_unload_plugin_by_id (AnjutaPluginManager *plugin_manager,
const gchar *plugin_id);
gboolean anjuta_plugin_manager_unload_plugin_by_handle (AnjutaPluginManager *plugin_manager,
AnjutaPluginHandle *handle);
GList* anjuta_plugin_manager_get_active_plugins (AnjutaPluginManager *plugin_manager);
GList* anjuta_plugin_manager_get_active_plugin_objects (AnjutaPluginManager *plugin_manager);
......@@ -107,20 +107,20 @@ GList* anjuta_plugin_manager_list_query (AnjutaPluginManager *plugin_manager,
GList *attribute_values);
/* Returns the plugin description that has been selected from the list */
AnjutaPluginDescription* anjuta_plugin_manager_select (AnjutaPluginManager *plugin_manager,
gchar *title, gchar *description,
GList *plugin_descriptions);
AnjutaPluginHandle* anjuta_plugin_manager_select (AnjutaPluginManager *plugin_manager,
gchar *title, gchar *description,
GList *plugin_handles);
GObject* anjuta_plugin_manager_select_and_activate (AnjutaPluginManager *plugin_manager,
gchar *title, gchar *description,
GList *plugin_descriptions);
gchar *title, gchar *description,
GList *plugin_handles);
AnjutaPluginDescription* anjuta_plugin_manager_get_plugin_description (AnjutaPluginManager *plugin_manager,
GObject *plugin);
AnjutaPluginHandle* anjuta_plugin_manager_get_plugin_handle (AnjutaPluginManager *plugin_manager,
GObject *plugin);
void anjuta_plugin_manager_activate_plugins (AnjutaPluginManager *plugin_manager,
GList *plugin_descs);
GList *plugin_handles);
void anjuta_plugin_manager_unload_all_plugins (AnjutaPluginManager *plugin_manager);
......
......@@ -71,7 +71,7 @@ static guint profile_manager_signals[LAST_SIGNAL] = { 0 };
static void
on_plugin_activated (AnjutaPluginManager *plugin_manager,
AnjutaPluginDescription *plugin_desc,
AnjutaPluginHandle *plugin_handle,
GObject *plugin_object,
AnjutaProfileManager *profile_manager)
{
......@@ -82,18 +82,20 @@ on_plugin_activated (AnjutaPluginManager *plugin_manager,
{
/* Add it current profile */
gboolean exclude;
AnjutaPluginDescription *desc;
if (!anjuta_plugin_description_get_boolean (plugin_desc, "Anjuta Plugin", "ExcludeFromSession", &exclude) || !exclude)
desc = anjuta_plugin_handle_get_description (plugin_handle);
if (!anjuta_plugin_description_get_boolean (desc, "Anjuta Plugin", "ExcludeFromSession", &exclude) || !exclude)
{
anjuta_profile_add_plugin (ANJUTA_PROFILE (priv->profiles->data),
plugin_desc);
plugin_handle);
}
}
}
static void
on_plugin_deactivated (AnjutaPluginManager *plugin_manager,
AnjutaPluginDescription *plugin_desc,
AnjutaPluginHandle *plugin_handle,
GObject *plugin_object,
AnjutaProfileManager *profile_manager)
{
......@@ -104,7 +106,7 @@ on_plugin_deactivated (AnjutaPluginManager *plugin_manager,
{
/* Remove from current profile */
anjuta_profile_remove_plugin (ANJUTA_PROFILE (priv->profiles->data),
plugin_desc);
plugin_handle);
}
}
......@@ -359,18 +361,11 @@ anjuta_profile_manager_load_profile (AnjutaProfileManager *profile_manager,
node = plugins_to_deactivate;
while (node)
{
AnjutaPluginDescription *desc;
gchar *plugin_id = NULL;
desc = (AnjutaPluginDescription *)node->data;
anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
"Location", &plugin_id);
g_assert (plugin_id != NULL);
/* DEBUG_PRINT ("Profile: deactivating %s", plugin_id); */
AnjutaPluginHandle *handle;
anjuta_plugin_manager_unload_plugin_by_id (priv->plugin_manager,
plugin_id);
handle = (AnjutaPluginHandle *)node->data;
anjuta_plugin_manager_unload_plugin_by_handle (priv->plugin_manager,
handle);
node = g_list_next (node);
}
......
......@@ -213,13 +213,13 @@ anjuta_profile_get_property (GObject *object, guint prop_id,
static void
anjuta_profile_plugin_added (AnjutaProfile *self,
AnjutaPluginDescription *plugin)
AnjutaPluginHandle *plugin)
{
}
static void
anjuta_profile_plugin_removed (AnjutaProfile *self,
AnjutaPluginDescription *plugin)
AnjutaPluginHandle *plugin)
{
}
......@@ -289,7 +289,7 @@ anjuta_profile_class_init (AnjutaProfileClass *klass)
/**
* AnjutaProfile::plugin-added:
* @profile: a #AnjutaProfile object.
* @plugin: the new plugin as a #AnjutaPluginDescription.
* @plugin: the new plugin as a #AnjutaPluginHandle.
*
* Emitted when a plugin is added in the list.
*/
......@@ -306,7 +306,7 @@ anjuta_profile_class_init (AnjutaProfileClass *klass)
/**
* AnjutaProfile::plugin-removed:
* @profile: a #AnjutaProfile object.
* @plugin: the removed plugin as a #AnjutaPluginDescription.
* @plugin: the removed plugin as a #AnjutaPluginHandle.
*
* Emitted when a plugin is removed from the list.
*/
......@@ -437,13 +437,13 @@ anjuta_profile_get_name (AnjutaProfile *profile)
/**
* anjuta_profile_add_plugin:
* @profile: a #AnjutaProfile object.
* @plugin: a #AnjutaPluginDescription.
* @plugin: a #AnjutaPluginHandle.
*
* Add one plugin into the profile plugin list.
*/
void
anjuta_profile_add_plugin (AnjutaProfile *profile,
AnjutaPluginDescription *plugin)
AnjutaPluginHandle *plugin)
{
AnjutaProfilePriv *priv;
g_return_if_fail (ANJUTA_IS_PROFILE (profile));
......@@ -460,13 +460,13 @@ anjuta_profile_add_plugin (AnjutaProfile *profile,
/**
* anjuta_profile_remove_plugin:
* @profile: a #AnjutaProfile object.
* @plugin: a #AnjutaPluginDescription.
* @plugin: a #AnjutaPluginHandle.
*
* Remove one plugin from the profile plugin list.
*/
void
anjuta_profile_remove_plugin (AnjutaProfile *profile,
AnjutaPluginDescription *plugin)
AnjutaPluginHandle *plugin)
{
AnjutaProfilePriv *priv;
g_return_if_fail (ANJUTA_IS_PROFILE (profile));
......@@ -483,7 +483,7 @@ anjuta_profile_remove_plugin (AnjutaProfile *profile,
/**
* anjuta_profile_has_plugin:
* @profile: a #AnjutaProfile object
* @plugin: a #AnjutaPluginDescription
* @plugin: a #AnjutaPluginHandle
*
* Check if a plugin is included in the profile plugin list.
*
......@@ -491,7 +491,7 @@ anjuta_profile_remove_plugin (AnjutaProfile *profile,
*/
gboolean
anjuta_profile_has_plugin (AnjutaProfile *profile,
AnjutaPluginDescription *plugin)
AnjutaPluginHandle *plugin)
{
AnjutaProfilePriv *priv;
g_return_val_if_fail (ANJUTA_IS_PROFILE (profile), FALSE);
......@@ -520,10 +520,10 @@ anjuta_profile_get_plugins (AnjutaProfile *profile)
static GList*
anjuta_profile_select_plugins (AnjutaProfile *profile,
GList *descs_list)
GList *handles_list)
{
GList *selected_plugins = NULL;
GList *node = descs_list;
GList *node = handles_list;
AnjutaProfilePriv *priv;
priv = profile->priv;
......@@ -537,13 +537,13 @@ anjuta_profile_select_plugins (AnjutaProfile *profile,
}
else
{
AnjutaPluginDescription* d;
d = anjuta_plugin_manager_select (priv->plugin_manager,
_("Select a plugin"),
_("Please select a plugin from the list"),
descs);
if (d)
selected_plugins = g_list_prepend (selected_plugins, d);
AnjutaPluginHandle* handle;
handle = anjuta_plugin_manager_select (priv->plugin_manager,
_("Select a plugin"),
_("Please select a plugin from the list"),
descs);
if (handle)
selected_plugins = g_list_prepend (selected_plugins, handle);
}
node = g_list_next (node);
}
......@@ -558,7 +558,7 @@ anjuta_profile_read_plugins_from_xml (AnjutaProfile *profile,
gchar *read_buf;
gsize size;
xmlDocPtr xml_doc;
GList *descs_list = NULL;
GList *handles_list = NULL;
GList *not_found_names = NULL;
GList *not_found_urls = NULL;
gboolean parse_error;
......@@ -666,16 +666,16 @@ anjuta_profile_read_plugins_from_xml (AnjutaProfile *profile,
}
else
{
GList *plugin_descs;
GList *plugin_handles;
plugin_descs =
plugin_handles =
anjuta_plugin_manager_list_query (profile->priv->plugin_manager,
groups,
attribs,
values);
if (plugin_descs)
if (plugin_handles)
{
descs_list = g_list_prepend (descs_list, plugin_descs);
handles_list = g_list_prepend (handles_list, plugin_handles);
}
else if (mandatory)
{
......@@ -709,9 +709,9 @@ anjuta_profile_read_plugins_from_xml (AnjutaProfile *profile,
uri);
g_free (uri);
g_list_foreach (descs_list, (GFunc)g_list_free, NULL);
g_list_free (descs_list);
descs_list = NULL;
g_list_foreach (handles_list, (GFunc)g_list_free, NULL);
g_list_free (handles_list);
handles_list = NULL;
}
else if (not_found_names)
{
......@@ -744,16 +744,16 @@ anjuta_profile_read_plugins_from_xml (AnjutaProfile *profile,
g_free (uri);
g_string_free (mesg, TRUE);
g_list_foreach (descs_list, (GFunc)g_list_free, NULL);
g_list_free (descs_list);
descs_list = NULL;
g_list_foreach (handles_list, (GFunc)g_list_free, NULL);
g_list_free (handles_list);
handles_list = NULL;
}
g_list_foreach (not_found_names, (GFunc)g_free, NULL);
g_list_free (not_found_names);
g_list_foreach (not_found_urls, (GFunc)g_free, NULL);
g_list_free (not_found_urls);
return descs_list;
return handles_list;
}
/**
......@@ -774,24 +774,24 @@ anjuta_profile_add_plugins_from_xml (AnjutaProfile *profile,
GError **error)
{
AnjutaProfilePriv *priv;
GList *descs_list = NULL;
GList *handles_list = NULL;
g_return_val_if_fail (ANJUTA_IS_PROFILE (profile), FALSE);
priv = profile->priv;
descs_list = anjuta_profile_read_plugins_from_xml (profile, profile_xml_file, error);
handles_list = anjuta_profile_read_plugins_from_xml (profile, profile_xml_file, error);
if (descs_list)
if (handles_list)
{
GList *selected_plugins = NULL;
GList *node;
/* Now everything okay. Select the plugins */
descs_list = g_list_reverse (descs_list);
handles_list = g_list_reverse (handles_list);
selected_plugins =
anjuta_profile_select_plugins (profile, descs_list);
g_list_foreach (descs_list, (GFunc)g_list_free, NULL);
g_list_free (descs_list);
anjuta_profile_select_plugins (profile, handles_list);
g_list_foreach (handles_list, (GFunc)g_list_free, NULL);
g_list_free (handles_list);
node = selected_plugins;
while (node)
......@@ -814,7 +814,7 @@ anjuta_profile_add_plugins_from_xml (AnjutaProfile *profile,
g_list_free (selected_plugins);
}
return descs_list != NULL;
return handles_list != NULL;
}
/**
......@@ -838,6 +838,7 @@ anjuta_profile_to_xml (AnjutaProfile *profile)
str = g_string_new ("<?xml version=\"1.0\"?>\n<anjuta>\n");
for (node = priv->plugins; node != NULL; node = g_list_next (node))
{
AnjutaPluginHandle *handle;
AnjutaPluginDescription *desc;
gboolean user_activatable = TRUE;
gchar *name = NULL, *plugin_id = NULL;
......@@ -847,8 +848,8 @@ anjuta_profile_to_xml (AnjutaProfile *profile)
/* Do not save plugin in the exclude list */
continue;
}
desc = (AnjutaPluginDescription *)node->data;
handle = (AnjutaPluginHandle *)node->data;
desc = anjuta_plugin_handle_get_description(handle);
if (anjuta_plugin_description_get_boolean (desc, "Anjuta Plugin",
"UserActivatable", &user_activatable)
&& !user_activatable)
......
......@@ -23,7 +23,7 @@
#include <glib-object.h>
#include <gio/gio.h>
#include <libanjuta/anjuta-plugin-description.h>
#include <libanjuta/anjuta-plugin-handle.h>
#include <libanjuta/anjuta-plugin-manager.h>
G_BEGIN_DECLS
......@@ -68,9 +68,9 @@ struct _AnjutaProfileClass
/* Signals */
void(* plugin_added) (AnjutaProfile *self,
AnjutaPluginDescription *plugin);
AnjutaPluginHandle *plugin);
void(* plugin_removed) (AnjutaProfile *self,
AnjutaPluginDescription *plugin);
AnjutaPluginHandle *plugin);
void(* changed) (AnjutaProfile *self, GList *plugins);
void(* descoped) (AnjutaProfile *self);
void(* scoped) (AnjutaProfile *self);
......@@ -94,15 +94,15 @@ AnjutaProfile* anjuta_profile_new (const gchar *name,
AnjutaPluginManager *plugin_manager);
const gchar *anjuta_profile_get_name (AnjutaProfile *profile);
void anjuta_profile_add_plugin (AnjutaProfile *profile,
AnjutaPluginDescription *plugin);
AnjutaPluginHandle *plugin);
void anjuta_profile_remove_plugin (AnjutaProfile *profile,
AnjutaPluginDescription *plugin);
AnjutaPluginHandle *plugin);
gboolean anjuta_profile_add_plugins_from_xml (AnjutaProfile *profile,
GFile* profile_xml_file,
gboolean exclude_from_sync,
GError **error);
gboolean anjuta_profile_has_plugin (AnjutaProfile *profile,
AnjutaPluginDescription *plugin);
AnjutaPluginHandle *plugin);
GList* anjuta_profile_get_plugins (AnjutaProfile *profile);
void anjuta_profile_set_sync_file (AnjutaProfile *profile,
......
......@@ -486,8 +486,8 @@ static gboolean
dma_debugger_activate_plugin (DmaDebuggerQueue* self, const gchar *mime_type)
{
AnjutaPluginManager *plugin_manager;
AnjutaPluginDescription *plugin;
GList *descs = NULL;
AnjutaPluginHandle *plugin;
GList *plugins = NULL;
gchar *value;
/* Get list of debugger plugins */
......@@ -495,19 +495,19 @@ dma_debugger_activate_plugin (DmaDebuggerQueue* self, const gchar *mime_type)
if (mime_type == NULL)
{
/* User has to select the right debugger */
descs = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin","Interfaces", "IAnjutaDebugger", NULL);
plugins = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin","Interfaces", "IAnjutaDebugger", NULL);
}
else
{
/* Propose only debugger supporting correct mime type */
descs = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin","Interfaces", "IAnjutaDebugger",
"File Loader", "SupportedMimeTypes", mime_type,
NULL);
plugins = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin","Interfaces", "IAnjutaDebugger",
"File Loader", "SupportedMimeTypes", mime_type,
NULL);
}
if (descs == NULL)
if (plugins == NULL)
{
/* No plugin found */
anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (self->plugin)->shell),
......@@ -515,29 +515,24 @@ dma_debugger_activate_plugin (DmaDebuggerQueue* self, const gchar *mime_type)
return FALSE;
}
else if (g_list_length (descs) == 1)
else if (g_list_length (plugins) == 1)
{
/* Only one plugin found, use it */
plugin = (AnjutaPluginDescription *)descs->data;
plugin = (AnjutaPluginHandle *)plugins->data;
}
else
{
/* Ask the user to select one plugin */
plugin = anjuta_plugin_manager_select (plugin_manager,
_("Select a plugin"),
_("Please select a plugin to activate"),
descs);
_("Select a plugin"),
_("Please select a plugin to activate"),
plugins);
}
if (plugin != NULL)
{
/* Get debugger location */
value = NULL;
anjuta_plugin_description_get_string (plugin, "Anjuta Plugin", "Location", &value);
g_return_val_if_fail (value != NULL, FALSE);
/* Get debugger interface */
self->debugger = (IAnjutaDebugger *)anjuta_plugin_manager_get_plugin_by_id (plugin_manager, value);
self->debugger = (IAnjutaDebugger *)anjuta_plugin_manager_get_plugin_by_handle (plugin_manager, plugin);
self->support = 0;
/* Check if register interface is available */
......@@ -554,8 +549,6 @@ dma_debugger_activate_plugin (DmaDebuggerQueue* self, const gchar *mime_type)
}
/* Check if variable interface is available */
self->support |= IANJUTA_IS_DEBUGGER_VARIABLE(self->debugger) ? HAS_VARIABLE : 0;
g_free (value);
return TRUE;
}
......
......@@ -1060,20 +1060,20 @@ on_support_plugin_deactivated (AnjutaPlugin* plugin, DocmanPlugin* docman_plugin
}
static GList*
load_new_support_plugins (DocmanPlugin* docman_plugin, GList* new_plugin_ids,
load_new_support_plugins (DocmanPlugin* docman_plugin, GList* new_plugin_handle,
AnjutaPluginManager* plugin_manager)
{
GList* node;
GList* needed_plugins = NULL;
for (node = new_plugin_ids; node != NULL; node = g_list_next (node))
for (node = new_plugin_handle; node != NULL; node = g_list_next (node))
{
gchar* plugin_id = node->data;
GObject* new_plugin = anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
plugin_id);
AnjutaPluginHandle *handle = (AnjutaPluginHandle *)node->data;
GObject* new_plugin = anjuta_plugin_manager_get_plugin_by_handle (plugin_manager,
handle);
GList* item = g_list_find (docman_plugin->support_plugins, new_plugin);
if (!item)
{
DEBUG_PRINT ("Loading plugin: %s", plugin_id);
DEBUG_PRINT ("Loading plugin: %s", anjuta_plugin_handle_get_id (handle));
g_signal_connect (new_plugin, "deactivated",
G_CALLBACK (on_support_plugin_deactivated), docman_plugin);
}
......@@ -1113,7 +1113,7 @@ update_language_plugin (AnjutaDocman *docman, IAnjutaDocument *doc,
{
AnjutaPluginManager *plugin_manager;
IAnjutaLanguage *lang_manager;
GList *new_support_plugins, *support_plugin_descs, *needed_plugins, *node;
GList *new_support_plugins, *needed_plugins, *node;
const gchar *language;
lang_manager = anjuta_shell_get_interface (plugin->shell,
......@@ -1139,26 +1139,13 @@ update_language_plugin (AnjutaDocman *docman, IAnjutaDocument *doc,
/* Load current language editor support plugins */
plugin_manager = anjuta_shell_get_plugin_manager (plugin->shell, NULL);
support_plugin_descs = anjuta_plugin_manager_query (plugin_manager,
new_support_plugins = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin",
"Interfaces",
"IAnjutaLanguageSupport",
"Language Support",
"Languages",
language, NULL);
new_support_plugins = NULL;
for (node = support_plugin_descs; node != NULL; node = g_list_next (node))
{
gchar *plugin_id;
AnjutaPluginDescription *desc = node->data;
anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Location",
&plugin_id);
new_support_plugins = g_list_append (new_support_plugins, plugin_id);
}
g_list_free (support_plugin_descs);
/* Load new plugins */
needed_plugins =
......@@ -1172,7 +1159,7 @@ update_language_plugin (AnjutaDocman *docman, IAnjutaDocument *doc,
g_list_free (docman_plugin->support_plugins);
docman_plugin->support_plugins = needed_plugins;
anjuta_util_glist_strings_free (new_support_plugins);
g_list_free (new_support_plugins);
}
else
{
......
......@@ -48,8 +48,10 @@ sort_wizards(gconstpointer wizard1, gconstpointer wizard2)
{
gchar* name1 = NULL, *name2 = NULL;
gint ret;
AnjutaPluginDescription* desc1 = (AnjutaPluginDescription*) wizard1;
AnjutaPluginDescription* desc2 = (AnjutaPluginDescription*) wizard2;
AnjutaPluginHandle* handle1 = (AnjutaPluginHandle*) wizard1;
AnjutaPluginHandle* handle2 = (AnjutaPluginHandle*) wizard2;
AnjutaPluginDescription* desc1 = anjuta_plugin_handle_get_description (handle1);
AnjutaPluginDescription* desc2 = anjuta_plugin_handle_get_description (handle2);
if ((anjuta_plugin_description_get_locale_string (desc1, "Wizard",
"Title", &name1) ||
......@@ -129,7 +131,7 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
const gchar *mime_type)
{
AnjutaPluginManager *plugin_manager;
GList *plugin_descs = NULL;
GList *plugin_handles = NULL;
gchar *content_type;
g_return_val_if_fail (mime_type != NULL, NULL);
......@@ -138,7 +140,7 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
NULL);
/* Check an exact match */
plugin_descs = anjuta_plugin_manager_query (plugin_manager,
plugin_handles = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin",
"Interfaces", "IAnjutaFile",
"File Loader",
......@@ -148,20 +150,24 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
/* Check for plugins supporting one supertype */
content_type = g_content_type_from_mime_type (mime_type);
if (plugin_descs == NULL)
if (plugin_handles == NULL)
{
GList *node;
GList *loader_descs = NULL;
GList *loader_handles = NULL;
loader_descs = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin",
loader_handles = anjuta_plugin_manager_query (plugin_manager,
"Anjuta Plugin",
"Interfaces", "IAnjutaFile",
NULL);
for (node = g_list_first (loader_descs); node != NULL; node = g_list_next (node))
for (node = g_list_first (loader_handles); node != NULL; node = g_list_next (node))
{
gchar *value;
AnjutaPluginHandle *handle;
AnjutaPluginDescription *desc;
if (anjuta_plugin_description_get_string ((AnjutaPluginDescription *)node->data,
handle = (AnjutaPluginHandle *)node->data;
desc = anjuta_plugin_handle_get_description (handle);
if (anjuta_plugin_description_get_string (desc,
"File Loader", "SupportedMimeTypes", &value))
{
gchar **split_value;
......@@ -178,11 +184,7 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
if (g_content_type_is_a (content_type, supertype))
{
gchar *loc;
anjuta_plugin_description_get_string ((AnjutaPluginDescription *)node->data,
"Anjuta Plugin", "Location", &loc);
plugin_descs = g_list_prepend (plugin_descs, node->data);
plugin_handles = g_list_prepend (plugin_handles, handle);
g_free (supertype);
......@@ -195,12 +197,12 @@ get_available_plugins_for_mime (AnjutaPlugin* plugin,
g_strfreev (split_value);
}
}
g_list_free (loader_descs);
plugin_descs = g_list_reverse (plugin_descs);
g_list_free (loader_handles);
plugin_handles = g_list_reverse (plugin_handles);
}
g_free (content_type);
return plugin_descs;
return plugin_handles;
}
static gboolean
......@@ -251,7 +253,7 @@ static void
open_with_dialog (AnjutaFileLoaderPlugin *plugin, const gchar *uri,
const gchar *mime_type)
{
GList *plugin_descs, *snode;
GList *plugin_handles, *snode;
GList *mime_apps, *node;
GAppInfo *mime_app;
......@@ -298,14 +300,16 @@ open_with_dialog (AnjutaFileLoaderPlugin *plugin, const gchar *uri,
col ++;
/* Open with plugins menu items */
plugin_descs = get_available_plugins_for_mime (ANJUTA_PLUGIN (plugin), mime_type);
snode = plugin_descs;
plugin_handles = get_available_plugins_for_mime (ANJUTA_PLUGIN (plugin), mime_type);
snode = plugin_handles;
while (snode)
{
gchar *name;
AnjutaPluginHandle *handle;
AnjutaPluginDescription *desc;
desc = (AnjutaPluginDescription *)(snode->data);
handle = (AnjutaPluginHandle *)(snode->data);
desc = anjuta_plugin_handle_get_description (handle);
name = NULL;
......@@ -372,37 +376,28 @@ open_with_dialog (AnjutaFileLoaderPlugin *plugin, const gchar *uri,
g_warning ("No document manager plugin!!");
}
}
else if (option < (g_list_length (plugin_descs) + 1))
else if (option < (g_list_length (plugin_handles) + 1))
{
AnjutaPluginDescription *desc;
gchar *location = NULL;
AnjutaPluginHandle *handle;
GObject *loaded_plugin;
option--;
desc = g_list_nth_data (plugin_descs, option);
anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
"Location", &location);
g_assert (location != NULL);
if (location != NULL)
{
GObject *loaded_plugin;
handle = (AnjutaPluginHandle *)g_list_nth_data (plugin_handles, option);
loaded_plugin =
anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
location);
if (loaded_plugin)
{
GFile* file = g_file_new_for_uri (uri);
ianjuta_file_open (IANJUTA_FILE (loaded_plugin), file, NULL);
update_recent_file (plugin, uri, mime_type, TRUE);
g_object_unref (file);
}
else
{
anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell),
"Failed to activate plugin: %s",
location);
}
g_free (location);
loaded_plugin =anjuta_plugin_manager_get_plugin_by_handle (plugin_manager,
handle);
if (loaded_plugin)
{
GFile* file = g_file_new_for_uri (uri);
ianjuta_file_open (IANJUTA_FILE (loaded_plugin), file, NULL);
update_recent_file (plugin, uri, mime_type, TRUE);
g_object_unref (file);
}
else
{
anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell),
"Failed to activate plugin: %s",
anjuta_plugin_handle_get_name (handle));