Skip to content
Open
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
24 changes: 24 additions & 0 deletions src/components/sidebar/pages/app_details_page.vala
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ namespace Singularity.SidebarPages {
view.open_subpage(page, "app-details-sandbox");
}

// Installed monospace families, sorted, always including the current
// value so a font that was removed or typed by hand stays visible.
private string[] monospace_families(string current) {
var names = new Gee.TreeSet<string>((a, b) => a.collate(b));
(unowned Pango.FontFamily)[] families;
get_pango_context().list_families(out families);
foreach (unowned var family in families) {
if (family.is_monospace()) names.add(family.get_name());
}
if (current != "") names.add(current);
return names.to_array();
}

private void build_settings_section() {
var group = new PreferencesGroup(_("App Settings"));
var loading_row = new PreferencesRow();
Expand Down Expand Up @@ -373,6 +386,17 @@ namespace Singularity.SidebarPages {
row.current_value = settings.get_string(item.key);
});
group.add_row(row);
} else if (item.widget == "monospace-font-selector") {
var current = settings.get_string(item.key);
var row = new SelectionRow(item.label, monospace_families(current), current);
if (item.subtitle != null) row.subtitle = item.subtitle;
row.selected.connect((family) => {
settings.set_string(item.key, family);
});
settings.changed[item.key].connect(() => {
row.current_value = settings.get_string(item.key);
});
group.add_row(row);
} else if (item.widget == "entry") {
var row = new EntryRow(item.label);
if (item.subtitle != null) row.subtitle = item.subtitle;
Expand Down