diff options
author | Christian Persch <chpe@src.gnome.org> | 2021-03-13 22:10:42 +0100 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2021-03-13 22:10:42 +0100 |
commit | 1be3d3d9fa160874ccf162acd1adb88ca8ba05a8 (patch) | |
tree | 10ca744c6d74b55b7275a0bb59262ff20ab4e2f1 /src/app | |
parent | cf4984c4c35b6c15b239fbea5abf3a92271665d2 (diff) | |
download | vte-1be3d3d9fa160874ccf162acd1adb88ca8ba05a8.tar.gz |
widget: Add alignment properties
Add API to set how to distribute extra-grid space allocated to the
widget. Previously, vte always positioned the content at the left and top
of the allocation.
Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/337
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/app.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/app/app.cc b/src/app/app.cc index 1c772718..2712ca52 100644 --- a/src/app/app.cc +++ b/src/app/app.cc @@ -122,6 +122,8 @@ public: VteCursorBlinkMode cursor_blink_mode{VTE_CURSOR_BLINK_SYSTEM}; VteCursorShape cursor_shape{VTE_CURSOR_SHAPE_BLOCK}; VteTextBlinkMode text_blink_mode{VTE_TEXT_BLINK_ALWAYS}; + GtkAlign xalign{GtkAlign(-1)}; + GtkAlign yalign{GtkAlign(-1)}; vte::glib::RefPtr<GtkCssProvider> css{}; #if VTE_GTK == 3 @@ -476,6 +478,28 @@ private: return true; } + static gboolean + parse_xalign(char const* option, char const* value, void* data, GError** error) + { + auto const that = static_cast<Options*>(data); + auto v = int{}; + auto const rv = that->parse_enum(GTK_TYPE_ALIGN, value, v, error); + if (rv) + that->xalign = GtkAlign(v); + return rv; + } + + static gboolean + parse_yalign(char const* option, char const* value, void* data, GError** error) + { + auto const that = static_cast<Options*>(data); + auto v = int{}; + auto const rv = that->parse_enum(GTK_TYPE_ALIGN, value, v, error); + if (rv) + that->yalign = GtkAlign(v); + return rv; + } + public: double get_alpha() const @@ -668,6 +692,11 @@ public: { "use-theme-colors", 0, 0, G_OPTION_ARG_NONE, &use_theme_colors, "Use foreground and background colors from the gtk+ theme", nullptr }, + { "xalign", 0, 0, G_OPTION_ARG_CALLBACK, (void*)parse_xalign, + "Horizontal alignment (fill|start|end|center)", "ALIGN" }, + { "yalign", 0, 0, G_OPTION_ARG_CALLBACK, (void*)parse_yalign, + "Vertical alignment (fill|start|end|center)", "ALIGN" }, + #if VTE_GTK == 3 { "no-argb-visual", 0, 0, G_OPTION_ARG_NONE, &no_argb_visual, "Don't use an ARGB visual", nullptr }, @@ -2549,6 +2578,10 @@ vteapp_window_constructed(GObject *object) vte_terminal_set_scroll_unit_is_pixels(window->terminal, options.scroll_unit_is_pixels); vte_terminal_set_scrollback_lines(window->terminal, options.scrollback_lines); vte_terminal_set_text_blink_mode(window->terminal, options.text_blink_mode); + if (options.xalign != GtkAlign(-1)) + vte_terminal_set_xalign(window->terminal, options.xalign); + if (options.yalign != GtkAlign(-1)) + vte_terminal_set_yalign(window->terminal, options.yalign); /* Style */ if (options.font_string != nullptr) { |