Merge lp:~attente/unity-gtk-module/1208019-2 into lp:unity-gtk-module/14.10
- 1208019-2
- Merge into trunk.14.10
Proposed by
William Hua
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ted Gould | ||||
Approved revision: | 335 | ||||
Merged at revision: | 330 | ||||
Proposed branch: | lp:~attente/unity-gtk-module/1208019-2 | ||||
Merge into: | lp:unity-gtk-module/14.10 | ||||
Diff against target: |
895 lines (+442/-230) 7 files modified
lib/unity-gtk-action-group.c (+269/-161) lib/unity-gtk-action-private.h (+19/-15) lib/unity-gtk-action.c (+14/-0) lib/unity-gtk-menu-item-private.h (+3/-1) lib/unity-gtk-menu-item.c (+88/-26) lib/unity-gtk-menu-section.c (+40/-25) lib/unity-gtk-menu-shell.c (+9/-2) |
||||
To merge this branch: | bzr merge lp:~attente/unity-gtk-module/1208019-2 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+224646@code.launchpad.net |
Commit message
Forward show and hide signals to GTK+ menus.
Description of the change
Forward show and hide signals to GTK+ menus.
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Ted Gould (ted) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/unity-gtk-action-group.c' | |||
2 | --- lib/unity-gtk-action-group.c 2014-03-25 21:48:16 +0000 | |||
3 | +++ lib/unity-gtk-action-group.c 2014-06-26 14:42:27 +0000 | |||
4 | @@ -42,6 +42,14 @@ | |||
5 | 42 | 42 | ||
6 | 43 | static gboolean unity_gtk_action_group_debug; | 43 | static gboolean unity_gtk_action_group_debug; |
7 | 44 | 44 | ||
8 | 45 | static gboolean | ||
9 | 46 | g_signal_emit_hide (gpointer user_data) | ||
10 | 47 | { | ||
11 | 48 | g_signal_emit_by_name (user_data, "hide"); | ||
12 | 49 | |||
13 | 50 | return G_SOURCE_REMOVE; | ||
14 | 51 | } | ||
15 | 52 | |||
16 | 45 | static void | 53 | static void |
17 | 46 | unity_gtk_action_group_handle_group_action_added (GActionGroup *action_group, | 54 | unity_gtk_action_group_handle_group_action_added (GActionGroup *action_group, |
18 | 47 | gchar *action_name, | 55 | gchar *action_name, |
19 | @@ -272,54 +280,79 @@ | |||
20 | 272 | 280 | ||
21 | 273 | if (action != NULL) | 281 | if (action != NULL) |
22 | 274 | { | 282 | { |
24 | 275 | if (action->items_by_name != NULL) | 283 | if (g_strcmp0 (name, action->name) == 0) |
25 | 276 | { | 284 | { |
60 | 277 | if (value != NULL) | 285 | if (action->items_by_name != NULL) |
61 | 278 | { | 286 | { |
62 | 279 | const gchar *name; | 287 | if (value != NULL) |
63 | 280 | UnityGtkMenuItem *item; | 288 | { |
64 | 281 | 289 | const gchar *name; | |
65 | 282 | g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)); | 290 | UnityGtkMenuItem *item; |
66 | 283 | 291 | ||
67 | 284 | name = g_variant_get_string (value, NULL); | 292 | g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)); |
68 | 285 | item = g_hash_table_lookup (action->items_by_name, name); | 293 | |
69 | 286 | 294 | name = g_variant_get_string (value, NULL); | |
70 | 287 | if (item == NULL || !unity_gtk_menu_item_is_check (item)) | 295 | item = g_hash_table_lookup (action->items_by_name, name); |
71 | 288 | { | 296 | |
72 | 289 | g_warn_if_reached (); | 297 | if (item == NULL || !unity_gtk_menu_item_is_check (item)) |
73 | 290 | 298 | { | |
74 | 291 | value = NULL; | 299 | g_warn_if_reached (); |
75 | 292 | } | 300 | |
76 | 293 | else | 301 | value = NULL; |
77 | 294 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item->menu_item), TRUE); | 302 | } |
78 | 295 | } | 303 | else |
79 | 296 | 304 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item->menu_item), TRUE); | |
80 | 297 | if (value == NULL) | 305 | } |
81 | 298 | { | 306 | |
82 | 299 | GHashTableIter iter; | 307 | if (value == NULL) |
83 | 300 | gpointer value; | 308 | { |
84 | 301 | 309 | GHashTableIter iter; | |
85 | 302 | g_hash_table_iter_init (&iter, action->items_by_name); | 310 | gpointer value; |
86 | 303 | while (g_hash_table_iter_next (&iter, NULL, &value)) | 311 | |
87 | 304 | { | 312 | g_hash_table_iter_init (&iter, action->items_by_name); |
88 | 305 | UnityGtkMenuItem *item = value; | 313 | while (g_hash_table_iter_next (&iter, NULL, &value)) |
89 | 306 | 314 | { | |
90 | 307 | if (unity_gtk_menu_item_is_check (item)) | 315 | UnityGtkMenuItem *item = value; |
91 | 308 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item->menu_item), FALSE); | 316 | |
92 | 309 | } | 317 | if (unity_gtk_menu_item_is_check (item)) |
93 | 310 | } | 318 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item->menu_item), FALSE); |
94 | 319 | } | ||
95 | 320 | } | ||
96 | 321 | } | ||
97 | 322 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | ||
98 | 323 | { | ||
99 | 324 | g_return_if_fail (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)); | ||
100 | 325 | |||
101 | 326 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (action->item->menu_item), g_variant_get_boolean (value)); | ||
102 | 327 | } | ||
103 | 328 | else | ||
104 | 329 | g_warn_if_fail (value == NULL); | ||
105 | 330 | |||
106 | 331 | return; | ||
107 | 311 | } | 332 | } |
109 | 312 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | 333 | else if (g_strcmp0 (name, action->subname) == 0) |
110 | 313 | { | 334 | { |
111 | 335 | GtkWidget *submenu; | ||
112 | 336 | |||
113 | 314 | g_return_if_fail (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)); | 337 | g_return_if_fail (value != NULL && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)); |
116 | 315 | 338 | g_return_if_fail (action->item != NULL && action->item->menu_item != NULL); | |
117 | 316 | gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (action->item->menu_item), g_variant_get_boolean (value)); | 339 | |
118 | 340 | submenu = gtk_menu_item_get_submenu (action->item->menu_item); | ||
119 | 341 | |||
120 | 342 | g_return_if_fail (submenu != NULL); | ||
121 | 343 | |||
122 | 344 | if (g_variant_get_boolean (value)) | ||
123 | 345 | g_signal_emit_by_name (submenu, "show"); | ||
124 | 346 | else | ||
125 | 347 | g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, g_signal_emit_hide, g_object_ref (submenu), g_object_unref); | ||
126 | 348 | |||
127 | 349 | return; | ||
128 | 317 | } | 350 | } |
129 | 318 | else | 351 | else |
133 | 319 | g_warn_if_fail (value == NULL); | 352 | g_warn_if_reached (); |
131 | 320 | |||
132 | 321 | return; | ||
134 | 322 | } | 353 | } |
135 | 354 | else | ||
136 | 355 | g_warn_if_reached (); | ||
137 | 323 | } | 356 | } |
138 | 324 | else | 357 | else |
139 | 325 | g_warn_if_reached (); | 358 | g_warn_if_reached (); |
140 | @@ -359,33 +392,40 @@ | |||
141 | 359 | 392 | ||
142 | 360 | if (action != NULL) | 393 | if (action != NULL) |
143 | 361 | { | 394 | { |
170 | 362 | if (action->items_by_name != NULL) | 395 | if (g_strcmp0 (name, action->name) == 0) |
171 | 363 | { | 396 | { |
172 | 364 | const gchar *name; | 397 | if (action->items_by_name != NULL) |
173 | 365 | UnityGtkMenuItem *item; | 398 | { |
174 | 366 | 399 | const gchar *name; | |
175 | 367 | g_return_if_fail (parameter != NULL && g_variant_is_of_type (parameter, G_VARIANT_TYPE_STRING)); | 400 | UnityGtkMenuItem *item; |
176 | 368 | 401 | ||
177 | 369 | name = g_variant_get_string (parameter, NULL); | 402 | g_return_if_fail (parameter != NULL && g_variant_is_of_type (parameter, G_VARIANT_TYPE_STRING)); |
178 | 370 | item = g_hash_table_lookup (action->items_by_name, name); | 403 | |
179 | 371 | 404 | name = g_variant_get_string (parameter, NULL); | |
180 | 372 | if (item != NULL) | 405 | item = g_hash_table_lookup (action->items_by_name, name); |
181 | 373 | unity_gtk_menu_item_activate (item); | 406 | |
182 | 374 | 407 | if (item != NULL) | |
183 | 375 | g_action_group_action_state_changed (G_ACTION_GROUP (group), action->name, parameter); | 408 | unity_gtk_menu_item_activate (item); |
184 | 376 | } | 409 | |
185 | 377 | else if (action->item != NULL) | 410 | g_action_group_action_state_changed (G_ACTION_GROUP (group), action->name, parameter); |
186 | 378 | { | 411 | } |
187 | 379 | if (unity_gtk_menu_item_get_draw_as_radio (action->item)) | 412 | else if (action->item != NULL) |
188 | 380 | g_warn_if_fail (g_variant_is_of_type (parameter, G_VARIANT_TYPE_STRING)); | 413 | { |
189 | 381 | else | 414 | if (unity_gtk_menu_item_get_draw_as_radio (action->item)) |
190 | 382 | g_warn_if_fail (parameter == NULL); | 415 | g_warn_if_fail (g_variant_is_of_type (parameter, G_VARIANT_TYPE_STRING)); |
191 | 383 | 416 | else | |
192 | 384 | unity_gtk_menu_item_activate (action->item); | 417 | g_warn_if_fail (parameter == NULL); |
193 | 385 | } | 418 | |
194 | 386 | 419 | unity_gtk_menu_item_activate (action->item); | |
195 | 387 | return; | 420 | } |
196 | 421 | |||
197 | 422 | return; | ||
198 | 423 | } | ||
199 | 424 | else | ||
200 | 425 | g_warn_if_reached (); | ||
201 | 388 | } | 426 | } |
202 | 427 | else | ||
203 | 428 | g_warn_if_reached (); | ||
204 | 389 | } | 429 | } |
205 | 390 | else | 430 | else |
206 | 391 | g_warn_if_reached (); | 431 | g_warn_if_reached (); |
207 | @@ -419,111 +459,142 @@ | |||
208 | 419 | 459 | ||
209 | 420 | if (action != NULL) | 460 | if (action != NULL) |
210 | 421 | { | 461 | { |
212 | 422 | if (enabled != NULL) | 462 | if (g_strcmp0 (name, action->name) == 0) |
213 | 423 | { | 463 | { |
227 | 424 | if (action->items_by_name != NULL) | 464 | if (enabled != NULL) |
228 | 425 | { | 465 | { |
229 | 426 | GHashTableIter iter; | 466 | if (action->items_by_name != NULL) |
230 | 427 | gpointer value; | 467 | { |
231 | 428 | 468 | GHashTableIter iter; | |
232 | 429 | *enabled = FALSE; | 469 | gpointer value; |
233 | 430 | 470 | ||
234 | 431 | g_hash_table_iter_init (&iter, action->items_by_name); | 471 | *enabled = FALSE; |
235 | 432 | while (!*enabled && g_hash_table_iter_next (&iter, NULL, &value)) | 472 | |
236 | 433 | *enabled = unity_gtk_menu_item_is_sensitive (value); | 473 | g_hash_table_iter_init (&iter, action->items_by_name); |
237 | 434 | } | 474 | while (!*enabled && g_hash_table_iter_next (&iter, NULL, &value)) |
238 | 435 | else | 475 | *enabled = unity_gtk_menu_item_is_sensitive (value); |
239 | 436 | *enabled = action->item != NULL && unity_gtk_menu_item_is_sensitive (action->item); | 476 | } |
240 | 477 | else | ||
241 | 478 | *enabled = action->item != NULL && unity_gtk_menu_item_is_sensitive (action->item); | ||
242 | 479 | } | ||
243 | 480 | |||
244 | 481 | if (parameter_type != NULL) | ||
245 | 482 | { | ||
246 | 483 | if (action->items_by_name != NULL || (action->item != NULL && unity_gtk_menu_item_get_draw_as_radio (action->item))) | ||
247 | 484 | *parameter_type = G_VARIANT_TYPE_STRING; | ||
248 | 485 | else | ||
249 | 486 | *parameter_type = NULL; | ||
250 | 487 | } | ||
251 | 488 | |||
252 | 489 | if (state_type != NULL) | ||
253 | 490 | { | ||
254 | 491 | if (action->items_by_name != NULL || (action->item != NULL && unity_gtk_menu_item_get_draw_as_radio (action->item))) | ||
255 | 492 | *state_type = G_VARIANT_TYPE_STRING; | ||
256 | 493 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | ||
257 | 494 | *state_type = G_VARIANT_TYPE_BOOLEAN; | ||
258 | 495 | else | ||
259 | 496 | *state_type = NULL; | ||
260 | 497 | } | ||
261 | 498 | |||
262 | 499 | if (state_hint != NULL) | ||
263 | 500 | { | ||
264 | 501 | if (action->items_by_name != NULL) | ||
265 | 502 | { | ||
266 | 503 | GVariantBuilder builder; | ||
267 | 504 | GHashTableIter iter; | ||
268 | 505 | gpointer key; | ||
269 | 506 | |||
270 | 507 | g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); | ||
271 | 508 | |||
272 | 509 | g_hash_table_iter_init (&iter, action->items_by_name); | ||
273 | 510 | while (g_hash_table_iter_next (&iter, &key, NULL)) | ||
274 | 511 | g_variant_builder_add (&builder, "s", key); | ||
275 | 512 | |||
276 | 513 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); | ||
277 | 514 | } | ||
278 | 515 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | ||
279 | 516 | { | ||
280 | 517 | GVariantBuilder builder; | ||
281 | 518 | |||
282 | 519 | if (unity_gtk_menu_item_get_draw_as_radio (action->item)) | ||
283 | 520 | { | ||
284 | 521 | g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); | ||
285 | 522 | g_variant_builder_add (&builder, "s", action->name); | ||
286 | 523 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); | ||
287 | 524 | } | ||
288 | 525 | else | ||
289 | 526 | { | ||
290 | 527 | g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); | ||
291 | 528 | g_variant_builder_add (&builder, "b", FALSE); | ||
292 | 529 | g_variant_builder_add (&builder, "b", TRUE); | ||
293 | 530 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); | ||
294 | 531 | } | ||
295 | 532 | } | ||
296 | 533 | else | ||
297 | 534 | *state_hint = NULL; | ||
298 | 535 | } | ||
299 | 536 | |||
300 | 537 | if (state != NULL) | ||
301 | 538 | { | ||
302 | 539 | if (action->items_by_name != NULL) | ||
303 | 540 | { | ||
304 | 541 | GHashTableIter iter; | ||
305 | 542 | gpointer key; | ||
306 | 543 | gpointer value; | ||
307 | 544 | |||
308 | 545 | *state = NULL; | ||
309 | 546 | |||
310 | 547 | g_hash_table_iter_init (&iter, action->items_by_name); | ||
311 | 548 | while (*state == NULL && g_hash_table_iter_next (&iter, &key, &value)) | ||
312 | 549 | if (unity_gtk_menu_item_is_active (value)) | ||
313 | 550 | *state = g_variant_ref_sink (g_variant_new_string (key)); | ||
314 | 551 | } | ||
315 | 552 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | ||
316 | 553 | { | ||
317 | 554 | if (unity_gtk_menu_item_get_draw_as_radio (action->item)) | ||
318 | 555 | { | ||
319 | 556 | if (unity_gtk_menu_item_is_active (action->item)) | ||
320 | 557 | *state = g_variant_ref_sink (g_variant_new_string (action->name)); | ||
321 | 558 | else | ||
322 | 559 | *state = g_variant_ref_sink (g_variant_new_string ("")); | ||
323 | 560 | } | ||
324 | 561 | else | ||
325 | 562 | *state = g_variant_ref_sink (g_variant_new_boolean (unity_gtk_menu_item_is_active (action->item))); | ||
326 | 563 | } | ||
327 | 564 | else | ||
328 | 565 | *state = NULL; | ||
329 | 566 | } | ||
330 | 567 | |||
331 | 568 | return TRUE; | ||
332 | 437 | } | 569 | } |
333 | 570 | else if (g_strcmp0 (name, action->subname) == 0) | ||
334 | 571 | { | ||
335 | 572 | if (enabled != NULL) | ||
336 | 573 | *enabled = TRUE; | ||
337 | 438 | 574 | ||
343 | 439 | if (parameter_type != NULL) | 575 | if (parameter_type != NULL) |
339 | 440 | { | ||
340 | 441 | if (action->items_by_name != NULL || (action->item != NULL && unity_gtk_menu_item_get_draw_as_radio (action->item))) | ||
341 | 442 | *parameter_type = G_VARIANT_TYPE_STRING; | ||
342 | 443 | else | ||
344 | 444 | *parameter_type = NULL; | 576 | *parameter_type = NULL; |
345 | 445 | } | ||
346 | 446 | 577 | ||
352 | 447 | if (state_type != NULL) | 578 | if (state_type != NULL) |
348 | 448 | { | ||
349 | 449 | if (action->items_by_name != NULL || (action->item != NULL && unity_gtk_menu_item_get_draw_as_radio (action->item))) | ||
350 | 450 | *state_type = G_VARIANT_TYPE_STRING; | ||
351 | 451 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | ||
353 | 452 | *state_type = G_VARIANT_TYPE_BOOLEAN; | 579 | *state_type = G_VARIANT_TYPE_BOOLEAN; |
354 | 453 | else | ||
355 | 454 | *state_type = NULL; | ||
356 | 455 | } | ||
357 | 456 | 580 | ||
361 | 457 | if (state_hint != NULL) | 581 | if (state_hint != NULL) |
359 | 458 | { | ||
360 | 459 | if (action->items_by_name != NULL) | ||
362 | 460 | { | 582 | { |
363 | 461 | GVariantBuilder builder; | 583 | GVariantBuilder builder; |
373 | 462 | GHashTableIter iter; | 584 | |
374 | 463 | gpointer key; | 585 | g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); |
375 | 464 | 586 | g_variant_builder_add (&builder, "b", FALSE); | |
376 | 465 | g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); | 587 | g_variant_builder_add (&builder, "b", TRUE); |
368 | 466 | |||
369 | 467 | g_hash_table_iter_init (&iter, action->items_by_name); | ||
370 | 468 | while (g_hash_table_iter_next (&iter, &key, NULL)) | ||
371 | 469 | g_variant_builder_add (&builder, "s", key); | ||
372 | 470 | |||
377 | 471 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); | 588 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); |
378 | 472 | } | 589 | } |
433 | 473 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | 590 | |
434 | 474 | { | 591 | if (state != NULL) |
435 | 475 | GVariantBuilder builder; | 592 | *state = g_variant_ref_sink (g_variant_new_boolean (TRUE)); |
436 | 476 | 593 | ||
437 | 477 | if (unity_gtk_menu_item_get_draw_as_radio (action->item)) | 594 | return TRUE; |
438 | 478 | { | 595 | } |
439 | 479 | g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); | 596 | else |
440 | 480 | g_variant_builder_add (&builder, "s", action->name); | 597 | g_warn_if_reached (); |
387 | 481 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); | ||
388 | 482 | } | ||
389 | 483 | else | ||
390 | 484 | { | ||
391 | 485 | g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); | ||
392 | 486 | g_variant_builder_add (&builder, "b", FALSE); | ||
393 | 487 | g_variant_builder_add (&builder, "b", TRUE); | ||
394 | 488 | *state_hint = g_variant_ref_sink (g_variant_builder_end (&builder)); | ||
395 | 489 | } | ||
396 | 490 | } | ||
397 | 491 | else | ||
398 | 492 | *state_hint = NULL; | ||
399 | 493 | } | ||
400 | 494 | |||
401 | 495 | if (state != NULL) | ||
402 | 496 | { | ||
403 | 497 | if (action->items_by_name != NULL) | ||
404 | 498 | { | ||
405 | 499 | GHashTableIter iter; | ||
406 | 500 | gpointer key; | ||
407 | 501 | gpointer value; | ||
408 | 502 | |||
409 | 503 | *state = NULL; | ||
410 | 504 | |||
411 | 505 | g_hash_table_iter_init (&iter, action->items_by_name); | ||
412 | 506 | while (*state == NULL && g_hash_table_iter_next (&iter, &key, &value)) | ||
413 | 507 | if (unity_gtk_menu_item_is_active (value)) | ||
414 | 508 | *state = g_variant_ref_sink (g_variant_new_string (key)); | ||
415 | 509 | } | ||
416 | 510 | else if (action->item != NULL && unity_gtk_menu_item_is_check (action->item)) | ||
417 | 511 | { | ||
418 | 512 | if (unity_gtk_menu_item_get_draw_as_radio (action->item)) | ||
419 | 513 | { | ||
420 | 514 | if (unity_gtk_menu_item_is_active (action->item)) | ||
421 | 515 | *state = g_variant_ref_sink (g_variant_new_string (action->name)); | ||
422 | 516 | else | ||
423 | 517 | *state = g_variant_ref_sink (g_variant_new_string ("")); | ||
424 | 518 | } | ||
425 | 519 | else | ||
426 | 520 | *state = g_variant_ref_sink (g_variant_new_boolean (unity_gtk_menu_item_is_active (action->item))); | ||
427 | 521 | } | ||
428 | 522 | else | ||
429 | 523 | *state = NULL; | ||
430 | 524 | } | ||
431 | 525 | |||
432 | 526 | return TRUE; | ||
441 | 527 | } | 598 | } |
442 | 528 | } | 599 | } |
443 | 529 | else | 600 | else |
444 | @@ -865,6 +936,21 @@ | |||
445 | 865 | g_warn_if_reached (); | 936 | g_warn_if_reached (); |
446 | 866 | 937 | ||
447 | 867 | g_action_group_action_added (G_ACTION_GROUP (group), new_action->name); | 938 | g_action_group_action_added (G_ACTION_GROUP (group), new_action->name); |
448 | 939 | |||
449 | 940 | /* Add a new submenu action so we can detect opening and closing. */ | ||
450 | 941 | if (item->menu_item != NULL && gtk_menu_item_get_submenu (item->menu_item) != NULL) | ||
451 | 942 | { | ||
452 | 943 | gchar *subname = unity_gtk_action_group_get_action_name (group, item); | ||
453 | 944 | unity_gtk_action_set_subname (new_action, subname); | ||
454 | 945 | g_free (subname); | ||
455 | 946 | |||
456 | 947 | if (group->actions_by_name != NULL) | ||
457 | 948 | g_hash_table_insert (group->actions_by_name, new_action->subname, g_object_ref (new_action)); | ||
458 | 949 | else | ||
459 | 950 | g_warn_if_reached (); | ||
460 | 951 | |||
461 | 952 | g_action_group_action_added (G_ACTION_GROUP (group), new_action->subname); | ||
462 | 953 | } | ||
463 | 868 | } | 954 | } |
464 | 869 | } | 955 | } |
465 | 870 | } | 956 | } |
466 | @@ -908,6 +994,17 @@ | |||
467 | 908 | 994 | ||
468 | 909 | if (g_hash_table_size (action->items_by_name) == 0) | 995 | if (g_hash_table_size (action->items_by_name) == 0) |
469 | 910 | { | 996 | { |
470 | 997 | /* Remove the submenu action used to detect opening and closing. */ | ||
471 | 998 | if (action->subname != NULL) | ||
472 | 999 | { | ||
473 | 1000 | if (group->actions_by_name != NULL) | ||
474 | 1001 | g_hash_table_remove (group->actions_by_name, action->subname); | ||
475 | 1002 | else | ||
476 | 1003 | g_warn_if_reached (); | ||
477 | 1004 | |||
478 | 1005 | g_action_group_action_removed (G_ACTION_GROUP (group), action->subname); | ||
479 | 1006 | } | ||
480 | 1007 | |||
481 | 911 | if (group->actions_by_name != NULL) | 1008 | if (group->actions_by_name != NULL) |
482 | 912 | g_hash_table_remove (group->actions_by_name, action->name); | 1009 | g_hash_table_remove (group->actions_by_name, action->name); |
483 | 913 | else | 1010 | else |
484 | @@ -924,6 +1021,17 @@ | |||
485 | 924 | } | 1021 | } |
486 | 925 | else | 1022 | else |
487 | 926 | { | 1023 | { |
488 | 1024 | /* Remove the submenu action used to detect opening and closing. */ | ||
489 | 1025 | if (action->subname != NULL) | ||
490 | 1026 | { | ||
491 | 1027 | if (group->actions_by_name != NULL) | ||
492 | 1028 | g_hash_table_remove (group->actions_by_name, action->subname); | ||
493 | 1029 | else | ||
494 | 1030 | g_warn_if_reached (); | ||
495 | 1031 | |||
496 | 1032 | g_action_group_action_removed (G_ACTION_GROUP (group), action->subname); | ||
497 | 1033 | } | ||
498 | 1034 | |||
499 | 927 | if (group->actions_by_name != NULL) | 1035 | if (group->actions_by_name != NULL) |
500 | 928 | g_hash_table_remove (group->actions_by_name, action->name); | 1036 | g_hash_table_remove (group->actions_by_name, action->name); |
501 | 929 | else | 1037 | else |
502 | 930 | 1038 | ||
503 | === modified file 'lib/unity-gtk-action-private.h' | |||
504 | --- lib/unity-gtk-action-private.h 2013-02-19 11:55:57 +0000 | |||
505 | +++ lib/unity-gtk-action-private.h 2014-06-26 14:42:27 +0000 | |||
506 | @@ -46,25 +46,29 @@ | |||
507 | 46 | 46 | ||
508 | 47 | /*< private >*/ | 47 | /*< private >*/ |
509 | 48 | gchar *name; | 48 | gchar *name; |
510 | 49 | gchar *subname; | ||
511 | 49 | UnityGtkMenuItem *item; | 50 | UnityGtkMenuItem *item; |
512 | 50 | GHashTable *items_by_name; | 51 | GHashTable *items_by_name; |
513 | 51 | }; | 52 | }; |
514 | 52 | 53 | ||
530 | 53 | GType unity_gtk_action_get_type (void) G_GNUC_INTERNAL; | 54 | GType unity_gtk_action_get_type (void) G_GNUC_INTERNAL; |
531 | 54 | 55 | ||
532 | 55 | UnityGtkAction * unity_gtk_action_new (const gchar *name, | 56 | UnityGtkAction * unity_gtk_action_new (const gchar *name, |
533 | 56 | UnityGtkMenuItem *item) G_GNUC_INTERNAL; | 57 | UnityGtkMenuItem *item) G_GNUC_INTERNAL; |
534 | 57 | 58 | ||
535 | 58 | UnityGtkAction * unity_gtk_action_new_radio (const gchar *name) G_GNUC_INTERNAL; | 59 | UnityGtkAction * unity_gtk_action_new_radio (const gchar *name) G_GNUC_INTERNAL; |
536 | 59 | 60 | ||
537 | 60 | void unity_gtk_action_set_name (UnityGtkAction *action, | 61 | void unity_gtk_action_set_name (UnityGtkAction *action, |
538 | 61 | const gchar *name) G_GNUC_INTERNAL; | 62 | const gchar *name) G_GNUC_INTERNAL; |
539 | 62 | 63 | ||
540 | 63 | void unity_gtk_action_set_item (UnityGtkAction *action, | 64 | void unity_gtk_action_set_subname (UnityGtkAction *action, |
541 | 64 | UnityGtkMenuItem *item) G_GNUC_INTERNAL; | 65 | const gchar *subname) G_GNUC_INTERNAL; |
542 | 65 | 66 | ||
543 | 66 | void unity_gtk_action_print (UnityGtkAction *action, | 67 | void unity_gtk_action_set_item (UnityGtkAction *action, |
544 | 67 | guint indent) G_GNUC_INTERNAL; | 68 | UnityGtkMenuItem *item) G_GNUC_INTERNAL; |
545 | 69 | |||
546 | 70 | void unity_gtk_action_print (UnityGtkAction *action, | ||
547 | 71 | guint indent) G_GNUC_INTERNAL; | ||
548 | 68 | 72 | ||
549 | 69 | G_END_DECLS | 73 | G_END_DECLS |
550 | 70 | 74 | ||
551 | 71 | 75 | ||
552 | === modified file 'lib/unity-gtk-action.c' | |||
553 | --- lib/unity-gtk-action.c 2013-02-19 11:55:57 +0000 | |||
554 | +++ lib/unity-gtk-action.c 2014-06-26 14:42:27 +0000 | |||
555 | @@ -41,6 +41,7 @@ | |||
556 | 41 | } | 41 | } |
557 | 42 | 42 | ||
558 | 43 | unity_gtk_action_set_item (action, NULL); | 43 | unity_gtk_action_set_item (action, NULL); |
559 | 44 | unity_gtk_action_set_subname (action, NULL); | ||
560 | 44 | unity_gtk_action_set_name (action, NULL); | 45 | unity_gtk_action_set_name (action, NULL); |
561 | 45 | 46 | ||
562 | 46 | G_OBJECT_CLASS (unity_gtk_action_parent_class)->dispose (object); | 47 | G_OBJECT_CLASS (unity_gtk_action_parent_class)->dispose (object); |
563 | @@ -93,6 +94,16 @@ | |||
564 | 93 | } | 94 | } |
565 | 94 | 95 | ||
566 | 95 | void | 96 | void |
567 | 97 | unity_gtk_action_set_subname (UnityGtkAction *action, | ||
568 | 98 | const gchar *subname) | ||
569 | 99 | { | ||
570 | 100 | g_return_if_fail (UNITY_GTK_IS_ACTION (action)); | ||
571 | 101 | |||
572 | 102 | g_free (action->subname); | ||
573 | 103 | action->subname = g_strdup (subname); | ||
574 | 104 | } | ||
575 | 105 | |||
576 | 106 | void | ||
577 | 96 | unity_gtk_action_set_item (UnityGtkAction *action, | 107 | unity_gtk_action_set_item (UnityGtkAction *action, |
578 | 97 | UnityGtkMenuItem *item) | 108 | UnityGtkMenuItem *item) |
579 | 98 | { | 109 | { |
580 | @@ -132,6 +143,9 @@ | |||
581 | 132 | if (action->name != NULL) | 143 | if (action->name != NULL) |
582 | 133 | g_print ("%s \"%s\"\n", space, action->name); | 144 | g_print ("%s \"%s\"\n", space, action->name); |
583 | 134 | 145 | ||
584 | 146 | if (action->subname != NULL) | ||
585 | 147 | g_print ("%s \"%s\"\n", space, action->subname); | ||
586 | 148 | |||
587 | 135 | if (action->item != NULL) | 149 | if (action->item != NULL) |
588 | 136 | g_print ("%s (%s *) %p\n", space, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (action->item)), action->item); | 150 | g_print ("%s (%s *) %p\n", space, G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (action->item)), action->item); |
589 | 137 | 151 | ||
590 | 138 | 152 | ||
591 | === modified file 'lib/unity-gtk-menu-item-private.h' | |||
592 | --- lib/unity-gtk-menu-item-private.h 2014-03-31 00:40:48 +0000 | |||
593 | +++ lib/unity-gtk-menu-item-private.h 2014-06-26 14:42:27 +0000 | |||
594 | @@ -52,7 +52,9 @@ | |||
595 | 52 | guchar child_shell_valid : 1; | 52 | guchar child_shell_valid : 1; |
596 | 53 | guint item_index; | 53 | guint item_index; |
597 | 54 | UnityGtkAction *action; | 54 | UnityGtkAction *action; |
599 | 55 | gchar *label; | 55 | GtkLabel *first_label; |
600 | 56 | GtkLabel *second_label; | ||
601 | 57 | gchar *label_label; | ||
602 | 56 | }; | 58 | }; |
603 | 57 | 59 | ||
604 | 58 | GType unity_gtk_menu_item_get_type (void) G_GNUC_INTERNAL; | 60 | GType unity_gtk_menu_item_get_type (void) G_GNUC_INTERNAL; |
605 | 59 | 61 | ||
606 | === modified file 'lib/unity-gtk-menu-item.c' | |||
607 | --- lib/unity-gtk-menu-item.c 2014-03-31 00:40:48 +0000 | |||
608 | +++ lib/unity-gtk-menu-item.c 2014-06-26 14:42:27 +0000 | |||
609 | @@ -368,6 +368,75 @@ | |||
610 | 368 | } | 368 | } |
611 | 369 | 369 | ||
612 | 370 | static void | 370 | static void |
613 | 371 | unity_gtk_menu_item_disconnect_labels (UnityGtkMenuItem *item) | ||
614 | 372 | { | ||
615 | 373 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); | ||
616 | 374 | |||
617 | 375 | if (item->second_label != NULL) | ||
618 | 376 | { | ||
619 | 377 | g_signal_handlers_disconnect_by_data (item->second_label, item); | ||
620 | 378 | item->second_label = NULL; | ||
621 | 379 | } | ||
622 | 380 | |||
623 | 381 | if (item->first_label != NULL) | ||
624 | 382 | { | ||
625 | 383 | g_signal_handlers_disconnect_by_data (item->first_label, item); | ||
626 | 384 | item->first_label = NULL; | ||
627 | 385 | } | ||
628 | 386 | } | ||
629 | 387 | |||
630 | 388 | static gboolean | ||
631 | 389 | unity_gtk_menu_item_connect_labels (UnityGtkMenuItem *item) | ||
632 | 390 | { | ||
633 | 391 | GtkLabel *first_label = NULL; | ||
634 | 392 | GtkLabel *second_label = NULL; | ||
635 | 393 | |||
636 | 394 | g_return_val_if_fail (UNITY_GTK_IS_MENU_ITEM (item), FALSE); | ||
637 | 395 | |||
638 | 396 | if (item->menu_item != NULL) | ||
639 | 397 | { | ||
640 | 398 | /* ensure label is available */ | ||
641 | 399 | gtk_menu_item_get_label (item->menu_item); | ||
642 | 400 | |||
643 | 401 | first_label = gtk_menu_item_get_nth_label (item->menu_item, 0); | ||
644 | 402 | second_label = gtk_menu_item_get_nth_label (item->menu_item, 1); | ||
645 | 403 | } | ||
646 | 404 | |||
647 | 405 | if (first_label != item->first_label || second_label != item->second_label) | ||
648 | 406 | { | ||
649 | 407 | unity_gtk_menu_item_disconnect_labels (item); | ||
650 | 408 | |||
651 | 409 | item->first_label = first_label; | ||
652 | 410 | item->second_label = second_label; | ||
653 | 411 | |||
654 | 412 | if (item->first_label != NULL) | ||
655 | 413 | g_signal_connect (item->first_label, "notify", G_CALLBACK (unity_gtk_menu_item_handle_label_notify), item); | ||
656 | 414 | if (item->second_label != NULL) | ||
657 | 415 | g_signal_connect (item->second_label, "notify", G_CALLBACK (unity_gtk_menu_item_handle_label_notify), item); | ||
658 | 416 | |||
659 | 417 | return TRUE; | ||
660 | 418 | } | ||
661 | 419 | |||
662 | 420 | return FALSE; | ||
663 | 421 | } | ||
664 | 422 | |||
665 | 423 | static void | ||
666 | 424 | unity_gtk_menu_item_handle_add_or_remove (GtkContainer *container, | ||
667 | 425 | GtkWidget *widget, | ||
668 | 426 | gpointer user_data) | ||
669 | 427 | { | ||
670 | 428 | UnityGtkMenuItem *item; | ||
671 | 429 | |||
672 | 430 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (user_data)); | ||
673 | 431 | |||
674 | 432 | item = UNITY_GTK_MENU_ITEM (user_data); | ||
675 | 433 | |||
676 | 434 | /* just ignore the case when parent_shell is NULL */ | ||
677 | 435 | if (item->parent_shell != NULL && unity_gtk_menu_item_connect_labels (item)) | ||
678 | 436 | unity_gtk_menu_shell_handle_item_notify (item->parent_shell, item, "label"); | ||
679 | 437 | } | ||
680 | 438 | |||
681 | 439 | static void | ||
682 | 371 | unity_gtk_menu_item_handle_accel_closures_changed (GtkWidget *widget, | 440 | unity_gtk_menu_item_handle_accel_closures_changed (GtkWidget *widget, |
683 | 372 | gpointer user_data) | 441 | gpointer user_data) |
684 | 373 | { | 442 | { |
685 | @@ -388,23 +457,16 @@ | |||
686 | 388 | unity_gtk_menu_item_set_menu_item (UnityGtkMenuItem *item, | 457 | unity_gtk_menu_item_set_menu_item (UnityGtkMenuItem *item, |
687 | 389 | GtkMenuItem *menu_item) | 458 | GtkMenuItem *menu_item) |
688 | 390 | { | 459 | { |
689 | 391 | GtkLabel *label; | ||
690 | 392 | |||
691 | 393 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); | 460 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); |
692 | 394 | 461 | ||
693 | 395 | if (menu_item != item->menu_item) | 462 | if (menu_item != item->menu_item) |
694 | 396 | { | 463 | { |
695 | 397 | UnityGtkMenuShell *child_shell = item->child_shell; | 464 | UnityGtkMenuShell *child_shell = item->child_shell; |
696 | 398 | 465 | ||
697 | 466 | unity_gtk_menu_item_disconnect_labels (item); | ||
698 | 467 | |||
699 | 399 | if (item->menu_item != NULL) | 468 | if (item->menu_item != NULL) |
708 | 400 | { | 469 | g_signal_handlers_disconnect_by_data (item->menu_item, item); |
701 | 401 | label = gtk_menu_item_get_nth_label (item->menu_item, 0); | ||
702 | 402 | |||
703 | 403 | if (label != NULL) | ||
704 | 404 | g_signal_handlers_disconnect_by_data (label, item); | ||
705 | 405 | |||
706 | 406 | g_signal_handlers_disconnect_by_data (item->menu_item, item); | ||
707 | 407 | } | ||
709 | 408 | 470 | ||
710 | 409 | if (child_shell != NULL) | 471 | if (child_shell != NULL) |
711 | 410 | { | 472 | { |
712 | @@ -419,20 +481,20 @@ | |||
713 | 419 | if (menu_item != NULL) | 481 | if (menu_item != NULL) |
714 | 420 | { | 482 | { |
715 | 421 | g_signal_connect (menu_item, "notify", G_CALLBACK (unity_gtk_menu_item_handle_item_notify), item); | 483 | g_signal_connect (menu_item, "notify", G_CALLBACK (unity_gtk_menu_item_handle_item_notify), item); |
724 | 422 | 484 | g_signal_connect (menu_item, "add", G_CALLBACK (unity_gtk_menu_item_handle_add_or_remove), item); | |
725 | 423 | /* ensure label is available */ | 485 | g_signal_connect (menu_item, "remove", G_CALLBACK (unity_gtk_menu_item_handle_add_or_remove), item); |
718 | 424 | gtk_menu_item_get_label (menu_item); | ||
719 | 425 | label = gtk_menu_item_get_nth_label (menu_item, 0); | ||
720 | 426 | |||
721 | 427 | if (label != NULL) | ||
722 | 428 | g_signal_connect (label, "notify", G_CALLBACK (unity_gtk_menu_item_handle_label_notify), item); | ||
723 | 429 | |||
726 | 430 | g_signal_connect (menu_item, "accel-closures-changed", G_CALLBACK (unity_gtk_menu_item_handle_accel_closures_changed), item); | 486 | g_signal_connect (menu_item, "accel-closures-changed", G_CALLBACK (unity_gtk_menu_item_handle_accel_closures_changed), item); |
727 | 431 | 487 | ||
729 | 432 | /* LP: #1208019 */ | 488 | /* |
730 | 489 | * LP: #1208019: We do this because Eclipse sets menu item | ||
731 | 490 | * accelerators using private API, and there's no way for us to | ||
732 | 491 | * detect when they change. | ||
733 | 492 | */ | ||
734 | 433 | if (gtk_menu_item_get_submenu (menu_item) != NULL) | 493 | if (gtk_menu_item_get_submenu (menu_item) != NULL) |
735 | 434 | g_signal_emit_by_name (gtk_menu_item_get_submenu (menu_item), "show"); | 494 | g_signal_emit_by_name (gtk_menu_item_get_submenu (menu_item), "show"); |
736 | 435 | } | 495 | } |
737 | 496 | |||
738 | 497 | unity_gtk_menu_item_connect_labels (item); | ||
739 | 436 | } | 498 | } |
740 | 437 | } | 499 | } |
741 | 438 | 500 | ||
742 | @@ -470,8 +532,8 @@ | |||
743 | 470 | 532 | ||
744 | 471 | item = UNITY_GTK_MENU_ITEM (object); | 533 | item = UNITY_GTK_MENU_ITEM (object); |
745 | 472 | 534 | ||
748 | 473 | g_free (item->label); | 535 | g_free (item->label_label); |
749 | 474 | item->label = NULL; | 536 | item->label_label = NULL; |
750 | 475 | 537 | ||
751 | 476 | G_OBJECT_CLASS (unity_gtk_menu_item_parent_class)->finalize (object); | 538 | G_OBJECT_CLASS (unity_gtk_menu_item_parent_class)->finalize (object); |
752 | 477 | } | 539 | } |
753 | @@ -661,7 +723,7 @@ | |||
754 | 661 | g_return_val_if_fail (UNITY_GTK_IS_MENU_ITEM (item), NULL); | 723 | g_return_val_if_fail (UNITY_GTK_IS_MENU_ITEM (item), NULL); |
755 | 662 | g_return_val_if_fail (item->menu_item != NULL, NULL); | 724 | g_return_val_if_fail (item->menu_item != NULL, NULL); |
756 | 663 | 725 | ||
758 | 664 | if (item->label == NULL) | 726 | if (item->label_label == NULL) |
759 | 665 | { | 727 | { |
760 | 666 | const gchar *label_label = gtk_menu_item_get_label (item->menu_item); | 728 | const gchar *label_label = gtk_menu_item_get_label (item->menu_item); |
761 | 667 | 729 | ||
762 | @@ -691,16 +753,16 @@ | |||
763 | 691 | if (gtk_label_get_use_underline (label)) | 753 | if (gtk_label_get_use_underline (label)) |
764 | 692 | { | 754 | { |
765 | 693 | if (item->parent_shell == NULL || item->parent_shell->has_mnemonics) | 755 | if (item->parent_shell == NULL || item->parent_shell->has_mnemonics) |
767 | 694 | item->label = g_strdup (label_label); | 756 | item->label_label = g_strdup (label_label); |
768 | 695 | else | 757 | else |
770 | 696 | item->label = g_strdup_no_mnemonics (label_label); | 758 | item->label_label = g_strdup_no_mnemonics (label_label); |
771 | 697 | } | 759 | } |
772 | 698 | else | 760 | else |
774 | 699 | item->label = g_strdup_escape_underscores (label_label); | 761 | item->label_label = g_strdup_escape_underscores (label_label); |
775 | 700 | } | 762 | } |
776 | 701 | } | 763 | } |
777 | 702 | 764 | ||
779 | 703 | return item->label; | 765 | return item->label_label; |
780 | 704 | } | 766 | } |
781 | 705 | 767 | ||
782 | 706 | GIcon * | 768 | GIcon * |
783 | 707 | 769 | ||
784 | === modified file 'lib/unity-gtk-menu-section.c' | |||
785 | --- lib/unity-gtk-menu-section.c 2014-03-31 00:40:48 +0000 | |||
786 | +++ lib/unity-gtk-menu-section.c 2014-06-26 14:42:27 +0000 | |||
787 | @@ -27,6 +27,10 @@ | |||
788 | 27 | #define G_MENU_ATTRIBUTE_ACCEL_TEXT "x-canonical-accel" | 27 | #define G_MENU_ATTRIBUTE_ACCEL_TEXT "x-canonical-accel" |
789 | 28 | #endif | 28 | #endif |
790 | 29 | 29 | ||
791 | 30 | #ifndef G_MENU_ATTRIBUTE_SUBMENU_ACTION | ||
792 | 31 | #define G_MENU_ATTRIBUTE_SUBMENU_ACTION "submenu-action" | ||
793 | 32 | #endif | ||
794 | 33 | |||
795 | 30 | G_DEFINE_TYPE (UnityGtkMenuSection, | 34 | G_DEFINE_TYPE (UnityGtkMenuSection, |
796 | 31 | unity_gtk_menu_section, | 35 | unity_gtk_menu_section, |
797 | 32 | G_TYPE_MENU_MODEL); | 36 | G_TYPE_MENU_MODEL); |
798 | @@ -136,32 +140,43 @@ | |||
799 | 136 | g_object_unref (icon); | 140 | g_object_unref (icon); |
800 | 137 | } | 141 | } |
801 | 138 | 142 | ||
803 | 139 | if (action != NULL && action->name != NULL) | 143 | if (action != NULL) |
804 | 140 | { | 144 | { |
829 | 141 | gchar *name = g_strdup_printf ("unity.%s", action->name); | 145 | if (action->name != NULL) |
830 | 142 | GVariant *variant = g_variant_ref_sink (g_variant_new_string (name)); | 146 | { |
831 | 143 | 147 | gchar *name = g_strdup_printf ("unity.%s", action->name); | |
832 | 144 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_ACTION, variant); | 148 | GVariant *variant = g_variant_ref_sink (g_variant_new_string (name)); |
833 | 145 | 149 | ||
834 | 146 | if (action->items_by_name != NULL) | 150 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_ACTION, variant); |
835 | 147 | { | 151 | |
836 | 148 | GHashTableIter iter; | 152 | if (action->items_by_name != NULL) |
837 | 149 | gpointer key; | 153 | { |
838 | 150 | gpointer value; | 154 | GHashTableIter iter; |
839 | 151 | const gchar *target = NULL; | 155 | gpointer key; |
840 | 152 | 156 | gpointer value; | |
841 | 153 | g_hash_table_iter_init (&iter, action->items_by_name); | 157 | const gchar *target = NULL; |
842 | 154 | while (target == NULL && g_hash_table_iter_next (&iter, &key, &value)) | 158 | |
843 | 155 | if (value == item) | 159 | g_hash_table_iter_init (&iter, action->items_by_name); |
844 | 156 | target = key; | 160 | while (target == NULL && g_hash_table_iter_next (&iter, &key, &value)) |
845 | 157 | 161 | if (value == item) | |
846 | 158 | if (target != NULL) | 162 | target = key; |
847 | 159 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_TARGET, g_variant_ref_sink (g_variant_new_string (target))); | 163 | |
848 | 160 | } | 164 | if (target != NULL) |
849 | 161 | else if (unity_gtk_menu_item_get_draw_as_radio (item)) | 165 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_TARGET, g_variant_ref_sink (g_variant_new_string (target))); |
850 | 162 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_TARGET, g_variant_ref_sink (g_variant_new_string (action->name))); | 166 | } |
851 | 163 | 167 | else if (unity_gtk_menu_item_get_draw_as_radio (item)) | |
852 | 164 | g_free (name); | 168 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_TARGET, g_variant_ref_sink (g_variant_new_string (action->name))); |
853 | 169 | |||
854 | 170 | g_free (name); | ||
855 | 171 | } | ||
856 | 172 | |||
857 | 173 | if (action->subname != NULL) | ||
858 | 174 | { | ||
859 | 175 | gchar *subname = g_strdup_printf ("unity.%s", action->subname); | ||
860 | 176 | GVariant *variant = g_variant_ref_sink (g_variant_new_string (subname)); | ||
861 | 177 | g_hash_table_insert (*attributes, G_MENU_ATTRIBUTE_SUBMENU_ACTION, variant); | ||
862 | 178 | g_free (subname); | ||
863 | 179 | } | ||
864 | 165 | } | 180 | } |
865 | 166 | 181 | ||
866 | 167 | if (item->menu_item != NULL) | 182 | if (item->menu_item != NULL) |
867 | 168 | 183 | ||
868 | === modified file 'lib/unity-gtk-menu-shell.c' | |||
869 | --- lib/unity-gtk-menu-shell.c 2014-03-27 19:52:20 +0000 | |||
870 | +++ lib/unity-gtk-menu-shell.c 2014-06-26 14:42:27 +0000 | |||
871 | @@ -449,8 +449,8 @@ | |||
872 | 449 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); | 449 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); |
873 | 450 | g_warn_if_fail (item->parent_shell == shell); | 450 | g_warn_if_fail (item->parent_shell == shell); |
874 | 451 | 451 | ||
877 | 452 | g_free (item->label); | 452 | g_free (item->label_label); |
878 | 453 | item->label = NULL; | 453 | item->label_label = NULL; |
879 | 454 | 454 | ||
880 | 455 | unity_gtk_menu_shell_update_item (shell, item); | 455 | unity_gtk_menu_shell_update_item (shell, item); |
881 | 456 | } | 456 | } |
882 | @@ -582,6 +582,13 @@ | |||
883 | 582 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); | 582 | g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (item)); |
884 | 583 | g_warn_if_fail (item->parent_shell == shell); | 583 | g_warn_if_fail (item->parent_shell == shell); |
885 | 584 | 584 | ||
886 | 585 | if (shell->action_group != NULL) | ||
887 | 586 | { | ||
888 | 587 | /* If a submenu was added or removed, we need to update the submenu action. */ | ||
889 | 588 | unity_gtk_action_group_disconnect_item (shell->action_group, item); | ||
890 | 589 | unity_gtk_action_group_connect_item (shell->action_group, item); | ||
891 | 590 | } | ||
892 | 591 | |||
893 | 585 | if (item->child_shell_valid) | 592 | if (item->child_shell_valid) |
894 | 586 | { | 593 | { |
895 | 587 | GtkMenuShell *old_submenu = item->child_shell != NULL ? item->child_shell->menu_shell : NULL; | 594 | GtkMenuShell *old_submenu = item->child_shell != NULL ? item->child_shell->menu_shell : NULL; |
PASSED: Continuous integration, rev:335 jenkins. qa.ubuntu. com/job/ unity-gtk- module- ci/56/ jenkins. qa.ubuntu. com/job/ unity-gtk- module- utopic- amd64-ci/ 10 jenkins. qa.ubuntu. com/job/ unity-gtk- module- utopic- armhf-ci/ 10 jenkins. qa.ubuntu. com/job/ unity-gtk- module- utopic- armhf-ci/ 10/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- gtk-module- ci/56/rebuild
http://