libgnt/libgnt

Fix the deprecation warnings around GntProgressBar
release-2.x.y
5 weeks ago, Gary Kramlich
3a32f08efbb5
Parents 20f8c9dcfbed
Children 687d59e7ec52
Fix the deprecation warnings around GntProgressBar

Testing Done:
Compiled and verified the warnings were gone.

Reviewed at https://reviews.imfreedom.org/r/3067/
--- a/gntprogressbar.c Sun Dec 17 01:51:40 2023 -0600
+++ b/gntprogressbar.c Tue Apr 09 21:17:43 2024 -0500
@@ -38,19 +38,19 @@
GntWidget parent;
};
-#define GNT_PROGRESS_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNT_TYPE_PROGRESS_BAR, GntProgressBarPrivate))
-
-static GntWidgetClass *parent_class = NULL;
-
+G_DEFINE_TYPE_WITH_PRIVATE(GntProgressBar, gnt_progress_bar, GNT_TYPE_WIDGET)
static void
gnt_progress_bar_draw (GntWidget *widget)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (GNT_PROGRESS_BAR (widget));
+ GntProgressBar *progress_bar = GNT_PROGRESS_BAR(widget);
+ GntProgressBarPrivate *priv = NULL;
gchar progress[8];
gint start, end, i, pos;
int color;
+ priv = gnt_progress_bar_get_instance_private(progress_bar);
+
g_snprintf (progress, sizeof (progress), "%.1f%%", priv->fraction * 100);
color = gnt_color_pair(GNT_COLOR_NORMAL);
@@ -115,23 +115,21 @@
}
static void
-gnt_progress_bar_class_init (gpointer klass, gpointer class_data)
+gnt_progress_bar_class_init (GntProgressBarClass *klass)
{
- GObjectClass *g_class = G_OBJECT_CLASS (klass);
+ GntWidgetClass *widget_class = GNT_WIDGET_CLASS(klass);
- parent_class = GNT_WIDGET_CLASS (klass);
-
- g_type_class_add_private (g_class, sizeof (GntProgressBarPrivate));
-
- parent_class->draw = gnt_progress_bar_draw;
- parent_class->size_request = gnt_progress_bar_size_request;
+ widget_class->draw = gnt_progress_bar_draw;
+ widget_class->size_request = gnt_progress_bar_size_request;
}
static void
-gnt_progress_bar_init (GTypeInstance *instance, gpointer g_class)
+gnt_progress_bar_init (GntProgressBar *progress_bar)
{
- GntWidget *widget = GNT_WIDGET (instance);
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (GNT_PROGRESS_BAR (widget));
+ GntWidget *widget = GNT_WIDGET (progress_bar);
+ GntProgressBarPrivate *priv = NULL;
+
+ priv = gnt_progress_bar_get_instance_private(progress_bar);
gnt_widget_set_take_focus (widget, FALSE);
gnt_widget_set_has_border(widget, FALSE);
@@ -144,31 +142,6 @@
priv->show_value = TRUE;
}
-GType
-gnt_progress_bar_get_type (void)
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof (GntProgressBarClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- gnt_progress_bar_class_init, /* class_init */
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GntProgressBar),
- 0, /* n_preallocs */
- gnt_progress_bar_init, /* instance_init */
- NULL /* value_table */
- };
-
- type = g_type_register_static (GNT_TYPE_WIDGET, "GntProgressBar", &info, 0);
- }
-
- return type;
-}
-
GntWidget *
gnt_progress_bar_new (void)
{
@@ -179,7 +152,9 @@
void
gnt_progress_bar_set_fraction (GntProgressBar *pbar, gdouble fraction)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (pbar);
+ GntProgressBarPrivate *priv = NULL;
+
+ priv = gnt_progress_bar_get_instance_private(pbar);
if (fraction > 1.0)
priv->fraction = 1.0;
@@ -197,9 +172,11 @@
gnt_progress_bar_set_orientation (GntProgressBar *pbar,
GntProgressBarOrientation orientation)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (pbar);
+ GntProgressBarPrivate *priv = NULL;
GntWidget *widget = GNT_WIDGET(pbar);
+ priv = gnt_progress_bar_get_instance_private(pbar);
+
priv->orientation = orientation;
if (orientation == GNT_PROGRESS_LEFT_TO_RIGHT ||
orientation == GNT_PROGRESS_RIGHT_TO_LEFT) {
@@ -222,28 +199,40 @@
void
gnt_progress_bar_set_show_progress (GntProgressBar *pbar, gboolean show)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (pbar);
+ GntProgressBarPrivate *priv = NULL;
+
+ priv = gnt_progress_bar_get_instance_private(pbar);
+
priv->show_value = show;
}
gdouble
gnt_progress_bar_get_fraction (GntProgressBar *pbar)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (pbar);
+ GntProgressBarPrivate *priv = NULL;
+
+ priv = gnt_progress_bar_get_instance_private(pbar);
+
return priv->fraction;
}
GntProgressBarOrientation
gnt_progress_bar_get_orientation (GntProgressBar *pbar)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (pbar);
+ GntProgressBarPrivate *priv = NULL;
+
+ priv = gnt_progress_bar_get_instance_private(pbar);
+
return priv->orientation;
}
gboolean
gnt_progress_bar_get_show_progress (GntProgressBar *pbar)
{
- GntProgressBarPrivate *priv = GNT_PROGRESS_BAR_GET_PRIVATE (pbar);
+ GntProgressBarPrivate *priv = NULL;
+
+ priv = gnt_progress_bar_get_instance_private(pbar);
+
return priv->show_value;
}
--- a/meson.build Sun Dec 17 01:51:40 2023 -0600
+++ b/meson.build Tue Apr 09 21:17:43 2024 -0500
@@ -55,7 +55,7 @@
# #######################################################################
# # Check for GLib 2.16
# #######################################################################
-glib = dependency('glib-2.0', version : '>= 2.16.0')
+glib = dependency('glib-2.0', version : '>= 2.38.0')
gobject = dependency('gobject-2.0')
gmodule = dependency('gmodule-2.0')
gnome = import('gnome')