[Xfce4-commits] <midori:master> Determine whether we can view the source via g_content_type_is_a
Christian Dywan
noreply at xfce.org
Sun Jan 3 23:04:01 CET 2010
Updating branch refs/heads/master
to bebacc8565482ccf0795966f6fb68b8c6f0976c2 (commit)
from 7383a647c9828341a7da36a8d9d88470f8b74141 (commit)
commit bebacc8565482ccf0795966f6fb68b8c6f0976c2
Author: Christian Dywan <christian at twotoasts.de>
Date: Sat Jan 2 23:32:52 2010 +0100
Determine whether we can view the source via g_content_type_is_a
midori/midori-view.c | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/midori/midori-view.c b/midori/midori-view.c
index d810cd4..af06c2c 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3920,22 +3920,27 @@ midori_view_can_zoom_out (MidoriView* view)
gboolean
midori_view_can_view_source (MidoriView* view)
{
- const gchar* uri = view->uri;
+ #if GLIB_CHECK_VERSION (2, 18, 0)
+ gchar* content_type;
+ gchar* text_type;
+ #endif
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
- /* FIXME: Consider other types that are also text */
- if (!g_str_has_prefix (view->mime_type, "text/")
- && !g_strrstr (view->mime_type, "xml"))
+ if (midori_view_is_blank (view))
return FALSE;
- if (!uri)
- return FALSE;
- if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri, "https://"))
- return TRUE;
- if (g_str_has_prefix (uri, "file://"))
- return TRUE;
- return FALSE;
+ #if GLIB_CHECK_VERSION (2, 18, 0)
+ content_type = g_content_type_from_mime_type (view->mime_type);
+ text_type = g_content_type_from_mime_type ("text/plain");
+ return g_content_type_is_a (content_type, text_type);
+ #elif defined (G_OS_UNIX)
+ return g_content_type_is_a (view->mime_type, "text/plain");
+ #else
+ return g_str_has_prefix (view->mime_type, "text/")
+ || g_strrstr (view->mime_type, "xml")
+ || g_strrstr (view->mime_type, "javascript");
+ #endif
}
#define can_do(what) \
More information about the Xfce4-commits
mailing list