Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
13 changes: 7 additions & 6 deletions src/Widgets/FormatBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,24 @@ public class Code.FormatBar : Gtk.Grid {
tab_popover.add (tab_grid);

tab_toggle.bind_property ("active", tab_popover, "visible", GLib.BindingFlags.BIDIRECTIONAL);
Scratch.settings.changed["indent-width"].connect (() => format_tab_header ());
Scratch.settings.changed["spaces-instead-of-tabs"].connect (() => format_tab_header ());
Scratch.settings.changed["indent-width"].connect (format_tab_header);
Scratch.settings.changed["spaces-instead-of-tabs"].connect (format_tab_header);
}

private void format_tab_header () {
var indent_width = Scratch.settings.get_int ("indent-width");
var spaces_instead_of_tabs = Scratch.settings.get_boolean ("spaces-instead-of-tabs");
if (doc != null) {
indent_width = (int)doc.source_view.tab_width;
spaces_instead_of_tabs = doc.source_view.insert_spaces_instead_of_tabs;
}

if (spaces_instead_of_tabs) {
tab_toggle.text = ngettext ("%d Space", "%d Spaces", indent_width).printf (indent_width);
} else {
tab_toggle.text = ngettext ("%d Tab", "%d Tabs", indent_width).printf (indent_width);
}

if (doc != null) {
doc.source_view.tab_width = (uint)indent_width;
doc.source_view.insert_spaces_instead_of_tabs = spaces_instead_of_tabs;
}
}

private void format_line_header () {
Expand Down
17 changes: 0 additions & 17 deletions src/Widgets/SourceView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ namespace Scratch.Widgets {
return !start.equal (end);
}

~SourceView () {
// Update settings when an instance is deleted
update_settings ();
}

public void change_syntax_highlight_from_file (File file) {
try {
var info = file.query_info ("standard::*", FileQueryInfoFlags.NONE, null);
Expand Down Expand Up @@ -298,18 +293,6 @@ namespace Scratch.Widgets {
style_changed (source_buffer.style_scheme);
}

private void update_settings () {
var source_buffer = (Gtk.SourceBuffer) buffer;
Scratch.settings.set_boolean ("show-right-margin", show_right_margin);
Scratch.settings.set_int ("right-margin-position", (int) right_margin_position);
Scratch.settings.set_boolean ("highlight-matching-brackets", source_buffer.highlight_matching_brackets);
Scratch.settings.set_boolean ("spaces-instead-of-tabs", insert_spaces_instead_of_tabs);
Scratch.settings.set_int ("indent-width", (int) tab_width);
Scratch.settings.set_string ("font", font);
Scratch.settings.set_string ("style-scheme", source_buffer.style_scheme.id);
style_changed (source_buffer.style_scheme);
}

public void go_to_line (int line, int offset = 0) {
Gtk.TextIter it;
buffer.get_iter_at_line (out it, line - 1);
Expand Down