summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2021-09-17 02:34:15 +0200
committerBenjamin Otte <otte@redhat.com>2021-09-17 02:34:15 +0200
commite58f70d7bb5990bfc8a7364c7f4e5af586e43750 (patch)
tree9ebda97878df893a1286069edc69911fee4e7e6d
parent4fcf54757f2da7f899fd7d7728666f40c4aeecfa (diff)
downloadgtk+-e58f70d7bb5990bfc8a7364c7f4e5af586e43750.tar.gz
pixbufutils: Don't hardcode formats
Just let the loaders figure out the file format themselves.
-rw-r--r--gtk/gdkpixbufutils.c34
-rw-r--r--gtk/gdkpixbufutilsprivate.h6
-rw-r--r--gtk/gtkicontheme.c4
3 files changed, 7 insertions, 37 deletions
diff --git a/gtk/gdkpixbufutils.c b/gtk/gdkpixbufutils.c
index 7bbe5d5fd8..df8c542deb 100644
--- a/gtk/gdkpixbufutils.c
+++ b/gtk/gdkpixbufutils.c
@@ -93,7 +93,6 @@ size_prepared_cb (GdkPixbufLoader *loader,
*/
GdkPixbuf *
_gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
- const char *format,
double scale,
GCancellable *cancellable,
GError **error)
@@ -101,14 +100,7 @@ _gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
- if (format)
- {
- loader = gdk_pixbuf_loader_new_with_type (format, error);
- if (!loader)
- return NULL;
- }
- else
- loader = gdk_pixbuf_loader_new ();
+ loader = gdk_pixbuf_loader_new ();
if (scale != 0)
g_signal_connect (loader, "size-prepared",
@@ -155,7 +147,6 @@ size_prepared_cb2 (GdkPixbufLoader *loader,
GdkPixbuf *
_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
- const char *format,
int width,
int height,
gboolean aspect,
@@ -166,14 +157,7 @@ _gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
GdkPixbuf *pixbuf;
int scales[3];
- if (format)
- {
- loader = gdk_pixbuf_loader_new_with_type (format, error);
- if (!loader)
- return NULL;
- }
- else
- loader = gdk_pixbuf_loader_new ();
+ loader = gdk_pixbuf_loader_new ();
scales[0] = width;
scales[1] = height;
@@ -190,11 +174,10 @@ _gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
GdkPixbuf *
_gdk_pixbuf_new_from_stream (GInputStream *stream,
- const char *format,
GCancellable *cancellable,
GError **error)
{
- return _gdk_pixbuf_new_from_stream_scaled (stream, format, 0, cancellable, error);
+ return _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
}
/* Like gdk_pixbuf_new_from_resource_at_scale, but
@@ -203,7 +186,6 @@ _gdk_pixbuf_new_from_stream (GInputStream *stream,
*/
GdkPixbuf *
_gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
- const char *format,
double scale,
GError **error)
{
@@ -214,7 +196,7 @@ _gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
if (stream == NULL)
return NULL;
- pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, format, scale, NULL, error);
+ pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, scale, NULL, error);
g_object_unref (stream);
return pixbuf;
@@ -222,15 +204,13 @@ _gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
GdkPixbuf *
_gdk_pixbuf_new_from_resource (const char *resource_path,
- const char *format,
GError **error)
{
- return _gdk_pixbuf_new_from_resource_scaled (resource_path, format, 0, error);
+ return _gdk_pixbuf_new_from_resource_scaled (resource_path, 0, error);
}
GdkPixbuf *
_gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
- const char *format,
int width,
int height,
gboolean preserve_aspect,
@@ -243,7 +223,7 @@ _gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
if (stream == NULL)
return NULL;
- pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, format, width, height, preserve_aspect, NULL, error);
+ pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, width, height, preserve_aspect, NULL, error);
g_object_unref (stream);
return pixbuf;
@@ -541,7 +521,7 @@ gtk_load_symbolic_texture_from_file (GFile *file)
if (stream == NULL)
return NULL;
- pixbuf = _gdk_pixbuf_new_from_stream (stream, "png", NULL, NULL);
+ pixbuf = _gdk_pixbuf_new_from_stream (stream, NULL, NULL);
g_object_unref (stream);
if (pixbuf == NULL)
return NULL;
diff --git a/gtk/gdkpixbufutilsprivate.h b/gtk/gdkpixbufutilsprivate.h
index 62efe3699e..2c4ab5b305 100644
--- a/gtk/gdkpixbufutilsprivate.h
+++ b/gtk/gdkpixbufutilsprivate.h
@@ -23,32 +23,26 @@
G_BEGIN_DECLS
GdkPixbuf *_gdk_pixbuf_new_from_stream (GInputStream *stream,
- const char *format,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
- const char *format,
int width,
int height,
gboolean aspect,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
- const char *format,
double scale,
GCancellable *cancellable,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource (const char *resource_path,
- const char *format,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
- const char *format,
int width,
int height,
gboolean preserve_aspect,
GError **error);
GdkPixbuf *_gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
- const char *format,
double scale,
GError **error);
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 94f1dc4730..eaeb8e4063 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3789,7 +3789,6 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
&load_error);
else
source_pixbuf = _gdk_pixbuf_new_from_resource_at_scale (icon->filename,
- "svg",
pixel_size, pixel_size,
TRUE, &load_error);
if (source_pixbuf)
@@ -3821,7 +3820,6 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
if (stream)
{
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
- "svg",
pixel_size, pixel_size,
TRUE, NULL,
&load_error);
@@ -3860,14 +3858,12 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
if (icon->is_svg)
{
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
- "svg",
pixel_size, pixel_size,
TRUE, NULL,
&load_error);
}
else
source_pixbuf = _gdk_pixbuf_new_from_stream (stream,
- g_str_has_suffix (icon->filename, ".xpm") ? "xpm" : "png",
NULL, &load_error);
g_object_unref (stream);
if (source_pixbuf)