summaryrefslogtreecommitdiff
path: root/Applications/FileManager
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-26 21:09:56 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-26 21:09:56 +0200
commit8f81a3f9dde15f4bf328c8864e6dcbf75a7090fe (patch)
tree8e0ef21fd86c0e55abb5ff85671e7e5cb9dcc2c8 /Applications/FileManager
parent9ff36afeaab7e583afd3de303bba5ded3b8a448e (diff)
downloadserenity-8f81a3f9dde15f4bf328c8864e6dcbf75a7090fe.zip
LibGUI+WindowServer: Make it possible to have checkable GActions.
They show up as checkable GButtons in GToolBar, and with (or without) check marks in menus. There are a bunch of places to make use of this. This patch only takes advantage of it in the FileManager for the view type actions.
Diffstat (limited to 'Applications/FileManager')
-rw-r--r--Applications/FileManager/main.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index d204017e6f..869556476d 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -98,13 +98,24 @@ int main(int argc, char** argv)
}
});
- auto view_as_table_action = GAction::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&] (const GAction&) {
+ RetainPtr<GAction> view_as_table_action;
+ RetainPtr<GAction> view_as_icons_action;
+
+ view_as_table_action = GAction::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&] (const GAction&) {
directory_view->set_view_mode(DirectoryView::ViewMode::List);
+ view_as_icons_action->set_checked(false);
+ view_as_table_action->set_checked(true);
});
+ view_as_table_action->set_checkable(true);
+ view_as_table_action->set_checked(false);
- auto view_as_icons_action = GAction::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&] (const GAction&) {
+ view_as_icons_action = GAction::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&] (const GAction&) {
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
+ view_as_table_action->set_checked(false);
+ view_as_icons_action->set_checked(true);
});
+ view_as_icons_action->set_checkable(true);
+ view_as_icons_action->set_checked(true);
auto copy_action = GAction::create("Copy", GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [] (const GAction&) {
dbgprintf("'Copy' action activated!\n");
@@ -138,8 +149,8 @@ int main(int argc, char** argv)
menubar->add_menu(move(file_menu));
auto view_menu = make<GMenu>("View");
- view_menu->add_action(view_as_table_action.copy_ref());
- view_menu->add_action(view_as_icons_action.copy_ref());
+ view_menu->add_action(*view_as_icons_action);
+ view_menu->add_action(*view_as_table_action);
menubar->add_menu(move(view_menu));
auto go_menu = make<GMenu>("Go");
@@ -165,8 +176,8 @@ int main(int argc, char** argv)
main_toolbar->add_action(delete_action.copy_ref());
main_toolbar->add_separator();
- main_toolbar->add_action(view_as_icons_action.copy_ref());
- main_toolbar->add_action(view_as_table_action.copy_ref());
+ main_toolbar->add_action(*view_as_icons_action);
+ main_toolbar->add_action(*view_as_table_action);
directory_view->on_path_change = [window, location_textbox, &file_system_model, tree_view] (const String& new_path) {
window->set_title(String::format("FileManager: %s", new_path.characters()));