From 47c7bfba297781f64df24bb1f61e66191f39cbae Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 30 Jul 2024 13:52:26 +0000 Subject: [PATCH] libgimp: Make GimpProgressBar a final type --- libgimp/gimpprogressbar.c | 26 +++++++++++++------------- libgimp/gimpprogressbar.h | 34 +++------------------------------- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/libgimp/gimpprogressbar.c b/libgimp/gimpprogressbar.c index 6c48f17c09..21a9375204 100644 --- a/libgimp/gimpprogressbar.c +++ b/libgimp/gimpprogressbar.c @@ -43,10 +43,13 @@ **/ -typedef struct _GimpProgressBarPrivate +struct _GimpProgressBar { - GBytes *window_handle; -} GimpProgressBarPrivate; + GtkProgressBar parent_instance; + + const gchar *progress_callback; + GBytes *window_handle; +}; static void gimp_progress_bar_dispose (GObject *object); @@ -63,7 +66,7 @@ static void gimp_progress_bar_pulse (gpointer user_data); static GBytes * gimp_progress_bar_get_window_handle (gpointer user_data); -G_DEFINE_TYPE_WITH_PRIVATE (GimpProgressBar, gimp_progress_bar, GTK_TYPE_PROGRESS_BAR) +G_DEFINE_TYPE (GimpProgressBar, gimp_progress_bar, GTK_TYPE_PROGRESS_BAR) #define parent_class gimp_progress_bar_parent_class @@ -79,8 +82,7 @@ gimp_progress_bar_class_init (GimpProgressBarClass *klass) static void gimp_progress_bar_init (GimpProgressBar *bar) { - GimpProgressVtable vtable = { 0, }; - GimpProgressBarPrivate *priv = gimp_progress_bar_get_instance_private (bar); + GimpProgressVtable vtable = { 0, }; gtk_progress_bar_set_text (GTK_PROGRESS_BAR (bar), " "); gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR (bar), PANGO_ELLIPSIZE_END); @@ -94,14 +96,13 @@ gimp_progress_bar_init (GimpProgressBar *bar) bar->progress_callback = gimp_progress_install_vtable (&vtable, bar, NULL); - gimp_widget_set_native_handle (GTK_WIDGET (bar), &priv->window_handle); + gimp_widget_set_native_handle (GTK_WIDGET (bar), &bar->window_handle); } static void gimp_progress_bar_dispose (GObject *object) { - GimpProgressBar *bar = GIMP_PROGRESS_BAR (object); - GimpProgressBarPrivate *priv = gimp_progress_bar_get_instance_private (bar); + GimpProgressBar *bar = GIMP_PROGRESS_BAR (object); if (bar->progress_callback) { @@ -109,7 +110,7 @@ gimp_progress_bar_dispose (GObject *object) bar->progress_callback = NULL; } - gimp_widget_free_native_handle (GTK_WIDGET (bar), &priv->window_handle); + gimp_widget_free_native_handle (GTK_WIDGET (bar), &bar->window_handle); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -186,10 +187,9 @@ gimp_progress_bar_pulse (gpointer user_data) static GBytes * gimp_progress_bar_get_window_handle (gpointer user_data) { - GimpProgressBar *bar = GIMP_PROGRESS_BAR (user_data); - GimpProgressBarPrivate *priv = gimp_progress_bar_get_instance_private (bar); + GimpProgressBar *bar = GIMP_PROGRESS_BAR (user_data); - return g_bytes_ref (priv->window_handle); + return g_bytes_ref (bar->window_handle); } /** diff --git a/libgimp/gimpprogressbar.h b/libgimp/gimpprogressbar.h index 3af45f26ba..15b494beee 100644 --- a/libgimp/gimpprogressbar.h +++ b/libgimp/gimpprogressbar.h @@ -29,39 +29,11 @@ G_BEGIN_DECLS -#define GIMP_TYPE_PROGRESS_BAR (gimp_progress_bar_get_type ()) -#define GIMP_PROGRESS_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROGRESS_BAR, GimpProgressBar)) -#define GIMP_PROGRESS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PROGRESS_BAR, GimpProgressBarClass)) -#define GIMP_IS_PROGRESS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROGRESS_BAR)) -#define GIMP_IS_PROGRESS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PROGRESS_BAR)) -#define GIMP_PROGRESS_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PROGRESS_BAR, GimpProgressBarClass)) +#define GIMP_TYPE_PROGRESS_BAR (gimp_progress_bar_get_type ()) +G_DECLARE_FINAL_TYPE (GimpProgressBar, gimp_progress_bar, GIMP, PROGRESS_BAR, GtkProgressBar) -typedef struct _GimpProgressBarClass GimpProgressBarClass; - -struct _GimpProgressBar -{ - GtkProgressBar parent_instance; - - const gchar *progress_callback; - gboolean cancelable; -}; - -struct _GimpProgressBarClass -{ - GtkProgressBarClass parent_class; - - /* Padding for future expansion */ - void (* _gimp_reserved1) (void); - void (* _gimp_reserved2) (void); - void (* _gimp_reserved3) (void); - void (* _gimp_reserved4) (void); -}; - - -GType gimp_progress_bar_get_type (void) G_GNUC_CONST; - -GtkWidget * gimp_progress_bar_new (void); +GtkWidget * gimp_progress_bar_new (void); G_END_DECLS