[gtk+/gtk-3-8] Bug 695895: Fix gtk3-demo on Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-8] Bug 695895: Fix gtk3-demo on Windows
- Date: Tue, 26 Mar 2013 09:00:25 +0000 (UTC)
commit 9c94e484203970a2252926d500e3703ed5ca8c66
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Mar 18 09:16:13 2013 +0800
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.
demos/gtk-demo/main.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index c890f58..d04a3e6 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]