[libadwaita/wip/exalm/view-switcher-cleanup: 10/16] view-switcher: Remove narrow-ellipsize
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/view-switcher-cleanup: 10/16] view-switcher: Remove narrow-ellipsize
- Date: Thu, 2 Sep 2021 15:09:34 +0000 (UTC)
commit 722fadf8ba0a7ce9eab8d4b811b94e0596c81b80
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Aug 31 15:45:41 2021 +0500
view-switcher: Remove narrow-ellipsize
Always assume 'end' for the narrow mode, 'none' for the wide mode.
Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/86
doc/migrating-libhandy-1-4-to-libadwaita.md | 5 ++
src/adw-view-switcher-bar.ui | 1 -
src/adw-view-switcher-button-private.h | 3 --
src/adw-view-switcher-button.c | 20 --------
src/adw-view-switcher-button.ui | 2 +
src/adw-view-switcher.c | 78 -----------------------------
src/adw-view-switcher.h | 6 ---
tests/test-view-switcher.c | 19 -------
8 files changed, 7 insertions(+), 127 deletions(-)
---
diff --git a/doc/migrating-libhandy-1-4-to-libadwaita.md b/doc/migrating-libhandy-1-4-to-libadwaita.md
index d5528c70..f93eecc7 100644
--- a/doc/migrating-libhandy-1-4-to-libadwaita.md
+++ b/doc/migrating-libhandy-1-4-to-libadwaita.md
@@ -254,6 +254,11 @@ You should stop using [property@Gtk.Stack:transition-type] and
[property@Gtk.Stack:transition-duration] properties before switching to
[class@Adw.ViewStack].
+### Adapt to [class@Adw.ViewSwitcher] API Changes
+
+The "narrow-ellipsize" property has been removed. Narrow view switchers always
+ellipsize their labels, wide switchers never do.
+
### Adapt to [class@Adw.ViewSwitcherBar] API Changes
The "policy" property has been removed. If you had used it, use a plain
diff --git a/src/adw-view-switcher-bar.ui b/src/adw-view-switcher-bar.ui
index 5a442dad..6f8c3c5a 100644
--- a/src/adw-view-switcher-bar.ui
+++ b/src/adw-view-switcher-bar.ui
@@ -8,7 +8,6 @@
<object class="AdwViewSwitcher" id="view_switcher">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
- <property name="narrow-ellipsize">end</property>
<property name="policy">narrow</property>
</object>
</child>
diff --git a/src/adw-view-switcher-button-private.h b/src/adw-view-switcher-button-private.h
index 12726dcc..9d2f2168 100644
--- a/src/adw-view-switcher-button-private.h
+++ b/src/adw-view-switcher-button-private.h
@@ -41,9 +41,6 @@ const char *adw_view_switcher_button_get_label (AdwViewSwitcherButton *self);
void adw_view_switcher_button_set_label (AdwViewSwitcherButton *self,
const char *label);
-void adw_view_switcher_button_set_narrow_ellipsize (AdwViewSwitcherButton *self,
- PangoEllipsizeMode mode);
-
void adw_view_switcher_button_get_size (AdwViewSwitcherButton *self,
int *h_min_width,
int *h_nat_width,
diff --git a/src/adw-view-switcher-button.c b/src/adw-view-switcher-button.c
index 08260390..a4736b35 100644
--- a/src/adw-view-switcher-button.c
+++ b/src/adw-view-switcher-button.c
@@ -521,26 +521,6 @@ adw_view_switcher_button_set_label (AdwViewSwitcherButton *self,
g_object_notify (G_OBJECT (self), "label");
}
-/**
- * adw_view_switcher_button_set_narrow_ellipsize:
- * @self: a `AdwViewSwitcherButton`
- * @mode: an ellipsize mode
- *
- * Sets the ellipsizing position for the label.
- *
- * Since: 1.0
- **/
-void
-adw_view_switcher_button_set_narrow_ellipsize (AdwViewSwitcherButton *self,
- PangoEllipsizeMode mode)
-{
- g_return_if_fail (ADW_IS_VIEW_SWITCHER_BUTTON (self));
- g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE && mode <= PANGO_ELLIPSIZE_END);
-
- gtk_label_set_ellipsize (self->vertical_label_active, mode);
- gtk_label_set_ellipsize (self->vertical_label_inactive, mode);
-}
-
/**
* adw_view_switcher_button_get_size:
* @self: a `AdwViewSwitcherButton`
diff --git a/src/adw-view-switcher-button.ui b/src/adw-view-switcher-button.ui
index 1e9d4ad8..1d4fc018 100644
--- a/src/adw-view-switcher-button.ui
+++ b/src/adw-view-switcher-button.ui
@@ -93,12 +93,14 @@
<object class="GtkLabel" id="vertical_label_inactive">
<property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
<property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
+ <property name="ellipsize">end</property>
</object>
</child>
<child>
<object class="GtkLabel" id="vertical_label_active">
<property name="label" bind-source="AdwViewSwitcherButton" bind-property="label"
bind-flags="sync-create|bidirectional" />
<property name="use-underline" bind-source="AdwViewSwitcherButton"
bind-property="use-underline" bind-flags="sync-create|bidirectional" />
+ <property name="ellipsize">end</property>
<style>
<class name="active"/>
</style>
diff --git a/src/adw-view-switcher.c b/src/adw-view-switcher.c
index 2b37dd36..45345834 100644
--- a/src/adw-view-switcher.c
+++ b/src/adw-view-switcher.c
@@ -54,7 +54,6 @@
enum {
PROP_0,
PROP_POLICY,
- PROP_NARROW_ELLIPSIZE,
PROP_STACK,
LAST_PROP,
};
@@ -69,7 +68,6 @@ struct _AdwViewSwitcher
GtkBox *box;
AdwViewSwitcherPolicy policy;
- PangoEllipsizeMode narrow_ellipsize;
};
static GParamSpec *props[LAST_PROP];
@@ -159,8 +157,6 @@ add_child (AdwViewSwitcher *self,
GTK_ACCESSIBLE_STATE_SELECTED, selected,
-1);
- adw_view_switcher_button_set_narrow_ellipsize (button, self->narrow_ellipsize);
-
g_signal_connect (button, "notify::active", G_CALLBACK (on_button_toggled), self);
g_signal_connect (page, "notify", G_CALLBACK (on_page_updated), self);
@@ -281,9 +277,6 @@ adw_view_switcher_get_property (GObject *object,
case PROP_POLICY:
g_value_set_enum (value, adw_view_switcher_get_policy (self));
break;
- case PROP_NARROW_ELLIPSIZE:
- g_value_set_enum (value, adw_view_switcher_get_narrow_ellipsize (self));
- break;
case PROP_STACK:
g_value_set_object (value, adw_view_switcher_get_stack (self));
break;
@@ -305,9 +298,6 @@ adw_view_switcher_set_property (GObject *object,
case PROP_POLICY:
adw_view_switcher_set_policy (self, g_value_get_enum (value));
break;
- case PROP_NARROW_ELLIPSIZE:
- adw_view_switcher_set_narrow_ellipsize (self, g_value_get_enum (value));
- break;
case PROP_STACK:
adw_view_switcher_set_stack (self, g_value_get_object (value));
break;
@@ -501,25 +491,6 @@ adw_view_switcher_class_init (AdwViewSwitcherClass *klass)
ADW_VIEW_SWITCHER_POLICY_AUTO,
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- /**
- * AdwViewSwitcher:narrow-ellipsize: (attributes
org.gtk.Property.get=adw_view_switcher_get_narrow_ellipsize
org.gtk.Property.set=adw_view_switcher_set_narrow_ellipsize)
- *
- * The ellipsizing position for the titles.
- *
- * Note that setting this property to a value other than
- * `PANGO_ELLIPSIZE_NONE` has the side-effect that the label requests only
- * enough space to display the ellipsis.
- *
- * Since: 1.0
- */
- props[PROP_NARROW_ELLIPSIZE] =
- g_param_spec_enum ("narrow-ellipsize",
- "Narrow ellipsize",
- "The ellipsizing position for the titles",
- PANGO_TYPE_ELLIPSIZE_MODE,
- PANGO_ELLIPSIZE_NONE,
- G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
-
/**
* AdwViewSwitcher:stack: (attributes org.gtk.Property.get=adw_view_switcher_get_stack
org.gtk.Property.set=adw_view_switcher_set_stack)
*
@@ -609,55 +580,6 @@ adw_view_switcher_set_policy (AdwViewSwitcher *self,
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-/**
- * adw_view_switcher_get_narrow_ellipsize: (attributes org.gtk.Method.get_property=narrow-ellipsize)
- * @self: a `AdwViewSwitcher`
- *
- * Gets the ellipsizing position for the titles.
- *
- * Returns: the ellipsize mode.
- *
- * Since: 1.0
- */
-PangoEllipsizeMode
-adw_view_switcher_get_narrow_ellipsize (AdwViewSwitcher *self)
-{
- g_return_val_if_fail (ADW_IS_VIEW_SWITCHER (self), PANGO_ELLIPSIZE_NONE);
-
- return self->narrow_ellipsize;
-}
-
-/**
- * adw_view_switcher_set_narrow_ellipsize: (attributes org.gtk.Method.set_property=narrow-ellipsize)
- * @self: a `AdwViewSwitcher`
- * @mode: the new value
- *
- * Sets the ellipsizing position for the titles.
- *
- * Since: 1.0
- */
-void
-adw_view_switcher_set_narrow_ellipsize (AdwViewSwitcher *self,
- PangoEllipsizeMode mode)
-{
- GHashTableIter iter;
- gpointer button;
-
- g_return_if_fail (ADW_IS_VIEW_SWITCHER (self));
- g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE && mode <= PANGO_ELLIPSIZE_END);
-
- if ((PangoEllipsizeMode) self->narrow_ellipsize == mode)
- return;
-
- self->narrow_ellipsize = mode;
-
- g_hash_table_iter_init (&iter, self->buttons);
- while (g_hash_table_iter_next (&iter, NULL, &button))
- adw_view_switcher_button_set_narrow_ellipsize (ADW_VIEW_SWITCHER_BUTTON (button), mode);
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NARROW_ELLIPSIZE]);
-}
-
/**
* adw_view_switcher_get_stack: (attributes org.gtk.Method.get_property=stack)
* @self: a `AdwViewSwitcher`
diff --git a/src/adw-view-switcher.h b/src/adw-view-switcher.h
index 265f9d65..b39954f2 100644
--- a/src/adw-view-switcher.h
+++ b/src/adw-view-switcher.h
@@ -39,12 +39,6 @@ ADW_AVAILABLE_IN_ALL
void adw_view_switcher_set_policy (AdwViewSwitcher *self,
AdwViewSwitcherPolicy policy);
-ADW_AVAILABLE_IN_ALL
-PangoEllipsizeMode adw_view_switcher_get_narrow_ellipsize (AdwViewSwitcher *self);
-ADW_AVAILABLE_IN_ALL
-void adw_view_switcher_set_narrow_ellipsize (AdwViewSwitcher *self,
- PangoEllipsizeMode mode);
-
ADW_AVAILABLE_IN_ALL
AdwViewStack *adw_view_switcher_get_stack (AdwViewSwitcher *self);
ADW_AVAILABLE_IN_ALL
diff --git a/tests/test-view-switcher.c b/tests/test-view-switcher.c
index 9e3acb9e..b2157e41 100644
--- a/tests/test-view-switcher.c
+++ b/tests/test-view-switcher.c
@@ -28,24 +28,6 @@ test_adw_view_switcher_policy (void)
}
-static void
-test_adw_view_switcher_narrow_ellipsize (void)
-{
- g_autoptr (AdwViewSwitcher) view_switcher = NULL;
-
- 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_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_NONE);
-
- adw_view_switcher_set_narrow_ellipsize (view_switcher, PANGO_ELLIPSIZE_END);
- g_assert_cmpint (adw_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_END);
-
- adw_view_switcher_set_narrow_ellipsize (view_switcher, PANGO_ELLIPSIZE_NONE);
- g_assert_cmpint (adw_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_NONE);
-}
-
-
static void
test_adw_view_switcher_stack (void)
{
@@ -76,7 +58,6 @@ main (int argc,
adw_init ();
g_test_add_func("/Adwaita/ViewSwitcher/policy", test_adw_view_switcher_policy);
- g_test_add_func("/Adwaita/ViewSwitcher/narrow_ellipsize", test_adw_view_switcher_narrow_ellipsize);
g_test_add_func("/Adwaita/ViewSwitcher/stack", test_adw_view_switcher_stack);
return g_test_run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]