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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *---------------------------------------------------------------------------*/
32 #include <libanjuta/anjuta-debug.h>
33 #include <libanjuta/interfaces/ianjuta-wizard.h>
35 /*---------------------------------------------------------------------------*/
38 static gpointer parent_class
;
41 npw_plugin_instance_init (GObject
*obj
)
43 NPWPlugin
*this = ANJUTA_PLUGIN_NPW (obj
);
50 /* dispose is used to unref object created with instance_init */
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
);
65 GNOME_CALL_PARENT (G_OBJECT_CLASS
, dispose
, (G_OBJECT (obj
)));
68 /* finalize used to free object created with instance init is not used */
71 npw_plugin_activate (AnjutaPlugin
*plugin
)
73 DEBUG_PRINT ("Project Wizard Plugin: Activating project wizard plugin...");
78 npw_plugin_deactivate (AnjutaPlugin
*plugin
)
80 DEBUG_PRINT ("Project Wizard Plugin: Deactivating project wizard plugin...");
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
;
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
);
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
);
128 ANJUTA_SIMPLE_PLUGIN (NPWPlugin
, npw_plugin
);
130 /* Control access to anjuta message view to avoid a closed view
131 *---------------------------------------------------------------------------*/
134 on_message_buffer_flush (IAnjutaMessageView
*view
, const gchar
*line
,
137 npw_plugin_print_view (this, IANJUTA_MESSAGE_VIEW_TYPE_NORMAL
, line
, "");
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
);
150 ianjuta_message_manager_add_view (man
, _("New Project Wizard"),
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
);
162 ianjuta_message_view_clear (this->view
, NULL
);
169 npw_plugin_append_view (NPWPlugin
* this, const gchar
* text
)
173 ianjuta_message_view_buffer_append (this->view
, text
, NULL
);
178 npw_plugin_print_view (NPWPlugin
* this, IAnjutaMessageViewType type
,
179 const gchar
* summary
, const gchar
* details
)
183 ianjuta_message_view_append (this->view
, type
, summary
, details
, NULL
);