Unify content type/ MIME type handling and plug leak

This commit is contained in:
Christian Dywan 2010-05-07 20:17:53 +02:00
parent 058325a022
commit fb72bcfeae
3 changed files with 9 additions and 24 deletions

View file

@ -2598,11 +2598,7 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
if (strcmp (mime_type, "application/xhtml+xml"))
{
#if GLIB_CHECK_VERSION (2, 18, 0)
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"))
view_source = TRUE;
g_free (content_type);
@ -2621,11 +2617,7 @@ webkit_web_view_mime_type_decision_cb (GtkWidget* web_view,
dialog = gtk_message_dialog_new (
NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
_("Open or download file"));
#if GLIB_CHECK_VERSION (2, 18, 0)
content_type = g_content_type_from_mime_type (mime_type);
#else
content_type = g_strdup (mime_type);
#endif
if (!content_type)
#ifdef G_OS_WIN32
content_type = g_content_type_get_mime_type ("*");
@ -4445,27 +4437,21 @@ midori_view_can_zoom_out (MidoriView* view)
gboolean
midori_view_can_view_source (MidoriView* view)
{
#if GLIB_CHECK_VERSION (2, 18, 0)
gchar* content_type;
gchar* text_type;
#endif
gboolean is_text;
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
if (midori_view_is_blank (view))
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
is_text = g_content_type_is_a (content_type, text_type);
g_free (content_type);
g_free (text_type);
return is_text;
}
#define can_do(what) \

View file

@ -224,12 +224,7 @@ sokoke_show_uri_with_mime_type (GdkScreen* screen,
GList* files;
gpointer context;
#if GLIB_CHECK_VERSION (2, 18, 0)
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,
!g_str_has_prefix (uri, "file://"));
g_free (content_type);

View file

@ -29,6 +29,10 @@
(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
#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)
#define gtk_dialog_get_content_area(dlg) dlg->vbox
#endif