summaryrefslogtreecommitdiff
path: root/adw
diff options
context:
space:
mode:
Diffstat (limited to 'adw')
-rw-r--r--adw/CMakeLists.txt22
-rw-r--r--adw/include/turns/adw/application.hpp55
-rw-r--r--adw/include/turns/adw/wrap_init.hpp9
-rw-r--r--adw/src/application.cpp102
-rw-r--r--adw/src/wrap_init.cpp21
5 files changed, 209 insertions, 0 deletions
diff --git a/adw/CMakeLists.txt b/adw/CMakeLists.txt
new file mode 100644
index 0000000..9ac563a
--- /dev/null
+++ b/adw/CMakeLists.txt
@@ -0,0 +1,22 @@
+add_library("adw"
+ "src/application.cpp"
+ "src/wrap_init.cpp"
+)
+
+add_library("turns::adw" ALIAS "adw")
+
+target_include_directories("adw" PUBLIC
+ "include"
+)
+
+target_compile_options("adw" PUBLIC
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wall>"
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wextra>"
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-Werror>"
+ "$<$<CXX_COMPILER_ID:GNU,Clang>:-pedantic-errors>"
+)
+
+target_link_libraries("adw" PUBLIC
+ "PkgConfig::adwaita"
+ "PkgConfig::gtkmm"
+)
diff --git a/adw/include/turns/adw/application.hpp b/adw/include/turns/adw/application.hpp
new file mode 100644
index 0000000..26bec41
--- /dev/null
+++ b/adw/include/turns/adw/application.hpp
@@ -0,0 +1,55 @@
+#ifndef TURNS_ADW_APPLICATION_HPP
+#define TURNS_ADW_APPLICATION_HPP
+
+#include <glibmm/refptr.h>
+#include <glibmm/ustring.h>
+
+#include <giomm/application.h>
+
+#include <gtkmm/application.h>
+
+using AdwApplication = struct _AdwApplication;
+
+namespace turns::adw
+{
+ struct Application_Class;
+
+ struct Application : Gtk::Application
+ {
+ Application(Application && other) noexcept = default;
+ auto operator=(Application && other) noexcept -> Application & = default;
+
+ Application(Application const & other) = delete;
+ auto operator=(Application const & other) noexcept -> Application & = delete;
+
+ auto static get_type() -> GType;
+ auto static get_base_type() -> GType;
+
+ template<typename Self>
+ auto gobj(this Self && self) noexcept
+ {
+ return reinterpret_cast<AdwApplication *>(self.gobject_);
+ }
+
+ auto gobj_copy() -> AdwApplication *;
+
+ auto static create(Glib::ustring const & id = {},
+ Gio::Application::Flags flags = Gio::Application::Flags::NONE) -> Glib::RefPtr<Application>;
+
+ protected:
+ explicit Application(Glib::ConstructParams const & params);
+ explicit Application(AdwApplication * gobj);
+ explicit Application(Glib::ustring const & id = {}, Gio::Application::Flags flags = Gio::Application::Flags::NONE);
+
+ private:
+ friend Application_Class;
+ static Application_Class s_class;
+ };
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwApplication * object, bool copy = false) -> Glib::RefPtr<turns::adw::Application>;
+} // namespace Glib
+
+#endif \ No newline at end of file
diff --git a/adw/include/turns/adw/wrap_init.hpp b/adw/include/turns/adw/wrap_init.hpp
new file mode 100644
index 0000000..5096736
--- /dev/null
+++ b/adw/include/turns/adw/wrap_init.hpp
@@ -0,0 +1,9 @@
+#ifndef TURNS_ADW_WRAP_INIT_HPP
+#define TURNS_ADW_WRAP_INIT_HPP
+
+namespace turns::adw
+{
+ auto wrap_init() -> void;
+} // namespace turns::adw
+
+#endif \ No newline at end of file
diff --git a/adw/src/application.cpp b/adw/src/application.cpp
new file mode 100644
index 0000000..539f7bc
--- /dev/null
+++ b/adw/src/application.cpp
@@ -0,0 +1,102 @@
+#include "turns/adw/application.hpp"
+
+#include "turns/adw/wrap_init.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+
+#include <gtkmm/init.h>
+
+#include <adwaita.h>
+
+#include <gtkmm/private/application_p.h>
+
+namespace turns::adw
+{
+ struct Application_Class : Glib::Class
+ {
+ auto init() -> Glib::Class const &;
+ auto static class_init_function(void * gclass, void * data) -> void;
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ auto Application_Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &Application_Class::class_init_function;
+ register_derived_type(adw_application_get_type());
+ }
+ return *this;
+ }
+
+ auto Application_Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<AdwApplicationClass *>(gclass);
+ Gtk::Application_Class::class_init_function(klass, data);
+ }
+
+ auto Application_Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return new Application(ADW_APPLICATION(object));
+ }
+
+ Application_Class Application::s_class{};
+
+ auto Application::get_type() -> GType
+ {
+ return s_class.init().get_type();
+ }
+
+ auto Application::get_base_type() -> GType
+ {
+ return adw_application_get_type();
+ }
+
+ auto Application::gobj_copy() -> AdwApplication *
+ {
+ reference();
+ return gobj();
+ }
+
+ auto Application::create(Glib::ustring const & id, Gio::Application::Flags flags) -> Glib::RefPtr<Application>
+ {
+ auto static did_init = false;
+
+ if (!did_init)
+ {
+ Gtk::init_gtkmm_internals();
+ turns::adw::wrap_init();
+ did_init = true;
+ }
+
+ return Glib::RefPtr<Application>(new Application(id, flags));
+ }
+
+ Application::Application(Glib::ConstructParams const & params)
+ : Gtk::Application{params}
+ {
+ }
+
+ Application::Application(AdwApplication * gobj)
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Application((GtkApplication *)gobj)
+ {
+ }
+
+ Application::Application(Glib::ustring const & id, Gio::Application::Flags flags)
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Application{Glib::ConstructParams{s_class.init(), "application_id", Glib::c_str_or_nullptr(id), "flags", static_cast<GApplicationFlags>(flags), nullptr}}
+ {
+ }
+
+} // namespace turns::adw
+
+namespace Glib
+{
+ auto wrap(AdwApplication * object, bool copy) -> Glib::RefPtr<turns::adw::Application>
+ {
+ return Glib::make_refptr_for_instance<turns::adw::Application>(
+ dynamic_cast<turns::adw::Application *>(Glib::wrap_auto(G_OBJECT(object), copy)));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/adw/src/wrap_init.cpp b/adw/src/wrap_init.cpp
new file mode 100644
index 0000000..42ff1cf
--- /dev/null
+++ b/adw/src/wrap_init.cpp
@@ -0,0 +1,21 @@
+#include "turns/adw/wrap_init.hpp"
+
+#include "turns/adw/application.hpp"
+
+#include <adwaita.h>
+
+namespace turns::adw
+{
+ struct Application_Class
+ {
+ auto static wrap_new(GObject * object) -> Glib::ObjectBase *;
+ };
+
+ auto wrap_init() -> void
+ {
+ adw_init();
+
+ Glib::wrap_register(adw_application_get_type(), &Application_Class::wrap_new);
+ g_type_ensure(Application::get_type());
+ }
+} // namespace turns::adw \ No newline at end of file