[Xfce4-commits] [apps/xfce4-terminal] 01/01: Add --show/hide-scrollbar command line options
noreply at xfce.org
noreply at xfce.org
Thu Sep 29 13:55:43 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 c4a0deb4b65ce8a38f1b986b0576186c9df23092
Author: Igor <f2404 at yandex.ru>
Date: Thu Sep 29 14:54:32 2016 +0300
Add --show/hide-scrollbar command line options
Options allow to override scrollbar settings for one window.
Implements https://bugzilla.xfce.org/show_bug.cgi?id=1779
---
terminal/main.c | 3 +-
terminal/terminal-app.c | 2 +
terminal/terminal-options.c | 5 ++
terminal/terminal-options.h | 1 +
terminal/terminal-screen.c | 192 ++++++++++++++++++++++++--------------------
terminal/terminal-screen.h | 2 +
terminal/terminal-window.c | 4 +
terminal/terminal-window.h | 2 +
8 files changed, 121 insertions(+), 90 deletions(-)
diff --git a/terminal/main.c b/terminal/main.c
index 5f980a2..25324b7 100644
--- a/terminal/main.c
+++ b/terminal/main.c
@@ -131,7 +131,8 @@ usage (void)
" --display=%s; --geometry=%s; --role=%s; --drop-down;\n"
" --startup-id=%s; -I, --icon=%s; --fullscreen; --maximize;\n"
" --show-menubar, --hide-menubar; --show-borders, --hide-borders;\n"
- " --show-toolbar, --hide-toolbar; --font=%s, --zoom=%s\n\n",
+ " --show-toolbar, --hide-toolbar; --show-scrollbar, --hide-scrollbar;\n"
+ " --font=%s; --zoom=%s\n\n",
_("Window Options"),
/* parameter of --display */
_("display"),
diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c
index d0580cc..4c84f09 100644
--- a/terminal/terminal-app.c
+++ b/terminal/terminal-app.c
@@ -760,6 +760,8 @@ terminal_app_open_window (TerminalApp *app,
}
}
+ TERMINAL_WINDOW (window)->scrollbar_visibility = attr->scrollbar;
+
/* font and zoom for new window */
if (!reuse_window)
{
diff --git a/terminal/terminal-options.c b/terminal/terminal-options.c
index 97d96e8..ce0abdd 100644
--- a/terminal/terminal-options.c
+++ b/terminal/terminal-options.c
@@ -425,6 +425,10 @@ terminal_window_attr_parse (gint argc,
{
win_attr->toolbar = visible;
}
+ else if (terminal_option_show_hide_cmp ("scrollbar", argc, argv, &n, &visible))
+ {
+ win_attr->scrollbar = visible;
+ }
else if (terminal_option_cmp ("tab", 0, argc, argv, &n, NULL))
{
if (can_reuse_tab)
@@ -552,6 +556,7 @@ terminal_window_attr_new (void)
win_attr->menubar = TERMINAL_VISIBILITY_DEFAULT;
win_attr->borders = TERMINAL_VISIBILITY_DEFAULT;
win_attr->toolbar = TERMINAL_VISIBILITY_DEFAULT;
+ win_attr->scrollbar = TERMINAL_VISIBILITY_DEFAULT;
win_attr->zoom = TERMINAL_ZOOM_LEVEL_DEFAULT;
tab_attr = g_slice_new0 (TerminalTabAttr);
diff --git a/terminal/terminal-options.h b/terminal/terminal-options.h
index f6d5bf8..d228b86 100644
--- a/terminal/terminal-options.h
+++ b/terminal/terminal-options.h
@@ -76,6 +76,7 @@ typedef struct
TerminalVisibility menubar;
TerminalVisibility borders;
TerminalVisibility toolbar;
+ TerminalVisibility scrollbar;
TerminalZoomLevel zoom;
} TerminalWindowAttr;
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index c43aa4a..4661ad6 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -114,7 +114,6 @@ static void terminal_screen_update_misc_bell (TerminalScreen
static void terminal_screen_update_misc_cursor_blinks (TerminalScreen *screen);
static void terminal_screen_update_misc_cursor_shape (TerminalScreen *screen);
static void terminal_screen_update_misc_mouse_autohide (TerminalScreen *screen);
-static void terminal_screen_update_scrolling_bar (TerminalScreen *screen);
static void terminal_screen_update_scrolling_lines (TerminalScreen *screen);
static void terminal_screen_update_scrolling_on_output (TerminalScreen *screen);
static void terminal_screen_update_scrolling_on_keystroke (TerminalScreen *screen);
@@ -1017,55 +1016,6 @@ terminal_screen_update_colors (TerminalScreen *screen)
-void
-terminal_screen_update_font (TerminalScreen *screen)
-{
- gboolean font_allow_bold;
- gchar *font_name;
- PangoFontDescription *font_desc;
- glong grid_w = 0, grid_h = 0;
- GtkWidget *toplevel;
-
- terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
- terminal_return_if_fail (TERMINAL_IS_PREFERENCES (screen->preferences));
- terminal_return_if_fail (VTE_IS_TERMINAL (screen->terminal));
-
- g_object_get (G_OBJECT (screen->preferences),
- "font-allow-bold", &font_allow_bold,
- "font-name", &font_name,
- NULL);
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
- if (TERMINAL_IS_WINDOW (toplevel))
- {
- if (TERMINAL_WINDOW (toplevel)->font)
- {
- g_free (font_name);
- font_name = g_strdup (TERMINAL_WINDOW (toplevel)->font);
- }
- if (TERMINAL_WINDOW (toplevel)->zoom != TERMINAL_ZOOM_LEVEL_DEFAULT)
- font_name = terminal_screen_zoom_font (screen, font_name, TERMINAL_WINDOW (toplevel)->zoom);
- }
-
- if (gtk_widget_get_realized (GTK_WIDGET (screen)))
- terminal_screen_get_size (screen, &grid_w, &grid_h);
-
- if (G_LIKELY (font_name != NULL))
- {
- font_desc = pango_font_description_from_string (font_name);
- vte_terminal_set_allow_bold (VTE_TERMINAL (screen->terminal), font_allow_bold);
- vte_terminal_set_font (VTE_TERMINAL (screen->terminal), font_desc);
- pango_font_description_free (font_desc);
- g_free (font_name);
- }
-
- /* update window geometry it required */
- if (grid_w > 0 && grid_h > 0)
- terminal_screen_force_resize_window (screen, GTK_WINDOW (toplevel), grid_w, grid_h);
-}
-
-
-
static void
terminal_screen_update_misc_bell (TerminalScreen *screen)
{
@@ -1128,45 +1078,6 @@ terminal_screen_update_misc_mouse_autohide (TerminalScreen *screen)
static void
-terminal_screen_update_scrolling_bar (TerminalScreen *screen)
-{
- TerminalScrollbar scrollbar;
- glong grid_w = 0, grid_h = 0;
- GtkWidget *toplevel;
-
- g_object_get (G_OBJECT (screen->preferences), "scrolling-bar", &scrollbar, NULL);
-
- if (gtk_widget_get_realized (GTK_WIDGET (screen)))
- terminal_screen_get_size (screen, &grid_w, &grid_h);
-
- switch (scrollbar)
- {
- case TERMINAL_SCROLLBAR_NONE:
- gtk_widget_hide (screen->scrollbar);
- break;
-
- case TERMINAL_SCROLLBAR_LEFT:
- gtk_box_reorder_child (GTK_BOX (screen), screen->scrollbar, 0);
- gtk_widget_show (screen->scrollbar);
- break;
-
- case TERMINAL_SCROLLBAR_RIGHT:
- gtk_box_reorder_child (GTK_BOX (screen), screen->scrollbar, 1);
- gtk_widget_show (screen->scrollbar);
- break;
- }
-
- /* update window geometry it required */
- if (grid_w > 0 && grid_h > 0)
- {
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
- terminal_screen_force_resize_window (screen, GTK_WINDOW (toplevel), grid_w, grid_h);
- }
-}
-
-
-
-static void
terminal_screen_update_scrolling_lines (TerminalScreen *screen)
{
guint lines;
@@ -2277,6 +2188,109 @@ terminal_screen_search_find_previous (TerminalScreen *screen)
void
+terminal_screen_update_scrolling_bar (TerminalScreen *screen)
+{
+ TerminalScrollbar scrollbar;
+ TerminalVisibility visibility = TERMINAL_VISIBILITY_DEFAULT;
+ glong grid_w = 0, grid_h = 0;
+ GtkWidget *toplevel;
+
+ g_object_get (G_OBJECT (screen->preferences), "scrolling-bar", &scrollbar, NULL);
+
+ if (gtk_widget_get_realized (GTK_WIDGET (screen)))
+ terminal_screen_get_size (screen, &grid_w, &grid_h);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
+ if (TERMINAL_IS_WINDOW (toplevel))
+ visibility = TERMINAL_WINDOW (toplevel)->scrollbar_visibility;
+
+ if (G_LIKELY (visibility == TERMINAL_VISIBILITY_DEFAULT))
+ {
+ switch (scrollbar)
+ {
+ case TERMINAL_SCROLLBAR_NONE:
+ gtk_widget_hide (screen->scrollbar);
+ break;
+
+ case TERMINAL_SCROLLBAR_LEFT:
+ gtk_box_reorder_child (GTK_BOX (screen), screen->scrollbar, 0);
+ gtk_widget_show (screen->scrollbar);
+ break;
+
+ case TERMINAL_SCROLLBAR_RIGHT:
+ gtk_box_reorder_child (GTK_BOX (screen), screen->scrollbar, 1);
+ gtk_widget_show (screen->scrollbar);
+ break;
+ }
+ }
+ else if (visibility == TERMINAL_VISIBILITY_HIDE)
+ {
+ gtk_widget_hide (screen->scrollbar);
+ }
+ else /* show */
+ {
+ gtk_box_reorder_child (GTK_BOX (screen), screen->scrollbar,
+ scrollbar == TERMINAL_SCROLLBAR_LEFT ? 0 : 1);
+ gtk_widget_show (screen->scrollbar);
+ }
+
+ /* update window geometry it required */
+ if (grid_w > 0 && grid_h > 0)
+ terminal_screen_force_resize_window (screen, GTK_WINDOW (toplevel), grid_w, grid_h);
+}
+
+
+
+void
+terminal_screen_update_font (TerminalScreen *screen)
+{
+ gboolean font_allow_bold;
+ gchar *font_name;
+ PangoFontDescription *font_desc;
+ glong grid_w = 0, grid_h = 0;
+ GtkWidget *toplevel;
+
+ terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
+ terminal_return_if_fail (TERMINAL_IS_PREFERENCES (screen->preferences));
+ terminal_return_if_fail (VTE_IS_TERMINAL (screen->terminal));
+
+ g_object_get (G_OBJECT (screen->preferences),
+ "font-allow-bold", &font_allow_bold,
+ "font-name", &font_name,
+ NULL);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
+ if (TERMINAL_IS_WINDOW (toplevel))
+ {
+ if (TERMINAL_WINDOW (toplevel)->font)
+ {
+ g_free (font_name);
+ font_name = g_strdup (TERMINAL_WINDOW (toplevel)->font);
+ }
+ if (TERMINAL_WINDOW (toplevel)->zoom != TERMINAL_ZOOM_LEVEL_DEFAULT)
+ font_name = terminal_screen_zoom_font (screen, font_name, TERMINAL_WINDOW (toplevel)->zoom);
+ }
+
+ if (gtk_widget_get_realized (GTK_WIDGET (screen)))
+ terminal_screen_get_size (screen, &grid_w, &grid_h);
+
+ if (G_LIKELY (font_name != NULL))
+ {
+ font_desc = pango_font_description_from_string (font_name);
+ vte_terminal_set_allow_bold (VTE_TERMINAL (screen->terminal), font_allow_bold);
+ vte_terminal_set_font (VTE_TERMINAL (screen->terminal), font_desc);
+ pango_font_description_free (font_desc);
+ g_free (font_name);
+ }
+
+ /* update window geometry it required */
+ if (grid_w > 0 && grid_h > 0)
+ terminal_screen_force_resize_window (screen, GTK_WINDOW (toplevel), grid_w, grid_h);
+}
+
+
+
+void
terminal_screen_set_input_enabled (TerminalScreen *screen,
gboolean enabled)
{
diff --git a/terminal/terminal-screen.h b/terminal/terminal-screen.h
index 8db3f8d..a67ab7c 100644
--- a/terminal/terminal-screen.h
+++ b/terminal/terminal-screen.h
@@ -109,6 +109,8 @@ void terminal_screen_search_find_next (TerminalScreen *scree
void terminal_screen_search_find_previous (TerminalScreen *screen);
+void terminal_screen_update_scrolling_bar (TerminalScreen *screen);
+
void terminal_screen_update_font (TerminalScreen *screen);
void terminal_screen_set_input_enabled (TerminalScreen *screen,
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index b4e3491..1ab65a0 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -2292,6 +2292,10 @@ terminal_window_add (TerminalWindow *window,
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (screen), TRUE);
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (screen), TRUE);
+ /* update scrollbar visibility */
+ if (window->scrollbar_visibility != TERMINAL_VISIBILITY_DEFAULT)
+ terminal_screen_update_scrolling_bar (screen);
+
/* update screen font from window */
if (window->font || window->zoom != TERMINAL_ZOOM_LEVEL_DEFAULT)
terminal_screen_update_font (screen);
diff --git a/terminal/terminal-window.h b/terminal/terminal-window.h
index 29aeaf6..32dd86a 100644
--- a/terminal/terminal-window.h
+++ b/terminal/terminal-window.h
@@ -90,6 +90,8 @@ typedef struct
GtkAction *action_fullscreen;
GQueue *closed_tabs_list;
+
+ TerminalVisibility scrollbar_visibility;
} TerminalWindow;
GType terminal_window_get_type (void) G_GNUC_CONST;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list