summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2013-03-18 09:16:13 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2013-03-26 16:59:16 +0800
commitb1aa23f4bd5397d2c12f80aed31853c49e8e283b (patch)
tree613be7513fa8f45e720beff6332b9d626b1496e6 /demos
parentbe2c1ac316e0f4f1edf5757dcfd2985859f98e7a (diff)
downloadgtk+-b1aa23f4bd5397d2c12f80aed31853c49e8e283b.tar.gz
Bug 695895: Fix gtk3-demo on Windows
In commit 4e41577b, we are using g_content_type_is_a() to determine how to display the demo resources in the right pane of the gtk3-demo program. Use g_content_type_get_mime_type(), so that we can obtain the mime type of the demo resources on all platforms, as g_content_type_guess() returns a platform-specific string, as https://developer.gnome.org/gio/2.35/gio-GContentType.html states. As .ui files and .css files are normally registered with a different mime type string on Windows, check for those strings as well. This will ensure the demo resources can be properly displayed on Windows as well.
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/main.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index c890f58782..d04a3e6c25 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -403,7 +403,7 @@ static GtkWidget *create_text (GtkWidget **text_view, gboolean is_source);
static void
add_data_tab (const gchar *demoname)
{
- gchar *resource_dir, *resource_name, *content_type;
+ gchar *resource_dir, *resource_name, *content_type, *content_mime;
gchar **resources;
GBytes *bytes;
GtkWidget *widget, *label;
@@ -427,17 +427,20 @@ add_data_tab (const gchar *demoname)
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes),
NULL);
+ content_mime = g_content_type_get_mime_type (content_type);
/* In theory we should look at all the mime types gdk-pixbuf supports
* and go from there, but we know what file types we've added.
*/
- if (g_content_type_is_a (content_type, "image/png") ||
- g_content_type_is_a (content_type, "image/gif") ||
- g_content_type_is_a (content_type, "image/jpeg"))
+ if (g_content_type_is_a (content_mime, "image/png") ||
+ g_content_type_is_a (content_mime, "image/gif") ||
+ g_content_type_is_a (content_mime, "image/jpeg"))
{
widget = gtk_image_new_from_resource (resource_name);
}
- else if (g_content_type_is_a (content_type, "text/plain"))
+ else if (g_content_type_is_a (content_mime, "text/plain") ||
+ g_content_type_is_a (content_mime, "application/x-ext-ui") ||
+ g_content_type_is_a (content_mime, "text/css"))
{
GtkTextBuffer *buffer;
GtkWidget *textview;
@@ -449,7 +452,8 @@ add_data_tab (const gchar *demoname)
}
else
{
- g_warning ("Don't know how to display resource '%s' of type '%s'\n", resource_name, content_type);
+
+ g_warning ("Don't know how to display resource '%s' of type '%s'\n", resource_name, content_mime);
widget = NULL;
}
@@ -458,6 +462,7 @@ add_data_tab (const gchar *demoname)
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
+ g_free (content_mime);
g_free (content_type);
g_free (resource_name);
g_bytes_unref (bytes);