diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-04-28 13:31:44 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-04-28 13:31:44 +0200 |
| commit | d7e133846015d005768e5588a6dd926fed4d3f04 (patch) | |
| tree | 4b8dda3736595fdb77c4ee7dd79459737c1c0fc9 | |
| parent | 6378909a3d85f7f65b5ba5c116d950f96342fed4 (diff) | |
| download | turns-d7e133846015d005768e5588a6dd926fed4d3f04.tar.xz turns-d7e133846015d005768e5588a6dd926fed4d3f04.zip | |
adw: implement EntryRow
| -rw-r--r-- | .vscode/settings.json | 1 | ||||
| -rw-r--r-- | adw/include/adwaitamm/entryrow.hpp | 122 | ||||
| -rw-r--r-- | adw/include/adwaitamm/private/entryrow_p.hpp | 35 | ||||
| -rw-r--r-- | adw/src/entryrow.cpp | 282 | ||||
| -rw-r--r-- | adw/src/private/entryrow_p.cpp | 44 | ||||
| -rw-r--r-- | adw/src/wrap_init.cpp | 4 |
6 files changed, 488 insertions, 0 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 1c7d479..51de9c8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,6 +17,7 @@ "klass", "LIBADWAITAMM", "Morgner", + "Pango", "refptr", "sigc", "ustring", diff --git a/adw/include/adwaitamm/entryrow.hpp b/adw/include/adwaitamm/entryrow.hpp new file mode 100644 index 0000000..16f0f3b --- /dev/null +++ b/adw/include/adwaitamm/entryrow.hpp @@ -0,0 +1,122 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef LIBADWAITAMM_ENTRY_ROW_HPP +#define LIBADWAITAMM_ENTRY_ROW_HPP + +#include "adwaitamm/helpers/gobj_mixin.hpp" +#include "adwaitamm/preferencesrow.hpp" + +#include <glibmm/object.h> +#include <glibmm/propertyproxy.h> +#include <glibmm/refptr.h> +#include <glibmm/signalproxy.h> +#include <glibmm/ustring.h> + +#include <giomm/listmodel.h> + +#include <gtkmm/editable.h> +#include <gtkmm/enums.h> +#include <gtkmm/expression.h> +#include <gtkmm/listitemfactory.h> +#include <gtkmm/stringfilter.h> +#include <gtkmm/widget.h> + +#include <glib-object.h> +#include <pangomm/attrlist.h> + +#define _ADWAITA_INSIDE +#include <adw-entry-row.h> +#undef _ADWAITA_INSIDE + +namespace Adwaita +{ + struct EntryRow : PreferencesRow, + Gtk::Editable, + helpers::gobj_mixin<EntryRow, AdwEntryRow> + { + using BaseObjectType = AdwEntryRow; + using BaseClassType = AdwEntryRowClass; + using CppObjectType = struct EntryRow; + using CppClassType = struct EntryRow_Class; + + using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj; + using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy; + +#pragma mark - Special Member Functions + explicit EntryRow(); + EntryRow(EntryRow const & other) = delete; + EntryRow(EntryRow && other) noexcept = default; + + auto operator=(EntryRow const & other) noexcept -> EntryRow & = delete; + auto operator=(EntryRow && other) noexcept -> EntryRow & = default; + +#pragma mark - GObject Support + auto static get_type() -> GType; + auto static get_base_type() -> GType; + +#pragma mark - Functions + auto add_prefix(Gtk::Widget & widget) -> void; + auto add_suffix(Gtk::Widget & widget) -> void; + auto grab_focus_without_selecting() -> bool; + auto remove(Gtk::Widget & widget) -> void; + +#pragma mark - Getters + [[nodiscard]] auto get_activates_default() const -> bool; + [[nodiscard]] auto get_attributes() const -> Pango::AttrList; + [[nodiscard]] auto get_enable_emoji_completion() const -> bool; + [[nodiscard]] auto get_input_hints() const -> Gtk::InputHints; + [[nodiscard]] auto get_input_purpose() const -> Gtk::InputPurpose; + [[nodiscard]] auto get_max_length() const -> int; + [[nodiscard]] auto get_show_apply_button() const -> bool; + [[nodiscard]] auto get_text_length() const -> unsigned int; + +#pragma mark - Setters + auto set_activates_default(bool value) -> void; + auto set_attributes(Pango::AttrList & value) -> void; + auto set_enable_emoji_completion(bool value) -> void; + auto set_input_hints(Gtk::InputHints value) -> void; + auto set_input_purpose(Gtk::InputPurpose value) -> void; + auto set_max_length(int value) -> void; + auto set_show_apply_button(bool value) -> void; + +#pragma mark - Properties + [[nodiscard]] auto property_activates_default() -> Glib::PropertyProxy<bool>; + [[nodiscard]] auto property_activates_default() const -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_attributes() -> Glib::PropertyProxy<Pango::AttrList>; + [[nodiscard]] auto property_attributes() const -> Glib::PropertyProxy_ReadOnly<Pango::AttrList>; + [[nodiscard]] auto property_enable_emoji_completion() -> Glib::PropertyProxy<bool>; + [[nodiscard]] auto property_enable_emoji_completion() const -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_input_hints() -> Glib::PropertyProxy<Gtk::InputHints>; + [[nodiscard]] auto property_input_hints() const -> Glib::PropertyProxy_ReadOnly<Gtk::InputHints>; + [[nodiscard]] auto property_input_purpose() -> Glib::PropertyProxy<Gtk::InputPurpose>; + [[nodiscard]] auto property_input_purpose() const -> Glib::PropertyProxy_ReadOnly<Gtk::InputPurpose>; + [[nodiscard]] auto property_max_length() -> Glib::PropertyProxy<int>; + [[nodiscard]] auto property_max_length() const -> Glib::PropertyProxy_ReadOnly<int>; + [[nodiscard]] auto property_show_apply_button() -> Glib::PropertyProxy<bool>; + [[nodiscard]] auto property_show_apply_button() const -> Glib::PropertyProxy_ReadOnly<bool>; + [[nodiscard]] auto property_text_length() -> Glib::PropertyProxy_ReadOnly<unsigned int>; + +#pragma mark - Signals + auto signal_apply() -> Glib::SignalProxy<void()>; + auto signal_entry_activated() -> Glib::SignalProxy<void()>; + + protected: + friend EntryRow_Class; + +#pragma mark - Internal Constructors + explicit EntryRow(Glib::ConstructParams const & params); + explicit EntryRow(BaseObjectType * gobj); + }; + +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwEntryRow * object, bool copy = false) -> Adwaita::EntryRow *; +} // namespace Glib + +#endif
\ No newline at end of file diff --git a/adw/include/adwaitamm/private/entryrow_p.hpp b/adw/include/adwaitamm/private/entryrow_p.hpp new file mode 100644 index 0000000..903776f --- /dev/null +++ b/adw/include/adwaitamm/private/entryrow_p.hpp @@ -0,0 +1,35 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef LIBADWAITAMM_PRIVATE_ENTRY_ROW_P_HPP +#define LIBADWAITAMM_PRIVATE_ENTRY_ROW_P_HPP + +#include "adwaitamm/private/preferencesrow_p.hpp" + +#include <glibmm/class.h> +#include <glibmm/objectbase.h> + +#define _ADWAITA_INSIDE +#include <adw-entry-row.h> +#undef _ADWAITA_INSIDE + +namespace Adwaita +{ + struct EntryRow_Class : Glib::Class + { + using BaseClassParent = AdwPreferencesRowClass; + using BaseClassType = AdwEntryRowClass; + using BaseObjectType = AdwEntryRow; + using CppClassParent = PreferencesRow_Class; + using CppObjectType = struct EntryRow; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; +} // namespace Adwaita + +#endif
\ No newline at end of file diff --git a/adw/src/entryrow.cpp b/adw/src/entryrow.cpp new file mode 100644 index 0000000..b6053fd --- /dev/null +++ b/adw/src/entryrow.cpp @@ -0,0 +1,282 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "adwaitamm/entryrow.hpp" + +#include "adwaitamm/preferencesrow.hpp" +#include "adwaitamm/private/entryrow_p.hpp" + +#include <glibmm/object.h> +#include <glibmm/objectbase.h> +#include <glibmm/propertyproxy.h> +#include <glibmm/refptr.h> +#include <glibmm/signalproxy.h> +#include <glibmm/ustring.h> +#include <glibmm/wrap.h> + +#include <giomm/listmodel.h> + +#include <gtkmm/enums.h> +#include <gtkmm/expression.h> +#include <gtkmm/listitemfactory.h> +#include <gtkmm/stringfilter.h> +#include <gtkmm/widget.h> + +#include <glib-object.h> +#include <gtk/gtk.h> +#include <gtk/gtkdropdown.h> +#include <pangomm/attrlist.h> + +namespace Adwaita +{ + namespace + { + auto constinit _class = EntryRow_Class{}; + + namespace property_name + { + auto constexpr activates_default = "activates-default"; + auto constexpr attributes = "attributes"; + auto constexpr enable_emoji_completion = "enable-emoji-completion"; + auto constexpr input_hints = "input-hints"; + auto constexpr input_purpose = "input-purpose"; + auto constexpr max_length = "max-length"; + auto constexpr show_apply_button = "show-apply-button"; + auto constexpr text_length = "text-length"; + } // namespace property_name + + namespace signal_info + { + auto const apply = Glib::SignalProxyInfo{ + "apply", + reinterpret_cast<GCallback>(&Glib::SignalProxyNormal::slot0_void_callback), + reinterpret_cast<GCallback>(&Glib::SignalProxyNormal::slot0_void_callback), + }; + + auto const entry_activated = Glib::SignalProxyInfo{ + "entry-activated", + reinterpret_cast<GCallback>(&Glib::SignalProxyNormal::slot0_void_callback), + reinterpret_cast<GCallback>(&Glib::SignalProxyNormal::slot0_void_callback), + }; + + } // namespace signal_info + } // namespace + + EntryRow::EntryRow() + : Glib::ObjectBase{nullptr} + , PreferencesRow{Glib::ConstructParams{_class.init()}} + { + } + + auto EntryRow::get_type() -> GType + { + return _class.init().get_type(); + } + + auto EntryRow::get_base_type() -> GType + { + return adw_entry_row_get_type(); + } + + auto EntryRow::add_prefix(Gtk::Widget & widget) -> void + { + return adw_entry_row_add_prefix(unwrap(this), unwrap(&widget)); + } + + auto EntryRow::add_suffix(Gtk::Widget & widget) -> void + { + return adw_entry_row_add_suffix(unwrap(this), unwrap(&widget)); + } + + auto EntryRow::grab_focus_without_selecting() -> bool + { + return adw_entry_row_grab_focus_without_selecting(unwrap(this)); + } + + auto EntryRow::remove(Gtk::Widget & widget) -> void + { + return adw_entry_row_remove(unwrap(this), unwrap(&widget)); + } + + auto EntryRow::get_activates_default() const -> bool + { + return adw_entry_row_get_activates_default(const_cast<BaseObjectType *>(unwrap(this))); + } + + auto EntryRow::get_attributes() const -> Pango::AttrList + { + return Glib::wrap(adw_entry_row_get_attributes(const_cast<BaseObjectType *>(unwrap(this)))); + } + + auto EntryRow::get_enable_emoji_completion() const -> bool + { + return adw_entry_row_get_enable_emoji_completion(const_cast<BaseObjectType *>(unwrap(this))); + } + + auto EntryRow::get_input_hints() const -> Gtk::InputHints + { + return static_cast<Gtk::InputHints>(adw_entry_row_get_input_hints(const_cast<BaseObjectType *>(unwrap(this)))); + } + + auto EntryRow::get_input_purpose() const -> Gtk::InputPurpose + { + return static_cast<Gtk::InputPurpose>(adw_entry_row_get_input_purpose(const_cast<BaseObjectType *>(unwrap(this)))); + } + + auto EntryRow::get_max_length() const -> int + { + return adw_entry_row_get_max_length(const_cast<BaseObjectType *>(unwrap(this))); + } + + auto EntryRow::get_show_apply_button() const -> bool + { + return adw_entry_row_get_show_apply_button(const_cast<BaseObjectType *>(unwrap(this))); + } + + auto EntryRow::get_text_length() const -> unsigned int + { + return adw_entry_row_get_text_length(const_cast<BaseObjectType *>(unwrap(this))); + } + + auto EntryRow::set_activates_default(bool value) -> void + { + return adw_entry_row_set_activates_default(unwrap(this), value); + } + + auto EntryRow::set_attributes(Pango::AttrList & value) -> void + { + return adw_entry_row_set_attributes(unwrap(this), Glib::unwrap(&value)); + } + + auto EntryRow::set_enable_emoji_completion(bool value) -> void + { + return adw_entry_row_set_enable_emoji_completion(unwrap(this), value); + } + + auto EntryRow::set_input_hints(Gtk::InputHints value) -> void + { + return adw_entry_row_set_input_hints(unwrap(this), static_cast<GtkInputHints>(value)); + } + + auto EntryRow::set_input_purpose(Gtk::InputPurpose value) -> void + { + return adw_entry_row_set_input_purpose(unwrap(this), static_cast<GtkInputPurpose>(value)); + } + + auto EntryRow::set_max_length(int value) -> void + { + return adw_entry_row_set_max_length(unwrap(this), value); + } + + auto EntryRow::set_show_apply_button(bool value) -> void + { + return adw_entry_row_set_show_apply_button(unwrap(this), value); + } + + auto EntryRow::property_activates_default() -> Glib::PropertyProxy<bool> + { + return {this, property_name::activates_default}; + } + + auto EntryRow::property_activates_default() const -> Glib::PropertyProxy_ReadOnly<bool> + { + return {this, property_name::activates_default}; + } + + auto EntryRow::property_attributes() -> Glib::PropertyProxy<Pango::AttrList> + { + return {this, property_name::attributes}; + } + + auto EntryRow::property_attributes() const -> Glib::PropertyProxy_ReadOnly<Pango::AttrList> + { + return {this, property_name::attributes}; + } + + auto EntryRow::property_enable_emoji_completion() -> Glib::PropertyProxy<bool> + { + return {this, property_name::enable_emoji_completion}; + } + + auto EntryRow::property_enable_emoji_completion() const -> Glib::PropertyProxy_ReadOnly<bool> + { + return {this, property_name::enable_emoji_completion}; + } + + auto EntryRow::property_input_hints() -> Glib::PropertyProxy<Gtk::InputHints> + { + return {this, property_name::input_hints}; + } + + auto EntryRow::property_input_hints() const -> Glib::PropertyProxy_ReadOnly<Gtk::InputHints> + { + return {this, property_name::input_hints}; + } + + auto EntryRow::property_input_purpose() -> Glib::PropertyProxy<Gtk::InputPurpose> + { + return {this, property_name::input_purpose}; + } + + auto EntryRow::property_input_purpose() const -> Glib::PropertyProxy_ReadOnly<Gtk::InputPurpose> + { + return {this, property_name::input_purpose}; + } + + auto EntryRow::property_max_length() -> Glib::PropertyProxy<int> + { + return {this, property_name::max_length}; + } + + auto EntryRow::property_max_length() const -> Glib::PropertyProxy_ReadOnly<int> + { + return {this, property_name::max_length}; + } + + auto EntryRow::property_show_apply_button() -> Glib::PropertyProxy<bool> + { + return {this, property_name::show_apply_button}; + } + + auto EntryRow::property_show_apply_button() const -> Glib::PropertyProxy_ReadOnly<bool> + { + return {this, property_name::show_apply_button}; + } + + auto EntryRow::property_text_length() -> Glib::PropertyProxy_ReadOnly<unsigned int> + { + return {this, property_name::text_length}; + } + + auto EntryRow::signal_apply() -> Glib::SignalProxy<void()> + { + return {this, &signal_info::apply}; + } + + auto EntryRow::signal_entry_activated() -> Glib::SignalProxy<void()> + { + return {this, &signal_info::entry_activated}; + } + + EntryRow::EntryRow(Glib::ConstructParams const & params) + : PreferencesRow{params} + { + } + + EntryRow::EntryRow(BaseObjectType * gobj) + : PreferencesRow(ADW_PREFERENCES_ROW(gobj)) + { + } + +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwEntryRow * object, bool copy) -> Adwaita::EntryRow * + { + return dynamic_cast<Adwaita::EntryRow *>(Glib::wrap_auto(G_OBJECT(object), copy)); + } +} // namespace Glib
\ No newline at end of file diff --git a/adw/src/private/entryrow_p.cpp b/adw/src/private/entryrow_p.cpp new file mode 100644 index 0000000..8f1274a --- /dev/null +++ b/adw/src/private/entryrow_p.cpp @@ -0,0 +1,44 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "adwaitamm/private/entryrow_p.hpp" + +#include "adwaitamm/entryrow.hpp" + +#include <glibmm/class.h> +#include <glibmm/object.h> +#include <glibmm/objectbase.h> + +#include <gtkmm/editable.h> +#include <gtkmm/object.h> + +#include <adwaita.h> +#include <gtk/gtk.h> + +namespace Adwaita +{ + auto EntryRow_Class::init() -> Glib::Class const & + { + if (!gtype_) + { + class_init_func_ = &class_init_function; + register_derived_type(adw_entry_row_get_type()); + Gtk::Editable::add_interface(get_type()); + } + return *this; + } + + auto EntryRow_Class::class_init_function(void * gclass, void * data) -> void + { + auto const klass = static_cast<BaseClassType *>(gclass); + CppClassParent::class_init_function(klass, data); + } + + auto EntryRow_Class::wrap_new(GObject * object) -> Glib::ObjectBase * + { + return Gtk::manage(new EntryRow(ADW_ENTRY_ROW(object))); + } +} // namespace Adwaita
\ No newline at end of file diff --git a/adw/src/wrap_init.cpp b/adw/src/wrap_init.cpp index f300b06..a609c48 100644 --- a/adw/src/wrap_init.cpp +++ b/adw/src/wrap_init.cpp @@ -14,6 +14,7 @@ #include "adwaitamm/breakpoint.hpp" #include "adwaitamm/comborow.hpp" #include "adwaitamm/dialog.hpp" +#include "adwaitamm/entryrow.hpp" #include "adwaitamm/preferencesdialog.hpp" #include "adwaitamm/preferencespage.hpp" #include "adwaitamm/preferencesrow.hpp" @@ -25,6 +26,7 @@ #include "adwaitamm/private/breakpoint_p.hpp" // IWYU pragma: keep - required for gobj class definition. #include "adwaitamm/private/comborow_p.hpp" // IWYU pragma: keep - required for gobj class definition. #include "adwaitamm/private/dialog_p.hpp" // IWYU pragma: keep - required for gobj class definition. +#include "adwaitamm/private/entryrow_p.hpp" // IWYU pragma: keep - required for gobj class definition. #include "adwaitamm/private/preferencesdialog_p.hpp" // IWYU pragma: keep - required for gobj class definition. #include "adwaitamm/private/preferencespage_p.hpp" // IWYU pragma: keep - required for gobj class definition. #include "adwaitamm/private/preferencesrow_p.hpp" // IWYU pragma: keep - required for gobj class definition. @@ -61,6 +63,7 @@ namespace Adwaita WRAP_CLASS(Breakpoint, breakpoint); WRAP_CLASS(ComboRow, combo_row); WRAP_CLASS(Dialog, dialog); + WRAP_CLASS(EntryRow, entry_row); WRAP_CLASS(PreferencesDialog, preferences_dialog); WRAP_CLASS(PreferencesPage, preferences_page); WRAP_CLASS(PreferencesRow, preferences_row); @@ -79,6 +82,7 @@ namespace Adwaita ENSURE_TYPE(Breakpoint); ENSURE_TYPE(ComboRow); ENSURE_TYPE(Dialog); + ENSURE_TYPE(EntryRow); ENSURE_TYPE(PreferencesDialog); ENSURE_TYPE(PreferencesPage); ENSURE_TYPE(PreferencesRow); |
