1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
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
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>
29 #include "project-import.h"
31 #define ICON_FILE "anjuta-project-import-plugin-48.png"
33 static gpointer parent_class
;
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
);
49 deactivate_plugin (AnjutaPlugin
*plugin
)
51 AnjutaProjectImportPlugin
*iplugin
;
52 iplugin
= ANJUTA_PLUGIN_PROJECT_IMPORT (plugin
);
57 dispose (GObject
*obj
)
59 GNOME_CALL_PARENT (G_OBJECT_CLASS
, dispose
, (obj
));
63 project_import_plugin_instance_init (GObject
*obj
)
65 // AnjutaFileWizardPlugin *plugin = ANJUTA_PLUGIN_PROJECT_IMPORT (obj);
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
;
81 iwizard_activate (IAnjutaWizard
*wiz
, GError
**err
)
83 AnjutaProjectImportPlugin
* plugin
= ANJUTA_PLUGIN_PROJECT_IMPORT (wiz
);
86 pi
= project_import_new(ANJUTA_PLUGIN(plugin
));
90 iwizard_iface_init (IAnjutaWizardIface
*iface
)
92 iface
->activate
= iwizard_activate
;
96 ifile_open (IAnjutaFile
*file
, const gchar
*uri
, GError
**err
)
98 gchar
*dir
, *ext
, *project_name
;
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
, '.');
110 pi
= project_import_new(ANJUTA_PLUGIN(plugin
));
111 project_import_set_name (pi
, project_name
);
112 project_import_set_directory (pi
, dir
);
116 ifile_get_uri (IAnjutaFile
*file
, GError
**err
)
118 g_warning ("Unsupported operation");
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
);
134 ANJUTA_SIMPLE_PLUGIN (AnjutaProjectImportPlugin
, project_import_plugin
);