Browse Source

BPP21 #comment merged master #time 10m

merge-requests/365/head
forgie 11 years ago
parent
commit
18e21cdce6
  1. 5
      juci/CMakeLists.txt
  2. 5
      juci/juci.cc
  3. 10
      juci/juci.h
  4. 4
      juci/keybindings.h
  5. 25
      juci/menu.cc
  6. 109
      juci/menu.h
  7. 41
      juci/source.cc
  8. 8
      juci/source.h
  9. 45
      juci/window.cc

5
juci/CMakeLists.txt

@ -62,12 +62,13 @@ endif()
# name of the executable on Windows will be example.exe # name of the executable on Windows will be example.exe
add_executable(${project_name} add_executable(${project_name}
#list of every needed file to create the executable #list of every needed file to create the executable
juci.h
juci.cc
keybindings keybindings
menu menu
source source
window window
juci
api api
#there is no need for extentions #there is no need for extentions

5
juci/juci.cc

@ -1,9 +1,14 @@
#include "juci.h" #include "juci.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");
// app->set_flags(Gio::APPLICATION_NON_UNIQUE);
Window window; Window window;
return app->run(window); return app->run(window);
} }

10
juci/juci.h

@ -1,4 +1,4 @@
/*juCi++ main header file*/ //juCi++ main header file
#ifndef JUCI_JUCI_H_ #ifndef JUCI_JUCI_H_
#define JUCI_JUCI_H_ #define JUCI_JUCI_H_
@ -11,14 +11,16 @@ class Window : public Gtk::Window {
public: public:
Window(); Window();
virtual ~Window() {} virtual ~Window() {}
Gtk::Box window_box_;
std::shared_ptr<Source::Controller> source();
private: private:
Keybindings::Controller keybindings_; Keybindings::Controller keybindings_;
Menu::Controller menu_; Menu::Controller menu_;
Source::Controller& source();
Source::Controller source_; Source::Controller source_;
Gtk::Box window_box_;
/*signal handler*/ /*signal handler*/
void onSystemQuit(); void OnSystemQuit();
}; };
#endif // JUCI_JUCI_H_ #endif // JUCI_JUCI_H_

4
juci/keybindings.h

