[gedit] Set the document as readonly when with fallback char error.



commit 634f604d2850bea4dfeb009dcca2d2050fbbcb5d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Jan 14 18:10:12 2010 +0100

    Set the document as readonly when with fallback char error.
    
    If there are invalid chars set the document as readonly instead
    of non editable view. Also listening to the read-only property
    in the window to update the sensitivity and the window title.

 gedit/gedit-tab.c    |   10 +++-------
 gedit/gedit-window.c |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 964a6b7..38dd47a 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -529,8 +529,7 @@ conversion_loading_error_message_area_response (GtkWidget        *message_area,
 
 			tab->priv->tmp_encoding = encoding;
 
-			if (tab->priv->auto_save_timeout > 0)
-				remove_auto_save_timeout (tab);
+			g_return_if_fail (tab->priv->auto_save_timeout <= 0);
 
 			gedit_document_load (doc,
 					     uri,
@@ -541,9 +540,7 @@ conversion_loading_error_message_area_response (GtkWidget        *message_area,
 		case GTK_RESPONSE_YES:
 			/* This means that we want to edit the document anyway */
 			set_message_area (tab, NULL);
-			tab->priv->not_editable = FALSE;
-			gtk_text_view_set_editable (GTK_TEXT_VIEW (view),
-						    TRUE);
+			_gedit_document_set_readonly (doc, FALSE);
 			break;
 		case GTK_RESPONSE_CANCEL:
 			/* We don't want to edit the document just show it */
@@ -1046,8 +1043,7 @@ document_loaded (GeditDocument *document,
 		{
 			GtkWidget *emsg;
 
-			//_gedit_document_set_readonly (document, TRUE);
-			tab->priv->not_editable = TRUE;
+			_gedit_document_set_readonly (document, TRUE);
 
 			emsg = gedit_conversion_error_while_loading_message_area_new (
 									uri,
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 98ebbf5..90d48c1 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -3201,6 +3201,19 @@ sync_languages_menu (GeditDocument *doc,
 }
 
 static void
+readonly_changed (GeditDocument *doc,
+		  GParamSpec    *pspec,
+		  GeditWindow   *window)
+{
+	set_sensitivity_according_to_tab (window, window->priv->active_tab);
+
+	sync_name (window->priv->active_tab, NULL, window);
+
+	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
+						 window);
+}
+
+static void
 editable_changed (GeditView  *view,
                   GParamSpec  *arg1,
                   GeditWindow *window)
@@ -3285,6 +3298,10 @@ notebook_tab_added (GeditNotebook *notebook,
 			  "notify::language",
 			  G_CALLBACK (sync_languages_menu),
 			  window);
+	g_signal_connect (doc,
+			  "notify::read-only",
+			  G_CALLBACK (readonly_changed),
+			  window);
 	g_signal_connect (view,
 			  "toggle_overwrite",
 			  G_CALLBACK (update_overwrite_mode_statusbar),
@@ -3347,6 +3364,9 @@ notebook_tab_removed (GeditNotebook *notebook,
 	g_signal_handlers_disconnect_by_func (doc,
 					      G_CALLBACK (sync_languages_menu),
 					      window);
+	g_signal_handlers_disconnect_by_func (doc,
+					      G_CALLBACK (readonly_changed),
+					      window);
 	g_signal_handlers_disconnect_by_func (view, 
 					      G_CALLBACK (update_overwrite_mode_statusbar),
 					      window);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]