Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -0,0 +1,57 @@
From f6d2db5a0c105785ee6f03717966ef0dbb1421f6 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Tue, 16 Jul 2013 10:32:11 +0200
Subject: [PATCH] pixbuf: Add getter/setter for the 2x variants
---
gdk-pixbuf/gdk-pixbuf-core.h | 3 +++
gdk-pixbuf/gdk-pixbuf.c | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/gdk-pixbuf/gdk-pixbuf-core.h b/gdk-pixbuf/gdk-pixbuf-core.h
index eb4d0a1..60c4ea3 100644
--- a/gdk-pixbuf/gdk-pixbuf-core.h
+++ b/gdk-pixbuf/gdk-pixbuf-core.h
@@ -474,6 +474,9 @@ GdkPixbuf *gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src);
const gchar * gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
const gchar *key);
+GdkPixbuf * gdk_pixbuf_get_hires_variant (GdkPixbuf *pixbuf);
+void gdk_pixbuf_set_hires_variant (GdkPixbuf *pixbuf,
+ GdkPixbuf *hires);
G_END_DECLS
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index 0e13f27..d61f2c7 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -990,3 +990,25 @@ gdk_pixbuf_get_property (GObject *object,
break;
}
}
+
+GdkPixbuf *
+gdk_pixbuf_get_hires_variant (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
+
+ return g_object_get_data (G_OBJECT (pixbuf),
+ "gdk-pixbuf-2x-variant");
+}
+
+void
+gdk_pixbuf_set_hires_variant (GdkPixbuf *pixbuf,
+ GdkPixbuf *hires)
+{
+ g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+ g_return_if_fail (GDK_IS_PIXBUF (hires));
+
+ g_object_set_data_full (G_OBJECT (pixbuf),
+ "gdk-pixbuf-2x-variant",
+ g_object_ref (hires),
+ (GDestroyNotify) g_object_unref);
+}
--
1.8.3.2

View File

@@ -0,0 +1,99 @@
>From de5d91aa15cc98795a68c8e553eb4baadaa0e501 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Fri, 17 May 2013 15:56:28 +0200
Subject: [PATCH] pixbuf: load "@2x" variants as pixbuf gobject data
if a variant of the filename is found that has a "@2x" appended
to the file name (before the extension), such file is loaded
and added as GObject data to the pixbuf
---
gdk-pixbuf/gdk-pixbuf-io.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index dac21b8..ed98cd3 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -1025,6 +1025,40 @@ _gdk_pixbuf_generic_image_load (GdkPixbufModule *module,
return pixbuf;
}
+static gboolean
+_gdk_pixbuf_file_is_scaled (const gchar *filename)
+{
+ gchar *basename, *ext;
+
+ basename = g_path_get_basename (filename);
+ ext = strrchr (basename, '.');
+
+ if (!ext)
+ ext = &basename[strlen(basename)];
+
+ if (ext > basename + 3 && strncmp (ext - 3, "@2x", 3) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gchar *
+_gdk_pixbuf_compose_scaled_filename (const gchar *filename)
+{
+ gchar *ext, *first, *composed;
+
+ ext = strrchr (filename, '.');
+
+ if (!ext)
+ return NULL;
+
+ first = g_strndup (filename, ext - filename);
+ composed = g_strdup_printf ("%s@2x%s", first, ext);
+ g_free (first);
+
+ return composed;
+}
+
/**
* gdk_pixbuf_new_from_file:
* @filename: Name of file to load, in the GLib file name encoding
@@ -1049,11 +1083,13 @@ gdk_pixbuf_new_from_file (const char *filename,
guchar buffer[SNIFF_BUFFER_SIZE];
GdkPixbufModule *image_module;
gchar *display_name;
+ gboolean filename_is_scaled;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
display_name = g_filename_display_name (filename);
+ filename_is_scaled = _gdk_pixbuf_file_is_scaled (filename);
f = g_fopen (filename, "rb");
if (!f) {
@@ -1097,6 +1133,25 @@ gdk_pixbuf_new_from_file (const char *filename,
pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
fclose (f);
+ if (pixbuf && !filename_is_scaled) {
+ GdkPixbuf *scaled_pixbuf = NULL;
+ gchar *scaled_filename;
+
+ scaled_filename = _gdk_pixbuf_compose_scaled_filename (filename);
+
+ if (scaled_filename) {
+ scaled_pixbuf = gdk_pixbuf_new_from_file (scaled_filename, NULL);
+ g_free (scaled_filename);
+ }
+
+ if (scaled_pixbuf) {
+ g_object_set_data_full (G_OBJECT (pixbuf),
+ "gdk-pixbuf-2x-variant",
+ scaled_pixbuf,
+ (GDestroyNotify) g_object_unref);
+ }
+ }
+
if (pixbuf == NULL && error != NULL && *error == NULL) {
/* I don't trust these crufty longjmp()'ing image libs
--
1.8.3.rc1