mug: quick & dirty port to webkit2gtk3
This commit is contained in:
12
configure.ac
12
configure.ac
@ -197,11 +197,13 @@ AM_CONDITIONAL(HAVE_GTK,[test "x$have_gtk" = "xyes"])
|
|||||||
|
|
||||||
# webkit? needed for the fancy web widget
|
# webkit? needed for the fancy web widget
|
||||||
# use --disable-webkit to disable it, even if you have it
|
# use --disable-webkit to disable it, even if you have it
|
||||||
|
#
|
||||||
|
# and note this is just a toy, not for distribution.
|
||||||
AC_ARG_ENABLE([webkit],AS_HELP_STRING([--disable-webkit],[Disable webkit]))
|
AC_ARG_ENABLE([webkit],AS_HELP_STRING([--disable-webkit],[Disable webkit]))
|
||||||
AS_IF([test "x$enable_webkit" != "xno"],[
|
AS_IF([test "x$enable_webkit" != "xno"],[
|
||||||
PKG_CHECK_MODULES(WEBKIT,webkitgtk-3.0 >= 1.8.0,[have_webkit=yes],[have_webkit=no])
|
PKG_CHECK_MODULES(WEBKIT,webkit2gtk-4.0 >= 2.0, [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 webkitgtk-3.0)"])
|
webkit_version="$($PKG_CONFIG --modversion webkit2gtk-4.0)"])
|
||||||
])
|
])
|
||||||
AM_CONDITIONAL(HAVE_WEBKIT, [test "x$have_webkit" = "xyes"])
|
AM_CONDITIONAL(HAVE_WEBKIT, [test "x$have_webkit" = "xyes"])
|
||||||
AM_CONDITIONAL(BUILD_GUI,[test "x$have_webkit" = "xyes" -a "x$have_gtk" = "xyes"])
|
AM_CONDITIONAL(BUILD_GUI,[test "x$have_webkit" = "xyes" -a "x$have_gtk" = "xyes"])
|
||||||
@ -288,7 +290,7 @@ echo "Json-Glib version : $json_glib_version"
|
|||||||
|
|
||||||
AM_COND_IF([BUILD_GUI],[
|
AM_COND_IF([BUILD_GUI],[
|
||||||
echo "GTK+ version : $gtk_version"
|
echo "GTK+ version : $gtk_version"
|
||||||
echo "Webkit version : $webkit_version"
|
echo "Webkit2/GTK+ version : $webkit_version"
|
||||||
])
|
])
|
||||||
|
|
||||||
AM_COND_IF([BUILD_GUILE],[
|
AM_COND_IF([BUILD_GUILE],[
|
||||||
@ -299,10 +301,6 @@ if test "x$build_mu4e" = "xyes"; then
|
|||||||
echo "Emacs version : $emacs_version"
|
echo "Emacs version : $emacs_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#AM_COND_IF([BUILD_PERL],[
|
|
||||||
#echo "Perl interface version : $perl_version"
|
|
||||||
#])
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Have wordexp : $ac_cv_header_wordexp_h"
|
echo "Have wordexp : $ac_cv_header_wordexp_h"
|
||||||
echo "Build mu4e emacs frontend : $build_mu4e"
|
echo "Build mu4e emacs frontend : $build_mu4e"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
## Copyright (C) 2008-2017 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
## Copyright (C) 2008-2019 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
@ -36,6 +36,9 @@ AM_CFLAGS= \
|
|||||||
|
|
||||||
AM_CXXFLAGS=$(WARN_CXXFLAGS)
|
AM_CXXFLAGS=$(WARN_CXXFLAGS)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Distributors: this is a _toy_, not for distribution. the "noinst_" says enough
|
||||||
|
#
|
||||||
noinst_PROGRAMS= \
|
noinst_PROGRAMS= \
|
||||||
mug
|
mug
|
||||||
|
|
||||||
|
|||||||
@ -16,10 +16,7 @@
|
|||||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
#include <webkit/webkitwebview.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>
|
||||||
|
|
||||||
@ -46,10 +43,11 @@ enum {
|
|||||||
|
|
||||||
|
|
||||||
struct _MuMsgBodyViewPrivate {
|
struct _MuMsgBodyViewPrivate {
|
||||||
WebKitWebSettings *_settings;
|
WebKitSettings *_settings;
|
||||||
MuMsg *_msg;
|
MuMsg *_msg;
|
||||||
ViewMode _view_mode;
|
ViewMode _view_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MU_MSG_BODY_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
#define MU_MSG_BODY_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
|
||||||
MU_TYPE_MSG_BODY_VIEW, \
|
MU_TYPE_MSG_BODY_VIEW, \
|
||||||
MuMsgBodyViewPrivate))
|
MuMsgBodyViewPrivate))
|
||||||
@ -136,62 +134,54 @@ save_file_for_cid (MuMsg *msg, const char* cid)
|
|||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_navigation_policy_decision_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
|
on_navigation_policy_decision_requested (MuMsgBodyView *self,
|
||||||
WebKitNetworkRequest *request,
|
WebKitPolicyDecision *decision,
|
||||||
WebKitWebNavigationAction *nav_action,
|
WebKitPolicyDecisionType decision_type,
|
||||||
WebKitWebPolicyDecision *policy_decision,
|
|
||||||
gpointer data)
|
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, don't the navigation */
|
/* XXX if it wasn't a user click, don't navigate */
|
||||||
if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
|
if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) {
|
||||||
webkit_web_policy_decision_ignore (policy_decision);
|
webkit_policy_decision_ignore (decision);
|
||||||
return TRUE;
|
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 */
|
||||||
* e-mail messages), we emit the 'action requested'
|
/* * e-mail messages), we emit the 'action requested' */
|
||||||
* signal. this allows e.g triggering a database refresh from
|
/* * signal. this allows e.g triggering a database refresh from */
|
||||||
* a <a href="cmd:refresh">Refresh</a> link
|
/* * a <a href="cmd:refresh">Refresh</a> link */
|
||||||
*/
|
/* *\/ */
|
||||||
if (g_ascii_strncasecmp (uri, "cmd:", 4) == 0) {
|
/* if (g_ascii_strncasecmp (uri, "cmd:", 4) == 0) { */
|
||||||
if (self->_priv->_view_mode == VIEW_MODE_NOTE) {
|
/* if (self->_priv->_view_mode == VIEW_MODE_NOTE) { */
|
||||||
g_signal_emit (G_OBJECT(self),
|
/* g_signal_emit (G_OBJECT(self), */
|
||||||
signals[ACTION_REQUESTED], 0,
|
/* signals[ACTION_REQUESTED], 0, */
|
||||||
uri + 4);
|
/* uri + 4); */
|
||||||
}
|
/* } */
|
||||||
return TRUE;
|
/* 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 */
|
||||||
* external content should do.*/
|
/* * external content should do.*\/ */
|
||||||
if (!mu_util_is_local_file(uri))
|
/* if (!mu_util_is_local_file(uri)) */
|
||||||
mu_util_play (uri, FALSE, TRUE, NULL);
|
/* mu_util_play (uri, FALSE, TRUE, NULL); */
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame,
|
on_resource_load_started (MuMsgBodyView *self, WebKitWebResource *resource,
|
||||||
WebKitWebResource *resource, WebKitNetworkRequest *request,
|
WebKitURIRequest *request, gpointer data)
|
||||||
WebKitNetworkResponse *response, gpointer data)
|
|
||||||
{
|
{
|
||||||
const char* uri;
|
const char* uri;
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
|
|
||||||
msg = self->_priv->_msg;
|
msg = self->_priv->_msg;
|
||||||
uri = webkit_network_request_get_uri (request);
|
uri = webkit_uri_request_get_uri (request);
|
||||||
|
|
||||||
/* g_warning ("%s: %s", __func__, uri); */
|
/* g_warning ("%s: %s", __func__, uri); */
|
||||||
|
|
||||||
@ -201,7 +191,7 @@ on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame,
|
|||||||
if (filepath) {
|
if (filepath) {
|
||||||
gchar *fileuri;
|
gchar *fileuri;
|
||||||
fileuri = g_strdup_printf ("file://%s", filepath);
|
fileuri = g_strdup_printf ("file://%s", filepath);
|
||||||
webkit_network_request_set_uri (request, fileuri);
|
webkit_uri_request_set_uri (request, fileuri);
|
||||||
g_free (fileuri);
|
g_free (fileuri);
|
||||||
g_free (filepath);
|
g_free (filepath);
|
||||||
}
|
}
|
||||||
@ -276,24 +266,18 @@ mu_msg_body_view_init (MuMsgBodyView *obj)
|
|||||||
obj->_priv->_msg = NULL;
|
obj->_priv->_msg = NULL;
|
||||||
obj->_priv->_view_mode = VIEW_MODE_NONE;
|
obj->_priv->_view_mode = VIEW_MODE_NONE;
|
||||||
|
|
||||||
obj->_priv->_settings = webkit_web_settings_new ();
|
obj->_priv->_settings = webkit_settings_new ();
|
||||||
g_object_set (G_OBJECT(obj->_priv->_settings),
|
g_object_set (G_OBJECT(obj->_priv->_settings),
|
||||||
"enable-scripts", FALSE,
|
"enable-javascript", FALSE,
|
||||||
"auto-load-images", TRUE,
|
"auto-load-images", TRUE,
|
||||||
"enable-plugins", FALSE,
|
"enable-plugins", FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
webkit_web_view_set_settings (WEBKIT_WEB_VIEW(obj),
|
webkit_web_view_set_settings (WEBKIT_WEB_VIEW(obj), obj->_priv->_settings);
|
||||||
obj->_priv->_settings);
|
|
||||||
webkit_web_view_set_editable (WEBKIT_WEB_VIEW(obj), FALSE);
|
|
||||||
|
|
||||||
/* to support cid: */
|
/* to support cid: */
|
||||||
g_signal_connect (obj, "resource-request-starting",
|
g_signal_connect (obj, "resource-load-started",
|
||||||
G_CALLBACK (on_resource_request_starting), NULL);
|
G_CALLBACK (on_resource_load_started), NULL);
|
||||||
/* handle navigation requests */
|
|
||||||
g_signal_connect (obj, "navigation-policy-decision-requested",
|
|
||||||
G_CALLBACK (on_navigation_policy_decision_requested), NULL);
|
|
||||||
/* handle right-button clicks */
|
|
||||||
g_signal_connect (obj, "button-press-event",
|
g_signal_connect (obj, "button-press-event",
|
||||||
G_CALLBACK(on_button_press_event), NULL);
|
G_CALLBACK(on_button_press_event), NULL);
|
||||||
}
|
}
|
||||||
@ -324,11 +308,9 @@ set_html (MuMsgBodyView *self, const char* html)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
|
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
|
||||||
|
|
||||||
webkit_web_view_load_string (WEBKIT_WEB_VIEW(self),
|
webkit_web_view_load_html (WEBKIT_WEB_VIEW(self),
|
||||||
html ? html : "",
|
html ? html : "",
|
||||||
"text/html",
|
NULL);
|
||||||
"utf-8",
|
|
||||||
"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -336,11 +318,7 @@ set_text (MuMsgBodyView *self, const char* txt)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
|
g_return_if_fail (MU_IS_MSG_BODY_VIEW(self));
|
||||||
|
|
||||||
webkit_web_view_load_string (WEBKIT_WEB_VIEW(self),
|
webkit_web_view_load_plain_text (WEBKIT_WEB_VIEW(self), txt ? txt : "");
|
||||||
txt ? txt : "",
|
|
||||||
"text/plain",
|
|
||||||
"utf-8",
|
|
||||||
"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#ifndef __MU_MSG_BODY_VIEW_H__
|
#ifndef __MU_MSG_BODY_VIEW_H__
|
||||||
#define __MU_MSG_BODY_VIEW_H__
|
#define __MU_MSG_BODY_VIEW_H__
|
||||||
|
|
||||||
#include <webkit/webkitwebview.h>
|
#include <webkit2/webkit2.h>
|
||||||
#include <mu-msg.h>
|
#include <mu-msg.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -67,4 +67,3 @@ void mu_msg_body_view_set_message_source (MuMsgBodyView *self, MuMsg *msg);
|
|||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __MU_MSG_BODY_VIEW_H__ */
|
#endif /* __MU_MSG_BODY_VIEW_H__ */
|
||||||
|
|
||||||
|
|||||||
@ -146,18 +146,20 @@ mu_msg_view_init (MuMsgView *self)
|
|||||||
GTK_ORIENTATION_VERTICAL);
|
GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
self->_priv = MU_MSG_VIEW_GET_PRIVATE(self);
|
self->_priv = MU_MSG_VIEW_GET_PRIVATE(self);
|
||||||
self->_priv->_msg = NULL;
|
|
||||||
self->_priv->_headers = mu_msg_header_view_new ();
|
self->_priv->_msg = NULL;
|
||||||
self->_priv->_attach = mu_msg_attach_view_new ();
|
self->_priv->_headers = mu_msg_header_view_new ();
|
||||||
self->_priv->_attachexpander = gtk_expander_new_with_mnemonic
|
self->_priv->_attach = mu_msg_attach_view_new ();
|
||||||
|
self->_priv->_attachexpander = gtk_expander_new_with_mnemonic
|
||||||
("_Attachments");
|
("_Attachments");
|
||||||
gtk_container_add (GTK_CONTAINER(self->_priv->_attachexpander),
|
|
||||||
|
gtk_container_add (GTK_CONTAINER(self->_priv->_attachexpander),
|
||||||
self->_priv->_attach);
|
self->_priv->_attach);
|
||||||
g_signal_connect (self->_priv->_attach, "attach-activated",
|
g_signal_connect (self->_priv->_attach, "attach-activated",
|
||||||
G_CALLBACK(on_attach_activated),
|
G_CALLBACK(on_attach_activated),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
self->_priv->_body = mu_msg_body_view_new ();
|
self->_priv->_body = mu_msg_body_view_new ();
|
||||||
g_signal_connect (self->_priv->_body,
|
g_signal_connect (self->_priv->_body,
|
||||||
"action-requested",
|
"action-requested",
|
||||||
G_CALLBACK(on_body_action_requested),
|
G_CALLBACK(on_body_action_requested),
|
||||||
@ -167,10 +169,6 @@ mu_msg_view_init (MuMsgView *self)
|
|||||||
FALSE, FALSE, 2);
|
FALSE, FALSE, 2);
|
||||||
gtk_box_pack_start (GTK_BOX(self), self->_priv->_attachexpander,
|
gtk_box_pack_start (GTK_BOX(self), self->_priv->_attachexpander,
|
||||||
FALSE, FALSE, 2);
|
FALSE, FALSE, 2);
|
||||||
gtk_box_pack_start (GTK_BOX(self),
|
|
||||||
gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
|
|
||||||
TRUE,TRUE,0);
|
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX(self), self->_priv->_body,
|
gtk_box_pack_start (GTK_BOX(self), self->_priv->_body,
|
||||||
TRUE, TRUE, 2);
|
TRUE, TRUE, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2019 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** This program is free software; you can redistribute it and/or modify it
|
||||||
** under the terms of the GNU General Public License as published by the
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -309,10 +309,10 @@ static MugError
|
|||||||
mu_result_to_mug_error (MuError r)
|
mu_result_to_mug_error (MuError r)
|
||||||
{
|
{
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case MU_ERROR_XAPIAN_DIR_NOT_ACCESSIBLE:
|
/* case MU_ERROR_XAPIAN_DIR_NOT_ACCESSIBLE: */
|
||||||
return MUG_ERROR_XAPIAN_DIR;
|
/* return MUG_ERROR_XAPIAN_DIR; */
|
||||||
case MU_ERROR_XAPIAN_VERSION_MISMATCH:
|
/* case MU_ERROR_XAPIAN_VERSION_MISMATCH: */
|
||||||
return MUG_ERROR_XAPIAN_NOT_UPTODATE;
|
/* return MUG_ERROR_XAPIAN_NOT_UPTODATE; */
|
||||||
case MU_ERROR_XAPIAN_QUERY:
|
case MU_ERROR_XAPIAN_QUERY:
|
||||||
return MUG_ERROR_QUERY;
|
return MUG_ERROR_QUERY;
|
||||||
default:
|
default:
|
||||||
@ -330,7 +330,7 @@ run_query (const char *xpath, const char *query, MugMsgListView * self)
|
|||||||
MuQueryFlags qflags;
|
MuQueryFlags qflags;
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
if (! (store = mu_store_new_read_only (xpath, &err)) ||
|
if (! (store = mu_store_new_readable (xpath, &err)) ||
|
||||||
! (xapian = mu_query_new (store, &err))) {
|
! (xapian = mu_query_new (store, &err))) {
|
||||||
if (store)
|
if (store)
|
||||||
mu_store_unref (store);
|
mu_store_unref (store);
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include <string.h> /* for memset */
|
#include <string.h> /* for memset */
|
||||||
|
|
||||||
#include <mu-util.h>
|
#include <mu-util.h>
|
||||||
#include <mu-store.h>
|
#include <mu-store.hh>
|
||||||
#include <mu-runtime.h>
|
#include <mu-runtime.h>
|
||||||
#include <mu-index.h>
|
#include <mu-index.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user