[libadwaita/wip/exalm/toast-mnemonics: 2/2] toast: Support mnemonics on the button




commit 1171616701bf12a1c56bbad3f0e8821208d87029
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Nov 7 16:29:37 2021 +0500

    toast: Support mnemonics on the button
    
    Just enable them unconditionally, I don't think there's a point in having
    use-underline here.

 demo/adw-demo-window.c  | 2 +-
 src/adw-toast-widget.ui | 1 +
 src/adw-toast.c         | 6 ++++--
 3 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/demo/adw-demo-window.c b/demo/adw-demo-window.c
index e1542a3f..44205045 100644
--- a/demo/adw-demo-window.c
+++ b/demo/adw-demo-window.c
@@ -430,7 +430,7 @@ add_toast_with_button_cb (AdwDemoWindow *self)
     self->undo_toast = adw_toast_new (title);
 
     adw_toast_set_priority (self->undo_toast, ADW_TOAST_PRIORITY_HIGH);
-    adw_toast_set_button_label (self->undo_toast, _("Undo"));
+    adw_toast_set_button_label (self->undo_toast, _("_Undo"));
     adw_toast_set_action_name (self->undo_toast, "toast.undo");
 
     g_signal_connect_swapped (self->undo_toast, "dismissed", G_CALLBACK (dismissed_cb), self);
diff --git a/src/adw-toast-widget.ui b/src/adw-toast-widget.ui
index bb69ba3b..8a414492 100644
--- a/src/adw-toast-widget.ui
+++ b/src/adw-toast-widget.ui
@@ -40,6 +40,7 @@
     <child>
       <object class="GtkButton" id="action_button">
         <property name="valign">center</property>
+        <property name="use-underline">True</property>
         <binding name="visible">
           <closure type="gboolean" function="string_is_not_empty">
             <lookup name="button-label" type="AdwToast">
diff --git a/src/adw-toast.c b/src/adw-toast.c
index f8f3276a..e1c4fde6 100644
--- a/src/adw-toast.c
+++ b/src/adw-toast.c
@@ -46,7 +46,7 @@
  * ```c
  * AdwToast *toast = adw_toast_new (_("Toast with Action"));
  *
- * adw_toast_set_button_label (toast, _("Example"));
+ * adw_toast_set_button_label (toast, _("_Example"));
  * adw_toast_set_action_name (toast, "win.example");
  *
  * adw_toast_overlay_add_toast (overlay, toast);
@@ -94,7 +94,7 @@
  *     self->undo_toast = adw_toast_new (title);
  *
  *     adw_toast_set_priority (self->undo_toast, ADW_TOAST_PRIORITY_HIGH);
- *     adw_toast_set_button_label (self->undo_toast, _("Undo"));
+ *     adw_toast_set_button_label (self->undo_toast, _("_Undo"));
  *     adw_toast_set_action_name (self->undo_toast, "toast.undo");
  *
  *     g_signal_connect_swapped (self->undo_toast, "dismissed",
@@ -265,6 +265,8 @@ adw_toast_class_init (AdwToastClass *klass)
    *
    * The label to show on the button.
    *
+   * Underlines in the button text can be used to indicate a mnemonic.
+   *
    * If set to `NULL`, the button won't be shown.
    *
    * See [property@Adw.Toast:action-name].


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]