diff --git a/doc/geany.txt b/doc/geany.txt index 69b4dc2c61..83081aece4 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -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. diff --git a/src/callbacks.c b/src/callbacks.c index 93900b0d05..2e13d6d039 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -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) { diff --git a/src/callbacks.h b/src/callbacks.h index 3cd4ac0455..4e9ac16d0f 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -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); diff --git a/src/keybindings.c b/src/keybindings.c index b0837158dd..e55f40ea6b 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -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; diff --git a/src/keybindings.h b/src/keybindings.h index 6f9ecae6d7..0b7f6c09a0 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -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 */ }; diff --git a/src/plugindata.h b/src/plugindata.h index 079f5f7e3a..6e4dc2ee6b 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -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.