Compare commits
No commits in common. "96cd01bc77058d8e77532f9cb54633678d6a0ae8" and "0b287f755b524e660d09f6e7357a025331985932" have entirely different histories.
96cd01bc77
...
0b287f755b
8 changed files with 13 additions and 44 deletions
|
@ -8,7 +8,6 @@ raven_dep = dependency('raven')
|
|||
|
||||
executable(
|
||||
'filemanager',
|
||||
'./src/Dirs.cpp',
|
||||
'./src/FileButton.cpp',
|
||||
'./src/DirectoryView.cpp',
|
||||
'./src/TopBar.cpp',
|
||||
|
|
|
@ -14,13 +14,11 @@ void AppWidget::on_init() {
|
|||
|
||||
top_bar->on_action = [directory_view](TopBar::Action action) {
|
||||
if (action == TopBar::Action::Back) {
|
||||
directory_view->go_back();
|
||||
directory_view->back();
|
||||
} else if (action == TopBar::Action::Forward) {
|
||||
directory_view->go_forward();
|
||||
directory_view->forward();
|
||||
} else if (action == TopBar::Action::Home) {
|
||||
directory_view->navigate_home();
|
||||
} else if (action == TopBar::Action::ParentDirectory) {
|
||||
directory_view->navigate_parent_directory();
|
||||
directory_view->home();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "DirectoryView.hpp"
|
||||
#include "src/Dirs.hpp"
|
||||
#include "src/Forward.hpp"
|
||||
|
||||
DirectoryView::~DirectoryView() {}
|
||||
|
@ -34,22 +33,18 @@ void DirectoryView::on_init() {
|
|||
|
||||
m_target = make_target();
|
||||
m_target->set_layout<Raven::DocumentLayout>(12.0);
|
||||
navigate_home();
|
||||
navigate("/");
|
||||
set_did_init(true);
|
||||
}
|
||||
|
||||
void DirectoryView::go_back() {
|
||||
void DirectoryView::back() {
|
||||
m_checkpoint_stack.undo();
|
||||
}
|
||||
|
||||
void DirectoryView::go_forward() {
|
||||
void DirectoryView::forward() {
|
||||
m_checkpoint_stack.redo();
|
||||
}
|
||||
|
||||
void DirectoryView::navigate_home() {
|
||||
navigate(get_home_directory());
|
||||
}
|
||||
|
||||
void DirectoryView::navigate_parent_directory() {
|
||||
navigate(m_current_path.parent_path());
|
||||
void DirectoryView::home() {
|
||||
std::cerr << "home(): not implemented" << std::endl;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,9 @@ public:
|
|||
|
||||
void navigate(std::string path);
|
||||
void navigate_relative(std::string path);
|
||||
void go_back();
|
||||
void go_forward();
|
||||
void navigate_home();
|
||||
void navigate_parent_directory();
|
||||
void back();
|
||||
void forward();
|
||||
void home();
|
||||
protected:
|
||||
void set_current_path(std::filesystem::path path);
|
||||
|
||||
|
|
11
src/Dirs.cpp
11
src/Dirs.cpp
|
@ -1,11 +0,0 @@
|
|||
#include "Dirs.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
std::filesystem::path get_home_directory() {
|
||||
auto home_env = std::getenv("HOME");
|
||||
if (!home_env || !std::filesystem::exists(home_env)) {
|
||||
return "/";
|
||||
}
|
||||
return home_env;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
std::filesystem::path get_home_directory();
|
|
@ -9,7 +9,7 @@ void TopBar::on_init() {
|
|||
set_style(&Raven::accent_widget_style);
|
||||
|
||||
auto layout = set_layout<Raven::BoxLayout>(Raven::Direction::Horizontal);
|
||||
layout->slot_pixel(24, 4);
|
||||
layout->slot_pixel(24, 3);
|
||||
layout->set_margin(4);
|
||||
layout->set_spacing(8);
|
||||
|
||||
|
@ -17,8 +17,6 @@ void TopBar::on_init() {
|
|||
back_button->set_style(&Raven::default_button_style);
|
||||
auto forward_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/next.svg");
|
||||
forward_button->set_style(&Raven::default_button_style);
|
||||
auto parent_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/up.svg");
|
||||
parent_button->set_style(&Raven::default_button_style);
|
||||
auto home_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/go-home.svg");
|
||||
home_button->set_style(&Raven::default_button_style);
|
||||
|
||||
|
@ -31,9 +29,6 @@ void TopBar::on_init() {
|
|||
home_button->on_click = [this]() {
|
||||
on_action(Action::Home);
|
||||
};
|
||||
parent_button->on_click = [this]() {
|
||||
on_action(Action::ParentDirectory);
|
||||
};
|
||||
|
||||
set_did_init(true);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ public:
|
|||
enum class Action {
|
||||
Back = 0,
|
||||
Forward,
|
||||
Home,
|
||||
ParentDirectory
|
||||
Home
|
||||
};
|
||||
public:
|
||||
TopBar()
|
||||
|
|
Loading…
Reference in a new issue