Updated Spanish translation
[anjuta-git-plugin.git] / plugins / build / clean_project.c
blob3ed1cb58629893fde8e65bc8bb8a9f33160654b8
1 /*
2 clean_project.c
3 Copyright (C) 2000 Kh. Naba Kumar Singh
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
23 #include <sys/stat.h>
24 #include <unistd.h>
25 #include <sys/types.h>
26 #include <sys/wait.h>
27 #include <signal.h>
28 #include <string.h>
29 #include <time.h>
31 #include <gnome.h>
32 #include "anjuta.h"
33 #include "build_file.h"
34 #include "launcher.h"
35 #include "clean_project.h"
36 #include "build_project.h"
39 static void (*on_clean_finished_cb) (void);
41 void
42 clean_project (void (*on_clean_cb) (void))
44 gchar *cmd, *prj_name;
46 if(app->project_dbase->is_saved == FALSE
47 && app->project_dbase->project_is_open==TRUE)
49 gboolean ret;
50 ret = project_dbase_save_project(app->project_dbase);
51 if (ret == FALSE)
52 return;
55 if (app->project_dbase->project_is_open)
57 cmd = command_editor_get_command (app->command_editor,
58 COMMAND_BUILD_CLEAN);
59 if (cmd == NULL)
61 anjuta_warning (_("Unable to clean Project. Check Settings->Commands."));
62 return;
64 chdir (app->project_dbase->top_proj_dir);
66 /* set up the callback for a successful finish */
67 on_clean_finished_cb = on_clean_cb;
69 /* launche 'make clean' */
70 if (build_execute_command (cmd) == FALSE)
72 g_free (cmd);
73 return;
76 anjuta_update_app_status (TRUE, _("Clean"));
77 an_message_manager_clear (app->messages, MESSAGE_BUILD);
78 an_message_manager_append (app->messages,
79 _("Cleaning the source directory of the Project: "),
80 MESSAGE_BUILD);
81 prj_name = project_dbase_get_proj_name (app->project_dbase);
82 an_message_manager_append (app->messages, prj_name, MESSAGE_BUILD);
83 an_message_manager_append (app->messages, " ...\n", MESSAGE_BUILD);
84 an_message_manager_append (app->messages, cmd, MESSAGE_BUILD);
85 an_message_manager_append (app->messages, "\n", MESSAGE_BUILD);
86 an_message_manager_append (app->messages, "", MESSAGE_BUILD); // Maybe something is missing here
87 an_message_manager_show (app->messages, MESSAGE_BUILD);
88 g_free (cmd);
89 g_free (prj_name);
93 void
94 clean_all_project ()
96 gchar *cmd, *prj_name;
98 if(app->project_dbase->is_saved == FALSE
99 && app->project_dbase->project_is_open==TRUE)
101 gboolean ret;
102 ret = project_dbase_save_project(app->project_dbase);
103 if (ret == FALSE)
104 return;
107 if (app->project_dbase->project_is_open)
109 cmd =
110 command_editor_get_command (app->command_editor,
111 COMMAND_BUILD_CLEAN_ALL);
112 if (cmd == NULL)
114 anjuta_warning (_
115 ("Unable to Clean All for the Project. Check Settings->Commands."));
116 return;
118 chdir (app->project_dbase->top_proj_dir);
119 if (build_execute_command (cmd) == FALSE)
121 g_free (cmd);
122 return;
124 anjuta_update_app_status (TRUE, _("Clean All"));
125 an_message_manager_clear (app->messages, MESSAGE_BUILD);
126 an_message_manager_append (app->messages,
127 _("Cleaning whole of the Project: "),
128 MESSAGE_BUILD);
129 prj_name = project_dbase_get_proj_name (app->project_dbase);
130 an_message_manager_append (app->messages, prj_name, MESSAGE_BUILD);
131 an_message_manager_append (app->messages, " ...\n", MESSAGE_BUILD);
132 an_message_manager_append (app->messages, cmd, MESSAGE_BUILD);
133 an_message_manager_append (app->messages, "\n", MESSAGE_BUILD);
134 an_message_manager_show (app->messages, MESSAGE_BUILD);
135 g_free (cmd);
136 g_free (prj_name);