* plugins/project-wizard/templates/cpp/src/main.cc:
[anjuta-git-plugin.git] / plugins / file-loader / plugin.c
blob65835024e6ffbdebf8e4919eae2e21cbc8a4fb9f
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 plugin.c
4 Copyright (C) 2004 Naba Kumar
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <config.h>
22 #include <libgnomevfs/gnome-vfs-mime-utils.h>
23 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
24 #include <libgnomevfs/gnome-vfs-ops.h>
26 #include <glib/gi18n.h>
28 #include <libanjuta/anjuta-shell.h>
29 #include <libanjuta/anjuta-status.h>
30 #include <libanjuta/anjuta-debug.h>
32 #include <libanjuta/interfaces/ianjuta-file.h>
33 #include <libanjuta/interfaces/ianjuta-file-loader.h>
34 #include <libanjuta/interfaces/ianjuta-document-manager.h>
35 #include <libanjuta/interfaces/ianjuta-wizard.h>
36 #include <libegg/menu/egg-submenu-action.h>
37 #include <libegg/menu/egg-recent-action.h>
39 #include "plugin.h"
40 #include "dnd.h"
42 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-loader-plugin.ui"
44 static gpointer parent_class;
46 static int
47 sort_wizards(gconstpointer wizard1, gconstpointer wizard2)
49 gchar* name1, *name2;
50 AnjutaPluginDescription* desc1 = (AnjutaPluginDescription*) wizard1;
51 AnjutaPluginDescription* desc2 = (AnjutaPluginDescription*) wizard2;
53 if ((anjuta_plugin_description_get_locale_string (desc1, "Wizard",
54 "Title", &name1) ||
55 anjuta_plugin_description_get_locale_string (desc1, "Anjuta Plugin",
56 "Name", &name1)) &&
57 (anjuta_plugin_description_get_locale_string (desc2, "Wizard",
58 "Title", &name2) ||
59 anjuta_plugin_description_get_locale_string (desc2, "Anjuta Plugin",
60 "Name", &name2)))
62 return strcmp(name1, name2);
64 else
65 return 0;
68 static void
69 set_recent_file (AnjutaFileLoaderPlugin *plugin, const gchar *uri,
70 const gchar *mime)
72 EggRecentItem *recent_item;
73 DEBUG_PRINT ("Adding recent item of mimi-type: %s", mime);
74 recent_item = egg_recent_item_new ();
75 egg_recent_item_set_uri (recent_item, uri);
76 egg_recent_item_set_mime_type (recent_item, mime);
77 if (strcmp (mime, "application/x-anjuta") == 0)
79 egg_recent_item_add_group (recent_item, "anjuta-projects");
80 egg_recent_model_add_full (plugin->recent_files_model_top,
81 recent_item);
83 else
85 egg_recent_item_add_group (recent_item, "anjuta-files");
86 egg_recent_model_add_full (plugin->recent_files_model_bottom,
87 recent_item);
91 static void
92 launch_application_failure (AnjutaFileLoaderPlugin *plugin,
93 const gchar *uri,
94 GnomeVFSResult result)
96 const gchar *errmsg;
97 GtkWidget *parent;
99 errmsg = gnome_vfs_result_to_string (result);
100 parent =
101 gtk_widget_get_toplevel (GTK_WIDGET(ANJUTA_PLUGIN (plugin)->shell));
102 anjuta_util_dialog_error (GTK_WINDOW (parent),
103 "Can not open \"%s\".\n\n%s",
104 g_basename (uri), errmsg);
107 static GList *
108 get_available_plugins_for_mime (AnjutaFileLoaderPlugin* plugin,
109 const gchar *mime_type)
111 AnjutaPluginManager *plugin_manager;
112 GList *plugin_descs = NULL;
114 g_return_val_if_fail (mime_type != NULL, NULL);
116 plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN(plugin)->shell,
117 NULL);
118 plugin_descs = anjuta_plugin_manager_query (plugin_manager,
119 "Anjuta Plugin",
120 "Interfaces", "IAnjutaFile",
121 "File Loader",
122 "SupportedMimeTypes",
123 mime_type,
124 NULL);
125 return plugin_descs;
128 static void
129 open_with_dialog (AnjutaFileLoaderPlugin *plugin, const gchar *uri,
130 const gchar *mime_type)
132 GList *plugin_descs, *snode;
133 GList *mime_apps, *node;
134 GtkWidget *menu, *menuitem;
135 GnomeVFSMimeApplication *mime_app;
137 GtkWidget *dialog, *parent, *hbox, *label;
138 GtkWidget *options;
139 gchar *message;
140 AnjutaPluginManager *plugin_manager;
142 plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (plugin)->shell,
143 NULL);
144 message = g_strdup_printf (_("<b>Cannot open \"%s\"</b>.\n\n"
145 "There is no plugin, default action, or application "
146 "configured to handle this file type.\n"
147 "\n"
148 "Mime type: %s.\n"
149 "\n"
150 "You may choose to try opening it with the following "
151 "plugins or applications."),
152 g_basename(uri), mime_type);
153 parent =
154 gtk_widget_get_toplevel (GTK_WIDGET(ANJUTA_PLUGIN (plugin)->shell));
155 dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (parent),
156 GTK_DIALOG_DESTROY_WITH_PARENT,
157 GTK_MESSAGE_INFO,
158 GTK_BUTTONS_OK_CANCEL, message);
159 g_free (message);
161 hbox = gtk_hbox_new (FALSE, 5);
162 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), hbox,
163 FALSE, FALSE, 5);
164 label = gtk_label_new (_("Open with:"));
165 options = gtk_option_menu_new ();
166 gtk_box_pack_end (GTK_BOX(hbox), options, FALSE, FALSE, 10);
167 gtk_box_pack_end (GTK_BOX(hbox), label, FALSE, FALSE, 10);
169 menu = gtk_menu_new ();
171 /* Document manager plugin */
172 menuitem = gtk_menu_item_new_with_label (_("Document Manager"));
173 gtk_menu_append (menu, menuitem);
175 /* Open with plugins menu items */
176 plugin_descs = get_available_plugins_for_mime (plugin, mime_type);
177 snode = plugin_descs;
178 while (snode)
180 gchar *name;
181 AnjutaPluginDescription *desc;
183 desc = (AnjutaPluginDescription *)(snode->data);
185 name = NULL;
187 anjuta_plugin_description_get_locale_string (desc, "File Loader",
188 "Title", &name);
190 if (!name)
192 anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin",
193 "Name", &name);
195 if (!name)
197 anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
198 "Location", &name);
200 menuitem = gtk_menu_item_new_with_label (name);
201 gtk_menu_append (menu, menuitem);
202 g_free (name);
203 snode = g_list_next (snode);
206 /* Open with application menu items */
207 mime_apps = gnome_vfs_mime_get_all_applications (mime_type);
208 if (mime_apps)
210 /* Separator */
211 menuitem = gtk_menu_item_new ();
212 gtk_menu_append (menu, menuitem);
214 node = mime_apps;
215 while (node)
217 mime_app = (GnomeVFSMimeApplication *)(node->data);
218 menuitem = gtk_menu_item_new_with_label (mime_app->name);
219 gtk_menu_append (menu, menuitem);
220 node = g_list_next (node);
223 gtk_option_menu_set_menu (GTK_OPTION_MENU (options), menu);
224 gtk_widget_show_all (hbox);
226 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
228 gint option;
230 option = gtk_option_menu_get_history(GTK_OPTION_MENU (options));
231 if (option == 0)
233 IAnjutaDocumentManager *docman;
234 docman = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
235 IAnjutaDocumentManager,
236 NULL);
237 if (docman)
239 ianjuta_file_open (IANJUTA_FILE (docman), uri, NULL);
241 else
243 g_warning ("No document manager plugin!!");
246 else if (option < (g_list_length (plugin_descs) + 1))
248 AnjutaPluginDescription *desc;
249 gchar *location = NULL;
251 option--;
252 desc = g_list_nth_data (plugin_descs, option);
253 anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
254 "Location", &location);
255 g_assert (location != NULL);
256 if (location != NULL)
258 GObject *loaded_plugin;
260 loaded_plugin =
261 anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
262 location);
263 if (loaded_plugin)
265 ianjuta_file_open (IANJUTA_FILE (loaded_plugin), uri, NULL);
266 set_recent_file (plugin, uri, mime_type);
268 else
270 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell),
271 "Failed to activate plugin: %s",
272 location);
274 g_free (location);
277 else
279 GList *uris = NULL;
280 GnomeVFSResult res;
282 option -= (g_list_length (plugin_descs) + 2);
283 mime_app = g_list_nth_data (mime_apps, option);
284 uris = g_list_prepend (uris, (gpointer)uri);
285 res = gnome_vfs_mime_application_launch (mime_app, uris);
286 if (res != GNOME_VFS_OK)
287 launch_application_failure (plugin, uri, res);
288 else
289 set_recent_file (plugin, uri, mime_type);
290 g_list_free (uris);
293 gnome_vfs_mime_application_list_free (mime_apps);
294 if (plugin_descs)
295 g_list_free (plugin_descs);
296 gtk_widget_destroy (dialog);
299 static gboolean
300 launch_in_default_application (AnjutaFileLoaderPlugin *plugin,
301 const gchar *mime_type, const gchar *uri)
303 GnomeVFSMimeAction *action;
304 GList *uris = NULL;
305 gboolean ret;
307 uris = g_list_prepend (uris, (gpointer)uri);
309 ret = TRUE;
310 action = gnome_vfs_mime_get_default_action (mime_type);
311 if (!action || gnome_vfs_mime_action_launch (action, uris) != GNOME_VFS_OK)
313 GnomeVFSMimeApplication *app;
314 GnomeVFSResult res;
315 app = gnome_vfs_mime_get_default_application (mime_type);
316 if (!app ||
317 (res =
318 gnome_vfs_mime_application_launch (app, uris)) != GNOME_VFS_OK)
320 open_with_dialog (plugin, uri, mime_type);
322 if (app)
323 gnome_vfs_mime_application_free (app);
325 if (action)
326 gnome_vfs_mime_action_free (action);
327 g_list_free (uris);
328 return ret;
331 static void
332 open_file (AnjutaFileLoaderPlugin *plugin, const gchar *uri)
334 GnomeVFSURI *vfs_uri;
335 gchar *dirname;
337 vfs_uri = gnome_vfs_uri_new (uri);
338 dirname = gnome_vfs_uri_extract_dirname (vfs_uri);
339 gnome_vfs_uri_unref (vfs_uri);
340 chdir (dirname);
341 g_free (dirname);
343 ianjuta_file_loader_load (IANJUTA_FILE_LOADER (plugin),
344 uri, FALSE, NULL);
347 typedef struct
349 AnjutaFileLoaderPlugin *plugin;
350 const gchar *uri;
351 } RecentIdelOpenData;
353 static gboolean
354 on_open_recent_file_idle (gpointer data)
356 RecentIdelOpenData *rdata;
358 rdata = (RecentIdelOpenData*)data;
359 open_file (rdata->plugin, rdata->uri);
360 g_free (rdata);
361 return FALSE;
364 static gboolean
365 on_open_recent_file (EggRecentAction *action, AnjutaFileLoaderPlugin *plugin)
367 const gchar *uri;
368 GnomeVFSURI *vfs_uri;
369 gboolean ret = TRUE;
370 RecentIdelOpenData *rdata;
372 uri = egg_recent_action_get_selected_uri (action);
373 vfs_uri = gnome_vfs_uri_new (uri);
374 rdata = g_new0 (RecentIdelOpenData, 1);
375 rdata->plugin = plugin;
376 rdata->uri = uri;
377 g_idle_add (on_open_recent_file_idle, rdata);
378 gnome_vfs_uri_unref (vfs_uri);
380 return ret;
383 static void
384 on_open_response_ok (GtkDialog* dialog, gint id,
385 AnjutaFileLoaderPlugin *plugin)
387 GSList *list, *node;
389 if (id != GTK_RESPONSE_ACCEPT)
391 gtk_widget_destroy (GTK_WIDGET (dialog));
392 return;
395 list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
396 node = list;
397 while (node)
399 if (node->data)
400 open_file (plugin, (gchar *)node->data);
401 g_free (node->data);
402 node = g_slist_next (node);
404 g_slist_free (list);
407 static void
408 setup_file_filters (GtkFileChooser *fc)
410 GtkFileFilter *filter;
412 filter = gtk_file_filter_new ();
413 gtk_file_filter_set_name (filter, _("All files"));
414 gtk_file_filter_add_pattern (filter, "*");
415 gtk_file_chooser_add_filter (fc, filter);
417 filter = gtk_file_filter_new ();
418 gtk_file_filter_set_name (filter, _("Anjuta Projects"));
419 gtk_file_filter_add_pattern (filter, "*.anjuta");
420 gtk_file_filter_add_pattern (filter, "*.prj");
421 gtk_file_chooser_add_filter (fc, filter);
423 filter = gtk_file_filter_new ();
424 gtk_file_filter_set_name (filter, _("C/C++ source files"));
425 gtk_file_filter_add_pattern (filter, "*.c");
426 gtk_file_filter_add_pattern (filter, "*.cc");
427 gtk_file_filter_add_pattern (filter, "*.cpp");
428 gtk_file_filter_add_pattern (filter, "*.cxx");
429 gtk_file_filter_add_pattern (filter, "*.c++");
430 gtk_file_filter_add_pattern (filter, "*.h");
431 gtk_file_filter_add_pattern (filter, "*.hh");
432 gtk_file_filter_add_pattern (filter, "*.hpp");
433 gtk_file_chooser_add_filter (fc, filter);
435 filter = gtk_file_filter_new ();
436 gtk_file_filter_set_name (filter, _("C# source files"));
437 gtk_file_filter_add_pattern (filter, "*.cs");
438 gtk_file_filter_add_pattern (filter, "*.h");
439 gtk_file_chooser_add_filter (fc, filter);
441 filter = gtk_file_filter_new ();
442 gtk_file_filter_set_name (filter, _("Java source files"));
443 gtk_file_filter_add_pattern (filter, "*.java");
444 gtk_file_filter_add_pattern (filter, "*.js");
445 gtk_file_chooser_add_filter (fc, filter);
447 filter = gtk_file_filter_new ();
448 gtk_file_filter_set_name (filter, _("Pascal source files"));
449 gtk_file_filter_add_pattern (filter, "*.pas");
450 gtk_file_chooser_add_filter (fc, filter);
452 filter = gtk_file_filter_new ();
453 gtk_file_filter_set_name (filter, _("PHP source files"));
454 gtk_file_filter_add_pattern (filter, "*.php");
455 gtk_file_filter_add_pattern (filter, "*.php?");
456 gtk_file_filter_add_pattern (filter, "*.phtml");
457 gtk_file_chooser_add_filter (fc, filter);
459 filter = gtk_file_filter_new ();
460 gtk_file_filter_set_name (filter, _("Perl source files"));
461 gtk_file_filter_add_pattern (filter, "*.pl");
462 gtk_file_filter_add_pattern (filter, "*.pm");
463 gtk_file_chooser_add_filter (fc, filter);
465 filter = gtk_file_filter_new ();
466 gtk_file_filter_set_name (filter, _("Python source files"));
467 gtk_file_filter_add_pattern (filter, "*.py");
468 gtk_file_chooser_add_filter (fc, filter);
470 filter = gtk_file_filter_new ();
471 gtk_file_filter_set_name (filter, _("Hyper text markup files"));
472 gtk_file_filter_add_pattern (filter, "*.htm");
473 gtk_file_filter_add_pattern (filter, "*.html");
474 gtk_file_filter_add_pattern (filter, "*.xhtml");
475 gtk_file_filter_add_pattern (filter, "*.dhtml");
476 gtk_file_filter_add_pattern (filter, "*.cs");
477 gtk_file_chooser_add_filter (fc, filter);
479 filter = gtk_file_filter_new ();
480 gtk_file_filter_set_name (filter, _("Shell scripts files"));
481 gtk_file_filter_add_pattern (filter, "*.sh");
482 gtk_file_chooser_add_filter (fc, filter);
484 filter = gtk_file_filter_new ();
485 gtk_file_filter_set_name (filter, _("Makefiles"));
486 gtk_file_filter_add_pattern (filter, "Makefile*");
487 gtk_file_filter_add_pattern (filter, "makefile*");
488 gtk_file_chooser_add_filter (fc, filter);
490 filter = gtk_file_filter_new ();
491 gtk_file_filter_set_name (filter, _("Lua files"));
492 gtk_file_filter_add_pattern (filter, "*.lua");
493 gtk_file_chooser_add_filter (fc, filter);
495 filter = gtk_file_filter_new ();
496 gtk_file_filter_set_name (filter, _("Diff files"));
497 gtk_file_filter_add_pattern (filter, "*.diff");
498 gtk_file_filter_add_pattern (filter, "*.patch");
499 gtk_file_filter_add_pattern (filter, "*.cvsdiff");
500 gtk_file_chooser_add_filter (fc, filter);
503 static GtkWidget*
504 create_file_open_dialog_gui(GtkWindow* parent, AnjutaFileLoaderPlugin* plugin)
506 GtkWidget* dialog =
507 gtk_file_chooser_dialog_new (_("Open file"),
508 parent,
509 GTK_FILE_CHOOSER_ACTION_OPEN,
510 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
511 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
512 NULL);
513 gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER(dialog), TRUE);
514 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
515 setup_file_filters (GTK_FILE_CHOOSER (dialog));
517 g_signal_connect(G_OBJECT(dialog), "response",
518 G_CALLBACK(on_open_response_ok), plugin);
519 g_signal_connect_swapped (GTK_OBJECT (dialog),
520 "response",
521 G_CALLBACK (gtk_widget_destroy),
522 GTK_OBJECT (dialog));
523 return dialog;
526 static void
527 on_open_activate (GtkAction *action, AnjutaFileLoaderPlugin *plugin)
529 GtkWidget *dlg;
531 dlg =
532 create_file_open_dialog_gui (GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell),
533 plugin);
534 gtk_widget_show (dlg);
537 static void
538 on_activate_wizard (GtkMenuItem *menuitem,
539 AnjutaFileLoaderPlugin *loader)
541 AnjutaPluginManager *plugin_manager;
542 AnjutaPluginDescription *desc;
544 desc = g_object_get_data (G_OBJECT (menuitem), "__plugin_desc");
545 plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (loader)->shell,
546 NULL);
547 if (desc)
549 gchar *id;
550 GObject *plugin;
552 if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
553 "Location", &id))
555 plugin =
556 anjuta_plugin_manager_get_plugin_by_id (plugin_manager, id);
557 ianjuta_wizard_activate (IANJUTA_WIZARD (plugin), NULL);
562 static GtkWidget*
563 on_create_submenu (gpointer user_data)
565 AnjutaPluginManager *plugin_manager;
566 AnjutaFileLoaderPlugin *loader;
567 GList *node;
568 gint count;
569 GtkWidget *submenu = NULL;
570 GList *plugin_descs = NULL;
572 loader = ANJUTA_PLUGIN_FILE_LOADER (user_data);
573 plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (loader)->shell,
574 NULL);
575 submenu = gtk_menu_new ();
576 gtk_widget_show (submenu);
578 plugin_descs = anjuta_plugin_manager_query (plugin_manager,
579 "Anjuta Plugin",
580 "Interfaces", "IAnjutaWizard",
581 NULL);
582 plugin_descs = g_list_sort(plugin_descs, sort_wizards);
583 node = plugin_descs;
584 count = 0;
585 while (node)
587 AnjutaPluginDescription *desc;
588 GtkWidget *menuitem;
589 GtkWidget *icon;
590 gchar *str, *icon_path, *name;
592 desc = node->data;
594 icon = NULL;
595 name = NULL;
596 if (anjuta_plugin_description_get_locale_string (desc, "Wizard",
597 "Title", &str) ||
598 anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin",
599 "Name", &str))
601 count++;
602 if (count < 10)
603 name = g_strdup_printf ("_%d. %s", count, N_(str));
604 else
605 name = g_strdup_printf ("%d. %s", count, N_(str));
606 g_free (str);
608 if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
609 "Icon", &str))
611 GdkPixbuf *pixbuf, *scaled_pixbuf;
612 gint height, width;
614 gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (submenu),
615 GTK_ICON_SIZE_MENU,
616 &width, &height);
617 icon_path = g_build_filename (PACKAGE_PIXMAPS_DIR, str, NULL);
618 pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL);
619 if (pixbuf)
621 scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, width, height,
622 GDK_INTERP_BILINEAR);
623 icon = gtk_image_new_from_pixbuf (scaled_pixbuf);
624 g_object_unref (pixbuf);
625 g_object_unref (scaled_pixbuf);
627 else
628 icon = gtk_image_new ();
630 gtk_widget_show (icon);
631 g_free (icon_path);
632 g_free (str);
634 if (name)
636 menuitem = gtk_image_menu_item_new_with_mnemonic (name);
637 g_free(name);
638 gtk_widget_show (menuitem);
639 g_object_set_data (G_OBJECT (menuitem), "__plugin_desc", desc);
640 g_signal_connect (G_OBJECT (menuitem), "activate",
641 G_CALLBACK (on_activate_wizard),
642 loader);
643 if (icon)
644 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
645 icon);
646 gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
648 node = g_list_next (node);
650 g_list_free (plugin_descs);
651 return submenu;
655 static void
656 on_recent_files_tooltip (GtkTooltips *tooltips, GtkWidget *menu_item,
657 EggRecentItem *item, gpointer user_data)
659 char *uri, *tip;
661 uri = egg_recent_item_get_uri_for_display (item);
662 tip = g_strdup_printf ("Open '%s'", uri);
664 gtk_tooltips_set_tip (tooltips, menu_item, tip, NULL);
666 g_free (uri);
670 static void
671 open_file_with (AnjutaFileLoaderPlugin *plugin, GtkMenuItem *menuitem,
672 const gchar *uri)
674 GList *mime_apps;
675 GnomeVFSMimeApplication *mime_app;
676 gchar *mime_type;
677 gint idx;
678 AnjutaPluginDescription *desc;
679 AnjutaPluginManager *plugin_manager;
681 idx = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "index"));
682 desc = (AnjutaPluginDescription*) g_object_get_data (G_OBJECT (menuitem),
683 "desc");
684 plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (plugin)->shell,
685 NULL);
686 mime_type = anjuta_util_get_uri_mime_type (uri);
687 mime_apps = gnome_vfs_mime_get_all_applications (mime_type);
689 /* Open with plugin */
690 if (desc)
692 gchar *location = NULL;
694 anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
695 "Location", &location);
696 g_assert (location != NULL);
697 if (location != NULL)
699 GObject *loaded_plugin;
701 loaded_plugin =
702 anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
703 location);
704 if (loaded_plugin)
706 ianjuta_file_open (IANJUTA_FILE (loaded_plugin), uri, NULL);
707 set_recent_file (plugin, uri, mime_type);
709 else
711 anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell),
712 _("Failed to activate plugin: %s"),
713 location);
715 g_free (location);
718 else
720 GList *uris = NULL;
721 GnomeVFSResult res;
723 mime_app = g_list_nth_data (mime_apps, idx);
724 uris = g_list_prepend (uris, (gpointer)uri);
725 res = gnome_vfs_mime_application_launch (mime_app, uris);
726 if (res != GNOME_VFS_OK)
727 launch_application_failure (plugin, uri, res);
728 else
729 set_recent_file (plugin, uri, mime_type);
730 g_list_free (uris);
732 gnome_vfs_mime_application_list_free (mime_apps);
733 g_free (mime_type);
736 static void
737 fm_open (GtkAction *action, AnjutaFileLoaderPlugin *plugin)
739 if (plugin->fm_current_uri)
740 open_file (plugin, plugin->fm_current_uri);
743 static void
744 fm_open_with (GtkMenuItem *menuitem, AnjutaFileLoaderPlugin *plugin)
746 if (plugin->fm_current_uri)
747 open_file_with (plugin, menuitem, plugin->fm_current_uri);
750 static void
751 pm_open (GtkAction *action, AnjutaFileLoaderPlugin *plugin)
753 if (plugin->pm_current_uri)
754 open_file (plugin, plugin->pm_current_uri);
757 static void
758 pm_open_with (GtkMenuItem *menuitem, AnjutaFileLoaderPlugin *plugin)
760 if (plugin->pm_current_uri)
761 open_file_with (plugin, menuitem, plugin->pm_current_uri);
764 static GtkActionEntry actions_file[] = {
766 "ActionFileOpen",
767 GTK_STOCK_OPEN,
768 N_("_Open..."),
769 "<control>o",
770 N_("Open file"),
771 G_CALLBACK (on_open_activate)
775 static GtkActionEntry popup_actions_file[] = {
777 "ActionPopupOpen",
778 GTK_STOCK_OPEN,
779 N_("_Open"), NULL,
780 N_("Open file"),
781 G_CALLBACK (fm_open)
784 "ActionPopupOpenWith",
785 NULL,
786 N_("Open _With"), NULL,
787 N_("Open with"), NULL
790 "ActionPopupPMOpen",
791 GTK_STOCK_OPEN,
792 N_("_Open"), NULL,
793 N_("Open file"),
794 G_CALLBACK (pm_open)
797 "ActionPopupPMOpenWith",
798 NULL,
799 N_("Open _With"), NULL,
800 N_("Open with"), NULL
804 static gboolean
805 create_open_with_submenu (AnjutaFileLoaderPlugin *plugin, GtkWidget *parentmenu,
806 const gchar *uri, GCallback callback,
807 gpointer callback_data)
809 GList *mime_apps, *node;
810 GnomeVFSMimeApplication *mime_app;
811 GList *plugin_descs, *snode;
812 GtkWidget *menu, *menuitem;
813 gchar *mime_type;
814 gint idx;
815 gboolean ret;
817 g_return_val_if_fail (GTK_IS_MENU_ITEM (parentmenu), FALSE);
819 menu = gtk_menu_new ();
820 gtk_widget_show (menu);
821 gtk_menu_item_set_submenu (GTK_MENU_ITEM (parentmenu), menu);
823 mime_type = anjuta_util_get_uri_mime_type (uri);
824 if (mime_type == NULL)
825 return FALSE;
827 idx = 0;
829 /* Open with plugins menu items */
830 plugin_descs = get_available_plugins_for_mime (plugin, mime_type);
831 snode = plugin_descs;
832 while (snode)
834 gchar *name;
835 AnjutaPluginDescription *desc;
837 desc = (AnjutaPluginDescription *)(snode->data);
838 name = NULL;
839 anjuta_plugin_description_get_locale_string (desc, "File Loader",
840 "Title", &name);
841 if (!name)
843 anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin",
844 "Name", &name);
846 if (!name)
848 anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
849 "Location", &name);
851 menuitem = gtk_menu_item_new_with_label (name);
852 g_object_set_data (G_OBJECT (menuitem), "index", GINT_TO_POINTER (idx));
853 g_object_set_data (G_OBJECT (menuitem), "desc", (gpointer)(desc));
854 g_signal_connect (G_OBJECT (menuitem), "activate",
855 G_CALLBACK (callback), callback_data);
856 gtk_menu_append (menu, menuitem);
857 g_free (name);
858 snode = g_list_next (snode);
859 idx++;
862 /* Open with applications */
863 mime_apps = gnome_vfs_mime_get_all_applications (mime_type);
864 if (idx > 0 && mime_apps)
866 menuitem = gtk_menu_item_new ();
867 gtk_menu_append (menu, menuitem);
868 idx++;
870 g_free (mime_type);
871 idx = 0;
872 node = mime_apps;
873 while (node)
875 mime_app = (GnomeVFSMimeApplication *)(node->data);
876 menuitem = gtk_menu_item_new_with_label (mime_app->name);
877 g_object_set_data (G_OBJECT (menuitem), "index", GINT_TO_POINTER (idx));
878 g_signal_connect (G_OBJECT (menuitem), "activate",
879 G_CALLBACK (callback), callback_data);
880 gtk_menu_append (menu, menuitem);
881 node = g_list_next (node);
882 idx++;
884 gtk_widget_show_all (menu);
886 if (mime_apps == NULL && plugin_descs == NULL)
887 ret = FALSE;
888 else
889 ret = TRUE;
891 gnome_vfs_mime_application_list_free (mime_apps);
892 if (plugin_descs)
893 g_list_free (plugin_descs);
895 return ret;
898 static void
899 value_added_fm_current_uri (AnjutaPlugin *plugin, const char *name,
900 const GValue *value, gpointer data)
902 AnjutaUI *ui;
903 const gchar *uri;
904 AnjutaFileLoaderPlugin *fl_plugin;
905 GtkAction *action;
906 GtkWidget *parentmenu;
908 uri = g_value_get_string (value);
909 g_return_if_fail (name != NULL);
911 fl_plugin = ANJUTA_PLUGIN_FILE_LOADER (plugin);
912 ui = anjuta_shell_get_ui (plugin->shell, NULL);
914 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader", "ActionPopupOpen");
915 g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
917 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader",
918 "ActionPopupOpenWith");
919 g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
921 if (fl_plugin->fm_current_uri)
922 g_free (fl_plugin->fm_current_uri);
923 fl_plugin->fm_current_uri = g_strdup (uri);
925 parentmenu =
926 gtk_ui_manager_get_widget (GTK_UI_MANAGER(ui),
927 "/PopupFileManager/PlaceholderPopupFileOpen/OpenWith");
928 if (!create_open_with_submenu (fl_plugin, parentmenu, uri,
929 G_CALLBACK (fm_open_with), plugin))
930 g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
933 static void
934 value_removed_fm_current_uri (AnjutaPlugin *plugin,
935 const char *name, gpointer data)
937 AnjutaUI *ui;
938 GtkAction *action;
939 AnjutaFileLoaderPlugin *fl_plugin;
941 fl_plugin = ANJUTA_PLUGIN_FILE_LOADER (plugin);
943 if (fl_plugin->fm_current_uri)
944 g_free (fl_plugin->fm_current_uri);
945 fl_plugin->fm_current_uri = NULL;
947 ui = anjuta_shell_get_ui (plugin->shell, NULL);
948 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader", "ActionPopupOpen");
949 g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
951 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader",
952 "ActionPopupOpenWith");
953 g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
956 static void
957 value_added_pm_current_uri (AnjutaPlugin *plugin, const char *name,
958 const GValue *value, gpointer data)
960 AnjutaUI *ui;
961 const gchar *uri;
962 AnjutaFileLoaderPlugin *fl_plugin;
963 GtkAction *action;
964 GtkWidget *parentmenu;
966 uri = g_value_get_string (value);
967 g_return_if_fail (name != NULL);
969 fl_plugin = ANJUTA_PLUGIN_FILE_LOADER (plugin);
970 ui = anjuta_shell_get_ui (plugin->shell, NULL);
972 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader", "ActionPopupPMOpen");
973 g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
975 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader",
976 "ActionPopupPMOpenWith");
977 g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
979 if (fl_plugin->pm_current_uri)
980 g_free (fl_plugin->pm_current_uri);
981 fl_plugin->pm_current_uri = g_strdup (uri);
983 parentmenu =
984 gtk_ui_manager_get_widget (GTK_UI_MANAGER(ui),
985 "/PopupProjectManager/PlaceholderPopupProjectOpen/OpenWith");
986 if (!create_open_with_submenu (fl_plugin, parentmenu, uri,
987 G_CALLBACK (pm_open_with), plugin))
988 g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
991 static void
992 value_removed_pm_current_uri (AnjutaPlugin *plugin,
993 const char *name, gpointer data)
995 AnjutaUI *ui;
996 GtkAction *action;
997 AnjutaFileLoaderPlugin *fl_plugin;
999 fl_plugin = ANJUTA_PLUGIN_FILE_LOADER (plugin);
1001 if (fl_plugin->pm_current_uri)
1002 g_free (fl_plugin->pm_current_uri);
1003 fl_plugin->pm_current_uri = NULL;
1005 ui = anjuta_shell_get_ui (plugin->shell, NULL);
1006 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader", "ActionPopupPMOpen");
1007 g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
1009 action = anjuta_ui_get_action (ui, "ActionGroupPopupLoader",
1010 "ActionPopupPMOpenWith");
1011 g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
1014 static void
1015 dnd_dropped (const gchar *uri, gpointer plugin)
1017 ianjuta_file_loader_load (IANJUTA_FILE_LOADER (plugin), uri, FALSE, NULL);
1020 static void
1021 on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase,
1022 AnjutaSession *session,
1023 AnjutaFileLoaderPlugin *plugin)
1025 AnjutaStatus *status;
1026 const gchar *uri;
1027 gchar *mime_type;
1028 GList *files, *node;
1029 gint i;
1031 /* We want to load the files first before other session loads */
1032 if (phase != ANJUTA_SESSION_PHASE_FIRST)
1033 return;
1035 files = anjuta_session_get_string_list (session, "File Loader", "Files");
1036 if (!files)
1037 return;
1039 status = anjuta_shell_get_status (shell, NULL);
1040 anjuta_status_progress_add_ticks (status, g_list_length(files));
1042 /* Open project files first and then regular files */
1043 for (i = 0; i < 2; i++)
1045 node = files;
1046 while (node)
1048 uri = node->data;
1049 if (uri)
1051 gchar *label, *filename;
1053 mime_type = anjuta_util_get_uri_mime_type (uri);
1055 filename = g_path_get_basename (uri);
1056 if (strchr (filename, '#'))
1057 *(strchr (filename, '#')) = '\0';
1059 label = g_strconcat ("Loaded: ", filename, NULL);
1061 if (i == 0 && mime_type &&
1062 strcmp (mime_type, "application/x-anjuta") == 0)
1064 /* Project files first */
1065 /* FIXME: Ignore project files for now */
1067 ianjuta_file_loader_load (IANJUTA_FILE_LOADER (plugin),
1068 uri, FALSE, NULL);
1070 anjuta_status_progress_tick (status, NULL, label);
1072 else if (i != 0 &&
1073 (!mime_type ||
1074 strcmp (mime_type, "application/x-anjuta") != 0))
1076 /* Then rest of the files */
1077 ianjuta_file_loader_load (IANJUTA_FILE_LOADER (plugin),
1078 uri, FALSE, NULL);
1079 anjuta_status_progress_tick (status, NULL, label);
1081 g_free (filename);
1082 g_free (label);
1083 g_free (mime_type);
1085 node = g_list_next (node);
1088 if (files)
1090 g_list_foreach (files, (GFunc)g_free, NULL);
1091 g_list_free (files);
1095 static gboolean
1096 activate_plugin (AnjutaPlugin *plugin)
1098 EggSubmenuAction *saction;
1099 GtkAction *action;
1100 AnjutaUI *ui;
1101 AnjutaFileLoaderPlugin *loader_plugin;
1102 // GtkWidget *recent_menu;
1103 // EggRecentViewGtk *recent_view;
1104 GtkActionGroup *group;
1106 loader_plugin = ANJUTA_PLUGIN_FILE_LOADER (plugin);
1108 DEBUG_PRINT ("AnjutaFileLoaderPlugin: Activating File Loader plugin...");
1110 ui = anjuta_shell_get_ui (plugin->shell, NULL);
1112 /* Add action group */
1113 loader_plugin->action_group =
1114 anjuta_ui_add_action_group_entries (ui, "ActionGroupLoader",
1115 _("File Loader"),
1116 actions_file,
1117 G_N_ELEMENTS (actions_file),
1118 GETTEXT_PACKAGE, TRUE, plugin);
1119 loader_plugin->popup_action_group =
1120 anjuta_ui_add_action_group_entries (ui, "ActionGroupPopupLoader",
1121 _("File Loader"),
1122 popup_actions_file,
1123 G_N_ELEMENTS (popup_actions_file),
1124 GETTEXT_PACKAGE, FALSE, plugin);
1125 saction = g_object_new (EGG_TYPE_SUBMENU_ACTION,
1126 "name", "ActionFileWizard",
1127 "label", _("New"),
1128 "tooltip", _("New file, project and project components."),
1129 NULL);
1130 egg_submenu_action_set_menu_factory (saction,
1131 on_create_submenu, plugin);
1132 gtk_action_group_add_action (loader_plugin->action_group,
1133 GTK_ACTION (saction));
1135 /* Set short labels */
1136 action = anjuta_ui_get_action (ui, "ActionGroupLoader", "ActionFileOpen");
1137 g_object_set (G_OBJECT (action), "short-label", _("Open"),
1138 "is-important", TRUE, NULL);
1140 group = gtk_action_group_new ("ActionGroupLoaderRecent");
1141 action = g_object_new (EGG_TYPE_RECENT_ACTION,
1142 "name", "ActionFileOpenRecent",
1143 "label", _("Open _Recent"),
1144 "tooltip", _("Open recent file"),
1145 NULL);
1146 egg_recent_action_add_model (EGG_RECENT_ACTION (action),
1147 loader_plugin->recent_files_model_top);
1148 egg_recent_action_add_model (EGG_RECENT_ACTION (action),
1149 loader_plugin->recent_files_model_bottom);
1150 g_signal_connect (action, "activate",
1151 G_CALLBACK (on_open_recent_file), plugin);
1152 gtk_action_group_add_action (group, action);
1153 anjuta_ui_add_action_group (ui, "ActionGroupLoaderRecent",
1154 N_("Open recent files"), group, FALSE);
1155 loader_plugin->recent_group = group;
1157 /* Add UI */
1158 loader_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
1160 /* Install drag n drop handler */
1161 dnd_drop_init (GTK_WIDGET (plugin->shell), dnd_dropped, plugin,
1162 "text/plain", "text/html", "text/source", "application-x/anjuta",
1163 NULL);
1165 /* Add watches */
1166 loader_plugin->fm_watch_id =
1167 anjuta_plugin_add_watch (plugin, "file_manager_current_uri",
1168 value_added_fm_current_uri,
1169 value_removed_fm_current_uri, NULL);
1170 loader_plugin->pm_watch_id =
1171 anjuta_plugin_add_watch (plugin, "project_manager_current_uri",
1172 value_added_pm_current_uri,
1173 value_removed_pm_current_uri, NULL);
1175 /* Connect to session */
1176 g_signal_connect (G_OBJECT (plugin->shell), "load_session",
1177 G_CALLBACK (on_session_load), plugin);
1178 return TRUE;
1181 static gboolean
1182 deactivate_plugin (AnjutaPlugin *plugin)
1184 AnjutaUI *ui;
1185 AnjutaFileLoaderPlugin *loader_plugin;
1187 loader_plugin = ANJUTA_PLUGIN_FILE_LOADER (plugin);
1189 DEBUG_PRINT ("AnjutaFileLoaderPlugin: Deactivating File Loader plugin...");
1191 /* Disconnect session */
1192 g_signal_handlers_disconnect_by_func (G_OBJECT (plugin->shell),
1193 G_CALLBACK (on_session_load), plugin);
1195 ui = anjuta_shell_get_ui (plugin->shell, NULL);
1196 /* Remove watches */
1197 anjuta_plugin_remove_watch (plugin, loader_plugin->fm_watch_id, TRUE);
1198 anjuta_plugin_remove_watch (plugin, loader_plugin->pm_watch_id, TRUE);
1199 /* Uninstall dnd */
1200 dnd_drop_finalize (GTK_WIDGET (plugin->shell), plugin);
1201 /* Remove UI */
1202 anjuta_ui_unmerge (ui, loader_plugin->uiid);
1203 /* Remove action group */
1204 anjuta_ui_remove_action_group (ui, loader_plugin->action_group);
1205 anjuta_ui_remove_action_group (ui, loader_plugin->popup_action_group);
1206 anjuta_ui_remove_action_group (ui, loader_plugin->recent_group);
1207 return TRUE;
1210 static void
1211 dispose (GObject *obj)
1213 AnjutaFileLoaderPlugin *plugin = ANJUTA_PLUGIN_FILE_LOADER (obj);
1214 if (plugin->recent_files_model_top)
1216 g_object_unref (plugin->recent_files_model_top);
1217 plugin->recent_files_model_top = NULL;
1219 if (plugin->recent_files_model_bottom)
1221 g_object_unref (plugin->recent_files_model_bottom);
1222 plugin->recent_files_model_bottom = NULL;
1224 GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (obj));
1227 static void
1228 anjuta_file_loader_plugin_instance_init (GObject *obj)
1230 AnjutaFileLoaderPlugin *plugin = ANJUTA_PLUGIN_FILE_LOADER (obj);
1232 plugin->fm_current_uri = NULL;
1233 plugin->pm_current_uri = NULL;
1235 plugin->recent_files_model_top =
1236 egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
1237 egg_recent_model_set_limit (plugin->recent_files_model_top, 5);
1238 egg_recent_model_set_filter_groups (plugin->recent_files_model_top,
1239 "anjuta-projects", NULL);
1240 plugin->recent_files_model_bottom =
1241 egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
1242 egg_recent_model_set_limit (plugin->recent_files_model_bottom, 15);
1243 egg_recent_model_set_filter_groups (plugin->recent_files_model_bottom,
1244 "anjuta-files", NULL);
1247 static void
1248 anjuta_file_loader_plugin_class_init (GObjectClass *klass)
1250 AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
1252 parent_class = g_type_class_peek_parent (klass);
1254 plugin_class->activate = activate_plugin;
1255 plugin_class->deactivate = deactivate_plugin;
1256 klass->dispose = dispose;
1259 static GObject*
1260 iloader_load (IAnjutaFileLoader *loader, const gchar *uri,
1261 gboolean read_only, GError **err)
1263 gchar *mime_type;
1264 gchar *new_uri;
1265 GnomeVFSURI* vfs_uri;
1266 AnjutaStatus *status;
1267 AnjutaPluginManager *plugin_manager;
1268 GList *plugin_descs = NULL;
1269 GObject *plugin = NULL;
1271 g_return_val_if_fail (uri != NULL, NULL);
1272 vfs_uri = gnome_vfs_uri_new (uri);
1274 if (!gnome_vfs_uri_exists (vfs_uri))
1276 launch_application_failure (ANJUTA_PLUGIN_FILE_LOADER (loader),
1277 uri, GNOME_VFS_ERROR_NOT_FOUND);
1278 gnome_vfs_uri_unref (vfs_uri);
1279 return NULL;
1282 new_uri = gnome_vfs_uri_to_string (vfs_uri,
1283 GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER);
1284 mime_type = anjuta_util_get_uri_mime_type (new_uri);
1285 gnome_vfs_uri_unref (vfs_uri);
1287 if (mime_type == NULL)
1289 launch_application_failure (ANJUTA_PLUGIN_FILE_LOADER (loader),
1290 new_uri, GNOME_VFS_ERROR_NOT_FOUND);
1291 g_free (new_uri);
1292 return NULL;
1295 plugin_manager = anjuta_shell_get_plugin_manager (ANJUTA_PLUGIN (loader)->shell,
1296 NULL);
1297 status = anjuta_shell_get_status (ANJUTA_PLUGIN (loader)->shell, NULL);
1298 anjuta_status_busy_push (status);
1300 DEBUG_PRINT ("Opening URI: %s", uri);
1302 plugin_descs = anjuta_plugin_manager_query (plugin_manager,
1303 "Anjuta Plugin",
1304 "Interfaces", "IAnjutaFile",
1305 "File Loader",
1306 "SupportedMimeTypes",
1307 mime_type,
1308 NULL);
1310 if (g_list_length (plugin_descs) > 1)
1312 plugin =
1313 anjuta_plugin_manager_select_and_activate (plugin_manager,
1314 "Open With",
1315 "Please select a plugin to open this file.",
1316 plugin_descs);
1318 else if (g_list_length (plugin_descs) == 1)
1320 gchar *location = NULL;
1322 AnjutaPluginDescription *desc = plugin_descs->data;
1323 anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
1324 "Location", &location);
1325 g_return_val_if_fail (location != NULL, NULL);
1326 plugin =
1327 anjuta_plugin_manager_get_plugin_by_id (plugin_manager,
1328 location);
1329 g_free (location);
1331 else
1333 launch_in_default_application (ANJUTA_PLUGIN_FILE_LOADER (loader), mime_type, uri);
1335 if (plugin)
1336 ianjuta_file_open (IANJUTA_FILE(plugin), uri, NULL);
1338 set_recent_file (ANJUTA_PLUGIN_FILE_LOADER (loader), new_uri, mime_type);
1340 if (plugin_descs)
1341 g_list_free (plugin_descs);
1342 g_free (mime_type);
1343 g_free (new_uri);
1344 anjuta_status_busy_pop (status);
1346 return plugin;
1349 static void
1350 iloader_iface_init(IAnjutaLoaderIface *iface)
1352 iface->find_plugins = NULL;
1355 static void
1356 iloader_file_iface_init(IAnjutaFileLoaderIface *iface)
1358 iface->load = iloader_load;
1361 ANJUTA_PLUGIN_BEGIN (AnjutaFileLoaderPlugin, anjuta_file_loader_plugin);
1362 ANJUTA_PLUGIN_ADD_INTERFACE (iloader, IANJUTA_TYPE_LOADER);
1363 ANJUTA_PLUGIN_ADD_INTERFACE (iloader_file, IANJUTA_TYPE_FILE_LOADER);
1364 ANJUTA_PLUGIN_END;
1366 ANJUTA_SIMPLE_PLUGIN (AnjutaFileLoaderPlugin, anjuta_file_loader_plugin);