mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
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
This commit is contained in:
parent
32c6c672d1
commit
e2d0846386
@ -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);
|
||||
|
||||
G_DEFINE_TYPE (GtkIconInfo, gtk_icon_info, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_icon_info_init (GtkIconInfo *icon_info)
|
||||
{
|
||||
icon_info->scale = -1.;
|
||||
}
|
||||
|
||||
static GtkIconInfo *
|
||||
icon_info_new (void)
|
||||
{
|
||||
GtkIconInfo *icon_info = g_slice_new0 (GtkIconInfo);
|
||||
|
||||
icon_info->scale = -1.;
|
||||
icon_info->ref_count = 1;
|
||||
|
||||
return icon_info;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user