1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2000 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
22 #include <gtk/gtkactiongroup.h>
23 #include <glib/gi18n.h>
24 #include <libgnomevfs/gnome-vfs-utils.h>
25 #include <libanjuta/anjuta-debug.h>
26 #include <libanjuta/interfaces/ianjuta-document-manager.h>
27 #include <libanjuta/interfaces/ianjuta-project-manager.h>
28 #include <libanjuta/interfaces/ianjuta-wizard.h>
33 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-file-wizard.ui"
34 #define ICON_FILE "anjuta-file-wizard-plugin.png"
36 static gpointer parent_class
;
39 project_root_added (AnjutaPlugin
*plugin
, const gchar
*name
,
40 const GValue
*value
, gpointer user_data
)
42 AnjutaFileWizardPlugin
*w_plugin
;
43 const gchar
*root_uri
;
45 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
46 root_uri
= g_value_get_string (value
);
50 gchar
*root_dir
= gnome_vfs_get_local_path_from_uri (root_uri
);
52 w_plugin
->top_dir
= g_strdup(root_dir
);
54 w_plugin
->top_dir
= NULL
;
58 w_plugin
->top_dir
= NULL
;
62 project_root_removed (AnjutaPlugin
*plugin
, const gchar
*name
,
65 AnjutaFileWizardPlugin
*w_plugin
;
66 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
68 g_free (w_plugin
->top_dir
);
69 w_plugin
->top_dir
= NULL
;
73 activate_plugin (AnjutaPlugin
*plugin
)
75 AnjutaFileWizardPlugin
*w_plugin
;
76 static gboolean initialized
= FALSE
;
78 DEBUG_PRINT ("AnjutaFileWizardPlugin: Activating File wizard plugin ...");
79 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
80 w_plugin
->prefs
= anjuta_shell_get_preferences (plugin
->shell
, NULL
);
82 /* set up project directory watch */
83 w_plugin
->root_watch_id
= anjuta_plugin_add_watch (plugin
,
84 IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI
,
93 deactivate_plugin (AnjutaPlugin
*plugin
)
95 AnjutaFileWizardPlugin
*w_plugin
;
96 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
97 anjuta_plugin_remove_watch (plugin
, w_plugin
->root_watch_id
, TRUE
);
102 dispose (GObject
*obj
)
104 G_OBJECT_CLASS (parent_class
)->dispose (obj
);
108 finalize (GObject
*obj
)
110 /* Finalization codes here */
111 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
115 file_wizard_plugin_instance_init (GObject
*obj
)
117 AnjutaFileWizardPlugin
*plugin
= ANJUTA_PLUGIN_FILE_WIZARD (obj
);
118 plugin
->top_dir
= NULL
;
122 file_wizard_plugin_class_init (GObjectClass
*klass
)
124 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
126 parent_class
= g_type_class_peek_parent (klass
);
128 plugin_class
->activate
= activate_plugin
;
129 plugin_class
->deactivate
= deactivate_plugin
;
130 klass
->dispose
= dispose
;
131 klass
->finalize
= finalize
;
135 iwizard_activate (IAnjutaWizard
*wiz
, GError
**err
)
137 AnjutaFileWizardPlugin
*plugin
;
138 IAnjutaDocumentManager
*docman
;
140 plugin
= ANJUTA_PLUGIN_FILE_WIZARD (wiz
);
141 docman
= anjuta_shell_get_interface (ANJUTA_PLUGIN (wiz
)->shell
,
142 IAnjutaDocumentManager
, NULL
);
143 display_new_file(plugin
, docman
);
147 iwizard_iface_init (IAnjutaWizardIface
*iface
)
149 iface
->activate
= iwizard_activate
;
152 ANJUTA_PLUGIN_BEGIN (AnjutaFileWizardPlugin
, file_wizard_plugin
);
153 ANJUTA_PLUGIN_ADD_INTERFACE(iwizard
, IANJUTA_TYPE_WIZARD
);
156 ANJUTA_SIMPLE_PLUGIN (AnjutaFileWizardPlugin
, file_wizard_plugin
);