[Xfce4-commits] [apps/xfce4-terminal] 01/01: Allow per-terminal configuration of 'scroll on output' mode

noreply at xfce.org noreply at xfce.org
Wed Jul 19 20:44:01 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 841f79cae72363b28fda2f125419da731ef2cc1d
Author: Igor <f2404 at yandex.ru>
Date:   Wed Jul 19 14:43:54 2017 -0400

    Allow per-terminal configuration of 'scroll on output' mode
---
 terminal/terminal-screen.c      | 22 +++++++++++++++++
 terminal/terminal-screen.h      |  8 ++++---
 terminal/terminal-window-ui.xml |  1 +
 terminal/terminal-window.c      | 53 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index 09e0a1a..74dff03 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -176,6 +176,7 @@ struct _TerminalScreen
 
   TerminalTitle        dynamic_title_mode;
   guint                hold : 1;
+  guint                scroll_on_output : 1;
 
   guint                activity_timeout_id;
   time_t               activity_resize_time;
@@ -1166,6 +1167,7 @@ terminal_screen_update_scrolling_on_output (TerminalScreen *screen)
 {
   gboolean scroll;
   g_object_get (G_OBJECT (screen->preferences), "scrolling-on-output", &scroll, NULL);
+  screen->scroll_on_output = scroll;
   vte_terminal_set_scroll_on_output (VTE_TERMINAL (screen->terminal), scroll);
 }
 
