Browse Source

Added tooltips with file path to tabs

merge-requests/365/head
eidheim 10 years ago
parent
commit
31d54f0b3c
  1. 4
      src/directories.cc
  2. 15
      src/notebook.cc
  3. 2
      src/notebook.h

4
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;
}
}

15
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;c<size();c++) {
@ -174,8 +174,11 @@ void Notebook::open(const boost::filesystem::path &file_path) {
break;
}
}
if(page!=-1)
tab_labels.at(get_index(page))->label.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");

2
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;
};

Loading…
Cancel
Save