diff --git a/data/io.elementary.code.gschema.xml b/data/io.elementary.code.gschema.xml index fe8db64eb..eee8b9788 100644 --- a/data/io.elementary.code.gschema.xml +++ b/data/io.elementary.code.gschema.xml @@ -47,6 +47,11 @@ Symbol outline visibility Whether or not the symbol outline is visible + + 160 + Symbol outline width + Width of the symbol outline sidebar + '' Last opened path diff --git a/src/Services/Document.vala b/src/Services/Document.vala index 9a60406ca..07db0501b 100644 --- a/src/Services/Document.vala +++ b/src/Services/Document.vala @@ -116,6 +116,12 @@ namespace Scratch.Services { public Gtk.Stack main_stack; public Scratch.Widgets.SourceView source_view; private Scratch.Services.SymbolOutline? outline = null; + private Scratch.Widgets.DocumentView doc_view { + get { + return ((MainWindow) get_toplevel ()).document_view; + } + } + public string original_content = ""; private string last_save_content = ""; public bool saved = true; @@ -1150,16 +1156,34 @@ namespace Scratch.Services { if (outline != null) { outline_widget_pane.pack2 (outline.get_widget (), false, false); - var position = int.max (outline_widget_pane.get_allocated_width () * 4 / 5, 100); - outline_widget_pane.set_position (position); - outline.parse_symbols (); + Idle.add (() => { + set_outline_width (doc_view.outline_width); + outline_widget_pane.notify["position"].connect (sync_outline_width); + outline.parse_symbols (); + return Source.REMOVE; + }); } } else if (!show && outline != null) { + outline_widget_pane.notify["position"].disconnect (sync_outline_width); outline_widget_pane.get_child2 ().destroy (); outline = null; } } + private void sync_outline_width () { + var width = outline_widget_pane.get_allocated_width () - outline_widget_pane.position; + if (width != doc_view.outline_width) { + doc_view.outline_width = width; + } + } + + public void set_outline_width (int width) { + if (outline != null) { + var aw = outline_widget_pane.get_allocated_width (); + outline_widget_pane.position = (aw - width); + } + } + private void unmounted_cb () { warning ("Folder containing the file was unmounted"); mounted = false; diff --git a/src/Widgets/DocumentView.vala b/src/Widgets/DocumentView.vala index 6f29fac35..2077b3f88 100644 --- a/src/Widgets/DocumentView.vala +++ b/src/Widgets/DocumentView.vala @@ -41,6 +41,7 @@ public class Scratch.Widgets.DocumentView : Granite.Widgets.DynamicNotebook { public bool is_closing = false; public bool outline_visible { get; set; default = false; } + public int outline_width { get; set; } private Gtk.CssProvider style_provider; @@ -108,7 +109,12 @@ public class Scratch.Widgets.DocumentView : Granite.Widgets.DynamicNotebook { granite_settings.notify["prefers-color-scheme"].connect (update_inline_tab_colors); notify["outline-visible"].connect (update_outline_visible); - + Scratch.saved_state.bind ("outline-width", this, "outline-width", DEFAULT); + this.notify["outline-width"].connect (() => { + foreach (var doc in docs) { + doc.set_outline_width (outline_width); + } + }); // Handle Drag-and-drop of files onto add-tab button to create document Gtk.TargetEntry uris = {"text/uri-list", 0, TargetType.URI_LIST}; Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, {uris}, Gdk.DragAction.COPY);