Branch: refs/heads/master Author: Thomas Martitz kugel@rockbox.org Committer: Thomas Martitz kugel@rockbox.org Date: Fri, 30 Oct 2015 14:23:44 UTC Commit: b1e9c4f3b6655517f0ebf6eccabfc75cd7090f96 https://github.com/geany/geany/commit/b1e9c4f3b6655517f0ebf6eccabfc75cd7090f...
Log Message: ----------- document: show informational doc message after first reload
6f5d5db and d6d4728 disabled "maintain history on reload" by default, with the intention to reenable it when we have a better method to make it discoverable for the user. This was necessary since it became enabled by default but could be surprising given Geany warned about losing data before.
This commit tries to resolve the discoverability, by providing an informational doc message that is shown once to the user, after the first reload. The doc message also gives the option to disable this feature.
Modified Paths: -------------- src/document.c src/document.h src/documentprivate.h src/keyfile.c
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 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -235,6 +235,8 @@ static void init_pref_groups(void) "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); + 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).