Browse Source

fixed quit_system bug

master
oyvang 11 years ago
parent
commit
1144ce805a
  1. 5
      juci/juci.cc
  2. 11
      juci/juci.h
  3. 4
      juci/keybindings.h
  4. 17
      juci/menu.cc
  5. 33
      juci/menu.h
  6. 14
      juci/window.cc

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);
} }

11
juci/juci.h

@ -10,15 +10,20 @@
class Window : public Gtk::Window { class Window : public Gtk::Window {
public: public:
Window(); Window();
virtual ~Window() {}
Gtk::Box window_box_; virtual ~Window() {
}
std::shared_ptr<Source::Controller> source(); 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_;
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_;

17
juci/menu.cc

@ -55,7 +55,7 @@ Menu::View::View(Gtk::Orientation 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));
@ -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)
} }

33
juci/menu.h

@ -9,8 +9,13 @@ namespace Menu {
class Model { class Model {
public: public:
Model(); Model();
virtual ~Model(); virtual ~Model();
std::string ui_string() { return ui_string_; }
std::string ui_string() {
return ui_string_;
}
private: private:
std::string ui_string_; std::string ui_string_;
}; // class Model }; // class Model
@ -18,8 +23,10 @@ namespace Menu {
class View { class View {
public: public:
explicit View(Gtk::Orientation orient); explicit View(Gtk::Orientation orient);
virtual ~View(); virtual ~View();
Gtk::Box& view(Glib::RefPtr<Gtk::UIManager> ui_manager);
Gtk::Box &view(Glib::RefPtr<Gtk::UIManager> ui_manager);
protected: protected:
Gtk::Box view_; Gtk::Box view_;
@ -28,25 +35,41 @@ namespace Menu {
class Controller { class Controller {
public: public:
explicit Controller(Keybindings::Controller keybindings); explicit Controller(Keybindings::Controller keybindings);
virtual ~Controller(); virtual ~Controller();
Gtk::Box& view();
Gtk::Box &view();
private: private:
Keybindings::Controller keybindings_; Keybindings::Controller keybindings_;
View menu_view_; View menu_view_;
Model menu_model_; Model menu_model_;
void OnFileNewEmptyfile(); /*Signal handlers*/
void OnFileNewEmptyfile();
/*Signal handlers*/
void OnFileNewCCFile(); void OnFileNewCCFile();
void OnFileNewHeaderFile(); void OnFileNewHeaderFile();
void OnFileOpenFile(); void OnFileOpenFile();
void OnFileOpenFolder(); void OnFileOpenFolder();
void OnSystemQuit();
void OnPluginAddSnippet(); void OnPluginAddSnippet();
void OnWindowCloseTab(); void OnWindowCloseTab();
void OnEditCopy(); void OnEditCopy();
void OnEditCut(); void OnEditCut();
void OnEditPaste(); void OnEditPaste();
void OnEditFind(); void OnEditFind();
void OnWindowSplitWindow(); void OnWindowSplitWindow();
void OnHelpAbout(); void OnHelpAbout();
}; // class Controller }; // class Controller
} // namespace Menu } // namespace Menu

14
juci/window.cc

@ -1,18 +1,26 @@
#include "juci.h" #include "juci.h"
Window::Window() : Window::Window() :
window_box_(Gtk::ORIENTATION_HORIZONTAL), window_box_(Gtk::ORIENTATION_HORIZONTAL),
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()); // window_box_.add(*source_.sourceview());
add(window_box_); add(window_box_);
keybindings_.action_group()->add(Gtk::Action::create("FileQuit",
Gtk::Stock::QUIT),
[this]() {
OnSystemQuit();
});
add_accel_group(keybindings_.ui_manager()->get_accel_group()); add_accel_group(keybindings_.ui_manager()->get_accel_group());
//Add views under here
window_box_.pack_start(menu_.view()); window_box_.pack_start(menu_.view());
show_all_children(); show_all_children();
} }
std::shared_ptr<Source::Controller> Window::source() { std::shared_ptr<Source::Controller> Window::source() {
return std::shared_ptr<Source::Controller>(&source_); return std::shared_ptr<Source::Controller>(&source_);
} }
void Window::OnSystemQuit() {
hide();
}
Loading…
Cancel
Save