[libadwaita/wip/exalm/pref-window-toast] demo: Add a prefrences window toast demo
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/pref-window-toast] demo: Add a prefrences window toast demo
- Date: Thu, 11 Nov 2021 15:21:06 +0000 (UTC)
commit 70de5ed9afdcbd755b687a02a047ea63e693de62
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Nov 11 20:20:42 2021 +0500
demo: Add a prefrences window toast demo
demo/adw-demo-preferences-window.c | 8 ++++++++
demo/adw-demo-preferences-window.ui | 17 +++++++++++++++++
2 files changed, 25 insertions(+)
---
diff --git a/demo/adw-demo-preferences-window.c b/demo/adw-demo-preferences-window.c
index bd9d2a42..7d219d0a 100644
--- a/demo/adw-demo-preferences-window.c
+++ b/demo/adw-demo-preferences-window.c
@@ -34,6 +34,12 @@ subpage2_activated_cb (AdwDemoPreferencesWindow *self)
adw_preferences_window_present_subpage (ADW_PREFERENCES_WINDOW (self), self->subpage2);
}
+static void
+toast_show_cb (AdwPreferencesWindow *window)
+{
+ adw_preferences_window_add_toast (window, adw_toast_new ("Example toast"));
+}
+
static void
adw_demo_preferences_window_class_init (AdwDemoPreferencesWindowClass *klass)
{
@@ -47,6 +53,8 @@ adw_demo_preferences_window_class_init (AdwDemoPreferencesWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, return_to_preferences_cb);
gtk_widget_class_bind_template_callback (widget_class, subpage1_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, subpage2_activated_cb);
+
+ gtk_widget_class_install_action (widget_class, "toast.show", NULL, (GtkWidgetActionActivateFunc)
toast_show_cb);
}
static void
diff --git a/demo/adw-demo-preferences-window.ui b/demo/adw-demo-preferences-window.ui
index d4beef59..a270fe0d 100644
--- a/demo/adw-demo-preferences-window.ui
+++ b/demo/adw-demo-preferences-window.ui
@@ -81,6 +81,23 @@
</child>
</object>
</child>
+ <child>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">Toasts</property>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Show a toast</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Show</property>
+ <property name="action-name">toast.show</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="AdwPreferencesGroup">
<property name="description" translatable="yes">Preferences windows can have subpages.</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]