[libadwaita/wip/exalm/carousel-refactor: 147/149] carousel-box: Rename AdwCarouselBoxChildInfo to ChildInfo
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/carousel-refactor: 147/149] carousel-box: Rename AdwCarouselBoxChildInfo to ChildInfo
- Date: Fri, 30 Apr 2021 07:25:02 +0000 (UTC)
commit 50ac8b54e6526729af308cd41f6ed2603b8d09ec
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Feb 21 20:15:48 2021 +0500
carousel-box: Rename AdwCarouselBoxChildInfo to ChildInfo
No need to namespace it, it's all static.
src/adw-carousel-box.c | 77 +++++++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 41 deletions(-)
---
diff --git a/src/adw-carousel-box.c b/src/adw-carousel-box.c
index 9815dcc..f6e3fe7 100644
--- a/src/adw-carousel-box.c
+++ b/src/adw-carousel-box.c
@@ -24,10 +24,7 @@
* Since: 1.0
*/
-typedef struct _AdwCarouselBoxChildInfo AdwCarouselBoxChildInfo;
-
-struct _AdwCarouselBoxChildInfo
-{
+typedef struct {
GtkWidget *widget;
int position;
gboolean visible;
@@ -38,7 +35,7 @@ struct _AdwCarouselBoxChildInfo
gboolean shift_position;
AdwAnimation *resize_animation;
-};
+} ChildInfo;
struct _AdwCarouselBox
{
@@ -46,7 +43,7 @@ struct _AdwCarouselBox
double animation_source_position;
AdwAnimation *animation;
- AdwCarouselBoxChildInfo *animation_target_child;
+ ChildInfo *animation_target_child;
GList *children;
double distance;
@@ -82,14 +79,14 @@ enum {
};
static guint signals[SIGNAL_LAST_SIGNAL];
-static AdwCarouselBoxChildInfo *
+static ChildInfo *
find_child_info (AdwCarouselBox *self,
GtkWidget *widget)
{
GList *l;
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *info = l->data;
+ ChildInfo *info = l->data;
if (widget == info->widget)
return info;
@@ -108,7 +105,7 @@ find_child_index (AdwCarouselBox *self,
i = 0;
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *info = l->data;
+ ChildInfo *info = l->data;
if (info->removing && !count_removing)
continue;
@@ -132,7 +129,7 @@ get_nth_link (AdwCarouselBox *self,
i = n;
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *info = l->data;
+ ChildInfo *info = l->data;
if (info->removing)
continue;
@@ -144,17 +141,17 @@ get_nth_link (AdwCarouselBox *self,
return NULL;
}
-static AdwCarouselBoxChildInfo *
+static ChildInfo *
get_closest_child_at (AdwCarouselBox *self,
double position,
gboolean count_adding,
gboolean count_removing)
{
GList *l;
- AdwCarouselBoxChildInfo *closest_child = NULL;
+ ChildInfo *closest_child = NULL;
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *child = l->data;
+ ChildInfo *child = l->data;
if (child->adding && !count_adding)
continue;
@@ -187,10 +184,10 @@ set_position (AdwCarouselBox *self,
}
static void
-update_shift_position_flag (AdwCarouselBox *self,
- AdwCarouselBoxChildInfo *child)
+update_shift_position_flag (AdwCarouselBox *self,
+ ChildInfo *child)
{
- AdwCarouselBoxChildInfo *closest_child;
+ ChildInfo *closest_child;
int animating_index, closest_index;
/* We want to still shift position when the active child is being removed */
@@ -206,8 +203,8 @@ update_shift_position_flag (AdwCarouselBox *self,
}
static void
-resize_animation_value_cb (double value,
- AdwCarouselBoxChildInfo *child)
+resize_animation_value_cb (double value,
+ ChildInfo *child)
{
AdwCarouselBox *self = ADW_CAROUSEL_BOX (adw_animation_get_widget (child->resize_animation));
double delta = value - child->size;
@@ -221,7 +218,7 @@ resize_animation_value_cb (double value,
}
static void
-resize_animation_done_cb (AdwCarouselBoxChildInfo *child)
+resize_animation_done_cb (ChildInfo *child)
{
AdwCarouselBox *self = ADW_CAROUSEL_BOX (adw_animation_get_widget (child->resize_animation));
@@ -240,10 +237,10 @@ resize_animation_done_cb (AdwCarouselBoxChildInfo *child)
}
static void
-animate_child (AdwCarouselBox *self,
- AdwCarouselBoxChildInfo *child,
- double value,
- gint64 duration)
+animate_child (AdwCarouselBox *self,
+ ChildInfo *child,
+ double value,
+ gint64 duration)
{
double old_size = child->size;
@@ -285,7 +282,7 @@ adw_carousel_box_measure (GtkWidget *widget,
*natural_baseline = -1;
for (children = self->children; children; children = children->next) {
- AdwCarouselBoxChildInfo *child_info = children->data;
+ ChildInfo *child_info = children->data;
GtkWidget *child = child_info->widget;
int child_min, child_nat;
@@ -326,7 +323,7 @@ adw_carousel_box_size_allocate (GtkWidget *widget,
size = 0;
for (children = self->children; children; children = children->next) {
- AdwCarouselBoxChildInfo *child_info = children->data;
+ ChildInfo *child_info = children->data;
GtkWidget *child = child_info->widget;
int min, nat;
int child_size;
@@ -366,7 +363,7 @@ adw_carousel_box_size_allocate (GtkWidget *widget,
snap_point = 0;
for (children = self->children; children; children = children->next) {
- AdwCarouselBoxChildInfo *child_info = children->data;
+ ChildInfo *child_info = children->data;
child_info->snap_point = snap_point + child_info->size - 1;
@@ -394,8 +391,7 @@ adw_carousel_box_size_allocate (GtkWidget *widget,
x -= offset;
for (children = self->children; children; children = children->next) {
- AdwCarouselBoxChildInfo *child_info = children->data;
-
+ ChildInfo *child_info = children->data;
GskTransform *transform = gsk_transform_new ();
if (!child_info->removing) {
@@ -678,13 +674,13 @@ adw_carousel_box_insert (AdwCarouselBox *self,
GtkWidget *widget,
int position)
{
- AdwCarouselBoxChildInfo *info;
+ ChildInfo *info;
GList *prev_link;
g_return_if_fail (ADW_IS_CAROUSEL_BOX (self));
g_return_if_fail (GTK_IS_WIDGET (widget));
- info = g_new0 (AdwCarouselBoxChildInfo, 1);
+ info = g_new0 (ChildInfo, 1);
info->widget = widget;
info->size = 0;
info->adding = TRUE;
@@ -723,7 +719,7 @@ adw_carousel_box_reorder (AdwCarouselBox *self,
GtkWidget *widget,
int position)
{
- AdwCarouselBoxChildInfo *info, *prev_info;
+ ChildInfo *info, *prev_info;
GList *link, *prev_link;
int old_position;
double closest_point, old_point, new_point;
@@ -740,7 +736,7 @@ adw_carousel_box_reorder (AdwCarouselBox *self,
if (position == old_position)
return;
- old_point = ((AdwCarouselBoxChildInfo *) link->data)->snap_point;
+ old_point = ((ChildInfo *) link->data)->snap_point;
if (position < 0 || position >= adw_carousel_box_get_n_pages (self))
prev_link = g_list_last (self->children);
@@ -767,9 +763,8 @@ void
adw_carousel_box_remove (AdwCarouselBox *self,
GtkWidget *widget)
{
- AdwCarouselBoxChildInfo *info;
+ ChildInfo *info = find_child_info (self, widget);
- info = find_child_info (self, widget);
if (!info)
return;
@@ -906,7 +901,7 @@ adw_carousel_box_get_n_pages (AdwCarouselBox *self)
n_pages = 0;
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *child = l->data;
+ ChildInfo *child = l->data;
if (!child->removing)
n_pages++;
@@ -971,7 +966,7 @@ adw_carousel_box_set_position (AdwCarouselBox *self,
set_position (self, position);
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *child = l->data;
+ ChildInfo *child = l->data;
if (child->adding || child->removing)
update_shift_position_flag (self, child);
@@ -1077,7 +1072,7 @@ GtkWidget *
adw_carousel_box_get_nth_child (AdwCarouselBox *self,
guint n)
{
- AdwCarouselBoxChildInfo *info;
+ ChildInfo *info;
g_return_val_if_fail (ADW_IS_CAROUSEL_BOX (self), NULL);
g_return_val_if_fail (n < adw_carousel_box_get_n_pages (self), NULL);
@@ -1115,7 +1110,7 @@ adw_carousel_box_get_snap_points (AdwCarouselBox *self,
i = 0;
for (l = self->children; l; l = l->next) {
- AdwCarouselBoxChildInfo *info = l->data;
+ ChildInfo *info = l->data;
points[i++] = info->snap_point;
}
@@ -1142,7 +1137,7 @@ adw_carousel_box_get_range (AdwCarouselBox *self,
double *upper)
{
GList *l;
- AdwCarouselBoxChildInfo *child;
+ ChildInfo *child;
g_return_if_fail (ADW_IS_CAROUSEL_BOX (self));
@@ -1169,7 +1164,7 @@ adw_carousel_box_get_range (AdwCarouselBox *self,
double
adw_carousel_box_get_closest_snap_point (AdwCarouselBox *self)
{
- AdwCarouselBoxChildInfo *closest_child;
+ ChildInfo *closest_child;
closest_child = get_closest_child_at (self, self->position, TRUE, TRUE);
@@ -1197,7 +1192,7 @@ adw_carousel_box_get_page_at_position (AdwCarouselBox *self,
double position)
{
double lower, upper;
- AdwCarouselBoxChildInfo *child;
+ ChildInfo *child;
g_return_val_if_fail (ADW_IS_CAROUSEL_BOX (self), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]