[libhandy/wip/haecker-felix/flap-widget] Modal
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/haecker-felix/flap-widget] Modal
- Date: Wed, 25 Nov 2020 10:13:06 +0000 (UTC)
commit 7453f827624dae0f8874e2d5f37bb177769cd47b
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Nov 25 14:53:57 2020 +0500
Modal
debian/libhandy-1-0.symbols | 4 +--
examples/hdy-flap-demo-window.ui | 11 ++++---
src/hdy-flap.c | 68 ++++++++++++++++++++--------------------
src/hdy-flap.h | 6 ++--
tests/test-flap.c | 22 ++++++-------
5 files changed, 56 insertions(+), 55 deletions(-)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index 5a6ce245..39f2f1dc 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -121,7 +121,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
hdy_expander_row_set_subtitle@LIBHANDY_1_0 0.80.0
hdy_expander_row_set_use_underline@LIBHANDY_1_0 0.80.0
hdy_flap_fold_policy_get_type@LIBHANDY_1_0 1.1.0
- hdy_flap_get_click_to_close@LIBHANDY_1_0 1.1.0
hdy_flap_get_content@LIBHANDY_1_0 1.1.0
hdy_flap_get_flap@LIBHANDY_1_0 1.1.0
hdy_flap_get_flap_position@LIBHANDY_1_0 1.1.0
@@ -129,6 +128,7 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
hdy_flap_get_fold_policy@LIBHANDY_1_0 1.1.0
hdy_flap_get_folded@LIBHANDY_1_0 1.1.0
hdy_flap_get_locked@LIBHANDY_1_0 1.1.0
+ hdy_flap_get_modal@LIBHANDY_1_0 1.1.0
hdy_flap_get_reveal_duration@LIBHANDY_1_0 1.1.0
hdy_flap_get_reveal_flap@LIBHANDY_1_0 1.1.0
hdy_flap_get_reveal_progress@LIBHANDY_1_0 1.1.0
@@ -138,12 +138,12 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
hdy_flap_get_transition_type@LIBHANDY_1_0 1.1.0
hdy_flap_get_type@LIBHANDY_1_0 1.1.0
hdy_flap_new@LIBHANDY_1_0 1.1.0
- hdy_flap_set_click_to_close@LIBHANDY_1_0 1.1.0
hdy_flap_set_flap@LIBHANDY_1_0 1.1.0
hdy_flap_set_flap_position@LIBHANDY_1_0 1.1.0
hdy_flap_set_fold_duration@LIBHANDY_1_0 1.1.0
hdy_flap_set_fold_policy@LIBHANDY_1_0 1.1.0
hdy_flap_set_locked@LIBHANDY_1_0 1.1.0
+ hdy_flap_set_modal@LIBHANDY_1_0 1.1.0
hdy_flap_set_reveal_duration@LIBHANDY_1_0 1.1.0
hdy_flap_set_reveal_flap@LIBHANDY_1_0 1.1.0
hdy_flap_set_separator@LIBHANDY_1_0 1.1.0
diff --git a/examples/hdy-flap-demo-window.ui b/examples/hdy-flap-demo-window.ui
index 0a6e39c1..1995beef 100644
--- a/examples/hdy-flap-demo-window.ui
+++ b/examples/hdy-flap-demo-window.ui
@@ -51,7 +51,7 @@
<property name="locked" bind-source="locked_switch" bind-property="active"
bind-flags="sync-create"/>
<property name="fold-policy" bind-source="fold_policy_row" bind-property="selected-index"/>
<property name="transition-type" bind-source="transition_type_row"
bind-property="selected-index"/>
- <property name="click-to-close" bind-source="click_to_close_switch" bind-property="active"
bind-flags="sync-create"/>
+ <property name="modal" bind-source="modal_switch" bind-property="active"
bind-flags="sync-create"/>
<property name="swipe-to-open" bind-source="swipe_to_open_switch" bind-property="active"
bind-flags="sync-create"/>
<property name="swipe-to-close" bind-source="swipe_to_close_switch" bind-property="active"
bind-flags="sync-create"/>
<child type="flap">
@@ -171,11 +171,12 @@
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
- <property name="title" translatable="yes">Click to Close</property>
- <property name="subtitle" translatable="yes">Clicking outside the sidebar will
close it when folded</property>
- <property name="activatable_widget">click_to_close_switch</property>
+ <property name="title" translatable="yes">Modal</property>
+ <property name="subtitle" translatable="yes">Clicking outside the sidebar or
pressing Esc will close it when folded</property>
+ <property name="subtitle-lines">2</property>
+ <property name="activatable_widget">modal_switch</property>
<child>
- <object class="GtkSwitch" id="click_to_close_switch">
+ <object class="GtkSwitch" id="modal_switch">
<property name="visible">True</property>
<property name="valign">center</property>
<property name="active">True</property>
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index 167a931d..58b4d062 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -92,7 +92,7 @@ struct _HdyFlap
HdySwipeTracker *tracker;
gboolean swipe_active;
- gboolean click_to_close;
+ gboolean modal;
GtkGesture *click_gesture;
};
@@ -117,7 +117,7 @@ enum {
PROP_FOLDED,
PROP_LOCKED,
PROP_TRANSITION_TYPE,
- PROP_CLICK_TO_CLOSE,
+ PROP_MODAL,
PROP_SWIPE_TO_OPEN,
PROP_SWIPE_TO_CLOSE,
@@ -899,7 +899,7 @@ hdy_flap_size_allocate (GtkWidget *widget,
allocate_child (self, &self->content, FALSE);
allocate_child (self, &self->separator, FALSE);
allocate_child (self, &self->flap,
- self->click_to_close &&
+ self->modal &&
self->reveal_progress > 0 &&
self->fold_progress > 0);
@@ -1277,8 +1277,8 @@ hdy_flap_get_property (GObject *object,
case PROP_TRANSITION_TYPE:
g_value_set_enum (value, hdy_flap_get_transition_type (self));
break;
- case PROP_CLICK_TO_CLOSE:
- g_value_set_boolean (value, hdy_flap_get_click_to_close (self));
+ case PROP_MODAL:
+ g_value_set_boolean (value, hdy_flap_get_modal (self));
break;
case PROP_SWIPE_TO_OPEN:
g_value_set_boolean (value, hdy_flap_get_swipe_to_open (self));
@@ -1330,8 +1330,8 @@ hdy_flap_set_property (GObject *object,
case PROP_TRANSITION_TYPE:
hdy_flap_set_transition_type (self, g_value_get_enum (value));
break;
- case PROP_CLICK_TO_CLOSE:
- hdy_flap_set_click_to_close (self, g_value_get_boolean (value));
+ case PROP_MODAL:
+ hdy_flap_set_modal (self, g_value_get_boolean (value));
break;
case PROP_SWIPE_TO_OPEN:
hdy_flap_set_swipe_to_open (self, g_value_get_boolean (value));
@@ -1539,20 +1539,20 @@ hdy_flap_class_init (HdyFlapClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
- * HdyFlap:click-to-close:
+ * HdyFlap:modal:
*
- * Whether the flap can be closed with a click.
+ * Whether the flap is modal.
*
- * If %TRUE, the flap can be closed with a click on the content widget while
- * flap is revealed. If %FALSE, clicks are passed through to the content
- * widget.
+ * If %TRUE, clicking the content widget while flap is revealed, as well as
+ * pressing Escape key, will close the flap. If %FALSE, clicks are passed
+ * through to the content widget.
*
* Since: 1.1
*/
- props[PROP_CLICK_TO_CLOSE] =
- g_param_spec_boolean ("click-to-close",
- _("Click to Close"),
- _("Whether the flap can be closed with a click"),
+ props[PROP_MODAL] =
+ g_param_spec_boolean ("modal",
+ _("Modal"),
+ _("Whether the flap is modal"),
TRUE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
@@ -1611,7 +1611,7 @@ hdy_flap_init (HdyFlap *self)
self->fold_progress = 0;
self->fold_duration = 250;
self->reveal_duration = 250;
- self->click_to_close = TRUE;
+ self->modal = TRUE;
self->swipe_to_open = TRUE;
self->swipe_to_close = TRUE;
@@ -2297,52 +2297,52 @@ hdy_flap_set_transition_type (HdyFlap *self,
}
/**
- * hdy_flap_get_click_to_close:
+ * hdy_flap_get_modal:
* @self: a #HdyFlap
*
- * Gets whether the @self can be closed with a click.
+ * Gets whether the @self is modal. See hdy_flap_set_modal().
*
- * Returns: %TRUE if @self can be closed with a click
+ * Returns: %TRUE if @self is modal
*
* Since: 1.1
*/
gboolean
-hdy_flap_get_click_to_close (HdyFlap *self)
+hdy_flap_get_modal (HdyFlap *self)
{
g_return_val_if_fail (HDY_IS_FLAP (self), FALSE);
- return self->click_to_close;
+ return self->modal;
}
/**
- * hdy_flap_set_click_to_close:
+ * hdy_flap_set_modal:
* @self: a #HdyFlap
- * @click_to_close: Whether @self can be closed with a click
+ * @modal: Whether @self can be closed with a click
*
* Sets whether the @self can be closed with a click.
*
- * If @click_to_close is %TRUE, @self can be closed with a click on the content
- * widget while flap is revealed. If %FALSE, clicks are passed through to the
- * content widget.
+ * If @modal %TRUE, clicking the content widget while flap is revealed, as well
+ * as pressing Escape key, will close the flap. If %FALSE, clicks are passed
+ * through to the content widget.
*
* Since: 1.1
*/
void
-hdy_flap_set_click_to_close (HdyFlap *self,
- gboolean click_to_close)
+hdy_flap_set_modal (HdyFlap *self,
+ gboolean modal)
{
GtkPropagationPhase phase = GTK_PHASE_NONE;
g_return_if_fail (HDY_IS_FLAP (self));
- click_to_close = !!click_to_close;
+ modal = !!modal;
- if (self->click_to_close == click_to_close)
+ if (self->modal == modal)
return;
- self->click_to_close = click_to_close;
+ self->modal = modal;
- if (click_to_close)
+ if (modal)
phase = GTK_PHASE_CAPTURE;
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->click_gesture),
@@ -2350,7 +2350,7 @@ hdy_flap_set_click_to_close (HdyFlap *self,
gtk_widget_queue_allocate (GTK_WIDGET (self));
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CLICK_TO_CLOSE]);
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_MODAL]);
}
/**
diff --git a/src/hdy-flap.h b/src/hdy-flap.h
index d669f7a2..d11ae6e1 100644
--- a/src/hdy-flap.h
+++ b/src/hdy-flap.h
@@ -102,10 +102,10 @@ void hdy_flap_set_transition_type (HdyFlap *self,
HdyFlapTransitionType transition_type);
HDY_AVAILABLE_IN_1_1
-gboolean hdy_flap_get_click_to_close (HdyFlap *self);
+gboolean hdy_flap_get_modal (HdyFlap *self);
HDY_AVAILABLE_IN_1_1
-void hdy_flap_set_click_to_close (HdyFlap *self,
- gboolean click_to_close);
+void hdy_flap_set_modal (HdyFlap *self,
+ gboolean modal);
HDY_AVAILABLE_IN_1_1
gboolean hdy_flap_get_swipe_to_open (HdyFlap *self);
diff --git a/tests/test-flap.c b/tests/test-flap.c
index cee3416f..8492c623 100644
--- a/tests/test-flap.c
+++ b/tests/test-flap.c
@@ -313,10 +313,10 @@ test_hdy_flap_transition_type (void)
}
static void
-test_hdy_flap_click_to_close (void)
+test_hdy_flap_modal (void)
{
g_autoptr (HdyFlap) flap = NULL;
- gboolean click_to_close;
+ gboolean modal;
flap = g_object_ref_sink (HDY_FLAP (hdy_flap_new ()));
g_assert_nonnull (flap);
@@ -324,20 +324,20 @@ test_hdy_flap_click_to_close (void)
hdy_flap_set_flap (flap, gtk_button_new ());
notified = 0;
- g_signal_connect (flap, "notify::click-to-close", G_CALLBACK (notify_cb), NULL);
+ g_signal_connect (flap, "notify::modal", G_CALLBACK (notify_cb), NULL);
- g_object_get (flap, "click-to-close", &click_to_close, NULL);
- g_assert_true (click_to_close);
+ g_object_get (flap, "modal", &modal, NULL);
+ g_assert_true (modal);
- hdy_flap_set_click_to_close (flap, TRUE);
+ hdy_flap_set_modal (flap, TRUE);
g_assert_cmpint (notified, ==, 0);
- hdy_flap_set_click_to_close (flap, FALSE);
- g_assert_false (hdy_flap_get_click_to_close (flap));
+ hdy_flap_set_modal (flap, FALSE);
+ g_assert_false (hdy_flap_get_modal (flap));
g_assert_cmpint (notified, ==, 1);
- g_object_set (flap, "click-to-close", TRUE, NULL);
- g_assert_true (hdy_flap_get_click_to_close (flap));
+ g_object_set (flap, "modal", TRUE, NULL);
+ g_assert_true (hdy_flap_get_modal (flap));
g_assert_cmpint (notified, ==, 2);
}
@@ -417,7 +417,7 @@ main (gint argc,
g_test_add_func ("/Handy/Flap/folded", test_hdy_flap_folded);
g_test_add_func ("/Handy/Flap/locked", test_hdy_flap_locked);
g_test_add_func ("/Handy/Flap/transition_type", test_hdy_flap_transition_type);
- g_test_add_func ("/Handy/Flap/click_to_close", test_hdy_flap_click_to_close);
+ g_test_add_func ("/Handy/Flap/modal", test_hdy_flap_modal);
g_test_add_func ("/Handy/Flap/swipe_to_open", test_hdy_flap_swipe_to_open);
g_test_add_func ("/Handy/Flap/swipe_to_close", test_hdy_flap_swipe_to_close);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]