[Xfce4-commits] <midori:master> Unify content type/ MIME type handling and plug leak

Christian Dywan noreply at xfce.org
Fri May 7 20:36:01 CEST 2010


Updating branch refs/heads/master
         to fb72bcfeaecd4d6e40fd01f1b291579a6d6dbcfa (commit)
       from 058325a022d2b77d09c5dbf357e3c5c3b64dba7a (commit)

commit fb72bcfeaecd4d6e40fd01f1b291579a6d6dbcfa
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri May 7 20:17:53 2010 +0200

    Unify content type/ MIME type handling and plug leak

 midori/midori-view.c |   24 +++++-------------------
 midori/sokoke.c      |    5 -----
 midori/sokoke.h      |    4 ++++
 3 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/midori/midori-view.c b/midori/midori-view.c
index b9bf397..e8a9f9d 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -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) \
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 2eeb668..32658a0 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -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);
diff --git a/midori/sokoke.h b/midori/sokoke.h
index 377a90b..46da82e 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -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



More information about the Xfce4-commits mailing list