From c8dd5b0e719970c374fb28ccd167769734c5207b Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 30 Mar 2020 15:04:33 +0200 Subject: [PATCH] Add confirm-close-dialog.ui --- po/POTFILES.in | 7 +- src/Makefile.am | 1 + src/confirm-close-dialog.ui | 176 ++++++++++++++++++++++++++++++++++++ src/terminal-window.c | 38 ++++---- src/terminal.gresource.xml | 1 + 5 files changed, 198 insertions(+), 25 deletions(-) create mode 100644 src/confirm-close-dialog.ui diff --git a/po/POTFILES.in b/po/POTFILES.in index f4aa963..a89bd24 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,12 +2,14 @@ # Please keep this file sorted alphabetically. mate-terminal.appdata.xml.in mate-terminal.desktop.in.in +src/confirm-close-dialog.ui src/eggsmclient.c -src/org.mate.terminal.gschema.xml.in -src/profile-editor.c src/encodings-dialog.ui +src/extra-strings.c src/find-dialog.ui src/keybinding-editor.ui +src/org.mate.terminal.gschema.xml.in +src/profile-editor.c src/profile-manager.ui src/profile-new-dialog.ui src/profile-preferences.ui @@ -25,4 +27,3 @@ src/terminal-tab-label.c src/terminal-tabs-menu.c src/terminal-util.c src/terminal-window.c -src/extra-strings.c diff --git a/src/Makefile.am b/src/Makefile.am index c102007..04bebf9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -158,6 +158,7 @@ CLEANFILES = \ $(BUILT_SOURCES) EXTRA_DIST = \ + confirm-close-dialog.ui \ encodings-dialog.ui \ find-dialog.ui \ keybinding-editor.ui \ diff --git a/src/confirm-close-dialog.ui b/src/confirm-close-dialog.ui new file mode 100644 index 0000000..50bab4b --- /dev/null +++ b/src/confirm-close-dialog.ui @@ -0,0 +1,176 @@ + + + + + + True + False + process-stop + + + True + False + window-close + + + False + 5 + True + center-on-parent + True + dialog + + + + + + True + False + vertical + 14 + + + True + False + True + True + expand + + + _Cancel + True + True + True + image_cancel + True + True + + + True + True + 1 + + + + + C_lose Window + True + True + True + True + True + image_close + True + True + + + True + True + 2 + + + + + + True + True + end + 0 + + + + + True + False + 6 + + + True + False + 5 + 12 + + + True + False + start + dialog-warning + 6 + + + False + False + 0 + + + + + True + False + vertical + 12 + + + True + False + start + Close this window? + True + True + 40 + + + + + + False + False + 0 + + + + + True + False + start + There is still a process running in this terminal. +Closing the terminal will kill it. + True + + + False + False + 1 + + + + + False + True + 1 + + + + + True + True + 0 + + + + + False + True + 1 + + + + + + button_cancel + button_close + + + diff --git a/src/terminal-window.c b/src/terminal-window.c index f61dc17..612075c 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -3566,6 +3566,7 @@ static gboolean confirm_close_window_or_tab (TerminalWindow *window, TerminalScreen *screen) { + GtkBuilder *builder; TerminalWindowPrivate *priv = window->priv; GtkWidget *dialog; gboolean do_confirm; @@ -3573,13 +3574,6 @@ confirm_close_window_or_tab (TerminalWindow *window, int n_tabs; char *confirm_msg; - if (priv->confirm_close_dialog) - { - /* WTF, already have one? It's modal, so how did that happen? */ - gtk_dialog_response (GTK_DIALOG (priv->confirm_close_dialog), - GTK_RESPONSE_DELETE_EVENT); - } - do_confirm = g_settings_get_boolean (settings_global, "confirm-window-close"); if (!do_confirm) @@ -3615,30 +3609,28 @@ confirm_close_window_or_tab (TerminalWindow *window, if (has_processes) { if (n_tabs > 1) - confirm_msg = _("There are still processes running in some terminals in this window. " + confirm_msg = _("There are still processes running in some terminals in this window.\n" "Closing the window will kill all of them."); else - confirm_msg = _("There is still a process running in this terminal. " + confirm_msg = _("There is still a process running in this terminal.\n" "Closing the terminal will kill it."); } else if (n_tabs > 1) confirm_msg = _("There are multiple tabs open in this window."); else return FALSE; - dialog = priv->confirm_close_dialog = - gtk_message_dialog_new (GTK_WINDOW (window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CANCEL, - "%s", n_tabs > 1 ? _("Close this window?") : _("Close this terminal?")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", confirm_msg); - - gtk_window_set_title (GTK_WINDOW (dialog), ""); - - gtk_dialog_add_button (GTK_DIALOG (dialog), n_tabs > 1 ? _("C_lose Window") : _("C_lose Terminal"), GTK_RESPONSE_ACCEPT); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); + builder = gtk_builder_new_from_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/confirm-close-dialog.ui"); + priv->confirm_close_dialog = dialog = GTK_WIDGET (gtk_builder_get_object (builder, "confirm_close_dialog")); + if (n_tabs > 1) { + gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "question_text")), _("Close this window?")); + gtk_button_set_label (GTK_BUTTON (gtk_builder_get_object (builder, "button_close")), _("C_lose Window")); + } else { + gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "question_text")), _("Close this terminal?")); + gtk_button_set_label (GTK_BUTTON (gtk_builder_get_object (builder, "button_close")), _("C_lose Terminal")); + } + gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "description_text")), confirm_msg); + g_object_unref (builder); g_object_set_data (G_OBJECT (dialog), "close-screen", screen); @@ -3647,6 +3639,8 @@ confirm_close_window_or_tab (TerminalWindow *window, g_signal_connect (dialog, "response", G_CALLBACK (confirm_close_response_cb), window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); + gtk_window_set_title (GTK_WINDOW (dialog), ""); gtk_window_present (GTK_WINDOW (dialog)); return TRUE; diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml index e8ff1f1..4332ba8 100644 --- a/src/terminal.gresource.xml +++ b/src/terminal.gresource.xml @@ -17,6 +17,7 @@ --> + confirm-close-dialog.ui encodings-dialog.ui find-dialog.ui keybinding-editor.ui