Browse Source

Fixed marking of changed tabs that are not saved.

merge-requests/365/head
eidheim 11 years ago
parent
commit
a10a0dc3c0
  1. 7
      juci/notebook.cc
  2. 22
      juci/source.cc
  3. 1
      juci/source.h

7
juci/notebook.cc

@ -301,18 +301,16 @@ Gtk::Box& Notebook::Controller::entry_view() {
void Notebook::Controller::OnNewPage(std::string name) {
INFO("Notebook Generate new page");
OnCreatePage();
text_vec_.back()->on_new_empty_file();
Notebook().append_page(*editor_vec_.back(), name);
Notebook().show_all_children();
Notebook().set_current_page(Pages()-1);
Notebook().set_focus_child(text_vec_.at(Pages()-1)->view);
text_vec_.back()->on_new_empty_file();
}
void Notebook::Controller::OnOpenFile(std::string path) {
INFO("Notebook open file");
OnCreatePage();
text_vec_.back()->on_open_file(path);
size_t pos = path.find_last_of("/\\");
std::string filename=path;
if(pos!=std::string::npos)
@ -321,6 +319,7 @@ void Notebook::Controller::OnOpenFile(std::string path) {
Notebook().show_all_children();
Notebook().set_current_page(Pages()-1);
Notebook().set_focus_child(text_vec_.back()->view);
text_vec_.back()->on_open_file(path);
}
void Notebook::Controller::OnCreatePage() {
@ -339,7 +338,7 @@ void Notebook::Controller::OnCreatePage() {
std::string filename=path;
if(pos!=std::string::npos)
filename=path.substr(pos+1);
Notebook().set_tab_label_text(*Notebook().get_nth_page(CurrentPage()), filename+"*");
Notebook().set_tab_label_text(*(Notebook().get_nth_page(CurrentPage())), filename+"*");
}
};
}

22
juci/source.cc

@ -183,7 +183,7 @@ highlight_token(clang::Token *token,
// Constructor for Controller
Source::Controller::Controller(const Source::Config &config,
const std::vector<std::unique_ptr<Source::Controller> > &controllers) :
config(config), parser(controllers), parse_thread_go(false), parse_thread_mapped(false), parse_thread_stop(false) {
config(config), parser(controllers), parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) {
INFO("Source Controller with childs constructed");
view.signal_key_press_event().connect(sigc::mem_fun(*this, &Source::Controller::on_key_press), false);
view.set_smart_home_end(Gsv::SMART_HOME_END_BEFORE);
@ -194,13 +194,6 @@ Source::Controller::Controller(const Source::Config &config,
for (auto &item : config.tags) {
buffer()->create_tag(item.first)->property_foreground() = item.second;
}
buffer()->signal_changed().connect([this]() {
if(signal_buffer_changed)
signal_buffer_changed(is_saved);
is_saved=false;
parse_thread_mapped=false;
parse_thread_go=true;
});
}
Source::Controller::~Controller() {
@ -238,12 +231,23 @@ void Source::Controller::update_syntax(const std::vector<Source::Range> &ranges)
}
}
void Source::Controller::set_handlers() {
buffer()->signal_changed().connect([this]() {
if(signal_buffer_changed)
signal_buffer_changed(is_saved);
is_saved=false;
parse_thread_mapped=false;
parse_thread_go=true;
});
}
void Source::Controller::on_new_empty_file() {
string filename("/tmp/untitled");
sourcefile s(filename);
parser.file_path=filename;
parser.project_path=filename;
s.save("");
set_handlers();
}
void Source::Controller::on_open_file(const string &filepath) {
@ -253,8 +257,8 @@ void Source::Controller::on_open_file(const string &filepath) {
buffer_map[filepath] = s.get_content();
buffer()->get_undo_manager()->begin_not_undoable_action();
buffer()->set_text(s.get_content());
is_saved=true;
buffer()->get_undo_manager()->end_not_undoable_action();
set_handlers();
int start_offset = buffer()->begin().get_offset();
int end_offset = buffer()->end().get_offset();
if (config.legal_extension(filepath.substr(filepath.find_last_of(".") + 1))) {

1
juci/source.h

@ -107,6 +107,7 @@ namespace Source {
const std::vector<std::unique_ptr<Source::Controller> > &controllers);
~Controller();
void update_syntax(const std::vector<Range> &locations);
void set_handlers();
void on_new_empty_file();
void on_open_file(const std::string &filename);
Glib::RefPtr<Gsv::Buffer> buffer();

Loading…
Cancel
Save