Determine whether we can view the source via g_content_type_is_a
This commit is contained in:
parent
7383a647c9
commit
bebacc8565
1 changed files with 16 additions and 11 deletions
|
@ -3920,22 +3920,27 @@ midori_view_can_zoom_out (MidoriView* view)
|
||||||
gboolean
|
gboolean
|
||||||
midori_view_can_view_source (MidoriView* view)
|
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);
|
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
|
||||||
|
|
||||||
/* FIXME: Consider other types that are also text */
|
if (midori_view_is_blank (view))
|
||||||
if (!g_str_has_prefix (view->mime_type, "text/")
|
|
||||||
&& !g_strrstr (view->mime_type, "xml"))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!uri)
|
#if GLIB_CHECK_VERSION (2, 18, 0)
|
||||||
return FALSE;
|
content_type = g_content_type_from_mime_type (view->mime_type);
|
||||||
if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri, "https://"))
|
text_type = g_content_type_from_mime_type ("text/plain");
|
||||||
return TRUE;
|
return g_content_type_is_a (content_type, text_type);
|
||||||
if (g_str_has_prefix (uri, "file://"))
|
#elif defined (G_OS_UNIX)
|
||||||
return TRUE;
|
return g_content_type_is_a (view->mime_type, "text/plain");
|
||||||
return FALSE;
|
#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) \
|
#define can_do(what) \
|
||||||
|
|
Loading…
Reference in a new issue