@@ -2465,6 +2467,26 @@ terminal_screen_set_input_enabled (TerminalScreen *screen,
 
 
 
+gboolean
+terminal_screen_get_scroll_on_output (TerminalScreen *screen)
+{
+  terminal_return_val_if_fail (TERMINAL_IS_SCREEN (screen), FALSE);
+  return screen->scroll_on_output;
+}
+
+
+
+void
+terminal_screen_set_scroll_on_output (TerminalScreen *screen,
+                                      gboolean        enabled)
+{
+  terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
+  screen->scroll_on_output = enabled;
+  vte_terminal_set_scroll_on_output (VTE_TERMINAL (screen->terminal), enabled);
+}
+
+
+
 void
 terminal_screen_save_contents (TerminalScreen *screen,
                                GOutputStream  *stream,
diff --git a/terminal/terminal-screen.h b/terminal/terminal-screen.h
index adad985..a8b7c37 100644
--- a/terminal/terminal-screen.h
+++ b/terminal/terminal-screen.h
@@ -95,18 +95,15 @@ GtkWidget      *terminal_screen_get_tab_label             (TerminalScreen *scree
 void            terminal_screen_focus                     (TerminalScreen *screen);
 
 const gchar    *terminal_screen_get_encoding              (TerminalScreen *screen);
-
 void            terminal_screen_set_encoding              (TerminalScreen *screen,
                                                            const gchar    *charset);
 
 void            terminal_screen_search_set_gregex         (TerminalScreen *screen,
                                                            GRegex         *regex,
                                                            gboolean        wrap_around);
-
 gboolean        terminal_screen_search_has_gregex         (TerminalScreen *screen);
 
 void            terminal_screen_search_find_next          (TerminalScreen *screen);
-
 void            terminal_screen_search_find_previous      (TerminalScreen *screen);
 
 void            terminal_screen_update_scrolling_bar      (TerminalScreen *screen);
@@ -117,10 +114,15 @@ gboolean        terminal_screen_get_input_enabled         (TerminalScreen *scree
 void            terminal_screen_set_input_enabled         (TerminalScreen *screen,
                                                            gboolean        enabled);
 
+gboolean        terminal_screen_get_scroll_on_output      (TerminalScreen *screen);
+void            terminal_screen_set_scroll_on_output      (TerminalScreen *screen,
+                                                           gboolean        enabled);
+
 void            terminal_screen_save_contents             (TerminalScreen *screen,
                                                            GOutputStream  *stream,
                                                            GError         *error);
 
+
 G_END_DECLS
 
 #endif /* !TERMINAL_SCREEN_H */
diff --git a/terminal/terminal-window-ui.xml b/terminal/terminal-window-ui.xml
index fbe2c0f..d47ce4e 100644
--- a/terminal/terminal-window-ui.xml
+++ b/terminal/terminal-window-ui.xml
@@ -48,6 +48,7 @@
       <menuitem action="set-encoding"/>
       <separator/>
       <menuitem action="read-only"/>
+      <menuitem action="scroll-on-output"/>
       <separator/>
       <menuitem action="save-contents"/>
       <separator/>
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 5e8eed3..671eef8 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -119,6 +119,7 @@ static void         terminal_window_set_size_force_grid           (TerminalWindo
                                                                    glong                   force_grid_height);
 static void         terminal_window_update_actions                (TerminalWindow         *window);
 static void         terminal_window_update_slim_tabs              (TerminalWindow         *window);
+static void         terminal_window_update_scroll_on_output       (TerminalWindow         *window);
 static void         terminal_window_notebook_page_switched        (GtkNotebook            *notebook,
                                                                    GtkWidget              *page,
                                                                    guint                   page_num,
@@ -200,6 +201,8 @@ static void         terminal_window_action_fullscreen             (GtkToggleActi
                                                                    TerminalWindow         *window);
 static void         terminal_window_action_readonly               (GtkToggleAction        *action,
                                                                    TerminalWindow         *window);
+static void         terminal_window_action_scroll_on_output       (GtkToggleAction        *action,
+                                                                   TerminalWindow         *window);
 static void         terminal_window_action_zoom_in                (GtkAction              *action,
                                                                    TerminalWindow         *window);
 static void         terminal_window_action_zoom_out               (GtkAction              *action,
@@ -354,6 +357,7 @@ static const GtkToggleActionEntry toggle_action_entries[] =
   { "show-borders", NULL, N_ ("Show Window _Borders"), NULL, N_ ("Show/hide the window decorations"), G_CALLBACK (terminal_window_action_show_borders), TRUE, },
   { "fullscreen", "view-fullscreen", N_ ("_Fullscreen"), "F11", N_ ("Toggle fullscreen mode"), G_CALLBACK (terminal_window_action_fullscreen), FALSE, },
   { "read-only", NULL, N_ ("_Read-Only"), NULL, N_ ("Toggle read-only mode"), G_CALLBACK (terminal_window_action_readonly), FALSE, },
+  { "scroll-on-output", NULL, N_ ("Scroll on _Output"), NULL, N_ ("Toggle scroll on output"), G_CALLBACK (terminal_window_action_scroll_on_output), FALSE, },
 };
 
 
@@ -536,6 +540,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   window->priv->action_search_prev = terminal_window_get_action (window, "search-prev");
   window->priv->action_fullscreen = terminal_window_get_action (window, "fullscreen");
 
+  /* monitor the scrolling-on-output setting */
+  g_signal_connect_swapped (G_OBJECT (window->priv->preferences), "notify::scrolling-on-output",
+                            G_CALLBACK (terminal_window_update_scroll_on_output), window);
+
 #if defined(GDK_WINDOWING_X11)
   if (GDK_IS_X11_SCREEN (screen))
     {
@@ -557,6 +565,10 @@ terminal_window_finalize (GObject *object)
 {
   TerminalWindow *window = TERMINAL_WINDOW (object);
 
+  /* disconnect the scrolling-on-output watch */
+  g_signal_handlers_disconnect_by_func (G_OBJECT (window->priv->preferences),
+                                        G_CALLBACK (terminal_window_update_scroll_on_output), window);
+
   if (window->priv->preferences_dialog != NULL)
     gtk_widget_destroy (window->priv->preferences_dialog);
   g_object_unref (G_OBJECT (window->priv->preferences));
@@ -903,6 +915,11 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
                                     !terminal_screen_get_input_enabled (window->priv->active));
 
+      /* update scroll on output mode */
+      action = terminal_window_get_action (window, "scroll-on-output");
+      gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                                    terminal_screen_get_scroll_on_output (window->priv->active));
+
       /* update the "Go" menu */
       action = g_object_get_qdata (G_OBJECT (window->priv->active), tabs_menu_action_quark);
       if (G_LIKELY (action != NULL))
@@ -937,6 +954,23 @@ terminal_window_update_slim_tabs (TerminalWindow *window)
 
 
 static void
+terminal_window_update_scroll_on_output (TerminalWindow *window)
+{
+  GtkAction *action;
+  gboolean   scroll;
+
+  g_object_get (G_OBJECT (window->priv->preferences),
+                "scrolling-on-output", &scroll,
+                NULL);
+  action = terminal_window_get_action (window, "scroll-on-output");
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), scroll);
+G_GNUC_END_IGNORE_DEPRECATIONS
+}
+
+
+
+static void
 terminal_window_notebook_page_switched (GtkNotebook     *notebook,
                                         GtkWidget       *page,
                                         guint            page_num,
@@ -1776,6 +1810,25 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
 
 static void
+terminal_window_action_scroll_on_output (GtkToggleAction *action,
+                                         TerminalWindow  *window)
+{
+  gboolean scroll_enabled;
+
+  terminal_return_if_fail (window->priv->active != NULL);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  scroll_enabled = gtk_toggle_action_get_active (action);
+  if (terminal_screen_get_scroll_on_output (window->priv->active) != scroll_enabled)
+    {
+      terminal_screen_set_scroll_on_output (window->priv->active, scroll_enabled);
+    }
+G_GNUC_END_IGNORE_DEPRECATIONS
+}
+
+
+
+static void
 terminal_window_action_zoom_in (GtkAction     *action,
                                TerminalWindow *window)
 {

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


More information about the Xfce4-commits mailing list