diff --git a/src/directories.cpp b/src/directories.cpp index 852dc3b..14c0a87 100644 --- a/src/directories.cpp +++ b/src/directories.cpp @@ -5,6 +5,7 @@ #include "source.hpp" #include "terminal.hpp" #include "utility.hpp" +#include "window.hpp" #include bool Directories::TreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path &path, const Gtk::SelectionData &selection_data) const { @@ -433,6 +434,7 @@ 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); diff --git a/src/window.cpp b/src/window.cpp index 7a99871..98f3466 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -170,7 +170,16 @@ Window::Window() { about.set_comments("This is an open source IDE with high-end features to make your programming experience juicy"); about.set_license_type(Gtk::License::LICENSE_MIT_X11); about.set_transient_for(*this); -} // Window constructor +} + +/// 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::configure() { Config::get().load(); diff --git a/src/window.hpp b/src/window.hpp index 88de5b0..a712375 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -15,6 +15,7 @@ public: void add_widgets(); void save_session(); void load_session(std::vector &directories, std::vector> &files, std::vector> &file_offsets, boost::filesystem::path ¤t_file, bool read_directories_and_files); + void set_title(const boost::filesystem::path &p); protected: bool on_key_press_event(GdkEventKey *event) override; @@ -24,7 +25,6 @@ private: Gtk::AboutDialog about; Gtk::ScrolledWindow directories_scrolled_window, terminal_scrolled_window; Gtk::Overlay status_overlay; - void configure(); void set_menu_actions(); void search_and_replace_entry();