From 31d54f0b3c0d74f16c5fd52c8ac8f92dddcfa0b9 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 31 Mar 2016 11:54:47 +0200 Subject: [PATCH] Added tooltips with file path to tabs --- src/directories.cc | 4 +++- src/notebook.cc | 15 +++++++++------ src/notebook.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/directories.cc b/src/directories.cc index c73c004..5898c4c 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -95,10 +95,12 @@ bool Directories::TreeStore::drag_data_received_vfunc(const TreeModel::Path &pat for(;file_it!=view->file_path.end();file_it++) new_file_path/=*file_it; view->file_path=new_file_path; + g_signal_emit_by_name(view->get_buffer()->gobj(), "modified_changed"); } } - if(view->file_path==source_path) { + else if(view->file_path==source_path) { view->file_path=target_path; + g_signal_emit_by_name(view->get_buffer()->gobj(), "modified_changed"); break; } } diff --git a/src/notebook.cc b/src/notebook.cc index 9a43194..8c68a83 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -25,9 +25,10 @@ namespace sigc { #endif } -Notebook::TabLabel::TabLabel(const std::string &title) : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) { +Notebook::TabLabel::TabLabel(const boost::filesystem::path &path) : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) { set_can_focus(false); - label.set_text(title+' '); + set_tooltip_text(path.string()); + label.set_text(path.filename().string()+' '); label.set_can_focus(false); button.set_image_from_icon_name("window-close-symbolic", Gtk::ICON_SIZE_MENU); button.set_can_focus(false); @@ -135,8 +136,7 @@ void Notebook::open(const boost::filesystem::path &file_path) { configure(source_views.size()-1); //Set up tab label - std::string title=file_path.filename().string(); - tab_labels.emplace_back(new TabLabel(title)); + tab_labels.emplace_back(new TabLabel(file_path)); auto source_view=source_views.back(); tab_labels.back()->button.signal_clicked().connect([this, source_view](){ for(int c=0;clabel.set_text(title); + if(page!=-1) { + auto &tab_label=tab_labels.at(get_index(page)); + tab_label->label.set_text(title); + tab_label->set_tooltip_text(source_view->file_path.string()); + } }); JDEBUG("end"); diff --git a/src/notebook.h b/src/notebook.h index 6bb3127..db38ee6 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -12,7 +12,7 @@ class Notebook : public Gtk::Notebook { class TabLabel : public Gtk::Box { public: - TabLabel(const std::string &title); + TabLabel(const boost::filesystem::path &path); Gtk::Label label; Gtk::Button button; };