@ -2,10 +2,10 @@
#include "gtkmm.h" #include "gtkmm.h"
namespace Keybindings { namespace Keybindings {
class Controller { class Controller {
public: public:
Controller(); Controller();
virtual ~Controller(); virtual ~Controller();
Glib::RefPtr<Gtk::ActionGroup> action_group() { Glib::RefPtr<Gtk::ActionGroup> action_group() {
@ -15,11 +15,11 @@ namespace Keybindings {
Glib::RefPtr<Gtk::UIManager> ui_manager() { Glib::RefPtr<Gtk::UIManager> ui_manager() {
return ui_manager_; return ui_manager_;
}; };
void set_ui_manger_string(std::string ui_string); void set_ui_manger_string(std::string ui_string);
void set_ui_manager_action_group(Glib::RefPtr<Gtk::ActionGroup> action_group); void set_ui_manager_action_group(Glib::RefPtr<Gtk::ActionGroup> action_group);
protected: protected:
Glib::RefPtr<Gtk::UIManager> ui_manager_; Glib::RefPtr<Gtk::UIManager> ui_manager_;
Glib::RefPtr<Gtk::ActionGroup> action_group_; Glib::RefPtr<Gtk::ActionGroup> action_group_;

25
juci/menu.cc

@ -7,7 +7,7 @@
Menu::Model::Model() { Menu::Model::Model() {
ui_string_ = ui_string_ =
"<ui> " "<ui> "
" <menubar name='MenuBar'> " " <menubar name='MenuBar'> "
" <menu action='FileMenu'> " " <menu action='FileMenu'> "
" <menu action='FileNew'> " " <menu action='FileNew'> "
@ -52,11 +52,11 @@ Menu::Model::~Model() {
Menu::View::View(Gtk::Orientation orientation) : Menu::View::View(Gtk::Orientation orientation) :
view_(orientation) { view_(orientation) {
} }
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_;
} }
@ -70,7 +70,7 @@ Menu::View::~View() {
Menu::Controller::Controller(Keybindings::Controller keybindings) : Menu::Controller::Controller(Keybindings::Controller keybindings) :
menu_view_(Gtk::ORIENTATION_VERTICAL), menu_view_(Gtk::ORIENTATION_VERTICAL),
menu_model_(), menu_model_(),
keybindings_(keybindings){ keybindings_(keybindings) {
/* Add action to menues */ /* Add action to menues */
/* START file menu */ /* START file menu */
keybindings_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE)); keybindings_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE));
@ -79,7 +79,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) :
keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard", keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard",
Gtk::Stock::NEW, "New empty file", "Create a new file"), Gtk::Stock::NEW, "New empty file", "Create a new file"),
[this]() { [this]() {
OnFileNewEmptyfile(); OnFileNewEmptyfile();
}); });
keybindings_.action_group()->add(Gtk::Action::create("FileNewCC", keybindings_.action_group()->add(Gtk::Action::create("FileNewCC",
Gtk::Stock::NEW, "New cc file", "Create a new cc file"), Gtk::Stock::NEW, "New cc file", "Create a new cc file"),
@ -87,7 +87,6 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) :
[this]() { [this]() {
OnFileNewCCFile(); OnFileNewCCFile();
}); });
keybindings_.action_group()->add(Gtk::Action::create("FileNewH", keybindings_.action_group()->add(Gtk::Action::create("FileNewH",
Gtk::Stock::NEW, "New h file", "Create a new h file"), Gtk::Stock::NEW, "New h file", "Create a new h file"),
Gtk::AccelKey("<control><alt>h"), Gtk::AccelKey("<control><alt>h"),
@ -103,10 +102,6 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) :
[this]() { [this]() {
OnFileOpenFolder(); OnFileOpenFolder();
}); });
keybindings_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
[this]() {
OnSystemQuit();
});
/* END file menu */ /* END file menu */
/* START edit menu */ /* START edit menu */
keybindings_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT)); keybindings_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT));
@ -169,7 +164,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) :
Menu::Controller::~Controller() { Menu::Controller::~Controller() {
} }
Gtk::Box& Menu::Controller::view() { Gtk::Box &Menu::Controller::view() {
return menu_view_.view(keybindings_.ui_manager()); return menu_view_.view(keybindings_.ui_manager());
} }
@ -188,12 +183,6 @@ void Menu::Controller::OnFileNewHeaderFile() {
//TODO(Oyvang) Legg til funksjon //TODO(Oyvang) Legg til funksjon
} }
void Menu::Controller::OnSystemQuit() {
//TODO(Oyvang, Zalox, Forgie) Add everything that needs to be done before quiting
/*Quit the system*/
}
void Menu::Controller::OnPluginAddSnippet() { void Menu::Controller::OnPluginAddSnippet() {
std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code)
juci_api::py::LoadPlugin("snippet"); juci_api::py::LoadPlugin("snippet");

109
juci/menu.h

@ -8,48 +8,71 @@
namespace Menu { namespace Menu {
class Model { class Model {
public: public:
Model(); Model();
virtual ~Model();
std::string ui_string() { return ui_string_; } virtual ~Model();
private:
std::string ui_string_; std::string ui_string() {
}; // class Model return ui_string_;
}
class View {
public: private:
explicit View(Gtk::Orientation orient); std::string ui_string_;
virtual ~View(); }; // class Model
Gtk::Box& view(Glib::RefPtr<Gtk::UIManager> ui_manager);
class View {
protected: public:
Gtk::Box view_; explicit View(Gtk::Orientation orient);
}; // class View
// controller virtual ~View();
class Controller {
public: Gtk::Box &view(Glib::RefPtr<Gtk::UIManager> ui_manager);
explicit Controller(Keybindings::Controller keybindings);
virtual ~Controller(); protected:
Gtk::Box& view(); Gtk::Box view_;
private: }; // class View
Keybindings::Controller keybindings_; // controller
View menu_view_; class Controller {
Model menu_model_; public:
void OnFileNewEmptyfile(); /*Signal handlers*/ explicit Controller(Keybindings::Controller keybindings);
void OnFileNewCCFile();
void OnFileNewHeaderFile(); virtual ~Controller();
void OnFileOpenFile();
void OnFileOpenFolder(); Gtk::Box &view();
void OnSystemQuit();
void OnPluginAddSnippet(); private:
void OnWindowCloseTab(); Keybindings::Controller keybindings_;
void OnEditCopy(); View menu_view_;
void OnEditCut(); Model menu_model_;
void OnEditPaste();
void OnEditFind(); void OnFileNewEmptyfile();
void OnWindowSplitWindow();
void OnHelpAbout(); /*Signal handlers*/
}; // class Controller void OnFileNewCCFile();
void OnFileNewHeaderFile();
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_

41
juci/source.cc

@ -1,47 +1,44 @@
#include "source.h" #include "source.h"
#include <iostream> #include <iostream>
using namespace std;
////////////// //////////////
//// View //// //// View ////
////////////// //////////////
Source::View::View() { Source::View::View() {
cout << "View construktor run" << endl; std::cout << "View constructor run" << std::endl;
} }
void Source::View::UpdateLine(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) { void Source::View::UpdateLine(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) {
cout << "Update line called. linum: " << mark->get_iter().get_line() << endl; std::cout << "Update line called. linum: ";
std::cout << mark->get_iter().get_line() << std::endl;
} }
/////////////// ///////////////
//// Model //// //// Model ////
/////////////// ///////////////
Source::Model::Model(){ Source::Model::Model() {
cout << "Model construktor run" << endl; std::cout << "Model constructor run" << std::endl;
} }
//////////////////// ////////////////////
//// Controller //// //// Controller ////
//////////////////// ////////////////////
/** // Source::Controller::Controller()
* // Constructor for Controller
*/
Source::Controller::Controller() { Source::Controller::Controller() {
cout << "Controller construktor run" << endl; std::cout << "Controller constructor run" << std::endl;
} }
/** // Source::Controller::view()
* // return shared_ptr to the view
*/ Source::View& Source::Controller::view() {
std::shared_ptr<Source::View> Source::Controller::sourceview() { return view_;
sourceview();
return std::shared_ptr<Source::View>(&sourceview_);
} }
/** // Source::Controller::model()
* // return shared_ptr to the model()
*/ Source::Model& Source::Controller::model() {
void Source::Controller::OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark){ return model_;
} }
// Source::Controller::OnLineEdit()
// fired when a line in the buffer is edited
void Source::Controller::OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark) {}

8
juci/source.h

@ -21,11 +21,15 @@ namespace Source {
class Controller { class Controller {
public: public:
Controller(); Controller();
std::shared_ptr<Source::View> sourceview(); View& view();
Model& model();
private: private:
void OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark); void OnLineEdit(Glib::RefPtr<Gtk::TextBuffer::Mark> mark);
protected: protected:
View sourceview_; View view_;
Model model_;
}; // class Controller }; // class Controller
} // namespace Source } // namespace Source
#endif // JUCI_SOURCE_H_ #endif // JUCI_SOURCE_H_

45
juci/window.cc

@ -1,18 +1,27 @@
#include "juci.h" #include "juci.h"
Window::Window() : Window::Window() :
window_box_(Gtk::ORIENTATION_HORIZONTAL), window_box_(Gtk::ORIENTATION_VERTICAL),
menu_(keybindings_) { menu_(keybindings_) {
set_title("example juCi++"); set_title("juCi++");
set_default_size(600, 600); set_default_size(600, 600);
// window_box_.add(*source_.sourceview()); add(window_box_);
add(window_box_); keybindings_.action_group()->add(Gtk::Action::create("FileQuit",
add_accel_group(keybindings_.ui_manager()->get_accel_group()); Gtk::Stock::QUIT),
window_box_.pack_start(menu_.view()); [this]() {
show_all_children(); OnSystemQuit();
});
}
add_accel_group(keybindings_.ui_manager()->get_accel_group());
std::shared_ptr<Source::Controller> Window::source() { window_box_.pack_start(menu_.view(), Gtk::PACK_SHRINK);
return std::shared_ptr<Source::Controller>(&source_); window_box_.pack_start(source().view());
} show_all_children();
}
Source::Controller& Window::source() {
return source_;
}
void Window::OnSystemQuit() {
hide();
}

Loading…
Cancel
Save