Updated Spanish translation
[anjuta-git-plugin.git] / plugins / project-wizard / plugin.c
blob09f48a096846276bb1e03ff71cf590b83269dce7
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 plugin.c
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Plugins functions
24 *---------------------------------------------------------------------------*/
26 #include <config.h>
28 #include "plugin.h"
30 #include "druid.h"
32 #include <libanjuta/anjuta-debug.h>
33 #include <libanjuta/interfaces/ianjuta-wizard.h>
35 /*---------------------------------------------------------------------------*/
37 /* Used in dispose */
38 static gpointer parent_class;
40 static void
41 npw_plugin_instance_init (GObject *obj)
43 NPWPlugin *this = ANJUTA_PLUGIN_NPW (obj);
45 this->druid = NULL;
46 this->install = NULL;
47 this->view = NULL;
50 /* dispose is used to unref object created with instance_init */
52 static void
53 npw_plugin_dispose (GObject *obj)
55 NPWPlugin *this = ANJUTA_PLUGIN_NPW (obj);
57 /* Warning this function could be called several times */
58 if (this->view != NULL)
60 g_object_remove_weak_pointer (G_OBJECT (this->view),
61 (gpointer*)&this->view);
62 this->view = NULL;
65 GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (G_OBJECT (obj)));
68 /* finalize used to free object created with instance init is not used */
70 static gboolean
71 npw_plugin_activate (AnjutaPlugin *plugin)
73 DEBUG_PRINT ("Project Wizard Plugin: Activating project wizard plugin...");
74 return TRUE;
77 static gboolean
78 npw_plugin_deactivate (AnjutaPlugin *plugin)
80 DEBUG_PRINT ("Project Wizard Plugin: Deactivating project wizard plugin...");
81 return TRUE;
84 static void
85 npw_plugin_class_init (GObjectClass *klass)
87 AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
89 parent_class = g_type_class_peek_parent (klass);
91 plugin_class->activate = npw_plugin_activate;
92 plugin_class->deactivate = npw_plugin_deactivate;
93 klass->dispose = npw_plugin_dispose;
96 static void
97 iwizard_activate (IAnjutaWizard *wiz, GError **err)
99 NPWPlugin *this = ANJUTA_PLUGIN_NPW (wiz);
101 if (this->install != NULL)
103 /* New project wizard is busy copying project file */
105 else if (this->druid == NULL)
107 /* Create a new project wizard druid */
108 npw_druid_new (this);
111 if (this->druid != NULL)
113 /* New project wizard druid is waiting for user inputs */
114 npw_druid_show (this->druid);
118 static void
119 iwizard_iface_init (IAnjutaWizardIface *iface)
121 iface->activate = iwizard_activate;
124 ANJUTA_PLUGIN_BEGIN (NPWPlugin, npw_plugin);
125 ANJUTA_PLUGIN_ADD_INTERFACE (iwizard, IANJUTA_TYPE_WIZARD);
126 ANJUTA_PLUGIN_END;
128 ANJUTA_SIMPLE_PLUGIN (NPWPlugin, npw_plugin);
130 /* Control access to anjuta message view to avoid a closed view
131 *---------------------------------------------------------------------------*/
133 static void
134 on_message_buffer_flush (IAnjutaMessageView *view, const gchar *line,
135 NPWPlugin *this)
137 npw_plugin_print_view (this, IANJUTA_MESSAGE_VIEW_TYPE_NORMAL, line, "");
140 IAnjutaMessageView*
141 npw_plugin_create_view (NPWPlugin* this)
143 if (this->view == NULL)
145 IAnjutaMessageManager* man;
147 man = anjuta_shell_get_interface (ANJUTA_PLUGIN (this)->shell,
148 IAnjutaMessageManager, NULL);
149 this->view =
150 ianjuta_message_manager_add_view (man, _("New Project Wizard"),
151 ICON_FILE, NULL);
152 if (this->view != NULL)
154 g_signal_connect (G_OBJECT (this->view), "buffer_flushed",
155 G_CALLBACK (on_message_buffer_flush), this);
156 g_object_add_weak_pointer (G_OBJECT (this->view),
157 (gpointer *)&this->view);
160 else
162 ianjuta_message_view_clear (this->view, NULL);
165 return this->view;
168 void
169 npw_plugin_append_view (NPWPlugin* this, const gchar* text)
171 if (this->view)
173 ianjuta_message_view_buffer_append (this->view, text, NULL);
177 void
178 npw_plugin_print_view (NPWPlugin* this, IAnjutaMessageViewType type,
179 const gchar* summary, const gchar* details)
181 if (this->view)
183 ianjuta_message_view_append (this->view, type, summary, details, NULL);