Commit 7e3c461e authored by Paulo Queiroz's avatar Paulo Queiroz 📦
Browse files

42.alpha1 - scrolling

App

- Introduced "show scrollbars" option & gschema key
- Introduced "overlay scrolling" option & gchema key - implements #6
- Replaced "Profiles" page with "Advanced" in preferences
- Introduced experimental section in Advanced preferences
- Introduced "pixel scrolling" experimental option & gschema key
- Bumped verion to 42.alpha1
parent 41801621
......@@ -17,6 +17,18 @@
<default>true</default>
<summary>Whether the headerbar should be shown or not</summary>
</key>
<key name="show-scrollbars" type="b">
<default>true</default>
<summary>Whether or not to show scrollbars</summary>
</key>
<key name="use-overlay-scrolling" type="b">
<default>true</default>
<summary>Whether overlay scrolling should be enabled</summary>
</key>
<key name="pixel-scrolling" type="b">
<default>false</default>
<summary>If enabled, terminals will scroll by pixels instead of rows</summary>
</key>
<key name="theme" type="s">
<default>'Material'</default>
<summary>The color scheme for the terminal</summary>
......
project('terminal', ['c', 'vala'],
version: '42.alpha0',
version: '42.alpha1',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
],
......
......@@ -43,6 +43,41 @@
</child>
</object>
</child>
<child>
<object class="AdwExpanderRow" id="scrollbars_expander_row">
<property name="visible">True</property>
<property name="title" translatable="yes">Scrollbars</property>
<child>
<object class="AdwActionRow">
<property name="activatable-widget">show_scrollbars_switch</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Show scrollbars</property>
<child>
<object class="GtkSwitch" id="show_scrollbars_switch">
<property name="visible">True</property>
<property name="valign">GTK_ALIGN_CENTER</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow" id="use_overlay_scrolling_action_row">
<property name="activatable-widget">use_overlay_scrolling_switch</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Use overlay scrolling</property>
<child>
<object class="GtkSwitch" id="use_overlay_scrolling_switch">
<property name="visible">True</property>
<property name="valign">GTK_ALIGN_CENTER</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="activatable-widget">pretty_switch</property>
......@@ -125,15 +160,29 @@
<object class="AdwPreferencesPage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">Profiles</property>
<property name="icon-name" translatable="yes">system-users-symbolic</property>
<property name="title" translatable="yes">Advanced</property>
<property name="icon-name" translatable="yes">applications-science</property>
<child>
<object class="AdwPreferencesGroup">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="description" translatable="yes">Coming soon</property>
<!-- <property name="use-markup">True</property> -->
<property name="title" translatable="yes">Experimental 🧪</property>
<property name="description" translatable="yes">Features in this section are known to be wonky. Please feel free to test and &lt;a href="https://gitlab.gnome.org/raggesilver/terminal/-/issues"&gt;report bugs&lt;/a&gt;.</property>
<child>
<placeholder/>
<object class="AdwActionRow" id="pixel_scrolling_action_row">
<property name="activatable-widget">pixel_scrolling_switch</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Pixel scrolling</property>
<property name="subtitle" translatable="yes">Scroll by pixel units instead of scrolling by lines. "Show scrollbars" must be enabled.</property>
<child>
<object class="GtkSwitch" id="pixel_scrolling_switch">
<property name="visible">True</property>
<property name="valign">GTK_ALIGN_CENTER</property>
</object>
</child>
</object>
</child>
</object>
</child>
......
......@@ -23,10 +23,17 @@ public class Terminal.PreferencesWindow : Adw.PreferencesWindow {
[GtkChild] unowned Gtk.Switch pretty_switch;
[GtkChild] unowned Gtk.Switch fill_tabs_switch;
[GtkChild] unowned Gtk.Switch show_headerbar_switch;
[GtkChild] unowned Gtk.Switch use_overlay_scrolling_switch;
[GtkChild] unowned Gtk.Switch show_scrollbars_switch;
[GtkChild] unowned Gtk.Switch pixel_scrolling_switch;
[GtkChild] unowned Gtk.FontButton font_button;
[GtkChild] unowned Gtk.ComboBoxText theme_combo;
[GtkChild] unowned Gtk.SpinButton padding_spin_button;
[GtkChild] unowned Adw.ExpanderRow scrollbars_expander_row;
[GtkChild] unowned Adw.ActionRow use_overlay_scrolling_action_row;
[GtkChild] unowned Adw.ActionRow pixel_scrolling_action_row;
weak Window window;
public PreferencesWindow(Gtk.Application app, Window window) {
......@@ -48,6 +55,39 @@ public class Terminal.PreferencesWindow : Adw.PreferencesWindow {
settings.schema.bind("show-headerbar", this.show_headerbar_switch,
"active", SettingsBindFlags.DEFAULT);
// Scrolling ====
settings.schema.bind (
"show-scrollbars",
this.show_scrollbars_switch,
"active",
SettingsBindFlags.DEFAULT
);
settings.schema.bind (
"use-overlay-scrolling",
this.use_overlay_scrolling_switch,
"active",
SettingsBindFlags.DEFAULT
);
settings.schema.bind (
"pixel-scrolling",
this.pixel_scrolling_switch,
"active",
SettingsBindFlags.DEFAULT
);
// If "Show scrollbars" is off, we want to disable every other setting
// related to scrolling
settings.notify["show-scrollbars"].connect (() => {
this.use_overlay_scrolling_action_row.sensitive = settings.show_scrollbars;
this.pixel_scrolling_action_row.sensitive = settings.show_scrollbars;
});
settings.notify_property ("show-scrollbars");
// Fonts ====
settings.schema.bind("font", this.font_button,
"font", SettingsBindFlags.DEFAULT);
......
......@@ -18,46 +18,96 @@
public class Terminal.TerminalTab : Gtk.Box {
public signal void close_request();
public signal void close_request ();
public string title { get; protected set; }
public string title { get; protected set; }
public Terminal terminal { get; protected set; }
public Gtk.ScrolledWindow scrolled { get; protected set; }
public weak Window window;
public Terminal terminal;
public TerminalTab(Window window, string? cwd) {
Object(
public TerminalTab (Window window, string? cwd) {
Object (
orientation: Gtk.Orientation.VERTICAL,
spacing: 0
);
this.window = window;
this.terminal = new Terminal(this.window, null, cwd);
this.terminal = new Terminal (this.window, null, cwd);
// Hack to stop vala-language-server from complaining
var twig = this.terminal as Gtk.Widget;
// this.set_child(twig);
this.append(twig);
twig.grab_focus();
this.scrolled = new Gtk.ScrolledWindow ();
this.scrolled.child = twig;
var click = new Gtk.GestureClick() {
this.append (this.scrolled);
twig.grab_focus ();
var click = new Gtk.GestureClick () {
button = Gdk.BUTTON_SECONDARY,
};
click.pressed.connect(this.show_menu);
click.pressed.connect (this.show_menu);
this.terminal.add_controller (click);
this.terminal.add_controller(click);
this.connect_signals ();
}
this.terminal.notify["window-title"].connect(() => {
private void connect_signals () {
var settings = Settings.get_default ();
this.terminal.notify["window-title"].connect (() => {
this.title = this.terminal.window_title;
});
this.terminal.exit.connect(() => {
this.close_request();
this.terminal.exit.connect (() => {
this.close_request ();
});
settings.notify["show-scrollbars"].connect (() => {
var show_scrollbars = settings.show_scrollbars;
var is_scrollbar_being_used = this.scrolled.child == this.terminal;
if (show_scrollbars && !is_scrollbar_being_used) {
this.remove (this.terminal);
this.scrolled.child = this.terminal;
this.append (this.scrolled);
}
else if (!show_scrollbars && is_scrollbar_being_used) {
this.remove (this.scrolled);
this.scrolled.child = null;
this.append (this.terminal);
}
// Pixel scrolling depends on this, so we'll notify it to trigger any
// listeners
settings.notify_property ("pixel-scrolling");
});
settings.notify_property ("show-scrollbars");
settings.schema.bind (
"use-overlay-scrolling",
this.scrolled,
"overlay-scrolling",
SettingsBindFlags.GET
);
settings.bind_property (
"pixel-scrolling",
// Make vala-language-server stop complaining
this.terminal as Object,
"scroll-unit-is-pixels",
BindingFlags.DEFAULT,
(_, from, ref to) => {
to = Settings.get_default ().show_scrollbars && from.get_boolean ();
return true;
},
null
);
}
public void show_menu(int n_pressed, double x, double y) {
public void show_menu (int n_pressed, double x, double y) {
var menu = new Menu ();
var edit_section = new Menu ();
var preferences_section = new Menu ();
......@@ -67,13 +117,13 @@ public class Terminal.TerminalTab : Gtk.Box {
menu.append ("New tab", "win.new_tab");
menu.append ("New window", "win.new_window");
menu.append_section(null, edit_section);
menu.append_section (null, edit_section);
preferences_section.append ("Preferences", "win.edit_preferences");
preferences_section.append ("About", "win.about");
menu.append_section(null, preferences_section);
menu.append_section (null, preferences_section);
var pop = new Gtk.PopoverMenu.from_model(menu);
var pop = new Gtk.PopoverMenu.from_model (menu);
Gdk.Rectangle r = {0};
r.x = (int) x;
......
......@@ -80,12 +80,15 @@ public struct Terminal.Padding {
}
public class Terminal.Settings : Marble.Settings {
public string font { get; set; }
public bool pretty { get; set; }
public bool fill_tabs { get; set; }
public bool show_headerbar { get; set; }
public string theme { get; set; }
public Variant terminal_padding { get; set; }
public bool fill_tabs { get; set; }
public bool pixel_scrolling { get; set; }
public bool pretty { get; set; }
public bool show_headerbar { get; set; }
public bool show_scrollbars { get; set; }
public bool use_overlay_scrolling { get; set; }
public string font { get; set; }
public string theme { get; set; }
public Variant terminal_padding { get; set; }
private static Settings instance = null;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment