[gtk/wip/baedert/icontheme2: 2/2] icontheme: Remove gtk_icon_info_load_texture
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/icontheme2: 2/2] icontheme: Remove gtk_icon_info_load_texture
- Date: Sat, 31 Aug 2019 06:52:57 +0000 (UTC)
commit c9f101dfc9561349d146ce52bed33367f9b4a17f
Author: Timm Bäder <mail baedert org>
Date: Fri Aug 30 22:58:41 2019 +0200
icontheme: Remove gtk_icon_info_load_texture
It's the same as load_icon now.
demos/gtk-demo/clipboard.c | 2 +-
gtk/gtkcssimageicontheme.c | 2 +-
gtk/gtkheaderbar.c | 13 ++++++------
gtk/gtkiconhelper.c | 2 +-
gtk/gtkicontheme.c | 51 ++++++++--------------------------------------
gtk/gtkicontheme.h | 4 ----
gtk/gtkmountoperation.c | 2 +-
gtk/gtkwindow.c | 13 +++++++-----
gtk/gtkwindowprivate.h | 4 ++--
tests/testdnd2.c | 2 +-
tests/testimage.c | 8 ++++----
11 files changed, 34 insertions(+), 69 deletions(-)
---
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index 9d6b281d7c..17566a3140 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -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 GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info, NULL));
+ return gtk_icon_info_load_icon (icon_info, NULL);
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c
index 093b9e9012..3832e8f34c 100644
--- a/gtk/gtkcssimageicontheme.c
+++ b/gtk/gtkcssimageicontheme.c
@@ -79,7 +79,7 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
g_assert (icon_info != NULL);
symbolic = gtk_icon_info_is_symbolic (icon_info);
- texture = gtk_icon_info_load_texture (icon_info, NULL);
+ texture = GDK_TEXTURE (gtk_icon_info_load_icon (icon_info, NULL));
g_clear_object (&icon_theme->cached_texture);
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 5785960771..2503ca0738 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -224,7 +224,7 @@ _gtk_header_bar_update_window_icon (GtkHeaderBar *bar,
GtkWindow *window)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
- GdkTexture *texture;
+ GdkPaintable *paintable;
gint scale;
if (priv->titlebar_icon == NULL)
@@ -232,15 +232,14 @@ _gtk_header_bar_update_window_icon (GtkHeaderBar *bar,
scale = gtk_widget_get_scale_factor (priv->titlebar_icon);
if (GTK_IS_BUTTON (gtk_widget_get_parent (priv->titlebar_icon)))
- texture = gtk_window_get_icon_for_size (window, 16 * scale);
+ paintable = gtk_window_get_icon_for_size (window, 16 * scale);
else
- texture = gtk_window_get_icon_for_size (window, 20 * scale);
+ paintable = gtk_window_get_icon_for_size (window, 20 * scale);
- if (texture)
+ if (paintable)
{
- gtk_image_set_from_paintable (GTK_IMAGE (priv->titlebar_icon),
- GDK_PAINTABLE (texture));
- g_object_unref (texture);
+ gtk_image_set_from_paintable (GTK_IMAGE (priv->titlebar_icon), paintable);
+ g_object_unref (paintable);
gtk_widget_show (priv->titlebar_icon);
return TRUE;
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index e6976b3a29..c891cecbdd 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -122,7 +122,7 @@ ensure_paintable_for_gicon (GtkIconHelper *self,
flags | GTK_ICON_LOOKUP_USE_BUILTIN |
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
*symbolic = gtk_icon_info_is_symbolic (info);
- paintable = GDK_PAINTABLE (gtk_icon_info_load_texture (info, NULL));
+ paintable = gtk_icon_info_load_icon (info, NULL);
g_object_unref (info);
if (paintable && scale != 1)
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 0bade5749e..31ae2ce058 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2320,7 +2320,7 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
GError **error)
{
GtkIconInfo *icon_info;
- GdkTexture *texture = NULL;
+ GdkPaintable *paintable = NULL;
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
g_return_val_if_fail (icon_name != NULL, NULL);
@@ -2338,11 +2338,11 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
return NULL;
}
- texture = gtk_icon_info_load_texture (icon_info, error);
+ paintable = gtk_icon_info_load_icon (icon_info, error);
g_prefix_error (error, "Failed to load %s: ", icon_info->filename);
g_object_unref (icon_info);
- return GDK_PAINTABLE (texture);
+ return paintable;
}
/**
@@ -3803,11 +3803,8 @@ icon_info_load_pixbuf (GtkIconInfo *icon_info,
* the #GtkIconInfo. If this flag has been specified, the pixbuf
* returned by this function will be scaled to the exact size.
*
- * Returns: (transfer full) (nullable): the rendered icon; this may be a newly
- * created icon or a new reference to an internal icon, so you must
- * not modify the icon. Use g_object_unref() to release your reference
- * to the icon.
- * If the icon could not be loaded, %NULL is returned and @error is set.
+ * Returns: (transfer full) (nullable): the rendered icon.
+ * Use g_object_unref() to release your reference to the icon.
*/
GdkPaintable *
gtk_icon_info_load_icon (GtkIconInfo *icon_info,
@@ -3816,30 +3813,6 @@ gtk_icon_info_load_icon (GtkIconInfo *icon_info,
g_return_val_if_fail (icon_info != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return (GdkPaintable *)gtk_icon_info_load_texture (icon_info, error);
-}
-
-/**
- * gtk_icon_info_load_texture:
- * @icon_info: a #GtkIconInfo
- * @error: (nullable): location to store error information on failure,
- * or %NULL.
- *
- * Returns a texture object that can be used to render the icon
- * with GSK.
- *
- * Returns: (transfer full) (nullable): the icon texture; this may be a newly
- * created texture or a new reference to an exiting texture. Use
- * g_object_unref() to release your reference.
- * In case of failure, %NULL is returned and @error is set
- */
-GdkTexture *
-gtk_icon_info_load_texture (GtkIconInfo *icon_info,
- GError **error)
-{
- g_return_val_if_fail (icon_info != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
if (!icon_info->texture)
{
GdkPixbuf *pixbuf;
@@ -3875,7 +3848,7 @@ gtk_icon_info_load_texture (GtkIconInfo *icon_info,
if (icon_info->in_cache != NULL)
ensure_in_lru_cache (icon_info->in_cache, icon_info);
- return g_object_ref (icon_info->texture);
+ return GDK_PAINTABLE (g_object_ref (icon_info->texture));
}
static void
@@ -3956,7 +3929,6 @@ gtk_icon_info_load_icon_finish (GtkIconInfo *icon_info,
{
GTask *task = G_TASK (result);
GtkIconInfo *dup;
- GdkTexture *texture;
g_return_val_if_fail (g_task_is_valid (result, icon_info), NULL);
@@ -3982,12 +3954,7 @@ gtk_icon_info_load_icon_finish (GtkIconInfo *icon_info,
g_assert (icon_info_get_pixbuf_ready (icon_info));
/* This is now guaranteed to not block */
- texture = gtk_icon_info_load_texture (icon_info, error);
-
- if (texture)
- return GDK_PAINTABLE (texture);
-
- return NULL;
+ return gtk_icon_info_load_icon (icon_info, error);
}
static void
@@ -4416,7 +4383,7 @@ gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
*was_symbolic = is_symbolic;
if (!is_symbolic)
- return (GdkPaintable *)gtk_icon_info_load_texture (icon_info, error);
+ return gtk_icon_info_load_icon (icon_info, error);
pixbuf = gtk_icon_info_load_symbolic_internal (icon_info,
fg, success_color,
@@ -4513,7 +4480,7 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info,
*was_symbolic = is_symbolic;
if (!is_symbolic)
- return (GdkPaintable *)gtk_icon_info_load_texture (icon_info, error);
+ return gtk_icon_info_load_icon (icon_info, error);
gtk_icon_theme_lookup_symbolic_colors (gtk_style_context_lookup_style (context),
&fg, &success_color,
diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h
index ba1c830ae4..d57faddc65 100644
--- a/gtk/gtkicontheme.h
+++ b/gtk/gtkicontheme.h
@@ -225,10 +225,6 @@ GDK_AVAILABLE_IN_ALL
GdkPaintable * gtk_icon_info_load_icon (GtkIconInfo *icon_info,
GError **error);
GDK_AVAILABLE_IN_ALL
-GdkTexture * gtk_icon_info_load_texture (GtkIconInfo *icon_info,
- GError **error);
-
-GDK_AVAILABLE_IN_ALL
void gtk_icon_info_load_icon_async (GtkIconInfo *icon_info,
GCancellable *cancellable,
GAsyncReadyCallback callback,
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index f5fab79029..b0c258c141 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -1171,7 +1171,7 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation,
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET
(mount_operation->priv->dialog)),
GTK_CSS_PROPERTY_ICON_THEME));
info = gtk_icon_theme_lookup_icon (theme, "application-x-executable", 24, 0);
- texture = gtk_icon_info_load_texture (info, NULL);
+ texture = GDK_TEXTURE (gtk_icon_info_load_icon (info, NULL));
g_object_unref (info);
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 513232c309..0edbe8c858 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4048,7 +4048,10 @@ icon_list_from_theme (GtkWindow *window,
0);
if (info)
{
- list = g_list_insert_sorted (list, gtk_icon_info_load_texture (info, NULL), (GCompareFunc)
icon_size_compare);
+ GdkPaintable *paintable = gtk_icon_info_load_icon (info, NULL);
+ if (paintable && GDK_IS_TEXTURE (paintable))
+ list = g_list_insert_sorted (list, GDK_TEXTURE (paintable), (GCompareFunc) icon_size_compare);
+
g_object_unref (info);
}
}
@@ -4105,13 +4108,13 @@ gtk_window_realize_icon (GtkWindow *window)
g_list_free_full (icon_list, g_object_unref);
}
-GdkTexture *
+GdkPaintable *
gtk_window_get_icon_for_size (GtkWindow *window,
int size)
{
const char *name;
GtkIconInfo *info;
- GdkTexture *texture;
+ GdkPaintable *paintable;
name = gtk_window_get_icon_name (window);
@@ -4126,10 +4129,10 @@ gtk_window_get_icon_for_size (GtkWindow *window,
if (info == NULL)
return NULL;
- texture = gtk_icon_info_load_texture (info, NULL);
+ paintable = gtk_icon_info_load_icon (info, NULL);
g_object_unref (info);
- return texture;
+ return paintable;
}
static void
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
index 941fe9c8f1..c803c56d61 100644
--- a/gtk/gtkwindowprivate.h
+++ b/gtk/gtkwindowprivate.h
@@ -112,8 +112,8 @@ GtkWidget * _gtk_window_get_popover_parent (GtkWindow *window,
gboolean _gtk_window_is_popover_widget (GtkWindow *window,
GtkWidget *popover);
-GdkTexture * gtk_window_get_icon_for_size (GtkWindow *window,
- int size);
+GdkPaintable * gtk_window_get_icon_for_size (GtkWindow *window,
+ int size);
void gtk_window_set_hardcoded_surface (GtkWindow *window,
GdkSurface *surface);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 7df9bb3a90..5505055d0e 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -21,7 +21,7 @@ get_image_paintable (GtkImage *image,
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
*out_size = width;
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, width,
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
- paintable = GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info, NULL));
+ paintable = gtk_icon_info_load_icon (icon_info, NULL);
g_object_unref (icon_info);
return paintable;
default:
diff --git a/tests/testimage.c b/tests/testimage.c
index b595cd8f4d..455d5c03fa 100644
--- a/tests/testimage.c
+++ b/tests/testimage.c
@@ -78,7 +78,7 @@ main (int argc, char **argv)
GtkWidget *window, *grid;
GtkWidget *label, *image;
GtkIconTheme *theme;
- GdkTexture *texture;
+ GdkPaintable *paintable;
gchar *icon_name = "help-browser";
gchar *anim_filename = NULL;
GtkIconInfo *icon_info;
@@ -110,10 +110,10 @@ main (int argc, char **argv)
theme = gtk_icon_theme_get_default ();
icon_info = gtk_icon_theme_lookup_icon_for_scale (theme, icon_name, 48, gtk_widget_get_scale_factor
(window), GTK_ICON_LOOKUP_GENERIC_FALLBACK);
- texture = gtk_icon_info_load_texture (icon_info, NULL);
+ paintable = gtk_icon_info_load_icon (icon_info, NULL);
g_object_unref (icon_info);
- image = gtk_image_new_from_paintable (GDK_PAINTABLE (texture));
- g_object_unref (texture);
+ image = gtk_image_new_from_paintable (paintable);
+ g_object_unref (paintable);
gtk_grid_attach (GTK_GRID (grid), image, 2, 1, 1, 1);
gtk_drag_source_set (image, GDK_BUTTON1_MASK,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]