Unify content type/ MIME type handling and plug leak
This commit is contained in:
parent
058325a022
commit
fb72bcfeae
3 changed files with 9 additions and 24 deletions
|
@ -2598,11 +2598,7 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
|
||||||
|
|
||||||
if (strcmp (mime_type, "application/xhtml+xml"))
|
if (strcmp (mime_type, "application/xhtml+xml"))
|
||||||
{
|
{
|
||||||
#if GLIB_CHECK_VERSION (2, 18, 0)
|
|
||||||
content_type = g_content_type_from_mime_type (mime_type);
|
content_type = g_content_type_from_mime_type (mime_type);
|
||||||
#else
|
|
||||||
content_type = g_strdup (mime_type);
|
|
||||||
#endif
|
|
||||||
if (g_content_type_is_a (content_type, "application/xml"))
|
if (g_content_type_is_a (content_type, "application/xml"))
|
||||||
view_source = TRUE;
|
view_source = TRUE;
|
||||||
g_free (content_type);
|
g_free (content_type);
|
||||||
|
@ -2621,11 +2617,7 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
|
||||||
dialog = gtk_message_dialog_new (
|
dialog = gtk_message_dialog_new (
|
||||||
NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
|
NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
|
||||||
_("Open or download file"));
|
_("Open or download file"));
|
||||||
#if GLIB_CHECK_VERSION (2, 18, 0)
|
|
||||||
content_type = g_content_type_from_mime_type (mime_type);
|
content_type = g_content_type_from_mime_type (mime_type);
|
||||||
#else
|
|
||||||
content_type = g_strdup (mime_type);
|
|
||||||
#endif
|
|
||||||
if (!content_type)
|
if (!content_type)
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
content_type = g_content_type_get_mime_type ("*");
|
content_type = g_content_type_get_mime_type ("*");
|
||||||
|
@ -4445,27 +4437,21 @@ midori_view_can_zoom_out (MidoriView* view)
|
||||||
gboolean
|
gboolean
|
||||||
midori_view_can_view_source (MidoriView* view)
|
midori_view_can_view_source (MidoriView* view)
|
||||||
{
|
{
|
||||||
#if GLIB_CHECK_VERSION (2, 18, 0)
|
|
||||||
gchar* content_type;
|
gchar* content_type;
|
||||||
gchar* text_type;
|
gchar* text_type;
|
||||||
#endif
|
gboolean is_text;
|
||||||
|
|
||||||
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
|
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
|
||||||
|
|
||||||
if (midori_view_is_blank (view))
|
if (midori_view_is_blank (view))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 18, 0)
|
|
||||||
content_type = g_content_type_from_mime_type (view->mime_type);
|
content_type = g_content_type_from_mime_type (view->mime_type);
|
||||||
text_type = g_content_type_from_mime_type ("text/plain");
|
text_type = g_content_type_from_mime_type ("text/plain");
|
||||||
return g_content_type_is_a (content_type, text_type);
|
is_text = g_content_type_is_a (content_type, text_type);
|
||||||
#elif defined (G_OS_UNIX)
|
g_free (content_type);
|
||||||
return g_content_type_is_a (view->mime_type, "text/plain");
|
g_free (text_type);
|
||||||
#else
|
return is_text;
|
||||||
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) \
|
||||||
|
|
|
@ -224,12 +224,7 @@ sokoke_show_uri_with_mime_type (GdkScreen* screen,
|
||||||
GList* files;
|
GList* files;
|
||||||
gpointer context;
|
gpointer context;
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 18, 0)
|
|
||||||
content_type = g_content_type_from_mime_type (mime_type);
|
content_type = g_content_type_from_mime_type (mime_type);
|
||||||
#else
|
|
||||||
content_type = g_strdup (mime_type);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
app_info = g_app_info_get_default_for_type (content_type,
|
app_info = g_app_info_get_default_for_type (content_type,
|
||||||
!g_str_has_prefix (uri, "file://"));
|
!g_str_has_prefix (uri, "file://"));
|
||||||
g_free (content_type);
|
g_free (content_type);
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
|
(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !GLIB_CHECK_VERSION (2, 18, 0)
|
||||||
|
#define g_content_type_from_mime_type(mtp) g_strdup (mtp)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION (2, 14, 0)
|
#if !GTK_CHECK_VERSION (2, 14, 0)
|
||||||
#define gtk_dialog_get_content_area(dlg) dlg->vbox
|
#define gtk_dialog_get_content_area(dlg) dlg->vbox
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue