### Eclipse Workspace Patch 1.0 #P Xpra Index: src/xpra/client/gtk_base/gtk_tray_menu_base.py =================================================================== --- src/xpra/client/gtk_base/gtk_tray_menu_base.py (revision 8011) +++ src/xpra/client/gtk_base/gtk_tray_menu_base.py (working copy) @@ -50,6 +50,21 @@ SPEED_OPTIONS[100] = "Lowest Latency" +def TrayCheckMenuItem(*args): + """ We add a button handler to catch clicks that somehow do not + trigger the "toggled" signal on some platforms (win32?) when we + show the tray menu with a right click and click on the item with the left click. + (or the other way around?) + """ + c = CheckMenuItem(*args) + def on_button_press_event(*args): + log.info("on_button_press_event%s", args) + c.toggled() + c.add_events(gtk.gdk.BUTTON_PRESS_MASK) + c.connect("button-press-event", on_button_press_event) + return c + + def make_min_auto_menu(title, min_options, options, get_current_min_value, get_current_value, set_min_value_cb, set_value_cb): #note: we must keep references to the parameters on the submenu #(closures and gtk callbacks don't mix so well!) @@ -70,7 +85,7 @@ options[value] = "%s%%" % value for s in sorted(options.keys()): t = options.get(s) - qi = CheckMenuItem(t) + qi = TrayCheckMenuItem(t) qi.set_draw_as_radio(True) candidate_match = s>=max(0, value) qi.set_active(not found_match and candidate_match) @@ -153,7 +168,7 @@ name = ENCODINGS_TO_NAME.get(encoding, encoding) descr = ENCODINGS_HELP.get(encoding) NAME_TO_ENCODING[name] = encoding - encoding_item = CheckMenuItem(name) + encoding_item = TrayCheckMenuItem(name) if descr: if encoding not in server_encodings: descr += "\n(not available on this server)" @@ -292,8 +307,8 @@ return menuitem(title, image, tooltip, cb) def checkitem(self, title, cb=None, active=False): - """ Utility method for easily creating a CheckMenuItem """ - check_item = CheckMenuItem(title) + """ Utility method for easily creating a TrayCheckMenuItem """ + check_item = TrayCheckMenuItem(title) check_item.set_active(active) if cb: check_item.connect("toggled", cb) @@ -436,7 +451,7 @@ "Secondary" : "SECONDARY"} from xpra.clipboard.translated_clipboard import TranslatedClipboardProtocolHelper for label, remote_clipboard in LABEL_TO_NAME.items(): - clipboard_item = CheckMenuItem(label) + clipboard_item = TrayCheckMenuItem(label) def remote_clipboard_changed(item): assert can_clipboard item = ensure_item_selected(clipboard_submenu, item) @@ -715,7 +730,7 @@ menu = gtk.Menu() menu.ignore_events = False def onoffitem(label, active, cb): - c = CheckMenuItem(label) + c = TrayCheckMenuItem(label) c.set_draw_as_radio(True) c.set_active(active) def submenu_uncheck(item, menu): @@ -855,7 +870,7 @@ log("setting compression level to %s", c) self.client.set_deflate_level(c) for i in range(0, 10): - c = CheckMenuItem(str(compression_options.get(i, i))) + c = TrayCheckMenuItem(str(compression_options.get(i, i))) c.set_draw_as_radio(True) c.set_active(i==self.client.compression_level) c.connect('activate', set_compression)