Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions data/dev.sinty.leafs.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,5 @@
<summary>Saved blooms (JSON)</summary>
<description>List of registered bloom commands as JSON strings (label, command).</description>
</key>
<key name="appearance" type="s">
<choices>
<choice value="system"/>
<choice value="light"/>
<choice value="dark"/>
</choices>
<default>"system"</default>
<summary>Appearance</summary>
<description>Window appearance when running outside the Singularity desktop: follow the system, or force light or dark.</description>
</key>
</schema>
</schemalist>
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ executable('singularity-leafs',
dependencies: [gtk_dep, gee_dep, vte_dep, json_dep, libsingularity_dep,
meson.get_compiler('c').find_library('m', required: true)],
vala_args: ['--pkg=posix'] + develop_vala_args,
install: true
install: true,
install_rpath: get_option('prefix') / get_option('libdir')
)

desktop_conf = configuration_data()
Expand Down
67 changes: 44 additions & 23 deletions src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ namespace Singularity.Apps {
// React to font/theme changes live
settings.changed["font-size"].connect ((_k) => apply_settings_to_all ());
settings.changed["font-family"].connect ((_k) => apply_settings_to_all ());
settings.changed["color-scheme"].connect ((_k) => apply_settings_to_all ());
settings.changed["color-scheme"].connect ((_k) => {
sync_window_chrome ();
apply_settings_to_all ();
});
settings.changed["scrollback-lines"].connect ((_k) => apply_settings_to_all ());
settings.changed["appearance"].connect ((_k) => set_app_appearance (settings.get_string ("appearance")));

// When "auto" theme is active, re-apply whenever system accent or dark-mode changes
desktop_settings = Singularity.Core.safe_settings ("dev.sinty.desktop");
Expand All @@ -138,6 +140,7 @@ namespace Singularity.Apps {
});
}
Singularity.Style.ThemeMode.get_default ().changed.connect (() => {
sync_window_chrome ();
if (settings.get_string ("color-scheme") == "auto")
apply_settings_to_all ();
});
Expand All @@ -146,7 +149,7 @@ namespace Singularity.Apps {
apply_settings_to_all ();
});

set_app_appearance (settings.get_string ("appearance"));
sync_window_chrome ();
}

