Merge lp:~midori/midori/navigationAction into lp:midori
- navigationAction
- Merge into trunk
Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~midori/midori/navigationAction | ||||
Merge into: | lp:midori | ||||
Diff against target: |
953 lines (+326/-419) 5 files modified
midori/midori-browser.c (+29/-416) midori/midori-navigationaction.vala (+293/-0) midori/midori-view.c (+3/-0) midori/midori-window.vala (+0/-3) po/POTFILES.in (+1/-0) |
||||
To merge this branch: | bzr merge lp:~midori/midori/navigationAction | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danielle Foré (community) | Needs Fixing | ||
Review via email: mp+257570@code.launchpad.net |
Commit message
Split Back, Forward and friends into NavigationAction
Description of the change
- 6950. By Cris Dywan
-
Merge lp:midori
- 6951. By Cris Dywan
-
Remaining NavigationAction subclasses
- 6952. By Cris Dywan
-
Coding style fixes
Cris Dywan (kalikiana) wrote : | # |
In 10 minutes I couldn't find a way to use GLib.Icon with ThemedIcon.
- 6953. By Cris Dywan
-
Related page boilerplate in NavigationAction
Danielle Foré (danrabbit) wrote : | # |
For what it's worth, Gtk.Action is also deprecated :p The only thing I can really figure out so far is that the button itself is visible but the Gtk.Image packed into it is set visible = false.
Cris Dywan (kalikiana) wrote : | # |
The slight predicament is that there's nothing replacing Gtk.Action. We need something with an icon, a short cut, sub menus and a label. We have Midori.
That said, what I would like to see is icon names on ContextAction that automatically append -symbolic, alternate icon names and an accelerators property (plural). I did the midori_
Danielle Foré (danrabbit) wrote : | # |
Hrm accoring to valadoc, GLib.Action replaces it http://
Unmerged revisions
- 6953. By Cris Dywan
-
Related page boilerplate in NavigationAction
- 6952. By Cris Dywan
-
Coding style fixes
- 6951. By Cris Dywan
-
Remaining NavigationAction subclasses
- 6950. By Cris Dywan
-
Merge lp:midori
- 6949. By Cris Dywan
-
Split Back, Forward and friends into NavigationAction
Preview Diff
1 | === modified file 'midori/midori-browser.c' | |||
2 | --- midori/midori-browser.c 2015-06-03 02:05:28 +0000 | |||
3 | +++ midori/midori-browser.c 2015-06-07 21:30:55 +0000 | |||
4 | @@ -192,12 +192,6 @@ | |||
5 | 192 | GParamSpec* pspec, | 192 | GParamSpec* pspec, |
6 | 193 | MidoriBrowser* browser); | 193 | MidoriBrowser* browser); |
7 | 194 | 194 | ||
8 | 195 | static void | ||
9 | 196 | midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser, | ||
10 | 197 | GtkWidget* widget, | ||
11 | 198 | gboolean back, | ||
12 | 199 | gint x, | ||
13 | 200 | gint y); | ||
14 | 201 | void | 195 | void |
15 | 202 | midori_panel_set_toolbar_style (MidoriPanel* panel, | 196 | midori_panel_set_toolbar_style (MidoriPanel* panel, |
16 | 203 | GtkToolbarStyle style); | 197 | GtkToolbarStyle style); |
17 | @@ -292,13 +286,6 @@ | |||
18 | 292 | { | 286 | { |
19 | 293 | GtkAction* action; | 287 | GtkAction* action; |
20 | 294 | 288 | ||
21 | 295 | _action_set_sensitive (browser, "Back", midori_view_can_go_back (view)); | ||
22 | 296 | _action_set_sensitive (browser, "Forward", midori_tab_can_go_forward (MIDORI_TAB (view))); | ||
23 | 297 | _action_set_sensitive (browser, "Previous", | ||
24 | 298 | midori_view_get_previous_page (view) != NULL); | ||
25 | 299 | _action_set_sensitive (browser, "Next", | ||
26 | 300 | midori_view_get_next_page (view) != NULL); | ||
27 | 301 | |||
28 | 302 | _action_set_sensitive (browser, "AddSpeedDial", !midori_view_is_blank (view)); | 289 | _action_set_sensitive (browser, "AddSpeedDial", !midori_view_is_blank (view)); |
29 | 303 | _action_set_sensitive (browser, "BookmarkAdd", !midori_view_is_blank (view)); | 290 | _action_set_sensitive (browser, "BookmarkAdd", !midori_view_is_blank (view)); |
30 | 304 | _action_set_sensitive (browser, "MailTo", !midori_view_is_blank (view)); | 291 | _action_set_sensitive (browser, "MailTo", !midori_view_is_blank (view)); |
31 | @@ -314,22 +301,6 @@ | |||
32 | 314 | _action_set_sensitive (browser, "SourceViewDom", | 301 | _action_set_sensitive (browser, "SourceViewDom", |
33 | 315 | midori_tab_can_view_source (MIDORI_TAB (view))); | 302 | midori_tab_can_view_source (MIDORI_TAB (view))); |
34 | 316 | 303 | ||
35 | 317 | action = _action_by_name (browser, "NextForward"); | ||
36 | 318 | if (midori_tab_can_go_forward (MIDORI_TAB (view))) | ||
37 | 319 | { | ||
38 | 320 | g_object_set (action, | ||
39 | 321 | "stock-id", GTK_STOCK_GO_FORWARD, | ||
40 | 322 | "tooltip", _("Go forward to the next page"), | ||
41 | 323 | "sensitive", TRUE, NULL); | ||
42 | 324 | } | ||
43 | 325 | else | ||
44 | 326 | { | ||
45 | 327 | g_object_set (action, | ||
46 | 328 | "stock-id", GTK_STOCK_MEDIA_NEXT, | ||
47 | 329 | "tooltip", _("Go to the next sub-page"), | ||
48 | 330 | "sensitive", midori_view_get_next_page (view) != NULL, NULL); | ||
49 | 331 | } | ||
50 | 332 | |||
51 | 333 | action = _action_by_name (browser, "Location"); | 304 | action = _action_by_name (browser, "Location"); |
52 | 334 | if (midori_tab_is_blank (MIDORI_TAB (view))) | 305 | if (midori_tab_is_blank (MIDORI_TAB (view))) |
53 | 335 | { | 306 | { |
54 | @@ -432,23 +403,6 @@ | |||
55 | 432 | action = _action_by_name (browser, "Location"); | 403 | action = _action_by_name (browser, "Location"); |
56 | 433 | midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action), progress); | 404 | midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action), progress); |
57 | 434 | 405 | ||
58 | 435 | _action_set_sensitive (browser, "Reload", !loading); | ||
59 | 436 | _action_set_sensitive (browser, "Stop", loading); | ||
60 | 437 | |||
61 | 438 | action = _action_by_name (browser, "ReloadStop"); | ||
62 | 439 | if (!loading) | ||
63 | 440 | { | ||
64 | 441 | g_object_set (action, | ||
65 | 442 | "stock-id", GTK_STOCK_REFRESH, | ||
66 | 443 | "tooltip", _("Reload the current page"), NULL); | ||
67 | 444 | } | ||
68 | 445 | else | ||
69 | 446 | { | ||
70 | 447 | g_object_set (action, | ||
71 | 448 | "stock-id", GTK_STOCK_STOP, | ||
72 | 449 | "tooltip", _("Stop loading the current page"), NULL); | ||
73 | 450 | } | ||
74 | 451 | |||
75 | 452 | g_object_set (browser->throbber, "active", loading, "visible", loading, NULL); | 406 | g_object_set (browser->throbber, "active", loading, "visible", loading, NULL); |
76 | 453 | } | 407 | } |
77 | 454 | 408 | ||
78 | @@ -734,8 +688,6 @@ | |||
79 | 734 | const gchar* uri = midori_view_get_display_uri (view); | 688 | const gchar* uri = midori_view_get_display_uri (view); |
80 | 735 | GtkAction* action = _action_by_name (browser, "Location"); | 689 | GtkAction* action = _action_by_name (browser, "Location"); |
81 | 736 | midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri); | 690 | midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri); |
82 | 737 | _action_set_sensitive (browser, "Back", midori_view_can_go_back (view)); | ||
83 | 738 | _action_set_sensitive (browser, "Forward", midori_tab_can_go_forward (MIDORI_TAB (view))); | ||
84 | 739 | g_object_notify (G_OBJECT (browser), "uri"); | 691 | g_object_notify (G_OBJECT (browser), "uri"); |
85 | 740 | } | 692 | } |
86 | 741 | } | 693 | } |
87 | @@ -2059,53 +2011,6 @@ | |||
88 | 2059 | /* Nothing to do */ | 2011 | /* Nothing to do */ |
89 | 2060 | } | 2012 | } |
90 | 2061 | 2013 | ||
91 | 2062 | static void | ||
92 | 2063 | _update_tooltip_if_changed (GtkAction* action, | ||
93 | 2064 | const gchar* text) | ||
94 | 2065 | { | ||
95 | 2066 | gchar *old; | ||
96 | 2067 | g_object_get (action, "tooltip", &old, NULL); | ||
97 | 2068 | if (g_strcmp0(old, text)) { | ||
98 | 2069 | g_object_set (action, | ||
99 | 2070 | "tooltip", text, NULL); | ||
100 | 2071 | } | ||
101 | 2072 | g_free (old); | ||
102 | 2073 | } | ||
103 | 2074 | |||
104 | 2075 | static void | ||
105 | 2076 | _update_reload_tooltip (GtkWidget* widget, | ||
106 | 2077 | GdkEventKey* event, | ||
107 | 2078 | gboolean released) | ||
108 | 2079 | { | ||
109 | 2080 | MidoriBrowser* browser = MIDORI_BROWSER (widget); | ||
110 | 2081 | |||
111 | 2082 | /* Update the reload/stop tooltip in case we are holding the hard refresh modifiers*/ | ||
112 | 2083 | GtkAction *reload_stop = _action_by_name (browser, "ReloadStop"); | ||
113 | 2084 | GtkAction *reload = _action_by_name (browser, "Reload"); | ||
114 | 2085 | GdkModifierType mask; | ||
115 | 2086 | gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask); | ||
116 | 2087 | const gchar *target; | ||
117 | 2088 | |||
118 | 2089 | if ( mask & GDK_SHIFT_MASK) | ||
119 | 2090 | { | ||
120 | 2091 | target = _("Reload page without caching"); | ||
121 | 2092 | } | ||
122 | 2093 | else | ||
123 | 2094 | { | ||
124 | 2095 | target = _("Reload the current page"); | ||
125 | 2096 | } | ||
126 | 2097 | _update_tooltip_if_changed (reload_stop, target); | ||
127 | 2098 | _update_tooltip_if_changed (reload, target); | ||
128 | 2099 | } | ||
129 | 2100 | |||
130 | 2101 | static gboolean | ||
131 | 2102 | midori_browser_key_release_event (GtkWidget* widget, | ||
132 | 2103 | GdkEventKey* event) | ||
133 | 2104 | { | ||
134 | 2105 | _update_reload_tooltip (widget, event, TRUE); | ||
135 | 2106 | return GTK_WIDGET_CLASS (midori_browser_parent_class)->key_release_event (widget, event); | ||
136 | 2107 | } | ||
137 | 2108 | |||
138 | 2109 | static gboolean | 2014 | static gboolean |
139 | 2110 | midori_browser_key_press_event (GtkWidget* widget, | 2015 | midori_browser_key_press_event (GtkWidget* widget, |
140 | 2111 | GdkEventKey* event) | 2016 | GdkEventKey* event) |
141 | @@ -2115,7 +2020,6 @@ | |||
142 | 2115 | GtkWidgetClass* widget_class; | 2020 | GtkWidgetClass* widget_class; |
143 | 2116 | guint clean_state; | 2021 | guint clean_state; |
144 | 2117 | 2022 | ||
145 | 2118 | _update_reload_tooltip(widget, event, FALSE); | ||
146 | 2119 | /* Interpret Ctrl(+Shift)+Tab as tab switching for compatibility */ | 2023 | /* Interpret Ctrl(+Shift)+Tab as tab switching for compatibility */ |
147 | 2120 | if (midori_browser_get_nth_tab (browser, 1) != NULL | 2024 | if (midori_browser_get_nth_tab (browser, 1) != NULL |
148 | 2121 | && event->keyval == GDK_KEY_Tab | 2025 | && event->keyval == GDK_KEY_Tab |
149 | @@ -2156,18 +2060,15 @@ | |||
150 | 2156 | && !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus))) | 2060 | && !webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (focus))) |
151 | 2157 | { | 2061 | { |
152 | 2158 | /* Space at the bottom of the page: Go to next page */ | 2062 | /* Space at the bottom of the page: Go to next page */ |
153 | 2159 | MidoriView* view = midori_view_get_for_widget (focus); | ||
154 | 2160 | GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus)); | 2063 | GtkScrolledWindow* scrolled = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (focus)); |
155 | 2161 | GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled); | 2064 | GtkAdjustment* vadjust = gtk_scrolled_window_get_vadjustment (scrolled); |
156 | 2162 | if (gtk_adjustment_get_value (vadjust) | 2065 | if (gtk_adjustment_get_value (vadjust) |
157 | 2163 | == (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust))) | 2066 | == (gtk_adjustment_get_upper (vadjust) - gtk_adjustment_get_page_size (vadjust))) |
158 | 2164 | { | 2067 | { |
162 | 2165 | /* Duplicate here because the URI pointer might change */ | 2068 | GtkAction* next = _action_by_name (browser, "Next"); |
163 | 2166 | gchar* uri = g_strdup (midori_view_get_next_page (view)); | 2069 | if (gtk_action_get_sensitive (next)) |
161 | 2167 | if (uri != NULL) | ||
164 | 2168 | { | 2070 | { |
167 | 2169 | midori_view_set_uri (view, uri); | 2071 | gtk_action_activate (next); |
166 | 2170 | g_free (uri); | ||
168 | 2171 | return TRUE; | 2072 | return TRUE; |
169 | 2172 | } | 2073 | } |
170 | 2173 | } | 2074 | } |
171 | @@ -2441,7 +2342,6 @@ | |||
172 | 2441 | 2342 | ||
173 | 2442 | gtkwidget_class = GTK_WIDGET_CLASS (class); | 2343 | gtkwidget_class = GTK_WIDGET_CLASS (class); |
174 | 2443 | gtkwidget_class->key_press_event = midori_browser_key_press_event; | 2344 | gtkwidget_class->key_press_event = midori_browser_key_press_event; |
175 | 2444 | gtkwidget_class->key_release_event = midori_browser_key_release_event; | ||
176 | 2445 | 2345 | ||
177 | 2446 | gobject_class = G_OBJECT_CLASS (class); | 2346 | gobject_class = G_OBJECT_CLASS (class); |
178 | 2447 | gobject_class->dispose = midori_browser_dispose; | 2347 | gobject_class->dispose = midori_browser_dispose; |
179 | @@ -3515,37 +3415,6 @@ | |||
180 | 3515 | } | 3415 | } |
181 | 3516 | 3416 | ||
182 | 3517 | static void | 3417 | static void |
183 | 3518 | _action_reload_stop_activate (GtkAction* action, | ||
184 | 3519 | MidoriBrowser* browser) | ||
185 | 3520 | { | ||
186 | 3521 | GtkWidget* view = midori_browser_get_current_tab (browser); | ||
187 | 3522 | gchar* stock_id; | ||
188 | 3523 | g_object_get (action, "stock-id", &stock_id, NULL); | ||
189 | 3524 | |||
190 | 3525 | /* Refresh or stop, depending on the stock id */ | ||
191 | 3526 | if (!strcmp (stock_id, GTK_STOCK_REFRESH)) | ||
192 | 3527 | { | ||
193 | 3528 | GdkModifierType state = (GdkModifierType)0; | ||
194 | 3529 | gint x, y; | ||
195 | 3530 | GdkWindow* window; | ||
196 | 3531 | gboolean from_cache = TRUE; | ||
197 | 3532 | |||
198 | 3533 | if (!strcmp (gtk_action_get_name (action), "ReloadUncached")) | ||
199 | 3534 | from_cache = FALSE; | ||
200 | 3535 | else if ((window = gtk_widget_get_window (GTK_WIDGET (browser)))) | ||
201 | 3536 | { | ||
202 | 3537 | gdk_window_get_pointer (window, &x, &y, &state); | ||
203 | 3538 | if (state & GDK_SHIFT_MASK) | ||
204 | 3539 | from_cache = FALSE; | ||
205 | 3540 | } | ||
206 | 3541 | midori_view_reload (MIDORI_VIEW (view), from_cache); | ||
207 | 3542 | } | ||
208 | 3543 | else | ||
209 | 3544 | midori_tab_stop_loading (MIDORI_TAB (view)); | ||
210 | 3545 | g_free (stock_id); | ||
211 | 3546 | } | ||
212 | 3547 | |||
213 | 3548 | static void | ||
214 | 3549 | _action_zoom_activate (GtkAction* action, | 3418 | _action_zoom_activate (GtkAction* action, |
215 | 3550 | MidoriBrowser* browser) | 3419 | MidoriBrowser* browser) |
216 | 3551 | { | 3420 | { |
217 | @@ -3792,129 +3661,6 @@ | |||
218 | 3792 | g_free (stylesheet); | 3661 | g_free (stylesheet); |
219 | 3793 | } | 3662 | } |
220 | 3794 | 3663 | ||
221 | 3795 | static gboolean | ||
222 | 3796 | _action_navigation_activate (GtkAction* action, | ||
223 | 3797 | MidoriBrowser* browser) | ||
224 | 3798 | { | ||
225 | 3799 | MidoriView* view; | ||
226 | 3800 | GtkWidget* tab; | ||
227 | 3801 | gchar* uri; | ||
228 | 3802 | const gchar* name; | ||
229 | 3803 | gboolean middle_click; | ||
230 | 3804 | |||
231 | 3805 | g_assert (GTK_IS_ACTION (action)); | ||
232 | 3806 | |||
233 | 3807 | if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action), | ||
234 | 3808 | "midori-middle-click"))) | ||
235 | 3809 | { | ||
236 | 3810 | middle_click = TRUE; | ||
237 | 3811 | g_object_set_data (G_OBJECT (action), | ||
238 | 3812 | "midori-middle-click", | ||
239 | 3813 | GINT_TO_POINTER(0)); | ||
240 | 3814 | } | ||
241 | 3815 | else | ||
242 | 3816 | middle_click = FALSE; | ||
243 | 3817 | |||
244 | 3818 | tab = midori_browser_get_current_tab (browser); | ||
245 | 3819 | view = MIDORI_VIEW (tab); | ||
246 | 3820 | name = gtk_action_get_name (action); | ||
247 | 3821 | |||
248 | 3822 | if (!strcmp (name, "NextForward")) | ||
249 | 3823 | name = midori_tab_can_go_forward (MIDORI_TAB (view)) ? "Forward" : "Next"; | ||
250 | 3824 | |||
251 | 3825 | if (g_str_equal (name, "Back")) | ||
252 | 3826 | { | ||
253 | 3827 | if (middle_click) | ||
254 | 3828 | { | ||
255 | 3829 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); | ||
256 | 3830 | #ifdef HAVE_WEBKIT2 | ||
257 | 3831 | WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | ||
258 | 3832 | WebKitBackForwardListItem* item = webkit_back_forward_list_get_back_item (list); | ||
259 | 3833 | const gchar* back_uri = webkit_back_forward_list_item_get_uri (item); | ||
260 | 3834 | #else | ||
261 | 3835 | WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | ||
262 | 3836 | WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list); | ||
263 | 3837 | const gchar* back_uri = webkit_web_history_item_get_uri (item); | ||
264 | 3838 | #endif | ||
265 | 3839 | |||
266 | 3840 | GtkWidget* new_view = midori_browser_add_uri (browser, back_uri); | ||
267 | 3841 | midori_browser_set_current_tab_smartly (browser, new_view); | ||
268 | 3842 | } | ||
269 | 3843 | else | ||
270 | 3844 | midori_view_go_back (view); | ||
271 | 3845 | |||
272 | 3846 | return TRUE; | ||
273 | 3847 | } | ||
274 | 3848 | else if (g_str_equal (name, "Forward")) | ||
275 | 3849 | { | ||
276 | 3850 | if (middle_click) | ||
277 | 3851 | { | ||
278 | 3852 | WebKitWebView* web_view = WEBKIT_WEB_VIEW (midori_view_get_web_view (view)); | ||
279 | 3853 | #ifdef HAVE_WEBKIT2 | ||
280 | 3854 | WebKitBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | ||
281 | 3855 | WebKitBackForwardListItem* item = webkit_back_forward_list_get_forward_item (list); | ||
282 | 3856 | const gchar* forward_uri = webkit_back_forward_list_item_get_uri (item); | ||
283 | 3857 | #else | ||
284 | 3858 | WebKitWebBackForwardList* list = webkit_web_view_get_back_forward_list (web_view); | ||
285 | 3859 | WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_forward_item (list); | ||
286 | 3860 | const gchar* forward_uri = webkit_web_history_item_get_uri (item); | ||
287 | 3861 | #endif | ||
288 | 3862 | |||
289 | 3863 | GtkWidget* new_view = midori_browser_add_uri (browser, forward_uri); | ||
290 | 3864 | midori_browser_set_current_tab_smartly (browser, new_view); | ||
291 | 3865 | } | ||
292 | 3866 | else | ||
293 | 3867 | midori_tab_go_forward (MIDORI_TAB (view)); | ||
294 | 3868 | |||
295 | 3869 | return TRUE; | ||
296 | 3870 | } | ||
297 | 3871 | else if (g_str_equal (name, "Previous")) | ||
298 | 3872 | { | ||
299 | 3873 | /* Duplicate here because the URI pointer might change */ | ||
300 | 3874 | uri = g_strdup (midori_view_get_previous_page (view)); | ||
301 | 3875 | |||
302 | 3876 | if (middle_click) | ||
303 | 3877 | { | ||
304 | 3878 | GtkWidget* new_view = midori_browser_add_uri (browser, uri); | ||
305 | 3879 | midori_browser_set_current_tab_smartly (browser, new_view); | ||
306 | 3880 | } | ||
307 | 3881 | else | ||
308 | 3882 | midori_view_set_uri (view, uri); | ||
309 | 3883 | |||
310 | 3884 | g_free (uri); | ||
311 | 3885 | return TRUE; | ||
312 | 3886 | } | ||
313 | 3887 | else if (g_str_equal (name, "Next")) | ||
314 | 3888 | { | ||
315 | 3889 | /* Duplicate here because the URI pointer might change */ | ||
316 | 3890 | uri = g_strdup (midori_view_get_next_page (view)); | ||
317 | 3891 | |||
318 | 3892 | if (middle_click) | ||
319 | 3893 | { | ||
320 | 3894 | GtkWidget* new_view = midori_browser_add_uri (browser, uri); | ||
321 | 3895 | midori_browser_set_current_tab_smartly (browser, new_view); | ||
322 | 3896 | } | ||
323 | 3897 | else | ||
324 | 3898 | midori_view_set_uri (view, uri); | ||
325 | 3899 | |||
326 | 3900 | g_free (uri); | ||
327 | 3901 | return TRUE; | ||
328 | 3902 | } | ||
329 | 3903 | else if (g_str_equal (name, "Homepage")) | ||
330 | 3904 | { | ||
331 | 3905 | if (middle_click) | ||
332 | 3906 | { | ||
333 | 3907 | GtkWidget* new_view = midori_browser_add_uri (browser, "about:home"); | ||
334 | 3908 | midori_browser_set_current_tab_smartly (browser, new_view); | ||
335 | 3909 | } | ||
336 | 3910 | else | ||
337 | 3911 | midori_view_set_uri (view, "about:home"); | ||
338 | 3912 | |||
339 | 3913 | return TRUE; | ||
340 | 3914 | } | ||
341 | 3915 | return FALSE; | ||
342 | 3916 | } | ||
343 | 3917 | |||
344 | 3918 | static void | 3664 | static void |
345 | 3919 | _action_location_activate (GtkAction* action, | 3665 | _action_location_activate (GtkAction* action, |
346 | 3920 | MidoriBrowser* browser) | 3666 | MidoriBrowser* browser) |
347 | @@ -4352,17 +4098,6 @@ | |||
348 | 4352 | GtkAction* action, | 4098 | GtkAction* action, |
349 | 4353 | MidoriBrowser* browser) | 4099 | MidoriBrowser* browser) |
350 | 4354 | { | 4100 | { |
351 | 4355 | const gchar* name = gtk_action_get_name (action); | ||
352 | 4356 | gboolean back = !g_strcmp0 (name, "Back"); | ||
353 | 4357 | if (back | ||
354 | 4358 | || g_str_has_suffix (name, "Forward")) | ||
355 | 4359 | { | ||
356 | 4360 | midori_browser_toolbar_popup_context_menu_history ( | ||
357 | 4361 | browser, | ||
358 | 4362 | widget, | ||
359 | 4363 | back, 0, 0); | ||
360 | 4364 | return TRUE; | ||
361 | 4365 | } | ||
362 | 4366 | return midori_browser_toolbar_popup_context_menu_cb (widget, 0, 0, 0, browser); | 4101 | return midori_browser_toolbar_popup_context_menu_cb (widget, 0, 0, 0, browser); |
363 | 4367 | } | 4102 | } |
364 | 4368 | 4103 | ||
365 | @@ -4455,23 +4190,6 @@ | |||
366 | 4455 | return FALSE; | 4190 | return FALSE; |
367 | 4456 | } | 4191 | } |
368 | 4457 | 4192 | ||
369 | 4458 | static gboolean | ||
370 | 4459 | midori_browser_menu_item_middle_click_event_cb (GtkWidget* toolitem, | ||
371 | 4460 | GdkEventButton* event, | ||
372 | 4461 | MidoriBrowser* browser) | ||
373 | 4462 | { | ||
374 | 4463 | if (MIDORI_EVENT_NEW_TAB (event)) | ||
375 | 4464 | { | ||
376 | 4465 | GtkAction* action; | ||
377 | 4466 | |||
378 | 4467 | action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (toolitem)); | ||
379 | 4468 | g_object_set_data (G_OBJECT (action), "midori-middle-click", GINT_TO_POINTER (1)); | ||
380 | 4469 | |||
381 | 4470 | return _action_navigation_activate (action, browser); | ||
382 | 4471 | } | ||
383 | 4472 | return FALSE; | ||
384 | 4473 | } | ||
385 | 4474 | |||
386 | 4475 | static void | 4193 | static void |
387 | 4476 | _action_bookmark_add_activate (GtkAction* action, | 4194 | _action_bookmark_add_activate (GtkAction* action, |
388 | 4477 | MidoriBrowser* browser) | 4195 | MidoriBrowser* browser) |
389 | @@ -5305,18 +5023,6 @@ | |||
390 | 5305 | 5023 | ||
391 | 5306 | { "View", NULL, N_("_View") }, | 5024 | { "View", NULL, N_("_View") }, |
392 | 5307 | { "Toolbars", NULL, N_("_Toolbars") }, | 5025 | { "Toolbars", NULL, N_("_Toolbars") }, |
393 | 5308 | { "Reload", GTK_STOCK_REFRESH, | ||
394 | 5309 | NULL, "<Ctrl>r", | ||
395 | 5310 | N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) }, | ||
396 | 5311 | { "ReloadUncached", GTK_STOCK_REFRESH, | ||
397 | 5312 | N_("Reload page without caching"), "<Ctrl><Shift>r", | ||
398 | 5313 | NULL, G_CALLBACK (_action_reload_stop_activate) }, | ||
399 | 5314 | { "Stop", GTK_STOCK_STOP, | ||
400 | 5315 | NULL, "Escape", | ||
401 | 5316 | N_("Stop loading the current page"), G_CALLBACK (_action_reload_stop_activate) }, | ||
402 | 5317 | { "ReloadStop", GTK_STOCK_STOP, | ||
403 | 5318 | NULL, "", | ||
404 | 5319 | N_("Reload the current page"), G_CALLBACK (_action_reload_stop_activate) }, | ||
405 | 5320 | { "ZoomIn", GTK_STOCK_ZOOM_IN, | 5026 | { "ZoomIn", GTK_STOCK_ZOOM_IN, |
406 | 5321 | NULL, "<Ctrl>plus", | 5027 | NULL, "<Ctrl>plus", |
407 | 5322 | N_("Increase the zoom level"), G_CALLBACK (_action_zoom_activate) }, | 5028 | N_("Increase the zoom level"), G_CALLBACK (_action_zoom_activate) }, |
408 | @@ -5356,26 +5062,6 @@ | |||
409 | 5356 | NULL, G_CALLBACK (_action_readable_activate) }, | 5062 | NULL, G_CALLBACK (_action_readable_activate) }, |
410 | 5357 | 5063 | ||
411 | 5358 | { "Go", NULL, N_("_Go") }, | 5064 | { "Go", NULL, N_("_Go") }, |
412 | 5359 | { "Back", GTK_STOCK_GO_BACK, | ||
413 | 5360 | NULL, "<Alt>Left", | ||
414 | 5361 | N_("Go back to the previous page"), G_CALLBACK (_action_navigation_activate) }, | ||
415 | 5362 | { "Forward", GTK_STOCK_GO_FORWARD, | ||
416 | 5363 | NULL, "<Alt>Right", | ||
417 | 5364 | N_("Go forward to the next page"), G_CALLBACK (_action_navigation_activate) }, | ||
418 | 5365 | { "Previous", GTK_STOCK_MEDIA_PREVIOUS, | ||
419 | 5366 | NULL, "<Alt><Shift>Left", | ||
420 | 5367 | /* i18n: Visit the previous logical page, ie. in a forum or blog */ | ||
421 | 5368 | N_("Go to the previous sub-page"), G_CALLBACK (_action_navigation_activate) }, | ||
422 | 5369 | { "Next", GTK_STOCK_MEDIA_NEXT, | ||
423 | 5370 | NULL, "<Alt><Shift>Right", | ||
424 | 5371 | /* i18n: Visit the following logical page, ie. in a forum or blog */ | ||
425 | 5372 | N_("Go to the next sub-page"), G_CALLBACK (_action_navigation_activate) }, | ||
426 | 5373 | { "NextForward", GTK_STOCK_MEDIA_NEXT, | ||
427 | 5374 | N_("Next or Forward"), "", | ||
428 | 5375 | N_("Go to the next sub-page or next page in history"), G_CALLBACK (_action_navigation_activate) }, | ||
429 | 5376 | { "Homepage", GTK_STOCK_HOME, | ||
430 | 5377 | N_("_Homepage"), "<Alt>Home", | ||
431 | 5378 | N_("Go to your homepage"), G_CALLBACK (_action_navigation_activate) }, | ||
432 | 5379 | { "TrashEmpty", GTK_STOCK_CLEAR, | 5065 | { "TrashEmpty", GTK_STOCK_CLEAR, |
433 | 5380 | N_("Empty Trash"), "", | 5066 | N_("Empty Trash"), "", |
434 | 5381 | NULL, G_CALLBACK (_action_trash_empty_activate) }, | 5067 | NULL, G_CALLBACK (_action_trash_empty_activate) }, |
435 | @@ -5914,6 +5600,20 @@ | |||
436 | 5914 | return FALSE; | 5600 | return FALSE; |
437 | 5915 | } | 5601 | } |
438 | 5916 | 5602 | ||
439 | 5603 | static GtkAction* | ||
440 | 5604 | midori_browser_add_action (MidoriBrowser* browser, | ||
441 | 5605 | GType type, | ||
442 | 5606 | const gchar* accelerator) | ||
443 | 5607 | { | ||
444 | 5608 | GtkAction* action = g_object_new (type, NULL); | ||
445 | 5609 | g_return_val_if_fail (gtk_action_get_name (action) != NULL, action); | ||
446 | 5610 | gtk_action_group_add_action_with_accel (browser->action_group, action, accelerator); | ||
447 | 5611 | if (MIDORI_IS_NAVIGATION_ACTION (action)) | ||
448 | 5612 | g_object_bind_property (browser, "tab", action, "tab", 0); | ||
449 | 5613 | g_object_unref (action); | ||
450 | 5614 | return action; | ||
451 | 5615 | } | ||
452 | 5616 | |||
453 | 5917 | static void | 5617 | static void |
454 | 5918 | midori_browser_init (MidoriBrowser* browser) | 5618 | midori_browser_init (MidoriBrowser* browser) |
455 | 5919 | { | 5619 | { |
456 | @@ -5925,9 +5625,6 @@ | |||
457 | 5925 | GError* error; | 5625 | GError* error; |
458 | 5926 | GtkAction* action; | 5626 | GtkAction* action; |
459 | 5927 | GtkWidget* menuitem; | 5627 | GtkWidget* menuitem; |
460 | 5928 | GtkWidget* homepage; | ||
461 | 5929 | GtkWidget* back; | ||
462 | 5930 | GtkWidget* forward; | ||
463 | 5931 | GtkWidget* hpaned; | 5628 | GtkWidget* hpaned; |
464 | 5932 | GtkWidget* vpaned; | 5629 | GtkWidget* vpaned; |
465 | 5933 | GtkWidget* scrolled; | 5630 | GtkWidget* scrolled; |
466 | @@ -5995,6 +5692,17 @@ | |||
467 | 5995 | /* Hide the 'Dummy' which only holds otherwise unused actions */ | 5692 | /* Hide the 'Dummy' which only holds otherwise unused actions */ |
468 | 5996 | _action_set_visible (browser, "Dummy", FALSE); | 5693 | _action_set_visible (browser, "Dummy", FALSE); |
469 | 5997 | 5694 | ||
470 | 5695 | midori_browser_add_action (browser, MIDORI_TYPE_BACK_ACTION, "<Alt>Left"); | ||
471 | 5696 | midori_browser_add_action (browser, MIDORI_TYPE_PREVIOUS_ACTION, "<Alt><Shift>Left"); | ||
472 | 5697 | midori_browser_add_action (browser, MIDORI_TYPE_FORWARD_ACTION, "<Alt>Right"); | ||
473 | 5698 | midori_browser_add_action (browser, MIDORI_TYPE_NEXT_ACTION, "<Alt><Shift>Right"); | ||
474 | 5699 | midori_browser_add_action (browser, MIDORI_TYPE_NEXT_FORWARD_ACTION, ""); | ||
475 | 5700 | midori_browser_add_action (browser, MIDORI_TYPE_HOMEPAGE_ACTION, "<Alt>Home"); | ||
476 | 5701 | midori_browser_add_action (browser, MIDORI_TYPE_STOP_ACTION, "Escape"); | ||
477 | 5702 | midori_browser_add_action (browser, MIDORI_TYPE_RELOAD_ACTION, "<Ctrl>r"); | ||
478 | 5703 | midori_browser_add_action (browser, MIDORI_TYPE_RELOAD_UNCACHED_ACTION, "<Ctrl><Shift>r"); | ||
479 | 5704 | midori_browser_add_action (browser, MIDORI_TYPE_RELOAD_STOP_ACTION, ""); | ||
480 | 5705 | |||
481 | 5998 | action = g_object_new (KATZE_TYPE_SEPARATOR_ACTION, | 5706 | action = g_object_new (KATZE_TYPE_SEPARATOR_ACTION, |
482 | 5999 | "name", "Separator", | 5707 | "name", "Separator", |
483 | 6000 | "label", _("_Separator"), | 5708 | "label", _("_Separator"), |
484 | @@ -6049,11 +5757,7 @@ | |||
485 | 6049 | action, "<Ctrl>K"); | 5757 | action, "<Ctrl>K"); |
486 | 6050 | g_object_unref (action); | 5758 | g_object_unref (action); |
487 | 6051 | 5759 | ||
493 | 6052 | action = g_object_new (MIDORI_TYPE_PANED_ACTION, | 5760 | midori_browser_add_action (browser, MIDORI_TYPE_PANED_ACTION, ""); |
489 | 6053 | "name", "LocationSearch", | ||
490 | 6054 | NULL); | ||
491 | 6055 | gtk_action_group_add_action (browser->action_group, action); | ||
492 | 6056 | g_object_unref (action); | ||
494 | 6057 | 5761 | ||
495 | 6058 | action = g_object_new (KATZE_TYPE_ARRAY_ACTION, | 5762 | action = g_object_new (KATZE_TYPE_ARRAY_ACTION, |
496 | 6059 | "name", "Trash", | 5763 | "name", "Trash", |
497 | @@ -6178,22 +5882,6 @@ | |||
498 | 6178 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM ( | 5882 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM ( |
499 | 6179 | gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Location")), NULL); | 5883 | gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Location")), NULL); |
500 | 6180 | 5884 | ||
501 | 6181 | homepage = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Homepage"); | ||
502 | 6182 | g_signal_connect (homepage, "button-press-event", | ||
503 | 6183 | G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser); | ||
504 | 6184 | back = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Back"); | ||
505 | 6185 | g_signal_connect (back, "button-press-event", | ||
506 | 6186 | G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser); | ||
507 | 6187 | forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Forward"); | ||
508 | 6188 | g_signal_connect (forward, "button-press-event", | ||
509 | 6189 | G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser); | ||
510 | 6190 | forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Previous"); | ||
511 | 6191 | g_signal_connect (forward, "button-press-event", | ||
512 | 6192 | G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser); | ||
513 | 6193 | forward = gtk_ui_manager_get_widget (ui_manager, "/menubar/Go/Next"); | ||
514 | 6194 | g_signal_connect (forward, "button-press-event", | ||
515 | 6195 | G_CALLBACK (midori_browser_menu_item_middle_click_event_cb), browser); | ||
516 | 6196 | |||
517 | 6197 | _action_set_sensitive (browser, "EncodingCustom", FALSE); | 5885 | _action_set_sensitive (browser, "EncodingCustom", FALSE); |
518 | 6198 | _action_set_visible (browser, "LastSession", FALSE); | 5886 | _action_set_visible (browser, "LastSession", FALSE); |
519 | 6199 | 5887 | ||
520 | @@ -6376,81 +6064,6 @@ | |||
521 | 6376 | gtk_toolbar_style); | 6064 | gtk_toolbar_style); |
522 | 6377 | } | 6065 | } |
523 | 6378 | 6066 | ||
524 | 6379 | #ifndef HAVE_WEBKIT2 | ||
525 | 6380 | static void | ||
526 | 6381 | midori_browser_toolbar_popup_context_menu_history_cb (GtkMenuItem* menu_item, | ||
527 | 6382 | MidoriBrowser* browser) | ||
528 | 6383 | { | ||
529 | 6384 | gint steps = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "steps")); | ||
530 | 6385 | MidoriView* view = MIDORI_VIEW (midori_browser_get_current_tab (browser)); | ||
531 | 6386 | midori_view_go_back_or_forward (view, steps); | ||
532 | 6387 | } | ||
533 | 6388 | #endif | ||
534 | 6389 | |||
535 | 6390 | static void | ||
536 | 6391 | midori_browser_toolbar_popup_context_menu_history (MidoriBrowser* browser, | ||
537 | 6392 | GtkWidget* widget, | ||
538 | 6393 | gboolean back, | ||
539 | 6394 | gint x, | ||
540 | 6395 | gint y) | ||
541 | 6396 | { | ||
542 | 6397 | #ifndef HAVE_WEBKIT2 | ||
543 | 6398 | const gint step = back ? -1 : 1; | ||
544 | 6399 | gint steps = step; | ||
545 | 6400 | GtkWidget* menu; | ||
546 | 6401 | WebKitWebBackForwardList* list; | ||
547 | 6402 | WebKitWebHistoryItem* current_item; | ||
548 | 6403 | WebKitWebHistoryItem* history_item; | ||
549 | 6404 | WebKitWebHistoryItem* (*history_next)(WebKitWebBackForwardList*); | ||
550 | 6405 | void (*history_action)(WebKitWebBackForwardList*); | ||
551 | 6406 | |||
552 | 6407 | list = webkit_web_view_get_back_forward_list ( | ||
553 | 6408 | WEBKIT_WEB_VIEW (midori_view_get_web_view ( | ||
554 | 6409 | MIDORI_VIEW (midori_browser_get_current_tab (browser))))); | ||
555 | 6410 | |||
556 | 6411 | if (!list) | ||
557 | 6412 | return; | ||
558 | 6413 | |||
559 | 6414 | menu = gtk_menu_new (); | ||
560 | 6415 | |||
561 | 6416 | history_action = back ? | ||
562 | 6417 | webkit_web_back_forward_list_go_back : | ||
563 | 6418 | webkit_web_back_forward_list_go_forward; | ||
564 | 6419 | history_next = back ? | ||
565 | 6420 | webkit_web_back_forward_list_get_back_item : | ||
566 | 6421 | webkit_web_back_forward_list_get_forward_item; | ||
567 | 6422 | current_item = webkit_web_back_forward_list_get_current_item (list); | ||
568 | 6423 | |||
569 | 6424 | for (; (history_item = history_next (list)); history_action (list), steps += step) | ||
570 | 6425 | { | ||
571 | 6426 | const gchar* uri = webkit_web_history_item_get_uri (history_item); | ||
572 | 6427 | GtkWidget* menu_item = gtk_image_menu_item_new_with_label ( | ||
573 | 6428 | webkit_web_history_item_get_title (history_item)); | ||
574 | 6429 | GdkPixbuf* pixbuf; | ||
575 | 6430 | if ((pixbuf = midori_paths_get_icon (uri, widget))) | ||
576 | 6431 | { | ||
577 | 6432 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), | ||
578 | 6433 | gtk_image_new_from_pixbuf (pixbuf)); | ||
579 | 6434 | g_object_unref (pixbuf); | ||
580 | 6435 | } | ||
581 | 6436 | g_object_set_data (G_OBJECT (menu_item), "uri", (gpointer)uri); | ||
582 | 6437 | g_object_set_data (G_OBJECT (menu_item), "steps", GINT_TO_POINTER (steps)); | ||
583 | 6438 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); | ||
584 | 6439 | g_signal_connect (G_OBJECT (menu_item), "activate", | ||
585 | 6440 | G_CALLBACK (midori_browser_toolbar_popup_context_menu_history_cb), | ||
586 | 6441 | browser); | ||
587 | 6442 | if (steps == (10 - 1)) | ||
588 | 6443 | break; | ||
589 | 6444 | } | ||
590 | 6445 | |||
591 | 6446 | webkit_web_back_forward_list_go_to_item (list, current_item); | ||
592 | 6447 | gtk_widget_show_all (menu); | ||
593 | 6448 | |||
594 | 6449 | katze_widget_popup (widget, GTK_MENU (menu), NULL, | ||
595 | 6450 | KATZE_MENU_POSITION_LEFT); | ||
596 | 6451 | #endif | ||
597 | 6452 | } | ||
598 | 6453 | |||
599 | 6454 | static void | 6067 | static void |
600 | 6455 | _midori_browser_update_settings (MidoriBrowser* browser) | 6068 | _midori_browser_update_settings (MidoriBrowser* browser) |
601 | 6456 | { | 6069 | { |
602 | 6457 | 6070 | ||
603 | === added file 'midori/midori-navigationaction.vala' | |||
604 | --- midori/midori-navigationaction.vala 1970-01-01 00:00:00 +0000 | |||
605 | +++ midori/midori-navigationaction.vala 2015-06-07 21:30:55 +0000 | |||
606 | @@ -0,0 +1,293 @@ | |||
607 | 1 | /* | ||
608 | 2 | Copyright (C) 2015 Christian Dywan <christian@twotoasts.de> | ||
609 | 3 | |||
610 | 4 | This library is free software; you can redistribute it and/or | ||
611 | 5 | modify it under the terms of the GNU Lesser General Public | ||
612 | 6 | License as published by the Free Software Foundation; either | ||
613 | 7 | version 2.1 of the License, or (at your option) any later version. | ||
614 | 8 | |||
615 | 9 | See the file COPYING for the full license text. | ||
616 | 10 | */ | ||
617 | 11 | |||
618 | 12 | namespace Midori { | ||
619 | 13 | /* Back or forward action, with a submenu | ||
620 | 14 | Since: 0.6.0 */ | ||
621 | 15 | protected abstract class NavigationAction : Gtk.Action { | ||
622 | 16 | protected string uri { get; set; } | ||
623 | 17 | protected double progress { get; set; } | ||
624 | 18 | |||
625 | 19 | public Midori.Tab? tab { get; set; } | ||
626 | 20 | public signal string? middle_click_uri (); | ||
627 | 21 | public signal Gtk.Menu? context_menu (); | ||
628 | 22 | |||
629 | 23 | Gtk.ToolButton? toolitem; | ||
630 | 24 | public override unowned Gtk.Widget create_tool_item () { | ||
631 | 25 | toolitem = new Gtk.ToolButton (null, null); | ||
632 | 26 | toolitem.icon_widget = create_icon (Gtk.IconSize.LARGE_TOOLBAR); | ||
633 | 27 | bind_property ("label", toolitem, "label"); | ||
634 | 28 | bind_property ("tooltip", toolitem, "tooltip-text"); | ||
635 | 29 | bind_property ("is-important", toolitem, "is-important"); | ||
636 | 30 | // Connect to child because ToolItem blocks button-press-event | ||
637 | 31 | toolitem.get_child ().button_press_event.connect ((event) => { | ||
638 | 32 | // Ctrl+click or middle click | ||
639 | 33 | string? uri = event.button == 2 | ||
640 | 34 | || (event.button == 1 && (bool)(event.state & Gdk.ModifierType.CONTROL_MASK)) | ||
641 | 35 | ? middle_click_uri () : null; | ||
642 | 36 | if (uri != null) { | ||
643 | 37 | Midori.Settings? settings = null; | ||
644 | 38 | /* Midori.View.settings */ | ||
645 | 39 | tab.get ("settings", ref settings); | ||
646 | 40 | GLib.Signal.emit_by_name (tab, "new-tab", uri, settings.open_tabs_in_the_background); | ||
647 | 41 | return true; | ||
648 | 42 | } | ||
649 | 43 | Gtk.Menu? menu = event.button == 3 ? context_menu () : null; | ||
650 | 44 | if (menu != null) { | ||
651 | 45 | menu.show (); | ||
652 | 46 | menu.attach_to_widget (toolitem, null); | ||
653 | 47 | menu.popup (null, null, null, 1, Gtk.get_current_event_time ()); | ||
654 | 48 | return true; | ||
655 | 49 | } | ||
656 | 50 | return false; | ||
657 | 51 | }); | ||
658 | 52 | return toolitem; | ||
659 | 53 | } | ||
660 | 54 | |||
661 | 55 | construct { | ||
662 | 56 | notify["tab"].connect (tab_changed); | ||
663 | 57 | } | ||
664 | 58 | |||
665 | 59 | void tab_changed (ParamSpec pspec) { | ||
666 | 60 | tab.bind_property ("uri", this, "uri", 0); | ||
667 | 61 | tab.bind_property ("progress", this, "progress", 0); | ||
668 | 62 | } | ||
669 | 63 | |||
670 | 64 | string? related_page (string rel, string local) { | ||
671 | 65 | #if HAVE_WEBKIT2 | ||
672 | 66 | return null; | ||
673 | 67 | #else | ||
674 | 68 | return null; | ||
675 | 69 | #endif | ||
676 | 70 | } | ||
677 | 71 | |||
678 | 72 | string next_page () { | ||
679 | 73 | /* i18n: word stem of "next page" type links, case is not important */ | ||
680 | 74 | return related_page ("next", _("next")); | ||
681 | 75 | } | ||
682 | 76 | |||
683 | 77 | string previous_page () { | ||
684 | 78 | /* i18n: word stem of "previous page" type links, case is not important */ | ||
685 | 79 | return related_page ("prev", _("previous")); | ||
686 | 80 | } | ||
687 | 81 | |||
688 | 82 | protected bool can_go_next () { | ||
689 | 83 | return next_page () != null; | ||
690 | 84 | } | ||
691 | 85 | |||
692 | 86 | protected void go_next () { | ||
693 | 87 | tab.web_view.load_uri (next_page ()); | ||
694 | 88 | } | ||
695 | 89 | |||
696 | 90 | protected void go_next_or_forward () { | ||
697 | 91 | if (tab.web_view.can_go_forward ()) | ||
698 | 92 | tab.web_view.go_forward (); | ||
699 | 93 | else | ||
700 | 94 | go_next (); | ||
701 | 95 | } | ||
702 | 96 | |||
703 | 97 | protected bool can_go_previous () { | ||
704 | 98 | return previous_page () != null; | ||
705 | 99 | } | ||
706 | 100 | |||
707 | 101 | protected void go_previous () { | ||
708 | 102 | tab.web_view.load_uri (previous_page ()); | ||
709 | 103 | } | ||
710 | 104 | |||
711 | 105 | GLib.Icon? scale_if_needed (GLib.Icon? icon) { | ||
712 | 106 | if (icon is Gdk.Pixbuf) { | ||
713 | 107 | var pixbuf = icon as Gdk.Pixbuf; | ||
714 | 108 | int icon_width = 16, icon_height = 16; | ||
715 | 109 | Gtk.icon_size_lookup (Gtk.IconSize.MENU, out icon_width, out icon_height); | ||
716 | 110 | if (pixbuf.width > icon_width || pixbuf.height > icon_height) | ||
717 | 111 | return pixbuf.scale_simple (icon_width, icon_height, Gdk.InterpType.BILINEAR); | ||
718 | 112 | } | ||
719 | 113 | return icon; | ||
720 | 114 | } | ||
721 | 115 | |||
722 | 116 | #if HAVE_WEBKIT2 | ||
723 | 117 | protected Gtk.Menu? build_menu (List<weak WebKit.BackForwardListItem> items) { | ||
724 | 118 | #else | ||
725 | 119 | protected Gtk.Menu? build_menu (List<weak WebKit.WebHistoryItem> items) { | ||
726 | 120 | #endif | ||
727 | 121 | var menu = new Gtk.Menu (); | ||
728 | 122 | foreach (var item in items) { | ||
729 | 123 | var menuitem = new Gtk.ImageMenuItem.with_label (item.get_title ()); | ||
730 | 124 | var icon = new Midori.URI.Icon (item.get_uri ()); | ||
731 | 125 | menuitem.image = new Gtk.Image.from_gicon (scale_if_needed (icon), Gtk.IconSize.MENU); | ||
732 | 126 | menuitem.always_show_image = true; | ||
733 | 127 | menuitem.show_all (); | ||
734 | 128 | menuitem.activate.connect (() =>{ tab.web_view.load_uri (item.get_uri ()); }); | ||
735 | 129 | menu.append (menuitem); | ||
736 | 130 | } | ||
737 | 131 | return menu; | ||
738 | 132 | } | ||
739 | 133 | } | ||
740 | 134 | |||
741 | 135 | public class BackAction : NavigationAction { | ||
742 | 136 | construct { | ||
743 | 137 | set ("name", "Back", | ||
744 | 138 | "tooltip", _("Go back to the previous page"), | ||
745 | 139 | "stock-id", Gtk.Stock.GO_BACK, | ||
746 | 140 | "is-important", true); | ||
747 | 141 | |||
748 | 142 | bind_property ("uri", this, "sensitive", 0, | ||
749 | 143 | (binding, source, ref target) => { target = tab.web_view.can_go_back (); return true; }); | ||
750 | 144 | activate.connect (() => { tab.web_view.go_back (); }); | ||
751 | 145 | middle_click_uri.connect (() => { return tab.web_view.get_back_forward_list ().get_back_item ().get_uri (); }); | ||
752 | 146 | context_menu.connect (() => { return build_menu (tab.web_view.get_back_forward_list ().get_back_list_with_limit (10)); }); | ||
753 | 147 | } | ||
754 | 148 | } | ||
755 | 149 | |||
756 | 150 | public class PreviousAction : NavigationAction { | ||
757 | 151 | construct { | ||
758 | 152 | set ("name", "Previous", | ||
759 | 153 | /* i18n: Visit the previous logical page, ie. in a forum or blog */ | ||
760 | 154 | "tooltip", _("Go to the previous sub-page"), | ||
761 | 155 | "stock-id", Gtk.Stock.MEDIA_PREVIOUS); | ||
762 | 156 | |||
763 | 157 | bind_property ("uri", this, "sensitive", 0, | ||
764 | 158 | (binding, source, ref target) => { target = can_go_previous (); return true; }); | ||
765 | 159 | activate.connect (() => { go_previous (); }); | ||
766 | 160 | context_menu.connect (() => { return build_menu (tab.web_view.get_back_forward_list ().get_back_list_with_limit (10)); }); | ||
767 | 161 | } | ||
768 | 162 | } | ||
769 | 163 | |||
770 | 164 | public class ForwardAction : NavigationAction { | ||
771 | 165 | construct { | ||
772 | 166 | set ("name", "Forward", | ||
773 | 167 | "tooltip", _("Go forward to the next page"), | ||
774 | 168 | "stock-id", Gtk.Stock.GO_FORWARD); | ||
775 | 169 | |||
776 | 170 | bind_property ("uri", this, "sensitive", 0, | ||
777 | 171 | (binding, source, ref target) => { target = tab.web_view.can_go_forward (); return true; }); | ||
778 | 172 | activate.connect (() => { tab.web_view.go_forward (); }); | ||
779 | 173 | middle_click_uri.connect (() => { return tab.web_view.get_back_forward_list ().get_forward_item ().get_uri (); }); | ||
780 | 174 | context_menu.connect (() => { return build_menu (tab.web_view.get_back_forward_list ().get_forward_list_with_limit (10)); }); | ||
781 | 175 | } | ||
782 | 176 | } | ||
783 | 177 | |||
784 | 178 | public class NextAction : NavigationAction { | ||
785 | 179 | construct { | ||
786 | 180 | set ("name", "Next", | ||
787 | 181 | /* i18n: Visit the following logical page, ie. in a forum or blog */ | ||
788 | 182 | "tooltip", _("Go to the next sub-page"), | ||
789 | 183 | "stock-id", Gtk.Stock.MEDIA_NEXT); | ||
790 | 184 | |||
791 | 185 | bind_property ("uri", this, "sensitive", 0, | ||
792 | 186 | (binding, source, ref target) => { target = can_go_next (); return true; }); | ||
793 | 187 | activate.connect (() => { go_next (); }); | ||
794 | 188 | context_menu.connect (() => { return build_menu (tab.web_view.get_back_forward_list ().get_forward_list_with_limit (10)); }); | ||
795 | 189 | } | ||
796 | 190 | } | ||
797 | 191 | |||
798 | 192 | public class NextForwardAction : NavigationAction { | ||
799 | 193 | construct { | ||
800 | 194 | set ("name", "NextForward", | ||
801 | 195 | "label", _("Next or Forward")); | ||
802 | 196 | |||
803 | 197 | bind_property ("uri", this, "sensitive", 0, | ||
804 | 198 | (binding, source, ref target) => { | ||
805 | 199 | target = (tab.web_view.can_go_forward () || can_go_next ()); | ||
806 | 200 | stock_id = (can_go_next () ? Gtk.Stock.GO_FORWARD : Gtk.Stock.MEDIA_NEXT); | ||
807 | 201 | tooltip = (can_go_next () ? _("Go forward to the next page") : _("Go to the next sub-page")); | ||
808 | 202 | return true; | ||
809 | 203 | }); | ||
810 | 204 | activate.connect (() => { go_next_or_forward (); }); | ||
811 | 205 | context_menu.connect (() => { return build_menu (tab.web_view.get_back_forward_list ().get_forward_list_with_limit (10)); }); | ||
812 | 206 | } | ||
813 | 207 | } | ||
814 | 208 | |||
815 | 209 | public class HomepageAction : NavigationAction { | ||
816 | 210 | construct { | ||
817 | 211 | set ("name", "Homepage", | ||
818 | 212 | "label", _("_Homepage"), | ||
819 | 213 | "tooltip", _("Go to your homepage"), | ||
820 | 214 | "stock-id", Gtk.Stock.HOME); | ||
821 | 215 | |||
822 | 216 | activate.connect (() => { tab.web_view.load_uri ("about:home"); }); | ||
823 | 217 | middle_click_uri.connect (() => { return "about:home"; }); | ||
824 | 218 | } | ||
825 | 219 | } | ||
826 | 220 | |||
827 | 221 | public class StopAction : NavigationAction { | ||
828 | 222 | construct { | ||
829 | 223 | set ("name", "Stop", | ||
830 | 224 | "tooltip",_("Stop loading the current page"), | ||
831 | 225 | "stock-id", Gtk.Stock.STOP); | ||
832 | 226 | |||
833 | 227 | bind_property ("progress", this, "sensitive", 0, | ||
834 | 228 | (binding, source, ref target) =>{ | ||
835 | 229 | target = progress > 0.0; | ||
836 | 230 | return true; | ||
837 | 231 | }); | ||
838 | 232 | activate.connect (() => { tab.web_view.stop_loading (); }); | ||
839 | 233 | } | ||
840 | 234 | } | ||
841 | 235 | |||
842 | 236 | public class ReloadAction : NavigationAction { | ||
843 | 237 | construct { | ||
844 | 238 | set ("name", "Reload", | ||
845 | 239 | "tooltip", _("Reload the current page"), | ||
846 | 240 | "stock-id", Gtk.Stock.REFRESH); | ||
847 | 241 | |||
848 | 242 | bind_property ("progress", this, "sensitive", 0, | ||
849 | 243 | (binding, source, ref target) =>{ | ||
850 | 244 | target = progress == 0.0; | ||
851 | 245 | return true; | ||
852 | 246 | }); | ||
853 | 247 | activate.connect (() => { tab.web_view.reload (); }); | ||
854 | 248 | middle_click_uri.connect (() => { return tab.uri; }); | ||
855 | 249 | } | ||
856 | 250 | } | ||
857 | 251 | |||
858 | 252 | public class ReloadUncachedAction : NavigationAction { | ||
859 | 253 | construct { | ||
860 | 254 | set ("name", "ReloadUncached", | ||
861 | 255 | "tooltip", _("Reload page without caching"), | ||
862 | 256 | "stock-id", Gtk.Stock.REFRESH); | ||
863 | 257 | |||
864 | 258 | bind_property ("progress", this, "sensitive", 0, | ||
865 | 259 | (binding, source, ref target) =>{ | ||
866 | 260 | target = progress == 0.0; | ||
867 | 261 | return true; | ||
868 | 262 | }); | ||
869 | 263 | activate.connect (() => { tab.web_view.reload_bypass_cache (); }); | ||
870 | 264 | middle_click_uri.connect (() => { return tab.uri; }); | ||
871 | 265 | } | ||
872 | 266 | } | ||
873 | 267 | |||
874 | 268 | public class ReloadStopAction : NavigationAction { | ||
875 | 269 | construct { | ||
876 | 270 | set ("name", "ReloadStop"); | ||
877 | 271 | |||
878 | 272 | bind_property ("progress", this, "stock-id", 0, | ||
879 | 273 | (binding, source, ref target) => { | ||
880 | 274 | target = progress > 0.0 ? Gtk.Stock.STOP : Gtk.Stock.REFRESH; | ||
881 | 275 | tooltip = progress > 0.0 ? _("Stop loading the current page") : _("Reload the current page"); | ||
882 | 276 | return true; | ||
883 | 277 | }); | ||
884 | 278 | activate.connect (() => { | ||
885 | 279 | if (progress > 0.0) | ||
886 | 280 | tab.web_view.stop_loading (); | ||
887 | 281 | else { | ||
888 | 282 | int x, y, state; | ||
889 | 283 | tab.get_window ().get_pointer (out x, out y, out state); | ||
890 | 284 | if ((bool)(state & Gdk.ModifierType.SHIFT_MASK)) | ||
891 | 285 | tab.web_view.reload_bypass_cache (); | ||
892 | 286 | else | ||
893 | 287 | tab.web_view.reload (); | ||
894 | 288 | } | ||
895 | 289 | }); | ||
896 | 290 | middle_click_uri.connect (() => { return tab.uri; }); | ||
897 | 291 | } | ||
898 | 292 | } | ||
899 | 293 | } | ||
900 | 0 | 294 | ||
901 | === modified file 'midori/midori-view.c' | |||
902 | --- midori/midori-view.c 2015-03-23 11:33:24 +0000 | |||
903 | +++ midori/midori-view.c 2015-06-07 21:30:55 +0000 | |||
904 | @@ -4638,6 +4638,7 @@ | |||
905 | 4638 | * Goes back or forward in history. | 4638 | * Goes back or forward in history. |
906 | 4639 | * | 4639 | * |
907 | 4640 | * Since: 0.4.5 | 4640 | * Since: 0.4.5 |
908 | 4641 | * Deprecated: 0.6.0 | ||
909 | 4641 | **/ | 4642 | **/ |
910 | 4642 | void | 4643 | void |
911 | 4643 | midori_view_go_back_or_forward (MidoriView* view, | 4644 | midori_view_go_back_or_forward (MidoriView* view, |
912 | @@ -4722,6 +4723,7 @@ | |||
913 | 4722 | * Return value: an URI, or %NULL | 4723 | * Return value: an URI, or %NULL |
914 | 4723 | * | 4724 | * |
915 | 4724 | * Since: 0.2.3 | 4725 | * Since: 0.2.3 |
916 | 4726 | * Deprecated: 0.6.0 | ||
917 | 4725 | **/ | 4727 | **/ |
918 | 4726 | const gchar* | 4728 | const gchar* |
919 | 4727 | midori_view_get_previous_page (MidoriView* view) | 4729 | midori_view_get_previous_page (MidoriView* view) |
920 | @@ -4741,6 +4743,7 @@ | |||
921 | 4741 | * Return value: an URI, or %NULL | 4743 | * Return value: an URI, or %NULL |
922 | 4742 | * | 4744 | * |
923 | 4743 | * Since: 0.2.3 | 4745 | * Since: 0.2.3 |
924 | 4746 | * Deprecated: 0.6.0 | ||
925 | 4744 | **/ | 4747 | **/ |
926 | 4745 | const gchar* | 4748 | const gchar* |
927 | 4746 | midori_view_get_next_page (MidoriView* view) | 4749 | midori_view_get_next_page (MidoriView* view) |
928 | 4747 | 4750 | ||
929 | === modified file 'midori/midori-window.vala' | |||
930 | --- midori/midori-window.vala 2015-06-06 12:20:44 +0000 | |||
931 | +++ midori/midori-window.vala 2015-06-07 21:30:55 +0000 | |||
932 | @@ -85,9 +85,6 @@ | |||
933 | 85 | 85 | ||
934 | 86 | Gtk.ToolItem create_tool_item (Gtk.Action action) { | 86 | Gtk.ToolItem create_tool_item (Gtk.Action action) { |
935 | 87 | var toolitem = action.create_tool_item () as Gtk.ToolItem; | 87 | var toolitem = action.create_tool_item () as Gtk.ToolItem; |
936 | 88 | /* Show label if button has no icon of any kind */ | ||
937 | 89 | if (action.icon_name == null && action.stock_id == null && action.gicon == null) | ||
938 | 90 | toolitem.is_important = true; | ||
939 | 91 | toolitem.get_child ().button_press_event.connect ((event) => { | 88 | toolitem.get_child ().button_press_event.connect ((event) => { |
940 | 92 | return event.button == 3 && context_menu (toolitem, action); }); | 89 | return event.button == 3 && context_menu (toolitem, action); }); |
941 | 93 | if (name == "CompactMenu") | 90 | if (name == "CompactMenu") |
942 | 94 | 91 | ||
943 | === modified file 'po/POTFILES.in' | |||
944 | --- po/POTFILES.in 2015-05-24 00:19:21 +0000 | |||
945 | +++ po/POTFILES.in 2015-06-07 21:30:55 +0000 | |||
946 | @@ -11,6 +11,7 @@ | |||
947 | 11 | midori/midori-database.vala | 11 | midori/midori-database.vala |
948 | 12 | midori/midori-extension.c | 12 | midori/midori-extension.c |
949 | 13 | midori/midori-locationaction.c | 13 | midori/midori-locationaction.c |
950 | 14 | midori/midori-navigationaction.vala | ||
951 | 14 | midori/midori-panel.c | 15 | midori/midori-panel.c |
952 | 15 | midori/midori-settings.vala | 16 | midori/midori-settings.vala |
953 | 16 | midori/midori-websettings.c | 17 | midori/midori-websettings.c |
Gtk.Stock is deprecated. Relevant icon names are "go-next", "go-previous", "go-home", "media- skip-forward" , "media- skip-backward" , "view-refresh"