2008-02-11 Johannes Schmid <jhs@gnome.org>
[anjuta-git-plugin.git] / plugins / project-import / plugin.c
blob256d1ff354ae4abc796243bed9c4eab12eb50ae6
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 plugin.c
4 Copyright (C) 2000 Naba Kumar, 2005 Johannes Schmid
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 <gtk/gtkactiongroup.h>
23 #include <libgnome/gnome-i18n.h>
24 #include <libanjuta/anjuta-debug.h>
25 #include <libanjuta/interfaces/ianjuta-wizard.h>
26 #include <libanjuta/interfaces/ianjuta-file.h>
28 #include "plugin.h"
29 #include "project-import.h"
31 #define ICON_FILE "anjuta-project-import-plugin-48.png"
33 static gpointer parent_class;
35 static gboolean
36 activate_plugin (AnjutaPlugin *plugin)
38 AnjutaProjectImportPlugin *iplugin;
40 DEBUG_PRINT ("AnjutaProjectImportPlugin: Activating Project Import Plugin ...");
42 iplugin = ANJUTA_PLUGIN_PROJECT_IMPORT (plugin);
43 iplugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
45 return TRUE;
48 static gboolean
49 deactivate_plugin (AnjutaPlugin *plugin)
51 AnjutaProjectImportPlugin *iplugin;
52 iplugin = ANJUTA_PLUGIN_PROJECT_IMPORT (plugin);
53 return TRUE;
56 static void
57 dispose (GObject *obj)
59 GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (obj));
62 static void
63 project_import_plugin_instance_init (GObject *obj)
65 // AnjutaFileWizardPlugin *plugin = ANJUTA_PLUGIN_PROJECT_IMPORT (obj);
68 static void
69 project_import_plugin_class_init (GObjectClass *klass)
71 AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
73 parent_class = g_type_class_peek_parent (klass);
75 plugin_class->activate = activate_plugin;
76 plugin_class->deactivate = deactivate_plugin;
77 klass->dispose = dispose;
80 static void
81 iwizard_activate (IAnjutaWizard *wiz, GError **err)
83 AnjutaProjectImportPlugin* plugin = ANJUTA_PLUGIN_PROJECT_IMPORT (wiz);
84 ProjectImport* pi;
86 pi = project_import_new(ANJUTA_PLUGIN(plugin));
89 static void
90 iwizard_iface_init (IAnjutaWizardIface *iface)
92 iface->activate = iwizard_activate;
95 static void
96 ifile_open (IAnjutaFile *file, const gchar *uri, GError **err)
98 gchar *dir, *ext, *project_name;
99 ProjectImport* pi;
100 AnjutaProjectImportPlugin* plugin = ANJUTA_PLUGIN_PROJECT_IMPORT (file);
102 g_return_if_fail (uri != NULL && strlen (uri) > 0);
104 dir = g_path_get_dirname (uri);
105 project_name = g_path_get_basename (uri);
106 ext = strrchr (project_name, '.');
107 if (ext)
108 *ext = '\0';
110 pi = project_import_new(ANJUTA_PLUGIN(plugin));
111 project_import_set_name (pi, project_name);
112 project_import_set_directory (pi, dir);
115 static gchar*
116 ifile_get_uri (IAnjutaFile *file, GError **err)
118 g_warning ("Unsupported operation");
119 return NULL;
122 static void
123 ifile_iface_init (IAnjutaFileIface *iface)
125 iface->open = ifile_open;
126 iface->get_uri = ifile_get_uri;
129 ANJUTA_PLUGIN_BEGIN (AnjutaProjectImportPlugin, project_import_plugin);
130 ANJUTA_PLUGIN_ADD_INTERFACE(iwizard, IANJUTA_TYPE_WIZARD);
131 ANJUTA_PLUGIN_ADD_INTERFACE(ifile, IANJUTA_TYPE_FILE);
132 ANJUTA_PLUGIN_END;
134 ANJUTA_SIMPLE_PLUGIN (AnjutaProjectImportPlugin, project_import_plugin);