Merge lp:~kalikiana/midori/ctxtabnew into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6336
Merged at revision: 6343
Proposed branch: lp:~kalikiana/midori/ctxtabnew
Merge into: lp:midori
Diff against target: 113 lines (+38/-35)
1 file modified
midori/midori-view.c (+38/-35)
To merge this branch: bzr merge lp:~kalikiana/midori/ctxtabnew
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+179739@code.launchpad.net

Commit message

Call ensure_link_uri in context-menu and split menu_new_tab callback

Description of the change

The issue that seems to be troubling here is that view->link_uri, a variable that is separate from the hit test result, is or isn't filled in at the time of the context menu. The hybrid tab menu callback isn't robust enough to cope.

Seeing as the real solution would be to kill the old view->link-uri, the next best less introsive fix is to enforce it to be uptodate before the context menu call and split and simplify the new tab callbacks for added robustness.

To post a comment you must log in.
Revision history for this message
André Stösel (ivaldi) wrote :

Looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-view.c'
2--- midori/midori-view.c 2013-08-12 15:40:31 +0000
3+++ midori/midori-view.c 2013-08-12 16:10:32 +0000
4@@ -2175,33 +2175,29 @@
5 }
6
7 static void
8-midori_web_view_menu_new_tab_activate_cb (GtkAction* action,
9- gpointer user_data)
10-{
11- MidoriView* view = user_data;
12- if (view->link_uri)
13- g_signal_emit (view, signals[NEW_TAB], 0, view->link_uri,
14- view->open_tabs_in_the_background);
15- else
16- {
17- gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri");
18- if (strchr (data, '@'))
19- {
20- gchar* uri = g_strconcat ("mailto:", data, NULL);
21- sokoke_show_uri (gtk_widget_get_screen (view->web_view),
22- uri, GDK_CURRENT_TIME, NULL);
23- g_free (uri);
24- }
25- else
26- {
27- gchar* uri = sokoke_magic_uri (data, TRUE, FALSE);
28- if (!uri)
29- uri = g_strdup (data);
30- g_signal_emit (view, signals[NEW_TAB], 0, uri,
31- view->open_tabs_in_the_background);
32- g_free (uri);
33- }
34- }
35+midori_view_menu_open_email_activate_cb (GtkAction* action,
36+ gpointer user_data)
37+{
38+ MidoriView* view = user_data;
39+ gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri");
40+ gchar* uri = g_strconcat ("mailto:", data, NULL);
41+ sokoke_show_uri (gtk_widget_get_screen (view->web_view),
42+ uri, GDK_CURRENT_TIME, NULL);
43+ g_free (uri);
44+}
45+
46+static void
47+midori_view_menu_open_link_tab_activate_cb (GtkAction* action,
48+ gpointer user_data)
49+{
50+ MidoriView* view = user_data;
51+ gchar* data = (gchar*)g_object_get_data (G_OBJECT (action), "uri");
52+ gchar* uri = sokoke_magic_uri (data, TRUE, FALSE);
53+ if (!uri)
54+ uri = g_strdup (data);
55+ g_signal_emit (view, signals[NEW_TAB], 0, uri,
56+ view->open_tabs_in_the_background);
57+ g_free (uri);
58 }
59
60 static void
61@@ -2352,13 +2348,17 @@
62 {
63 if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_APP)
64 {
65- midori_context_action_add_simple (menu, "OpenLinkTab", _("Open _Link"), NULL, STOCK_TAB_NEW,
66- midori_web_view_menu_new_tab_activate_cb, view);
67+ GtkAction* action = gtk_action_new ("OpenLinkTab", _("Open _Link"), NULL, STOCK_TAB_NEW);
68+ g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->link_uri), (GDestroyNotify)g_free);
69+ g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
70+ midori_context_action_add (menu, action);
71 }
72 else if (!midori_view_always_same_tab (view->link_uri))
73 {
74- midori_context_action_add_simple (menu, "OpenLinkTab", _("Open Link in New _Tab"), NULL, STOCK_TAB_NEW,
75- midori_web_view_menu_new_tab_activate_cb, view);
76+ GtkAction* action = gtk_action_new ("OpenLinkTab", _("Open Link in New _Tab"), NULL, STOCK_TAB_NEW);
77+ g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->link_uri), (GDestroyNotify)g_free);
78+ g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
79+ midori_context_action_add (menu, action);
80 midori_context_action_add_simple (menu, "OpenLinkForegroundTab",
81 view->open_tabs_in_the_background
82 ? _("Open Link in _Foreground Tab") : _("Open Link in _Background Tab"), NULL, NULL,
83@@ -2430,16 +2430,16 @@
84 {
85 gchar* text = g_strdup_printf (_("Send a message to %s"), view->selected_text);
86 GtkAction* action = gtk_action_new ("SendMessage", text, NULL, GTK_STOCK_JUMP_TO);
87- g_object_set_data (G_OBJECT (action), "uri", view->selected_text);
88- g_signal_connect (action, "activate", G_CALLBACK (midori_web_view_menu_new_tab_activate_cb), view);
89+ g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free);
90+ g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_email_activate_cb), view);
91 midori_context_action_add (menu, action);
92 g_free (text);
93 }
94 else
95 {
96 GtkAction* action = gtk_action_new ("OpenAddressInNewTab", _("Open Address in New _Tab"), NULL, GTK_STOCK_JUMP_TO);
97- g_object_set_data (G_OBJECT (action), "uri", view->selected_text);
98- g_signal_connect (action, "activate", G_CALLBACK (midori_web_view_menu_new_tab_activate_cb), view);
99+ g_object_set_data_full (G_OBJECT (action), "uri", g_strdup (view->selected_text), (GDestroyNotify)g_free);
100+ g_signal_connect (action, "activate", G_CALLBACK (midori_view_menu_open_link_tab_activate_cb), view);
101 midori_context_action_add (menu, action);
102 }
103 }
104@@ -2577,6 +2577,9 @@
105 #endif
106 MidoriView* view)
107 {
108+ GdkEvent* event = gtk_get_current_event();
109+ midori_view_ensure_link_uri (view, NULL, NULL, (GdkEventButton *)event);
110+ gdk_event_free (event);
111 MidoriContextAction* menu = midori_view_get_page_context_action (view, hit_test_result);
112 #ifdef HAVE_WEBKIT2
113 webkit_context_menu_remove_all (context_menu);

Subscribers

People subscribed via source and target branches

to all changes: