Branch: refs/heads/master Author: David Yang davidyang6us@gmail.com Committer: GitHub noreply@github.com Date: Sun, 12 Sep 2021 10:12:00 UTC Commit: 3608d6717b092e3d69acbd7c023b4c2f1f914c41 https://github.com/geany/geany/commit/3608d6717b092e3d69acbd7c023b4c2f1f914c...
Log Message: ----------- Add reload all keybinding (#2859)
Modified Paths: -------------- doc/geany.txt src/callbacks.c src/callbacks.h src/keybindings.c src/keybindings.h src/plugindata.h
Modified: doc/geany.txt 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -3349,6 +3349,8 @@ Close Ctrl-W (C) Closes the current fil
Reload file Ctrl-R (C) Reloads the current file.
+Reload all Reloads all open files. If the reload will not be 'undo'-able and changes that will be lost are detected (unsaved or saved) the reload will be confirmed, otherwise the reload will proceed without confirmation. + Print Ctrl-P (C) Prints the current file.
Quit Ctrl-Q (C) Quits Geany.
Modified: src/callbacks.c 37 lines changed, 37 insertions(+), 0 deletions(-) =================================================================== @@ -335,6 +335,43 @@ void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data) document_reload_prompt(doc, NULL); }
+/* reload all files */ +void on_reload_all(GtkAction *action, gpointer user_data) +{ + guint i; + gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook)); + + if (!file_prefs.keep_edit_history_on_reload) + { + GeanyDocument *doc; + foreach_document(i) + { + doc = documents[i]; + if (doc->changed || document_can_undo(doc) || document_can_redo(doc)) + { + if (dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL, + _("Changes detected, reloading all will lose any changes and history."), + _("Are you sure you want to reload all files?"))) + { + break; // break the loop and continue with reloading below + } + else + { + return; // cancel reloading + } + } + } + } + + foreach_document(i) + { + if (! (documents[i]->file_name == NULL)) + document_reload_force(documents[i], documents[i]->encoding); + } + + gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), cur_page); +} +
static void on_change_font1_activate(GtkMenuItem *menuitem, gpointer user_data) {
Modified: src/callbacks.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -98,6 +98,8 @@ void on_find_in_files1_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data);
+void on_reload_all(GtkAction *action, gpointer user_data); + void on_go_to_line_activate(GtkMenuItem *menuitem, gpointer user_data);
void on_help1_activate(GtkMenuItem *menuitem, gpointer user_data);
Modified: src/keybindings.c 5 lines changed, 5 insertions(+), 0 deletions(-) =================================================================== @@ -355,6 +355,8 @@ static void init_default_kb(void) "menu_close_all1"); add_kb(group, GEANY_KEYS_FILE_RELOAD, NULL, GDK_KEY_r, GEANY_PRIMARY_MOD_MASK, "menu_reloadfile", _("Reload file"), "menu_reload1"); + add_kb(group, GEANY_KEYS_FILE_RELOAD_ALL, NULL, + 0, 0, "menu_reloadall", _("Reload all files"), NULL); add_kb(group, GEANY_KEYS_FILE_OPENLASTTAB, NULL, 0, 0, "file_openlasttab", _("Re-open last closed tab"), NULL); add_kb(group, GEANY_KEYS_FILE_QUIT, NULL, @@ -1476,6 +1478,9 @@ static gboolean cb_func_file_action(guint key_id) case GEANY_KEYS_FILE_RELOAD: on_toolbutton_reload_clicked(NULL, NULL); break; + case GEANY_KEYS_FILE_RELOAD_ALL: + on_reload_all(NULL, NULL); + break; case GEANY_KEYS_FILE_PRINT: on_print1_activate(NULL, NULL); break;
Modified: src/keybindings.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -275,6 +275,8 @@ enum GeanyKeyBindingID GEANY_KEYS_EDITOR_DELETELINETOBEGINNING, /**< Keybinding. */ GEANY_KEYS_DOCUMENT_STRIPTRAILINGSPACES, /**< Keybinding. * @since 1.34 (API 238) */ + GEANY_KEYS_FILE_RELOAD_ALL, /**< Keybinding. + * @since 1.38 (API 240) */ GEANY_KEYS_COUNT /* must not be used by plugins */ };
Modified: src/plugindata.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -58,7 +58,7 @@ G_BEGIN_DECLS * @warning You should not test for values below 200 as previously * @c GEANY_API_VERSION was defined as an enum value, not a macro. */ -#define GEANY_API_VERSION 239 +#define GEANY_API_VERSION 240
/* hack to have a different ABI when built with different GTK major versions * because loading plugins linked to a different one leads to crashes.
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).