app: add gimp_widget_load_icon() as replacement for gtk_widget_render_icon()
...and use it instead.
This commit is contained in:
@ -551,8 +551,7 @@ gimp_statusbar_progress_message (GimpProgress *progress,
|
|||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
pixbuf = gtk_widget_render_icon (statusbar->label, icon_name,
|
pixbuf = gimp_widget_load_icon (statusbar->label, icon_name, 16);
|
||||||
GTK_ICON_SIZE_MENU, NULL);
|
|
||||||
|
|
||||||
width += ICON_SPACING + gdk_pixbuf_get_width (pixbuf);
|
width += ICON_SPACING + gdk_pixbuf_get_width (pixbuf);
|
||||||
|
|
||||||
@ -596,14 +595,14 @@ gimp_statusbar_set_text (GimpStatusbar *statusbar,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (statusbar->icon)
|
if (statusbar->icon)
|
||||||
|
{
|
||||||
g_object_unref (statusbar->icon);
|
g_object_unref (statusbar->icon);
|
||||||
|
statusbar->icon = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (icon_name)
|
if (icon_name)
|
||||||
statusbar->icon = gtk_widget_render_icon (statusbar->label,
|
statusbar->icon = gimp_widget_load_icon (statusbar->label,
|
||||||
icon_name,
|
icon_name, 16);
|
||||||
GTK_ICON_SIZE_MENU, NULL);
|
|
||||||
else
|
|
||||||
statusbar->icon = NULL;
|
|
||||||
|
|
||||||
if (statusbar->icon)
|
if (statusbar->icon)
|
||||||
{
|
{
|
||||||
|
@ -191,9 +191,8 @@ gimp_error_console_add (GimpErrorConsole *console,
|
|||||||
|
|
||||||
gtk_text_buffer_get_end_iter (console->text_buffer, &end);
|
gtk_text_buffer_get_end_iter (console->text_buffer, &end);
|
||||||
|
|
||||||
pixbuf = gtk_widget_render_icon (console->text_view,
|
pixbuf = gimp_widget_load_icon (GTK_WIDGET (console),
|
||||||
gimp_get_message_icon_name (severity),
|
gimp_get_message_icon_name (severity), 20);
|
||||||
GTK_ICON_SIZE_BUTTON, NULL);
|
|
||||||
gtk_text_buffer_insert_pixbuf (console->text_buffer, &end, pixbuf);
|
gtk_text_buffer_insert_pixbuf (console->text_buffer, &end, pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "gimpdnd.h"
|
#include "gimpdnd.h"
|
||||||
#include "gimpfgbgeditor.h"
|
#include "gimpfgbgeditor.h"
|
||||||
|
#include "gimpwidgets-utils.h"
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -251,9 +252,8 @@ gimp_fg_bg_editor_expose (GtkWidget *widget,
|
|||||||
|
|
||||||
/* draw the default colors pixbuf */
|
/* draw the default colors pixbuf */
|
||||||
if (! editor->default_icon)
|
if (! editor->default_icon)
|
||||||
editor->default_icon = gtk_widget_render_icon (widget,
|
editor->default_icon = gimp_widget_load_icon (widget,
|
||||||
GIMP_STOCK_DEFAULT_COLORS,
|
GIMP_STOCK_DEFAULT_COLORS, 12);
|
||||||
GTK_ICON_SIZE_MENU, NULL);
|
|
||||||
|
|
||||||
default_w = gdk_pixbuf_get_width (editor->default_icon);
|
default_w = gdk_pixbuf_get_width (editor->default_icon);
|
||||||
default_h = gdk_pixbuf_get_height (editor->default_icon);
|
default_h = gdk_pixbuf_get_height (editor->default_icon);
|
||||||
@ -271,9 +271,8 @@ gimp_fg_bg_editor_expose (GtkWidget *widget,
|
|||||||
|
|
||||||
/* draw the swap colors pixbuf */
|
/* draw the swap colors pixbuf */
|
||||||
if (! editor->swap_icon)
|
if (! editor->swap_icon)
|
||||||
editor->swap_icon = gtk_widget_render_icon (widget,
|
editor->swap_icon = gimp_widget_load_icon (widget,
|
||||||
GIMP_STOCK_SWAP_COLORS,
|
GIMP_STOCK_SWAP_COLORS, 12);
|
||||||
GTK_ICON_SIZE_MENU, NULL);
|
|
||||||
|
|
||||||
swap_w = gdk_pixbuf_get_width (editor->swap_icon);
|
swap_w = gdk_pixbuf_get_width (editor->swap_icon);
|
||||||
swap_h = gdk_pixbuf_get_height (editor->swap_icon);
|
swap_h = gdk_pixbuf_get_height (editor->swap_icon);
|
||||||
|
@ -197,9 +197,7 @@ gimp_view_renderer_ensure_frame (GimpViewRenderer *renderer,
|
|||||||
|
|
||||||
if (! class->frame)
|
if (! class->frame)
|
||||||
{
|
{
|
||||||
class->frame = gtk_widget_render_icon (widget,
|
class->frame = gimp_widget_load_icon (widget, GIMP_STOCK_FRAME, 48);
|
||||||
GIMP_STOCK_FRAME,
|
|
||||||
GTK_ICON_SIZE_DIALOG, NULL);
|
|
||||||
|
|
||||||
/* FIXME: shouldn't be hardcoded */
|
/* FIXME: shouldn't be hardcoded */
|
||||||
class->frame_left = 2;
|
class->frame_left = 2;
|
||||||
|
@ -879,8 +879,7 @@ gimp_view_renderer_render_icon (GimpViewRenderer *renderer,
|
|||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
const gchar *icon_name)
|
const gchar *icon_name)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = NULL;
|
GdkPixbuf *pixbuf;
|
||||||
GtkIconSize icon_size;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
|
g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
|
||||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
@ -898,11 +897,8 @@ gimp_view_renderer_render_icon (GimpViewRenderer *renderer,
|
|||||||
renderer->surface = NULL;
|
renderer->surface = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon_size = gimp_get_icon_size (widget, icon_name, GTK_ICON_SIZE_INVALID,
|
pixbuf = gimp_widget_load_icon (widget, icon_name,
|
||||||
renderer->width, renderer->height);
|
MIN (renderer->width, renderer->height));
|
||||||
|
|
||||||
if (icon_size)
|
|
||||||
pixbuf = gtk_widget_render_icon (widget, icon_name, icon_size, NULL);
|
|
||||||
|
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
@ -1148,9 +1144,8 @@ gimp_view_renderer_create_background (GimpViewRenderer *renderer,
|
|||||||
|
|
||||||
if (renderer->bg_icon_name)
|
if (renderer->bg_icon_name)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = gtk_widget_render_icon (widget,
|
GdkPixbuf *pixbuf = gimp_widget_load_icon (widget,
|
||||||
renderer->bg_icon_name,
|
renderer->bg_icon_name, 64);
|
||||||
GTK_ICON_SIZE_DIALOG, NULL);
|
|
||||||
|
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "gimpviewrendererimagefile.h"
|
#include "gimpviewrendererimagefile.h"
|
||||||
#include "gimpviewrenderer-frame.h"
|
#include "gimpviewrenderer-frame.h"
|
||||||
|
#include "gimpwidgets-utils.h"
|
||||||
|
|
||||||
|
|
||||||
static void gimp_view_renderer_imagefile_render (GimpViewRenderer *renderer,
|
static void gimp_view_renderer_imagefile_render (GimpViewRenderer *renderer,
|
||||||
@ -98,7 +99,7 @@ gimp_view_renderer_imagefile_render (GimpViewRenderer *renderer,
|
|||||||
/* The code to get an icon for a mime-type is lifted from GtkRecentManager. */
|
/* The code to get an icon for a mime-type is lifted from GtkRecentManager. */
|
||||||
|
|
||||||
static GdkPixbuf *
|
static GdkPixbuf *
|
||||||
get_icon_for_mime_type (const char *mime_type,
|
get_icon_for_mime_type (const gchar *mime_type,
|
||||||
gint pixel_size)
|
gint pixel_size)
|
||||||
{
|
{
|
||||||
GtkIconTheme *icon_theme;
|
GtkIconTheme *icon_theme;
|
||||||
@ -120,9 +121,7 @@ get_icon_for_mime_type (const char *mime_type,
|
|||||||
g_string_append_c (icon_name, '-');
|
g_string_append_c (icon_name, '-');
|
||||||
g_string_append (icon_name, separator + 1);
|
g_string_append (icon_name, separator + 1);
|
||||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
||||||
pixel_size,
|
pixel_size, 0, NULL);
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
g_string_free (icon_name, TRUE);
|
g_string_free (icon_name, TRUE);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
@ -133,9 +132,7 @@ get_icon_for_mime_type (const char *mime_type,
|
|||||||
g_string_append_c (icon_name, '-');
|
g_string_append_c (icon_name, '-');
|
||||||
g_string_append (icon_name, separator + 1);
|
g_string_append (icon_name, separator + 1);
|
||||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
||||||
pixel_size,
|
pixel_size, 0, NULL);
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
g_string_free (icon_name, TRUE);
|
g_string_free (icon_name, TRUE);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
@ -144,9 +141,7 @@ get_icon_for_mime_type (const char *mime_type,
|
|||||||
icon_name = g_string_new ("gnome-mime-");
|
icon_name = g_string_new ("gnome-mime-");
|
||||||
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
g_string_append_len (icon_name, mime_type, separator - mime_type);
|
||||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name->str,
|
||||||
pixel_size,
|
pixel_size, 0, NULL);
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
g_string_free (icon_name, TRUE);
|
g_string_free (icon_name, TRUE);
|
||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
@ -186,8 +181,7 @@ gimp_view_renderer_imagefile_get_icon (GimpImagefile *imagefile,
|
|||||||
|
|
||||||
if (! pixbuf && thumbnail->image_mimetype)
|
if (! pixbuf && thumbnail->image_mimetype)
|
||||||
{
|
{
|
||||||
pixbuf = get_icon_for_mime_type (thumbnail->image_mimetype,
|
pixbuf = get_icon_for_mime_type (thumbnail->image_mimetype, size);
|
||||||
size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! pixbuf)
|
if (! pixbuf)
|
||||||
|
@ -364,6 +364,55 @@ gimp_enum_radio_frame_add (GtkFrame *frame,
|
|||||||
gimp_enum_radio_box_add (GTK_BOX (box), widget, enum_value, below);
|
gimp_enum_radio_box_add (GTK_BOX (box), widget, enum_value, below);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkPixbuf *
|
||||||
|
gimp_widget_load_icon (GtkWidget *widget,
|
||||||
|
const gchar *icon_name,
|
||||||
|
gint size)
|
||||||
|
{
|
||||||
|
GtkIconTheme *icon_theme;
|
||||||
|
gint *icon_sizes;
|
||||||
|
gint closest_size = -1;
|
||||||
|
gint min_diff = G_MAXINT;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||||
|
g_return_val_if_fail (icon_name != NULL, NULL);
|
||||||
|
|
||||||
|
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
|
||||||
|
|
||||||
|
if (! gtk_icon_theme_has_icon (icon_theme, icon_name))
|
||||||
|
{
|
||||||
|
g_printerr ("gimp_widget_load_icon (): icon theme has no icon '%s'\n",
|
||||||
|
icon_name);
|
||||||
|
|
||||||
|
return gtk_icon_theme_load_icon (icon_theme, GIMP_STOCK_WILBER_EEK,
|
||||||
|
size, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
icon_sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_name);
|
||||||
|
|
||||||
|
for (i = 0; icon_sizes[i]; i++)
|
||||||
|
{
|
||||||
|
if (icon_sizes[i] > 0 &&
|
||||||
|
icon_sizes[i] <= size)
|
||||||
|
{
|
||||||
|
if (size - icon_sizes[i] < min_diff)
|
||||||
|
{
|
||||||
|
min_diff = size - icon_sizes[i];
|
||||||
|
closest_size = icon_sizes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (icon_sizes);
|
||||||
|
|
||||||
|
if (closest_size != -1)
|
||||||
|
size = closest_size;
|
||||||
|
|
||||||
|
return gtk_icon_theme_load_icon (icon_theme, icon_name, size,
|
||||||
|
GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
GtkIconSize
|
GtkIconSize
|
||||||
gimp_get_icon_size (GtkWidget *widget,
|
gimp_get_icon_size (GtkWidget *widget,
|
||||||
const gchar *icon_name,
|
const gchar *icon_name,
|
||||||
|
@ -44,6 +44,9 @@ void gimp_enum_radio_frame_add (GtkFrame *frame,
|
|||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
gint enum_value,
|
gint enum_value,
|
||||||
gboolean below);
|
gboolean below);
|
||||||
|
GdkPixbuf * gimp_widget_load_icon (GtkWidget *widget,
|
||||||
|
const gchar *icon_name,
|
||||||
|
gint size);
|
||||||
GtkIconSize gimp_get_icon_size (GtkWidget *widget,
|
GtkIconSize gimp_get_icon_size (GtkWidget *widget,
|
||||||
const gchar *icon_name,
|
const gchar *icon_name,
|
||||||
GtkIconSize max_size,
|
GtkIconSize max_size,
|
||||||
|
Reference in New Issue
Block a user