[geany/geany] f50a1a: Merge pull request #672 from kugel-/reload-docmsg
elextr
git-noreply at xxxxx
Sat Oct 31 01:47:43 UTC 2015
Branch: refs/heads/master
Author: elextr <elextr at gmail.com>
Committer: elextr <elextr at gmail.com>
Date: Sat, 31 Oct 2015 01:47:43 UTC
Commit: f50a1a9fc4b3b83e2caf0a55f7d2400582b31ec7
https://github.com/geany/geany/commit/f50a1a9fc4b3b83e2caf0a55f7d2400582b31ec7
Log Message:
-----------
Merge pull request #672 from kugel-/reload-docmsg
document: show informational doc message after first reload
Closes #562
Modified Paths:
--------------
doc/geany.txt
src/document.c
src/document.h
src/documentprivate.h
src/keyfile.c
Modified: doc/geany.txt
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -2652,7 +2652,7 @@ use_gio_unsafe_file_saving Whether to use GIO as the unsafe file t
correctly on some complex setups.
gio_unsafe_save_backup Make a backup when using GIO unsafe file false immediately
saving. Backup is named `filename~`.
-keep_edit_history_on_reload_125 Whether to maintain the edit history when false immediately
+keep_edit_history_on_reload Whether to maintain the edit history when true immediately
reloading a file, and allow the operation
to be reverted.
**Filetype related**
Modified: src/document.c
34 lines changed, 34 insertions(+), 0 deletions(-)
===================================================================
@@ -1575,6 +1575,24 @@ void document_open_files(const GSList *filenames, gboolean readonly, GeanyFilety
}
+static void on_keep_edit_history_on_reload_response(GtkWidget *bar, gint response_id, GeanyDocument *doc)
+{
+ if (response_id == GTK_RESPONSE_NO)
+ {
+ file_prefs.keep_edit_history_on_reload = FALSE;
+ document_reload_force(doc, doc->encoding);
+ }
+ else if (response_id == GTK_RESPONSE_CANCEL)
+ {
+ /* this condition cannot be reached via info bar buttons, but by our code
+ * to replace this bar with a higher priority one */
+ file_prefs.show_keep_edit_history_on_reload_msg = TRUE;
+ }
+ doc->priv->info_bars[MSG_TYPE_POST_RELOAD] = NULL;
+ gtk_widget_destroy(bar);
+}
+
+
/**
* Reloads the document with the specified file encoding.
* @a forced_enc or @c NULL to auto-detect the file encoding.
@@ -1589,6 +1607,7 @@ gboolean document_reload_force(GeanyDocument *doc, const gchar *forced_enc)
{
gint pos = 0;
GeanyDocument *new_doc;
+ GtkWidget *bar;
g_return_val_if_fail(doc != NULL, FALSE);
@@ -1600,6 +1619,21 @@ gboolean document_reload_force(GeanyDocument *doc, const gchar *forced_enc)
pos = sci_get_current_position(doc->editor->sci);
new_doc = document_open_file_full(doc, NULL, pos, doc->readonly, doc->file_type, forced_enc);
+ if (file_prefs.keep_edit_history_on_reload && file_prefs.show_keep_edit_history_on_reload_msg)
+ {
+ bar = document_show_message(doc, GTK_MESSAGE_INFO,
+ on_keep_edit_history_on_reload_response,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ _("Discard history"), GTK_RESPONSE_NO,
+ NULL, 0, _("The buffer's previous state is stored in the history and "
+ "undoing restores it. You can disable this by discarding the history upon "
+ "reload. This message will not be displayed again but "
+ "Your choice can be changed in the various preferences."),
+ _("The file has been reloaded."));
+ doc->priv->info_bars[MSG_TYPE_POST_RELOAD] = bar;
+ file_prefs.show_keep_edit_history_on_reload_msg = FALSE;
+ }
+
return (new_doc != NULL);
}
Modified: src/document.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -65,6 +65,7 @@ typedef struct GeanyFilePrefs
gchar *extract_filetype_regex; /* regex to extract filetype on opening */
gboolean tab_close_switch_to_mru;
gboolean keep_edit_history_on_reload; /* Keep undo stack upon, and allow undoing of, document reloading. */
+ gboolean show_keep_edit_history_on_reload_msg; /* whether to show the message introducing the above feature */
}
GeanyFilePrefs;
Modified: src/documentprivate.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -65,6 +65,7 @@ enum
{
MSG_TYPE_RELOAD,
MSG_TYPE_RESAVE,
+ MSG_TYPE_POST_RELOAD,
NUM_MSG_TYPES
};
Modified: src/keyfile.c
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -234,7 +234,9 @@ static void init_pref_groups(void)
stash_group_add_boolean(group, &file_prefs.use_gio_unsafe_file_saving,
"use_gio_unsafe_file_saving", TRUE);
stash_group_add_boolean(group, &file_prefs.keep_edit_history_on_reload,
- "keep_edit_history_on_reload_125", FALSE);
+ "keep_edit_history_on_reload", TRUE);
+ stash_group_add_boolean(group, &file_prefs.show_keep_edit_history_on_reload_msg,
+ "show_keep_edit_history_on_reload_msg", TRUE);
/* for backwards-compatibility */
stash_group_add_integer(group, &editor_prefs.indentation->hard_tab_width,
"indent_hard_tab_width", 8);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list