[libhandy/wip/haecker-felix/flap-widget] Proper swipeable + buildable
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/haecker-felix/flap-widget] Proper swipeable + buildable
- Date: Tue, 17 Nov 2020 14:53:52 +0000 (UTC)
commit 75c44c32df1aeaf124d30a70dd21bd9b35a933d3
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 17 19:53:38 2020 +0500
Proper swipeable + buildable
src/hdy-flap.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index 160e805d..17b8fa0e 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -59,10 +59,12 @@ struct _HdyFlap
HdySwipeTracker *tracker;
};
+static void hdy_flap_buildable_init (GtkBuildableIface *iface);
static void hdy_flap_swipeable_init (HdySwipeableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (HdyFlap, hdy_flap, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, hdy_flap_buildable_init)
G_IMPLEMENT_INTERFACE (HDY_TYPE_SWIPEABLE, hdy_flap_swipeable_init))
enum {
@@ -247,8 +249,6 @@ set_reveal_flap (HdyFlap *self,
guint64 duration,
gboolean emit_child_switched)
{
- gboolean is_end;
-
reveal_flap = !!reveal_flap;
if (self->reveal_flap == reveal_flap)
@@ -258,8 +258,7 @@ set_reveal_flap (HdyFlap *self,
animate_reveal (self, reveal_flap ? 1 : 0, duration);
- is_end = self->flap_position == GTK_PACK_END;
- hdy_swipeable_emit_child_switched (HDY_SWIPEABLE (self), (is_end == reveal_flap) ? 1 : 0, duration);
+ hdy_swipeable_emit_child_switched (HDY_SWIPEABLE (self), reveal_flap ? 1 : 0, duration);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_REVEAL_FLAP]);
}
@@ -927,15 +926,34 @@ hdy_flap_init (HdyFlap *self)
update_swipe_tracker (self);
}
+static void
+hdy_flap_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type)
+{
+ if (type && !g_strcmp0 (type, "flap"))
+ hdy_flap_set_flap (HDY_FLAP (buildable), GTK_WIDGET (child));
+ else if (!type)
+ gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
+ else
+ GTK_BUILDER_WARN_INVALID_CHILD_TYPE (HDY_FLAP (buildable), type);
+}
+
+static void
+hdy_flap_buildable_init (GtkBuildableIface *iface)
+{
+ iface->add_child = hdy_flap_add_child;
+}
+
static void
hdy_flap_switch_child (HdySwipeable *swipeable,
guint index,
gint64 duration)
{
HdyFlap *self = HDY_FLAP (swipeable);
- gboolean is_end = self->flap_position == GTK_PACK_END;
- set_reveal_flap (self, is_end == (index > 0), duration, FALSE);
+ set_reveal_flap (self, index > 0, duration, FALSE);
}
static HdySwipeTracker *
@@ -1155,10 +1173,9 @@ hdy_flap_get_flap_position (HdyFlap *self)
* Since: 1.1
*/
void
-hdy_flap_set_flap_position (HdyFlap *self,
- GtkPackType position)
+hdy_flap_set_flap_position (HdyFlap *self,
+ GtkPackType position)
{
-
g_return_if_fail (HDY_IS_FLAP (self));
if (self->flap_position == position)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]