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.
parent 61a8c6f5
...@@ -529,8 +529,7 @@ conversion_loading_error_message_area_response (GtkWidget *message_area, ...@@ -529,8 +529,7 @@ conversion_loading_error_message_area_response (GtkWidget *message_area,
tab->priv->tmp_encoding = encoding; tab->priv->tmp_encoding = encoding;
if (tab->priv->auto_save_timeout > 0) g_return_if_fail (tab->priv->auto_save_timeout <= 0);
remove_auto_save_timeout (tab);
gedit_document_load (doc, gedit_document_load (doc,
uri, uri,
...@@ -541,9 +540,7 @@ conversion_loading_error_message_area_response (GtkWidget *message_area, ...@@ -541,9 +540,7 @@ conversion_loading_error_message_area_response (GtkWidget *message_area,
case GTK_RESPONSE_YES: case GTK_RESPONSE_YES:
/* This means that we want to edit the document anyway */ /* This means that we want to edit the document anyway */
set_message_area (tab, NULL); set_message_area (tab, NULL);
tab->priv->not_editable = FALSE; _gedit_document_set_readonly (doc, FALSE);
gtk_text_view_set_editable (GTK_TEXT_VIEW (view),
TRUE);
break; break;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
/* We don't want to edit the document just show it */ /* We don't want to edit the document just show it */
...@@ -1046,8 +1043,7 @@ document_loaded (GeditDocument *document, ...@@ -1046,8 +1043,7 @@ document_loaded (GeditDocument *document,
{ {
GtkWidget *emsg; GtkWidget *emsg;
//_gedit_document_set_readonly (document, TRUE); _gedit_document_set_readonly (document, TRUE);
tab->priv->not_editable = TRUE;
emsg = gedit_conversion_error_while_loading_message_area_new ( emsg = gedit_conversion_error_while_loading_message_area_new (
uri, uri,
......
...@@ -3200,6 +3200,19 @@ sync_languages_menu (GeditDocument *doc, ...@@ -3200,6 +3200,19 @@ sync_languages_menu (GeditDocument *doc,
window); window);
} }
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 static void
editable_changed (GeditView *view, editable_changed (GeditView *view,
GParamSpec *arg1, GParamSpec *arg1,
...@@ -3285,6 +3298,10 @@ notebook_tab_added (GeditNotebook *notebook, ...@@ -3285,6 +3298,10 @@ notebook_tab_added (GeditNotebook *notebook,
"notify::language", "notify::language",
G_CALLBACK (sync_languages_menu), G_CALLBACK (sync_languages_menu),
window); window);
g_signal_connect (doc,
"notify::read-only",
G_CALLBACK (readonly_changed),
window);
g_signal_connect (view, g_signal_connect (view,
"toggle_overwrite", "toggle_overwrite",
G_CALLBACK (update_overwrite_mode_statusbar), G_CALLBACK (update_overwrite_mode_statusbar),
...@@ -3347,6 +3364,9 @@ notebook_tab_removed (GeditNotebook *notebook, ...@@ -3347,6 +3364,9 @@ notebook_tab_removed (GeditNotebook *notebook,
g_signal_handlers_disconnect_by_func (doc, g_signal_handlers_disconnect_by_func (doc,
G_CALLBACK (sync_languages_menu), G_CALLBACK (sync_languages_menu),
window); window);
g_signal_handlers_disconnect_by_func (doc,
G_CALLBACK (readonly_changed),
window);
g_signal_handlers_disconnect_by_func (view, g_signal_handlers_disconnect_by_func (view,
G_CALLBACK (update_overwrite_mode_statusbar), G_CALLBACK (update_overwrite_mode_statusbar),
window); window);
......
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