From 90047be4d735d1b513544d6f48fb166e3a5c7a62 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 18 Aug 2006 17:24:44 +0000 Subject: [PATCH] Use Reload button for reload dialog; Share on_reload_as_activate code for reloading git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@738 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 6 +++++ src/callbacks.c | 64 ++++++++++++++++++++++++------------------------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9ffe87d..553cb69e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ * src/keyfile.c: Fix a small memory leak in configuration_load. * src/dialogs.c: Change Don't save button icon and add mnemonic. * src/main.c: Fix building on win32 - thanks to Củ Văn Chuối. + * src/dialogs.c, src/dialogs.h: + Add dialogs_show_question_full for custom buttons and extra text. + Don't show message dialogs in the window manager taskbar. + * src/utils.c: Use Reload button for utils_check_disk_status dialog. + * src/callbacks.c: Use Reload button for reload dialog. + Share on_reload_as_activate code for reloading. 2006-08-17 Nick Treleaven diff --git a/src/callbacks.c b/src/callbacks.c index b1ea1a7b..fb7f1d23 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -196,8 +196,9 @@ on_exit_clicked (GtkWidget *widget, gpointer gdata) { if (app->pref_main_confirm_exit) { - if (dialogs_show_question(_("Do you really want to quit?")) && - on_close_all1_activate(NULL, NULL)) destroyapp(NULL, gdata); + if (dialogs_show_question_full(GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL, + _("Do you really want to quit?")) && on_close_all1_activate(NULL, NULL)) + destroyapp(NULL, gdata); else app->quitting = FALSE; } else @@ -211,7 +212,9 @@ on_exit_clicked (GtkWidget *widget, gpointer gdata) { if (app->pref_main_confirm_exit) { - if (dialogs_show_question(_("Do you really want to quit?"))) destroyapp(NULL, gdata); + if (dialogs_show_question(GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL, + _("Do you really want to quit?"))) + destroyapp(NULL, gdata); else app->quitting = FALSE; } else @@ -488,20 +491,38 @@ on_toolbutton19_clicked (GtkToolButton *toolbutton, void on_toolbutton23_clicked (GtkToolButton *toolbutton, gpointer user_data) +{ + on_reload_as_activate(NULL, GINT_TO_POINTER(-1)); +} + + +// also used for reloading when user_data is -1 +void +on_reload_as_activate (GtkMenuItem *menuitem, + gpointer user_data) { gint idx = document_get_cur_idx(); gchar *basename; + gint i = GPOINTER_TO_INT(user_data); + gchar *charset = NULL; - if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_name == NULL) return; - - basename = g_path_get_basename(doc_list[idx].file_name); - if (dialogs_show_question(_ - ("Are you sure you want to reload '%s'?\nAny unsaved changes will be lost."), - basename)) + if (idx < 0 || ! doc_list[idx].is_valid || doc_list[idx].file_name == NULL) + return; + if (i >= 0) { - document_reload_file(idx, NULL); + if (i >= GEANY_ENCODINGS_MAX || encodings[i].charset == NULL) return; + charset = encodings[i].charset; } + basename = g_path_get_basename(doc_list[idx].file_name); + if (dialogs_show_question_full(_("_Reload"), GTK_STOCK_CANCEL, + _("Any unsaved changes will be lost."), + _("Are you sure you want to reload '%s'?"), basename)) + { + document_reload_file(idx, charset); + if (charset != NULL) + utils_update_statusbar(idx, -1); + } g_free(basename); } @@ -2346,29 +2367,6 @@ on_encoding_change (GtkMenuItem *menuitem, } -void -on_reload_as_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - gint idx = document_get_cur_idx(); - gchar *basename; - gint i = GPOINTER_TO_INT(user_data); - - if (idx < 0 || ! doc_list[idx].is_valid || doc_list[idx].file_name == NULL || - i < 0 || i >= GEANY_ENCODINGS_MAX || encodings[i].charset == NULL) - return; - - basename = g_path_get_basename(doc_list[idx].file_name); - if (dialogs_show_question(_ - ("Are you sure you want to reload '%s'?\nAny unsaved changes will be lost."), - basename)) - { - document_reload_file(idx, encodings[i].charset); - utils_update_statusbar(idx, -1); - } - g_free(basename); -} - void on_print1_activate (GtkMenuItem *menuitem, gpointer user_data)