Browse Source

merged

master
Jørgen Lien Sellæg 11 years ago
parent
commit
c5ff9e38cf
  1. 14
      juci/entry.cc
  2. 2
      juci/juci.cc
  3. 97
      juci/keybindings.cc
  4. 79
      juci/keybindings.h
  5. 145
      juci/menu.cc
  6. 74
      juci/menu.h
  7. 129
      juci/notebook.cc
  8. 58
      juci/notebook.h
  9. 16
      juci/window.cc
  10. 5
      juci/window.h

14
juci/entry.cc

@ -3,20 +3,16 @@
Entry::Model::Model() : Entry::Model::Model() :
next_("Next"), next_("Next"),
prev_("Prev"){ prev_("Prev"){
std::cout<<"Model Entry"<<std::endl; std::cout<<"Model Entry"<<std::endl;
} }
Entry::View::View() : Entry::View::View() :
view_(Gtk::ORIENTATION_HORIZONTAL), view_(Gtk::ORIENTATION_HORIZONTAL),
button_apply_(Gtk::Stock::APPLY), button_apply_(Gtk::Stock::APPLY),
button_cancel_(Gtk::Stock::CANCEL){ button_cancel_(Gtk::Stock::CANCEL){
// container_.add(view_); }
std::cout<<"View Entry"<<std::endl;
}
Gtk::Box& Entry::View::view() { Gtk::Box& Entry::View::view() {
return view_; return view_;
} }
void Entry::View::OnShowSetFilenName(std::string exstension) { void Entry::View::OnShowSetFilenName(std::string exstension) {
entry_.set_max_length(50); entry_.set_max_length(50);
entry_.set_text(exstension); entry_.set_text(exstension);
@ -30,26 +26,20 @@ void Entry::View::OnHideEntry()
view_.remove(button_cancel_); view_.remove(button_cancel_);
view_.remove(button_apply_); view_.remove(button_apply_);
} }
Entry::Controller::Controller() { Entry::Controller::Controller() {
std::cout<<"Controller Entry"<<std::endl;
} }
Gtk::Box& Entry::Controller::view() { Gtk::Box& Entry::Controller::view() {
return view_.view(); return view_.view();
} }
Gtk::Button& Entry::Controller::button_apply(){ Gtk::Button& Entry::Controller::button_apply(){
return view_.button_apply(); return view_.button_apply();
} }
void Entry::Controller::OnShowSetFilenName(std::string exstension) { void Entry::Controller::OnShowSetFilenName(std::string exstension) {
view_.OnShowSetFilenName(exstension); view_.OnShowSetFilenName(exstension);
view_.view().show_all(); view_.view().show_all();
view_.entry().grab_focus(); view_.entry().grab_focus();
view_.entry().set_position(0); view_.entry().set_position(0);
} }
void Entry::Controller::OnHideEntries(){ void Entry::Controller::OnHideEntries(){
view_.OnHideEntry(); view_.OnHideEntry();
} }

2
juci/juci.cc

@ -1,13 +1,11 @@
#include "window.h" #include "window.h"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create( Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(
argc, argc,
argv, argv,
"no.sout.juci"); "no.sout.juci");
Window window; Window window;
return app->run(window); return app->run(window);
} }

97
juci/keybindings.cc

