[libadwaita/wip/exalm/view-switcher-cleanup: 9/14] view-switcher: Remove the auto policy
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/view-switcher-cleanup: 9/14] view-switcher: Remove the auto policy
- Date: Thu, 2 Sep 2021 15:14:29 +0000 (UTC)
commit ebc9cee47eb47132b8b8ef261769bf8bf427c85b
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Aug 31 15:50:02 2021 +0500
view-switcher: Remove the auto policy
AdwViewSwitcherTitle uses 2 view switchers now. There's no reason to also
provide the auto policy, and it complicates the code a lot.
doc/migrating-libhandy-1-4-to-libadwaita.md | 12 ++++++++----
src/adw-view-switcher.c | 11 +++--------
src/adw-view-switcher.h | 1 -
tests/test-view-switcher.c | 7 ++-----
4 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/doc/migrating-libhandy-1-4-to-libadwaita.md b/doc/migrating-libhandy-1-4-to-libadwaita.md
index f93eecc7..8d826c66 100644
--- a/doc/migrating-libhandy-1-4-to-libadwaita.md
+++ b/doc/migrating-libhandy-1-4-to-libadwaita.md
@@ -254,6 +254,10 @@ You should stop using [property@Gtk.Stack:transition-type] and
[property@Gtk.Stack:transition-duration] properties before switching to
[class@Adw.ViewStack].
+The `auto` view switcher policy has been removed. [class@Adw.ViewSwitcher] only
+has narrow and wide policies; if you had used the `auto` policy, use an
+[class@Adw.Squeezer] with two view switchers inside.
+
### Adapt to [class@Adw.ViewSwitcher] API Changes
The "narrow-ellipsize" property has been removed. Narrow view switchers always
@@ -266,10 +270,10 @@ The "policy" property has been removed. If you had used it, use a plain
### Adapt to [class@Adw.ViewSwitcherTitle] API Changes
-The "policy" property has been removed, the behavior is similar to the `auto`
-policy. If you had used `wide` or `narrow` policies, use an [class@Adw.Squeezer]
-with an [class@Adw.ViewSwitcher] and an [class@Adw.WindowTitle] inside, with the
-switcher having the desired policy.
+The "policy" property has been removed, the behavior is similar to the removed
+`auto` policy. If you had used `wide` or `narrow` policies, use an
+[class@Adw.Squeezer] with an [class@Adw.ViewSwitcher] and an
+[class@Adw.WindowTitle] inside, with the switcher having the desired policy.
### Adapt to [class@Adw.Avatar] API Changes
diff --git a/src/adw-view-switcher.c b/src/adw-view-switcher.c
index 45345834..3e3b73fa 100644
--- a/src/adw-view-switcher.c
+++ b/src/adw-view-switcher.c
@@ -42,7 +42,6 @@
/**
* AdwViewSwitcherPolicy:
- * @ADW_VIEW_SWITCHER_POLICY_AUTO: Automatically adapt to the best fitting mode
* @ADW_VIEW_SWITCHER_POLICY_NARROW: Force the narrow mode
* @ADW_VIEW_SWITCHER_POLICY_WIDE: Force the wide mode
*
@@ -371,6 +370,7 @@ adw_view_switcher_measure (GtkWidget *widget,
switch (self->policy) {
case ADW_VIEW_SWITCHER_POLICY_NARROW:
+ default:
min = max_v_min * n_children;
nat = max_v_nat * n_children;
break;
@@ -378,11 +378,6 @@ adw_view_switcher_measure (GtkWidget *widget,
min = max_h_min * n_children;
nat = max_h_nat * n_children;
break;
- case ADW_VIEW_SWITCHER_POLICY_AUTO:
- default:
- min = max_v_min * n_children;
- nat = max_h_nat * n_children;
- break;
}
} else {
while (g_hash_table_iter_next (&iter, (gpointer *) &page, (gpointer *) &button)) {
@@ -488,7 +483,7 @@ adw_view_switcher_class_init (AdwViewSwitcherClass *klass)
"Policy",
"The policy to determine the mode to use",
ADW_TYPE_VIEW_SWITCHER_POLICY,
- ADW_VIEW_SWITCHER_POLICY_AUTO,
+ ADW_VIEW_SWITCHER_POLICY_NARROW,
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
/**
@@ -550,7 +545,7 @@ adw_view_switcher_new (void)
AdwViewSwitcherPolicy
adw_view_switcher_get_policy (AdwViewSwitcher *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_SWITCHER (self), ADW_VIEW_SWITCHER_POLICY_AUTO);
+ g_return_val_if_fail (ADW_IS_VIEW_SWITCHER (self), ADW_VIEW_SWITCHER_POLICY_NARROW);
return self->policy;
}
diff --git a/src/adw-view-switcher.h b/src/adw-view-switcher.h
index b39954f2..5682fbb0 100644
--- a/src/adw-view-switcher.h
+++ b/src/adw-view-switcher.h
@@ -25,7 +25,6 @@ ADW_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (AdwViewSwitcher, adw_view_switcher, ADW, VIEW_SWITCHER, GtkWidget)
typedef enum {
- ADW_VIEW_SWITCHER_POLICY_AUTO,
ADW_VIEW_SWITCHER_POLICY_NARROW,
ADW_VIEW_SWITCHER_POLICY_WIDE,
} AdwViewSwitcherPolicy;
diff --git a/tests/test-view-switcher.c b/tests/test-view-switcher.c
index b2157e41..dafc5463 100644
--- a/tests/test-view-switcher.c
+++ b/tests/test-view-switcher.c
@@ -15,16 +15,13 @@ test_adw_view_switcher_policy (void)
view_switcher = g_object_ref_sink (ADW_VIEW_SWITCHER (adw_view_switcher_new ()));
g_assert_nonnull (view_switcher);
- g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_AUTO);
-
- adw_view_switcher_set_policy (view_switcher, ADW_VIEW_SWITCHER_POLICY_NARROW);
g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_NARROW);
adw_view_switcher_set_policy (view_switcher, ADW_VIEW_SWITCHER_POLICY_WIDE);
g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_WIDE);
- adw_view_switcher_set_policy (view_switcher, ADW_VIEW_SWITCHER_POLICY_AUTO);
- g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_AUTO);
+ adw_view_switcher_set_policy (view_switcher, ADW_VIEW_SWITCHER_POLICY_NARROW);
+ g_assert_cmpint (adw_view_switcher_get_policy (view_switcher), ==, ADW_VIEW_SWITCHER_POLICY_NARROW);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]