aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2025-04-29 12:30:21 +0200
committerFelix Morgner <felix.morgner@gmail.com>2025-04-29 12:32:34 +0200
commit673e58ca36421bb560d4e04277b6b58ce6e0db6f (patch)
tree4688e5b25a4bceac10c38a9ef0dc966d8f5131c2 /src
parent68b3389d282284a59329c9c6a6603c7045a2db72 (diff)
downloadlibadwaitamm-673e58ca36421bb560d4e04277b6b58ce6e0db6f.tar.xz
libadwaitamm-673e58ca36421bb560d4e04277b6b58ce6e0db6f.zip
adw: implement ToolbarView
Diffstat (limited to 'src')
-rw-r--r--src/enums.cpp9
-rw-r--r--src/private/toolbarview_p.cpp42
-rw-r--r--src/toolbarview.cpp253
-rw-r--r--src/wrap_init.cpp16
4 files changed, 311 insertions, 9 deletions
diff --git a/src/enums.cpp b/src/enums.cpp
index b93ac3d..57a6c32 100644
--- a/src/enums.cpp
+++ b/src/enums.cpp
@@ -6,8 +6,6 @@
#include "adwaitamm/enums.hpp"
-#include "adwaitamm/stylemanager.hpp"
-
#include <adwaita.h>
#include <glib-object.h>
@@ -58,6 +56,10 @@ namespace Adwaita
static_assert(matches<ToastPriority::Normal, ADW_TOAST_PRIORITY_NORMAL>);
static_assert(matches<ToastPriority::High, ADW_TOAST_PRIORITY_HIGH>);
+ static_assert(matches<ToolbarStyle::Flat, ADW_TOOLBAR_FLAT>);
+ static_assert(matches<ToolbarStyle::Raised, ADW_TOOLBAR_RAISED>);
+ static_assert(matches<ToolbarStyle::RaisedBorder, ADW_TOOLBAR_RAISED_BORDER>);
+
} // namespace Adwaita
namespace Glib
@@ -71,10 +73,11 @@ namespace Glib
VALUE_SPECIALIZATION(AccentColor, accent_color)
VALUE_SPECIALIZATION(ColorScheme, color_scheme)
VALUE_SPECIALIZATION(LengthType, breakpoint_condition)
- VALUE_SPECIALIZATION(PresentationMode, dialog_presentation_mode);
+ VALUE_SPECIALIZATION(PresentationMode, dialog_presentation_mode)
VALUE_SPECIALIZATION(RatioType, breakpoint_condition)
VALUE_SPECIALIZATION(ResponseAppearance, response_appearance)
VALUE_SPECIALIZATION(ToastPriority, toast_priority)
+ VALUE_SPECIALIZATION(ToolbarStyle, toolbar_style)
#undef VALUE_SPECIALIZATION
} // namespace Glib \ No newline at end of file
diff --git a/src/private/toolbarview_p.cpp b/src/private/toolbarview_p.cpp
new file mode 100644
index 0000000..271b0d7
--- /dev/null
+++ b/src/private/toolbarview_p.cpp
@@ -0,0 +1,42 @@
+/**
+ * @author Felix Morgner (felix.morgner@gmail.com)
+ * @copyright Copyright (c) 2025
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "adwaitamm/private/toolbarview_p.hpp"
+
+#include "adwaitamm/toolbarview.hpp"
+
+#include <glibmm/class.h>
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+
+#include <gtkmm/object.h>
+#include <gtkmm/private/widget_p.h>
+
+namespace Adwaita
+{
+
+ auto ToolbarView_Class::init() -> Glib::Class const &
+ {
+ if (!gtype_)
+ {
+ class_init_func_ = &class_init_function;
+ gtype_ = adw_toolbar_view_get_type();
+ }
+ return *this;
+ }
+
+ auto ToolbarView_Class::class_init_function(void * gclass, void * data) -> void
+ {
+ auto const klass = static_cast<BaseClassType *>(gclass);
+ CppClassParent::class_init_function(klass, data);
+ }
+
+ auto ToolbarView_Class::wrap_new(GObject * object) -> Glib::ObjectBase *
+ {
+ return Gtk::manage(new ToolbarView(ADW_TOOLBAR_VIEW(object)));
+ }
+
+} // namespace Adwaita \ No newline at end of file
diff --git a/src/toolbarview.cpp b/src/toolbarview.cpp
new file mode 100644
index 0000000..b2a9de6
--- /dev/null
+++ b/src/toolbarview.cpp
@@ -0,0 +1,253 @@
+/**
+ * @author Felix Morgner (felix.morgner@gmail.com)
+ * @copyright Copyright (c) 2025
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "adwaitamm/toolbarview.hpp"
+
+#include "adwaitamm/enums.hpp"
+#include "adwaitamm/private/toolbarview_p.hpp"
+
+#include <glibmm/object.h>
+#include <glibmm/objectbase.h>
+#include <glibmm/propertyproxy.h>
+#include <glibmm/ustring.h>
+#include <glibmm/wrap.h>
+
+#include <gtkmm/widget.h>
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+namespace Adwaita
+{
+
+ namespace
+ {
+ auto constinit _class = ToolbarView_Class{};
+
+ namespace property_name
+ {
+ auto constexpr bottom_bar_height = "bottom-bar-height";
+ auto constexpr bottom_bar_style = "bottom-bar-style";
+ auto constexpr content = "content";
+ auto constexpr extend_content_to_bottom_edge = "extend-content-to-bottom-edge";
+ auto constexpr extend_content_to_top_edge = "extend-content-to-top-edge";
+ auto constexpr reveal_bottom_bars = "reveal-bottom-bars";
+ auto constexpr reveal_top_bars = "reveal-top-bars";
+ auto constexpr top_bar_height = "top-bar-height";
+ auto constexpr top_bar_style = "top-bar-style";
+ } // namespace property_name
+ } // namespace
+
+ ToolbarView::ToolbarView()
+ : Glib::ObjectBase{nullptr}
+ , Gtk::Widget{Glib::ConstructParams{_class.init()}}
+ {
+ }
+
+ auto ToolbarView::get_type() -> GType
+ {
+ return _class.init().get_type();
+ }
+
+ auto ToolbarView::get_base_type() -> GType
+ {
+ return adw_toolbar_view_get_type();
+ }
+
+ ToolbarView::ToolbarView(Glib::ConstructParams const & params)
+ : Gtk::Widget{params}
+ {
+ }
+
+ ToolbarView::ToolbarView(BaseObjectType * gobj)
+ : Gtk::Widget(GTK_WIDGET(gobj))
+ {
+ }
+
+ auto ToolbarView::add_bottom_bar(Gtk::Widget & widget) -> void
+ {
+ return adw_toolbar_view_add_bottom_bar(unwrap(this), unwrap(&widget));
+ }
+
+ auto ToolbarView::add_top_bar(Gtk::Widget & widget) -> void
+ {
+ return adw_toolbar_view_add_top_bar(unwrap(this), unwrap(&widget));
+ }
+
+ auto ToolbarView::remove(Gtk::Widget & widget) -> void
+ {
+ return adw_toolbar_view_remove(unwrap(this), unwrap(&widget));
+ }
+
+ auto ToolbarView::get_bottom_bar_height() const -> int
+ {
+ return adw_toolbar_view_get_bottom_bar_height(const_cast<BaseObjectType *>(unwrap(this)));
+ }
+
+ auto ToolbarView::get_bottom_bar_style() const -> ToolbarStyle
+ {
+ return static_cast<ToolbarStyle>(adw_toolbar_view_get_bottom_bar_style(const_cast<BaseObjectType *>(unwrap(this))));
+ }
+
+ auto ToolbarView::get_content() const -> Gtk::Widget *
+ {
+ return Glib::wrap(adw_toolbar_view_get_content(const_cast<BaseObjectType *>(unwrap(this))));
+ }
+
+ auto ToolbarView::get_extend_content_to_bottom_edge() const -> bool
+ {
+ return adw_toolbar_view_get_extend_content_to_bottom_edge(const_cast<BaseObjectType *>(unwrap(this)));
+ }
+
+ auto ToolbarView::get_extend_content_to_top_edge() const -> bool
+ {
+ return adw_toolbar_view_get_extend_content_to_top_edge(const_cast<BaseObjectType *>(unwrap(this)));
+ }
+
+ auto ToolbarView::get_reveal_bottom_bars() const -> bool
+ {
+ return adw_toolbar_view_get_reveal_bottom_bars(const_cast<BaseObjectType *>(unwrap(this)));
+ }
+
+ auto ToolbarView::get_reveal_top_bars() const -> bool
+ {
+ return adw_toolbar_view_get_reveal_top_bars(const_cast<BaseObjectType *>(unwrap(this)));
+ }
+
+ auto ToolbarView::get_top_bar_height() const -> int
+ {
+ return adw_toolbar_view_get_top_bar_height(const_cast<BaseObjectType *>(unwrap(this)));
+ }
+
+ auto ToolbarView::get_top_bar_style() const -> ToolbarStyle
+ {
+ return static_cast<ToolbarStyle>(adw_toolbar_view_get_top_bar_style(const_cast<BaseObjectType *>(unwrap(this))));
+ }
+
+ auto ToolbarView::set_bottom_bar_style(ToolbarStyle value) -> void
+ {
+ return adw_toolbar_view_set_bottom_bar_style(unwrap(this), static_cast<AdwToolbarStyle>(value));
+ }
+
+ auto ToolbarView::set_content(Gtk::Widget & value) -> void
+ {
+ return adw_toolbar_view_set_content(unwrap(this), unwrap(&value));
+ }
+
+ auto ToolbarView::set_extend_content_to_bottom_edge(bool value) -> void
+ {
+ return adw_toolbar_view_set_extend_content_to_bottom_edge(unwrap(this), value);
+ }
+
+ auto ToolbarView::set_extend_content_to_top_edge(bool value) -> void
+ {
+ return adw_toolbar_view_set_extend_content_to_top_edge(unwrap(this), value);
+ }
+
+ auto ToolbarView::set_reveal_bottom_bars(bool value) -> void
+ {
+ return adw_toolbar_view_set_reveal_bottom_bars(unwrap(this), value);
+ }
+
+ auto ToolbarView::set_reveal_top_bars(bool value) -> void
+ {
+ return adw_toolbar_view_set_reveal_top_bars(unwrap(this), value);
+ }
+
+ auto ToolbarView::set_top_bar_style(ToolbarStyle value) -> void
+ {
+ return adw_toolbar_view_set_top_bar_style(unwrap(this), static_cast<AdwToolbarStyle>(value));
+ }
+
+ auto ToolbarView::property_bottom_bar_height() const -> Glib::PropertyProxy_ReadOnly<int>
+ {
+ return {this, property_name::bottom_bar_height};
+ }
+
+ auto ToolbarView::property_bottom_bar_style() -> Glib::PropertyProxy<ToolbarStyle>
+ {
+ return {this, property_name::bottom_bar_style};
+ }
+
+ auto ToolbarView::property_bottom_bar_style() const -> Glib::PropertyProxy_ReadOnly<ToolbarStyle>
+ {
+ return {this, property_name::bottom_bar_style};
+ }
+
+ auto ToolbarView::property_content() -> Glib::PropertyProxy<Gtk::Widget *>
+ {
+ return {this, property_name::content};
+ }
+
+ auto ToolbarView::property_content() const -> Glib::PropertyProxy_ReadOnly<Gtk::Widget *>
+ {
+ return {this, property_name::content};
+ }
+
+ auto ToolbarView::property_extend_content_to_bottom_edge() -> Glib::PropertyProxy<bool>
+ {
+ return {this, property_name::extend_content_to_bottom_edge};
+ }
+
+ auto ToolbarView::property_extend_content_to_bottom_edge() const -> Glib::PropertyProxy_ReadOnly<bool>
+ {
+ return {this, property_name::extend_content_to_bottom_edge};
+ }
+
+ auto ToolbarView::property_extend_content_to_top_edge() -> Glib::PropertyProxy<bool>
+ {
+ return {this, property_name::extend_content_to_top_edge};
+ }
+
+ auto ToolbarView::property_extend_content_to_top_edge() const -> Glib::PropertyProxy_ReadOnly<bool>
+ {
+ return {this, property_name::extend_content_to_top_edge};
+ }
+
+ auto ToolbarView::property_reveal_bottom_bars() -> Glib::PropertyProxy<bool>
+ {
+ return {this, property_name::reveal_bottom_bars};
+ }
+
+ auto ToolbarView::property_reveal_bottom_bars() const -> Glib::PropertyProxy_ReadOnly<bool>
+ {
+ return {this, property_name::reveal_bottom_bars};
+ }
+
+ auto ToolbarView::property_reveal_top_bars() -> Glib::PropertyProxy<bool>
+ {
+ return {this, property_name::reveal_top_bars};
+ }
+
+ auto ToolbarView::property_reveal_top_bars() const -> Glib::PropertyProxy_ReadOnly<bool>
+ {
+ return {this, property_name::reveal_top_bars};
+ }
+
+ auto ToolbarView::property_top_bar_height() const -> Glib::PropertyProxy_ReadOnly<int>
+ {
+ return {this, property_name::top_bar_height};
+ }
+
+ auto ToolbarView::property_top_bar_style() -> Glib::PropertyProxy<ToolbarStyle>
+ {
+ return {this, property_name::top_bar_style};
+ }
+
+ auto ToolbarView::property_top_bar_style() const -> Glib::PropertyProxy_ReadOnly<ToolbarStyle>
+ {
+ return {this, property_name::top_bar_style};
+ }
+
+} // namespace Adwaita
+
+namespace Glib
+{
+ auto wrap(AdwToolbarView * object, bool copy) -> Adwaita::ToolbarView *
+ {
+ return dynamic_cast<Adwaita::ToolbarView *>(Glib::wrap_auto(G_OBJECT(object), copy));
+ }
+} // namespace Glib \ No newline at end of file
diff --git a/src/wrap_init.cpp b/src/wrap_init.cpp
index a609c48..1e3195c 100644
--- a/src/wrap_init.cpp
+++ b/src/wrap_init.cpp
@@ -30,17 +30,19 @@
#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.
-#include "adwaitamm/private/spinrow_p.hpp"
-#include "adwaitamm/private/stylemanager_p.hpp"
-#include "adwaitamm/private/switchrow_p.hpp"
-#include "adwaitamm/private/toast_p.hpp"
-#include "adwaitamm/private/toastoverlay_p.hpp"
-#include "adwaitamm/private/windowtitle_p.hpp"
+#include "adwaitamm/private/spinrow_p.hpp" // IWYU pragma: keep - required for gobj class definition.
+#include "adwaitamm/private/stylemanager_p.hpp" // IWYU pragma: keep - required for gobj class definition.
+#include "adwaitamm/private/switchrow_p.hpp" // IWYU pragma: keep - required for gobj class definition.
+#include "adwaitamm/private/toast_p.hpp" // IWYU pragma: keep - required for gobj class definition.
+#include "adwaitamm/private/toastoverlay_p.hpp" // IWYU pragma: keep - required for gobj class definition.
+#include "adwaitamm/private/toolbarview_p.hpp" // IWYU pragma: keep - required for gobj class definition.
+#include "adwaitamm/private/windowtitle_p.hpp" // IWYU pragma: keep - required for gobj class definition.
#include "adwaitamm/spinrow.hpp"
#include "adwaitamm/stylemanager.hpp"
#include "adwaitamm/switchrow.hpp"
#include "adwaitamm/toast.hpp"
#include "adwaitamm/toastoverlay.hpp"
+#include "adwaitamm/toolbarview.hpp"
#include "adwaitamm/windowtitle.hpp"
#include <glibmm/wrap.h>
@@ -72,6 +74,7 @@ namespace Adwaita
WRAP_CLASS(SwitchRow, switch_row);
WRAP_CLASS(Toast, toast);
WRAP_CLASS(ToastOverlay, toast_overlay);
+ WRAP_CLASS(ToolbarView, toolbar_view);
WRAP_CLASS(WindowTitle, window_title);
ENSURE_TYPE(AboutDialog);
@@ -91,6 +94,7 @@ namespace Adwaita
ENSURE_TYPE(SwitchRow);
ENSURE_TYPE(Toast);
ENSURE_TYPE(ToastOverlay);
+ ENSURE_TYPE(ToolbarView);
ENSURE_TYPE(WindowTitle);
}
} // namespace Adwaita \ No newline at end of file