[Xfce4-commits] [apps/xfce4-terminal] 01/01: Show the confirm close dialog on closing tabs
noreply at xfce.org
noreply at xfce.org
Mon Oct 2 23:14:27 CEST 2017
This is an automated email from the git hooks/post-receive script.
f 2 4 0 4 p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-terminal.
commit f27b7b04c9f998e57892118c58f2891fbeb9cf76
Author: Igor <f2404 at yandex.ru>
Date: Mon Oct 2 17:13:09 2017 -0400
Show the confirm close dialog on closing tabs
Similarly to when closing the entire window except for some wording.
---
terminal/terminal-screen.c | 22 ++++++++++-
terminal/terminal-window.c | 91 ++++++++++++++++++++++++++++++----------------
2 files changed, 81 insertions(+), 32 deletions(-)
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index 5a91565..3e0a370 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -71,6 +71,7 @@ enum
{
GET_CONTEXT_MENU,
SELECTION_CHANGED,
+ CLOSE_TAB,
LAST_SIGNAL
};
@@ -256,6 +257,17 @@ terminal_screen_class_init (TerminalScreenClass *klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * TerminalScreen::close-tab-request
+ **/
+ screen_signals[CLOSE_TAB] =
+ g_signal_new (I_("close-tab-request"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
@@ -2269,6 +2281,14 @@ terminal_screen_reset_activity (TerminalScreen *screen)
+static void
+terminal_screen_close_tab_cb (TerminalScreen *screen)
+{
+ g_signal_emit (G_OBJECT (screen), screen_signals[CLOSE_TAB], 0);
+}
+
+
+
GtkWidget *
terminal_screen_get_tab_label (TerminalScreen *screen)
{
@@ -2305,7 +2325,7 @@ terminal_screen_get_tab_label (TerminalScreen *screen)
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (hbox), button);
g_signal_connect_swapped (G_OBJECT (button), "clicked",
- G_CALLBACK (gtk_widget_destroy), screen);
+ G_CALLBACK (terminal_screen_close_tab_cb), screen);
/* button image */
image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU);
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index eaa04d7..ad43bfd 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -110,7 +110,8 @@ static gboolean terminal_window_scroll_event (GtkWidget
GdkEventScroll *event);
static gboolean terminal_window_map_event (GtkWidget *widget,
GdkEventAny *event);
-static gboolean terminal_window_confirm_close (TerminalWindow *window);
+static gboolean terminal_window_confirm_close (TerminalScreen *terminal,
+ TerminalWindow *window);
static void terminal_window_size_push (TerminalWindow *window);
static gboolean terminal_window_size_pop (gpointer data);
static void terminal_window_set_size_force_grid (TerminalWindow *window,
@@ -619,7 +620,7 @@ terminal_window_delete_event (GtkWidget *widget,
gint n_pages, i;
/* disconnect remove signal if we're closing the window */
- if (terminal_window_confirm_close (window))
+ if (terminal_window_confirm_close (NULL, window))
{
/* disconnect handlers for closing Set Title dialog */
if (window->priv->title_popover != NULL)
@@ -742,20 +743,22 @@ G_GNUC_END_IGNORE_DEPRECATIONS
static gboolean
-terminal_window_confirm_close (TerminalWindow *window)
+terminal_window_confirm_close (TerminalScreen *terminal,
+ TerminalWindow *window)
{
- GtkWidget *dialog;
- GtkWidget *button;
- GtkWidget *hbox;
- GtkWidget *image;
- GtkWidget *vbox;
- GtkWidget *label;
- GtkWidget *checkbox;
- gboolean confirm_close;
- gchar *message;
- gchar *markup;
- gint response;
- gint i, n_tabs;
+ GtkWidget *dialog;
+ GtkWidget *button;
+ GtkWidget *hbox;
+ GtkWidget *image;
+ GtkWidget *vbox;
+ GtkWidget *label;
+ GtkWidget *checkbox;
+ const gchar *title;
+ gchar *message;
+ gchar *markup;
+ gint response;
+ gint i, n_tabs;
+ gboolean confirm_close;
g_object_get (G_OBJECT (window->priv->preferences), "misc-confirm-close", &confirm_close, NULL);
if (!confirm_close)
@@ -766,14 +769,14 @@ terminal_window_confirm_close (TerminalWindow *window)
for (i = 0; i < n_tabs; ++i)
{
TerminalScreen *screen = TERMINAL_SCREEN (gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->priv->notebook), i));
- if (terminal_screen_has_foreground_process (screen))
+ if ((terminal == NULL || terminal == screen) && terminal_screen_has_foreground_process (screen))
{
confirm_close = TRUE;
break;
}
}
- if (n_tabs < 2 && !confirm_close)
+ if ((terminal != NULL || n_tabs < 2) && !confirm_close)
return TRUE;
dialog = gtk_dialog_new_with_buttons (_("Warning"), GTK_WINDOW (window),
@@ -783,12 +786,9 @@ terminal_window_confirm_close (TerminalWindow *window)
GTK_RESPONSE_CANCEL,
NULL);
- if (n_tabs > 1)
+ if (terminal == NULL && n_tabs > 1)
{
- /* multiple tabs */
- button = xfce_gtk_button_new_mixed ("window-close", _("Close T_ab"));
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE);
-
+ /* closing window with multiple tabs */
if (confirm_close)
{
/* and process running */
@@ -797,20 +797,38 @@ terminal_window_confirm_close (TerminalWindow *window)
}
else
{
+ /* and no process running */
message = g_strdup_printf (_("This window has %d tabs open. Closing this window\n"
"will also close all its tabs."), n_tabs);
}
+
+ title = _("Close all tabs?");
}
else
{
- /* single tab, process running */
+ /* closing a tab or a single tab window, and process running */
message = g_strdup_printf (_("There is still a process running.\n"
- "Closing this window will kill it."));
+ "Closing this %s will kill it."), terminal != NULL ? "tab" : "window");
+
+ if (terminal != NULL)
+ title = _("Close tab?");
+ else
+ title = _("Close window?");
+ }
+
+ if (terminal != NULL || n_tabs > 1)
+ {
+ button = xfce_gtk_button_new_mixed ("window-close", _("Close T_ab"));
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE);
+ gtk_widget_grab_focus (button);
}
- button = xfce_gtk_button_new_mixed ("application-exit", _("Close _Window"));
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_YES);
- gtk_widget_grab_focus (button);
+ if (terminal == NULL)
+ {
+ button = xfce_gtk_button_new_mixed ("application-exit", _("Close _Window"));
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_YES);
+ gtk_widget_grab_focus (button);
+ }
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
@@ -824,8 +842,7 @@ terminal_window_confirm_close (TerminalWindow *window)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
- markup = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- n_tabs > 1 ? _("Close all tabs?") : _("Close window?"), message);
+ markup = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", title, message);
g_free (message);
label = g_object_new (GTK_TYPE_LABEL,
@@ -1086,6 +1103,16 @@ terminal_window_notebook_page_reordered (GtkNotebook *notebook,
static void
+terminal_window_close_tab_request (TerminalScreen *screen,
+ TerminalWindow *window)
+{
+ if (terminal_window_confirm_close (screen, window))
+ gtk_widget_destroy (GTK_WIDGET (screen));
+}
+
+
+
+static void
terminal_window_notebook_page_added (GtkNotebook *notebook,
GtkWidget *child,
guint page_num,
@@ -1106,6 +1133,8 @@ terminal_window_notebook_page_added (GtkNotebook *notebook,
G_CALLBACK (terminal_window_notify_title), window);
g_signal_connect_swapped (G_OBJECT (screen), "selection-changed",
G_CALLBACK (terminal_window_update_actions), window);
+ g_signal_connect (G_OBJECT (screen), "close-tab-request",
+ G_CALLBACK (terminal_window_close_tab_request), window);
g_signal_connect (G_OBJECT (screen), "drag-data-received",
G_CALLBACK (terminal_window_notebook_drag_data_received), window);
@@ -1662,7 +1691,7 @@ terminal_window_action_close_tab (GtkAction *action,
TerminalWindow *window)
{
if (G_LIKELY (window->priv->active != NULL))
- gtk_widget_destroy (GTK_WIDGET (window->priv->active));
+ terminal_window_close_tab_request (window->priv->active, window);
}
@@ -1689,7 +1718,7 @@ static void
terminal_window_action_close_window (GtkAction *action,
TerminalWindow *window)
{
- if (terminal_window_confirm_close (window))
+ if (terminal_window_confirm_close (NULL, window))
gtk_widget_destroy (GTK_WIDGET (window));
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list