Browse Source

Cleanup of window.* and notebook.*, work still in progress. Also fixed save as and some smaller issues.

merge-requests/365/head
eidheim 11 years ago
parent
commit
38abe1f632
  1. 8
      juci/api.cc
  2. 4
      juci/api.h
  3. 7
      juci/juci.cc
  4. 2
      juci/juci.h
  5. 350
      juci/notebook.cc
  6. 55
      juci/notebook.h
  7. 6
      juci/singletons.cc
  8. 2
      juci/singletons.h
  9. 437
      juci/window.cc
  10. 31
      juci/window.h

8
juci/api.cc

@ -3,13 +3,13 @@
#include "singletons.h" #include "singletons.h"
Menu* PluginApi::menu_=nullptr; Menu* PluginApi::menu_=nullptr;
Notebook::Controller* PluginApi::notebook_=nullptr; Notebook* PluginApi::notebook=nullptr;
///////////////////////////// /////////////////////////////
//// API ServiceProvider //// //// API ServiceProvider ////
///////////////////////////// /////////////////////////////
PluginApi::PluginApi() { PluginApi::PluginApi(Notebook* notebook) {
DEBUG("Adding pointers for the API"); DEBUG("Adding pointers for the API");
notebook_ = Singleton::notebook(); this->notebook = notebook;
menu_ = Singleton::menu(); menu_ = Singleton::menu();
DEBUG("Initiating plugins(from plugins.py).."); DEBUG("Initiating plugins(from plugins.py)..");
#ifndef __APPLE__ #ifndef __APPLE__
@ -211,7 +211,7 @@ void libjuci::IterToWordEnd(Gtk::TextIter &iter) {
} }
Glib::RefPtr<Gtk::TextBuffer> libjuci::BufferFromNotebook() { Glib::RefPtr<Gtk::TextBuffer> libjuci::BufferFromNotebook() {
return Glib::RefPtr<Gtk::TextBuffer>(PluginApi::notebook_ return Glib::RefPtr<Gtk::TextBuffer>(PluginApi::notebook
->CurrentSourceView()->get_buffer()); ->CurrentSourceView()->get_buffer());
} }

4
juci/api.h

@ -12,9 +12,9 @@
//////////////////// ////////////////////
class PluginApi { class PluginApi {
public: public:
PluginApi(); PluginApi(Notebook* notebook);
static Menu* menu_; static Menu* menu_;
static Notebook::Controller* notebook_; static Notebook* notebook;
static void InitPlugins(); static void InitPlugins();
static std::string ProjectPath(); static std::string ProjectPath();
// for Python module: // for Python module:

7
juci/juci.cc

@ -36,12 +36,11 @@ void Juci::on_activate() {
add_window(*window); add_window(*window);
window->show(); window->show();
if(directory!="") { if(directory!="") {
//TODO: use the following instead, window->notebook.open_directory(directory); window->notebook.project_path=directory;
Singleton::notebook()->project_path=directory; window->directories.open_folder(directory);
Singleton::notebook()->directories.open_folder(directory);
} }
for(auto &f: files) for(auto &f: files)
Singleton::notebook()->open_file(f); window->notebook.open_file(f);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {

2
juci/juci.h

@ -1,6 +1,7 @@
#ifndef JUCI_JUCI_H_ #ifndef JUCI_JUCI_H_
#define JUCI_JUCI_H_ #define JUCI_JUCI_H_
#include "config.h"
#include "window.h" #include "window.h"
#include "logging.h" #include "logging.h"
@ -12,6 +13,7 @@ public:
void on_activate(); void on_activate();
private: private:
MainConfig main_config;
std::unique_ptr<Window> window; std::unique_ptr<Window> window;
std::string directory; std::string directory;
std::vector<std::string> files; std::vector<std::string> files;

350
juci/notebook.cc

@ -9,90 +9,17 @@ namespace sigc {
SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
} }
Notebook::View::View() { Notebook::Notebook() : Gtk::Notebook() {
pack2(notebook);
set_position(120);
}
Notebook::Controller::Controller() :
directories() {
INFO("Create notebook"); INFO("Create notebook");
Gsv::init(); Gsv::init();
clipboard = Gtk::Clipboard::get();
view.pack1(directories.widget(), true, true);
CreateKeybindings();
entry_box.signal_hide().connect([this]() {
if(CurrentPage()!=-1) {
CurrentSourceView()->grab_focus();
}
});
view.notebook.signal_switch_page().connect([this](Gtk::Widget* page, guint page_num) {
if(search_entry_shown && entry_box.labels.size()>0 && CurrentPage()!=-1) {
CurrentSourceView()->update_search_occurrences=[this](int number){
entry_box.labels.begin()->update(0, std::to_string(number));
};
CurrentSourceView()->search_highlight(last_search, case_sensitive_search, regex_search);
}
if(CurrentPage()!=-1) {
if(auto menu_item=dynamic_cast<Gtk::MenuItem*>(Singleton::menu()->ui_manager->get_widget("/MenuBar/SourceMenu/SourceGotoDeclaration")))
menu_item->set_sensitive((bool)CurrentSourceView()->get_declaration_location);
if(auto menu_item=dynamic_cast<Gtk::MenuItem*>(Singleton::menu()->ui_manager->get_widget("/MenuBar/SourceMenu/SourceGotoMethod")))
menu_item->set_sensitive((bool)CurrentSourceView()->goto_method);
if(auto menu_item=dynamic_cast<Gtk::MenuItem*>(Singleton::menu()->ui_manager->get_widget("/MenuBar/SourceMenu/SourceRename")))
menu_item->set_sensitive((bool)CurrentSourceView()->rename_similar_tokens);
}
});
INFO("Notebook Controller Success");
} // Constructor
void Notebook::Controller::CreateKeybindings() {
auto menu=Singleton::menu(); auto menu=Singleton::menu();
INFO("Notebook create signal handlers"); INFO("Notebook create signal handlers");
directories.m_TreeView.signal_row_activated().connect(sigc::mem_fun(*this, &Notebook::Controller::OnDirectoryNavigation));
menu->action_group->add(Gtk::Action::create("FileMenu", "File")); menu->action_group->add(Gtk::Action::create("FileMenu", "File"));
menu->action_group->add(Gtk::Action::create("FileNewFile", "New file"), Gtk::AccelKey(menu->key_map["new_file"]), [this]() {
OnFileNewFile();
});
menu->action_group->add(Gtk::Action::create("WindowCloseTab", "Close tab"), Gtk::AccelKey(menu->key_map["close_tab"]), [this]() { menu->action_group->add(Gtk::Action::create("WindowCloseTab", "Close tab"), Gtk::AccelKey(menu->key_map["close_tab"]), [this]() {
close_current_page(); close_current_page();
}); });
menu->action_group->add(Gtk::Action::create("EditFind", "Find"), Gtk::AccelKey(menu->key_map["edit_find"]), [this]() {
show_search_and_replace();
});
menu->action_group->add(Gtk::Action::create("EditCopy", "Copy"), Gtk::AccelKey(menu->key_map["edit_copy"]), [this]() {
auto window=(Gtk::Window*)view.get_toplevel();
auto widget=window->get_focus();
if(auto entry=dynamic_cast<Gtk::Entry*>(widget))
entry->copy_clipboard();
else if(auto text_view=dynamic_cast<Gtk::TextView*>(widget))
text_view->get_buffer()->copy_clipboard(clipboard);
});
menu->action_group->add(Gtk::Action::create("EditCut", "Cut"), Gtk::AccelKey(menu->key_map["edit_cut"]), [this]() {
auto window=(Gtk::Window*)view.get_toplevel();
auto widget=window->get_focus();
if(auto entry=dynamic_cast<Gtk::Entry*>(widget))
entry->cut_clipboard();
else {
if (Pages() != 0)
CurrentSourceView()->get_buffer()->cut_clipboard(clipboard);
}
});
menu->action_group->add(Gtk::Action::create("EditPaste", "Paste"), Gtk::AccelKey(menu->key_map["edit_paste"]), [this]() {
auto window=(Gtk::Window*)view.get_toplevel();
auto widget=window->get_focus();
if(auto entry=dynamic_cast<Gtk::Entry*>(widget))
entry->paste_clipboard();
else {
if (Pages() != 0)
CurrentSourceView()->get_buffer()->paste_clipboard(clipboard);
}
});
menu->action_group->add(Gtk::Action::create("EditUndo", "Undo"), Gtk::AccelKey(menu->key_map["edit_undo"]), [this]() { menu->action_group->add(Gtk::Action::create("EditUndo", "Undo"), Gtk::AccelKey(menu->key_map["edit_undo"]), [this]() {
INFO("On undo"); INFO("On undo");
@ -135,153 +62,14 @@ void Notebook::Controller::CreateKeybindings() {
} }
} }
}); });
menu->action_group->add(Gtk::Action::create("SourceRename", "Rename function/variable"), Gtk::AccelKey(menu->key_map["source_rename"]), [this]() {
entry_box.clear();
if(CurrentPage()!=-1) {
if(CurrentSourceView()->get_token && CurrentSourceView()->get_token_name) {
auto token=std::make_shared<std::string>(CurrentSourceView()->get_token());
if(token->size()>0 && CurrentSourceView()->get_token_name) {
auto token_name=std::make_shared<std::string>(CurrentSourceView()->get_token_name());
for(int c=0;c<Pages();c++) {
if(source_views.at(c)->view->tag_similar_tokens) {
source_views.at(c)->view->tag_similar_tokens(*token);
}
}
entry_box.labels.emplace_back();
auto label_it=entry_box.labels.begin();
label_it->update=[label_it](int state, const std::string& message){
label_it->set_text("Warning: only opened and parsed tabs will have its content renamed, and modified files will be saved.");
};
label_it->update(0, "");
entry_box.entries.emplace_back(*token_name, [this, token_name, token](const std::string& content){
if(CurrentPage()!=-1 && content!=*token_name) {
for(int c=0;c<Pages();c++) {
if(source_views.at(c)->view->rename_similar_tokens) {
auto number=source_views.at(c)->view->rename_similar_tokens(*token, content);
if(number>0) {
Singleton::terminal()->print("Replaced "+std::to_string(number)+" occurrences in file "+source_views.at(c)->view->file_path+"\n");
source_views.at(c)->view->save();
}
}
}
entry_box.hide();
}
});
auto entry_it=entry_box.entries.begin();
entry_box.buttons.emplace_back("Rename", [this, entry_it](){
entry_it->activate();
});
entry_box.show();
}
}
}
});
INFO("Notebook signal handlers sucsess");
} }
void Notebook::Controller::show_search_and_replace() { void Notebook::open_file(std::string path) {
entry_box.clear();
entry_box.labels.emplace_back();
auto label_it=entry_box.labels.begin();
label_it->update=[label_it](int state, const std::string& message){
if(state==0) {
int number=stoi(message);
if(number==0)
label_it->set_text("");
else if(number==1)
label_it->set_text("1 result found");
else if(number>1)
label_it->set_text(std::to_string(number)+" results found");
}
};
entry_box.entries.emplace_back(last_search, [this](const std::string& content){
if(CurrentPage()!=-1)
CurrentSourceView()->search_forward();
});
auto search_entry_it=entry_box.entries.begin();
search_entry_it->set_placeholder_text("Find");
if(CurrentPage()!=-1) {
CurrentSourceView()->update_search_occurrences=[label_it](int number){
label_it->update(0, std::to_string(number));
};
CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
}
search_entry_it->signal_key_press_event().connect([this](GdkEventKey* event){
if(event->keyval==GDK_KEY_Return && event->state==GDK_SHIFT_MASK) {
if(CurrentPage()!=-1)
CurrentSourceView()->search_backward();
}
return false;
});
search_entry_it->signal_changed().connect([this, search_entry_it](){
last_search=search_entry_it->get_text();
if(CurrentPage()!=-1)
CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
});
entry_box.entries.emplace_back(last_replace, [this](const std::string &content){
if(CurrentPage()!=-1)
CurrentSourceView()->replace_forward(content);
});
auto replace_entry_it=entry_box.entries.begin();
replace_entry_it++;
replace_entry_it->set_placeholder_text("Replace");
replace_entry_it->signal_key_press_event().connect([this, replace_entry_it](GdkEventKey* event){
if(event->keyval==GDK_KEY_Return && event->state==GDK_SHIFT_MASK) {
if(CurrentPage()!=-1)
CurrentSourceView()->replace_backward(replace_entry_it->get_text());
}
return false;
});
replace_entry_it->signal_changed().connect([this, replace_entry_it](){
last_replace=replace_entry_it->get_text();
});
entry_box.buttons.emplace_back("Find", [this](){
if(CurrentPage()!=-1)
CurrentSourceView()->search_forward();
});
entry_box.buttons.emplace_back("Replace", [this, replace_entry_it](){
if(CurrentPage()!=-1)
CurrentSourceView()->replace_forward(replace_entry_it->get_text());
});
entry_box.buttons.emplace_back("Replace all", [this, replace_entry_it](){
if(CurrentPage()!=-1)
CurrentSourceView()->replace_all(replace_entry_it->get_text());
});
entry_box.toggle_buttons.emplace_back("Match case");
entry_box.toggle_buttons.back().set_active(case_sensitive_search);
entry_box.toggle_buttons.back().on_activate=[this, search_entry_it](){
case_sensitive_search=!case_sensitive_search;
if(CurrentPage()!=-1)
CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
};
entry_box.toggle_buttons.emplace_back("Use regex");
entry_box.toggle_buttons.back().set_active(regex_search);
entry_box.toggle_buttons.back().on_activate=[this, search_entry_it](){
regex_search=!regex_search;
if(CurrentPage()!=-1)
CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
};
entry_box.signal_hide().connect([this]() {
for(int c=0;c<Pages();c++) {
source_views.at(c)->view->update_search_occurrences=nullptr;
source_views.at(c)->view->search_highlight("", case_sensitive_search, regex_search);
}
search_entry_shown=false;
});
search_entry_shown=true;
entry_box.show();
}
void Notebook::Controller::open_file(std::string path) {
INFO("Notebook open file"); INFO("Notebook open file");
INFO("Notebook create page"); INFO("Notebook create page");
for(int c=0;c<Pages();c++) { for(int c=0;c<Pages();c++) {
if(path==source_views.at(c)->view->file_path) { if(path==source_views.at(c)->view->file_path) {
view.notebook.set_current_page(c); set_current_page(c);
return; return;
} }
} }
@ -293,10 +81,10 @@ void Notebook::Controller::open_file(std::string path) {
boost::filesystem::path file_path(source_views.back()->view->file_path); boost::filesystem::path file_path(source_views.back()->view->file_path);
std::string title=file_path.filename().string(); std::string title=file_path.filename().string();
view.notebook.append_page(*hboxes.back(), title); append_page(*hboxes.back(), title);
view.notebook.show_all_children(); show_all_children();
view.notebook.set_current_page(Pages()-1); set_current_page(Pages()-1);
view.notebook.set_focus_child(*source_views.back()->view); set_focus_child(*source_views.back()->view);
CurrentSourceView()->get_buffer()->set_modified(false); CurrentSourceView()->get_buffer()->set_modified(false);
//Add star on tab label when the page is not saved: //Add star on tab label when the page is not saved:
auto source_view=CurrentSourceView(); auto source_view=CurrentSourceView();
@ -313,142 +101,42 @@ void Notebook::Controller::open_file(std::string path) {
} }
} }
if(page!=-1) if(page!=-1)
view.notebook.set_tab_label_text(*(view.notebook.get_nth_page(page)), title); set_tab_label_text(*(get_nth_page(page)), title);
}); });
} }
bool Notebook::Controller::close_current_page() { bool Notebook::close_current_page() {
INFO("Notebook close page"); INFO("Notebook close page");
if (Pages() != 0) { if (Pages() != 0) {
if(CurrentSourceView()->get_buffer()->get_modified()){ if(CurrentSourceView()->get_buffer()->get_modified()){
if(!save_dialog()) if(!save_modified_dialog())
return false; return false;
} }
int page = CurrentPage(); int page = CurrentPage();
view.notebook.remove_page(page); remove_page(page);
source_views.erase(source_views.begin()+ page); source_views.erase(source_views.begin()+ page);
scrolled_windows.erase(scrolled_windows.begin()+page); scrolled_windows.erase(scrolled_windows.begin()+page);
hboxes.erase(hboxes.begin()+page); hboxes.erase(hboxes.begin()+page);
} }
return true; return true;
} }
void Notebook::Controller::OnFileNewFile() {
entry_box.clear();
entry_box.entries.emplace_back("untitled", [this](const std::string& content){
std::string filename=content;
if(filename!="") {
if(project_path!="" && !boost::filesystem::path(filename).is_absolute())
filename=project_path+"/"+filename;
boost::filesystem::path p(filename);
if(boost::filesystem::exists(p)) {
Singleton::terminal()->print("Error: "+p.string()+" already exists.\n");
}
else {
std::ofstream f(p.string().c_str());
if(f) {
open_file(boost::filesystem::canonical(p).string());
Singleton::terminal()->print("New file "+p.string()+" created.\n");
if(project_path!="")
directories.open_folder(project_path); //TODO: Do refresh instead
}
else {
Singleton::terminal()->print("Error: could not create new file "+p.string()+".\n");
}
f.close();
}
}
entry_box.hide();
});
auto entry_it=entry_box.entries.begin();
entry_box.buttons.emplace_back("Create file", [this, entry_it](){
entry_it->activate();
});
entry_box.show();
}
void Notebook::Controller Source::View* Notebook::CurrentSourceView() {
::OnDirectoryNavigation(const Gtk::TreeModel::Path& path,
Gtk::TreeViewColumn* column) {
INFO("Notebook directory navigation");
Gtk::TreeModel::iterator iter = directories.m_refTreeModel->get_iter(path);
if (iter) {
Gtk::TreeModel::Row row = *iter;
std::string upath = Glib::ustring(row[directories.view().m_col_path]);
boost::filesystem::path fs_path(upath);
if (boost::filesystem::is_directory(fs_path)) {
directories.m_TreeView.row_expanded(path) ?
directories.m_TreeView.collapse_row(path) :
directories.m_TreeView.expand_row(path, false);
} else {
std::stringstream sstm;
sstm << row[directories.view().m_col_path];
std::string file = sstm.str();
open_file(file);
}
}
}
Source::View* Notebook::Controller::CurrentSourceView() {
INFO("Getting sourceview"); INFO("Getting sourceview");
return source_views.at(CurrentPage())->view.get(); return source_views.at(CurrentPage())->view.get();
} }
int Notebook::Controller::CurrentPage() { int Notebook::CurrentPage() {
return view.notebook.get_current_page(); return get_current_page();
}
int Notebook::Controller::Pages() {
return view.notebook.get_n_pages();
} }
bool Notebook::Controller:: OnSaveFile(std::string path) { int Notebook::Pages() {
INFO("Notebook save file with path"); return get_n_pages();
if (path != "" && CurrentSourceView()->get_buffer()->get_modified()) {
std::ofstream file;
file.open (path);
file << CurrentSourceView()->get_buffer()->get_text();
file.close();
boost::filesystem::path path(CurrentSourceView()->file_path);
std::string title=path.filename().string();
CurrentSourceView()->get_buffer()->set_modified(false);
return true;
}
return false;
}
std::string Notebook::Controller::OnSaveFileAs(){
INFO("Notebook save as");
Gtk::FileChooserDialog dialog((Gtk::Window&)(*view.get_toplevel()), "Please choose a file",
Gtk::FILE_CHOOSER_ACTION_SAVE);
DEBUG("SET TRANSISTEN FPR");
dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS);
dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL);
dialog.add_button("_Save", Gtk::RESPONSE_OK);
//dialog.set_current_name("Untitled");
DEBUG("RUN DIALOG");
int result = dialog.run();
DEBUG("DIALOG RUNNING");
switch (result) {
case(Gtk::RESPONSE_OK): {
DEBUG("get_filename()");
std::string path = dialog.get_filename();
return path;
}
case(Gtk::RESPONSE_CANCEL): {
break;
}
default: {
DEBUG("Unexpected button clicked.");
break;
}
}
return "";
} }
bool Notebook::Controller::save_dialog() { bool Notebook::save_modified_dialog() {
INFO("Notebook::Controller::save_dialog"); INFO("Notebook::save_dialog");
Gtk::MessageDialog dialog((Gtk::Window&)(*view.get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog((Gtk::Window&)(*get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO);
dialog.set_secondary_text("Do you want to save: " + CurrentSourceView()->file_path+" ?"); dialog.set_secondary_text("Do you want to save: " + CurrentSourceView()->file_path+" ?");
int result = dialog.run(); int result = dialog.run();
if(result==Gtk::RESPONSE_YES) { if(result==Gtk::RESPONSE_YES) {

55
juci/notebook.h

@ -12,46 +12,21 @@
#include <sigc++/sigc++.h> #include <sigc++/sigc++.h>
#include "clangmm.h" #include "clangmm.h"
namespace Notebook { class Notebook : public Gtk::Notebook {
class View : public Gtk::Paned { public:
public: Notebook();
View(); Source::View* CurrentSourceView();
Gtk::Notebook notebook; int CurrentPage();
}; bool close_current_page();
class Controller { void open_file(std::string filename);
public: int Pages();
Controller(); std::string project_path;
Source::View* CurrentSourceView();
int CurrentPage();
bool close_current_page();
void OnFileNewFile();
bool OnSaveFile(std::string path);
void OnDirectoryNavigation(const Gtk::TreeModel::Path& path,
Gtk::TreeViewColumn* column);
void open_file(std::string filename);
int Pages();
View view;
std::string OnSaveFileAs();
std::string project_path;
Directories::Controller directories; //Todo: make private after creating open_directory()
EntryBox entry_box; std::vector<std::unique_ptr<Source> > source_views;
void show_search_and_replace(); private:
std::string last_search; bool save_modified_dialog();
std::string last_replace;
bool case_sensitive_search=true;
bool regex_search=false;
bool search_entry_shown=false;
sigc::connection delayed_search_label_update;
std::vector<std::unique_ptr<Source> > source_views; std::vector<std::unique_ptr<Gtk::ScrolledWindow> > scrolled_windows;
private: std::vector<std::unique_ptr<Gtk::HBox> > hboxes;
void CreateKeybindings(); };
bool save_dialog();
std::vector<std::unique_ptr<Gtk::ScrolledWindow> > scrolled_windows;
std::vector<std::unique_ptr<Gtk::HBox> > hboxes;
Glib::RefPtr<Gtk::Clipboard> clipboard;
}; // class controller
} // namespace Notebook
#endif // JUCI_NOTEBOOK_H_ #endif // JUCI_NOTEBOOK_H_

6
juci/singletons.cc

@ -5,18 +5,12 @@ std::unique_ptr<Terminal::Config> Singleton::Config::terminal_=std::unique_ptr<T
std::unique_ptr<Directories::Config> Singleton::Config::directories_=std::unique_ptr<Directories::Config>(new Directories::Config()); std::unique_ptr<Directories::Config> Singleton::Config::directories_=std::unique_ptr<Directories::Config>(new Directories::Config());
std::unique_ptr<Terminal::Controller> Singleton::terminal_=std::unique_ptr<Terminal::Controller>(); std::unique_ptr<Terminal::Controller> Singleton::terminal_=std::unique_ptr<Terminal::Controller>();
std::unique_ptr<Notebook::Controller> Singleton::notebook_=std::unique_ptr<Notebook::Controller>();
std::unique_ptr<Menu> Singleton::menu_=std::unique_ptr<Menu>(); std::unique_ptr<Menu> Singleton::menu_=std::unique_ptr<Menu>();
Terminal::Controller *Singleton::terminal() { Terminal::Controller *Singleton::terminal() {
if(!terminal_) if(!terminal_)
terminal_=std::unique_ptr<Terminal::Controller>(new Terminal::Controller()); terminal_=std::unique_ptr<Terminal::Controller>(new Terminal::Controller());
return terminal_.get(); return terminal_.get();
} }
Notebook::Controller *Singleton::notebook() {
if(!notebook_)
notebook_=std::unique_ptr<Notebook::Controller>(new Notebook::Controller());
return notebook_.get();
}
Menu *Singleton::menu() { Menu *Singleton::menu() {
if(!menu_) if(!menu_)
menu_=std::unique_ptr<Menu>(new Menu()); menu_=std::unique_ptr<Menu>(new Menu());

2
juci/singletons.h

@ -21,11 +21,9 @@ public:
}; };
static Terminal::Controller *terminal(); static Terminal::Controller *terminal();
static Notebook::Controller *notebook();
static Menu *menu(); static Menu *menu();
private: private:
static std::unique_ptr<Terminal::Controller> terminal_; static std::unique_ptr<Terminal::Controller> terminal_;
static std::unique_ptr<Notebook::Controller> notebook_;
static std::unique_ptr<Menu> menu_; static std::unique_ptr<Menu> menu_;
}; };

437
juci/window.cc

@ -6,87 +6,192 @@ namespace sigc {
SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
} }
Window::Window() : Window::Window() : notebook(), plugin_api(&notebook), box(Gtk::ORIENTATION_VERTICAL) {
window_box_(Gtk::ORIENTATION_VERTICAL) {
INFO("Create Window"); INFO("Create Window");
set_title("juCi++"); set_title("juCi++");
set_default_size(600, 400); set_default_size(600, 400);
set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK|Gdk::SCROLL_MASK); set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK|Gdk::SCROLL_MASK);
add(window_box_); add(box);
//TODO: see TODO Window::on_directory_navigation
directories.m_TreeView.signal_row_activated().connect(sigc::mem_fun(*this, &Window::on_directory_navigation));
auto menu=Singleton::menu(); auto menu=Singleton::menu();
menu->action_group->add(Gtk::Action::create("FileQuit", "Quit juCi++"), Gtk::AccelKey(menu->key_map["quit"]), [this]() { menu->action_group->add(Gtk::Action::create("FileQuit", "Quit juCi++"), Gtk::AccelKey(menu->key_map["quit"]), [this]() {
hide(); hide();
}); });
menu->action_group->add(Gtk::Action::create("FileNewFile", "New file"), Gtk::AccelKey(menu->key_map["new_file"]), [this]() {
new_file_entry();
});
menu->action_group->add(Gtk::Action::create("FileOpenFile", "Open file"), Gtk::AccelKey(menu->key_map["open_file"]), [this]() { menu->action_group->add(Gtk::Action::create("FileOpenFile", "Open file"), Gtk::AccelKey(menu->key_map["open_file"]), [this]() {
OnOpenFile(); open_file_dialog();
}); });
menu->action_group->add(Gtk::Action::create("FileOpenFolder", "Open folder"), Gtk::AccelKey(menu->key_map["open_folder"]), [this]() { menu->action_group->add(Gtk::Action::create("FileOpenFolder", "Open folder"), Gtk::AccelKey(menu->key_map["open_folder"]), [this]() {
OnFileOpenFolder(); open_folder_dialog();
}); });
menu->action_group->add(Gtk::Action::create("FileSaveAs", "Save as"), Gtk::AccelKey(menu->key_map["save_as"]), [this]() { menu->action_group->add(Gtk::Action::create("FileSaveAs", "Save as"), Gtk::AccelKey(menu->key_map["save_as"]), [this]() {
SaveFileAs(); save_file_dialog();
}); });
menu->action_group->add(Gtk::Action::create("FileSave", "Save"), Gtk::AccelKey(menu->key_map["save"]), [this]() { menu->action_group->add(Gtk::Action::create("FileSave", "Save"), Gtk::AccelKey(menu->key_map["save"]), [this]() {
SaveFile(); notebook.CurrentSourceView()->save();
});
menu->action_group->add(Gtk::Action::create("EditCopy", "Copy"), Gtk::AccelKey(menu->key_map["edit_copy"]), [this]() {
auto widget=get_focus();
if(auto entry=dynamic_cast<Gtk::Entry*>(widget))
entry->copy_clipboard();
else if(auto text_view=dynamic_cast<Gtk::TextView*>(widget))
text_view->get_buffer()->copy_clipboard(Gtk::Clipboard::get());
});
menu->action_group->add(Gtk::Action::create("EditCut", "Cut"), Gtk::AccelKey(menu->key_map["edit_cut"]), [this]() {
auto widget=get_focus();
if(auto entry=dynamic_cast<Gtk::Entry*>(widget))
entry->cut_clipboard();
else {
if (notebook.Pages() != 0)
notebook.CurrentSourceView()->get_buffer()->cut_clipboard(Gtk::Clipboard::get());
}
});
menu->action_group->add(Gtk::Action::create("EditPaste", "Paste"), Gtk::AccelKey(menu->key_map["edit_paste"]), [this]() {
auto widget=get_focus();
if(auto entry=dynamic_cast<Gtk::Entry*>(widget))
entry->paste_clipboard();
else {
if (notebook.Pages() != 0)
notebook.CurrentSourceView()->get_buffer()->paste_clipboard(Gtk::Clipboard::get());
}
});
menu->action_group->add(Gtk::Action::create("EditFind", "Find"), Gtk::AccelKey(menu->key_map["edit_find"]), [this]() {
search_and_replace_entry();
});
menu->action_group->add(Gtk::Action::create("SourceRename", "Rename function/variable"), Gtk::AccelKey(menu->key_map["source_rename"]), [this]() {
entry_box.clear();
if(notebook.CurrentPage()!=-1) {
if(notebook.CurrentSourceView()->get_token && notebook.CurrentSourceView()->get_token_name) {
auto token=std::make_shared<std::string>(notebook.CurrentSourceView()->get_token());
if(token->size()>0 && notebook.CurrentSourceView()->get_token_name) {
auto token_name=std::make_shared<std::string>(notebook.CurrentSourceView()->get_token_name());
for(int c=0;c<notebook.Pages();c++) {
if(notebook.source_views.at(c)->view->tag_similar_tokens) {
notebook.source_views.at(c)->view->tag_similar_tokens(*token);
}
}
entry_box.labels.emplace_back();
auto label_it=entry_box.labels.begin();
label_it->update=[label_it](int state, const std::string& message){
label_it->set_text("Warning: only opened and parsed tabs will have its content renamed, and modified files will be saved.");
};
label_it->update(0, "");
entry_box.entries.emplace_back(*token_name, [this, token_name, token](const std::string& content){
if(notebook.CurrentPage()!=-1 && content!=*token_name) {
for(int c=0;c<notebook.Pages();c++) {
if(notebook.source_views.at(c)->view->rename_similar_tokens) {
auto number=notebook.source_views.at(c)->view->rename_similar_tokens(*token, content);
if(number>0) {
Singleton::terminal()->print("Replaced "+std::to_string(number)+" occurrences in file "+notebook.source_views.at(c)->view->file_path+"\n");
notebook.source_views.at(c)->view->save();
}
}
}
entry_box.hide();
}
});
auto entry_it=entry_box.entries.begin();
entry_box.buttons.emplace_back("Rename", [this, entry_it](){
entry_it->activate();
});
entry_box.show();
}
}
}
}); });
menu->action_group->add(Gtk::Action::create("ProjectCompileAndRun", "Compile And Run"), Gtk::AccelKey(menu->key_map["compile_and_run"]), [this]() { menu->action_group->add(Gtk::Action::create("ProjectCompileAndRun", "Compile And Run"), Gtk::AccelKey(menu->key_map["compile_and_run"]), [this]() {
SaveFile(); if(notebook.CurrentPage()==-1)
if (running.try_lock()) { return;
std::thread execute([this]() { notebook.CurrentSourceView()->save();
std::string path = Singleton::notebook()->CurrentSourceView()->file_path; if (running.try_lock()) {
size_t pos = path.find_last_of("/\\"); std::thread execute([this]() {
if(pos != std::string::npos) { std::string path = notebook.CurrentSourceView()->file_path;
path.erase(path.begin()+pos,path.end()); size_t pos = path.find_last_of("/\\");
Singleton::terminal()->SetFolderCommand(path); if(pos != std::string::npos) {
} path.erase(path.begin()+pos,path.end());
Singleton::terminal()->Compile(); Singleton::terminal()->SetFolderCommand(path);
std::string executable = Singleton::notebook()->directories. }
GetCmakeVarValue(path,"add_executable"); Singleton::terminal()->Compile();
Singleton::terminal()->Run(executable); std::string executable = directories.GetCmakeVarValue(path,"add_executable");
running.unlock(); Singleton::terminal()->Run(executable);
}); running.unlock();
execute.detach(); });
} execute.detach();
}); }
});
menu->action_group->add(Gtk::Action::create("ProjectCompile", "Compile"), Gtk::AccelKey(menu->key_map["compile"]), [this]() { menu->action_group->add(Gtk::Action::create("ProjectCompile", "Compile"), Gtk::AccelKey(menu->key_map["compile"]), [this]() {
SaveFile(); if(notebook.CurrentPage()==-1)
return;
notebook.CurrentSourceView()->save();
if (running.try_lock()) { if (running.try_lock()) {
std::thread execute([this]() { std::thread execute([this]() {
std::string path = Singleton::notebook()->CurrentSourceView()->file_path; std::string path = notebook.CurrentSourceView()->file_path;
size_t pos = path.find_last_of("/\\"); size_t pos = path.find_last_of("/\\");
if(pos != std::string::npos){ if(pos != std::string::npos){
path.erase(path.begin()+pos,path.end()); path.erase(path.begin()+pos,path.end());
Singleton::terminal()->SetFolderCommand(path); Singleton::terminal()->SetFolderCommand(path);
} }
Singleton::terminal()->Compile(); Singleton::terminal()->Compile();
running.unlock(); running.unlock();
}); });
execute.detach(); execute.detach();
} }
}); });
add_accel_group(menu->ui_manager->get_accel_group()); add_accel_group(menu->ui_manager->get_accel_group());
menu->build(); menu->build();
box.pack_start(menu->get_widget(), Gtk::PACK_SHRINK);
box.pack_start(entry_box, Gtk::PACK_SHRINK);
window_box_.pack_start(menu->get_widget(), Gtk::PACK_SHRINK); directory_and_notebook_panes.pack1(directories.widget(), true, true); //TODO: should be pack1(directories, ...) Clean up directories.*
directory_and_notebook_panes.pack2(notebook);
directory_and_notebook_panes.set_position(120);
window_box_.pack_start(Singleton::notebook()->entry_box, Gtk::PACK_SHRINK); vpaned.set_position(300);
paned_.set_position(300); vpaned.pack1(directory_and_notebook_panes, true, false);
paned_.pack1(Singleton::notebook()->view, true, false); vpaned.pack2(Singleton::terminal()->view, true, true);
paned_.pack2(Singleton::terminal()->view, true, true); box.pack_end(vpaned);
window_box_.pack_end(paned_);
show_all_children(); show_all_children();
Singleton::notebook()->entry_box.signal_show().connect([this](){ entry_box.signal_show().connect([this](){
std::vector<Gtk::Widget*> focus_chain; std::vector<Gtk::Widget*> focus_chain;
focus_chain.emplace_back(&Singleton::notebook()->entry_box); focus_chain.emplace_back(&entry_box);
window_box_.set_focus_chain(focus_chain); box.set_focus_chain(focus_chain);
}); });
Singleton::notebook()->entry_box.signal_hide().connect([this](){ entry_box.signal_hide().connect([this](){
window_box_.unset_focus_chain(); box.unset_focus_chain();
});
entry_box.signal_hide().connect([this]() {
if(notebook.CurrentPage()!=-1) {
notebook.CurrentSourceView()->grab_focus();
}
});
notebook.signal_switch_page().connect([this](Gtk::Widget* page, guint page_num) {
if(search_entry_shown && entry_box.labels.size()>0 && notebook.CurrentPage()!=-1) {
notebook.CurrentSourceView()->update_search_occurrences=[this](int number){
entry_box.labels.begin()->update(0, std::to_string(number));
};
notebook.CurrentSourceView()->search_highlight(last_search, case_sensitive_search, regex_search);
}
if(notebook.CurrentPage()!=-1) {
if(auto menu_item=dynamic_cast<Gtk::MenuItem*>(Singleton::menu()->ui_manager->get_widget("/MenuBar/SourceMenu/SourceGotoDeclaration")))
menu_item->set_sensitive((bool)notebook.CurrentSourceView()->get_declaration_location);
if(auto menu_item=dynamic_cast<Gtk::MenuItem*>(Singleton::menu()->ui_manager->get_widget("/MenuBar/SourceMenu/SourceGotoMethod")))
menu_item->set_sensitive((bool)notebook.CurrentSourceView()->goto_method);
if(auto menu_item=dynamic_cast<Gtk::MenuItem*>(Singleton::menu()->ui_manager->get_widget("/MenuBar/SourceMenu/SourceRename")))
menu_item->set_sensitive((bool)notebook.CurrentSourceView()->rename_similar_tokens);
}
}); });
INFO("Window created"); INFO("Window created");
@ -94,7 +199,7 @@ Window::Window() :
bool Window::on_key_press_event(GdkEventKey *event) { bool Window::on_key_press_event(GdkEventKey *event) {
if(event->keyval==GDK_KEY_Escape) if(event->keyval==GDK_KEY_Escape)
Singleton::notebook()->entry_box.hide(); entry_box.hide();
#ifdef __APPLE__ //For Apple's Command-left, right, up, down keys #ifdef __APPLE__ //For Apple's Command-left, right, up, down keys
else if((event->state & GDK_META_MASK)>0) { else if((event->state & GDK_META_MASK)>0) {
if(event->keyval==GDK_KEY_Left) { if(event->keyval==GDK_KEY_Left) {
@ -139,17 +244,52 @@ bool Window::on_delete_event (GdkEventAny *event) {
} }
void Window::hide() { void Window::hide() {
auto size=Singleton::notebook()->source_views.size(); auto size=notebook.source_views.size();
for(size_t c=0;c<size;c++) { for(size_t c=0;c<size;c++) {
if(!Singleton::notebook()->close_current_page()) if(!notebook.close_current_page())
return; return;
} }
Gtk::Window::hide(); Gtk::Window::hide();
} }
void Window::OnFileOpenFolder() { void Window::new_file_entry() {
Gtk::FileChooserDialog dialog("Please choose a folder", entry_box.clear();
Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); entry_box.entries.emplace_back("untitled", [this](const std::string& content){
std::string filename=content;
if(filename!="") {
if(notebook.project_path!="" && !boost::filesystem::path(filename).is_absolute())
filename=notebook.project_path+"/"+filename;
boost::filesystem::path p(filename);
if(boost::filesystem::exists(p)) {
Singleton::terminal()->print("Error: "+p.string()+" already exists.\n");
}
else {
std::ofstream f(p.string().c_str());
if(f) {
notebook.open_file(boost::filesystem::canonical(p).string());
Singleton::terminal()->print("New file "+p.string()+" created.\n");
if(notebook.project_path!="")
directories.open_folder(notebook.project_path); //TODO: Do refresh instead
}
else {
Singleton::terminal()->print("Error: could not create new file "+p.string()+".\n");
}
f.close();
}
}
entry_box.hide();
});
auto entry_it=entry_box.entries.begin();
entry_box.buttons.emplace_back("Create file", [this, entry_it](){
entry_it->activate();
});
entry_box.show();
}
void Window::open_folder_dialog() {
Gtk::FileChooserDialog dialog("Please choose a folder", Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
if(notebook.project_path.size()>0)
gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), notebook.project_path.c_str());
dialog.set_transient_for(*this); dialog.set_transient_for(*this);
//Add response buttons the the dialog: //Add response buttons the the dialog:
dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL); dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL);
@ -157,31 +297,18 @@ void Window::OnFileOpenFolder() {
int result = dialog.run(); int result = dialog.run();
//Handle the response: if(result==Gtk::RESPONSE_OK) {
switch(result) std::string project_path=dialog.get_filename();
{ notebook.project_path=project_path;
case(Gtk::RESPONSE_OK): directories.open_folder(project_path);
{ }
std::string project_path=dialog.get_filename();
Singleton::notebook()->project_path=project_path;
Singleton::notebook()->directories.open_folder(project_path);
break;
}
case(Gtk::RESPONSE_CANCEL):
{
break;
}
default:
{
break;
}
}
} }
void Window::open_file_dialog() {
void Window::OnOpenFile() { Gtk::FileChooserDialog dialog("Please choose a file", Gtk::FILE_CHOOSER_ACTION_OPEN);
Gtk::FileChooserDialog dialog("Please choose a file", if(notebook.project_path.size()>0)
Gtk::FILE_CHOOSER_ACTION_OPEN); gtk_file_chooser_set_current_folder((GtkFileChooser*)dialog.gobj(), notebook.project_path.c_str());
std::cout << notebook.project_path << std::endl;
dialog.set_transient_for(*this); dialog.set_transient_for(*this);
dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS); dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS);
@ -209,31 +336,151 @@ void Window::OnOpenFile() {
int result = dialog.run(); int result = dialog.run();
switch (result) { if(result==Gtk::RESPONSE_OK) {
case(Gtk::RESPONSE_OK): {
std::string path = dialog.get_filename(); std::string path = dialog.get_filename();
Singleton::notebook()->open_file(path); notebook.open_file(path);
break;
}
case(Gtk::RESPONSE_CANCEL): {
break;
}
default: {
break;
} }
}
void Window::save_file_dialog() {
INFO("Save file dialog");
Gtk::FileChooserDialog dialog(*this, "Please choose a file", Gtk::FILE_CHOOSER_ACTION_SAVE);
gtk_file_chooser_set_filename((GtkFileChooser*)dialog.gobj(), notebook.CurrentSourceView()->file_path.c_str());
dialog.set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS);
dialog.add_button("_Cancel", Gtk::RESPONSE_CANCEL);
dialog.add_button("_Save", Gtk::RESPONSE_OK);
int result = dialog.run();
if(result==Gtk::RESPONSE_OK) {
auto path = dialog.get_filename();
if(path.size()>0) {
std::ofstream file(path);
if(file) {
file << notebook.CurrentSourceView()->get_buffer()->get_text();
file.close();
notebook.open_file(path);
Singleton::terminal()->print("File saved to: " + notebook.CurrentSourceView()->file_path+"\n");
if(notebook.project_path!="")
directories.open_folder(notebook.project_path); //TODO: Do refresh instead
}
else
Singleton::terminal()->print("Error saving file\n");
}
} }
} }
//TODO: Move to notebook. Maybe also replace bool with void? //TODO: move most of it to Directories
bool Window::SaveFile() { void Window::on_directory_navigation(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column) {
return Singleton::notebook()->CurrentSourceView()->save(); INFO("Directory navigation");
Gtk::TreeModel::iterator iter = directories.m_refTreeModel->get_iter(path);
if (iter) {
Gtk::TreeModel::Row row = *iter;
std::string upath = Glib::ustring(row[directories.view().m_col_path]);
boost::filesystem::path fs_path(upath);
if (boost::filesystem::is_directory(fs_path)) {
directories.m_TreeView.row_expanded(path) ?
directories.m_TreeView.collapse_row(path) :
directories.m_TreeView.expand_row(path, false);
} else {
std::stringstream sstm;
sstm << row[directories.view().m_col_path];
std::string file = sstm.str();
notebook.open_file(file);
}
}
} }
bool Window::SaveFileAs() {
if(Singleton::notebook()->OnSaveFile(Singleton::notebook()->OnSaveFileAs())){ void Window::search_and_replace_entry() {
Singleton::terminal()->print("File saved to: " + entry_box.clear();
Singleton::notebook()->CurrentSourceView()->file_path+"\n"); entry_box.labels.emplace_back();
return true; auto label_it=entry_box.labels.begin();
label_it->update=[label_it](int state, const std::string& message){
if(state==0) {
int number=stoi(message);
if(number==0)
label_it->set_text("");
else if(number==1)
label_it->set_text("1 result found");
else if(number>1)
label_it->set_text(std::to_string(number)+" results found");
}
};
entry_box.entries.emplace_back(last_search, [this](const std::string& content){
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->search_forward();
});
auto search_entry_it=entry_box.entries.begin();
search_entry_it->set_placeholder_text("Find");
if(notebook.CurrentPage()!=-1) {
notebook.CurrentSourceView()->update_search_occurrences=[label_it](int number){
label_it->update(0, std::to_string(number));
};
notebook.CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
} }
Singleton::terminal()->print("File not saved"); search_entry_it->signal_key_press_event().connect([this](GdkEventKey* event){
return false; if(event->keyval==GDK_KEY_Return && event->state==GDK_SHIFT_MASK) {
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->search_backward();
}
return false;
});
search_entry_it->signal_changed().connect([this, search_entry_it](){
last_search=search_entry_it->get_text();
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
});
entry_box.entries.emplace_back(last_replace, [this](const std::string &content){
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->replace_forward(content);
});
auto replace_entry_it=entry_box.entries.begin();
replace_entry_it++;
replace_entry_it->set_placeholder_text("Replace");
replace_entry_it->signal_key_press_event().connect([this, replace_entry_it](GdkEventKey* event){
if(event->keyval==GDK_KEY_Return && event->state==GDK_SHIFT_MASK) {
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->replace_backward(replace_entry_it->get_text());
}
return false;
});
replace_entry_it->signal_changed().connect([this, replace_entry_it](){
last_replace=replace_entry_it->get_text();
});
entry_box.buttons.emplace_back("Find", [this](){
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->search_forward();
});
entry_box.buttons.emplace_back("Replace", [this, replace_entry_it](){
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->replace_forward(replace_entry_it->get_text());
});
entry_box.buttons.emplace_back("Replace all", [this, replace_entry_it](){
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->replace_all(replace_entry_it->get_text());
});
entry_box.toggle_buttons.emplace_back("Match case");
entry_box.toggle_buttons.back().set_active(case_sensitive_search);
entry_box.toggle_buttons.back().on_activate=[this, search_entry_it](){
case_sensitive_search=!case_sensitive_search;
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
};
entry_box.toggle_buttons.emplace_back("Use regex");
entry_box.toggle_buttons.back().set_active(regex_search);
entry_box.toggle_buttons.back().on_activate=[this, search_entry_it](){
regex_search=!regex_search;
if(notebook.CurrentPage()!=-1)
notebook.CurrentSourceView()->search_highlight(search_entry_it->get_text(), case_sensitive_search, regex_search);
};
entry_box.signal_hide().connect([this]() {
for(int c=0;c<notebook.Pages();c++) {
notebook.source_views.at(c)->view->update_search_occurrences=nullptr;
notebook.source_views.at(c)->view->search_highlight("", case_sensitive_search, regex_search);
}
search_entry_shown=false;
});
search_entry_shown=true;
entry_box.show();
} }

31
juci/window.h

@ -2,28 +2,39 @@
#define JUCI_WINDOW_H_ #define JUCI_WINDOW_H_
#include "api.h" #include "api.h"
#include "config.h"
#include <cstddef> #include <cstddef>
class Window : public Gtk::Window { class Window : public Gtk::Window {
public: public:
Window(); Window();
Gtk::Box window_box_; Notebook notebook;
MainConfig main_config; Directories::Controller directories;
PluginApi api;
protected: protected:
bool on_key_press_event(GdkEventKey *event); bool on_key_press_event(GdkEventKey *event);
bool on_delete_event (GdkEventAny *event); bool on_delete_event (GdkEventAny *event);
private: private:
Gtk::Box box;
Gtk::VPaned vpaned;
Gtk::Paned directory_and_notebook_panes;
EntryBox entry_box;
PluginApi plugin_api;
std::mutex running; std::mutex running;
Gtk::VPaned paned_;
//signal handlers
void hide(); void hide();
void OnOpenFile(); void new_file_entry();
void OnFileOpenFolder(); void open_folder_dialog();
bool SaveFile(); void open_file_dialog();
bool SaveFileAs(); void save_file_dialog();
void on_directory_navigation(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
void search_and_replace_entry();
std::string last_search;
std::string last_replace;
bool case_sensitive_search=true;
bool regex_search=false;
bool search_entry_shown=false;
}; };
#endif // JUCI_WINDOW_H #endif // JUCI_WINDOW_H

Loading…
Cancel
Save