[gnome-terminal] window: Implement read-only setting



commit 6331c2ed3949bf8052fd3c17f91f657b31dcbf9e
Author: Christian Persch <chpe gnome org>
Date:   Fri Apr 18 11:42:20 2014 +0200

    window: Implement read-only setting
    
    Required vte commit 3868467b2d4613e5aa5f34c0d8e74abc3a38ef16.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=626747

 src/terminal-window.c |   37 +++++++++++++++++++++++++++++++++++++
 src/terminal.xml      |    5 +++++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 75bce5c..e579a43 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -185,6 +185,8 @@ static void terminal_reset_callback           (GtkAction *action,
                                                TerminalWindow *window);
 static void terminal_reset_clear_callback     (GtkAction *action,
                                                TerminalWindow *window);
+static void terminal_readonly_toggled_callback(GtkToggleAction *action,
+                                               TerminalWindow *window);
 static void tabs_next_or_previous_tab_cb      (GtkAction *action,
                                                TerminalWindow *window);
 static void tabs_move_left_callback           (GtkAction *action,
@@ -1592,6 +1594,22 @@ terminal_window_update_encoding_menu_active_encoding (TerminalWindow *window)
 }
 
 static void
+terminal_window_update_terminal_menu (TerminalWindow *window)
+{
+  TerminalWindowPrivate *priv = window->priv;
+  GtkAction *action;
+
+  if (!priv->active_screen)
+    return;
+
+  action = gtk_action_group_get_action(priv->action_group, "TerminalReadOnly");
+  g_signal_handlers_block_by_func (action, G_CALLBACK (terminal_readonly_toggled_callback), window);
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                !vte_terminal_get_input_enabled (VTE_TERMINAL (priv->active_screen)));
+  g_signal_handlers_unblock_by_func (action, G_CALLBACK (terminal_readonly_toggled_callback), window);
+}
+
+static void
 terminal_size_to_cb (GtkAction *action,
                      TerminalWindow *window)
 {
@@ -2501,6 +2519,11 @@ terminal_window_init (TerminalWindow *window)
       { "ViewFullscreen", NULL, N_("_Full Screen"), NULL,
         NULL,
         G_CALLBACK (view_fullscreen_toggled_callback),
+        FALSE },
+      /* Terminal menu */
+      { "TerminalReadOnly", NULL, N_("Read-_Only"), NULL,
+        NULL,
+        G_CALLBACK (terminal_readonly_toggled_callback),
         FALSE }
     };
   TerminalWindowPrivate *priv;
@@ -3217,6 +3240,7 @@ mdi_screen_switched_cb (TerminalMdiContainer *container,
 
   terminal_window_update_tabs_menu_sensitivity (window);
   terminal_window_update_encoding_menu_active_encoding (window);
+  terminal_window_update_terminal_menu (window);
   terminal_window_update_set_profile_menu_active_profile (window);
   terminal_window_update_copy_sensitivity (screen, window);
   terminal_window_update_zoom_sensitivity (window);
@@ -3690,6 +3714,19 @@ terminal_reset_clear_callback (GtkAction *action,
 }
 
 static void
+terminal_readonly_toggled_callback (GtkToggleAction *action,
+                                    TerminalWindow *window)
+{
+  TerminalWindowPrivate *priv = window->priv;
+
+  if (priv->active_screen == NULL)
+    return;
+
+  vte_terminal_set_input_enabled(VTE_TERMINAL(priv->active_screen),
+                                 !gtk_toggle_action_get_active (action));
+}
+
+static void
 tabs_next_or_previous_tab_cb (GtkAction *action,
                               TerminalWindow *window)
 {
diff --git a/src/terminal.xml b/src/terminal.xml
index 72cef17..d280f79 100644
--- a/src/terminal.xml
+++ b/src/terminal.xml
@@ -52,6 +52,8 @@
         <menuitem action="TerminalAddEncoding" />
       </menu>
       <separator />
+      <menuitem action="TerminalReadOnly" />
+      <separator />
       <menuitem action="TerminalReset" />
       <menuitem action="TerminalResetClear" />
       <separator />
@@ -92,6 +94,9 @@
         <separator />
         <menuitem action="EditCurrentProfile" />
     </menu>
+    <separator/>
+    <menuitem action="TerminalReadOnly" />
+    <separator/>
     <menuitem action="ViewMenubar" />
     <menuitem action="PopupLeaveFullscreen" />
   </popup>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]