Browse Source

WIP

notebook_tab
Jørgen Lien Sellæg 8 years ago committed by Jørgen Lien Sellæg
parent
commit
a5b2f75bab
  1. 10
      src/directories.cc
  2. 13
      src/notebook.cc
  3. 4
      src/notebook.h
  4. 2
      src/source_base.cc

10
src/directories.cc

@ -69,7 +69,7 @@ bool Directories::TreeStore::drag_data_received_vfunc(const TreeModel::Path &pat
Terminal::get().print("Error: could not move file: " + ec.message() + '\n', true);
return false;
}
auto new_file_path = target_path;
for(size_t c = 0; c < Notebook::get().size(); c++) {
auto view = Notebook::get().get_view(c);
if(is_directory) {
@ -77,7 +77,6 @@ bool Directories::TreeStore::drag_data_received_vfunc(const TreeModel::Path &pat
auto file_it = view->file_path.begin();
for(auto source_it = source_path.begin(); source_it != source_path.end(); source_it++)
file_it++;
auto new_file_path = target_path;
for(; file_it != view->file_path.end(); file_it++)
new_file_path /= *file_it;
view->rename(new_file_path);
@ -88,7 +87,7 @@ bool Directories::TreeStore::drag_data_received_vfunc(const TreeModel::Path &pat
break;
}
}
Notebook::get().update_labels(new_file_path);
Directories::get().update();
Directories::get().on_save_file(target_path);
directories.select(target_path);
@ -262,7 +261,7 @@ Directories::Directories() : Gtk::ListViewText(1) {
update();
on_save_file(target_path);
select(target_path);
auto new_file_path = target_path;
for(size_t c = 0; c < Notebook::get().size(); c++) {
auto view = Notebook::get().get_view(c);
if(is_directory) {
@ -270,7 +269,6 @@ Directories::Directories() : Gtk::ListViewText(1) {
auto file_it = view->file_path.begin();
for(auto source_it = source_path.begin(); source_it != source_path.end(); source_it++)
file_it++;
auto new_file_path = target_path;
for(; file_it != view->file_path.end(); file_it++)
new_file_path /= *file_it;
view->rename(new_file_path);
@ -290,7 +288,7 @@ Directories::Directories() : Gtk::ListViewText(1) {
Terminal::get().print("Warning: language for " + target_path.string() + " has changed. Please reopen the file\n");
}
}
Notebook::get().update_labels(new_file_path);
EntryBox::get().hide();
});

13
src/notebook.cc

@ -270,7 +270,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
if(index != static_cast<size_t>(-1))
close(index);
}));
source_view->update_tab_label = [this](Source::BaseView *view) {
update_tab_label = [this](Source::BaseView *view) {
std::string title = view->file_path.filename().string();
if(view->get_buffer()->get_modified())
title += '*';
@ -285,12 +285,11 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
}
}
};
source_view->update_tab_label(source_view);
//Add star on tab label when the page is not saved:
source_view->get_buffer()->signal_modified_changed().connect([source_view]() {
if(source_view->update_tab_label)
source_view->update_tab_label(source_view);
update_tab_label(source_view);
source_view->get_buffer()->signal_modified_changed().connect([this, source_view]() {
if(update_tab_label) {
update_tab_label(source_view);
}
});
//Cursor history

4
src/notebook.h

@ -55,11 +55,15 @@ public:
Gtk::Label status_diagnostics;
Gtk::Label status_state;
void update_status(Source::BaseView *view);
void update_labels(const boost::filesystem::path &path);
void clear_status();
std::function<void(Source::View *)> on_change_page;
std::function<void(Source::View *)> on_close_page;
std::function<void(Source::BaseView *view)> update_tab_label;
std::function<void(Source::BaseView *view)> update_modified;
/// Cursor history
std::vector<CursorLocation> cursor_locations;
size_t current_cursor_location = -1;

2
src/source_base.cc

@ -214,8 +214,6 @@ void Source::BaseView::rename(const boost::filesystem::path &path) {
if(update_status_file_path)
update_status_file_path(this);
if(update_tab_label)
update_tab_label(this);
}
void Source::BaseView::monitor_file() {

Loading…
Cancel
Save