[libhandy/wip/haecker-felix/flap-widget: 85/98] properly use getter/setter
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/haecker-felix/flap-widget: 85/98] properly use getter/setter
- Date: Mon, 3 Aug 2020 16:27:56 +0000 (UTC)
commit 73c2494e485ad121b9450eee76597d2741fb98bb
Author: Felix Häcker <haeckerfelix gnome org>
Date: Tue Jul 28 18:45:59 2020 +0200
properly use getter/setter
src/hdy-flap.c | 63 ++++++++++++++++++++++++----------------------------------
1 file changed, 26 insertions(+), 37 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index ddc5d30c..e171d1bd 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -272,6 +272,22 @@ adjust_for_text_direction (HdyFlap *self,
return pack_type;
}
+static void
+set_overlay (HdyFlap *self,
+ gboolean overlay)
+{
+ g_return_if_fail (HDY_IS_FLAP (self));
+ overlay = !!overlay;
+
+ if (self->reveal_flap == overlay)
+ return;
+
+ self->overlay = overlay;
+ animate_overlay(self);
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_OVERLAY]);
+}
+
/* This private method is prefixed by the call name because it will be a virtual
* method in GTK 4.
*/
@@ -285,7 +301,7 @@ hdy_flap_measure (GtkWidget *widget,
int *natural_baseline)
{
HdyFlap *self = HDY_FLAP (widget);
- GtkWidget *content = gtk_bin_get_child ( GTK_BIN (self));
+ GtkWidget *content = gtk_bin_get_child (GTK_BIN (self));
gint content_min = 0, content_nat = 0;
gint flap_min = 0, flap_nat = 0;
@@ -335,7 +351,7 @@ get_flap_size (HdyFlap *self,
if (!self->flap)
return 0;
- gtk_widget_get_preferred_size (hdy_flap_get_flap (self), &flap_min_size, &flap_nat_size);
+ gtk_widget_get_preferred_size (self->flap, &flap_min_size, &flap_nat_size);
if (widget_orientation == GTK_ORIENTATION_HORIZONTAL) {
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -426,7 +442,7 @@ allocate_content (HdyFlap *self,
if (self->orientation == GTK_ORIENTATION_HORIZONTAL){
int min = content_min.width + flap_min.width;
if (self->flap_mode == HDY_FLAP_MODE_AUTO)
- self->overlay = widget_alloc-> width <= min;
+ set_overlay (self, widget_alloc->width <= min);
if (self->flap_position == adjust_for_text_direction (self, GTK_PACK_START)){
content_x = widget_alloc->x + adjust_for_overlay (self, get_flap_size(self, widget_alloc,
GTK_ORIENTATION_HORIZONTAL));
@@ -440,7 +456,7 @@ allocate_content (HdyFlap *self,
if (self->orientation == GTK_ORIENTATION_VERTICAL){
gint min = content_min.height + flap_min.height;
- if (self->flap_mode == HDY_FLAP_MODE_AUTO) self->overlay = widget_alloc->height <= min;
+ if (self->flap_mode == HDY_FLAP_MODE_AUTO) set_overlay (self, widget_alloc->height <= min);
if (self->flap_position == GTK_PACK_START){
content_x = widget_alloc->x;
@@ -469,7 +485,7 @@ hdy_flap_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, alloc);
- if (!hdy_flap_get_flap (self))
+ if (!self->flap)
allocate_flap (self, alloc);
if (content)
@@ -525,7 +541,6 @@ hdy_flap_forall (GtkContainer *container,
{
HdyFlap * self;
GtkWidget* content;
- GtkWidget* flap;
self = HDY_FLAP (container);
content = gtk_bin_get_child (GTK_BIN (self));
@@ -533,9 +548,8 @@ hdy_flap_forall (GtkContainer *container,
callback (content, callback_target);
}
- flap = hdy_flap_get_flap (self);
- if (flap) {
- callback (flap, callback_target);
+ if (self->flap) {
+ callback (self->flap, callback_target);
}
}
@@ -544,13 +558,11 @@ hdy_flap_remove (GtkContainer *base,
GtkWidget *widget)
{
HdyFlap * self;
- GtkWidget* flap;
self = HDY_FLAP (base);
g_return_if_fail (widget);
- flap = hdy_flap_get_flap (self);
- if (widget == flap) {
+ if (widget == self->flap) {
hdy_flap_set_flap (self, NULL);
} else {
gtk_container_remove (GTK_CONTAINER (self), widget);
@@ -700,9 +712,9 @@ hdy_flap_new (void)
/**
* hdy_flap_get_flap:
- * @self: a #HdyFlap
+ * @flap: (nullable): a #HdyFlap
*
- * Returns: Flap child.
+ * Returns: (transfer none): Flap child.
*
* Since: 1.0
*/
@@ -864,29 +876,6 @@ hdy_flap_get_overlay (HdyFlap *self)
return self->overlay;
}
-/**
- * hdy_flap_set_overlay:
- * @self: a #HdyFlap
- * @overlay: Overlay flap
- *
- * Since: 1.0
- */
-static void
-hdy_flap_set_overlay (HdyFlap *self,
- gboolean overlay)
-{
- g_return_if_fail (HDY_IS_FLAP (self));
- overlay = !!overlay;
-
- if (self->reveal_flap == overlay)
- return;
-
- self->overlay = overlay;
- animate_overlay(self);
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_OVERLAY]);
-}
-
/**
* hdy_flap_get_overlay_duration:
* @self: a #HdyFlap
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]