[libadwaita] action-row: Drop the use-underline property



commit a686139ec2a32b8a4a521d7a59f1bd37be886f0a
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Oct 6 17:29:08 2021 +0200

    action-row: Drop the use-underline property
    
    It conflicts with AdwPreferencesRow:use-underline.
    
    This also drops the mnemonics on the subtitle as it is a bit useless.
    
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/48

 doc/migrating-between-development-versions.md |  7 +++
 doc/migrating-libhandy-1-4-to-libadwaita.md   |  5 ++
 src/adw-action-row.c                          | 80 +--------------------------
 src/adw-action-row.h                          |  6 --
 src/adw-action-row.ui                         |  3 +
 src/adw-expander-row.c                        |  4 +-
 tests/test-action-row.c                       | 19 -------
 7 files changed, 18 insertions(+), 106 deletions(-)
---
diff --git a/doc/migrating-between-development-versions.md b/doc/migrating-between-development-versions.md
index fc955961..1a50c6a1 100644
--- a/doc/migrating-between-development-versions.md
+++ b/doc/migrating-between-development-versions.md
@@ -212,3 +212,10 @@ Important: the [property@Gtk.Button:has-frame] property will **not** be set to
 `FALSE` when a button gets the flat appearance automatically. It also cannot be
 set to `TRUE` to make a button raised, the style class should be used directly
 instead.
+
+## Migrating from alpha 3 to alpha 4
+
+### Adapt to [class@Adw.ActionRow] API Changes
+
+The "use-underline" property and its accessors have been removed. Use
+[property@Adw.PreferencesRow:use-underline] and its accessors instead.
diff --git a/doc/migrating-libhandy-1-4-to-libadwaita.md b/doc/migrating-libhandy-1-4-to-libadwaita.md
index 8fa4c2a0..e5ded4de 100644
--- a/doc/migrating-libhandy-1-4-to-libadwaita.md
+++ b/doc/migrating-libhandy-1-4-to-libadwaita.md
@@ -133,6 +133,11 @@ Adding children in a UI file still works.
 
 `HdyWindowHandle` has been removed, use [class@Gtk.WindowHandle] instead.
 
+### Adapt to [class@Adw.ActionRow] API Changes
+
+The "use-underline" property and its accessors have been removed. Use
+[property@Adw.PreferencesRow:use-underline] and its accessors instead.
+
 ### Adapt to [class@Adw.Clamp] API Changes
 
 `HdyClamp` previously had `.small`, `.medium` or `.large` style classes
diff --git a/src/adw-action-row.c b/src/adw-action-row.c
index 09252b89..30909b54 100644
--- a/src/adw-action-row.c
+++ b/src/adw-action-row.c
@@ -57,7 +57,6 @@ typedef struct
 
   GtkWidget *previous_parent;
 
-  gboolean use_underline;
   int title_lines;
   int subtitle_lines;
   GtkWidget *activatable_widget;
