2 * configurer.c Copyright (C) 2000 Kh. Naba Kumar Singh
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc., 59
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <sys/types.h>
32 #include <libanjuta/resources.h>
35 #include "message-manager.h"
36 #include "text_editor.h"
37 #include "utilities.h"
39 #include "configurer.h"
40 #include "build_file.h"
42 static GtkWidget
* create_configurer_dialog (Configurer
* c
);
43 static void on_configurer_response (GtkDialog
*dialog
, gint res
, gpointer data
);
44 static void on_configurer_entry_changed (GtkEditable
*editable
, gpointer data
);
46 static void on_configurer_environment_changed (GtkEditable * editable,
51 configurer_new (PropsID props
)
53 Configurer
*c
= g_new0 (Configurer
, 1);
59 configurer_destroy (Configurer
* c
)
61 g_return_if_fail (c
!= NULL
);
66 configurer_show (Configurer
* c
)
68 gtk_widget_show (create_configurer_dialog (c
));
72 create_configurer_dialog (Configurer
* c
)
79 gxml
= glade_xml_new (GLADE_FILE_ANJUTA
, "configurer_dialog", NULL
);
80 dialog
= glade_xml_get_widget (gxml
, "configurer_dialog");
81 g_signal_connect (G_OBJECT (dialog
), "response",
82 G_CALLBACK (on_configurer_response
), c
);
83 gtk_widget_show (dialog
);
85 entry
= glade_xml_get_widget (gxml
, "configurer_entry");
86 options
= prop_get (c
->props
, "project.configure.options");
89 gtk_entry_set_text (GTK_ENTRY (entry
), options
);
92 g_signal_connect (G_OBJECT (entry
), "changed",
93 G_CALLBACK (on_configurer_entry_changed
), c
);
95 /* Not implemented yet
97 entry = glade_xml_get_widget (gxml, "configurer_environment_entry");
98 options = prop_get (c->props, "project.configure.environment");
101 gtk_entry_set_text (GTK_ENTRY (entry), options);
104 g_signal_connect (G_OBJECT (entry), "changed",
105 G_CALLBACK (on_configurer_environment_changed), c); */
107 g_object_unref (G_OBJECT (gxml
));
109 /* gtk_accel_group_attach (app->accel_group, GTK_OBJECT (dialog)); */
114 on_configurer_entry_changed (GtkEditable
* editable
, gpointer user_data
)
116 Configurer
*c
= (Configurer
*) user_data
;
117 const gchar
*options
;
118 options
= gtk_entry_get_text (GTK_ENTRY (editable
));
120 prop_set_with_key (c
->props
, "project.configure.options",
123 prop_set_with_key (c
->props
, "project.configure.options", "");
129 on_configurer_environment_changed (GtkEditable
* editable
, gpointer user_data
)
131 Configurer
*c
= (Configurer
*) user_data
;
132 const gchar
*options
;
133 options
= gtk_entry_get_text (GTK_ENTRY (editable
));
135 prop_set_with_key (c
->props
, "project.configure.environment",
138 prop_set_with_key (c
->props
, "project.configure.environment", "");
143 on_configurer_response (GtkDialog
* dialog
, gint res
, gpointer user_data
)
146 gchar
*tmp
, *options
;
149 g_return_if_fail (cof
!= NULL
);
150 if (res
== GTK_RESPONSE_OK
)
152 g_return_if_fail (app
->project_dbase
->project_is_open
);
154 chdir (app
->project_dbase
->top_proj_dir
);
155 if (file_is_executable ("./configure") == FALSE
)
158 ("Project does not have an executable configure script.\n"
159 "Auto generate the Project first."));
162 options
= prop_get (cof
->props
, "project.configure.options");
165 tmp
= g_strconcat ("./configure ", options
, NULL
);
170 tmp
= g_strdup ("./configure ");
172 options
= prop_get(cof
->props
, "project.configure.environment");
175 gchar
*tmp1
= g_strdup_printf("sh -c '%s %s'", options
, tmp
);
180 g_message("Executing '%s'\n", tmp
);
182 if (build_execute_command (tmp
) == FALSE
)
184 anjuta_error ("Project configuration failed.");
189 anjuta_update_app_status (TRUE
, _("Configure"));
190 an_message_manager_clear (app
->messages
, MESSAGE_BUILD
);
191 an_message_manager_append (app
->messages
, _("Configuring the Project...\n"), MESSAGE_BUILD
);
192 an_message_manager_show (app
->messages
, MESSAGE_BUILD
);
194 gtk_widget_destroy (GTK_WIDGET (dialog
));