From 247bda729127cdbf1643b03424b098abfbc1312e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 09:51:14 -0800 Subject: [PATCH 1/8] Put the ProjectChooserButton inside the sidebar --- src/MainWindow.vala | 4 ++-- src/Widgets/HeaderBar.vala | 12 ------------ src/Widgets/Sidebar.vala | 8 ++++++++ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index e986f28f6b..7cf54d1d72 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -271,7 +271,6 @@ namespace Scratch { break; } - sidebar.bind_property ("visible", toolbar.choose_project_revealer, "reveal-child"); // Show/Hide widgets show_all (); @@ -294,7 +293,7 @@ namespace Scratch { toolbar = new Scratch.Widgets.HeaderBar (); toolbar.title = title; - toolbar.choose_project_button.project_chosen.connect (() => { + sidebar.choose_project_button.project_chosen.connect (() => { folder_manager_view.collapse_other_projects (); }); @@ -449,6 +448,7 @@ namespace Scratch { title = doc.get_basename (); toolbar.set_document_focus (doc); + sidebar.choose_project_button.set_document (doc); folder_manager_view.select_path (doc.file.get_path ()); // Set actions sensitive property diff --git a/src/Widgets/HeaderBar.vala b/src/Widgets/HeaderBar.vala index 724b0fc38b..460227d946 100644 --- a/src/Widgets/HeaderBar.vala +++ b/src/Widgets/HeaderBar.vala @@ -27,8 +27,6 @@ namespace Scratch.Widgets { public Gtk.ToggleButton find_button; public Gtk.Button templates_button; public Code.FormatBar format_bar; - public Code.ChooseProjectButton choose_project_button; - public Gtk.Revealer choose_project_revealer; private const string STYLE_SCHEME_HIGH_CONTRAST = "classic"; private const string STYLE_SCHEME_LIGHT = "elementary-light"; @@ -44,14 +42,6 @@ namespace Scratch.Widgets { construct { var app_instance = (Scratch.Application) GLib.Application.get_default (); - choose_project_revealer = new Gtk.Revealer () { - transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT - }; - choose_project_button = new Code.ChooseProjectButton () { - valign = Gtk.Align.CENTER - }; - choose_project_revealer.add (choose_project_button); - var open_button = new Gtk.Button.from_icon_name ("document-open", Gtk.IconSize.LARGE_TOOLBAR); open_button.action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_OPEN; open_button.tooltip_markup = Granite.markup_accel_tooltip ( @@ -218,7 +208,6 @@ namespace Scratch.Widgets { }; set_custom_title (format_bar); - pack_start (choose_project_revealer); pack_start (open_button); pack_start (templates_button); pack_start (save_button); @@ -363,7 +352,6 @@ namespace Scratch.Widgets { public void set_document_focus (Scratch.Services.Document doc) { format_bar.set_document (doc); - choose_project_button.set_document (doc); } } } diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index f7fbfabf18..0bf18d0d53 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -19,11 +19,18 @@ public class Code.Sidebar : Gtk.Grid { public Gtk.Stack stack { get; private set; } + public Code.ChooseProjectButton choose_project_button { get; private set; } + private Gtk.StackSwitcher stack_switcher; + construct { orientation = Gtk.Orientation.VERTICAL; get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR); + choose_project_button = new Code.ChooseProjectButton () { + margin = 6 + }; + stack = new Gtk.Stack (); stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; @@ -63,6 +70,7 @@ public class Code.Sidebar : Gtk.Grid { actionbar.add (add_folder_button); actionbar.pack_end (project_more_button); + add (choose_project_button); add (stack_switcher); add (stack); add (actionbar); From 80efa0c6170c9febf0631d347ee97068ca270a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 10:06:24 -0800 Subject: [PATCH 2/8] Make sidebar pane the toplevel container --- src/MainWindow.vala | 19 +++++++++++++------ src/Widgets/Sidebar.vala | 11 +++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 7cf54d1d72..8d12b2548a 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -391,16 +391,23 @@ namespace Scratch { vp.pack1 (content_stack, true, false); vp.pack2 (bottombar, false, false); + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + box.add (toolbar); + box.add (vp); + hp1 = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); - hp1.position = 180; hp1.pack1 (sidebar, false, false); - hp1.pack2 (vp, true, false); + hp1.pack2 (box, true, false); + + add (hp1); - var grid = new Gtk.Grid (); - grid.attach (toolbar, 0, 0); - grid.attach (hp1, 0, 1); + var header_group = new Hdy.HeaderGroup (); + header_group.add_header_bar (sidebar.headerbar); + header_group.add_header_bar (toolbar); - add (grid); + var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.VERTICAL); + size_group.add_widget (sidebar.headerbar); + size_group.add_widget (toolbar); search_revealer.set_reveal_child (false); diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index 0bf18d0d53..3a23f5e506 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -20,6 +20,7 @@ public class Code.Sidebar : Gtk.Grid { public Gtk.Stack stack { get; private set; } public Code.ChooseProjectButton choose_project_button { get; private set; } + public Hdy.HeaderBar headerbar { get; private set; } private Gtk.StackSwitcher stack_switcher; @@ -28,9 +29,15 @@ public class Code.Sidebar : Gtk.Grid { get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR); choose_project_button = new Code.ChooseProjectButton () { - margin = 6 + valign = Gtk.Align.CENTER }; + headerbar = new Hdy.HeaderBar () { + custom_title = choose_project_button, + show_close_button = true + }; + headerbar.get_style_context ().add_class(Gtk.STYLE_CLASS_FLAT); + stack = new Gtk.Stack (); stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; @@ -70,7 +77,7 @@ public class Code.Sidebar : Gtk.Grid { actionbar.add (add_folder_button); actionbar.pack_end (project_more_button); - add (choose_project_button); + add (headerbar); add (stack_switcher); add (stack); add (actionbar); From c5a123d1104e4ce0edeff65fe0c91a2c28c29d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 10:11:28 -0800 Subject: [PATCH 3/8] lint --- src/Widgets/Sidebar.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index 3a23f5e506..5969fd97d0 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -36,7 +36,7 @@ public class Code.Sidebar : Gtk.Grid { custom_title = choose_project_button, show_close_button = true }; - headerbar.get_style_context ().add_class(Gtk.STYLE_CLASS_FLAT); + headerbar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); stack = new Gtk.Stack (); stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; From 81a62e29506f9ade627e11ca3b1efce73f69ab90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 11:50:16 -0800 Subject: [PATCH 4/8] Expand to fill --- src/Widgets/Sidebar.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index 5969fd97d0..41f07d216a 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -29,6 +29,7 @@ public class Code.Sidebar : Gtk.Grid { get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR); choose_project_button = new Code.ChooseProjectButton () { + hexpand = true, valign = Gtk.Align.CENTER }; From c217ece8013bb9d3a514b9fd0b9a15df482da016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 14:09:38 -0800 Subject: [PATCH 5/8] ChooseProjectButton: Remove minimum width --- src/Widgets/ChooseProjectButton.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Widgets/ChooseProjectButton.vala b/src/Widgets/ChooseProjectButton.vala index 62dfe3ee90..61490f0dce 100644 --- a/src/Widgets/ChooseProjectButton.vala +++ b/src/Widgets/ChooseProjectButton.vala @@ -31,7 +31,6 @@ public class Code.ChooseProjectButton : Gtk.MenuButton { }; label_widget = new Gtk.Label (_(NO_PROJECT_SELECTED)) { - width_chars = 24, ellipsize = Pango.EllipsizeMode.MIDDLE, max_width_chars = 24, xalign = 0.0f From f16e1e72ba95b83ab7e005d2cc3f6ee057f0fcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 14:11:07 -0800 Subject: [PATCH 6/8] ChooseProjectButton: Remove max width --- src/Widgets/ChooseProjectButton.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Widgets/ChooseProjectButton.vala b/src/Widgets/ChooseProjectButton.vala index 61490f0dce..cff6595cf4 100644 --- a/src/Widgets/ChooseProjectButton.vala +++ b/src/Widgets/ChooseProjectButton.vala @@ -32,7 +32,6 @@ public class Code.ChooseProjectButton : Gtk.MenuButton { label_widget = new Gtk.Label (_(NO_PROJECT_SELECTED)) { ellipsize = Pango.EllipsizeMode.MIDDLE, - max_width_chars = 24, xalign = 0.0f }; From 10c712349c56db19ba91156dd2e59044ff69676e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 12:44:38 -0800 Subject: [PATCH 7/8] HeaderBar: put find actions in menu --- data/icons/find-on-page-symbolic.svg | 15 ++++++++ data/io.elementary.code.gresource.xml | 1 + src/MainWindow.vala | 4 +-- src/Widgets/HeaderBar.vala | 52 ++++++++++++++++++++------- 4 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 data/icons/find-on-page-symbolic.svg diff --git a/data/icons/find-on-page-symbolic.svg b/data/icons/find-on-page-symbolic.svg new file mode 100644 index 0000000000..1760704d33 --- /dev/null +++ b/data/icons/find-on-page-symbolic.svg @@ -0,0 +1,15 @@ + + + + + diff --git a/data/io.elementary.code.gresource.xml b/data/io.elementary.code.gresource.xml index fbd48b25d0..92cb509d45 100644 --- a/data/io.elementary.code.gresource.xml +++ b/data/io.elementary.code.gresource.xml @@ -22,5 +22,6 @@ icons/SymbolOutline/virtualmethod.svg icons/SymbolOutline/virtualproperty.svg icons/SymbolOutline/plugin-outline-symbolic.svg + icons/find-on-page-symbolic.svg diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8d12b2548a..384585510f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -213,8 +213,8 @@ namespace Scratch { if (name == ACTION_SHOW_FIND) { if (new_state.get_boolean () == false) { toolbar.find_button.tooltip_markup = Granite.markup_accel_tooltip ( - app.get_accels_for_action (ACTION_PREFIX + ACTION_FIND), - _("Find…") + app.get_accels_for_action (ACTION_PREFIX + ACTION_FIND + "::"), + _("Find on Page…") ); } else { toolbar.find_button.tooltip_markup = Granite.markup_accel_tooltip ( diff --git a/src/Widgets/HeaderBar.vala b/src/Widgets/HeaderBar.vala index 460227d946..51a1038c51 100644 --- a/src/Widgets/HeaderBar.vala +++ b/src/Widgets/HeaderBar.vala @@ -24,10 +24,12 @@ namespace Scratch.Widgets { public Gtk.Menu share_menu; public Gtk.MenuButton share_app_menu; public Gtk.MenuButton app_menu; - public Gtk.ToggleButton find_button; public Gtk.Button templates_button; public Code.FormatBar format_bar; + public Gtk.Button search_button { get; private set; } + public Gtk.ToggleButton find_button { get; private set; } + private const string STYLE_SCHEME_HIGH_CONTRAST = "classic"; private const string STYLE_SCHEME_LIGHT = "elementary-light"; private const string STYLE_SCHEME_DARK = "elementary-dark"; @@ -74,14 +76,6 @@ namespace Scratch.Widgets { _("Restore this file") ); - find_button = new Gtk.ToggleButton (); - find_button.action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_SHOW_FIND; - find_button.image = new Gtk.Image.from_icon_name ("edit-find", Gtk.IconSize.LARGE_TOOLBAR); - find_button.tooltip_markup = Granite.markup_accel_tooltip ( - app_instance.get_accels_for_action (MainWindow.ACTION_PREFIX + MainWindow.ACTION_FIND), - _("Find…") - ); - share_menu = new Gtk.Menu (); share_app_menu = new Gtk.MenuButton (); share_app_menu.image = new Gtk.Image.from_icon_name ("document-export", Gtk.IconSize.LARGE_TOOLBAR); @@ -110,15 +104,48 @@ namespace Scratch.Widgets { _("Zoom In") ); - var font_size_grid = new Gtk.Grid (); + var font_size_grid = new Gtk.Grid () { + margin_top = 12, + margin_end = 12, + margin_bottom = 6, + margin_start = 12 + }; font_size_grid.column_homogeneous = true; font_size_grid.hexpand = true; - font_size_grid.margin = 12; font_size_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED); font_size_grid.add (zoom_out_button); font_size_grid.add (zoom_default_button); font_size_grid.add (zoom_in_button); + find_button = new Gtk.ToggleButton () { + action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_SHOW_FIND, + image = new Gtk.Image.from_icon_name ("edit-find-on-page-symbolic", Gtk.IconSize.MENU) + }; + find_button.tooltip_markup = Granite.markup_accel_tooltip ( + app_instance.get_accels_for_action (MainWindow.ACTION_PREFIX + MainWindow.ACTION_FIND + "::"), + _("Find on Page…") + ); + + search_button = new Gtk.Button.from_icon_name ("edit-find-symbolic", Gtk.IconSize.MENU) { + action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_FIND_GLOBAL, + action_target = new Variant.string ("") + }; + search_button.tooltip_markup = Granite.markup_accel_tooltip ( + app_instance.get_accels_for_action (search_button.action_name + "::"), + _("Find in Project…") + ); + + var find_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { + hexpand = true, + homogeneous = true, + margin_end = 12, + margin_bottom = 12, + margin_start = 12 + }; + find_box.get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED); + find_box.add (find_button); + find_box.add (search_button); + var follow_system_switchmodelbutton = new Granite.SwitchModelButton (_("Follow System Style")) { margin_top = 3 }; @@ -185,6 +212,7 @@ namespace Scratch.Widgets { width_request = 200 }; menu_box.add (font_size_grid); + menu_box.add (find_box); menu_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); menu_box.add (follow_system_switchmodelbutton); menu_box.add (color_revealer); @@ -216,8 +244,6 @@ namespace Scratch.Widgets { pack_start (revert_button); pack_end (app_menu); pack_end (share_app_menu); - pack_end (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); - pack_end (find_button); show_all (); From 2f18b41a086506fff2693c9899072b7c6e5a1c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 8 Jan 2023 12:49:38 -0800 Subject: [PATCH 8/8] Scope down search button --- src/Widgets/HeaderBar.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Widgets/HeaderBar.vala b/src/Widgets/HeaderBar.vala index 51a1038c51..b58c99cb0c 100644 --- a/src/Widgets/HeaderBar.vala +++ b/src/Widgets/HeaderBar.vala @@ -27,7 +27,6 @@ namespace Scratch.Widgets { public Gtk.Button templates_button; public Code.FormatBar format_bar; - public Gtk.Button search_button { get; private set; } public Gtk.ToggleButton find_button { get; private set; } private const string STYLE_SCHEME_HIGH_CONTRAST = "classic"; @@ -126,7 +125,7 @@ namespace Scratch.Widgets { _("Find on Page…") ); - search_button = new Gtk.Button.from_icon_name ("edit-find-symbolic", Gtk.IconSize.MENU) { + var search_button = new Gtk.Button.from_icon_name ("edit-find-symbolic", Gtk.IconSize.MENU) { action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_FIND_GLOBAL, action_target = new Variant.string ("") };