@@ -77,7 +76,6 @@ enum {
   PROP_ICON_NAME,
   PROP_ACTIVATABLE_WIDGET,
   PROP_SUBTITLE,
-  PROP_USE_UNDERLINE,
   PROP_TITLE_LINES,
   PROP_SUBTITLE_LINES,
   LAST_PROP,
@@ -153,9 +151,6 @@ adw_action_row_get_property (GObject    *object,
   case PROP_TITLE_LINES:
     g_value_set_int (value, adw_action_row_get_title_lines (self));
     break;
-  case PROP_USE_UNDERLINE:
-    g_value_set_boolean (value, adw_action_row_get_use_underline (self));
-    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   }
@@ -185,9 +180,6 @@ adw_action_row_set_property (GObject      *object,
   case PROP_TITLE_LINES:
     adw_action_row_set_title_lines (self, g_value_get_int (value));
     break;
-  case PROP_USE_UNDERLINE:
-    adw_action_row_set_use_underline (self, g_value_get_boolean (value));
-    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   }
@@ -253,7 +245,7 @@ adw_action_row_class_init (AdwActionRowClass *klass)
    *
    * The row can be activated either by clicking on it, calling
    * [method@Adw.ActionRow.activate], or via mnemonics in the title or the
-   * subtitle. See the [property@Adw.ActionRow:use-underline] property to
+   * subtitle. See the [property@Adw.PreferencesRow:use-underline] property to
    * enable mnemonics.
    *
    * The target widget will be activated by emitting the
@@ -282,20 +274,6 @@ adw_action_row_class_init (AdwActionRowClass *klass)
                          "",
                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
-  /**
-   * AdwActionRow:use-underline: (attributes org.gtk.Property.get=adw_action_row_get_use_underline 
org.gtk.Property.set=adw_action_row_set_use_underline)
-   *
-   * Whether underlines in title or subtitle are interpreted as mnemonics.
-   *
-   * Since: 1.0
-   */
-  props[PROP_USE_UNDERLINE] =
-    g_param_spec_boolean ("use-underline",
-                          "Use underline",
-                          "Whether underlines in title or subtitle are interpreted as mnemonics",
-                          FALSE,
-                          G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
   /**
    * AdwActionRow:title-lines: (attributes org.gtk.Property.get=adw_action_row_get_title_lines 
org.gtk.Property.set=adw_action_row_set_title_lines)
    *
@@ -611,62 +589,6 @@ adw_action_row_set_activatable_widget (AdwActionRow *self,
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVATABLE_WIDGET]);
 }
 
-/**
- * adw_action_row_get_use_underline: (attributes org.gtk.Method.get_property=use-underline)
- * @self: a `AdwActionRow`
- *
- * Gets whether underlines in title or subtitle are interpreted as mnemonics.
- *
- * Returns: `TRUE` if underlines are interpreted as mnemonics
- *
- * Since: 1.0
- */
-gboolean
-adw_action_row_get_use_underline (AdwActionRow *self)
-{
-  AdwActionRowPrivate *priv;
-
-  g_return_val_if_fail (ADW_IS_ACTION_ROW (self), FALSE);
-
-  priv = adw_action_row_get_instance_private (self);
-
-  return priv->use_underline;
-}
-
-/**
- * adw_action_row_set_use_underline: (attributes org.gtk.Method.set_property=use-underline)
- * @self: a `AdwActionRow`
- * @use_underline: whether underlines are interpreted as mnemonics
- *
- * Sets whether underlines in title or subtitle are interpreted as mnemonics.
- *
- * Since: 1.0
- */
-void
-adw_action_row_set_use_underline (AdwActionRow *self,
-                                  gboolean      use_underline)
-{
-  AdwActionRowPrivate *priv;
-
-  g_return_if_fail (ADW_IS_ACTION_ROW (self));
-
-  priv = adw_action_row_get_instance_private (self);
-
-  use_underline = !!use_underline;
-
-  if (priv->use_underline == use_underline)
-    return;
-
-  priv->use_underline = use_underline;
-  adw_preferences_row_set_use_underline (ADW_PREFERENCES_ROW (self), priv->use_underline);
-  gtk_label_set_use_underline (priv->title, priv->use_underline);
-  gtk_label_set_use_underline (priv->subtitle, priv->use_underline);
-  gtk_label_set_mnemonic_widget (priv->title, GTK_WIDGET (self));
-  gtk_label_set_mnemonic_widget (priv->subtitle, GTK_WIDGET (self));
-
-  g_object_notify_by_pspec (G_OBJECT (self), props[PROP_USE_UNDERLINE]);
-}
-
 /**
  * adw_action_row_get_title_lines: (attributes org.gtk.Method.get_property=title-lines)
  * @self: a `AdwActionRow`
diff --git a/src/adw-action-row.h b/src/adw-action-row.h
index bbb50e12..7ed1eae2 100644
--- a/src/adw-action-row.h
+++ b/src/adw-action-row.h
@@ -57,12 +57,6 @@ ADW_AVAILABLE_IN_ALL
 void       adw_action_row_set_activatable_widget (AdwActionRow *self,
                                                   GtkWidget    *widget);
 
-ADW_AVAILABLE_IN_ALL
-gboolean adw_action_row_get_use_underline (AdwActionRow *self);
-ADW_AVAILABLE_IN_ALL
-void     adw_action_row_set_use_underline (AdwActionRow *self,
-                                           gboolean      use_underline);
-
 ADW_AVAILABLE_IN_ALL
 int  adw_action_row_get_title_lines (AdwActionRow *self);
 ADW_AVAILABLE_IN_ALL
diff --git a/src/adw-action-row.ui b/src/adw-action-row.ui
index 15d941a8..fa7c8062 100644
--- a/src/adw-action-row.ui
+++ b/src/adw-action-row.ui
@@ -43,6 +43,8 @@
                 <property name="hexpand">True</property>
                 <property name="label" bind-source="AdwActionRow" bind-property="title" 
bind-flags="sync-create"/>
                 <property name="lines">0</property>
+                <property name="mnemonic-widget">AdwActionRow</property>
+                <property name="use-underline" bind-source="AdwActionRow" bind-property="use-underline" 
bind-flags="sync-create"/>
                 <property name="wrap">True</property>
                 <property name="wrap-mode">word-char</property>
                 <property name="xalign">0</property>
@@ -58,6 +60,7 @@
                 <property name="halign">start</property>
                 <property name="hexpand">True</property>
                 <property name="lines">0</property>
+                <property name="use-underline" bind-source="AdwActionRow" bind-property="use-underline" 
bind-flags="sync-create"/>
                 <property name="wrap">True</property>
                 <property name="wrap-mode">word-char</property>
                 <property name="xalign">0</property>
diff --git a/src/adw-expander-row.c b/src/adw-expander-row.c
index 3bc794d1..84927e47 100644
--- a/src/adw-expander-row.c
+++ b/src/adw-expander-row.c
@@ -389,7 +389,7 @@ adw_expander_row_get_use_underline (AdwExpanderRow *self)
 
   priv = adw_expander_row_get_instance_private (self);
 
-  return adw_action_row_get_use_underline (priv->action_row);
+  return adw_preferences_row_get_use_underline (ADW_PREFERENCES_ROW (priv->action_row));
 }
 
 /**
@@ -411,7 +411,7 @@ adw_expander_row_set_use_underline (AdwExpanderRow *self,
 
   priv = adw_expander_row_get_instance_private (self);
 
-  adw_action_row_set_use_underline (priv->action_row, use_underline);
+  adw_preferences_row_set_use_underline (ADW_PREFERENCES_ROW (priv->action_row), use_underline);
 }
 
 /**
diff --git a/tests/test-action-row.c b/tests/test-action-row.c
index c949e42d..ff9283d3 100644
--- a/tests/test-action-row.c
+++ b/tests/test-action-row.c
@@ -68,24 +68,6 @@ test_adw_action_row_icon_name (void)
 }
 
 
-static void
-test_adw_action_row_use_underline (void)
-{
-  g_autoptr (AdwActionRow) row = NULL;
-
-  row = g_object_ref_sink (ADW_ACTION_ROW (adw_action_row_new ()));
-  g_assert_nonnull (row);
-
-  g_assert_false (adw_action_row_get_use_underline (row));
-
-  adw_action_row_set_use_underline (row, TRUE);
-  g_assert_true (adw_action_row_get_use_underline (row));
-
-  adw_action_row_set_use_underline (row, FALSE);
-  g_assert_false (adw_action_row_get_use_underline (row));
-}
-
-
 static void
 test_adw_action_row_title_lines (void)
 {
@@ -154,7 +136,6 @@ main (int   argc,
   g_test_add_func("/Adwaita/ActionRow/add_remove", test_adw_action_row_add_remove);
   g_test_add_func("/Adwaita/ActionRow/subtitle", test_adw_action_row_subtitle);
   g_test_add_func("/Adwaita/ActionRow/icon_name", test_adw_action_row_icon_name);
-  g_test_add_func("/Adwaita/ActionRow/use_underline", test_adw_action_row_use_underline);
   g_test_add_func("/Adwaita/ActionRow/title_lines", test_adw_action_row_title_lines);
   g_test_add_func("/Adwaita/ActionRow/subtitle_lines", test_adw_action_row_subtitle_lines);
   g_test_add_func("/Adwaita/ActionRow/activate", test_adw_action_row_activate);


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