[gtk+/wip/hires-icons: 4/11] widget: Add _scaled() variants for icon rendering
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/hires-icons: 4/11] widget: Add _scaled() variants for icon rendering
- Date: Tue, 14 May 2013 10:54:43 +0000 (UTC)
commit fad5a1d69bf835df4f4d8489db91f6d43ce113e6
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Feb 12 14:01:15 2013 +0100
widget: Add _scaled() variants for icon rendering
Likewise to the iconfactory changes, this API allows to
deal with stock icons at sizes that are suitable for
gdk_window_get_scale_factor()
gtk/gtkwidget.c | 23 +++++++++++++++++++++++
gtk/gtkwidget.h | 4 ++++
2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 123f396..f9411ce 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -9681,6 +9681,29 @@ gtk_widget_render_icon_pixbuf (GtkWidget *widget,
return gtk_icon_set_render_icon_pixbuf (icon_set, context, size);
}
+GdkPixbuf*
+gtk_widget_render_icon_pixbuf_scaled (GtkWidget *widget,
+ const gchar *stock_id,
+ GtkIconSize size,
+ gdouble *scale)
+{
+ GtkStyleContext *context;
+ GtkIconSet *icon_set;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (stock_id != NULL, NULL);
+ g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
+
+ context = gtk_widget_get_style_context (widget);
+ icon_set = gtk_style_context_lookup_icon_set (context, stock_id);
+
+ if (icon_set == NULL)
+ return NULL;
+
+ return gtk_icon_set_render_icon_pixbuf_scaled (icon_set, context,
+ size, scale);
+}
+
/**
* gtk_widget_set_parent_window:
* @widget: a #GtkWidget.
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 1033716..751a9eb 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1006,6 +1006,10 @@ GDK_AVAILABLE_IN_ALL
GdkPixbuf *gtk_widget_render_icon_pixbuf (GtkWidget *widget,
const gchar *stock_id,
GtkIconSize size);
+GdkPixbuf *gtk_widget_render_icon_scaled (GtkWidget *widget,
+ const gchar *stock_id,
+ GtkIconSize size,
+ gdouble *scale);
/* handle composite names for GTK_COMPOSITE_CHILD widgets,
* the returned name is newly allocated.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]