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-wizard.h>
32 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-file-wizard.ui"
33 #define ICON_FILE "anjuta-file-wizard-plugin.png"
35 static gpointer parent_class
;
38 project_root_added (AnjutaPlugin
*plugin
, const gchar
*name
,
39 const GValue
*value
, gpointer user_data
)
41 AnjutaFileWizardPlugin
*w_plugin
;
42 const gchar
*root_uri
;
44 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
45 root_uri
= g_value_get_string (value
);
49 gchar
*root_dir
= gnome_vfs_get_local_path_from_uri (root_uri
);
51 w_plugin
->top_dir
= g_strdup(root_dir
);
53 w_plugin
->top_dir
= NULL
;
57 w_plugin
->top_dir
= NULL
;
61 project_root_removed (AnjutaPlugin
*plugin
, const gchar
*name
,
64 AnjutaFileWizardPlugin
*w_plugin
;
65 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
67 g_free (w_plugin
->top_dir
);
68 w_plugin
->top_dir
= NULL
;
72 activate_plugin (AnjutaPlugin
*plugin
)
74 AnjutaFileWizardPlugin
*w_plugin
;
75 static gboolean initialized
= FALSE
;
77 DEBUG_PRINT ("AnjutaFileWizardPlugin: Activating File wizard plugin ...");
78 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
79 w_plugin
->prefs
= anjuta_shell_get_preferences (plugin
->shell
, NULL
);
81 /* set up project directory watch */
82 w_plugin
->root_watch_id
= anjuta_plugin_add_watch (plugin
,
92 deactivate_plugin (AnjutaPlugin
*plugin
)
94 AnjutaFileWizardPlugin
*w_plugin
;
95 w_plugin
= ANJUTA_PLUGIN_FILE_WIZARD (plugin
);
96 anjuta_plugin_remove_watch (plugin
, w_plugin
->root_watch_id
, TRUE
);
101 dispose (GObject
*obj
)
103 G_OBJECT_CLASS (parent_class
)->dispose (obj
);
107 finalize (GObject
*obj
)
109 /* Finalization codes here */
110 G_OBJECT_CLASS (parent_class
)->finalize (obj
);
114 file_wizard_plugin_instance_init (GObject
*obj
)
116 AnjutaFileWizardPlugin
*plugin
= ANJUTA_PLUGIN_FILE_WIZARD (obj
);
117 plugin
->top_dir
= NULL
;
121 file_wizard_plugin_class_init (GObjectClass
*klass
)
123 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
125 parent_class
= g_type_class_peek_parent (klass
);
127 plugin_class
->activate
= activate_plugin
;
128 plugin_class
->deactivate
= deactivate_plugin
;
129 klass
->dispose
= dispose
;
130 klass
->finalize
= finalize
;
134 iwizard_activate (IAnjutaWizard
*wiz
, GError
**err
)
136 AnjutaFileWizardPlugin
*plugin
;
137 IAnjutaDocumentManager
*docman
;
139 plugin
= ANJUTA_PLUGIN_FILE_WIZARD (wiz
);
140 docman
= anjuta_shell_get_interface (ANJUTA_PLUGIN (wiz
)->shell
,
141 IAnjutaDocumentManager
, NULL
);
142 display_new_file(plugin
, docman
);
146 iwizard_iface_init (IAnjutaWizardIface
*iface
)
148 iface
->activate
= iwizard_activate
;
151 ANJUTA_PLUGIN_BEGIN (AnjutaFileWizardPlugin
, file_wizard_plugin
);
152 ANJUTA_PLUGIN_ADD_INTERFACE(iwizard
, IANJUTA_TYPE_WIZARD
);
155 ANJUTA_SIMPLE_PLUGIN (AnjutaFileWizardPlugin
, file_wizard_plugin
);