Index: gedit/gedit/ChangeLog
===================================================================
RCS file: /export/cvs/head/gedit/gedit/ChangeLog,v
retrieving revision 1.715
diff -p -u -5 -r1.715 ChangeLog
--- gedit/gedit/ChangeLog	2004/12/07 13:20:37	1.715
+++ gedit/gedit/ChangeLog	2004/12/09 12:19:34
@@ -1,5 +1,22 @@
+2004-12-09  Archana Shah <archana.shah@wipro.com>
+
+	* gedit-document.h: Added prototype for
+	gedit_document_set_auto_save_timer(), and
+	gedit_docuent_set_auto_save_interval_timer().
+
+	* gedit-document.c: (gedit_document_set_auto_save_timer):
+	Function added to take appropriate action when the auto save
+	button is tooggled.
+	(gedit_document_set_auto_save_interval_timer):
+	Function added to take appropriate action when auto save interval
+	is changed.
+
+	* gedit-preferences-manager-app.c:
+        (gedit_prefs_manager_auto_save_changed): Function added to be notified
+        when auto save button is toggled or auto save interval is changed.
+
 2004-12-07  Arvind Samptur  <arvind.samptur@wipro.com>
 
 	Patch from Srirama Sharma  <srirama.sharma@wipro.com>
 
 	* gedit/dialogs/gedit-page-setup-dialog.c: Setting the AtkRelation 
Index: gedit/gedit/gedit-document.c
===================================================================
RCS file: /export/cvs/head/gedit/gedit/gedit-document.c,v
retrieving revision 1.106
diff -p -u -5 -r1.106 gedit-document.c
--- gedit/gedit/gedit-document.c	2004/12/06 18:13:36	1.106
+++ gedit/gedit/gedit-document.c	2004/12/09 12:19:34
@@ -1571,10 +1571,38 @@ gedit_document_save (GeditDocument *doc,
 	}
 
 	return ret;
 }
 
+void
+gedit_document_set_auto_save_timer (GeditDocument* doc, gboolean auto_save_enable)
+{
+	gint auto_save_interval;
+
+	gedit_debug (DEBUG_DOCUMENT, "");
+
+	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
+	g_return_if_fail (doc != NULL);
+	g_return_if_fail (doc->priv != NULL);
+
+	if (auto_save_enable)
+	{
+		auto_save_interval = gedit_prefs_manager_get_auto_save_interval ();
+
+		doc->priv->auto_save_timeout = g_timeout_add (auto_save_interval * 1000 * 60,
+							      (GSourceFunc) gedit_document_auto_save,
+							      doc);
+	}
+
+	else if (doc->priv->auto_save_timeout > 0)
+	{
+		g_source_remove (doc->priv->auto_save_timeout);
+
+		doc->priv->auto_save_timeout = 0;
+	}
+}
+
 gboolean	
 gedit_document_save_as (GeditDocument* doc, const gchar *uri, 
 			const GeditEncoding *encoding, GError **error)
 {	
 	gboolean auto_save;
@@ -2128,10 +2156,37 @@ gedit_document_set_max_undo_levels (Gedi
 
 	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
 
 	gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (doc), 
 					       max_undo_levels);
+}
+
+void
+gedit_document_set_auto_save_interval_timer (GeditDocument *doc, gint auto_save_interval)
+{
+	gboolean auto_save;
+
+	gedit_debug (DEBUG_DOCUMENT, "");
+
+	g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
+	g_return_if_fail (doc != NULL);
+	g_return_if_fail (doc->priv != NULL);
+
+	auto_save = gedit_prefs_manager_get_auto_save ();
+
+	if (auto_save && doc->priv->auto_save_timeout > 0)
+	{
+		g_source_remove (doc->priv->auto_save_timeout);
+		doc->priv->auto_save_timeout = 0;
+	}
+
+	if (auto_save && doc->priv->auto_save_timeout <= 0)
+	{
+		doc->priv->auto_save_timeout = g_timeout_add (auto_save_interval * 1000 * 60,
+							      (GSourceFunc) gedit_document_auto_save,
+							      doc);
+	}
 }
 
 gboolean
 gedit_document_can_undo	(const GeditDocument *doc)
 {
Index: gedit/gedit/gedit-document.h
===================================================================
RCS file: /export/cvs/head/gedit/gedit/gedit-document.h,v
retrieving revision 1.40
diff -p -u -5 -r1.40 gedit-document.h
--- gedit/gedit/gedit-document.h	2004/12/06 18:13:36	1.40
+++ gedit/gedit/gedit-document.h	2004/12/09 12:19:34
@@ -174,10 +174,16 @@ void		gedit_document_end_not_undoable_ac
 void		gedit_document_begin_user_action (GeditDocument *doc);
 void		gedit_document_end_user_action	 (GeditDocument *doc);
 
 void		gedit_document_goto_line 	(GeditDocument* doc, guint line);
 
+void            gedit_document_set_auto_save_timer (GeditDocument *doc,
+                                                    gboolean auto_save_enable);
+
+void            gedit_document_set_auto_save_interval_timer (GeditDocument *doc,
+                                                             gint auto_save_internal);
+
 gchar* 		gedit_document_get_last_searched_text (GeditDocument* doc);
 gchar* 		gedit_document_get_last_replace_text  (GeditDocument* doc);
 
 void 		gedit_document_set_last_searched_text (GeditDocument* doc, const gchar *text);
 void 		gedit_document_set_last_replace_text  (GeditDocument* doc, const gchar *text);
Index: gedit/gedit/gedit-prefs-manager-app.c
===================================================================
RCS file: /export/cvs/head/gedit/gedit/gedit-prefs-manager-app.c,v
retrieving revision 1.5
diff -p -u -5 -r1.5 gedit-prefs-manager-app.c
--- gedit/gedit/gedit-prefs-manager-app.c	2004/11/13 11:06:18	1.5
+++ gedit/gedit/gedit-prefs-manager-app.c	2004/12/09 12:19:34
@@ -56,10 +56,14 @@ static void		gedit_prefs_manager_editor_
 				   				   gpointer user_data);
 static void 		gedit_prefs_manager_tabs_size_changed 	(GConfClient *client,
 							       	 guint cnxn_id, 
 							       	 GConfEntry *entry, 
 							       	 gpointer user_data);
