[evolution/webkit: 99/182] Port context menu for mail-links in EMailDisplay



commit f02264f9c37300fb2fe606e4bc2c7a29514d9f81
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Jan 5 16:48:36 2012 +0100

    Port context menu for mail-links in EMailDisplay

 mail/e-mail-display.c |   40 +++++++++++++++++++++++-----------------
 mail/e-mail-display.h |    3 +++
 mail/e-mail-reader.c  |   20 +++++++++++---------
 3 files changed, 37 insertions(+), 26 deletions(-)
---
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 2502704..bd469b5 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -64,6 +64,8 @@ struct _EMailDisplayPrivate {
 	GList *webviews;
 
         GtkWidget *current_webview;
+
+	GtkActionGroup *actions;
 };
 
 enum {
@@ -101,7 +103,6 @@ static const gchar *ui =
 "        <menuitem action='search-folder-sender'/>"
 "      </menu>"
 "    </placeholder>"
-"    <placeholder name='inspect' />"
 "  </popup>"
 "</ui>";
 
@@ -370,7 +371,7 @@ mail_display_process_mailto (EWebView *web_view,
 		CamelFolder *folder = NULL;
 		EShell *shell;
 
-		priv = E_MAIL_DISPLAY_GET_PRIVATE (web_view);
+		priv = E_MAIL_DISPLAY_GET_PRIVATE (display);
 		g_return_val_if_fail (priv->formatter != NULL, FALSE);
 
 		format = EM_FORMAT (priv->formatter);
@@ -609,10 +610,7 @@ mail_display_setup_webview (EMailDisplay *display,
 	EWebView *web_view;
         WebKitWebSettings *settings;
 	GtkUIManager *ui_manager;
-	GtkActionGroup *action_group;
 	GError *error = NULL;
-        guint merge_id;
-        EMailImageLoadingPolicy policy;
 
 	web_view = E_WEB_VIEW (e_web_view_new ());
 
@@ -642,24 +640,18 @@ mail_display_setup_webview (EMailDisplay *display,
         else
                 g_object_set (G_OBJECT (settings), "auto-load-images", FALSE, NULL);
 
-	/* EWebView's action groups are added during its instance
-	 * initialization function (like what we're in now), so it
-	 * is safe to fetch them this early in construction. */
-	action_group = e_web_view_get_action_group (web_view, "mailto");
-
-	/* We don't actually handle the actions we're adding.
-	 * EMailReader handles them.  How devious is that? */
-	gtk_action_group_add_actions (
-		action_group, mailto_entries,
-		G_N_ELEMENTS (mailto_entries), web_view);
 
 	/* Because we are loading from a hard-coded string, there is
 	 * no chance of I/O errors.  Failure here implies a malformed
 	 * UI definition.  Full stop. */
 	ui_manager = e_web_view_get_ui_manager (web_view);
+	gtk_ui_manager_insert_action_group (ui_manager, display->priv->actions, 0);
 	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
-	if (error != NULL)
+
+	if (error != NULL) {
 		g_error ("%s", error->message);
+                g_error_free (error);
+        }
 
 	return web_view;
 }
@@ -1012,8 +1004,12 @@ mail_display_init (EMailDisplay *display)
 
 	display->priv->webviews = NULL;
 
-	/* WEBKIT TODO: ESearchBar */
+	display->priv->actions = gtk_action_group_new ("mailto");
+	gtk_action_group_add_actions (display->priv->actions, mailto_entries, 
+		G_N_ELEMENTS (mailto_entries), NULL);
+
 
+	/* WEBKIT TODO: ESearchBar */
 
 	/* Register our own handler for our own mail:// protocol */
 	session = webkit_get_default_session ();
@@ -1242,6 +1238,16 @@ e_mail_display_get_current_web_view (EMailDisplay *display)
         return E_WEB_VIEW (display->priv->current_webview);
 }
 
+GtkAction*
+e_mail_display_get_action (EMailDisplay *display,
+			   const gchar *action_name)
+{
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
+	g_return_val_if_fail (action_name != NULL, NULL);
+
+	return gtk_action_group_get_action (display->priv->actions, action_name);
+}
+
 void
 e_mail_display_set_status (EMailDisplay *display,
 			   const gchar *status)
diff --git a/mail/e-mail-display.h b/mail/e-mail-display.h
index 2cbbb40..82bf5b7 100644
--- a/mail/e-mail-display.h
+++ b/mail/e-mail-display.h
@@ -93,6 +93,9 @@ void			e_mail_display_reload		(EMailDisplay *display);
 EWebView *		e_mail_display_get_current_web_view
 							(EMailDisplay *display);
 
+GtkAction *		e_mail_display_get_action	(EMailDisplay *display,
+							 const gchar *action_name);
+
 void			e_mail_display_set_status	(EMailDisplay *display,
 							 const gchar *status);
 void			e_mail_display_clear		(EMailDisplay *display);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 3dd98e8..27f6a7b 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -205,7 +205,7 @@ action_add_to_address_book_cb (GtkAction *action,
 	EShellBackend *shell_backend;
 	EMailDisplay *display;
 	CamelInternetAddress *cia;
-	GtkWidget *web_view;
+	EWebView *web_view;
 	CamelURL *curl;
 	const gchar *uri;
 	gchar *email;
@@ -215,11 +215,11 @@ action_add_to_address_book_cb (GtkAction *action,
 	backend = e_mail_reader_get_backend (reader);
 	display = e_mail_reader_get_mail_display (reader);
 
-	web_view = gtk_container_get_focus_child (GTK_CONTAINER  (display));
+	web_view = e_mail_display_get_current_web_view (display);
 	if (!E_IS_WEB_VIEW (web_view))
 		return;
 
-	uri = e_web_view_get_selected_uri (E_WEB_VIEW (web_view));
+	uri = e_web_view_get_selected_uri (web_view);
 	g_return_if_fail (uri != NULL);
 
 	curl = camel_url_new (uri, NULL);
@@ -3669,6 +3669,7 @@ e_mail_reader_init (EMailReader *reader,
 	GtkAction *action;
 	gboolean sensitive;
 	const gchar *action_name;
+	EMailDisplay *display;
 
 #ifndef G_OS_WIN32
 	GSettings *settings;
@@ -3816,31 +3817,32 @@ e_mail_reader_init (EMailReader *reader,
 	gtk_action_set_is_important (action, TRUE);
 	gtk_action_set_short_label (action, _("Reply"));
 
-	/* FIXME WEBKIT
+	display = e_mail_reader_get_mail_display (reader);
+
 	action_name = "add-to-address-book";
-	action = e_web_view_get_action (web_view, action_name);
+	action = e_mail_display_get_action (display, action_name);
 	g_signal_connect (
 		action, "activate",
 		G_CALLBACK (action_add_to_address_book_cb), reader);
 
 	action_name = "send-reply";
-	action = e_web_view_get_action (web_view, action_name);
+	action = e_mail_display_get_action (display, action_name);
 	g_signal_connect (
 		action, "activate",
 		G_CALLBACK (action_mail_reply_recipient_cb), reader);
 
 	action_name = "search-folder-recipient";
-	action = e_web_view_get_action (web_view, action_name);
+	action = e_mail_display_get_action (display, action_name);
 	g_signal_connect (
 		action, "activate",
 		G_CALLBACK (action_search_folder_recipient_cb), reader);
 
 	action_name = "search-folder-sender";
-	action = e_web_view_get_action (web_view, action_name);
+	action = e_mail_display_get_action (display, action_name);
 	g_signal_connect (
 		action, "activate",
 		G_CALLBACK (action_search_folder_sender_cb), reader);
-	*/
+
 #ifndef G_OS_WIN32
 	/* Lockdown integration. */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]