forked from AuroraMiddleware/gtk
Convert trivial users of icon theme loading to use info as paintable
This commit is contained in:
parent
aefd8443de
commit
c42977af04
@ -110,7 +110,7 @@ get_image_paintable (GtkImage *image)
|
||||
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
|
||||
if (icon_info == NULL)
|
||||
return NULL;
|
||||
return gtk_icon_info_load_icon (icon_info, NULL);
|
||||
return GDK_PAINTABLE (icon_info);
|
||||
default:
|
||||
g_warning ("Image storage type %d not handled",
|
||||
gtk_image_get_storage_type (image));
|
||||
|
@ -363,7 +363,7 @@ get_image_paintable (GtkImage *image)
|
||||
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
|
||||
if (icon_info == NULL)
|
||||
return NULL;
|
||||
return gtk_icon_info_load_icon (icon_info, NULL);
|
||||
return GDK_PAINTABLE (icon_info);
|
||||
default:
|
||||
g_warning ("Image storage type %d not handled",
|
||||
gtk_image_get_storage_type (image));
|
||||
|
@ -2585,7 +2585,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
|
||||
GdkDevice *device;
|
||||
GdkDrag *drag;
|
||||
GtkIconTheme *theme;
|
||||
GdkPaintable *paintable;
|
||||
GtkIconInfo *icon;
|
||||
GdkSurface *surface;
|
||||
|
||||
if (!priv->in_drag)
|
||||
@ -2604,9 +2604,9 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
|
||||
drag = gdk_drag_begin (surface, device, content, GDK_ACTION_COPY, start_x, start_y);
|
||||
|
||||
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
|
||||
paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL);
|
||||
gtk_drag_icon_set_from_paintable (drag, paintable, 0, 0);
|
||||
g_clear_object (&paintable);
|
||||
icon = gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 0);
|
||||
gtk_drag_icon_set_from_paintable (drag, GDK_PAINTABLE (icon), 0, 0);
|
||||
g_clear_object (&icon);
|
||||
|
||||
g_object_unref (content);
|
||||
g_object_unref (drag);
|
||||
|
@ -484,9 +484,9 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
|
||||
if (!source->paintable)
|
||||
{
|
||||
GtkIconTheme *theme;
|
||||
|
||||
|
||||
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
|
||||
source->paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL);
|
||||
source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 0));
|
||||
source->hot_x = 0;
|
||||
source->hot_y = 0;
|
||||
}
|
||||
|
@ -4102,7 +4102,6 @@ gtk_window_get_icon_for_size (GtkWindow *window,
|
||||
{
|
||||
const char *name;
|
||||
GtkIconInfo *info;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
name = gtk_window_get_icon_name (window);
|
||||
|
||||
@ -4117,10 +4116,7 @@ gtk_window_get_icon_for_size (GtkWindow *window,
|
||||
if (info == NULL)
|
||||
return NULL;
|
||||
|
||||
paintable = gtk_icon_info_load_icon (info, NULL);
|
||||
g_object_unref (info);
|
||||
|
||||
return paintable;
|
||||
return GDK_PAINTABLE (info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -90,8 +90,7 @@ main (int argc, char *argv[])
|
||||
|
||||
if (strcmp (argv[1], "display") == 0)
|
||||
{
|
||||
GError *error;
|
||||
GdkPaintable *paintable;
|
||||
GtkIconInfo *icon;
|
||||
GtkWidget *window, *image;
|
||||
|
||||
if (argc < 4)
|
||||
@ -107,22 +106,21 @@ main (int argc, char *argv[])
|
||||
if (argc >= 6)
|
||||
scale = atoi (argv[5]);
|
||||
|
||||
error = NULL;
|
||||
paintable = gtk_icon_theme_load_icon_for_scale (icon_theme, argv[3], size, scale, flags, &error);
|
||||
if (!paintable)
|
||||
icon = gtk_icon_theme_lookup_icon_for_scale (icon_theme, argv[3], size, scale, flags);
|
||||
if (!icon)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_print ("Icon '%s' not found\n", argv[3]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
image = gtk_image_new ();
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (image), paintable);
|
||||
g_object_unref (paintable);
|
||||
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (icon));
|
||||
g_object_unref (icon);
|
||||
gtk_container_add (GTK_CONTAINER (window), image);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
||||
gtk_widget_show (window);
|
||||
|
||||
|
||||
gtk_main ();
|
||||
}
|
||||
else if (strcmp (argv[1], "display-async") == 0)
|
||||
@ -199,16 +197,10 @@ main (int argc, char *argv[])
|
||||
|
||||
if (icon_info)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
GdkPaintable *paintable = GDK_PAINTABLE (icon_info);
|
||||
|
||||
g_print ("Base size: %d, Scale: %d\n", gtk_icon_info_get_base_size (icon_info), gtk_icon_info_get_base_scale (icon_info));
|
||||
|
||||
texture = GDK_TEXTURE (gtk_icon_info_load_icon (icon_info, NULL));
|
||||
if (texture != NULL)
|
||||
{
|
||||
g_print ("texture size: %dx%d\n", gdk_texture_get_width (texture), gdk_texture_get_height (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
g_print ("texture size: %dx%d\n", gdk_paintable_get_intrinsic_width (paintable), gdk_paintable_get_intrinsic_height (paintable));
|
||||
|
||||
g_object_unref (icon_info);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user