* mu-msg-body-view: implement "action-requested" signal, emitted when user
clicks cmd:-urls
This commit is contained in:
@ -30,7 +30,7 @@ static void mu_msg_body_view_finalize (GObject *obj);
|
|||||||
|
|
||||||
/* list my signals */
|
/* list my signals */
|
||||||
enum {
|
enum {
|
||||||
/* MY_SIGNAL_1, */
|
ACTION_REQUESTED,
|
||||||
/* MY_SIGNAL_2, */
|
/* MY_SIGNAL_2, */
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
@ -50,8 +50,7 @@ struct _MuMsgBodyViewPrivate {
|
|||||||
/* globals */
|
/* globals */
|
||||||
static WebKitWebViewClass *parent_class = NULL;
|
static WebKitWebViewClass *parent_class = NULL;
|
||||||
|
|
||||||
/* uncomment the following if you have defined any signals */
|
static guint signals[LAST_SIGNAL] = {0};
|
||||||
/* static guint signals[LAST_SIGNAL] = {0}; */
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (MuMsgBodyView, mu_msg_body_view, WEBKIT_TYPE_WEB_VIEW);
|
G_DEFINE_TYPE (MuMsgBodyView, mu_msg_body_view, WEBKIT_TYPE_WEB_VIEW);
|
||||||
|
|
||||||
@ -66,12 +65,15 @@ mu_msg_body_view_class_init (MuMsgBodyViewClass *klass)
|
|||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof(MuMsgBodyViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof(MuMsgBodyViewPrivate));
|
||||||
|
|
||||||
/* signal definitions go here, e.g.: */
|
signals[ACTION_REQUESTED] =
|
||||||
/* signals[MY_SIGNAL_1] = */
|
g_signal_new ("action-requested",
|
||||||
/* g_signal_new ("my_signal_1",....); */
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
/* signals[MY_SIGNAL_2] = */
|
G_SIGNAL_RUN_FIRST,
|
||||||
/* g_signal_new ("my_signal_2",....); */
|
G_STRUCT_OFFSET (MuMsgBodyViewClass,
|
||||||
/* etc. */
|
action_requested),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__STRING,
|
||||||
|
G_TYPE_NONE, 1, G_TYPE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,12 +118,23 @@ on_navigation_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
|
|||||||
|
|
||||||
uri = webkit_network_request_get_uri (request);
|
uri = webkit_network_request_get_uri (request);
|
||||||
|
|
||||||
|
/* if there are 'cmd:<action>" links in the body text of
|
||||||
|
* mu-internal messages (ie., notification from mu, not real
|
||||||
|
* e-mail messages), we emit the 'action requested'
|
||||||
|
* signal. this allows e.g triggering a database refresh from
|
||||||
|
* 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->_mu_mode)
|
if (self->_priv->_mu_mode) {
|
||||||
g_printerr ("execute: '%s'\n", uri + 4);
|
g_signal_emit (G_OBJECT(self),
|
||||||
|
signals[ACTION_REQUESTED], 0,
|
||||||
|
uri + 4);
|
||||||
|
}
|
||||||
return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
|
return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* don't try to play files on our local file system, this is not something
|
||||||
|
* external content should do.*/
|
||||||
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);
|
||||||
|
|
||||||
@ -138,7 +151,6 @@ on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame,
|
|||||||
|
|
||||||
msg = self->_priv->_message;
|
msg = self->_priv->_message;
|
||||||
uri = webkit_network_request_get_uri (request);
|
uri = webkit_network_request_get_uri (request);
|
||||||
|
|
||||||
|
|
||||||
if (g_ascii_strncasecmp (uri, "cid:", 4) == 0) {
|
if (g_ascii_strncasecmp (uri, "cid:", 4) == 0) {
|
||||||
gchar *filepath;
|
gchar *filepath;
|
||||||
|
|||||||
@ -47,8 +47,7 @@ struct _MuMsgBodyView {
|
|||||||
|
|
||||||
struct _MuMsgBodyViewClass {
|
struct _MuMsgBodyViewClass {
|
||||||
WebKitWebViewClass parent_class;
|
WebKitWebViewClass parent_class;
|
||||||
/* insert signal callback declarations, e.g. */
|
void (* action_requested) (MuMsgBodyView* self, const char* action);
|
||||||
/* void (* my_event) (MuMsgBodyView* obj); */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* member functions */
|
/* member functions */
|
||||||
|
|||||||
Reference in New Issue
Block a user