protected override void activate () {
Expand Down Expand Up @@ -433,6 +436,7 @@ namespace Singularity.Apps {
var popover = new Gtk.Popover ();
popover.set_parent (anchor);
popover.has_arrow = true;
popover.add_css_class ("context-menu");

var root_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
root_box.set_size_request (290, -1);
Expand Down Expand Up @@ -638,15 +642,25 @@ namespace Singularity.Apps {
if (prefs_win != null) { prefs_win.present (); return; }

var page = new Singularity.Widgets.PreferencesPage ();
var group = new Singularity.Widgets.PreferencesGroup (_("Appearance"));
var group = new Singularity.Widgets.PreferencesGroup (_("Terminal"));

var themes = Singularity.Core.TerminalThemes.get_all ();
string[] names = {};
foreach (var t in themes) names += t.name;
string current = settings.get_string ("color-scheme");
string current_name = "";
foreach (var t in themes)
if (t.id == current) current_name = t.name;

var theme_row = new Singularity.Widgets.SelectionRow (_("Theme"),
{ _("System"), _("Light"), _("Dark") },
appearance_label (settings.get_string ("appearance")));
var theme_row = new Singularity.Widgets.SelectionRow (_("Theme"), names, current_name);
theme_row.selected.connect ((item) => {
string tok = appearance_token (item);
if (settings.get_string ("appearance") != tok)
settings.set_string ("appearance", tok);
foreach (var t in themes) {
if (t.name == item) {
if (settings.get_string ("color-scheme") != t.id)
settings.set_string ("color-scheme", t.id);
break;
}
}
});
group.add_row (theme_row);
page.append_group (group);
Expand All @@ -656,18 +670,16 @@ namespace Singularity.Apps {
prefs_win.present ();
}

private string appearance_label (string tok) {
switch (tok) {
case "light": return _("Light");
case "dark": return _("Dark");
default: return _("System");
}
}

private string appearance_token (string label) {
if (label == _("Light")) return "light";
if (label == _("Dark")) return "dark";
return "system";
private void sync_window_chrome () {
string scheme = settings.get_string ("color-scheme");
bool dark = scheme == "auto"
? Singularity.Style.ThemeMode.get_default ().app_dark ()
: Singularity.Core.TerminalThemes.is_dark_background (
(Singularity.Core.TerminalThemes.get_by_id (scheme)
?? Singularity.Core.TerminalThemes.get_by_id ("onedark")).background);
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = dark;
Singularity.Style.StyleManager.get_default ().apply_color_scheme (dark);
}

private void apply_settings_to_all () {
Expand Down Expand Up @@ -768,6 +780,7 @@ namespace Singularity.Apps {
var popover = new Gtk.Popover ();
popover.set_parent (anchor);
popover.has_arrow = true;
popover.add_css_class ("context-menu");

var root_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
root_box.set_size_request (290, -1);
Expand Down Expand Up @@ -888,7 +901,7 @@ namespace Singularity.Apps {
provider.load_from_data (LEAFS_CSS.data);
Gtk.StyleContext.add_provider_for_display (
Gdk.Display.get_default (), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.STYLE_PROVIDER_PRIORITY_USER + 1);
}

private const string LEAFS_CSS = """
Expand Down Expand Up @@ -1009,7 +1022,15 @@ namespace Singularity.Apps {
.bloom-terminal {
padding: 30px 12px 8px 12px;
}
""";
/* Hover buttons force a white icon/label color (library CSS); stop
it from inheriting into popovers anchored on them (GTK4 popovers
are style-tree children of their anchor). */
.leafs-window popover.context-menu,
.leafs-window popover.context-menu > contents,
.leafs-window popover.context-menu * {
color: @text_color;
}
""";
}

}
11 changes: 10 additions & 1 deletion src/leaf_pane.vala
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ namespace Singularity.Apps {
hover_controls.add_control (grip_btn);

var add_btn = new Button.from_icon_name ("list-add-symbolic");
add_btn.add_css_class ("flat");
add_btn.tooltip_text = _("New leaf / bug");
add_btn.clicked.connect (() => {
_add_menu = new Singularity.Widgets.ContextMenu (add_btn);
Expand All @@ -177,19 +178,23 @@ namespace Singularity.Apps {
hover_controls.add_control (add_btn);

ssh_btn = new Button.from_icon_name ("network-server-symbolic");
ssh_btn.add_css_class ("flat");
ssh_btn.tooltip_text = _("SSH Sessions");
hover_controls.add_control (ssh_btn);

bloom_btn = new Button.from_icon_name ("window-restore-symbolic");
bloom_btn.add_css_class ("flat");
bloom_btn.tooltip_text = _("Blooms");
hover_controls.add_control (bloom_btn);

var settings_btn = new Button.from_icon_name ("emblem-system-symbolic");
settings_btn.add_css_class ("flat");
settings_btn.tooltip_text = _("Settings");
settings_btn.clicked.connect (() => settings_requested ());
hover_controls.add_control (settings_btn);

var close_btn = new Button.from_icon_name ("window-close-symbolic");
close_btn.add_css_class ("flat");
close_btn.tooltip_text = _("Close");
close_btn.clicked.connect (() => {
_close_menu = new Singularity.Widgets.ContextMenu (close_btn);
Expand Down Expand Up @@ -327,7 +332,11 @@ namespace Singularity.Apps {
vte.set_font (font_desc);
vte.set_scrollback_lines (s.get_int ("scrollback-lines"));

var theme = Singularity.Core.TerminalThemes.get_by_id (s.get_string ("color-scheme"));
string scheme = s.get_string ("color-scheme");
var theme = (scheme == "auto")
? Singularity.Core.TerminalThemes.make_auto_theme (
Singularity.Style.ThemeMode.get_default ().app_dark ())
: Singularity.Core.TerminalThemes.get_by_id (scheme);
if (theme == null)
theme = Singularity.Core.TerminalThemes.get_by_id ("onedark");
if (theme != null) {
Expand Down
1 change: 1 addition & 0 deletions src/window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Singularity.Apps {

public LeafsWindow (Gtk.Application app) {
Object (application: app);
add_css_class ("leafs-window");
#if DEVEL
set_title (_("Leafs (Devel)"));
#else
Expand Down