diff --git a/data/icons/panel-bottom-symbolic.svg b/data/icons/panel-bottom-symbolic.svg new file mode 100644 index 0000000000..7362d82bd3 --- /dev/null +++ b/data/icons/panel-bottom-symbolic.svg @@ -0,0 +1,16 @@ + + diff --git a/data/icons/panel-left-rtl-symbolic.svg b/data/icons/panel-left-rtl-symbolic.svg new file mode 100644 index 0000000000..18e7a4cfdf --- /dev/null +++ b/data/icons/panel-left-rtl-symbolic.svg @@ -0,0 +1,16 @@ + + diff --git a/data/icons/panel-left-symbolic.svg b/data/icons/panel-left-symbolic.svg new file mode 100644 index 0000000000..11dfe83236 --- /dev/null +++ b/data/icons/panel-left-symbolic.svg @@ -0,0 +1,16 @@ + + diff --git a/data/icons/panel-right-rtl-symbolic.svg b/data/icons/panel-right-rtl-symbolic.svg new file mode 100644 index 0000000000..f11aaae9a0 --- /dev/null +++ b/data/icons/panel-right-rtl-symbolic.svg @@ -0,0 +1,16 @@ + + diff --git a/data/icons/panel-right-symbolic.svg b/data/icons/panel-right-symbolic.svg new file mode 100644 index 0000000000..ac8d3d62c3 --- /dev/null +++ b/data/icons/panel-right-symbolic.svg @@ -0,0 +1,16 @@ + + diff --git a/data/io.elementary.code.gresource.xml b/data/io.elementary.code.gresource.xml index 92cb509d45..ff90ecb696 100644 --- a/data/io.elementary.code.gresource.xml +++ b/data/io.elementary.code.gresource.xml @@ -23,5 +23,10 @@ icons/SymbolOutline/virtualproperty.svg icons/SymbolOutline/plugin-outline-symbolic.svg icons/find-on-page-symbolic.svg + icons/panel-bottom-symbolic.svg + icons/panel-left-rtl-symbolic.svg + icons/panel-left-symbolic.svg + icons/panel-right-rtl-symbolic.svg + icons/panel-right-symbolic.svg diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 31f451eff5..2c0f378308 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -131,8 +131,8 @@ namespace Scratch { { ACTION_ZOOM_IN, action_zoom_in }, { ACTION_ZOOM_OUT, action_zoom_out}, { ACTION_TOGGLE_COMMENT, action_toggle_comment }, - { ACTION_TOGGLE_SIDEBAR, action_toggle_sidebar }, - { ACTION_TOGGLE_OUTLINE, action_toggle_outline }, + { ACTION_TOGGLE_SIDEBAR, action_toggle_sidebar, null, "true" }, + { ACTION_TOGGLE_OUTLINE, action_toggle_outline, null, "false" }, { ACTION_NEXT_TAB, action_next_tab }, { ACTION_PREVIOUS_TAB, action_previous_tab }, { ACTION_CLEAR_LINES, action_clear_lines }, @@ -209,24 +209,6 @@ namespace Scratch { actions.add_action_entries (ACTION_ENTRIES, this); insert_action_group (ACTION_GROUP, actions); - actions.action_state_changed.connect ((name, new_state) => { - 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 on Page…") - ); - } else { - toolbar.find_button.tooltip_markup = Granite.markup_accel_tooltip ( - {"Escape"}, - _("Hide search bar") - ); - } - - search_revealer.set_reveal_child (new_state.get_boolean ()); - } - }); - foreach (var action in action_accelerators.get_keys ()) { var accels_array = action_accelerators[action].to_array (); accels_array += null; @@ -285,10 +267,71 @@ namespace Scratch { // Create folder for unsaved documents create_unsaved_documents_directory (); + actions.action_state_changed.connect ((name, new_state) => { + update_toolbar_button (name, new_state.get_boolean ()); + }); + + var sidebar_action = Utils.action_from_group (ACTION_TOGGLE_SIDEBAR, actions); + sidebar_action.set_state (saved_state.get_boolean ("sidebar-visible")); + update_toolbar_button (ACTION_TOGGLE_SIDEBAR, saved_state.get_boolean ("sidebar-visible")); + + var outline_action = Utils.action_from_group (ACTION_TOGGLE_OUTLINE, actions); + outline_action.set_state (saved_state.get_boolean ("outline-visible")); + update_toolbar_button (ACTION_TOGGLE_OUTLINE, saved_state.get_boolean ("outline-visible")); + Unix.signal_add (Posix.Signal.INT, quit_source_func, Priority.HIGH); Unix.signal_add (Posix.Signal.TERM, quit_source_func, Priority.HIGH); } + private void update_toolbar_button (string name, bool new_state) { + switch (name) { + case ACTION_SHOW_FIND: + if (new_state) { + toolbar.find_button.tooltip_markup = Granite.markup_accel_tooltip ( + {"Escape"}, + _("Hide search bar") + ); + } else { + toolbar.find_button.tooltip_markup = Granite.markup_accel_tooltip ( + app.get_accels_for_action (ACTION_PREFIX + name), + _("Find on Page…") + ); + } + + search_revealer.set_reveal_child (new_state); + + break; + case ACTION_TOGGLE_SIDEBAR: + if (new_state) { + toolbar.sidebar_button.tooltip_markup = Granite.markup_accel_tooltip ( + app.get_accels_for_action (ACTION_PREFIX + name), + _("Hide Projects Sidebar") + ); + } else { + toolbar.sidebar_button.tooltip_markup = Granite.markup_accel_tooltip ( + app.get_accels_for_action (ACTION_PREFIX + name), + _("Show Projects Sidebar") + ); + } + + break; + case ACTION_TOGGLE_OUTLINE: + if (new_state) { + toolbar.outline_button.tooltip_markup = Granite.markup_accel_tooltip ( + app.get_accels_for_action (ACTION_PREFIX + name), + _("Hide Symbol Outline") + ); + } else { + toolbar.outline_button.tooltip_markup = Granite.markup_accel_tooltip ( + app.get_accels_for_action (ACTION_PREFIX + name), + _("Show Symbol Outline") + ); + } + + break; + }; + } + private void init_layout () { toolbar = new Scratch.Widgets.HeaderBar (); toolbar.title = title; @@ -1058,16 +1101,18 @@ namespace Scratch { doc.source_view.sort_selected_lines (); } - private void action_toggle_sidebar () { + private void action_toggle_sidebar (SimpleAction action) { if (sidebar == null) { return; } - sidebar.visible = !sidebar.visible; + action.set_state (!action.get_state ().get_boolean ()); + sidebar.visible = action.get_state ().get_boolean (); } - private void action_toggle_outline () { - document_view.outline_visible = !document_view.outline_visible; + private void action_toggle_outline (SimpleAction action) { + action.set_state (!action.get_state ().get_boolean ()); + document_view.outline_visible = action.get_state ().get_boolean (); } private void action_next_tab () { diff --git a/src/Widgets/HeaderBar.vala b/src/Widgets/HeaderBar.vala index b58c99cb0c..444663efb9 100644 --- a/src/Widgets/HeaderBar.vala +++ b/src/Widgets/HeaderBar.vala @@ -28,6 +28,8 @@ namespace Scratch.Widgets { public Code.FormatBar format_bar; public Gtk.ToggleButton find_button { get; private set; } + public Gtk.ToggleButton outline_button { get; private set; } + public Gtk.ToggleButton sidebar_button { get; private set; } private const string STYLE_SCHEME_HIGH_CONTRAST = "classic"; private const string STYLE_SCHEME_LIGHT = "elementary-light"; @@ -182,25 +184,26 @@ namespace Scratch.Widgets { margin_top = 3 }; - var toggle_sidebar_accellabel = new Granite.AccelLabel.from_action_name ( - _("Toggle Sidebar"), - MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_SIDEBAR - ); - - var toggle_sidebar_menuitem = new Gtk.ModelButton (); - toggle_sidebar_menuitem.action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_SIDEBAR; - toggle_sidebar_menuitem.get_child ().destroy (); - toggle_sidebar_menuitem.add (toggle_sidebar_accellabel); + sidebar_button = new Gtk.ToggleButton () { + action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_SIDEBAR, + image = new Gtk.Image.from_icon_name ("panel-left-symbolic", Gtk.IconSize.MENU) + }; - var toggle_outline_accellabel = new Granite.AccelLabel.from_action_name ( - _("Toggle Symbol Outline"), - MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_OUTLINE - ); + outline_button = new Gtk.ToggleButton () { + action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_OUTLINE, + image = new Gtk.Image.from_icon_name ("panel-right-symbolic", Gtk.IconSize.MENU) + }; - var toggle_outline_menuitem = new Gtk.ModelButton (); - toggle_outline_menuitem.action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_OUTLINE; - toggle_outline_menuitem.get_child ().destroy (); - toggle_outline_menuitem.add (toggle_outline_accellabel); + var panels_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { + homogeneous = true, + margin_top = 6, + margin_end = 12, + margin_bottom = 6, + margin_start = 12 + }; + panels_box.get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED); + panels_box.add (sidebar_button); + panels_box.add (outline_button); var preferences_menuitem = new Gtk.ModelButton (); preferences_menuitem.text = _("Preferences"); @@ -215,9 +218,8 @@ namespace Scratch.Widgets { menu_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); menu_box.add (follow_system_switchmodelbutton); menu_box.add (color_revealer); + menu_box.add (panels_box); menu_box.add (menu_separator); - menu_box.add (toggle_sidebar_menuitem); - menu_box.add (toggle_outline_menuitem); menu_box.add (preferences_menuitem); menu_box.show_all ();