[libadwaita/wip/exalm/animation-cleanup: 2/10] animation: Split AdwAnimationTarget into a separate file




commit d1851d13d858421908999ad979030bd0b78727c1
Author: Manuel Genovés <manuel genoves gmail com>
Date:   Tue Nov 16 02:15:45 2021 +0500

    animation: Split AdwAnimationTarget into a separate file

 src/adw-animation-private.h        | 17 +++-------
 src/adw-animation-target-private.h | 32 +++++++++++++++++++
 src/adw-animation-target.c         | 63 ++++++++++++++++++++++++++++++++++++++
 src/adw-animation.c                | 48 +----------------------------
 src/meson.build                    |  1 +
 5 files changed, 101 insertions(+), 60 deletions(-)
---
diff --git a/src/adw-animation-private.h b/src/adw-animation-private.h
index 34db2b51..b710d8d8 100644
--- a/src/adw-animation-private.h
+++ b/src/adw-animation-private.h
@@ -11,23 +11,14 @@
 #error "Only <adwaita.h> can be included directly."
 #endif
 
-#include <gtk/gtk.h>
 #include "adw-version.h"
-#include "adw-enums-private.h"
-
-G_BEGIN_DECLS
-typedef void   (*AdwAnimationTargetFunc) (double   value,
-                                          gpointer user_data);
 
-#define ADW_TYPE_ANIMATION_TARGET (adw_animation_target_get_type())
-
-G_DECLARE_FINAL_TYPE (AdwAnimationTarget, adw_animation_target, ADW, ANIMATION_TARGET, GObject)
+#include <gtk/gtk.h>
 
-AdwAnimationTarget *adw_animation_target_new (AdwAnimationTargetFunc callback,
-                                              gpointer               data);
+#include "adw-enums-private.h"
+#include "adw-animation-target-private.h"
 
-void adw_animation_target_set_value (AdwAnimationTarget *target,
-                                     double              value);
+G_BEGIN_DECLS
 
 #define ADW_TYPE_ANIMATION (adw_animation_get_type())
 
diff --git a/src/adw-animation-target-private.h b/src/adw-animation-target-private.h
new file mode 100644
index 00000000..f8428758
--- /dev/null
+++ b/src/adw-animation-target-private.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Manuel Genovés <manuel genoves gmail com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#pragma once
+
+#if !defined(_ADWAITA_INSIDE) && !defined(ADWAITA_COMPILATION)
+#error "Only <adwaita.h> can be included directly."
+#endif
+
+#include "adw-version.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef void (*AdwAnimationTargetFunc) (double   value,
+                                        gpointer user_data);
+
+#define ADW_TYPE_ANIMATION_TARGET (adw_animation_target_get_type())
+
+G_DECLARE_FINAL_TYPE (AdwAnimationTarget, adw_animation_target, ADW, ANIMATION_TARGET, GObject)
+
+AdwAnimationTarget *adw_animation_target_new (AdwAnimationTargetFunc callback,
+                                              gpointer               user_data);
+
+void adw_animation_target_set_value (AdwAnimationTarget *self,
+                                     double              value);
+
+G_END_DECLS
diff --git a/src/adw-animation-target.c b/src/adw-animation-target.c
new file mode 100644
index 00000000..32b04e6e
--- /dev/null
+++ b/src/adw-animation-target.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2021 Manuel Genovés <manuel genoves gmail com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "config.h"
+
+#include "adw-animation-target-private.h"
+#include "adw-macros-private.h"
+
+struct _AdwAnimationTarget
+{
+  GObject parent_instance;
+
+  AdwAnimationTargetFunc callback;
+  gpointer user_data;
+};
+
+struct _AdwAnimationTargetClass
+{
+  GObjectClass parent_class;
+
+  void (*set_value) (AdwAnimationTarget *self,
+                     double              value);
+};
+
+G_DEFINE_FINAL_TYPE (AdwAnimationTarget, adw_animation_target, G_TYPE_OBJECT)
+
+static void
+adw_animation_target_class_init (AdwAnimationTargetClass *klass)
+{
+}
+
+static void
+adw_animation_target_init (AdwAnimationTarget *self)
+{
+}
+
+AdwAnimationTarget *
+adw_animation_target_new (AdwAnimationTargetFunc callback,
+                          gpointer               user_data)
+{
+  AdwAnimationTarget *self;
+
+  g_return_val_if_fail (callback != NULL, NULL);
+
+  self = g_object_new (ADW_TYPE_ANIMATION_TARGET, NULL);
+
+  self->callback = callback;
+  self->user_data = user_data;
+
+  return self;
+}
+
+void
+adw_animation_target_set_value (AdwAnimationTarget *self,
+                                double              value)
+{
+  g_return_if_fail (ADW_IS_ANIMATION_TARGET (self));
+
+  self->callback (value, self->user_data);
+}
diff --git a/src/adw-animation.c b/src/adw-animation.c
index 22b200a8..5ae48d22 100644
--- a/src/adw-animation.c
+++ b/src/adw-animation.c
@@ -7,9 +7,8 @@
 
 #include "config.h"
 
-#include "adw-animation-util-private.h"
 #include "adw-animation-private.h"
-#include "adw-macros-private.h"
+#include "adw-animation-util-private.h"
 
 typedef struct
 {
@@ -599,48 +598,3 @@ adw_animation_set_status (AdwAnimation       *self,
 
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATUS]);
 }
-
-struct _AdwAnimationTarget
-{
-  GObject parent_instance;
-
-  AdwAnimationTargetFunc callback;
-  gpointer user_data;
-};
-
-G_DEFINE_FINAL_TYPE (AdwAnimationTarget, adw_animation_target, G_TYPE_OBJECT);
-
-static void
-adw_animation_target_class_init (AdwAnimationTargetClass *klass)
-{
-}
-
-static void
-adw_animation_target_init (AdwAnimationTarget *self)
-{
-}
-
-AdwAnimationTarget *
-adw_animation_target_new (AdwAnimationTargetFunc callback,
-                          gpointer               user_data)
-{
-  AdwAnimationTarget *self;
-
-  g_return_val_if_fail (callback != NULL, NULL);
-
-  self = g_object_new (ADW_TYPE_ANIMATION_TARGET, NULL);
-
-  self->callback = callback;
-  self->user_data = user_data;
-
-  return self;
-}
-
-void
-adw_animation_target_set_value (AdwAnimationTarget *self,
-                                double              value)
-{
-  g_return_if_fail (ADW_IS_ANIMATION_TARGET (self));
-
-  self->callback (value, self->user_data);
-}
diff --git a/src/meson.build b/src/meson.build
index 27d68eeb..d7329b6d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -138,6 +138,7 @@ src_sources = [
   'gtkprogresstracker.c',
   'adw-action-row.c',
   'adw-animation.c',
+  'adw-animation-target.c',
   'adw-animation-util.c',
   'adw-application.c',
   'adw-application-window.c',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]