[libadwaita/wip/exalm/swipe-group: 23/29] swipeable: Remove switch_child()
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/swipe-group: 23/29] swipeable: Remove switch_child()
- Date: Fri, 30 Apr 2021 07:36:33 +0000 (UTC)
commit 694301cc2645829da13c0f737284b739313d1f33
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Feb 26 14:33:54 2021 +0500
swipeable: Remove switch_child()
This was only needed for AdwSwipeGroup.
src/adw-carousel.c | 16 ---------
src/adw-flap.c | 26 +++------------
src/adw-leaflet.c | 93 ++++++-----------------------------------------------
src/adw-swipeable.c | 78 --------------------------------------------
src/adw-swipeable.h | 15 ---------
5 files changed, 15 insertions(+), 213 deletions(-)
---
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index a3ead5f..d997a68 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -1082,17 +1082,6 @@ adw_carousel_buildable_init (GtkBuildableIface *iface)
iface->add_child = adw_carousel_buildable_add_child;
}
-static void
-adw_carousel_switch_child (AdwSwipeable *swipeable,
- guint index,
- gint64 duration)
-{
- AdwCarousel *self = ADW_CAROUSEL (swipeable);
- GtkWidget *child = adw_carousel_get_nth_page (self, index);
-
- scroll_to (self, child, duration);
-}
-
static AdwSwipeTracker *
adw_carousel_get_swipe_tracker (AdwSwipeable *swipeable)
{
@@ -1153,7 +1142,6 @@ adw_carousel_get_cancel_progress (AdwSwipeable *swipeable)
static void
adw_carousel_swipeable_init (AdwSwipeableInterface *iface)
{
- iface->switch_child = adw_carousel_switch_child;
iface->get_swipe_tracker = adw_carousel_get_swipe_tracker;
iface->get_distance = adw_carousel_get_distance;
iface->get_snap_points = adw_carousel_get_snap_points;
@@ -1386,15 +1374,11 @@ adw_carousel_scroll_to_full (AdwCarousel *self,
GtkWidget *widget,
gint64 duration)
{
- int index;
-
g_return_if_fail (ADW_IS_CAROUSEL (self));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (duration >= 0);
- index = find_child_index (self, widget, FALSE);
scroll_to (self, widget, duration);
- adw_swipeable_emit_child_switched (ADW_SWIPEABLE (self), index, duration);
}
/**
diff --git a/src/adw-flap.c b/src/adw-flap.c
index ce25878..4f0ba38 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -346,8 +346,7 @@ animate_reveal (AdwFlap *self,
static void
set_reveal_flap (AdwFlap *self,
gboolean reveal_flap,
- gint64 duration,
- gboolean emit_child_switched)
+ guint64 duration)
{
reveal_flap = !!reveal_flap;
@@ -356,13 +355,9 @@ set_reveal_flap (AdwFlap *self,
self->reveal_flap = reveal_flap;
- if (!self->swipe_active) {
+ if (!self->swipe_active)
animate_reveal (self, reveal_flap ? 1 : 0, duration);
- if (emit_child_switched)
- adw_swipeable_emit_child_switched (ADW_SWIPEABLE (self), reveal_flap ? 1 : 0, duration);
- }
-
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_REVEAL_FLAP]);
}
@@ -391,7 +386,7 @@ set_folded (AdwFlap *self,
animate_fold (self);
if (!self->locked)
- set_reveal_flap (self, !self->folded, self->fold_duration, TRUE);
+ set_reveal_flap (self, !self->folded, self->fold_duration);
context = gtk_widget_get_style_context (GTK_WIDGET (self));
if (folded) {
@@ -458,7 +453,7 @@ end_swipe_cb (AdwSwipeTracker *tracker,
if ((to > 0) == self->reveal_flap)
animate_reveal (self, to, duration);
else
- set_reveal_flap (self, to > 0, duration, FALSE);
+ set_reveal_flap (self, to > 0, duration);
}
static void
@@ -1603,16 +1598,6 @@ adw_flap_buildable_init (GtkBuildableIface *iface)
iface->add_child = adw_flap_add_child;
}
-static void
-adw_flap_switch_child (AdwSwipeable *swipeable,
- guint index,
- gint64 duration)
-{
- AdwFlap *self = ADW_FLAP (swipeable);
-
- set_reveal_flap (self, index > 0, duration, FALSE);
-}
-
static AdwSwipeTracker *
adw_flap_get_swipe_tracker (AdwSwipeable *swipeable)
{
@@ -1769,7 +1754,6 @@ adw_flap_get_swipe_area (AdwSwipeable *swipeable,
static void
adw_flap_swipeable_init (AdwSwipeableInterface *iface)
{
- iface->switch_child = adw_flap_switch_child;
iface->get_swipe_tracker = adw_flap_get_swipe_tracker;
iface->get_distance = adw_flap_get_distance;
iface->get_snap_points = adw_flap_get_snap_points;
@@ -2027,7 +2011,7 @@ adw_flap_set_reveal_flap (AdwFlap *self,
{
g_return_if_fail (ADW_IS_FLAP (self));
- set_reveal_flap (self, reveal_flap, self->reveal_duration, TRUE);
+ set_reveal_flap (self, reveal_flap, self->reveal_duration);
}
/**
diff --git a/src/adw-leaflet.c b/src/adw-leaflet.c
index e60dae8..5c2c721 100644
--- a/src/adw-leaflet.c
+++ b/src/adw-leaflet.c
@@ -736,8 +736,7 @@ static void
set_visible_child (AdwLeaflet *self,
AdwLeafletPage *page,
AdwLeafletTransitionType transition_type,
- guint transition_duration,
- gboolean emit_child_switched)
+ guint transition_duration)
{
GtkWidget *widget = GTK_WIDGET (self);
GtkRoot *root;
@@ -860,26 +859,6 @@ set_visible_child (AdwLeaflet *self,
start_child_transition (self, transition_duration, transition_direction);
}
- if (emit_child_switched) {
- int index = 0;
- GList *l;
-
- for (l = self->children; l; l = l->next) {
- AdwLeafletPage *p = l->data;
-
- if (!p->navigatable)
- continue;
-
- if (p == page)
- break;
-
- index++;
- }
-
- adw_swipeable_emit_child_switched (ADW_SWIPEABLE (self), index,
- transition_duration);
- }
-
if (self->pages) {
if (old_pos == GTK_INVALID_LIST_POSITION && new_pos == GTK_INVALID_LIST_POSITION)
; /* nothing to do */
@@ -1544,9 +1523,9 @@ update_child_visible (AdwLeaflet *self,
enabled = gtk_widget_get_visible (page->widget);
if (self->visible_child == NULL && enabled)
- set_visible_child (self, page, self->transition_type, self->child_transition.duration, TRUE);
+ set_visible_child (self, page, self->transition_type, self->child_transition.duration);
else if (self->visible_child == page && !enabled)
- set_visible_child (self, NULL, self->transition_type, self->child_transition.duration, TRUE);
+ set_visible_child (self, NULL, self->transition_type, self->child_transition.duration);
if (page == self->last_visible_child) {
gtk_widget_set_child_visible (self->last_visible_child->widget, FALSE);
@@ -1620,7 +1599,7 @@ begin_swipe_cb (AdwSwipeTracker *tracker,
if (page) {
self->child_transition.is_gesture_active = TRUE;
set_visible_child (self, page, self->transition_type,
- self->child_transition.duration, FALSE);
+ self->child_transition.duration);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CHILD_TRANSITION_RUNNING]);
}
@@ -1672,8 +1651,6 @@ add_page (AdwLeaflet *self,
AdwLeafletPage *page,
AdwLeafletPage *sibling_page)
{
- int visible_child_pos_before_insert = -1;
- int visible_child_pos_after_insert = -1;
GList *l;
g_return_if_fail (page->widget != NULL);
@@ -1689,9 +1666,6 @@ add_page (AdwLeaflet *self,
}
}
- if (self->visible_child)
- visible_child_pos_before_insert = g_list_index (self->children, self->visible_child);
-
g_object_ref (page);
if (!sibling_page) {
@@ -1707,9 +1681,6 @@ add_page (AdwLeaflet *self,
g_list_insert (self->children_reversed, page, length - sibling_pos - 1);
}
- if (self->visible_child)
- visible_child_pos_after_insert = g_list_index (self->children, self->visible_child);
-
gtk_widget_set_child_visible (page->widget, FALSE);
if (self->transition_type == ADW_LEAFLET_TRANSITION_TYPE_OVER)
@@ -1731,12 +1702,7 @@ add_page (AdwLeaflet *self,
if (self->visible_child == NULL &&
gtk_widget_get_visible (page->widget))
set_visible_child (self, page, self->transition_type,
- self->child_transition.duration, FALSE);
- else if (visible_child_pos_before_insert != visible_child_pos_after_insert)
- adw_swipeable_emit_child_switched (ADW_SWIPEABLE (self),
- visible_child_pos_after_insert,
- 0);
-
+ self->child_transition.duration);
if (!self->folded ||
(self->folded && (self->homogeneous[ADW_FOLD_FOLDED][GTK_ORIENTATION_HORIZONTAL] ||
self->homogeneous[ADW_FOLD_FOLDED][GTK_ORIENTATION_VERTICAL] ||
@@ -1772,7 +1738,7 @@ leaflet_remove (AdwLeaflet *self,
if (in_dispose)
self->visible_child = NULL;
else
- set_visible_child (self, NULL, self->transition_type, self->child_transition.duration, TRUE);
+ set_visible_child (self, NULL, self->transition_type, self->child_transition.duration);
}
if (self->last_visible_child == page)
@@ -2536,36 +2502,6 @@ adw_leaflet_buildable_init (GtkBuildableIface *iface)
iface->add_child = adw_leaflet_buildable_add_child;
}
-static void
-adw_leaflet_switch_child (AdwSwipeable *swipeable,
- guint index,
- gint64 duration)
-{
- AdwLeaflet *self = ADW_LEAFLET (swipeable);
- AdwLeafletPage *page = NULL;
- GList *l;
- guint i = 0;
-
- for (l = self->children; l; l = l->next) {
- page = l->data;
-
- if (!page->navigatable)
- continue;
-
- if (i == index)
- break;
-
- i++;
- }
-
- if (page == NULL) {
- g_critical ("Couldn't find eligible child with index %u", index);
- return;
- }
-
- set_visible_child (self, page, self->transition_type, duration, FALSE);
-}
-
static AdwSwipeTracker *
adw_leaflet_get_swipe_tracker (AdwSwipeable *swipeable)
{
@@ -2724,7 +2660,6 @@ adw_leaflet_get_swipe_area (AdwSwipeable *swipeable,
static void
adw_leaflet_swipeable_init (AdwSwipeableInterface *iface)
{
- iface->switch_child = adw_leaflet_switch_child;
iface->get_swipe_tracker = adw_leaflet_get_swipe_tracker;
iface->get_distance = adw_leaflet_get_distance;
iface->get_snap_points = adw_leaflet_get_snap_points;
@@ -2874,7 +2809,7 @@ adw_leaflet_page_set_navigatable (AdwLeafletPage *self,
if (self == leaflet->visible_child)
set_visible_child (leaflet, NULL, leaflet->transition_type,
- leaflet->child_transition.duration, TRUE);
+ leaflet->child_transition.duration);
}
g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_NAVIGATABLE]);
@@ -2994,8 +2929,6 @@ adw_leaflet_reorder_child_after (AdwLeaflet *self,
AdwLeafletPage *child_page;
AdwLeafletPage *sibling_page;
int sibling_page_pos;
- int visible_child_pos_before_reorder;
- int visible_child_pos_after_reorder;
int previous_position;
g_return_if_fail (ADW_IS_LEAFLET (self));
@@ -3008,7 +2941,6 @@ adw_leaflet_reorder_child_after (AdwLeaflet *self,
if (child == sibling)
return;
- visible_child_pos_before_reorder = g_list_index (self->children, self->visible_child);
previous_position = g_list_index (self->children, child) - 1;
/* Cancel a gesture if there's one in progress */
@@ -3045,11 +2977,6 @@ adw_leaflet_reorder_child_after (AdwLeaflet *self,
max = MAX (position, previous_position) + 1;
g_list_model_items_changed (G_LIST_MODEL (self->pages), min, max - min, max - min);
}
-
- visible_child_pos_after_reorder = g_list_index (self->children, self->visible_child);
-
- if (visible_child_pos_before_reorder != visible_child_pos_after_reorder)
- adw_swipeable_emit_child_switched (ADW_SWIPEABLE (self), visible_child_pos_after_reorder, 0);
}
/**
@@ -3381,7 +3308,7 @@ adw_leaflet_set_visible_child (AdwLeaflet *self,
g_return_if_fail (contains_child);
- set_visible_child (self, page, self->transition_type, self->child_transition.duration, TRUE);
+ set_visible_child (self, page, self->transition_type, self->child_transition.duration);
}
/**
@@ -3431,7 +3358,7 @@ adw_leaflet_set_visible_child_name (AdwLeaflet *self,
g_return_if_fail (contains_child);
- set_visible_child (self, page, self->transition_type, self->child_transition.duration, TRUE);
+ set_visible_child (self, page, self->transition_type, self->child_transition.duration);
}
/**
@@ -3644,7 +3571,7 @@ adw_leaflet_navigate (AdwLeaflet *self,
if (!page)
return FALSE;
- set_visible_child (self, page, self->transition_type, self->child_transition.duration, TRUE);
+ set_visible_child (self, page, self->transition_type, self->child_transition.duration);
return TRUE;
}
diff --git a/src/adw-swipeable.c b/src/adw-swipeable.c
index 5ab520a..4ae0297 100644
--- a/src/adw-swipeable.c
+++ b/src/adw-swipeable.c
@@ -23,87 +23,9 @@
G_DEFINE_INTERFACE (AdwSwipeable, adw_swipeable, GTK_TYPE_WIDGET)
-enum {
- SIGNAL_CHILD_SWITCHED,
- SIGNAL_LAST_SIGNAL,
-};
-
-static guint signals[SIGNAL_LAST_SIGNAL];
-
static void
adw_swipeable_default_init (AdwSwipeableInterface *iface)
{
- /**
- * AdwSwipeable::child-switched:
- * @self: The #AdwSwipeable instance
- * @index: the index of the child to switch to
- * @duration: Animation duration in milliseconds
- *
- * This signal should be emitted when the widget's visible child is changed.
- *
- * @duration can be 0 if the child is switched without animation.
- *
- * This is used by #AdwSwipeGroup, applications should not connect to it.
- *
- * Since: 1.0
- */
- signals[SIGNAL_CHILD_SWITCHED] =
- g_signal_new ("child-switched",
- G_TYPE_FROM_INTERFACE (iface),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 2,
- G_TYPE_UINT, G_TYPE_INT64);
-}
-
-/**
- * adw_swipeable_switch_child:
- * @self: a #AdwSwipeable
- * @index: the index of the child to switch to
- * @duration: Animation duration in milliseconds
- *
- * See AdwSwipeable::child-switched.
- *
- * Since: 1.0
- */
-void
-adw_swipeable_switch_child (AdwSwipeable *self,
- guint index,
- gint64 duration)
-{
- AdwSwipeableInterface *iface;
-
- g_return_if_fail (ADW_IS_SWIPEABLE (self));
-
- iface = ADW_SWIPEABLE_GET_IFACE (self);
- g_return_if_fail (iface->switch_child != NULL);
-
- iface->switch_child (self, index, duration);
-}
-
-/**
- * adw_swipeable_emit_child_switched:
- * @self: a #AdwSwipeable
- * @index: the index of the child to switch to
- * @duration: Animation duration in milliseconds
- *
- * Emits AdwSwipeable::child-switched signal. This should be called when the
- * widget switches visible child widget.
- *
- * @duration can be 0 if the child is switched without animation.
- *
- * Since: 1.0
- */
-void
-adw_swipeable_emit_child_switched (AdwSwipeable *self,
- guint index,
- gint64 duration)
-{
- g_return_if_fail (ADW_IS_SWIPEABLE (self));
-
- g_signal_emit (self, signals[SIGNAL_CHILD_SWITCHED], 0, index, duration);
}
/**
diff --git a/src/adw-swipeable.h b/src/adw-swipeable.h
index 514d893..a081eaf 100644
--- a/src/adw-swipeable.h
+++ b/src/adw-swipeable.h
@@ -26,7 +26,6 @@ G_DECLARE_INTERFACE (AdwSwipeable, adw_swipeable, ADW, SWIPEABLE, GtkWidget)
/**
* AdwSwipeableInterface:
* @parent: The parent interface.
- * @switch_child: Switches visible child.
* @get_swipe_tracker: Gets the swipe tracker.
* @get_distance: Gets the swipe distance.
* @get_snap_points: Gets the snap points
@@ -42,10 +41,6 @@ struct _AdwSwipeableInterface
{
GTypeInterface parent;
- void (*switch_child) (AdwSwipeable *self,
- guint index,
- gint64 duration);
-
AdwSwipeTracker * (*get_swipe_tracker) (AdwSwipeable *self);
double (*get_distance) (AdwSwipeable *self);
double * (*get_snap_points) (AdwSwipeable *self,
@@ -61,16 +56,6 @@ struct _AdwSwipeableInterface
gpointer padding[4];
};
-ADW_AVAILABLE_IN_ALL
-void adw_swipeable_switch_child (AdwSwipeable *self,
- guint index,
- gint64 duration);
-
-ADW_AVAILABLE_IN_ALL
-void adw_swipeable_emit_child_switched (AdwSwipeable *self,
- guint index,
- gint64 duration);
-
ADW_AVAILABLE_IN_ALL
AdwSwipeTracker *adw_swipeable_get_swipe_tracker (AdwSwipeable *self);
ADW_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]