Merge lp:~aauzi/midori/fix-1184716 into lp:midori
- fix-1184716
- Merge into trunk
Proposed by
André Auzi
Status: | Superseded |
---|---|
Proposed branch: | lp:~aauzi/midori/fix-1184716 |
Merge into: | lp:midori |
Diff against target: |
619 lines (+276/-126) 3 files modified
katze/katze-arrayaction.c (+228/-77) midori/marshal.list (+1/-0) midori/midori-browser.c (+47/-49) |
To merge this branch: | bzr merge lp:~aauzi/midori/fix-1184716 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Midori Devs | Pending | ||
Review via email: mp+166146@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-09-28.
Commit message
Description of the change
(For review: doesn't depend on other branches)
To post a comment you must log in.
lp:~aauzi/midori/fix-1184716
updated
- 6178. By André Auzi
-
merge lp:midori
- 6179. By André Auzi
-
merge lp:midori
- 6180. By André Auzi
-
fix most anoying weird menu behaviors when activating the context popup
- 6181. By André Auzi
-
merge lp:midori
- 6182. By André Auzi
-
merge lp:midori
- 6183. By André Auzi
-
merge lp:midori
- 6184. By André Auzi
-
merge lp:midori and build with Gtk3
- 6185. By André Auzi
-
simplify things by an straight forward evolution of activate-item-alt
- 6186. By André Auzi
-
select correct marshalling and update comment
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'katze/katze-arrayaction.c' | |||
2 | --- katze/katze-arrayaction.c 2012-12-16 18:40:00 +0000 | |||
3 | +++ katze/katze-arrayaction.c 2013-09-28 15:27:18 +0000 | |||
4 | @@ -52,6 +52,7 @@ | |||
5 | 52 | POPULATE_FOLDER, | 52 | POPULATE_FOLDER, |
6 | 53 | ACTIVATE_ITEM, | 53 | ACTIVATE_ITEM, |
7 | 54 | ACTIVATE_ITEM_ALT, | 54 | ACTIVATE_ITEM_ALT, |
8 | 55 | ACTIVATE_ITEM_FULL, | ||
9 | 55 | LAST_SIGNAL | 56 | LAST_SIGNAL |
10 | 56 | }; | 57 | }; |
11 | 57 | 58 | ||
12 | @@ -167,7 +168,7 @@ | |||
13 | 167 | * Return value: %TRUE if the event was handled. If %FALSE is returned, | 168 | * Return value: %TRUE if the event was handled. If %FALSE is returned, |
14 | 168 | * the default "activate-item" signal is emitted. | 169 | * the default "activate-item" signal is emitted. |
15 | 169 | * | 170 | * |
17 | 170 | * Since: 0.1.7 | 171 | * Deprecated: 0.5.2: Use "activate-item-full" instead. |
18 | 171 | **/ | 172 | **/ |
19 | 172 | signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt", | 173 | signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt", |
20 | 173 | G_TYPE_FROM_CLASS (class), | 174 | G_TYPE_FROM_CLASS (class), |
21 | @@ -179,6 +180,34 @@ | |||
22 | 179 | G_TYPE_BOOLEAN, 2, | 180 | G_TYPE_BOOLEAN, 2, |
23 | 180 | KATZE_TYPE_ITEM, G_TYPE_UINT); | 181 | KATZE_TYPE_ITEM, G_TYPE_UINT); |
24 | 181 | 182 | ||
25 | 183 | /** | ||
26 | 184 | * KatzeArrayAction::activate-item-full: | ||
27 | 185 | * @array: the object on which the signal is emitted | ||
28 | 186 | * @item: the item being activated | ||
29 | 187 | * @event: the %GdkButtonEvent pressed | ||
30 | 188 | * @proxy: the %GtkWidget that caught the event | ||
31 | 189 | * | ||
32 | 190 | * An item was clicked, with the specified @button. | ||
33 | 191 | * | ||
34 | 192 | * Return value: %TRUE if the event was handled. If %FALSE is returned, | ||
35 | 193 | * the default "activate-item-alt" signal is emitted. If | ||
36 | 194 | * "activate-item-alt" is not handled on its turn, the | ||
37 | 195 | * "activate-item" signal is finally emitted. | ||
38 | 196 | * | ||
39 | 197 | * Since: 0.5.2 | ||
40 | 198 | **/ | ||
41 | 199 | signals[ACTIVATE_ITEM_FULL] = g_signal_new ("activate-item-full", | ||
42 | 200 | G_TYPE_FROM_CLASS (class), | ||
43 | 201 | (GSignalFlags) (G_SIGNAL_RUN_LAST), | ||
44 | 202 | 0, | ||
45 | 203 | 0, | ||
46 | 204 | NULL, | ||
47 | 205 | midori_cclosure_marshal_BOOLEAN__OBJECT_POINTER_OBJECT, | ||
48 | 206 | G_TYPE_BOOLEAN, 3, | ||
49 | 207 | KATZE_TYPE_ITEM, | ||
50 | 208 | GDK_TYPE_EVENT, | ||
51 | 209 | GTK_TYPE_WIDGET); | ||
52 | 210 | |||
53 | 182 | gobject_class = G_OBJECT_CLASS (class); | 211 | gobject_class = G_OBJECT_CLASS (class); |
54 | 183 | gobject_class->finalize = katze_array_action_finalize; | 212 | gobject_class->finalize = katze_array_action_finalize; |
55 | 184 | gobject_class->set_property = katze_array_action_set_property; | 213 | gobject_class->set_property = katze_array_action_set_property; |
56 | @@ -285,16 +314,76 @@ | |||
57 | 285 | GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action); | 314 | GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action); |
58 | 286 | } | 315 | } |
59 | 287 | 316 | ||
61 | 288 | static void | 317 | static gboolean |
62 | 289 | katze_array_action_activate_item (KatzeArrayAction* action, | 318 | katze_array_action_activate_item (KatzeArrayAction* action, |
63 | 290 | KatzeItem* item, | 319 | KatzeItem* item, |
65 | 291 | gint button) | 320 | GdkEventButton* event, |
66 | 321 | GtkWidget* proxy) | ||
67 | 292 | { | 322 | { |
68 | 323 | /* katze_array_action_activate_item emits the signal. | ||
69 | 324 | * It can result from "clicked" event where the button event | ||
70 | 325 | * is not provided. | ||
71 | 326 | * We need to check if the current event is usable. | ||
72 | 327 | * If it's not we just synthetize a usable button event. | ||
73 | 328 | */ | ||
74 | 329 | |||
75 | 330 | gboolean free_event = FALSE; | ||
76 | 293 | gboolean handled = FALSE; | 331 | gboolean handled = FALSE; |
79 | 294 | g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item, | 332 | |
80 | 295 | button, &handled); | 333 | if (!event) |
81 | 334 | { | ||
82 | 335 | event = (GdkEventButton*)gtk_get_current_event (); | ||
83 | 336 | if (event->type != GDK_BUTTON_PRESS) | ||
84 | 337 | { | ||
85 | 338 | gdk_event_free ((GdkEvent*)event); | ||
86 | 339 | event = NULL; | ||
87 | 340 | } | ||
88 | 341 | else | ||
89 | 342 | free_event = TRUE; | ||
90 | 343 | } | ||
91 | 344 | |||
92 | 345 | if (!event) | ||
93 | 346 | { /* Simulate a button 1 press event */ | ||
94 | 347 | gint x; | ||
95 | 348 | gint y; | ||
96 | 349 | gint x_root; | ||
97 | 350 | gint y_root; | ||
98 | 351 | |||
99 | 352 | free_event = TRUE; | ||
100 | 353 | event = (GdkEventButton*)gdk_event_new (GDK_BUTTON_PRESS); | ||
101 | 354 | event->type = GDK_BUTTON_PRESS; | ||
102 | 355 | event->window = proxy->window; | ||
103 | 356 | event->send_event = FALSE; | ||
104 | 357 | event->time = gtk_get_current_event_time(); | ||
105 | 358 | gdk_window_get_pointer (proxy->window, | ||
106 | 359 | &x, &y, | ||
107 | 360 | NULL); | ||
108 | 361 | event->x = x; | ||
109 | 362 | event->y = y; | ||
110 | 363 | gtk_get_current_event_state (&event->state); | ||
111 | 364 | |||
112 | 365 | event->button = 1; | ||
113 | 366 | event->device = NULL; /* FIXME: find the mouse device */ | ||
114 | 367 | gdk_window_get_root_coords (proxy->window, | ||
115 | 368 | x, y, | ||
116 | 369 | &x_root, | ||
117 | 370 | &y_root); | ||
118 | 371 | event->x_root = x_root; | ||
119 | 372 | event->y_root = y_root; | ||
120 | 373 | } | ||
121 | 374 | |||
122 | 375 | g_signal_emit (action, signals[ACTIVATE_ITEM_FULL], 0, item, | ||
123 | 376 | event, proxy, &handled); | ||
124 | 377 | if (!handled) | ||
125 | 378 | g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item, | ||
126 | 379 | event->button, &handled); | ||
127 | 296 | if (!handled) | 380 | if (!handled) |
128 | 297 | g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item); | 381 | g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item); |
129 | 382 | |||
130 | 383 | if (free_event) | ||
131 | 384 | gdk_event_free ((GdkEvent*)event); | ||
132 | 385 | |||
133 | 386 | return handled; | ||
134 | 298 | } | 387 | } |
135 | 299 | 388 | ||
136 | 300 | static void | 389 | static void |
137 | @@ -302,7 +391,46 @@ | |||
138 | 302 | KatzeArrayAction* array_action) | 391 | KatzeArrayAction* array_action) |
139 | 303 | { | 392 | { |
140 | 304 | KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem"); | 393 | KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem"); |
142 | 305 | katze_array_action_activate_item (array_action, item, 1); | 394 | |
143 | 395 | katze_array_action_activate_item (array_action, item, NULL, proxy); | ||
144 | 396 | } | ||
145 | 397 | |||
146 | 398 | static gboolean | ||
147 | 399 | katze_array_action_menu_item_button_press_cb (GtkWidget* proxy, | ||
148 | 400 | GdkEventButton* event, | ||
149 | 401 | KatzeArrayAction* array_action) | ||
150 | 402 | { | ||
151 | 403 | KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem"); | ||
152 | 404 | |||
153 | 405 | return katze_array_action_activate_item (array_action, item, event, proxy); | ||
154 | 406 | } | ||
155 | 407 | |||
156 | 408 | static gboolean | ||
157 | 409 | pointer_in_menu_window (GtkWidget *widget, | ||
158 | 410 | gdouble x_root, | ||
159 | 411 | gdouble y_root) | ||
160 | 412 | { | ||
161 | 413 | GtkMenu *menu = GTK_MENU (widget); | ||
162 | 414 | |||
163 | 415 | if (gtk_widget_get_mapped (menu->toplevel)) | ||
164 | 416 | { | ||
165 | 417 | GtkMenuShell *menu_shell; | ||
166 | 418 | gint window_x, window_y; | ||
167 | 419 | |||
168 | 420 | gdk_window_get_position (menu->toplevel->window, &window_x, &window_y); | ||
169 | 421 | |||
170 | 422 | if (x_root >= window_x && x_root < window_x + widget->allocation.width && | ||
171 | 423 | y_root >= window_y && y_root < window_y + widget->allocation.height) | ||
172 | 424 | return TRUE; | ||
173 | 425 | |||
174 | 426 | menu_shell = GTK_MENU_SHELL (widget); | ||
175 | 427 | |||
176 | 428 | if (GTK_IS_MENU (menu_shell->parent_menu_shell)) | ||
177 | 429 | return pointer_in_menu_window (menu_shell->parent_menu_shell, | ||
178 | 430 | x_root, y_root); | ||
179 | 431 | } | ||
180 | 432 | |||
181 | 433 | return FALSE; | ||
182 | 306 | } | 434 | } |
183 | 307 | 435 | ||
184 | 308 | static gboolean | 436 | static gboolean |
185 | @@ -310,22 +438,74 @@ | |||
186 | 310 | GdkEventButton* event, | 438 | GdkEventButton* event, |
187 | 311 | KatzeArrayAction* array_action) | 439 | KatzeArrayAction* array_action) |
188 | 312 | { | 440 | { |
199 | 313 | KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem"); | 441 | /* Take precedence over menu button-press-event handling to avoid |
200 | 314 | 442 | menu item activation and menu disparition for popup opening | |
201 | 315 | katze_array_action_activate_item (array_action, item, event->button); | 443 | */ |
202 | 316 | 444 | ||
203 | 317 | /* we need to block the 'activate' handler which would be called | 445 | if (GTK_IS_MENU_SHELL (gtk_get_event_widget ((GdkEvent *) event)) && |
204 | 318 | * otherwise as well */ | 446 | pointer_in_menu_window (proxy, event->x_root, event->y_root)) |
205 | 319 | g_signal_handlers_block_by_func (proxy, | 447 | return FALSE; |
206 | 320 | katze_array_action_menu_activate_cb, array_action); | 448 | |
207 | 321 | 449 | return katze_array_action_menu_item_button_press_cb (gtk_get_event_widget ((GdkEvent *) event), event, array_action); | |
208 | 322 | return TRUE; | 450 | } |
209 | 451 | |||
210 | 452 | static gboolean | ||
211 | 453 | katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy, | ||
212 | 454 | GdkEventButton* event, | ||
213 | 455 | KatzeArrayAction* array_action) | ||
214 | 456 | { | ||
215 | 457 | GtkWidget* toolitem = proxy->parent; | ||
216 | 458 | KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem"); | ||
217 | 459 | |||
218 | 460 | /* let the 'clicked' signal be processed normally */ | ||
219 | 461 | if (event->button == 1) | ||
220 | 462 | return FALSE; | ||
221 | 463 | |||
222 | 464 | return katze_array_action_activate_item (array_action, item, event, proxy); | ||
223 | 323 | } | 465 | } |
224 | 324 | 466 | ||
225 | 325 | static void | 467 | static void |
226 | 326 | katze_array_action_menu_item_select_cb (GtkWidget* proxy, | 468 | katze_array_action_menu_item_select_cb (GtkWidget* proxy, |
227 | 327 | KatzeArrayAction* array_action); | 469 | KatzeArrayAction* array_action); |
228 | 328 | 470 | ||
229 | 471 | static GtkWidget* | ||
230 | 472 | katze_array_action_menu_item_new (KatzeArrayAction* array_action, | ||
231 | 473 | KatzeItem* item) | ||
232 | 474 | { | ||
233 | 475 | GtkWidget* menuitem = katze_image_menu_item_new_ellipsized ( | ||
234 | 476 | katze_item_get_name (item)); | ||
235 | 477 | GtkWidget* image = katze_item_get_image (item, menuitem); | ||
236 | 478 | |||
237 | 479 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); | ||
238 | 480 | gtk_image_menu_item_set_always_show_image ( | ||
239 | 481 | GTK_IMAGE_MENU_ITEM (menuitem), TRUE); | ||
240 | 482 | |||
241 | 483 | g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); | ||
242 | 484 | |||
243 | 485 | if (KATZE_ITEM_IS_FOLDER (item)) | ||
244 | 486 | { | ||
245 | 487 | GtkWidget* submenu = gtk_menu_new (); | ||
246 | 488 | gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); | ||
247 | 489 | g_signal_connect (submenu, "button-press-event", | ||
248 | 490 | G_CALLBACK (katze_array_action_menu_button_press_cb), array_action); | ||
249 | 491 | g_signal_connect (menuitem, "select", | ||
250 | 492 | G_CALLBACK (katze_array_action_menu_item_select_cb), array_action); | ||
251 | 493 | g_signal_connect (menuitem, "activate", | ||
252 | 494 | G_CALLBACK (katze_array_action_menu_item_select_cb), array_action); | ||
253 | 495 | } | ||
254 | 496 | else | ||
255 | 497 | { | ||
256 | 498 | /* we need the 'activate' signal as well for keyboard events */ | ||
257 | 499 | g_signal_connect (menuitem, "activate", | ||
258 | 500 | G_CALLBACK (katze_array_action_menu_activate_cb), array_action); | ||
259 | 501 | } | ||
260 | 502 | |||
261 | 503 | g_signal_connect (menuitem, "button-press-event", | ||
262 | 504 | G_CALLBACK (katze_array_action_menu_item_button_press_cb), array_action); | ||
263 | 505 | |||
264 | 506 | return menuitem; | ||
265 | 507 | } | ||
266 | 508 | |||
267 | 329 | /** | 509 | /** |
268 | 330 | * katze_array_action_generate_menu: | 510 | * katze_array_action_generate_menu: |
269 | 331 | * @array_action: a #KatzeArrayAction | 511 | * @array_action: a #KatzeArrayAction |
270 | @@ -355,15 +535,13 @@ | |||
271 | 355 | gint summand; | 535 | gint summand; |
272 | 356 | KatzeItem* item; | 536 | KatzeItem* item; |
273 | 357 | GtkWidget* menuitem; | 537 | GtkWidget* menuitem; |
274 | 358 | GtkWidget* image; | ||
275 | 359 | GtkWidget* submenu; | ||
276 | 360 | 538 | ||
277 | 361 | g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action)); | 539 | g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action)); |
278 | 362 | g_return_if_fail (KATZE_IS_ITEM (array)); | 540 | g_return_if_fail (KATZE_IS_ITEM (array)); |
279 | 363 | g_return_if_fail (GTK_IS_MENU_SHELL (menu)); | 541 | g_return_if_fail (GTK_IS_MENU_SHELL (menu)); |
280 | 364 | g_return_if_fail (GTK_IS_TOOL_ITEM (proxy) | 542 | g_return_if_fail (GTK_IS_TOOL_ITEM (proxy) |
283 | 365 | || GTK_IS_MENU_ITEM (proxy) | 543 | || GTK_IS_MENU_ITEM (proxy) |
284 | 366 | || GTK_IS_WINDOW (proxy)); | 544 | || GTK_IS_WINDOW (proxy)); |
285 | 367 | 545 | ||
286 | 368 | if (!KATZE_IS_ARRAY (array)) | 546 | if (!KATZE_IS_ARRAY (array)) |
287 | 369 | return; | 547 | return; |
288 | @@ -388,35 +566,19 @@ | |||
289 | 388 | gtk_menu_shell_append (menu, menuitem); | 566 | gtk_menu_shell_append (menu, menuitem); |
290 | 389 | continue; | 567 | continue; |
291 | 390 | } | 568 | } |
300 | 391 | menuitem = katze_image_menu_item_new_ellipsized ( | 569 | |
301 | 392 | katze_item_get_name (item)); | 570 | menuitem = katze_array_action_menu_item_new (array_action, item); |
302 | 393 | image = katze_item_get_image (item, menuitem); | 571 | |
295 | 394 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); | ||
296 | 395 | gtk_image_menu_item_set_always_show_image ( | ||
297 | 396 | GTK_IMAGE_MENU_ITEM (menuitem), TRUE); | ||
298 | 397 | gtk_menu_shell_append (menu, menuitem); | ||
299 | 398 | g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); | ||
303 | 399 | if (KATZE_ITEM_IS_FOLDER (item)) | 572 | if (KATZE_ITEM_IS_FOLDER (item)) |
304 | 400 | { | 573 | { |
307 | 401 | submenu = gtk_menu_new (); | 574 | GtkWidget* submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem)); |
306 | 402 | gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); | ||
308 | 403 | /* Make sure menu appears to contain items */ | 575 | /* Make sure menu appears to contain items */ |
309 | 404 | gtk_menu_shell_append (GTK_MENU_SHELL (submenu), | 576 | gtk_menu_shell_append (GTK_MENU_SHELL (submenu), |
310 | 405 | gtk_separator_menu_item_new ()); | 577 | gtk_separator_menu_item_new ()); |
324 | 406 | g_signal_connect (menuitem, "select", | 578 | } |
325 | 407 | G_CALLBACK (katze_array_action_menu_item_select_cb), array_action); | 579 | |
313 | 408 | g_signal_connect (menuitem, "activate", | ||
314 | 409 | G_CALLBACK (katze_array_action_menu_item_select_cb), array_action); | ||
315 | 410 | } | ||
316 | 411 | else | ||
317 | 412 | { | ||
318 | 413 | /* we need the 'activate' signal as well for keyboard events */ | ||
319 | 414 | g_signal_connect (menuitem, "activate", | ||
320 | 415 | G_CALLBACK (katze_array_action_menu_activate_cb), array_action); | ||
321 | 416 | } | ||
322 | 417 | g_signal_connect (menuitem, "button-press-event", | ||
323 | 418 | G_CALLBACK (katze_array_action_menu_button_press_cb), array_action); | ||
326 | 419 | gtk_widget_show (menuitem); | 580 | gtk_widget_show (menuitem); |
327 | 581 | gtk_menu_shell_append (menu, menuitem); | ||
328 | 420 | } | 582 | } |
329 | 421 | } | 583 | } |
330 | 422 | 584 | ||
331 | @@ -444,7 +606,7 @@ | |||
332 | 444 | katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy); | 606 | katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy); |
333 | 445 | g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled); | 607 | g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled); |
334 | 446 | g_object_set_data (G_OBJECT (proxy), "last-update", | 608 | g_object_set_data (G_OBJECT (proxy), "last-update", |
336 | 447 | GINT_TO_POINTER (time (NULL))); | 609 | GINT_TO_POINTER (time (NULL))); |
337 | 448 | return TRUE; | 610 | return TRUE; |
338 | 449 | } | 611 | } |
339 | 450 | 612 | ||
340 | @@ -476,13 +638,14 @@ | |||
341 | 476 | gboolean handled = FALSE; | 638 | gboolean handled = FALSE; |
342 | 477 | 639 | ||
343 | 478 | array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem"); | 640 | array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem"); |
344 | 641 | |||
345 | 479 | if (GTK_IS_MENU_ITEM (proxy)) | 642 | if (GTK_IS_MENU_ITEM (proxy)) |
346 | 480 | { | 643 | { |
347 | 481 | if (katze_array_action_menu_item_need_update (array_action, proxy)) | 644 | if (katze_array_action_menu_item_need_update (array_action, proxy)) |
348 | 482 | { | 645 | { |
349 | 483 | g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, | 646 | g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, |
352 | 484 | gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)), | 647 | gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)), |
353 | 485 | array, &handled); | 648 | array, &handled); |
354 | 486 | if (!handled) | 649 | if (!handled) |
355 | 487 | g_signal_emit (array_action, signals[POPULATE_POPUP], 0, | 650 | g_signal_emit (array_action, signals[POPULATE_POPUP], 0, |
356 | 488 | gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy))); | 651 | gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy))); |
357 | @@ -492,7 +655,7 @@ | |||
358 | 492 | 655 | ||
359 | 493 | if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array)) | 656 | if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array)) |
360 | 494 | { | 657 | { |
362 | 495 | katze_array_action_activate_item (array_action, KATZE_ITEM (array), 1); | 658 | katze_array_action_activate_item (array_action, KATZE_ITEM (array), NULL, proxy); |
363 | 496 | return; | 659 | return; |
364 | 497 | } | 660 | } |
365 | 498 | 661 | ||
366 | @@ -512,7 +675,7 @@ | |||
367 | 512 | } | 675 | } |
368 | 513 | 676 | ||
369 | 514 | katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu), | 677 | katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu), |
371 | 515 | NULL, KATZE_MENU_POSITION_LEFT); | 678 | NULL, KATZE_MENU_POSITION_LEFT); |
372 | 516 | gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE); | 679 | gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE); |
373 | 517 | g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action); | 680 | g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action); |
374 | 518 | g_signal_connect (menu, "deactivate", | 681 | g_signal_connect (menu, "deactivate", |
375 | @@ -606,31 +769,9 @@ | |||
376 | 606 | { | 769 | { |
377 | 607 | KatzeArrayAction* array_action; | 770 | KatzeArrayAction* array_action; |
378 | 608 | GtkWidget* menuitem; | 771 | GtkWidget* menuitem; |
379 | 609 | GtkWidget* image; | ||
380 | 610 | 772 | ||
381 | 611 | array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction"); | 773 | array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction"); |
404 | 612 | menuitem = katze_image_menu_item_new_ellipsized ( | 774 | menuitem = katze_array_action_menu_item_new (array_action, item); |
383 | 613 | katze_item_get_name (item)); | ||
384 | 614 | image = katze_item_get_image (item, menuitem); | ||
385 | 615 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); | ||
386 | 616 | gtk_image_menu_item_set_always_show_image ( | ||
387 | 617 | GTK_IMAGE_MENU_ITEM (menuitem), TRUE); | ||
388 | 618 | g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); | ||
389 | 619 | if (KATZE_ITEM_IS_FOLDER (item)) | ||
390 | 620 | { | ||
391 | 621 | GtkWidget* submenu = gtk_menu_new (); | ||
392 | 622 | gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); | ||
393 | 623 | g_signal_connect (menuitem, "select", | ||
394 | 624 | G_CALLBACK (katze_array_action_menu_item_select_cb), array_action); | ||
395 | 625 | } | ||
396 | 626 | else | ||
397 | 627 | { | ||
398 | 628 | g_signal_connect (menuitem, "button-press-event", | ||
399 | 629 | G_CALLBACK (katze_array_action_menu_button_press_cb), array_action); | ||
400 | 630 | /* we need the 'activate' signal as well for keyboard events */ | ||
401 | 631 | g_signal_connect (menuitem, "activate", | ||
402 | 632 | G_CALLBACK (katze_array_action_menu_activate_cb), array_action); | ||
403 | 633 | } | ||
405 | 634 | gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (proxy), | 775 | gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (proxy), |
406 | 635 | "katze-tool-item-menu", menuitem); | 776 | "katze-tool-item-menu", menuitem); |
407 | 636 | return TRUE; | 777 | return TRUE; |
408 | @@ -706,9 +847,19 @@ | |||
409 | 706 | else | 847 | else |
410 | 707 | gtk_tool_item_set_tooltip_text (toolitem, uri); | 848 | gtk_tool_item_set_tooltip_text (toolitem, uri); |
411 | 708 | 849 | ||
413 | 709 | g_object_set_data (G_OBJECT (toolitem), "KatzeArray", item); | 850 | g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item); |
414 | 710 | g_signal_connect (toolitem, "clicked", | 851 | g_signal_connect (toolitem, "clicked", |
415 | 711 | G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action); | 852 | G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action); |
416 | 853 | if (KATZE_IS_ITEM (item)) | ||
417 | 854 | { | ||
418 | 855 | /* Tool items block the "button-press-event" but we can get it | ||
419 | 856 | * when connecting it to the tool item's child widget | ||
420 | 857 | */ | ||
421 | 858 | |||
422 | 859 | GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem)); | ||
423 | 860 | g_signal_connect (child, "button-press-event", | ||
424 | 861 | G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action); | ||
425 | 862 | } | ||
426 | 712 | 863 | ||
427 | 713 | g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action); | 864 | g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action); |
428 | 714 | g_signal_connect (item, "notify", | 865 | g_signal_connect (item, "notify", |
429 | @@ -779,11 +930,11 @@ | |||
430 | 779 | 930 | ||
431 | 780 | /* FIXME: Add and remove items dynamically */ | 931 | /* FIXME: Add and remove items dynamically */ |
432 | 781 | /*g_object_connect (array, | 932 | /*g_object_connect (array, |
438 | 782 | "signal-after::add-item", | 933 | "signal-after::add-item", |
439 | 783 | katze_array_action_engines_add_item_cb, array_action, | 934 | katze_array_action_engines_add_item_cb, array_action, |
440 | 784 | "signal-after::remove-item", | 935 | "signal-after::remove-item", |
441 | 785 | katze_array_action_engines_remove_item_cb, array_action, | 936 | katze_array_action_engines_remove_item_cb, array_action, |
442 | 786 | NULL);*/ | 937 | NULL);*/ |
443 | 787 | 938 | ||
444 | 788 | g_object_notify (G_OBJECT (array_action), "array"); | 939 | g_object_notify (G_OBJECT (array_action), "array"); |
445 | 789 | 940 | ||
446 | 790 | 941 | ||
447 | === modified file 'midori/marshal.list' | |||
448 | --- midori/marshal.list 2013-09-03 14:45:17 +0000 | |||
449 | +++ midori/marshal.list 2013-09-28 15:27:18 +0000 | |||
450 | @@ -1,6 +1,7 @@ | |||
451 | 1 | BOOLEAN:OBJECT | 1 | BOOLEAN:OBJECT |
452 | 2 | BOOLEAN:OBJECT,OBJECT | 2 | BOOLEAN:OBJECT,OBJECT |
453 | 3 | BOOLEAN:OBJECT,UINT | 3 | BOOLEAN:OBJECT,UINT |
454 | 4 | BOOLEAN:OBJECT,POINTER,OBJECT | ||
455 | 4 | BOOLEAN:VOID | 5 | BOOLEAN:VOID |
456 | 5 | BOOLEAN:STRING | 6 | BOOLEAN:STRING |
457 | 6 | OBJECT:OBJECT | 7 | OBJECT:OBJECT |
458 | 7 | 8 | ||
459 | === modified file 'midori/midori-browser.c' | |||
460 | --- midori/midori-browser.c 2013-09-17 19:34:23 +0000 | |||
461 | +++ midori/midori-browser.c 2013-09-28 15:27:18 +0000 | |||
462 | @@ -3124,18 +3124,31 @@ | |||
463 | 3124 | return TRUE; | 3124 | return TRUE; |
464 | 3125 | } | 3125 | } |
465 | 3126 | 3126 | ||
466 | 3127 | static void | ||
467 | 3128 | midori_browser_bookmark_popup (GtkWidget* proxy, | ||
468 | 3129 | GdkEventButton* event, | ||
469 | 3130 | KatzeItem* item, | ||
470 | 3131 | MidoriBrowser* browser); | ||
471 | 3132 | |||
472 | 3127 | static gboolean | 3133 | static gboolean |
477 | 3128 | midori_bookmarkbar_activate_item_alt (GtkAction* action, | 3134 | midori_bookmarkbar_activate_item_full (GtkAction* action, |
478 | 3129 | KatzeItem* item, | 3135 | KatzeItem* item, |
479 | 3130 | guint button, | 3136 | GdkEventButton* event, |
480 | 3131 | MidoriBrowser* browser) | 3137 | GtkWidget* proxy, |
481 | 3138 | MidoriBrowser* browser) | ||
482 | 3132 | { | 3139 | { |
484 | 3133 | if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ())) | 3140 | g_assert (event); |
485 | 3141 | |||
486 | 3142 | if (MIDORI_EVENT_NEW_TAB (event)) | ||
487 | 3134 | { | 3143 | { |
488 | 3135 | GtkWidget* view = midori_browser_add_item (browser, item); | 3144 | GtkWidget* view = midori_browser_add_item (browser, item); |
489 | 3136 | midori_browser_set_current_tab_smartly (browser, view); | 3145 | midori_browser_set_current_tab_smartly (browser, view); |
490 | 3137 | } | 3146 | } |
492 | 3138 | else if (button == 1) | 3147 | else if (MIDORI_EVENT_CONTEXT_MENU (event)) |
493 | 3148 | { | ||
494 | 3149 | midori_browser_bookmark_popup (proxy, NULL, item, browser); | ||
495 | 3150 | } | ||
496 | 3151 | else if (event->button == 1) | ||
497 | 3139 | { | 3152 | { |
498 | 3140 | midori_browser_open_bookmark (browser, item); | 3153 | midori_browser_open_bookmark (browser, item); |
499 | 3141 | } | 3154 | } |
500 | @@ -3240,12 +3253,6 @@ | |||
501 | 3240 | midori_context_action_create_menu (menu, default_menu, TRUE); | 3253 | midori_context_action_create_menu (menu, default_menu, TRUE); |
502 | 3241 | } | 3254 | } |
503 | 3242 | 3255 | ||
504 | 3243 | static void | ||
505 | 3244 | midori_browser_bookmark_popup (GtkWidget* widget, | ||
506 | 3245 | GdkEventButton* event, | ||
507 | 3246 | KatzeItem* item, | ||
508 | 3247 | MidoriBrowser* browser); | ||
509 | 3248 | |||
510 | 3249 | static gboolean | 3256 | static gboolean |
511 | 3250 | _action_bookmarks_populate_folder (GtkAction* action, | 3257 | _action_bookmarks_populate_folder (GtkAction* action, |
512 | 3251 | GtkMenuShell* menu, | 3258 | GtkMenuShell* menu, |
513 | @@ -4373,6 +4380,9 @@ | |||
514 | 4373 | it is an item, we forward it to the actual widget. */ | 4380 | it is an item, we forward it to the actual widget. */ |
515 | 4374 | if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem))) | 4381 | if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem))) |
516 | 4375 | { | 4382 | { |
517 | 4383 | if (toolitem->window != event->window) | ||
518 | 4384 | return FALSE; | ||
519 | 4385 | |||
520 | 4376 | midori_browser_toolbar_popup_context_menu_cb ( | 4386 | midori_browser_toolbar_popup_context_menu_cb ( |
521 | 4377 | GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ? | 4387 | GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ? |
522 | 4378 | gtk_widget_get_parent (toolitem) : toolitem, | 4388 | gtk_widget_get_parent (toolitem) : toolitem, |
523 | @@ -6202,8 +6212,8 @@ | |||
524 | 6202 | g_object_connect (action, | 6212 | g_object_connect (action, |
525 | 6203 | "signal::populate-folder", | 6213 | "signal::populate-folder", |
526 | 6204 | _action_bookmarks_populate_folder, browser, | 6214 | _action_bookmarks_populate_folder, browser, |
529 | 6205 | "signal::activate-item-alt", | 6215 | "signal::activate-item-full", |
530 | 6206 | midori_bookmarkbar_activate_item_alt, browser, | 6216 | midori_bookmarkbar_activate_item_full, browser, |
531 | 6207 | NULL); | 6217 | NULL); |
532 | 6208 | gtk_action_group_add_action_with_accel (browser->action_group, action, ""); | 6218 | gtk_action_group_add_action_with_accel (browser->action_group, action, ""); |
533 | 6209 | g_object_unref (action); | 6219 | g_object_unref (action); |
534 | @@ -6220,8 +6230,6 @@ | |||
535 | 6220 | g_object_connect (action, | 6230 | g_object_connect (action, |
536 | 6221 | "signal::populate-popup", | 6231 | "signal::populate-popup", |
537 | 6222 | _action_tools_populate_popup, browser, | 6232 | _action_tools_populate_popup, browser, |
538 | 6223 | "signal::activate-item-alt", | ||
539 | 6224 | midori_bookmarkbar_activate_item_alt, browser, | ||
540 | 6225 | NULL); | 6233 | NULL); |
541 | 6226 | gtk_action_group_add_action (browser->action_group, action); | 6234 | gtk_action_group_add_action (browser->action_group, action); |
542 | 6227 | g_object_unref (action); | 6235 | g_object_unref (action); |
543 | @@ -6989,29 +6997,6 @@ | |||
544 | 6989 | g_value_unset (&value); | 6997 | g_value_unset (&value); |
545 | 6990 | } | 6998 | } |
546 | 6991 | 6999 | ||
547 | 6992 | static gboolean | ||
548 | 6993 | midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem, | ||
549 | 6994 | GdkEventButton* event, | ||
550 | 6995 | MidoriBrowser* browser) | ||
551 | 6996 | { | ||
552 | 6997 | KatzeItem* item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem"); | ||
553 | 6998 | if (MIDORI_EVENT_NEW_TAB (event)) | ||
554 | 6999 | { | ||
555 | 7000 | if (KATZE_ITEM_IS_BOOKMARK (item)) | ||
556 | 7001 | { | ||
557 | 7002 | GtkWidget* view = midori_browser_add_uri (browser, katze_item_get_uri (item)); | ||
558 | 7003 | midori_browser_set_current_tab_smartly (browser, view); | ||
559 | 7004 | return TRUE; | ||
560 | 7005 | } | ||
561 | 7006 | } | ||
562 | 7007 | else if (MIDORI_EVENT_CONTEXT_MENU (event)) | ||
563 | 7008 | { | ||
564 | 7009 | midori_browser_bookmark_popup (toolitem, NULL, item, browser); | ||
565 | 7010 | return TRUE; | ||
566 | 7011 | } | ||
567 | 7012 | return FALSE; | ||
568 | 7013 | } | ||
569 | 7014 | |||
570 | 7015 | static void | 7000 | static void |
571 | 7016 | midori_bookmarkbar_insert_item (GtkWidget* toolbar, | 7001 | midori_bookmarkbar_insert_item (GtkWidget* toolbar, |
572 | 7017 | KatzeItem* item) | 7002 | KatzeItem* item) |
573 | @@ -7022,15 +7007,7 @@ | |||
574 | 7022 | KATZE_ARRAY_ACTION (action), item); | 7007 | KATZE_ARRAY_ACTION (action), item); |
575 | 7023 | g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item); | 7008 | g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item); |
576 | 7024 | 7009 | ||
586 | 7025 | if (KATZE_IS_ITEM (item)) | 7010 | if (!KATZE_IS_ITEM (item)) /* Separator */ |
578 | 7026 | { | ||
579 | 7027 | GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem)); | ||
580 | 7028 | g_object_set_data (G_OBJECT (child), "KatzeItem", item); | ||
581 | 7029 | g_signal_connect (child, "button-press-event", | ||
582 | 7030 | G_CALLBACK (midori_bookmarkbar_item_button_press_event_cb), | ||
583 | 7031 | browser); | ||
584 | 7032 | } | ||
585 | 7033 | else /* Separator */ | ||
587 | 7034 | gtk_tool_item_set_use_drag_window (toolitem, TRUE); | 7011 | gtk_tool_item_set_use_drag_window (toolitem, TRUE); |
588 | 7035 | 7012 | ||
589 | 7036 | gtk_widget_show (GTK_WIDGET (toolitem)); | 7013 | gtk_widget_show (GTK_WIDGET (toolitem)); |
590 | @@ -7899,7 +7876,28 @@ | |||
591 | 7899 | 7876 | ||
592 | 7900 | browser = gtk_window_get_transient_for (GTK_WINDOW (browser)); | 7877 | browser = gtk_window_get_transient_for (GTK_WINDOW (browser)); |
593 | 7901 | if (!MIDORI_IS_BROWSER (browser)) | 7878 | if (!MIDORI_IS_BROWSER (browser)) |
595 | 7902 | return NULL; | 7879 | { |
596 | 7880 | /* For some reason, when called on the wiget of the | ||
597 | 7881 | * application menubar we get here. | ||
598 | 7882 | */ | ||
599 | 7883 | |||
600 | 7884 | GList* top_levels = gtk_window_list_toplevels (); | ||
601 | 7885 | GList *iter; | ||
602 | 7886 | |||
603 | 7887 | for (iter = top_levels; iter; iter = g_list_next (iter)) | ||
604 | 7888 | { | ||
605 | 7889 | browser = iter->data; | ||
606 | 7890 | |||
607 | 7891 | if (MIDORI_IS_BROWSER (browser)) | ||
608 | 7892 | { | ||
609 | 7893 | g_list_free (top_levels); | ||
610 | 7894 | return MIDORI_BROWSER (browser); | ||
611 | 7895 | } | ||
612 | 7896 | } | ||
613 | 7897 | |||
614 | 7898 | g_list_free (top_levels); | ||
615 | 7899 | return NULL; | ||
616 | 7900 | } | ||
617 | 7903 | } | 7901 | } |
618 | 7904 | 7902 | ||
619 | 7905 | return MIDORI_BROWSER (browser); | 7903 | return MIDORI_BROWSER (browser); |