Skip to content

Commit

Permalink
Merge pull request #240 from gdt050579/miscelaneous-improvements
Browse files Browse the repository at this point in the history
Miscelaneous improvements
  • Loading branch information
rzaharia authored Mar 1, 2024
2 parents 4f9608f + 431765c commit 5bf822a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions GView/src/GView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ int main(int argc, const char** argv)
{
if (argc < 2)
{
ShowHelp();
return 0;
const char* openCurrentFolderCommand[] = { "."};
return ProcessOpenCommand(1, openCurrentFolderCommand, 0);
}

auto cmdID = GetCommandID(argv[1]);
Expand Down
16 changes: 16 additions & 0 deletions GViewCore/src/App/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ constexpr _MenuCommand_ menuFileList[] = {
{ "", 0, Key::None },
{ "E&xit", MenuCommands::EXIT_GVIEW, Key::Shift | Key::Escape },
};
constexpr ItemHandle menuFileDisabledCommandsList[] = { 3, 4 };

constexpr _MenuCommand_ menuWindowList[] = {
{ "Arrange &Vertically", MenuCommands::ARRANGE_VERTICALLY, Key::None },
{ "Arrange &Horizontally", MenuCommands::ARRANGE_HORIZONTALLY, Key::None },
Expand Down Expand Up @@ -129,6 +131,9 @@ bool Instance::BuildMainMenus()
{
CHECK(mnuFile = AppCUI::Application::AddMenu("File"), false, "Unable to create 'File' menu");
CHECK(AddMenuCommands(mnuFile, menuFileList, ARRAY_LEN(menuFileList)), false, "");
for (auto itemHandle : menuFileDisabledCommandsList) {
CHECK(mnuFile->SetEnable(itemHandle, false), false, "Fail to disable menu item");
}
CHECK(mnuWindow = AppCUI::Application::AddMenu("&Windows"), false, "Unable to create 'Windows' menu");
CHECK(AddMenuCommands(mnuWindow, menuWindowList, ARRAY_LEN(menuWindowList)), false, "");
CHECK(mnuHelp = AppCUI::Application::AddMenu("&Help"), false, "Unable to create 'Help' menu");
Expand Down Expand Up @@ -495,6 +500,14 @@ void Instance::OpenFile()
ShowErrors();
}
}
void Instance::OpenFolder()
{
auto res = Dialogs::FileDialog::ShowOpenFileWindow("", "GVIEW:IGNORE-EVERYTHING", ".");
if (res.has_value()) {
if (AddFileWindow(res.value(), OpenMethod::BestMatch, "") == false)
ShowErrors();
}
}
void Instance::UpdateCommandBar(AppCUI::Application::CommandBar& commandBar)
{
auto idx = GENERIC_PLUGINS_CMDID;
Expand Down Expand Up @@ -567,6 +580,9 @@ bool Instance::OnEvent(Reference<Control> control, Event eventType, int ID)
case MenuCommands::OPEN_FILE:
OpenFile();
return true;
case MenuCommands::OPEN_FOLDER:
OpenFolder();
return true;
}
if ((ID >= GENERIC_PLUGINS_CMDID) && (ID < GENERIC_PLUGINS_CMDID + GENERIC_PLUGINS_FRAME * 1000))
{
Expand Down
1 change: 1 addition & 0 deletions GViewCore/src/include/Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ namespace App
bool BuildMainMenus();
bool LoadSettings();
void OpenFile();
void OpenFolder();
void ShowErrors();

Reference<Type::Plugin> IdentifyTypePlugin_FirstMatch(
Expand Down

0 comments on commit 5bf822a

Please sign in to comment.