[gtk+] Make GtkIconInfo a GObject
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Make GtkIconInfo a GObject
- Date: Thu, 14 Feb 2013 21:11:41 +0000 (UTC)
commit e2d0846386ed65efce5018e09a5196005dbedf16
Author: Alexander Larsson <alexl redhat com>
Date: Wed Feb 13 15:05:02 2013 +0100
Make GtkIconInfo a GObject
This is necessary in order to have async operations on it.
All the old copy/free functions keeps working, and g_boxed_copy on a GObject
also works, so this should be mostly compatible, but techncally its a minor
ABI break since the GType changes fundamental type. Changes like this has
happened before though, like with GVariant becomming its own fundamental
type.
https://bugzilla.gnome.org/show_bug.cgi?id=693802
gtk/gtkicontheme.c | 52 ++++++++++++++++++++++++++++++++++------------------
gtk/gtkicontheme.h | 6 ++++++
2 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 0520686..3b79a55 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -225,8 +225,15 @@ struct _SymbolicPixbufCache {
SymbolicPixbufCache *next;
};
+struct _GtkIconInfoClass
+{
+ GObjectClass parent_class;
+};
+
struct _GtkIconInfo
{
+ GObject parent_instance;
+
/* Information about the source
*/
IconInfoKey key;
@@ -256,8 +263,6 @@ struct _GtkIconInfo
guint forced_size : 1;
guint emblems_applied : 1;
- guint ref_count;
-
/* Cached information if we go ahead and try to load
* the icon.
*/
@@ -2971,19 +2976,20 @@ icon_data_free (GtkIconData *icon_data)
* GtkIconInfo
*/
-G_DEFINE_BOXED_TYPE (GtkIconInfo, gtk_icon_info,
- gtk_icon_info_copy,
- gtk_icon_info_free)
+static void gtk_icon_info_class_init (GtkIconInfoClass *klass);
-static GtkIconInfo *
-icon_info_new (void)
-{
- GtkIconInfo *icon_info = g_slice_new0 (GtkIconInfo);
+G_DEFINE_TYPE (GtkIconInfo, gtk_icon_info, G_TYPE_OBJECT)
+static void
+gtk_icon_info_init (GtkIconInfo *icon_info)
+{
icon_info->scale = -1.;
- icon_info->ref_count = 1;
+}
- return icon_info;
+static GtkIconInfo *
+icon_info_new (void)
+{
+ return g_object_new (GTK_TYPE_ICON_INFO, NULL);
}
static GtkIconInfo *
@@ -3015,9 +3021,7 @@ gtk_icon_info_copy (GtkIconInfo *icon_info)
g_return_val_if_fail (icon_info != NULL, NULL);
- icon_info->ref_count++;
-
- return icon_info;
+ return g_object_ref (icon_info);
}
/**
@@ -3033,9 +3037,13 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
{
g_return_if_fail (icon_info != NULL);
- icon_info->ref_count--;
- if (icon_info->ref_count > 0)
- return;
+ g_object_unref (icon_info);
+}
+
+static void
+gtk_icon_info_finalize (GObject *object)
+{
+ GtkIconInfo *icon_info = (GtkIconInfo *) object;
if (icon_info->in_cache)
g_hash_table_remove (icon_info->in_cache->priv->info_cache, &icon_info->key);
@@ -3057,7 +3065,15 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
symbolic_pixbuf_cache_free (icon_info->symbolic_pixbuf_cache);
- g_slice_free (GtkIconInfo, icon_info);
+ G_OBJECT_CLASS (gtk_icon_info_parent_class)->finalize (object);
+}
+
+static void
+gtk_icon_info_class_init (GtkIconInfoClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = gtk_icon_info_finalize;
}
/**
diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h
index 8852110..cf28429 100644
--- a/gtk/gtkicontheme.h
+++ b/gtk/gtkicontheme.h
@@ -29,6 +29,11 @@
G_BEGIN_DECLS
#define GTK_TYPE_ICON_INFO (gtk_icon_info_get_type ())
+#define GTK_ICON_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_INFO, GtkIconInfo))
+#define GTK_ICON_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_INFO,
GtkIconInfoClass))
+#define GTK_IS_ICON_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_INFO))
+#define GTK_IS_ICON_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_INFO))
+#define GTK_ICON_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_INFO,
GtkIconInfoClass))
#define GTK_TYPE_ICON_THEME (gtk_icon_theme_get_type ())
#define GTK_ICON_THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_THEME,
GtkIconTheme))
@@ -44,6 +49,7 @@ G_BEGIN_DECLS
* an icon theme.
*/
typedef struct _GtkIconInfo GtkIconInfo;
+typedef struct _GtkIconInfoClass GtkIconInfoClass;
typedef struct _GtkIconTheme GtkIconTheme;
typedef struct _GtkIconThemeClass GtkIconThemeClass;
typedef struct _GtkIconThemePrivate GtkIconThemePrivate;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]