Browse Source

File path in status bar is now relative to opened folder if file is within this folder

pipelines/353213535
eidheim 4 years ago
parent
commit
7f62bd6802
  1. 6
      src/directories.cpp
  2. 9
      src/notebook.cpp

6
src/directories.cpp

@ -538,6 +538,9 @@ void Directories::open(const boost::filesystem::path &dir_path) {
directories.clear(); directories.clear();
add_or_update_path(path, Gtk::TreeModel::Row(), true); add_or_update_path(path, Gtk::TreeModel::Row(), true);
if(auto view = Notebook::get().get_current_view())
view->update_status_file_path(view);
} }
void Directories::close(const boost::filesystem::path &dir_path) { void Directories::close(const boost::filesystem::path &dir_path) {
@ -550,6 +553,9 @@ void Directories::close(const boost::filesystem::path &dir_path) {
} }
else else
remove_path(dir_path); remove_path(dir_path);
if(auto view = Notebook::get().get_current_view())
view->update_status_file_path(view);
} }
void Directories::update() { void Directories::update() {

9
src/notebook.cpp

@ -1,6 +1,7 @@
#include "notebook.hpp" #include "notebook.hpp"
#include "config.hpp" #include "config.hpp"
#include "dialog.hpp" #include "dialog.hpp"
#include "directories.hpp"
#include "filesystem.hpp" #include "filesystem.hpp"
#include "project.hpp" #include "project.hpp"
#include "selection_dialog.hpp" #include "selection_dialog.hpp"
@ -368,8 +369,12 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position
} }
}; };
view->update_status_file_path = [this](Source::BaseView *view) { view->update_status_file_path = [this](Source::BaseView *view) {
if(get_current_view() == view) if(get_current_view() == view) {
status_file_path.set_text(' ' + filesystem::get_short_path(view->file_path).string()); if(!Directories::get().path.empty() && filesystem::file_in_path(view->file_path, Directories::get().path))
status_file_path.set_text(' ' + filesystem::get_relative_path(view->file_path, Directories::get().path).string());
else
status_file_path.set_text(' ' + filesystem::get_short_path(view->file_path).string());
}
}; };
view->update_status_branch = [this](Source::BaseView *view) { view->update_status_branch = [this](Source::BaseView *view) {
if(get_current_view() == view) { if(get_current_view() == view) {

Loading…
Cancel
Save