Commit a46b338b authored by Naba Kumar's avatar Naba Kumar

Adds the functionality to Anjuta to auto save your unsaved files before

	* src/preferences.h,
	  src/preferences.c,
	  src/preferences_gui.c:

	  Adds the functionality to Anjuta to auto save your unsaved
	  files before you build a project.

	  Patch submitted by:
	  jason <jason_williams@suth.com>

	* src/anjuta.[h,c]:
	  Added function for save all files.

	* src/mainmenu_callbacks.c:
	  Modified to use the above function.

	* src/build_project.c:
	  Save all files before build if it is set in the
	  preferences.
parent 292309c1
2002-01-17 Naba Kumar <kh_naba@users.sourceforge.net>
* src/preferences.h,
src/preferences.c,
src/preferences_gui.c:
Adds the functionality to Anjuta to auto save your unsaved
files before you build a project.
Patch submitted by:
jason <jason_williams@suth.com>
* src/anjuta.[h,c]:
Added function for save all files.
* src/mainmenu_callbacks.c:
Modified to use the above function.
* src/build_project.c:
Save all files before build if it is set in the
preferences.
2002-01-17 Naba Kumar <kh_naba@users.sourceforge.net>
* src/message-manager-private.cc
......
......@@ -971,6 +971,22 @@ gboolean anjuta_load_yourself (PropsID pr)
return TRUE;
}
void
anjuta_save_all_files()
{
TextEditor *te;
int i;
tags_manager_freeze (app->tags_manager);
for (i = 0; i < g_list_length (app->text_editor_list); i++)
{
te = g_list_nth_data (app->text_editor_list, i);
if (te->full_filename && !text_editor_is_saved (te))
text_editor_save_file (te);
}
tags_manager_thaw (app->tags_manager);
anjuta_status (_("All files saved ..."));
}
void
anjuta_update_title ()
{
......
......@@ -213,6 +213,8 @@ TextEditor *anjuta_get_notebook_text_editor (gint page_num);
void anjuta_save_settings (void);
void anjuta_save_all_files(void);
gboolean anjuta_save_yourself (FILE * stream);
gboolean anjuta_load_yourself (PropsID pr);
......
......@@ -48,12 +48,12 @@ build_project ()
if (ret == FALSE)
return;
}
src_dir = project_dbase_get_module_dir (app->project_dbase, MODULE_SOURCE);
if (src_dir)
{
gchar *prj_name, *cmd;
cmd = command_editor_get_command (app->command_editor, COMMAND_BUILD_MODULE);
if (cmd == NULL)
{
......@@ -65,6 +65,11 @@ build_project ()
anjuta_set_execution_dir(src_dir);
g_free (src_dir);
if(preferences_get_int(app->preferences, BUILD_OPTION_AUTOSAVE))
{
anjuta_save_all_files();
}
if (launcher_execute
(cmd, build_mesg_arrived, build_mesg_arrived,
build_terminated) == FALSE)
......@@ -105,7 +110,7 @@ build_all_project ()
if (ret == FALSE)
return;
}
if (app->project_dbase->project_is_open)
{
cmd = command_editor_get_command (app->command_editor, COMMAND_BUILD_PROJECT);
......@@ -116,6 +121,12 @@ build_all_project ()
}
chdir (app->project_dbase->top_proj_dir);
anjuta_set_execution_dir(app->project_dbase->top_proj_dir);
if(preferences_get_int(app->preferences, BUILD_OPTION_AUTOSAVE))
{
anjuta_save_all_files();
}
if (launcher_execute
(cmd, build_mesg_arrived, build_mesg_arrived,
build_all_terminated) == FALSE)
......@@ -152,7 +163,7 @@ build_dist_project ()
if (ret == FALSE)
return;
}
if (app->project_dbase->project_is_open)
{
cmd = command_editor_get_command (app->command_editor, COMMAND_BUILD_TARBALL);
......@@ -164,6 +175,12 @@ build_dist_project ()
}
chdir (app->project_dbase->top_proj_dir);
anjuta_set_execution_dir(app->project_dbase->top_proj_dir);
if(preferences_get_int(app->preferences, BUILD_OPTION_AUTOSAVE))
{
anjuta_save_all_files();
}
if (launcher_execute
(cmd, build_mesg_arrived, build_mesg_arrived,
build_dist_terminated) == FALSE)
......@@ -213,6 +230,12 @@ build_install_project ()
}
chdir (app->project_dbase->top_proj_dir);
anjuta_set_execution_dir(app->project_dbase->top_proj_dir);
if(preferences_get_int(app->preferences, BUILD_OPTION_AUTOSAVE))
{
anjuta_save_all_files();
}
if (launcher_execute
(cmd, build_mesg_arrived, build_mesg_arrived,
build_install_terminated) == FALSE)
......@@ -267,6 +290,12 @@ build_autogen_project ()
return;
}
}
if(preferences_get_int(app->preferences, BUILD_OPTION_AUTOSAVE))
{
anjuta_save_all_files();
}
if (launcher_execute
(cmd, build_mesg_arrived, build_mesg_arrived,
build_autogen_terminated) == FALSE)
......
......@@ -110,17 +110,7 @@ on_save_as1_activate (GtkMenuItem * menuitem, gpointer user_data)
void
on_save_all1_activate (GtkMenuItem * menuitem, gpointer user_data)
{
TextEditor *te;
int i;
tags_manager_freeze (app->tags_manager);
for (i = 0; i < g_list_length (app->text_editor_list); i++)
{
te = g_list_nth_data (app->text_editor_list, i);
if (te->full_filename && !text_editor_is_saved (te))
text_editor_save_file (te);
}
tags_manager_thaw (app->tags_manager);
anjuta_status (_("All files saved ..."));
anjuta_save_all_files();
}
void
......
......@@ -157,7 +157,8 @@ preferences_destroy (Preferences * pr)
gtk_widget_unref (pr->widgets.build_debug_check);
gtk_widget_unref (pr->widgets.build_warn_undef_check);
gtk_widget_unref (pr->widgets.build_jobs_spin);
// gtk_widget_unref (pr->widgets.build_autosave_check);
gtk_widget_unref (pr->widgets.auto_save_check);
gtk_widget_unref (pr->widgets.auto_indent_check);
gtk_widget_unref (pr->widgets.tab_size_spin);
......@@ -309,6 +310,12 @@ preferences_sync (Preferences * pr)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(pr->widgets.build_warn_undef_check),
preferences_get_int (pr, BUILD_OPTION_WARN_UNDEF));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
(pr->widgets.build_autosave_check),
preferences_get_int (pr, BUILD_OPTION_AUTOSAVE));
gtk_spin_button_set_value (GTK_SPIN_BUTTON
(pr->widgets.build_jobs_spin),
preferences_get_int (pr, BUILD_OPTION_JOBS));
......@@ -685,7 +692,9 @@ gboolean preferences_save_yourself (Preferences * pr, FILE * fp)
fprintf (fp, "%s=%d\n", BUILD_OPTION_JOBS,
preferences_get_int (pr, BUILD_OPTION_JOBS));
fprintf (fp, "%s=%d", BUILD_OPTION_AUTOSAVE,
preferences_get_int (pr, BUILD_OPTION_AUTOSAVE));
/* Page 2 */
for (i = 0;; i += 2)
{
......
......@@ -72,6 +72,7 @@ struct _PreferencesWidgets
GtkWidget *build_debug_check;
GtkWidget *build_warn_undef_check;
GtkWidget *build_jobs_spin;
GtkWidget *build_autosave_check;
/*
* * page2
......@@ -258,6 +259,7 @@ void preferences_set_build_options(Preferences* p);
#define BUILD_OPTION_SILENT "build.option.silent"
#define BUILD_OPTION_WARN_UNDEF "build.option.warn.undef"
#define BUILD_OPTION_JOBS "build.option.jobs"
#define BUILD_OPTION_AUTOSAVE "build.option.autosave"
#define DISABLE_SYNTAX_HILIGHTING "disable.syntax.hilighting"
#define SAVE_AUTOMATIC "save.automatic"
......
......@@ -534,6 +534,7 @@ create_preferences_page1 (Preferences * p)
GtkWidget *checkbutton2;
GtkWidget *checkbutton3;
GtkWidget *checkbutton6;
GtkWidget *checkbutton7;
GtkWidget *hseparator1;
GtkWidget *hbox1;
GtkWidget *label1;
......@@ -576,6 +577,14 @@ create_preferences_page1 (Preferences * p)
gtk_box_pack_start (GTK_BOX (vbox1), checkbutton6, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (checkbutton6), 5);
checkbutton7 =
gtk_check_button_new_with_label(_
("Autosave Before Build"));
gtk_widget_show(checkbutton7);
gtk_box_pack_start(GTK_BOX (vbox1), checkbutton7, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (checkbutton7), 5);
hseparator1 = gtk_hseparator_new ();
gtk_widget_show (hseparator1);
gtk_box_pack_start (GTK_BOX (vbox1), hseparator1, FALSE, FALSE, 0);
......@@ -601,12 +610,14 @@ create_preferences_page1 (Preferences * p)
p->widgets.build_debug_check = checkbutton3;
p->widgets.build_warn_undef_check = checkbutton6;
p->widgets.build_jobs_spin = spinbutton1;
p->widgets.build_autosave_check = checkbutton7;
gtk_widget_ref (checkbutton1);
gtk_widget_ref (checkbutton2);
gtk_widget_ref (checkbutton3);
gtk_widget_ref (checkbutton6);
gtk_widget_ref (spinbutton1);
gtk_widget_ref (checkbutton7);
return frame1;
}
......@@ -1810,10 +1821,14 @@ on_preferences_apply_clicked (GtkButton * button, gpointer user_data)
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(pr->widgets.build_warn_undef_check)));
preferences_set_int (pr, BUILD_OPTION_AUTOSAVE,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(pr->widgets.build_autosave_check)));
preferences_set_int (pr, BUILD_OPTION_JOBS,
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
(pr->widgets.build_jobs_spin)));
/* page 2 */
for (i = 0;; i += 2)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment