[totem/wip/hadess/simplify-decls: 8/8] skipto: Simplify TotemTimeEntry declaration




commit c46aad13a5fcab08241a70d841aba8ecc12754bf
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 31 16:48:38 2022 +0200

    skipto: Simplify TotemTimeEntry declaration

 src/plugins/skipto/totem-time-entry.c | 35 ++++++++++++++++-------------------
 src/plugins/skipto/totem-time-entry.h | 17 +----------------
 2 files changed, 17 insertions(+), 35 deletions(-)
---
diff --git a/src/plugins/skipto/totem-time-entry.c b/src/plugins/skipto/totem-time-entry.c
index 501d1784a..bd632b4fc 100644
--- a/src/plugins/skipto/totem-time-entry.c
+++ b/src/plugins/skipto/totem-time-entry.c
@@ -42,12 +42,13 @@ static gint input_cb (GtkSpinButton *self, gdouble *new_value, gpointer user_dat
 static void notify_adjustment_cb (TotemTimeEntry *self, GParamSpec *pspec, gpointer user_data);
 static void changed_cb (GtkAdjustment *adjustment, TotemTimeEntry *self);
 
-struct TotemTimeEntryPrivate {
+struct _TotemTimeEntry {
+       GtkSpinButton parent;
        GtkAdjustment *adjustment;
        gulong adjustment_changed_signal;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (TotemTimeEntry, totem_time_entry, GTK_TYPE_SPIN_BUTTON)
+G_DEFINE_TYPE (TotemTimeEntry, totem_time_entry, GTK_TYPE_SPIN_BUTTON)
 
 static gint64
 totem_string_to_time (const char *time_string)
@@ -82,8 +83,6 @@ totem_time_entry_class_init (TotemTimeEntryClass *klass)
 static void
 totem_time_entry_init (TotemTimeEntry *self)
 {
-       self->priv = totem_time_entry_get_instance_private (self);
-
        /* Connect to signals */
        g_signal_connect (self, "output", G_CALLBACK (output_cb), NULL);
        g_signal_connect (self, "input", G_CALLBACK (input_cb), NULL);
@@ -93,13 +92,13 @@ totem_time_entry_init (TotemTimeEntry *self)
 static void
 dispose (GObject *object)
 {
-       TotemTimeEntryPrivate *priv = TOTEM_TIME_ENTRY (object)->priv;
+       TotemTimeEntry *entry = TOTEM_TIME_ENTRY (object);
 
-       if (priv->adjustment != NULL) {
-               g_signal_handler_disconnect (priv->adjustment, priv->adjustment_changed_signal);
-               g_object_unref (priv->adjustment);
+       if (entry->adjustment != NULL) {
+               g_signal_handler_disconnect (entry->adjustment, entry->adjustment_changed_signal);
+               g_object_unref (entry->adjustment);
        }
-       priv->adjustment = NULL;
+       entry->adjustment = NULL;
 
        G_OBJECT_CLASS (totem_time_entry_parent_class)->dispose (object);
 }
@@ -143,19 +142,17 @@ input_cb (GtkSpinButton *self, gdouble *new_value, gpointer user_data)
 static void
 notify_adjustment_cb (TotemTimeEntry *self, GParamSpec *pspec, gpointer user_data)
 {
-       TotemTimeEntryPrivate *priv = self->priv;
-
-       if (priv->adjustment != NULL) {
-               g_signal_handler_disconnect (priv->adjustment, priv->adjustment_changed_signal);
-               g_object_unref (priv->adjustment);
+       if (self->adjustment != NULL) {
+               g_signal_handler_disconnect (self->adjustment, self->adjustment_changed_signal);
+               g_object_unref (self->adjustment);
        }
 
-       priv->adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (self));
-       priv->adjustment_changed_signal = 0;
+       self->adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (self));
+       self->adjustment_changed_signal = 0;
 
-       if (priv->adjustment != NULL) {
-               g_object_ref (priv->adjustment);
-               priv->adjustment_changed_signal = g_signal_connect (priv->adjustment, "changed", G_CALLBACK 
(changed_cb), self);
+       if (self->adjustment != NULL) {
+               g_object_ref (self->adjustment);
+               self->adjustment_changed_signal = g_signal_connect (self->adjustment, "changed", G_CALLBACK 
(changed_cb), self);
        }
 }
 
diff --git a/src/plugins/skipto/totem-time-entry.h b/src/plugins/skipto/totem-time-entry.h
index e0a7f3197..cfc4cbe36 100644
--- a/src/plugins/skipto/totem-time-entry.h
+++ b/src/plugins/skipto/totem-time-entry.h
@@ -34,22 +34,7 @@
 #include <gtk/gtk.h>
 
 #define TOTEM_TYPE_TIME_ENTRY          (totem_time_entry_get_type ())
-#define TOTEM_TIME_ENTRY(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), TOTEM_TYPE_TIME_ENTRY, 
TotemTimeEntry))
-#define TOTEM_TIME_ENTRY_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), TOTEM_TYPE_TIME_ENTRY, 
TotemTimeEntryClass))
-#define TOTEM_IS_TIME_ENTRY(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), TOTEM_TYPE_TIME_ENTRY))
-#define TOTEM_IS_TIME_ENTRY_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), TOTEM_TYPE_TIME_ENTRY))
-#define TOTEM_TIME_ENTRY_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), TOTEM_TYPE_TIME_ENTRY, 
TotemTimeEntryClass))
-
-typedef struct TotemTimeEntryPrivate   TotemTimeEntryPrivate;
-
-typedef struct {
-       GtkSpinButton parent;
-       TotemTimeEntryPrivate *priv;
-} TotemTimeEntry;
-
-typedef struct {
-       GtkSpinButtonClass parent;
-} TotemTimeEntryClass;
+G_DECLARE_FINAL_TYPE(TotemTimeEntry, totem_time_entry, TOTEM, TIME_ENTRY, GtkSpinButton)
 
 GType totem_time_entry_get_type (void);
 GtkWidget *totem_time_entry_new (GtkAdjustment *adjustment, gdouble climb_rate);


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