Browse Source

Cleanup and corrections to Window::set_title() and its usages: title is now correctly set when opening juCi++ for the first time, and when closing a folder

merge-requests/413/head
eidheim 3 years ago
parent
commit
7ae617d264
  1. 3
      src/directories.cpp
  2. 12
      src/window.cpp
  3. 3
      src/window.hpp

3
src/directories.cpp

@ -426,6 +426,7 @@ void Directories::open(const boost::filesystem::path &dir_path) {
pos += 2;
}
get_column(0)->set_title(title);
Window::get().set_title(path);
for(auto &directory : directories) {
if(directory.second.repository)
@ -434,7 +435,6 @@ void Directories::open(const boost::filesystem::path &dir_path) {
directories.clear();
add_or_update_path(path, Gtk::TreeModel::Row(), true);
Window::get().set_title(path);
if(auto view = Notebook::get().get_current_view())
view->update_status_file_path(view);
@ -447,6 +447,7 @@ void Directories::close(const boost::filesystem::path &dir_path) {
tree_store->clear();
path.clear();
get_column(0)->set_title("");
Window::get().set_title();
}
else
remove_path(dir_path);

12
src/window.cpp

@ -23,7 +23,7 @@
Window::Window() {
Gsv::init();
set_title("juCi++");
set_title();
get_style_context()->add_class("juci_window");
set_events(Gdk::POINTER_MOTION_MASK | Gdk::FOCUS_CHANGE_MASK | Gdk::SCROLL_MASK | Gdk::LEAVE_NOTIFY_MASK);
@ -172,13 +172,9 @@ Window::Window() {
about.set_transient_for(*this);
}
/// Sets the title to the filename part of the path passed
void Window::set_title(const boost::filesystem::path &p) {
const auto tmp = p.filename();
if(tmp.empty()) {
return ApplicationWindow::set_title("juCi++");
}
ApplicationWindow::set_title(tmp.string() + " – juCi++");
void Window::set_title(const boost::filesystem::path &path) {
const auto filename = path.filename();
ApplicationWindow::set_title(filename.empty() ? "juCi++" : filename.string() + " – juCi++");
}
void Window::configure() {

3
src/window.hpp

@ -15,7 +15,8 @@ public:
void add_widgets();
void save_session();
void load_session(std::vector<boost::filesystem::path> &directories, std::vector<std::pair<boost::filesystem::path, size_t>> &files, std::vector<std::pair<int, int>> &file_offsets, boost::filesystem::path &current_file, bool read_directories_and_files);
void set_title(const boost::filesystem::path &p);
/// Sets the title to the filename part of the path passed
void set_title(const boost::filesystem::path &path = {});
protected:
bool on_key_press_event(GdkEventKey *event) override;

Loading…
Cancel
Save