Browse Source

set main window title based on open directory in tree view

merge-requests/413/head
Jørgen Lien Sellæg 3 years ago
parent
commit
73977fa1ad
  1. 2
      src/directories.cpp
  2. 11
      src/window.cpp
  3. 2
      src/window.hpp

2
src/directories.cpp

@ -5,6 +5,7 @@
#include "source.hpp"
#include "terminal.hpp"
#include "utility.hpp"
#include "window.hpp"
#include <algorithm>
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);

11
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();

2
src/window.hpp

@ -15,6 +15,7 @@ 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);
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();

Loading…
Cancel
Save