[Xfce4-commits] [apps/xfce4-terminal] 01/01: Do not allow creating multiple Set Title dialog windows

noreply at xfce.org noreply at xfce.org
Fri Jul 15 14:39:25 CEST 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit e194e04cf54680d7f21f2382d071641abdb3b82a
Author: Igor <f2404 at yandex.ru>
Date:   Fri Jul 15 15:39:19 2016 +0300

    Do not allow creating multiple Set Title dialog windows
---
 terminal/terminal-window.c | 63 ++++++++++++++++++++++++++++------------------
 terminal/terminal-window.h |  1 +
 2 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index c7bf575..ffbf03a 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -1540,20 +1540,30 @@ terminal_window_action_goto_tab (GtkRadioAction *action,
 
 
 static void
+title_dialog_close (GtkWidget      *dialog,
+                    TerminalWindow *window)
+{
+  terminal_return_if_fail (window->title_dialog == dialog);
+
+  /* need for hiding on focus */
+  if (window->drop_down)
+    terminal_util_activate_window (GTK_WINDOW (window));
+
+  /* close the dialog */
+  window->n_child_windows--;
+  gtk_widget_destroy (dialog);
+  window->title_dialog = NULL;
+}
+
+
+
+static void
 title_dialog_response (GtkWidget      *dialog,
                        gint            response,
                        TerminalWindow *window)
 {
   if (response == GTK_RESPONSE_CLOSE)
-    {
-      /* need for hiding on focus */
-      if (window->drop_down)
-        terminal_util_activate_window (GTK_WINDOW (window));
-
-      /* close the dialog */
-      window->n_child_windows--;
-      gtk_widget_destroy (dialog);
-    }
+    title_dialog_close (dialog, window);
 }
 
 
@@ -1573,30 +1583,29 @@ terminal_window_action_set_title (GtkAction      *action,
                                   TerminalWindow *window)
 {
   AtkObject *object;
-  GtkWidget *dialog;
   GtkWidget *button;
   GtkWidget *box;
   GtkWidget *label;
   GtkWidget *entry;
 
-  if (G_LIKELY (window->active != NULL))
-    {
-      window->n_child_windows++;
+  terminal_return_if_fail (window->active != NULL);
 
-      dialog = gtk_dialog_new_with_buttons (Q_("Window Title|Set Title"),
-                                            GTK_WINDOW (window),
-                                            GTK_DIALOG_DESTROY_WITH_PARENT,
-                                            NULL,
-                                            NULL);
+  if (window->title_dialog == NULL)
+    {
+      window->title_dialog = gtk_dialog_new_with_buttons (Q_("Window Title|Set Title"),
+                                                          GTK_WINDOW (window),
+                                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                          NULL,
+                                                          NULL);
 
       button = xfce_gtk_button_new_mixed ("window-close", _("_Close"));
       gtk_widget_set_can_default (button, TRUE);
-      gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE);
-      gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
+      gtk_dialog_add_action_widget (GTK_DIALOG (window->title_dialog), button, GTK_RESPONSE_CLOSE);
+      gtk_dialog_set_default_response (GTK_DIALOG (window->title_dialog), GTK_RESPONSE_CLOSE);
 
       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
       gtk_container_set_border_width (GTK_CONTAINER (box), 6);
-      gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), box, TRUE, TRUE, 0);
+      gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window->title_dialog))), box, TRUE, TRUE, 0);
 
       label = gtk_label_new_with_mnemonic (_("_Title:"));
       gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
@@ -1616,11 +1625,17 @@ terminal_window_action_set_title (GtkAction      *action,
                               G_OBJECT (entry), "text",
                               G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
 
-      g_signal_connect (G_OBJECT (dialog), "response",
+      g_signal_connect (G_OBJECT (window->title_dialog), "response",
                         G_CALLBACK (title_dialog_response), window);
-
-      gtk_widget_show_all (dialog);
+      g_signal_connect (G_OBJECT (window->title_dialog), "close",
+                        G_CALLBACK (title_dialog_close), window);
     }
+
+    if (!gtk_widget_get_visible (window->title_dialog))
+      window->n_child_windows++;
+
+    gtk_widget_show_all (window->title_dialog);
+    gtk_window_present (GTK_WINDOW (window->title_dialog));
 }
 
 
diff --git a/terminal/terminal-window.h b/terminal/terminal-window.h
index ac20573..c89ac46 100644
--- a/terminal/terminal-window.h
+++ b/terminal/terminal-window.h
@@ -66,6 +66,7 @@ struct _TerminalWindow
   GtkWidget           *notebook;
 
   GtkWidget           *search_dialog;
+  GtkWidget           *title_dialog;
 
   /* pushed size of screen */
   glong                grid_width;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list