[gnome-software] progress button: Port to G_DECLARE_FINAL_TYPE macro
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] progress button: Port to G_DECLARE_FINAL_TYPE macro
- Date: Mon, 7 Sep 2015 17:38:28 +0000 (UTC)
commit 93dafb4514e51e16324197923df77c6bc08c92ac
Author: Kalev Lember <klember redhat com>
Date: Mon Sep 7 17:41:19 2015 +0200
progress button: Port to G_DECLARE_FINAL_TYPE macro
src/gs-progress-button.c | 18 ++++++++----------
src/gs-progress-button.h | 22 ++--------------------
2 files changed, 10 insertions(+), 30 deletions(-)
---
diff --git a/src/gs-progress-button.c b/src/gs-progress-button.c
index aea60aa..ce29f91 100644
--- a/src/gs-progress-button.c
+++ b/src/gs-progress-button.c
@@ -23,17 +23,18 @@
#include "gs-progress-button.h"
-struct _GsProgressButtonPrivate
+struct _GsProgressButton
{
+ GtkButton parent_instance;
+
GtkCssProvider *css_provider;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GsProgressButton, gs_progress_button, GTK_TYPE_BUTTON)
+G_DEFINE_TYPE (GsProgressButton, gs_progress_button, GTK_TYPE_BUTTON)
void
gs_progress_button_set_progress (GsProgressButton *button, guint percentage)
{
- GsProgressButtonPrivate *priv = gs_progress_button_get_instance_private (button);
gchar *css;
if (percentage == 0)
@@ -43,7 +44,7 @@ gs_progress_button_set_progress (GsProgressButton *button, guint percentage)
else
css = g_strdup_printf (".button.install-progress { background: linear-gradient(to right,
@theme_selected_bg_color %d%%, @theme_bg_color %d%%); }", percentage, percentage + 1);
- gtk_css_provider_load_from_data (priv->css_provider, css, -1, NULL);
+ gtk_css_provider_load_from_data (button->css_provider, css, -1, NULL);
g_free (css);
}
@@ -63,9 +64,8 @@ static void
gs_progress_button_dispose (GObject *object)
{
GsProgressButton *button = GS_PROGRESS_BUTTON (object);
- GsProgressButtonPrivate *priv = gs_progress_button_get_instance_private (button);
- g_clear_object (&priv->css_provider);
+ g_clear_object (&button->css_provider);
G_OBJECT_CLASS (gs_progress_button_parent_class)->dispose (object);
}
@@ -73,11 +73,9 @@ gs_progress_button_dispose (GObject *object)
static void
gs_progress_button_init (GsProgressButton *button)
{
- GsProgressButtonPrivate *priv = gs_progress_button_get_instance_private (button);
-
- priv->css_provider = gtk_css_provider_new ();
+ button->css_provider = gtk_css_provider_new ();
gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (button)),
- GTK_STYLE_PROVIDER (priv->css_provider),
+ GTK_STYLE_PROVIDER (button->css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
diff --git a/src/gs-progress-button.h b/src/gs-progress-button.h
index ba10d21..98e01ba 100644
--- a/src/gs-progress-button.h
+++ b/src/gs-progress-button.h
@@ -24,30 +24,12 @@
#include <gtk/gtk.h>
-#define GS_TYPE_PROGRESS_BUTTON (gs_progress_button_get_type())
-#define GS_PROGRESS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),
GS_TYPE_PROGRESS_BUTTON, GsProgressButton))
-#define GS_PROGRESS_BUTTON_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST((cls), GS_TYPE_PROGRESS_BUTTON,
GsProgressButtonClass))
-#define GS_IS_PROGRESS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GS_TYPE_PROGRESS_BUTTON))
-#define GS_IS_PROGRESS_BUTTON_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), GS_TYPE_PROGRESS_BUTTON))
-#define GS_PROGRESS_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GS_TYPE_PROGRESS_BUTTON,
GsProgressButtonClass))
-
G_BEGIN_DECLS
-typedef struct _GsProgressButton GsProgressButton;
-typedef struct _GsProgressButtonClass GsProgressButtonClass;
-typedef struct _GsProgressButtonPrivate GsProgressButtonPrivate;
-
-struct _GsProgressButton
-{
- GtkButton parent;
-};
+#define GS_TYPE_PROGRESS_BUTTON (gs_progress_button_get_type ())
-struct _GsProgressButtonClass
-{
- GtkButtonClass parent_class;
-};
+G_DECLARE_FINAL_TYPE (GsProgressButton, gs_progress_button, GS, PROGRESS_BUTTON, GtkButton)
-GType gs_progress_button_get_type (void);
GtkWidget *gs_progress_button_new (void);
void gs_progress_button_set_progress (GsProgressButton *button,
guint percentage);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]