@ -2,65 +2,60 @@
Keybindings::Model::Model() { Keybindings::Model::Model() {
menu_ui_string_ = menu_ui_string_ =
"<ui> " "<ui> "
" <menubar name='MenuBar'> " " <menubar name='MenuBar'> "
" <menu action='FileMenu'> " " <menu action='FileMenu'> "
" <menu action='FileNew'> " " <menu action='FileNew'> "
" <menuitem action='FileNewStandard'/> " " <menuitem action='FileNewStandard'/> "
" <menuitem action='FileNewCC'/> " " <menuitem action='FileNewCC'/> "
" <menuitem action='FileNewH'/> " " <menuitem action='FileNewH'/> "
" </menu> " " </menu> "
" <menuitem action='FileOpenFile'/> " " <menuitem action='FileOpenFile'/> "
" <menuitem action='FileOpenFolder'/> " " <menuitem action='FileOpenFolder'/> "
" <separator/> " " <separator/> "
" <menuitem action='FileQuit'/> " " <menuitem action='FileQuit'/> "
" </menu> " " </menu> "
" <menu action='EditMenu'> " " <menu action='EditMenu'> "
" <menuitem action='EditCopy'/> " " <menuitem action='EditCopy'/> "
" <menuitem action='EditCut'/> " " <menuitem action='EditCut'/> "
" <menuitem action='EditPaste'/> " " <menuitem action='EditPaste'/> "
" <separator/> " " <separator/> "
" <menuitem action='EditFind'/> " " <menuitem action='EditFind'/> "
" </menu> " " </menu> "
" <menu action='WindowMenu'> " " <menu action='WindowMenu'> "
" <menuitem action='WindowCloseTab'/> " " <menuitem action='WindowCloseTab'/> "
" <menuitem action='WindowSplitWindow'/> " " <menuitem action='WindowSplitWindow'/> "
" </menu> " " </menu> "
" <menu action='PluginMenu'> " " <menu action='PluginMenu'> "
" <menu action='PluginSnippet'> " " <menu action='PluginSnippet'> "
" <menuitem action='PluginAddSnippet'/> " " <menuitem action='PluginAddSnippet'/> "
" </menu> " " </menu> "
" </menu> " " </menu> "
" <menu action='HelpMenu'> " " <menu action='HelpMenu'> "
" <menuitem action='HelpAbout'/> " " <menuitem action='HelpAbout'/> "
" </menu> " " </menu> "
" </menubar> " " </menubar> "
"</ui> "; "</ui> ";
hidden_ui_string_ = hidden_ui_string_ =
"<ui> " "<ui> "
" <menubar name='MenuBar'> " " <menubar name='MenuBar'> "
" <menuitem action='Test'/> " " <menuitem action='Test'/> "
" </menubar> " " </menubar> "
"</ui> "; "</ui> ";
}; };
Keybindings::Model::~Model() { Keybindings::Model::~Model() {
} }
Keybindings::Controller::Controller() { Keybindings::Controller::Controller() {
action_group_menu_ = Gtk::ActionGroup::create(); action_group_menu_ = Gtk::ActionGroup::create();
ui_manager_menu_ = Gtk::UIManager::create(); ui_manager_menu_ = Gtk::UIManager::create();
action_group_hidden_ = Gtk::ActionGroup::create();
action_group_hidden_ = Gtk::ActionGroup::create(); ui_manager_hidden_ = Gtk::UIManager::create();
ui_manager_hidden_ = Gtk::UIManager::create(); }
}
Keybindings::Controller::~Controller(){ Keybindings::Controller::~Controller(){
} }
void Keybindings::Controller::BuildMenu() { void Keybindings::Controller::BuildMenu() {
try { try {
ui_manager_menu_->add_ui_from_string(model_.menu_ui_string()); ui_manager_menu_->add_ui_from_string(model_.menu_ui_string());
@ -70,8 +65,6 @@ void Keybindings::Controller::BuildMenu() {
} }
ui_manager_menu_->insert_action_group(action_group_menu_); ui_manager_menu_->insert_action_group(action_group_menu_);
} }
void Keybindings::Controller::BuildHiddenMenu() { void Keybindings::Controller::BuildHiddenMenu() {
try { try {
ui_manager_hidden_->add_ui_from_string(model_.hidden_ui_string()); ui_manager_hidden_->add_ui_from_string(model_.hidden_ui_string());

79
juci/keybindings.h

@ -6,53 +6,42 @@
#include "gtkmm.h" #include "gtkmm.h"
namespace Keybindings { namespace Keybindings {
class Model {
class Model { public:
public: Model();
Model(); virtual ~Model();
virtual ~Model(); std::string menu_ui_string(){return menu_ui_string_;}
std::string menu_ui_string(){return menu_ui_string_;} std::string hidden_ui_string(){return hidden_ui_string_;}
std::string hidden_ui_string(){return hidden_ui_string_;} private:
private: std::string menu_ui_string_;
std::string menu_ui_string_; std::string hidden_ui_string_;
std::string hidden_ui_string_; }; // Model
class Controller {
public:
Controller();
virtual ~Controller();
Glib::RefPtr<Gtk::ActionGroup> action_group_menu() {
return action_group_menu_;
}; };
Glib::RefPtr<Gtk::UIManager> ui_manager_menu() {
class Controller { return ui_manager_menu_;
public:
Controller();
virtual ~Controller();
Glib::RefPtr<Gtk::ActionGroup> action_group_menu() {
return action_group_menu_;
};
Glib::RefPtr<Gtk::UIManager> ui_manager_menu() {
return ui_manager_menu_;
};
Glib::RefPtr<Gtk::ActionGroup> action_group_hidden() {
return action_group_hidden_;
};
Glib::RefPtr<Gtk::UIManager> ui_manager_hidden() {
return ui_manager_hidden_;
};
void BuildMenu();
void BuildHiddenMenu();
protected:
Glib::RefPtr<Gtk::UIManager> ui_manager_menu_;
Glib::RefPtr<Gtk::ActionGroup> action_group_menu_;
Glib::RefPtr<Gtk::UIManager> ui_manager_hidden_;
Glib::RefPtr<Gtk::ActionGroup> action_group_hidden_;
private:
Keybindings::Model model_;
}; };
Glib::RefPtr<Gtk::ActionGroup> action_group_hidden() {
return action_group_hidden_;
};
Glib::RefPtr<Gtk::UIManager> ui_manager_hidden() {
return ui_manager_hidden_;
};
void BuildMenu();
void BuildHiddenMenu();
protected:
Glib::RefPtr<Gtk::UIManager> ui_manager_menu_;
Glib::RefPtr<Gtk::ActionGroup> action_group_menu_;
Glib::RefPtr<Gtk::UIManager> ui_manager_hidden_;
Glib::RefPtr<Gtk::ActionGroup> action_group_hidden_;
private:
Keybindings::Model model_;
};//Controller
} }
#endif // JUCI_KEYBINDINGS_H_ #endif // JUCI_KEYBINDINGS_H_

145
juci/menu.cc

@ -1,160 +1,93 @@
#include "menu.h" #include "menu.h"
// VIEW
Menu::View::View(Gtk::Orientation orientation) : Menu::View::View(Gtk::Orientation orientation) :
view_(orientation) { view_(orientation) {
Gtk::MenuBar menutest;
}// view controller view_.pack_end(menutest);
}
Gtk::Box &Menu::View::view( Gtk::Box &Menu::View::view(
Glib::RefPtr<Gtk::UIManager> ui_manager) { Glib::RefPtr<Gtk::UIManager> ui_manager) {
view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK);
return view_; return view_;
} }
// CONTROLLER
Menu::Controller::Controller(Keybindings::Controller& keybindings) : Menu::Controller::Controller(Keybindings::Controller& keybindings) :
menu_view_(Gtk::ORIENTATION_VERTICAL), menu_view_(Gtk::ORIENTATION_VERTICAL),
keybindings_(keybindings) { keybindings_(keybindings) {
/* Add action to menues */
/* START file menu */
/* File-> New files end */
keybindings_.action_group_menu()->add(Gtk::Action::create("FileOpenFile", keybindings_.action_group_menu()->add(Gtk::Action::create("FileOpenFile",
Gtk::Stock::OPEN), Gtk::Stock::OPEN),
[this]() { [this]() {
OnFileOpenFile(); OnFileOpenFile();
}); });
keybindings_.action_group_menu()->add(Gtk::Action::create("FileOpenFolder", keybindings_.action_group_menu()->add(Gtk::Action::create("FileOpenFolder",
"Open folder"), "Open folder"),
[this]() { [this]() {
OnFileOpenFolder(); OnFileOpenFolder();
}); });
/* END file menu */
/* START edit menu */
keybindings_.action_group_menu()->add(Gtk::Action::create("EditMenu", keybindings_.action_group_menu()->add(Gtk::Action::create("EditMenu",
Gtk::Stock::EDIT)); Gtk::Stock::EDIT));
keybindings_.action_group_menu()->add(Gtk::Action::create("EditCopy",
Gtk::Stock::COPY),
[this]() {
OnEditCopy();
});
keybindings_.action_group_menu()->add(Gtk::Action::create("EditCut",
Gtk::Stock::CUT),
[this]() {
OnEditCut();
});
keybindings_.action_group_menu()->add(Gtk::Action::create("EditPaste",
Gtk::Stock::PASTE),
[this]() {
OnEditPaste();
});
/* END edit menu */
/* START window menu */
keybindings_.action_group_menu()->add(Gtk::Action::create("WindowMenu", keybindings_.action_group_menu()->add(Gtk::Action::create("WindowMenu",
"_Window")); "_Window"));
keybindings_.action_group_menu()->add(Gtk::Action::create("WindowSplitWindow", keybindings_.action_group_menu()->add(Gtk::Action::create("WindowSplitWindow",
"Split window"), "Split window"),
Gtk::AccelKey("<control><alt>S"), Gtk::AccelKey("<control><alt>S"),
[this]() { [this]() {
OnWindowSplitWindow(); OnWindowSplitWindow();
}); });
/* END window menu */
/* START Plugin menu */
keybindings_.action_group_menu()->add(Gtk::Action::create("PluginMenu", keybindings_.action_group_menu()->add(Gtk::Action::create("PluginMenu",
"_Plugins")); "_Plugins"));
/*Plugin->snippet*/
keybindings_.action_group_menu()->add(Gtk::Action::create("PluginSnippet", keybindings_.action_group_menu()->add(Gtk::Action::create("PluginSnippet",
"Snippet")); "Snippet"));
keybindings_.action_group_menu()->add(Gtk::Action::create("PluginAddSnippet", keybindings_.action_group_menu()->add(Gtk::Action::create("PluginAddSnippet",
"Add snippet"), "Add snippet"),
Gtk::AccelKey("<alt>space"), Gtk::AccelKey("<alt>space"),
[this]() { [this]() {
OnPluginAddSnippet(); OnPluginAddSnippet();
}); });
/* End snippet */
/* END plugin menu */
/* START help menu */
keybindings_.action_group_menu()->add(Gtk::Action::create("HelpMenu", keybindings_.action_group_menu()->add(Gtk::Action::create("HelpMenu",
Gtk::Stock::HELP)); Gtk::Stock::HELP));
keybindings_.action_group_menu()->add(Gtk::Action::create("HelpAbout", keybindings_.action_group_menu()->add(Gtk::Action::create("HelpAbout",
Gtk::Stock::ABOUT), Gtk::Stock::ABOUT),
[this]() { [this]() {
OnHelpAbout(); OnHelpAbout();
}); });
// Hidden actions
keybindings_.action_group_hidden()->add(Gtk::Action::create("Test"), keybindings_.action_group_hidden()->add(Gtk::Action::create("Test"),
Gtk::AccelKey("<control><alt>K"), Gtk::AccelKey("<control><alt>K"),
[this]() { [this]() {
OnHelpAbout(); OnHelpAbout();
}); });
keybindings_.BuildMenu(); keybindings_.BuildMenu();
keybindings_.BuildHiddenMenu(); keybindings_.BuildHiddenMenu();
} // Controller
/* END help menu */
}
Gtk::Box &Menu::Controller::view() { Gtk::Box &Menu::Controller::view() {
return menu_view_.view(keybindings_.ui_manager_menu()); return menu_view_.view(keybindings_.ui_manager_menu());
} }
void Menu::Controller::OnPluginAddSnippet() { void Menu::Controller::OnPluginAddSnippet() {
//TODO(Forgi add you snippet magic code) //TODO(Forgi add you snippet magic code)
std::cout << "Add snipper" << std::endl; std::cout << "Add snipper" << std::endl;
juci_api::py::LoadPlugin("snippet"); juci_api::py::LoadPlugin("snippet");
} }
// void Menu::Controller::LoadPlugin() {
// juci_api::py::LoadPlugin("plugin_name");
// }
void Menu::Controller::OnFileOpenFile() { void Menu::Controller::OnFileOpenFile() {
std::cout << "Open file clicked" << std::endl; std::cout << "Open file clicked" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }
void Menu::Controller::OnFileOpenFolder() { void Menu::Controller::OnFileOpenFolder() {
std::cout << "Open folder clicked" << std::endl; std::cout << "Open folder clicked" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }
void Menu::Controller::OnEditCopy() {
std::cout << "Clicked copy" << std::endl;
//TODO(Oyvang) Legg til funksjon
}
void Menu::Controller::OnEditCut() { void Menu::Controller::OnEditCut() {
std::cout << "Clicked cut" << std::endl; std::cout << "Clicked cut" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }
void Menu::Controller::OnEditPaste() {
std::cout << "Clicked paste" << std::endl;
//TODO(Oyvang) Legg til funksjon
}
void Menu::Controller::OnEditFind() { void Menu::Controller::OnEditFind() {
std::cout << "Clicked find" << std::endl; std::cout << "Clicked find" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }
void Menu::Controller::OnWindowSplitWindow() { void Menu::Controller::OnWindowSplitWindow() {
std::cout << "Clicked split window" << std::endl; std::cout << "Clicked split window" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }
void Menu::Controller::OnHelpAbout() { void Menu::Controller::OnHelpAbout() {
std::cout << "Clicked about" << std::endl; std::cout << "Clicked about" << std::endl;
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon

74
juci/menu.h

@ -6,54 +6,32 @@
#include "keybindings.h" #include "keybindings.h"
#include "api.h" #include "api.h"
namespace Menu { namespace Menu {
class View { class View {
public: public:
explicit View(Gtk::Orientation orient); explicit View(Gtk::Orientation orient);
Gtk::Box &view(Glib::RefPtr<Gtk::UIManager> ui_manager);
Gtk::Box &view(Glib::RefPtr<Gtk::UIManager> ui_manager); protected:
Gtk::Box view_;
protected: }; // class View
Gtk::Box view_; class Controller {
}; // class View public:
explicit Controller(Keybindings::Controller& keybindings);
class Controller { Gtk::Box &view();
public: private:
explicit Controller(Keybindings::Controller& keybindings); Keybindings::Controller &keybindings_;
View menu_view_;
Gtk::Box &view(); void OnFileNewEmptyfile();
void OnFileNewCCFile();
private: void OnFileNewHeaderFile();
Keybindings::Controller keybindings_; void OnFileOpenFile();
View menu_view_; void OnFileOpenFolder();
void OnPluginAddSnippet();
void OnFileNewEmptyfile(); void OnWindowCloseTab();
void OnEditCut();
// Signal handlers void OnEditFind();
void OnFileNewCCFile(); void OnWindowSplitWindow();
void OnHelpAbout();
void OnFileNewHeaderFile(); }; // class Controller
void OnFileOpenFile();
void OnFileOpenFolder();
void OnPluginAddSnippet();
void OnWindowCloseTab();
void OnEditCopy();
void OnEditCut();
void OnEditPaste();
void OnEditFind();
void OnWindowSplitWindow();
void OnHelpAbout();
}; // class Controller
} // namespace Menu } // namespace Menu
#endif // JUCI_MENU_H_ #endif // JUCI_MENU_H_

129
juci/notebook.cc

@ -9,66 +9,81 @@ Gtk::Box& Notebook::View::view() {
view_.pack_start(notebook_); view_.pack_start(notebook_);
return view_; return view_;
} }
Notebook::Controller::Controller(Keybindings::Controller& keybindings){ Notebook::Controller::Controller(Keybindings::Controller& keybindings){
scrolledwindow_vec_.push_back(new Gtk::ScrolledWindow()); scrolledwindow_vec_.push_back(new Gtk::ScrolledWindow());
source_vec_.push_back(new Source::Controller); source_vec_.push_back(new Source::Controller);
scrolledwindow_vec_.back()->add(source_vec_.back()->view()); scrolledwindow_vec_.back()->add(source_vec_.back()->view());
source_vec_.back()->OnNewEmptyFile(); source_vec_.back()->OnNewEmptyFile();
view_.notebook().append_page(*scrolledwindow_vec_.back(), "juCi++"); view_.notebook().append_page(*scrolledwindow_vec_.back(), "juCi++");
refClipboard = Gtk::Clipboard::get();
keybindings.action_group_menu()->add(Gtk::Action::create("FileMenu", keybindings.action_group_menu()->add(Gtk::Action::create("FileMenu",
Gtk::Stock::FILE)); Gtk::Stock::FILE));
/* File->New files */ /* File->New files */
keybindings.action_group_menu()->add(Gtk::Action::create("FileNew", "New")); keybindings.action_group_menu()->add(Gtk::Action::create("FileOpenFile",
Gtk::Stock::OPEN),
[this]() {
OnOpenFile();
});
keybindings.action_group_menu()->add(Gtk::Action::create("FileNewStandard", keybindings.action_group_menu()->add(Gtk::Action::create("FileNewStandard",
Gtk::Stock::NEW, "New empty file", "Create a new file"), Gtk::Stock::NEW,
[this]() { "New empty file",
OnFileNewEmptyfile(); "Create a new file"),
}); [this]() {
OnFileNewEmptyfile();
});
keybindings.action_group_menu()->add(Gtk::Action::create("FileNewCC", keybindings.action_group_menu()->add(Gtk::Action::create("FileNewCC",
"New cc file"), "New cc file"),
Gtk::AccelKey("<control><alt>c"), Gtk::AccelKey("<control><alt>c"),
[this]() { [this]() {
OnFileNewCCFile(); OnFileNewCCFile();
}); });
keybindings.action_group_menu()->add(Gtk::Action::create("FileNewH", keybindings.action_group_menu()->add(Gtk::Action::create("FileNewH",
"New h file"), "New h file"),
Gtk::AccelKey("<control><alt>h"), Gtk::AccelKey("<control><alt>h"),
[this]() { [this]() {
OnFileNewHeaderFile(); OnFileNewHeaderFile();
}); });
keybindings.action_group_menu()->add(Gtk::Action::create("WindowCloseTab", keybindings.action_group_menu()->add(Gtk::Action::create("WindowCloseTab",
"Close tab"), "Close tab"),
Gtk::AccelKey("<control>w"), Gtk::AccelKey("<control>w"),
[this]() { [this]() {
OnCloseCurrentPage(); OnCloseCurrentPage();
}); });
keybindings.action_group_menu()->add(Gtk::Action::create("EditFind", keybindings.action_group_menu()->add(Gtk::Action::create("EditFind",
Gtk::Stock::FIND), Gtk::Stock::FIND),
[this]() { [this]() {
// OnEditFind(); //TODO(Oyvang, Zalox, Forgi)Create function OnEditFind();
}); });
keybindings.action_group_menu()->add(Gtk::Action::create("EditCopy",
entry_.view_.entry().signal_activate().connect( Gtk::Stock::COPY),
[this]() { [this]() {
OnNewPage(entry_.view_.entry().get_text()); OnEditCopy();
entry_.OnHideEntries(); });
}); keybindings.action_group_menu()->add(Gtk::Action::create("EditCut",
} Gtk::Stock::CUT),
[this]() {
OnEditCut();
});
keybindings.action_group_menu()->add(Gtk::Action::create("EditPaste",
Gtk::Stock::PASTE),
[this]() {
OnEditPaste();
});
entry_.view_.entry().signal_activate().connect(
[this]() {
OnNewPage(entry_.view_.entry().get_text());
entry_.OnHideEntries();
});
}//Constructor
Gtk::Box& Notebook::Controller::view() { Gtk::Box& Notebook::Controller::view() {
return view_.view(); return view_.view();
} }
Gtk::Box& Notebook::Controller::entry_view(){ Gtk::Box& Notebook::Controller::entry_view(){
return entry_.view(); return entry_.view();
} }
void Notebook::Controller::OnNewPage(std::string name) { void Notebook::Controller::OnNewPage(std::string name) {
scrolledwindow_vec_.push_back(new Gtk::ScrolledWindow()); scrolledwindow_vec_.push_back(new Gtk::ScrolledWindow());
source_vec_.push_back(new Source::Controller); source_vec_.push_back(new Source::Controller);
scrolledwindow_vec_.back()->add(source_vec_.back()->view()); scrolledwindow_vec_.back()->add(source_vec_.back()->view());
@ -76,10 +91,8 @@ void Notebook::Controller::OnNewPage(std::string name) {
view_.notebook().append_page(*scrolledwindow_vec_.back(), name); view_.notebook().append_page(*scrolledwindow_vec_.back(), name);
view_.notebook().show_all_children(); view_.notebook().show_all_children();
view_.notebook().set_focus_child(*scrolledwindow_vec_.back()); view_.notebook().set_focus_child(*scrolledwindow_vec_.back());
view().show_all_children();
view_.notebook().set_current_page(view_.notebook().get_n_pages()-1); view_.notebook().set_current_page(view_.notebook().get_n_pages()-1);
} }
void Notebook::Controller::OnCloseCurrentPage() { void Notebook::Controller::OnCloseCurrentPage() {
//TODO (oyvang, zalox, forgi) Save a temp file, in case you close one you dont want to close? //TODO (oyvang, zalox, forgi) Save a temp file, in case you close one you dont want to close?
int page = view_.notebook().get_current_page(); int page = view_.notebook().get_current_page();
@ -89,20 +102,42 @@ void Notebook::Controller::OnCloseCurrentPage() {
source_vec_.erase(source_vec_.begin()+ page); source_vec_.erase(source_vec_.begin()+ page);
scrolledwindow_vec_.erase(scrolledwindow_vec_.begin()+page); scrolledwindow_vec_.erase(scrolledwindow_vec_.begin()+page);
} }
void Notebook::Controller::OnFileNewEmptyfile() { void Notebook::Controller::OnFileNewEmptyfile() {
entry_.OnShowSetFilenName(""); entry_.OnShowSetFilenName("");
//TODO(Oyvang) Legg til funksjon for Entry file name.extension
} }
void Notebook::Controller::OnFileNewCCFile() { void Notebook::Controller::OnFileNewCCFile() {
entry_.OnShowSetFilenName(".cc"); entry_.OnShowSetFilenName(".cc");
//TODO(Oyvang) Legg til funksjon for Entry file name.extension
} }
void Notebook::Controller::OnFileNewHeaderFile() { void Notebook::Controller::OnFileNewHeaderFile() {
entry_.OnShowSetFilenName(".h"); entry_.OnShowSetFilenName(".h");
//TODO(Oyvang) Legg til funksjon for Entry file name.extension }
void Notebook::Controller::OnEditCopy() {
if(view_.notebook().get_n_pages()!=0){
int source_pos = view_.notebook().get_current_page();
Glib::RefPtr<Gtk::TextBuffer> buffer = source_vec_.at(source_pos)
->view().get_buffer();
buffer->copy_clipboard(refClipboard);
}
}
void Notebook::Controller::OnEditPaste() {
if(view_.notebook().get_n_pages()!=0){
int source_pos = view_.notebook().get_current_page();
Glib::RefPtr<Gtk::TextBuffer> buffer = source_vec_.at(source_pos)
->view().get_buffer();
buffer->paste_clipboard(refClipboard);
}
}
void Notebook::Controller::OnEditCut() {
if(view_.notebook().get_n_pages()!=0){
int source_pos = view_.notebook().get_current_page();
Glib::RefPtr<Gtk::TextBuffer> buffer = source_vec_.at(source_pos)
->view().get_buffer();
buffer->cut_clipboard(refClipboard);
}
}
void Notebook::Controller::OnOpenFile() {
std::cout << "fired" << std::endl;
} }

58
juci/notebook.h

@ -7,32 +7,38 @@
#include "source.h" #include "source.h"
namespace Notebook { namespace Notebook {
class View { class View {
public: public:
View(); View();
Gtk::Box& view(); Gtk::Box& view();
Gtk::Notebook& notebook(){return notebook_;} Gtk::Notebook& notebook(){return notebook_;}
protected: protected:
Gtk::Box view_; Gtk::Box view_;
Gtk::Notebook notebook_; Gtk::Notebook notebook_;
}; };
class Controller { class Controller {
public: public:
Controller(Keybindings::Controller& keybindings); Controller(Keybindings::Controller& keybindings);
Gtk::Box& view(); Gtk::Box& view();
Gtk::Box& entry_view(); Gtk::Box& entry_view();
void OnNewPage(std::string name); void OnNewPage(std::string name);
void OnCloseCurrentPage(); void OnCloseCurrentPage();
private: private:
View view_; View view_;
Entry::Controller entry_; Entry::Controller entry_;
std::vector<Source::Controller*> source_vec_; std::vector<Source::Controller*> source_vec_;
std::vector<Gtk::ScrolledWindow*> scrolledwindow_vec_; std::vector<Gtk::ScrolledWindow*> scrolledwindow_vec_;
void OnFileNewEmptyfile(); Glib::RefPtr<Gtk::Clipboard> refClipboard;
void OnFileNewCCFile(); std::list<Gtk::TargetEntry> listTargets;
void OnFileNewHeaderFile(); void OnFileNewEmptyfile();
};// class controller void OnFileNewCCFile();
} // namespace notebook void OnFileNewHeaderFile();
void OnEditCopy();
void OnEditPaste();
void OnEditCut();
void OnOpenFile();
}; // class controller
} // namespace Notebook
#endif // JUCI_NOTEBOOK_H_ #endif // JUCI_NOTEBOOK_H_

16
juci/window.cc

@ -5,14 +5,13 @@ Window::Window() :
notebook_(keybindings_), notebook_(keybindings_),
menu_(keybindings_){ menu_(keybindings_){
set_title("juCi++"); set_title("juCi++");
set_default_size(600, 00); set_default_size(600, 400);
add(window_box_); add(window_box_);
keybindings_.action_group_menu()->add(Gtk::Action::create("FileQuit", keybindings_.action_group_menu()->add(Gtk::Action::create("FileQuit",
Gtk::Stock::QUIT), Gtk::Stock::QUIT),
[this]() { [this]() {
OnWindowHide(); OnWindowHide();
}); });
add_accel_group(keybindings_.ui_manager_menu()->get_accel_group()); add_accel_group(keybindings_.ui_manager_menu()->get_accel_group());
add_accel_group(keybindings_.ui_manager_hidden()->get_accel_group()); add_accel_group(keybindings_.ui_manager_hidden()->get_accel_group());
@ -20,10 +19,7 @@ Window::Window() :
window_box_.pack_start(notebook_.entry_view(), Gtk::PACK_SHRINK); window_box_.pack_start(notebook_.entry_view(), Gtk::PACK_SHRINK);
window_box_.pack_start(notebook_.view()); window_box_.pack_start(notebook_.view());
show_all_children(); show_all_children();
} // Window constructor
} // Window constructor
void Window::OnWindowHide() { void Window::OnWindowHide() {
hide(); hide();
} }

5
juci/window.h

@ -10,8 +10,6 @@ class Window : public Gtk::Window {
public: public:
Window(); Window();
Gtk::Box window_box_; Gtk::Box window_box_;
private: private:
Keybindings::Controller keybindings_; Keybindings::Controller keybindings_;
Menu::Controller menu_; Menu::Controller menu_;
@ -19,9 +17,6 @@ private:
//signal handlers //signal handlers
void OnWindowHide(); void OnWindowHide();
}; };
#endif // JUCI_WINDOW_H_ #endif // JUCI_WINDOW_H_

Loading…
Cancel
Save