[libhandy/wip/haecker-felix/flap-widget] Add locked property
- From: Felix Häcker <haeckerfelix src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/haecker-felix/flap-widget] Add locked property
- Date: Sat, 1 Aug 2020 14:05:12 +0000 (UTC)
commit 202fcfb4972dab1e6376e8eabc84d5572d5cd649
Author: Felix Häcker <haeckerfelix gnome org>
Date: Sat Aug 1 16:05:07 2020 +0200
Add locked property
src/hdy-flap.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/hdy-flap.h | 3 +++
2 files changed, 64 insertions(+)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index ba1f1334..c5421fad 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -27,6 +27,7 @@ struct _HdyFlap
HdyFlapFoldPolicy flap_fold_policy;
GtkPackType flap_position;
gboolean reveal_flap;
+ gboolean locked;
gboolean overlay;
gint overlay_duration;
@@ -52,6 +53,7 @@ enum {
PROP_FLAP_FOLD_POLICY,
PROP_FLAP_POSITION,
PROP_REVEAL_FLAP,
+ PROP_LOCKED,
PROP_OVERLAY,
PROP_OVERLAY_DURATION,
@@ -98,6 +100,9 @@ hdy_flap_get_property (GObject *object,
case PROP_REVEAL_FLAP:
g_value_set_boolean (value, hdy_flap_get_reveal_flap (self));
break;
+ case PROP_LOCKED:
+ g_value_set_boolean (value, hdy_flap_get_locked (self));
+ break;
case PROP_OVERLAY:
g_value_set_boolean (value, hdy_flap_get_overlay (self));
break;
@@ -136,6 +141,9 @@ hdy_flap_set_property (GObject *object,
case PROP_REVEAL_FLAP:
hdy_flap_set_reveal_flap (self, g_value_get_boolean (value));
break;
+ case PROP_LOCKED:
+ hdy_flap_set_locked (self, g_value_get_boolean (value));
+ break;
case PROP_OVERLAY_DURATION:
hdy_flap_set_overlay_duration (self, g_value_get_int (value));
break;
@@ -638,6 +646,19 @@ hdy_flap_class_init (HdyFlapClass *klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * HdyFlap:locked:
+ *
+ * Since: 1.0
+ */
+ props[PROP_LOCKED] =
+ g_param_spec_boolean ("locked",
+ _("Locked"),
+ _("Locked"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
+
/**
* HdyFlap:overlay:
*
@@ -692,6 +713,7 @@ hdy_flap_init (HdyFlap *self)
self->flap_position = GTK_PACK_START;
self->flap_fold_policy = HDY_FLAP_FOLD_POLICY_NEVER;
self->reveal_flap = TRUE;
+ self->locked = FALSE;
self->reveal_progress = 1;
self->overlay = FALSE;
self->overlay_progress = 0;
@@ -876,6 +898,45 @@ hdy_flap_set_reveal_flap (HdyFlap *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_REVEAL_FLAP]);
}
+/**
+ * hdy_flap_get_locked:
+ * @self: a #HdyFlap
+ *
+ * Returns: %TRUE if flap widget is locked.
+ *
+ * Since: 1.0
+ */
+gboolean
+hdy_flap_get_locked (HdyFlap *self)
+{
+ g_return_val_if_fail (HDY_IS_FLAP (self), FALSE);
+
+ return self->locked;
+}
+
+/**
+ * hdy_flap_set_locked:
+ * @self: a #HdyFlap
+ * @locked: Reveal flap
+ *
+ * Since: 1.0
+ */
+void
+hdy_flap_set_locked (HdyFlap *self,
+ gboolean locked)
+{
+ g_return_if_fail (HDY_IS_FLAP (self));
+ locked = !!locked;
+
+ if (self->locked == locked)
+ return;
+
+ self->locked = locked;
+ animate_reveal(self);
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_LOCKED]);
+}
+
/**
* hdy_flap_get_overlay:
* @self: a #HdyFlap
diff --git a/src/hdy-flap.h b/src/hdy-flap.h
index b5ef7d23..982d3cc6 100644
--- a/src/hdy-flap.h
+++ b/src/hdy-flap.h
@@ -40,6 +40,9 @@ void hdy_flap_set_flap_position (HdyFlap *self,
gboolean hdy_flap_get_reveal_flap (HdyFlap *self);
void hdy_flap_set_reveal_flap (HdyFlap *self,
gboolean reveal_flap);
+gboolean hdy_flap_get_locked (HdyFlap *self);
+void hdy_flap_set_locked (HdyFlap *self,
+ gboolean locked);
gboolean hdy_flap_get_overlay (HdyFlap *self);
gint hdy_flap_get_overlay_duration (HdyFlap *self);
void hdy_flap_set_overlay_duration (HdyFlap *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]