mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
cellrendererpixbuf: Store the texture in the iconhelper paintable
That's kinda weird but allows us to delete the texture case from GtkIconHelper and GTK_IMAGE_TEXTURE from the GtkImageType enum. And it doesn't cause any other problems because the cell renderer can't deal with paintables - otherwise it would mirror GtkImage and have a "paintable" property instead.
This commit is contained in:
parent
cbe40f5f46
commit
12409ee075
@ -240,7 +240,7 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object,
|
||||
g_value_set_object (value, priv->pixbuf_expander_closed);
|
||||
break;
|
||||
case PROP_TEXTURE:
|
||||
g_value_set_object (value, gtk_image_definition_get_texture (priv->image_def));
|
||||
g_value_set_object (value, gtk_image_definition_get_paintable (priv->image_def));
|
||||
break;
|
||||
case PROP_ICON_SIZE:
|
||||
g_value_set_enum (value, priv->icon_size);
|
||||
@ -263,11 +263,8 @@ notify_storage_type (GtkCellRendererPixbuf *cellpixbuf,
|
||||
{
|
||||
switch (storage_type)
|
||||
{
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
g_object_notify (G_OBJECT (cellpixbuf), "texture");
|
||||
break;
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
g_object_notify (G_OBJECT (cellpixbuf), "paintable");
|
||||
g_object_notify (G_OBJECT (cellpixbuf), "texture");
|
||||
break;
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
g_object_notify (G_OBJECT (cellpixbuf), "icon-name");
|
||||
@ -335,7 +332,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
else
|
||||
texture = NULL;
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_texture (texture));
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_paintable (GDK_PAINTABLE (texture)));
|
||||
break;
|
||||
case PROP_PIXBUF_EXPANDER_OPEN:
|
||||
if (priv->pixbuf_expander_open)
|
||||
@ -348,7 +345,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
|
||||
priv->pixbuf_expander_closed = (GdkPixbuf*) g_value_dup_object (value);
|
||||
break;
|
||||
case PROP_TEXTURE:
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_texture (g_value_get_object (value)));
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_paintable (g_value_get_object (value)));
|
||||
break;
|
||||
case PROP_ICON_SIZE:
|
||||
gtk_cell_renderer_pixbuf_set_icon_size (cellpixbuf, g_value_get_enum (value));
|
||||
@ -530,14 +527,14 @@ gtk_cell_renderer_pixbuf_snapshot (GtkCellRenderer *cell,
|
||||
{
|
||||
icon_helper = gtk_icon_helper_new (gtk_style_context_get_node (context), widget);
|
||||
texture = gdk_texture_new_for_pixbuf (priv->pixbuf_expander_open);
|
||||
_gtk_icon_helper_set_texture (icon_helper, texture);
|
||||
_gtk_icon_helper_set_paintable (icon_helper, GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
else if (!is_expanded && priv->pixbuf_expander_closed != NULL)
|
||||
{
|
||||
icon_helper = gtk_icon_helper_new (gtk_style_context_get_node (context), widget);
|
||||
texture = gdk_texture_new_for_pixbuf (priv->pixbuf_expander_closed);
|
||||
_gtk_icon_helper_set_texture (icon_helper, texture);
|
||||
_gtk_icon_helper_set_paintable (icon_helper, GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
else
|
||||
|
@ -6555,7 +6555,6 @@ gtk_entry_clear_icon (GtkEntry *entry,
|
||||
: PROP_GICON_SECONDARY]);
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -103,16 +103,6 @@ get_icon_lookup_flags (GtkIconHelper *self,
|
||||
return flags;
|
||||
}
|
||||
|
||||
static GdkPaintable *
|
||||
ensure_paintable_from_texture (GtkIconHelper *self,
|
||||
GdkTexture *texture,
|
||||
int *scale)
|
||||
{
|
||||
*scale = gtk_image_definition_get_storage_type (self->def);
|
||||
|
||||
return g_object_ref (GDK_PAINTABLE (texture));
|
||||
}
|
||||
|
||||
static GdkPaintable *
|
||||
ensure_paintable_from_paintable (GtkIconHelper *self,
|
||||
GdkPaintable *paintable,
|
||||
@ -171,11 +161,6 @@ gtk_icon_helper_load_paintable (GtkIconHelper *self,
|
||||
|
||||
switch (gtk_image_definition_get_storage_type (self->def))
|
||||
{
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
paintable = ensure_paintable_from_texture (self, gtk_image_definition_get_texture (self->def), &scale);
|
||||
symbolic = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
paintable = ensure_paintable_from_paintable (self, gtk_image_definition_get_paintable (self->def), &scale);
|
||||
symbolic = FALSE;
|
||||
@ -273,7 +258,6 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
default:
|
||||
@ -305,9 +289,6 @@ gtk_icon_helper_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
|
||||
switch (gtk_image_definition_get_storage_type (self->def))
|
||||
{
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
return gdk_paintable_get_intrinsic_width (GDK_PAINTABLE (gtk_image_definition_get_texture (self->def)));
|
||||
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
return gdk_paintable_get_intrinsic_width (gtk_image_definition_get_paintable (self->def));
|
||||
|
||||
@ -337,9 +318,6 @@ gtk_icon_helper_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
|
||||
switch (gtk_image_definition_get_storage_type (self->def))
|
||||
{
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
return gdk_paintable_get_intrinsic_height (GDK_PAINTABLE (gtk_image_definition_get_texture (self->def)));
|
||||
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
return gdk_paintable_get_intrinsic_height (gtk_image_definition_get_paintable (self->def));
|
||||
|
||||
@ -368,9 +346,6 @@ static double gtk_icon_helper_paintable_get_intrinsic_aspect_ratio (GdkPaintable
|
||||
|
||||
switch (gtk_image_definition_get_storage_type (self->def))
|
||||
{
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
return gdk_paintable_get_intrinsic_aspect_ratio (GDK_PAINTABLE (gtk_image_definition_get_texture (self->def)));
|
||||
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
return gdk_paintable_get_intrinsic_aspect_ratio (gtk_image_definition_get_paintable (self->def));
|
||||
|
||||
@ -551,7 +526,6 @@ gtk_icon_helper_measure (GtkIconHelper *self,
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
case GTK_IMAGE_GICON:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
@ -626,14 +600,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
|
||||
width = height = get_default_size (self);
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
{
|
||||
GdkTexture *texture = gtk_image_definition_get_texture (self->def);
|
||||
width = gdk_texture_get_width (texture);
|
||||
height = gdk_texture_get_height (texture);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
{
|
||||
GdkPaintable *paintable = gtk_image_definition_get_paintable (self->def);
|
||||
@ -692,13 +658,6 @@ _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
|
||||
gtk_icon_helper_take_definition (self, gtk_image_definition_new_icon_name (icon_name));
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_helper_set_texture (GtkIconHelper *self,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
gtk_icon_helper_take_definition (self, gtk_image_definition_new_texture (texture));
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_helper_set_paintable (GtkIconHelper *self,
|
||||
GdkPaintable *paintable)
|
||||
@ -762,12 +721,6 @@ _gtk_icon_helper_peek_gicon (GtkIconHelper *self)
|
||||
return gtk_image_definition_get_gicon (self->def);
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
_gtk_icon_helper_peek_texture (GtkIconHelper *self)
|
||||
{
|
||||
return gtk_image_definition_get_texture (self->def);
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
_gtk_icon_helper_peek_paintable (GtkIconHelper *self)
|
||||
{
|
||||
|
@ -46,8 +46,6 @@ void _gtk_icon_helper_set_gicon (GtkIconHelper *self,
|
||||
|
||||
void _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
|
||||
const gchar *icon_name);
|
||||
void _gtk_icon_helper_set_texture (GtkIconHelper *self,
|
||||
GdkTexture *texture);
|
||||
void _gtk_icon_helper_set_paintable (GtkIconHelper *self,
|
||||
GdkPaintable *paintable);
|
||||
|
||||
@ -61,7 +59,6 @@ gint _gtk_icon_helper_get_pixel_size (GtkIconHelper *self);
|
||||
gboolean _gtk_icon_helper_get_use_fallback (GtkIconHelper *self);
|
||||
|
||||
GIcon *_gtk_icon_helper_peek_gicon (GtkIconHelper *self);
|
||||
GdkTexture *_gtk_icon_helper_peek_texture (GtkIconHelper *self);
|
||||
GdkPaintable *_gtk_icon_helper_peek_paintable (GtkIconHelper *self);
|
||||
|
||||
GtkImageDefinition *gtk_icon_helper_get_definition (GtkIconHelper *self);
|
||||
|
@ -1205,7 +1205,6 @@ gtk_image_notify_for_storage_type (GtkImage *image,
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_PAINTABLE]);
|
||||
break;
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
default:
|
||||
break;
|
||||
|
@ -55,8 +55,6 @@ typedef struct _GtkImageClass GtkImageClass;
|
||||
* This image type was added in GTK+ 2.6
|
||||
* @GTK_IMAGE_GICON: the widget contains a #GIcon.
|
||||
* This image type was added in GTK+ 2.14
|
||||
* @GTK_IMAGE_TEXTURE: the widget contains a #GdkTexture.
|
||||
* This image type was added in GTK+ 3.94
|
||||
* @GTK_IMAGE_PAINTABLE: the widget contains a #GdkPaintable.
|
||||
* This image type was added in GTK+ 3.96
|
||||
*
|
||||
@ -73,7 +71,6 @@ typedef enum
|
||||
GTK_IMAGE_EMPTY,
|
||||
GTK_IMAGE_ICON_NAME,
|
||||
GTK_IMAGE_GICON,
|
||||
GTK_IMAGE_TEXTURE,
|
||||
GTK_IMAGE_PAINTABLE
|
||||
} GtkImageType;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
typedef struct _GtkImageDefinitionEmpty GtkImageDefinitionEmpty;
|
||||
typedef struct _GtkImageDefinitionIconName GtkImageDefinitionIconName;
|
||||
typedef struct _GtkImageDefinitionGIcon GtkImageDefinitionGIcon;
|
||||
typedef struct _GtkImageDefinitionTexture GtkImageDefinitionTexture;
|
||||
typedef struct _GtkImageDefinitionPaintable GtkImageDefinitionPaintable;
|
||||
|
||||
struct _GtkImageDefinitionEmpty {
|
||||
@ -44,13 +43,6 @@ struct _GtkImageDefinitionGIcon {
|
||||
GIcon *gicon;
|
||||
};
|
||||
|
||||
struct _GtkImageDefinitionTexture {
|
||||
GtkImageType type;
|
||||
gint ref_count;
|
||||
|
||||
GdkTexture *texture;
|
||||
};
|
||||
|
||||
struct _GtkImageDefinitionPaintable {
|
||||
GtkImageType type;
|
||||
gint ref_count;
|
||||
@ -64,7 +56,6 @@ union _GtkImageDefinition
|
||||
GtkImageDefinitionEmpty empty;
|
||||
GtkImageDefinitionIconName icon_name;
|
||||
GtkImageDefinitionGIcon gicon;
|
||||
GtkImageDefinitionTexture texture;
|
||||
GtkImageDefinitionPaintable paintable;
|
||||
};
|
||||
|
||||
@ -83,7 +74,6 @@ gtk_image_definition_alloc (GtkImageType type)
|
||||
sizeof (GtkImageDefinitionEmpty),
|
||||
sizeof (GtkImageDefinitionIconName),
|
||||
sizeof (GtkImageDefinitionGIcon),
|
||||
sizeof (GtkImageDefinitionTexture),
|
||||
sizeof (GtkImageDefinitionPaintable)
|
||||
};
|
||||
GtkImageDefinition *def;
|
||||
@ -125,20 +115,6 @@ gtk_image_definition_new_gicon (GIcon *gicon)
|
||||
return def;
|
||||
}
|
||||
|
||||
GtkImageDefinition *
|
||||
gtk_image_definition_new_texture (GdkTexture *texture)
|
||||
{
|
||||
GtkImageDefinition *def;
|
||||
|
||||
if (texture == NULL)
|
||||
return NULL;
|
||||
|
||||
def = gtk_image_definition_alloc (GTK_IMAGE_TEXTURE);
|
||||
def->texture.texture = g_object_ref (texture);
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
GtkImageDefinition *
|
||||
gtk_image_definition_new_paintable (GdkPaintable *paintable)
|
||||
{
|
||||
@ -175,9 +151,6 @@ gtk_image_definition_unref (GtkImageDefinition *def)
|
||||
case GTK_IMAGE_EMPTY:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
g_object_unref (def->texture.texture);
|
||||
break;
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
g_object_unref (def->paintable.paintable);
|
||||
break;
|
||||
@ -207,7 +180,6 @@ gtk_image_definition_get_scale (const GtkImageDefinition *def)
|
||||
g_assert_not_reached ();
|
||||
case GTK_IMAGE_EMPTY:
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
case GTK_IMAGE_GICON:
|
||||
return 1;
|
||||
@ -232,15 +204,6 @@ gtk_image_definition_get_gicon (const GtkImageDefinition *def)
|
||||
return def->gicon.gicon;
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gtk_image_definition_get_texture (const GtkImageDefinition *def)
|
||||
{
|
||||
if (def->type != GTK_IMAGE_TEXTURE)
|
||||
return NULL;
|
||||
|
||||
return def->texture.texture;
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
gtk_image_definition_get_paintable (const GtkImageDefinition *def)
|
||||
{
|
||||
|
@ -28,7 +28,6 @@ typedef union _GtkImageDefinition GtkImageDefinition;
|
||||
GtkImageDefinition * gtk_image_definition_new_empty (void);
|
||||
GtkImageDefinition * gtk_image_definition_new_icon_name (const char *icon_name);
|
||||
GtkImageDefinition * gtk_image_definition_new_gicon (GIcon *gicon);
|
||||
GtkImageDefinition * gtk_image_definition_new_texture (GdkTexture *texture);
|
||||
GtkImageDefinition * gtk_image_definition_new_paintable (GdkPaintable *paintable);
|
||||
|
||||
GtkImageDefinition * gtk_image_definition_ref (GtkImageDefinition *def);
|
||||
@ -38,7 +37,6 @@ GtkImageType gtk_image_definition_get_storage_type (const GtkImageD
|
||||
gint gtk_image_definition_get_scale (const GtkImageDefinition *def);
|
||||
const gchar * gtk_image_definition_get_icon_name (const GtkImageDefinition *def);
|
||||
GIcon * gtk_image_definition_get_gicon (const GtkImageDefinition *def);
|
||||
GdkTexture * gtk_image_definition_get_texture (const GtkImageDefinition *def);
|
||||
GdkPaintable * gtk_image_definition_get_paintable (const GtkImageDefinition *def);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user