+static void		gedit_prefs_manager_auto_save_changed (GConfClient *client,
+								guint cnxn_id,
+								GConfEntry *entry,
+								gpointer user_data);
 static void 		gedit_prefs_manager_wrap_mode_changed 	(GConfClient *client,
 								 guint cnxn_id, 
 								 GConfEntry *entry, 
 								 gpointer user_data);
 static void 		gedit_prefs_manager_line_numbers_changed (GConfClient *client,
@@ -121,10 +125,15 @@ gedit_prefs_manager_app_init (void)
 
 		gconf_client_notify_add (gedit_prefs_manager->gconf_client,
 				GPM_TABS_DIR,
 				gedit_prefs_manager_tabs_size_changed,
 				NULL, NULL, NULL);
+
+		gconf_client_notify_add (gedit_prefs_manager->gconf_client,
+				GPM_SAVE_DIR,
+				gedit_prefs_manager_auto_save_changed,
+				NULL, NULL, NULL);
 		
 		gconf_client_notify_add (gedit_prefs_manager->gconf_client,
 				GPM_WRAP_MODE_DIR,
 				gedit_prefs_manager_wrap_mode_changed,
 				NULL, NULL, NULL);
@@ -483,10 +492,73 @@ gedit_prefs_manager_editor_colors_change
 		g_free (str_color);
 
 		set_colors (def, NULL, NULL, NULL, &color);
 	
 		return;
+	}
+}
+
+static void
+gedit_prefs_manager_auto_save_changed (GConfClient *client,
+	guint cnxn_id, GConfEntry *entry, gpointer user_data)
+{
+		gedit_debug (DEBUG_PREFS, "");
+
+		g_return_if_fail (entry->key != NULL);
+		g_return_if_fail (entry->value != NULL);
+
+		if (strcmp (entry->key, GPM_AUTO_SAVE) == 0)
+		{
+			gboolean auto_save;
+			GList *docs;
+
+			if (entry->value->type == GCONF_VALUE_BOOL)
+				auto_save = gconf_value_get_bool (entry->value);
+			else
+				auto_save = GPM_DEFAULT_AUTO_SAVE;
+
+			docs = gedit_get_open_documents ();
+
+			while (docs != NULL)
+			{
+				while (docs != NULL)
+				{
+					GeditDocument *doc = GEDIT_DOCUMENT (docs->data);
+
+					gedit_document_set_auto_save_timer (doc, auto_save);
+
+					docs = g_list_next (docs);
+
+				}
+
+			}
+		}
+
+	else if (strcmp (entry->key,  GPM_AUTO_SAVE_INTERVAL) == 0)
+		{
+			gint auto_save_interval;
+			GList *docs;
+
+			if (entry->value->type == GCONF_VALUE_INT)
+				auto_save_interval = gconf_value_get_int (entry->value);
+			else
+				auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL;
+
+			docs = gedit_get_open_documents ();
+
+			while (docs != NULL)
+			{
+				while (docs != NULL)
+				{
+					GeditDocument *doc = GEDIT_DOCUMENT (docs->data);
+
+					gedit_document_set_auto_save_interval_timer (doc, auto_save_interval);
+
+					docs = g_list_next (docs);
+				}
+
+			}
 	}
 }
 
 static void 
 gedit_prefs_manager_tabs_size_changed (GConfClient *client,
