diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/confirm-close-dialog.ui | 176 | ||||
-rw-r--r-- | src/terminal-window.c | 38 | ||||
-rw-r--r-- | src/terminal.gresource.xml | 1 |
4 files changed, 194 insertions, 22 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.2 --> +<interface> + <requires lib="gtk+" version="3.22"/> + <object class="GtkImage" id="image_cancel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">process-stop</property> + </object> + <object class="GtkImage" id="image_close"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">window-close</property> + </object> + <object class="GtkDialog" id="confirm_close_dialog"> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="modal">True</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">dialog</property> + <child type="titlebar"> + <placeholder/> + </child> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">14</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="homogeneous">True</property> + <property name="layout_style">expand</property> + <child> + <object class="GtkButton" id="button_cancel"> + <property name="label" translatable="yes">_Cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">image_cancel</property> + <property name="use_underline">True</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button_close"> + <property name="label" translatable="yes">C_lose Window</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="image">image_close</property> + <property name="use_underline">True</property> + <property name="always_show_image">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <style> + <class name="linked"/> + </style> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="vbox8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">6</property> + <child> + <object class="GtkBox" id="hbox3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="spacing">12</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="icon_name">dialog-warning</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="question_text"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Close this window?</property> + <property name="selectable">True</property> + <property name="single_line_mode">True</property> + <property name="max_width_chars">40</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="description_text"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">There is still a process running in this terminal. +Closing the terminal will kill it.</property> + <property name="selectable">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-6">button_cancel</action-widget> + <action-widget response="-3">button_close</action-widget> + </action-widgets> + </object> +</interface> 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 @@ --> <gresources> <gresource prefix="/org/mate/terminal/ui"> + <file compressed="true" preprocess="xml-stripblanks">confirm-close-dialog.ui</file> <file compressed="true" preprocess="xml-stripblanks">encodings-dialog.ui</file> <file compressed="true" preprocess="xml-stripblanks">find-dialog.ui</file> <file compressed="true" preprocess="xml-stripblanks">keybinding-editor.ui</file> |