From 5467a7c2b1fb1831ca726d1ecb6b46010d146ebc Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 27 Mar 2025 08:27:32 +0100 Subject: adw: clean up implementation --- adw/include/turns/adw/actionrow.hpp | 98 +++++++---------------------- adw/include/turns/adw/application.hpp | 3 +- adw/include/turns/adw/applicationwindow.hpp | 64 +++++++++++++++++++ adw/include/turns/adw/dialog.hpp | 7 ++- adw/include/turns/adw/preferencesdialog.hpp | 3 +- adw/include/turns/adw/preferencespage.hpp | 3 +- adw/include/turns/adw/preferencesrow.hpp | 3 +- adw/include/turns/adw/switchrow.hpp | 10 ++- 8 files changed, 108 insertions(+), 83 deletions(-) create mode 100644 adw/include/turns/adw/applicationwindow.hpp (limited to 'adw/include/turns') diff --git a/adw/include/turns/adw/actionrow.hpp b/adw/include/turns/adw/actionrow.hpp index 15ddbb1..d098d65 100644 --- a/adw/include/turns/adw/actionrow.hpp +++ b/adw/include/turns/adw/actionrow.hpp @@ -2,16 +2,22 @@ #define TURNS_ADW_ACTION_ROW_HPP #include "helpers/gobj_mixin.hpp" -#include "turns/adw/helpers/properties.hpp" #include "turns/adw/preferencesrow.hpp" #include +#include +#include +#include #include #include #include +#include +#include + using AdwActionRow = struct _AdwActionRow; +using AdwActionRowClass = struct _AdwActionRowClass; namespace turns::adw { @@ -21,9 +27,9 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = AdwPreferencesRowClass; - using BaseClassType = struct AdwActionRowClass; + using BaseClassType = AdwActionRowClass; using BaseObjectType = AdwActionRow; - using CppClassParent = adw::PreferencesRow; + using CppClassParent = adw::PreferencesRow::Class; using CppObjectType = ActionRow; auto init() -> Glib::Class const &; @@ -53,12 +59,19 @@ namespace turns::adw auto add_suffix(Gtk::Widget & widget) -> ActionRow &; auto remove(Gtk::Widget & widget) -> ActionRow &; - auto get_activatable_widget(this auto && self) noexcept; - [[deprecated("replaced by add_prefix")]] auto get_icon_name(this auto && self); - auto get_subtitle(this auto && self); - auto get_subtitle_lines(this auto && self) noexcept; - auto get_subtitle_selectable(this auto && self) noexcept; - auto get_title_lines(this auto && self) noexcept; + auto get_activatable_widget() const noexcept -> Glib::RefPtr; + [[deprecated("replaced by add_prefix")]] auto get_icon_name() const -> Glib::ustring; + auto get_subtitle() const -> Glib::ustring; + auto get_subtitle_lines() const noexcept -> int; + auto get_subtitle_selectable() const noexcept -> bool; + auto get_title_lines() const noexcept -> int; + + auto property_activatable_widget() noexcept -> Glib::PropertyProxy; + [[deprecated("replaced by add_prefix")]] auto property_icon_name() noexcept -> Glib::PropertyProxy; + auto property_subtitle() noexcept -> Glib::PropertyProxy; + auto property_subtitle_lines() noexcept -> Glib::PropertyProxy; + auto property_subtitle_selectable() noexcept -> Glib::PropertyProxy; + auto property_title_lines() noexcept -> Glib::PropertyProxy; auto set_activatable_widget(Gtk::Widget & widget) noexcept -> CppObjectType &; [[deprecated("replaced by add_prefix")]] auto set_icon_name(Glib::ustring const & name) -> CppObjectType &; @@ -67,78 +80,11 @@ namespace turns::adw auto set_subtitle_selectable(bool subtitle_selectable) noexcept -> CppObjectType &; auto set_title_lines(int title_lines) noexcept -> CppObjectType &; - auto property_activatable_widget(this auto && self); - [[deprecated("replaced by add_prefix")]] auto property_icon_name(this auto && self); - auto property_subtitle(this auto && self); - auto property_subtitle_lines(this auto && self); - auto property_subtitle_selectable(this auto && self); - auto property_title_lines(this auto && self); - protected: explicit ActionRow(Glib::ConstructParams const & params); explicit ActionRow(BaseObjectType * gobj); }; - auto ActionRow::get_activatable_widget(this auto && self) noexcept - { - return self.property_activatable_widget().value(); - } - - auto ActionRow::get_icon_name(this auto && self) - { - return self.property_icon_name().value(); - } - - auto ActionRow::get_subtitle(this auto && self) - { - return self.property_subtitle().value(); - } - - auto ActionRow::get_subtitle_lines(this auto && self) noexcept - { - return self.property_subtitle_lines().value(); - } - - auto ActionRow::get_subtitle_selectable(this auto && self) noexcept - { - return self.property_subtitle_selectable().value(); - } - - auto ActionRow::get_title_lines(this auto && self) noexcept - { - return self.property_title_lines().value(); - } - - auto ActionRow::property_activatable_widget(this auto && self) - { - return helpers::make_property_proxy(self, "activatable-widget"); - } - - auto ActionRow::property_icon_name(this auto && self) - { - return helpers::make_property_proxy(self, "icon-name"); - } - - auto ActionRow::property_subtitle(this auto && self) - { - return helpers::make_property_proxy(self, "subtitle"); - } - - auto ActionRow::property_subtitle_lines(this auto && self) - { - return helpers::make_property_proxy(self, "subtitle-lines"); - } - - auto ActionRow::property_subtitle_selectable(this auto && self) - { - return helpers::make_property_proxy(self, "subtitle-selectable"); - } - - auto ActionRow::property_title_lines(this auto && self) - { - return helpers::make_property_proxy(self, "title-lines"); - } - } // namespace turns::adw namespace Glib diff --git a/adw/include/turns/adw/application.hpp b/adw/include/turns/adw/application.hpp index 64efcb0..df5e930 100644 --- a/adw/include/turns/adw/application.hpp +++ b/adw/include/turns/adw/application.hpp @@ -12,6 +12,7 @@ #include using AdwApplication = struct _AdwApplication; +using AdwApplicationClass = struct _AdwApplicationClass; namespace turns::adw { @@ -21,7 +22,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkApplicationClass; - using BaseClassType = struct AdwApplicationClass; + using BaseClassType = AdwApplicationClass; using BaseObjectType = AdwApplication; using CppClassParent = struct Gtk::Application_Class; using CppObjectType = Application; diff --git a/adw/include/turns/adw/applicationwindow.hpp b/adw/include/turns/adw/applicationwindow.hpp new file mode 100644 index 0000000..e5b02b0 --- /dev/null +++ b/adw/include/turns/adw/applicationwindow.hpp @@ -0,0 +1,64 @@ +#ifndef TURNS_ADW_APPLICATION_WINDOW_HPP +#define TURNS_ADW_APPLICATION_WINDOW_HPP + +#include "helpers/gobj_mixin.hpp" + +#include +#include +#include +#include + +#include +#include + +using AdwApplicationWindow = struct _AdwApplicationWindow; +using AdwApplicationWindowClass = struct _AdwApplicationWindowClass; + +namespace turns::adw +{ + struct ApplicationWindow : Gtk::ApplicationWindow, + helpers::gobj_mixin + { + struct Class : Glib::Class + { + using BaseClassParent = GtkApplicationWindowClass; + using BaseClassType = AdwApplicationWindowClass; + using BaseObjectType = AdwApplicationWindow; + using CppClassParent = struct Gtk::ApplicationWindow_Class; + using CppObjectType = ApplicationWindow; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; + + using BaseObjectType = Class::BaseObjectType; + using BaseClassType = Class::BaseClassType; + using CppObjectType = Class::CppObjectType; + using CppClassType = Class; + + using helpers::gobj_mixin::gobj; + using helpers::gobj_mixin::gobj_copy; + + explicit ApplicationWindow(Gtk::Application & app); + ApplicationWindow(ApplicationWindow const & other) = delete; + ApplicationWindow(ApplicationWindow && other) noexcept = default; + + auto operator=(ApplicationWindow const & other) noexcept -> ApplicationWindow & = delete; + auto operator=(ApplicationWindow && other) noexcept -> ApplicationWindow & = default; + + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + protected: + explicit ApplicationWindow(Glib::ConstructParams const & params); + explicit ApplicationWindow(BaseObjectType * gobj); + }; +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwApplicationWindow * object, bool copy = false) -> turns::adw::ApplicationWindow *; +} // namespace Glib + +#endif \ No newline at end of file diff --git a/adw/include/turns/adw/dialog.hpp b/adw/include/turns/adw/dialog.hpp index af5f5da..75a095c 100644 --- a/adw/include/turns/adw/dialog.hpp +++ b/adw/include/turns/adw/dialog.hpp @@ -4,11 +4,16 @@ #include "helpers/gobj_mixin.hpp" #include +#include +#include #include #include +#include + using AdwDialog = struct _AdwDialog; +using AdwDialogClass = struct _AdwDialogClass; namespace turns::adw { @@ -20,7 +25,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkWidgetClass; - using BaseClassType = struct AdwDialogClass; + using BaseClassType = AdwDialogClass; using BaseObjectType = AdwDialog; using CppClassParent = struct Gtk::Widget_Class; using CppObjectType = Dialog; diff --git a/adw/include/turns/adw/preferencesdialog.hpp b/adw/include/turns/adw/preferencesdialog.hpp index 06ac600..85735ef 100644 --- a/adw/include/turns/adw/preferencesdialog.hpp +++ b/adw/include/turns/adw/preferencesdialog.hpp @@ -11,6 +11,7 @@ #include using AdwPreferencesDialog = struct _AdwPreferencesDialog; +using AdwPreferencesDialogClass = struct _AdwPreferencesDialogClass; namespace turns::adw { @@ -22,7 +23,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = AdwDialogClass; - using BaseClassType = struct AdwPreferencesDialogClass; + using BaseClassType = AdwPreferencesDialogClass; using BaseObjectType = AdwPreferencesDialog; using CppClassParent = adw::Dialog::Class; using CppObjectType = PreferencesDialog; diff --git a/adw/include/turns/adw/preferencespage.hpp b/adw/include/turns/adw/preferencespage.hpp index 30e7eed..b8b4051 100644 --- a/adw/include/turns/adw/preferencespage.hpp +++ b/adw/include/turns/adw/preferencespage.hpp @@ -10,6 +10,7 @@ #include using AdwPreferencesPage = struct _AdwPreferencesPage; +using AdwPreferencesPageClass = struct _AdwPreferencesPageClass; namespace turns::adw { @@ -19,7 +20,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkWidgetClass; - using BaseClassType = struct AdwPreferencesPageClass; + using BaseClassType = AdwPreferencesPageClass; using BaseObjectType = AdwPreferencesPage; using CppClassParent = struct Gtk::Widget_Class; using CppObjectType = PreferencesPage; diff --git a/adw/include/turns/adw/preferencesrow.hpp b/adw/include/turns/adw/preferencesrow.hpp index 6f831b0..a0f22ed 100644 --- a/adw/include/turns/adw/preferencesrow.hpp +++ b/adw/include/turns/adw/preferencesrow.hpp @@ -11,6 +11,7 @@ #include using AdwPreferencesRow = struct _AdwPreferencesRow; +using AdwPreferencesRowClass = struct _AdwPreferencesRowClass; namespace turns::adw { @@ -20,7 +21,7 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = GtkListBoxRowClass; - using BaseClassType = struct AdwPreferencesRowClass; + using BaseClassType = AdwPreferencesRowClass; using BaseObjectType = AdwPreferencesRow; using CppClassParent = struct Gtk::ListBoxRow_Class; using CppObjectType = PreferencesRow; diff --git a/adw/include/turns/adw/switchrow.hpp b/adw/include/turns/adw/switchrow.hpp index ed5190a..e7e0131 100644 --- a/adw/include/turns/adw/switchrow.hpp +++ b/adw/include/turns/adw/switchrow.hpp @@ -6,11 +6,17 @@ #include "turns/adw/helpers/properties.hpp" #include +#include +#include #include #include #include +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE + using AdwSwitchRow = struct _AdwSwitchRow; namespace turns::adw @@ -21,9 +27,9 @@ namespace turns::adw struct Class : Glib::Class { using BaseClassParent = AdwActionRowClass; - using BaseClassType = struct AdwSwitchRowClass; + using BaseClassType = AdwSwitchRowClass; using BaseObjectType = AdwSwitchRow; - using CppClassParent = adw::ActionRow; + using CppClassParent = adw::ActionRow::Class; using CppObjectType = SwitchRow; auto init() -> Glib::Class const &; -- cgit v1.2.3