diff --git a/src/application.cpp b/src/application.cpp new file mode 100644 index 0000000..4d79a74 --- /dev/null +++ b/src/application.cpp @@ -0,0 +1,58 @@ +module; +#include + +#include +export module larra.application; +import larra.main_window; + +namespace larra { + +export struct Application : Gtk::Application { + Application() : Gtk::Application("org.larra.larra") { + Glib::set_application_name("Larra"); + }; + static auto create() -> Glib::RefPtr { + return Glib::make_refptr_for_instance(new Application{}); // NOLINT + }; + auto on_startup() -> void final { + this->Gtk::Application::on_startup(); + this->add_action("preferences", sigc::mem_fun(*this, &Application::OnClickPreferences)); + this->add_action("accounts", sigc::mem_fun(*this, &Application::OnClickManageAccounts)); + this->add_action("about", sigc::mem_fun(*this, &Application::OnClickAbout)); + + auto gmenu = Gio::Menu::create(); + auto larraMenu = Gio::Menu::create(); + larraMenu->append("Preferences", "app.preferences"); + auto accountsMenu = Gio::Menu::create(); + accountsMenu->append("Manage accounts", "app.accounts"); + auto helpMenu = Gio::Menu::create(); + helpMenu->append("About", "app.about"); + + gmenu->append_submenu("Larra", larraMenu); + gmenu->append_submenu("Accounts", accountsMenu); + gmenu->append_submenu("Help", helpMenu); + this->set_menubar(gmenu); + }; + + auto on_activate() -> void final { + auto win = new MainWindow{}; // NOLINT + this->add_window(*win); + win->signal_hide().connect([win] { + delete win; // NOLINT + }); + win->set_show_menubar(); + win->set_visible(true); + }; + + auto OnClickPreferences() -> void { + + }; + + auto OnClickManageAccounts() -> void { + + }; + + auto OnClickAbout() -> void {}; +}; + +} // namespace larra diff --git a/src/main.cpp b/src/main.cpp index a536faf..37f6fe0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,7 @@ -module; -#include export module larra.main; -import larra.library; -import larra.main_window; +import larra.application; auto main(int argc, char* argv[]) -> int { - auto app = Gtk::Application::create("org.larra.larra"); - return app->make_window_and_run(argc, argv); + auto app = larra::Application::create(); + return app->run(argc, argv); }; diff --git a/src/main_window.cpp b/src/main_window.cpp index ab1caa9..b194dac 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -2,9 +2,20 @@ module; #include export module larra.main_window; -export struct MainWindow : public Gtk::Window { +namespace larra { + +export struct MainWindow : Gtk::ApplicationWindow { + Gtk::Box main; + + Gtk::Box leftPanel{Gtk::Orientation::VERTICAL}; + Gtk::Box accounts{Gtk::Orientation::VERTICAL}; + MainWindow() { - this->set_title("XMPP Client"); - this->set_default_size(200, 200); - }; + this->set_title("Larra"); + auto settings = Gtk::Settings::get_default(); + this->main.append(this->leftPanel); + this->set_child(this->main); + } }; + +} // namespace larra