From e8ed52743efeccc857f8981319b44219bacadbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 21 Jul 2026 10:16:52 -0700 Subject: [PATCH 01/14] FormatBar: use Action for lang state --- src/Widgets/FormatBar.vala | 103 +++++++++++++------------------------ 1 file changed, 35 insertions(+), 68 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 8286caefcc..a16604c254 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -27,10 +27,9 @@ public class Code.FormatBar : Gtk.Box { private Granite.SwitchModelButton space_tab_modelbutton; private Gtk.Entry goto_entry; private Gtk.InfoBar editorconfig_infobar; - private Gtk.ListBox lang_selection_listbox; private Gtk.SourceLanguageManager manager; private Gtk.SpinButton width_spinbutton; - private LangEntry normal_entry; + private SimpleAction language_action; private unowned Scratch.Services.Document? doc = null; @@ -94,7 +93,7 @@ public class Code.FormatBar : Gtk.Box { placeholder_text = _("Filter languages") }; - lang_selection_listbox = new Gtk.ListBox () { + var lang_selection_listbox = new Gtk.ListBox () { selection_mode = SINGLE }; lang_selection_listbox.set_sort_func ((row1, row2) => { @@ -105,16 +104,13 @@ public class Code.FormatBar : Gtk.Box { return (((LangEntry) row).lang_name.down ().contains (lang_selection_filter.text.down ().strip ())); }); - unowned SList group = null; foreach (unowned string id in manager.get_language_ids ()) { weak Gtk.SourceLanguage lang = manager.get_language (id); - var entry = new LangEntry (id, lang.name, group); - group = entry.get_radio_group (); + var entry = new LangEntry (id, lang.name); lang_selection_listbox.add (entry); } - normal_entry = new LangEntry (null, _("Plain Text"), group); - + var normal_entry = new LangEntry ("", _("Plain Text")); lang_selection_listbox.add (normal_entry); var lang_scrolled = new Gtk.ScrolledWindow (null, null) { @@ -180,9 +176,29 @@ public class Code.FormatBar : Gtk.Box { add (lang_menubutton); add (line_menubutton); + language_action = new SimpleAction.stateful ("language", VariantType.STRING, new Variant.string ("")); + language_action.change_state.connect ((parameter) => { + language_action.set_state (parameter); + + var lang_id = parameter.get_string (); + if (lang_id != "") { + unowned var lang = manager.get_language (lang_id); + lang_menubutton.text = lang.name; + } else { + lang_menubutton.text = _("Plain Text"); + } + + doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; + }); + + var action_group = new SimpleActionGroup (); + action_group.add_action (language_action); + + insert_action_group ("format", action_group); + lang_selection_listbox.row_activated.connect ((row) => { var lang_entry = ((LangEntry) row); - select_language (lang_entry); + language_action.set_state (new Variant.string (lang_entry.lang_id)); }); lang_selection_filter.changed.connect (() => { @@ -229,17 +245,6 @@ public class Code.FormatBar : Gtk.Box { line_menubutton.active = true; } - private void select_language (LangEntry lang, bool update_source_view = true) { - lang_selection_listbox.select_row (lang); - lang_menubutton.text = lang.lang_name; - if (update_source_view) { - lang.active = true; - doc.source_view.language = lang.lang_id != null ? manager.get_language (lang.lang_id) : null; - } else { - lang.selected = true; - } - } - private void format_tab_header_from_global_settings () { if (!tab_style_set_by_editor_config) { set_insert_spaces_instead_of_tabs (Scratch.settings.get_boolean ("spaces-instead-of-tabs")); @@ -299,15 +304,9 @@ public class Code.FormatBar : Gtk.Box { private void update_current_lang () { var language = doc.source_view.language; if (language != null) { - var lang_id = language.id; - lang_selection_listbox.get_children ().foreach ((child) => { - var lang_entry = ((LangEntry) child); - if (lang_entry.lang_id == lang_id) { - select_language (lang_entry, false); - } - }); + language_action.set_state (new Variant.string (language.id)); } else { - select_language (normal_entry, false); + language_action.set_state (new Variant.string ("")); } } @@ -350,35 +349,11 @@ public class Code.FormatBar : Gtk.Box { } private class LangEntry : Gtk.ListBoxRow { - public string? lang_id { get; construct; } + public string lang_id { get; construct; } public string lang_name { get; construct; } - public unowned SList group { get; construct; } - - public bool active { - get { - return lang_radio.active; - } - - set { - lang_radio.active = value; - } - } - - public bool selected { - get { - return lang_radio.active; - } - set { - lang_radio.toggled.disconnect (radio_toggled); - lang_radio.active = value; - lang_radio.toggled.connect (radio_toggled); - } - } - - private Gtk.RadioButton lang_radio; - public LangEntry (string? lang_id, string lang_name, SList group) { - Object (group: group, lang_id: lang_id, lang_name: lang_name); + public LangEntry (string lang_id, string lang_name) { + Object (lang_id: lang_id, lang_name: lang_name); } class construct { @@ -386,20 +361,12 @@ public class Code.FormatBar : Gtk.Box { } construct { - lang_radio = new Gtk.RadioButton.with_label (group, lang_name); - - add (lang_radio); - lang_radio.toggled.connect (radio_toggled); - } - - private void radio_toggled () { - if (lang_radio.active) { - activate (); - } - } + var lang_radio = new Gtk.RadioButton.with_label (null, lang_name) { + action_name = "format.language", + action_target = new Variant.string (lang_id) + }; - public unowned SList get_radio_group () { - return lang_radio.get_group (); + child = lang_radio; } } } From 904313be07ad36339a7c7ba64970a0da2932e142 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:10:42 +0100 Subject: [PATCH 02/14] Change a confusing name --- src/Widgets/FormatBar.vala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index f05f0713a8..66af90ac63 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -32,7 +32,7 @@ public class Code.FormatBar : Gtk.Box { private Gtk.SpinButton width_spinbutton; private SimpleAction language_action; - private unowned Scratch.Services.Document? doc = null; + private unowned Scratch.Services.Document? current_doc = null; construct { get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED); @@ -195,7 +195,7 @@ public class Code.FormatBar : Gtk.Box { lang_formatbox.text = _("Plain Text"); } - doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; + current_doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; }); var action_group = new SimpleActionGroup (); @@ -236,9 +236,10 @@ public class Code.FormatBar : Gtk.Box { int line, column; goto_entry.text = goto_entry.text.replace (":", "."); goto_entry.text.scanf ("%i.%i", out line, out column); - doc.source_view.go_to_line (line, column - 1); - // Focuses parent to the source view, so that the cursor, which indicates line and column is actually visible. - doc.source_view.grab_focus (); + current_doc.source_view.go_to_line (line, column - 1); + // Focuses parent to the source view, so that the cursor, which indicates line and column + // is actually visible. + current_doc.source_view.grab_focus (); }); Scratch.settings.changed["indent-width"].connect (format_tab_header_from_global_settings); From 067356f35e45559396e0c1da6733f0a639fdf672 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:12:26 +0100 Subject: [PATCH 03/14] Fix set document on start up --- src/Widgets/FormatBar.vala | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 66af90ac63..57ddf56bd1 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -253,10 +253,24 @@ public class Code.FormatBar : Gtk.Box { line_menubutton.active = true; } + public void set_document (Scratch.Services.Document doc) requires (doc != null) { + current_doc = doc; + if (doc.loading) { + Timeout.add (200, () => { + if (doc.loading) { + return Source.CONTINUE; + } else { + update_widgets (); + return Source.REMOVE; + } + }); + } else { + update_widgets (); private void format_tab_header_from_global_settings () { if (!tab_style_set_by_editor_config) { set_insert_spaces_instead_of_tabs (Scratch.settings.get_boolean ("spaces-instead-of-tabs")); } + } if (!tab_width_set_by_editor_config) { set_tab_width (Scratch.settings.get_int ("indent-width")); @@ -276,17 +290,6 @@ public class Code.FormatBar : Gtk.Box { goto_entry.text = "%d.%d".printf (line, iter.get_line_offset () + 1); } - public void set_document (Scratch.Services.Document doc) { - if (this.doc != null) { - this.doc.source_view.buffer.notify["cursor-position"].disconnect (format_line_header); - } - - this.doc = doc; - update_current_lang (); - format_tab_header_from_global_settings (); - format_line_header (); - this.doc.source_view.buffer.notify["cursor-position"].connect (format_line_header); - } public void set_insert_spaces_instead_of_tabs (bool use_spaces) { space_tab_modelbutton.active = use_spaces; From 6e6dbb0d4bc121f1bde155148728881e56819ecd Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:13:07 +0100 Subject: [PATCH 04/14] Remove unnecessary, duplicate handler --- src/Widgets/FormatBar.vala | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 57ddf56bd1..c4d9d7cebf 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -203,11 +203,6 @@ public class Code.FormatBar : Gtk.Box { insert_action_group ("format", action_group); - lang_selection_listbox.row_activated.connect ((row) => { - var lang_entry = ((LangEntry) row); - language_action.set_state (new Variant.string (lang_entry.lang_id)); - }); - lang_selection_filter.changed.connect (() => { lang_selection_listbox.invalidate_filter (); }); From 6a880eb66497ff6922d4475e9d4d7b99a03f03cc Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:13:43 +0100 Subject: [PATCH 05/14] Reorder public before private functions --- src/Widgets/FormatBar.vala | 66 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index c4d9d7cebf..dc94c2d0fa 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -261,22 +261,35 @@ public class Code.FormatBar : Gtk.Box { }); } else { update_widgets (); - private void format_tab_header_from_global_settings () { - if (!tab_style_set_by_editor_config) { - set_insert_spaces_instead_of_tabs (Scratch.settings.get_boolean ("spaces-instead-of-tabs")); } } - if (!tab_width_set_by_editor_config) { - set_tab_width (Scratch.settings.get_int ("indent-width")); + public void set_insert_spaces_instead_of_tabs (bool use_spaces) requires (current_doc != null) { + space_tab_modelbutton.active = use_spaces; + current_doc.source_view.insert_spaces_instead_of_tabs = use_spaces; + } + + public void set_tab_width (int indent_width) requires (current_doc != null) { + width_spinbutton.@value = indent_width; + if (space_tab_modelbutton.active) { + tab_formatbox.text = ngettext ("%d Space", "%d Spaces", indent_width).printf (indent_width); + } else { + tab_formatbox.text = ngettext ("%d Tab", "%d Tabs", indent_width).printf (indent_width); } - editorconfig_infobar.revealed = tab_style_set_by_editor_config || tab_width_set_by_editor_config; - space_tab_modelbutton.sensitive = !tab_style_set_by_editor_config; + current_doc.source_view.indent_width = indent_width; + current_doc.source_view.tab_width = indent_width; } - private void format_line_header () { - var buffer = doc.source_view.buffer; + private void update_widgets () requires (current_doc != null) { + update_current_lang (); + format_tab_header_from_global_settings (); + format_line_header (); + current_doc.source_view.buffer.notify["cursor-position"].connect (format_line_header); + } + + private void format_line_header () requires (current_doc != null) { + var buffer = current_doc.source_view.buffer; var position = buffer.cursor_position; Gtk.TextIter iter; buffer.get_iter_at_offset (out iter, position); @@ -285,35 +298,26 @@ public class Code.FormatBar : Gtk.Box { goto_entry.text = "%d.%d".printf (line, iter.get_line_offset () + 1); } - - public void set_insert_spaces_instead_of_tabs (bool use_spaces) { - space_tab_modelbutton.active = use_spaces; - if (doc != null) { - doc.source_view.insert_spaces_instead_of_tabs = use_spaces; + private void update_current_lang () requires (current_doc != null) { + var language = current_doc.source_view.language; + if (language != null) { + language_action.change_state (new Variant.string (language.id)); + } else { + language_action.change_state (new Variant.string ("")); } } - public void set_tab_width (int indent_width) { - width_spinbutton.@value = indent_width; - if (space_tab_modelbutton.active) { - tab_formatbox.text = ngettext ("%d Space", "%d Spaces", indent_width).printf (indent_width); - } else { - tab_formatbox.text = ngettext ("%d Tab", "%d Tabs", indent_width).printf (indent_width); + private void format_tab_header_from_global_settings () { + if (!tab_style_set_by_editor_config) { + set_insert_spaces_instead_of_tabs (Scratch.settings.get_boolean ("spaces-instead-of-tabs")); } - if (doc != null) { - doc.source_view.indent_width = indent_width; - doc.source_view.tab_width = indent_width; + if (!tab_width_set_by_editor_config) { + set_tab_width (Scratch.settings.get_int ("indent-width")); } - } - private void update_current_lang () { - var language = doc.source_view.language; - if (language != null) { - language_action.set_state (new Variant.string (language.id)); - } else { - language_action.set_state (new Variant.string ("")); - } + editorconfig_infobar.revealed = tab_style_set_by_editor_config || tab_width_set_by_editor_config; + space_tab_modelbutton.sensitive = !tab_style_set_by_editor_config; } private class FormatBox : Gtk.Box { From 7bf3ca0c4134e6f0faa9d5ec4591cec0ee9a2ab5 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:14:00 +0100 Subject: [PATCH 06/14] Fix long lines --- src/Widgets/FormatBar.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index dc94c2d0fa..17e93a63c0 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -200,7 +200,6 @@ public class Code.FormatBar : Gtk.Box { var action_group = new SimpleActionGroup (); action_group.add_action (language_action); - insert_action_group ("format", action_group); lang_selection_filter.changed.connect (() => { @@ -226,7 +225,8 @@ public class Code.FormatBar : Gtk.Box { } }); - // We need to connect_after because otherwise, the text isn't parsed into the "value" property and we only get the previous value + // We need to connect_after because otherwise, the text isn't parsed into the "value" property + // and we only get the previous value goto_entry.activate.connect_after (() => { int line, column; goto_entry.text = goto_entry.text.replace (":", "."); From bf8c02a04907218c4b755e1b20aa5832679041f2 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:46:57 +0100 Subject: [PATCH 07/14] Cleanup update current lang --- src/Widgets/FormatBar.vala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 17e93a63c0..47e5a45a91 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -300,11 +300,8 @@ public class Code.FormatBar : Gtk.Box { private void update_current_lang () requires (current_doc != null) { var language = current_doc.source_view.language; - if (language != null) { - language_action.change_state (new Variant.string (language.id)); - } else { - language_action.change_state (new Variant.string ("")); - } + var lang_id = language != null ? language.id : ""; + language_action.change_state (new Variant.string (lang_id)); } private void format_tab_header_from_global_settings () { From 7efa64fc61ca9e3d3e326689364fbf904a918c86 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:47:32 +0100 Subject: [PATCH 08/14] Use CheckButton --- src/Widgets/FormatBar.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 47e5a45a91..aa78da99d7 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -359,12 +359,12 @@ public class Code.FormatBar : Gtk.Box { } construct { - var lang_radio = new Gtk.RadioButton.with_label (null, lang_name) { + var lang_checkbutton = new Gtk.CheckButton.with_label (lang_name) { action_name = "format.language", action_target = new Variant.string (lang_id) }; - child = lang_radio; + child = lang_checkbutton; } } } From 54e26f7ceb103685c099f03279bc853c63f96742 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 14:47:51 +0100 Subject: [PATCH 09/14] Popdown list after choice --- src/Widgets/FormatBar.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index aa78da99d7..a05755702c 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -186,7 +186,6 @@ public class Code.FormatBar : Gtk.Box { language_action = new SimpleAction.stateful ("language", VariantType.STRING, new Variant.string ("")); language_action.change_state.connect ((parameter) => { language_action.set_state (parameter); - var lang_id = parameter.get_string (); if (lang_id != "") { unowned var lang = manager.get_language (lang_id); @@ -196,6 +195,8 @@ public class Code.FormatBar : Gtk.Box { } current_doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; + + lang_popover.popdown (); }); var action_group = new SimpleActionGroup (); From 498db2c7a241ee69e5a9941d6437e5839ba0746e Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 15:58:34 +0100 Subject: [PATCH 10/14] Do not popdown - like master --- src/Widgets/FormatBar.vala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index a05755702c..61ab2e6fd2 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -195,8 +195,6 @@ public class Code.FormatBar : Gtk.Box { } current_doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; - - lang_popover.popdown (); }); var action_group = new SimpleActionGroup (); From 8a0685dc0847c3e185a89034d15a82303126f694 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 15:59:30 +0100 Subject: [PATCH 11/14] Do not set document language to same language --- src/Widgets/FormatBar.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 61ab2e6fd2..5dee8363f3 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -187,14 +187,18 @@ public class Code.FormatBar : Gtk.Box { language_action.change_state.connect ((parameter) => { language_action.set_state (parameter); var lang_id = parameter.get_string (); + + if (current_doc.source_view.language.id != lang_id) { // Avoids loop + current_doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; + } + if (lang_id != "") { unowned var lang = manager.get_language (lang_id); lang_formatbox.text = lang.name; } else { lang_formatbox.text = _("Plain Text"); + current_doc.source_view.language = null; } - - current_doc.source_view.language = lang_id != "" ? manager.get_language (lang_id) : null; }); var action_group = new SimpleActionGroup (); From 0a0d2c4abd6799e2e4055d5dca6b76c57336c51c Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 16:00:30 +0100 Subject: [PATCH 12/14] Do not call format_tab_header_from_global_settings too early --- src/Widgets/FormatBar.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 5dee8363f3..1644b17661 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -209,7 +209,6 @@ public class Code.FormatBar : Gtk.Box { lang_selection_listbox.invalidate_filter (); }); - format_tab_header_from_global_settings (); width_spinbutton.value_changed.connect (() => { if (!tab_width_set_by_editor_config) { Scratch.settings.set_int ( @@ -285,6 +284,7 @@ public class Code.FormatBar : Gtk.Box { } private void update_widgets () requires (current_doc != null) { + format_tab_header_from_global_settings (); update_current_lang (); format_tab_header_from_global_settings (); format_line_header (); From 4b0beb7c4b548a8a9b280492cec589c2ac3f875a Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 16:01:11 +0100 Subject: [PATCH 13/14] Ensure signal handlers connect and disconnect once per doc --- src/Widgets/FormatBar.vala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 1644b17661..9e5a04415c 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -251,6 +251,11 @@ public class Code.FormatBar : Gtk.Box { } public void set_document (Scratch.Services.Document doc) requires (doc != null) { + if (current_doc != null) { + SignalHandler.disconnect (current_doc, cursor_handler); + SignalHandler.disconnect (current_doc, language_handler); + } + current_doc = doc; if (doc.loading) { Timeout.add (200, () => { @@ -283,12 +288,20 @@ public class Code.FormatBar : Gtk.Box { current_doc.source_view.tab_width = indent_width; } + private ulong cursor_handler = 0; + private ulong language_handler = 0; private void update_widgets () requires (current_doc != null) { format_tab_header_from_global_settings (); update_current_lang (); format_tab_header_from_global_settings (); format_line_header (); - current_doc.source_view.buffer.notify["cursor-position"].connect (format_line_header); + if (cursor_handler == 0) { + cursor_handler = current_doc.source_view.buffer.notify["cursor-position"].connect (format_line_header); + } + + if (language_handler == 0) { + language_handler = current_doc.source_view.notify["language"].connect (update_current_lang); + } } private void format_line_header () requires (current_doc != null) { @@ -304,6 +317,7 @@ public class Code.FormatBar : Gtk.Box { private void update_current_lang () requires (current_doc != null) { var language = current_doc.source_view.language; var lang_id = language != null ? language.id : ""; + // Should not directly modify action state language_action.change_state (new Variant.string (lang_id)); } From b75732de6272114c76cf4de1ebceef933efcd7db Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Aug 2026 16:03:06 +0100 Subject: [PATCH 14/14] Move handler ids to start --- src/Widgets/FormatBar.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 9e5a04415c..40a3a6bc4c 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -31,6 +31,8 @@ public class Code.FormatBar : Gtk.Box { private Gtk.SourceLanguageManager manager; private Gtk.SpinButton width_spinbutton; private SimpleAction language_action; + private ulong cursor_handler = 0; + private ulong language_handler = 0; private unowned Scratch.Services.Document? current_doc = null; @@ -288,8 +290,6 @@ public class Code.FormatBar : Gtk.Box { current_doc.source_view.tab_width = indent_width; } - private ulong cursor_handler = 0; - private ulong language_handler = 0; private void update_widgets () requires (current_doc != null) { format_tab_header_from_global_settings (); update_current_lang ();