[Xfce4-commits] [apps/xfce4-terminal] 01/01: Add "Copy Input" action

noreply at xfce.org noreply at xfce.org
Fri Apr 13 19:33:42 CEST 2018


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 9892ee7d05fa2a29a49c9aaccffec5da05dfb785
Author: Igor <f2404 at yandex.ru>
Date:   Fri Apr 13 13:32:14 2018 -0400

    Add "Copy Input" action
    
    It shows a popover and allows to copy the input to all tabs within the current
    window.
    Fixes bug #10047
---
 terminal/terminal-screen.c      | 10 ++++++
 terminal/terminal-screen.h      |  3 ++
 terminal/terminal-window-ui.xml |  2 ++
 terminal/terminal-window.c      | 75 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 90 insertions(+)

diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index b580b5d..fe03ce3 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -2774,3 +2774,13 @@ terminal_screen_has_foreground_process (TerminalScreen *screen)
 
   return TRUE;
 }
+
+
+
+void
+terminal_screen_feed_text (TerminalScreen *screen,
+                           const char     *text)
+{
+  terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
+  vte_terminal_feed_child (VTE_TERMINAL (screen->terminal), text, strlen (text));
+}
diff --git a/terminal/terminal-screen.h b/terminal/terminal-screen.h
index 00d3f5c..b70e5ef 100644
--- a/terminal/terminal-screen.h
+++ b/terminal/terminal-screen.h
@@ -127,6 +127,9 @@ void            terminal_screen_save_contents             (TerminalScreen *scree
 
 gboolean        terminal_screen_has_foreground_process    (TerminalScreen *screen);
 
+void            terminal_screen_feed_text                 (TerminalScreen *screen,
+                                                           const char     *text);
+
 G_END_DECLS
 
 #endif /* !TERMINAL_SCREEN_H */
diff --git a/terminal/terminal-window-ui.xml b/terminal/terminal-window-ui.xml
index d47ce4e..824660e 100644
--- a/terminal/terminal-window-ui.xml
+++ b/terminal/terminal-window-ui.xml
@@ -26,6 +26,8 @@
       <separator/>
       <menuitem action="select-all"/>
       <separator/>
+      <menuitem action="copy-input"/>
+      <separator/>
       <menuitem action="preferences"/>
     </menu>
     <menu action="view-menu">
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index f427e35..f556669 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -196,6 +196,8 @@ static void         terminal_window_action_paste_selection        (GtkAction
                                                                    TerminalWindow         *window);
 static void         terminal_window_action_select_all             (GtkAction              *action,
                                                                    TerminalWindow         *window);
+static void         terminal_window_action_copy_input             (GtkAction              *action,
+                                                                   TerminalWindow         *window);
 static void         terminal_window_action_prefs                  (GtkAction              *action,
                                                                    TerminalWindow         *window);
 static void         terminal_window_action_show_toolbar           (GtkToggleAction        *action,
@@ -334,6 +336,7 @@ static const GtkActionEntry action_entries[] =
     { "paste", "edit-paste", N_ ("_Paste"), "<control><shift>v", N_ ("Paste from clipboard"), G_CALLBACK (terminal_window_action_paste), },
     { "paste-selection", NULL, N_ ("Paste _Selection"), NULL, NULL, G_CALLBACK (terminal_window_action_paste_selection), },
     { "select-all", "edit-select-all", N_ ("Select _All"), "<control><shift>a", NULL, G_CALLBACK (terminal_window_action_select_all), },
+    { "copy-input", NULL, N_ ("Copy _Input To All Tabs..."), NULL, NULL, G_CALLBACK (terminal_window_action_copy_input), },
     { "preferences", "preferences-system", N_ ("Pr_eferences..."), NULL, N_ ("Open the preferences dialog"), G_CALLBACK (terminal_window_action_prefs), },
   { "view-menu", NULL, N_ ("_View"), NULL, NULL, NULL, },
     { "zoom-in", "zoom-in", N_ ("Zoom _In"), "<control>plus", N_ ("Zoom in with larger font"), G_CALLBACK (terminal_window_action_zoom_in), },
@@ -1785,6 +1788,78 @@ terminal_window_action_select_all (GtkAction      *action,
 
 
 static void
+copy_input_popover_close (GtkWidget      *popover,
+                          TerminalWindow *window)
+{
+  /* need for hiding on focus */
+  if (window->drop_down)
+    terminal_util_activate_window (GTK_WINDOW (window));
+
+  /* close the dialog */
+  gtk_widget_destroy (popover);
+
+  /* focus the terminal */
+  if (G_LIKELY (window->priv->active != NULL && TERMINAL_IS_SCREEN (window->priv->active)))
+    terminal_screen_focus (window->priv->active);
+}
+
+
+
+static void
+copy_input_popover_do_copy (GtkWidget *popover,
+                            GtkWidget *entry)
+{
+  TerminalWindow *window = TERMINAL_WINDOW (gtk_widget_get_toplevel (popover));
+  GtkNotebook    *notebook = GTK_NOTEBOOK (window->priv->notebook);
+  gint            n, npages = gtk_notebook_get_n_pages (notebook);
+
+  /* copy the input to all tabs */
+  for (n = 0; n < npages; n++)
+    {
+      TerminalScreen *screen = TERMINAL_SCREEN (gtk_notebook_get_nth_page (notebook, n));
+      terminal_screen_feed_text (screen, gtk_entry_get_text (GTK_ENTRY (entry)));
+    }
+}
+
+
+
+static void
+terminal_window_action_copy_input (GtkAction      *action,
+                                   TerminalWindow *window)
+{
+  GtkWidget *popover, *button, *box, *label, *entry;
+
+  popover = gtk_popover_new (GTK_WIDGET (window->priv->menubar));
+  gtk_popover_set_position (GTK_POPOVER (popover), GTK_POS_BOTTOM);
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+  gtk_container_set_border_width (GTK_CONTAINER (box), 6);
+  gtk_container_add (GTK_CONTAINER (popover), box);
+
+  label = gtk_label_new_with_mnemonic (_("Copy _Input:"));
+  gtk_container_add (GTK_CONTAINER (box), label);
+
+  entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_text (entry, _("Enter the text to be copied to all tabs"));
+  gtk_container_add (GTK_CONTAINER (box), entry);
+  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+  g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (copy_input_popover_do_copy), entry);
+
+  button = gtk_button_new_from_icon_name ("edit-copy-symbolic", GTK_ICON_SIZE_BUTTON);
+  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+  gtk_widget_set_tooltip_text (button, _("Copy input"));
+  gtk_container_add (GTK_CONTAINER (box), button);
+  g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (copy_input_popover_do_copy), entry);
+
+  g_signal_connect (G_OBJECT (popover), "closed", G_CALLBACK (copy_input_popover_close), window);
+
+  gtk_widget_show_all (popover);
+}
+
+
+
+static void
 terminal_window_action_prefs_died (gpointer  user_data,
                                    GObject  *where_the_object_was)
 {

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


More information about the Xfce4-commits mailing list