entry: use gtk_render_icon()
This commit is contained in:
committed by
Benjamin Otte
parent
0198662d79
commit
02e82d69b8
@ -230,6 +230,8 @@ struct _EntryIconInfo
|
|||||||
gchar *icon_name;
|
gchar *icon_name;
|
||||||
GIcon *gicon;
|
GIcon *gicon;
|
||||||
|
|
||||||
|
gboolean symbolic;
|
||||||
|
|
||||||
GtkTargetList *target_list;
|
GtkTargetList *target_list;
|
||||||
GdkDragAction actions;
|
GdkDragAction actions;
|
||||||
};
|
};
|
||||||
@ -3371,26 +3373,33 @@ draw_icon (GtkWidget *widget,
|
|||||||
x = (width - gdk_pixbuf_get_width (pixbuf)) / 2;
|
x = (width - gdk_pixbuf_get_width (pixbuf)) / 2;
|
||||||
y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
|
y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
|
||||||
|
|
||||||
icon_source = gtk_icon_source_new ();
|
if (!icon_info->symbolic)
|
||||||
gtk_icon_source_set_pixbuf (icon_source, pixbuf);
|
{
|
||||||
gtk_icon_source_set_state_wildcarded (icon_source, TRUE);
|
GdkPixbuf *temp_pixbuf;
|
||||||
|
|
||||||
state = 0;
|
icon_source = gtk_icon_source_new ();
|
||||||
if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
|
gtk_icon_source_set_pixbuf (icon_source, pixbuf);
|
||||||
state |= GTK_STATE_FLAG_INSENSITIVE;
|
gtk_icon_source_set_state_wildcarded (icon_source, TRUE);
|
||||||
else if (icon_info->prelight)
|
|
||||||
state |= GTK_STATE_FLAG_PRELIGHT;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
state = 0;
|
||||||
gtk_style_context_save (context);
|
if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
|
||||||
gtk_style_context_set_state (context, state);
|
state |= GTK_STATE_FLAG_INSENSITIVE;
|
||||||
pixbuf = gtk_render_icon_pixbuf (context, icon_source, (GtkIconSize)-1);
|
else if (icon_info->prelight)
|
||||||
gtk_style_context_restore (context);
|
state |= GTK_STATE_FLAG_PRELIGHT;
|
||||||
|
|
||||||
gtk_icon_source_free (icon_source);
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
gtk_style_context_save (context);
|
||||||
|
gtk_style_context_set_state (context, state);
|
||||||
|
temp_pixbuf = gtk_render_icon_pixbuf (context, icon_source, (GtkIconSize)-1);
|
||||||
|
gtk_style_context_restore (context);
|
||||||
|
|
||||||
gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
|
gtk_icon_source_free (icon_source);
|
||||||
cairo_paint (cr);
|
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
pixbuf = temp_pixbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_render_icon (context, cr, pixbuf, x, y);
|
||||||
|
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
@ -6766,10 +6775,19 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
|
|||||||
GTK_ICON_SIZE_MENU,
|
GTK_ICON_SIZE_MENU,
|
||||||
&width, &height);
|
&width, &height);
|
||||||
|
|
||||||
icon_info->pixbuf = gtk_icon_theme_load_icon (icon_theme,
|
info = gtk_icon_theme_lookup_icon (icon_theme,
|
||||||
icon_info->icon_name,
|
icon_info->icon_name,
|
||||||
MIN (width, height),
|
MIN (width, height),
|
||||||
0, NULL);
|
0);
|
||||||
|
if (info)
|
||||||
|
{
|
||||||
|
icon_info->pixbuf =
|
||||||
|
gtk_icon_info_load_symbolic_for_context (info,
|
||||||
|
context,
|
||||||
|
&icon_info->symbolic,
|
||||||
|
NULL);
|
||||||
|
gtk_icon_info_free (info);
|
||||||
|
}
|
||||||
|
|
||||||
if (icon_info->pixbuf == NULL)
|
if (icon_info->pixbuf == NULL)
|
||||||
icon_info->pixbuf = create_normal_pixbuf (context,
|
icon_info->pixbuf = create_normal_pixbuf (context,
|
||||||
@ -6795,7 +6813,11 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
|
|||||||
GTK_ICON_LOOKUP_USE_BUILTIN);
|
GTK_ICON_LOOKUP_USE_BUILTIN);
|
||||||
if (info)
|
if (info)
|
||||||
{
|
{
|
||||||
icon_info->pixbuf = gtk_icon_info_load_icon (info, NULL);
|
icon_info->pixbuf =
|
||||||
|
gtk_icon_info_load_symbolic_for_context (info,
|
||||||
|
context,
|
||||||
|
&icon_info->symbolic,
|
||||||
|
NULL);
|
||||||
gtk_icon_info_free (info);
|
gtk_icon_info_free (info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user