* mu-msg-body-view: use the navigation-policy-decision-requested signal so we
can distinguish user clicks (open externally) and things like iframes (open internally); require webkit >= 1.0.3
This commit is contained in:
@ -117,7 +117,7 @@ AC_SUBST(GMIME_LIBS)
|
|||||||
|
|
||||||
|
|
||||||
# webkit? needed for the fancy web widget
|
# webkit? needed for the fancy web widget
|
||||||
PKG_CHECK_MODULES(WEBKIT,webkit-1.0,[have_webkit=yes],[have_webkit=no])
|
PKG_CHECK_MODULES(WEBKIT,webkit-1.0 >= 1.0.3,[have_webkit=yes],[have_webkit=no])
|
||||||
AS_IF([test "x$have_webkit" = "xyes"],[
|
AS_IF([test "x$have_webkit" = "xyes"],[
|
||||||
webkit_version="`pkg-config --modversion webkit-1.0`"])
|
webkit_version="`pkg-config --modversion webkit-1.0`"])
|
||||||
AC_SUBST(WEBKIT_CFLAGS)
|
AC_SUBST(WEBKIT_CFLAGS)
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
#include <webkit/webkitwebview.h>
|
#include <webkit/webkitwebview.h>
|
||||||
#include <webkit/webkitnetworkresponse.h>
|
#include <webkit/webkitnetworkresponse.h>
|
||||||
|
#include <webkit/webkitwebnavigationaction.h>
|
||||||
|
#include <webkit/webkitwebpolicydecision.h>
|
||||||
|
|
||||||
|
|
||||||
#include "mu-msg-body-view.h"
|
#include "mu-msg-body-view.h"
|
||||||
#include <mu-msg-part.h>
|
#include <mu-msg-part.h>
|
||||||
@ -110,13 +113,28 @@ save_file_for_cid (MuMsg *msg, const char* cid)
|
|||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WebKitNavigationResponse
|
|
||||||
on_navigation_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
|
static gboolean
|
||||||
WebKitNetworkRequest *request, gpointer data)
|
on_navigation_policy_decision_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
|
||||||
|
WebKitNetworkRequest *request,
|
||||||
|
WebKitWebNavigationAction *nav_action,
|
||||||
|
WebKitWebPolicyDecision *policy_decision,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
const char* uri;
|
const char* uri;
|
||||||
|
WebKitWebNavigationReason reason;
|
||||||
|
|
||||||
uri = webkit_network_request_get_uri (request);
|
uri = webkit_network_request_get_uri (request);
|
||||||
|
reason = webkit_web_navigation_action_get_reason (nav_action);
|
||||||
|
|
||||||
|
/* if it wasn't a user click, do the navigation */
|
||||||
|
if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
|
||||||
|
webkit_web_policy_decision_ignore (policy_decision);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we handle links clicked ourselves, no need for navigation */
|
||||||
|
webkit_web_policy_decision_ignore (policy_decision);
|
||||||
|
|
||||||
/* if there are 'cmd:<action>" links in the body text of
|
/* if there are 'cmd:<action>" links in the body text of
|
||||||
* mu-internal messages (ie., notification from mu, not real
|
* mu-internal messages (ie., notification from mu, not real
|
||||||
@ -130,7 +148,7 @@ on_navigation_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
|
|||||||
signals[ACTION_REQUESTED], 0,
|
signals[ACTION_REQUESTED], 0,
|
||||||
uri + 4);
|
uri + 4);
|
||||||
}
|
}
|
||||||
return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't try to play files on our local file system, this is not something
|
/* don't try to play files on our local file system, this is not something
|
||||||
@ -138,9 +156,11 @@ on_navigation_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
|
|||||||
if (!mu_util_is_local_file(uri))
|
if (!mu_util_is_local_file(uri))
|
||||||
mu_util_play (uri, FALSE, TRUE);
|
mu_util_play (uri, FALSE, TRUE);
|
||||||
|
|
||||||
return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame,
|
on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame,
|
||||||
WebKitWebResource *resource, WebKitNetworkRequest *request,
|
WebKitWebResource *resource, WebKitNetworkRequest *request,
|
||||||
@ -188,11 +208,9 @@ mu_msg_body_view_init (MuMsgBodyView *obj)
|
|||||||
/* to support cid: */
|
/* to support cid: */
|
||||||
g_signal_connect (obj, "resource-request-starting",
|
g_signal_connect (obj, "resource-request-starting",
|
||||||
G_CALLBACK (on_resource_request_starting), NULL);
|
G_CALLBACK (on_resource_request_starting), NULL);
|
||||||
|
|
||||||
/* handle navigation requests */
|
/* handle navigation requests */
|
||||||
g_signal_connect (obj, "navigation-requested",
|
g_signal_connect (obj, "navigation-policy-decision-requested",
|
||||||
G_CALLBACK (on_navigation_requested), (void*)0x666);
|
G_CALLBACK (on_navigation_policy_decision_requested), NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user