Commit cdf74955b2b07889eeedbb9281da037ca4be9bd8

Authored by Colomban Wendling
1 parent ca608bee

status-notifier: avoid activation loop on toggle items

Do not send the activation signal in response to state synchronization
not to create an infinite loop between the application and the item.

https://bugzilla.gnome.org/show_bug.cgi?id=776278
sn-dbus-menu-item.c
... ... @@ -369,10 +369,14 @@ sn_dbus_menu_item_update_props (SnDBusMenuItem *item,
369 369  
370 370 check = GTK_CHECK_MENU_ITEM (item->item);
371 371  
  372 + g_signal_handler_block (item->item, item->activate_id);
  373 +
372 374 if (item->toggle_state == 1)
373 375 gtk_check_menu_item_set_active (check, TRUE);
374 376 else if (item->toggle_state == 0)
375 377 gtk_check_menu_item_set_active (check, FALSE);
  378 +
  379 + g_signal_handler_unblock (item->item, item->activate_id);
376 380 }
377 381 }
378 382 else if (g_strcmp0 (prop, "type") == 0)
... ...
sn-dbus-menu-item.h
... ... @@ -45,6 +45,8 @@ typedef struct
45 45  
46 46 GtkWidget *item;
47 47 GtkMenu *submenu;
  48 +
  49 + gulong activate_id;
48 50 } SnDBusMenuItem;
49 51  
50 52 SnDBusMenuItem *sn_dbus_menu_item_new (GVariant *props);
... ...
sn-dbus-menu.c
... ... @@ -101,7 +101,9 @@ layout_update_item (SnDBusMenu *menu,
101 101  
102 102 g_object_set_data (G_OBJECT (item->item), "item-id", GUINT_TO_POINTER (id));
103 103 gtk_menu_shell_append (GTK_MENU_SHELL (gtk_menu), item->item);
104   - g_signal_connect (item->item, "activate", G_CALLBACK (activate_cb), menu);
  104 +
  105 + item->activate_id = g_signal_connect (item->item, "activate",
  106 + G_CALLBACK (activate_cb), menu);
105 107  
106 108 g_hash_table_replace (menu->items, GUINT_TO_POINTER (id), item);
107 109 }
... ...