Beispiel #1
0
 def sound_submenu_activate(self, item, menu, cb):
     log("submenu_uncheck(%s, %s, %s) ignore_events=%s, active=%s", item, menu, cb, menu.ignore_events, item.get_active())
     if menu.ignore_events:
         return
     ensure_item_selected(menu, item)
     if item.get_active():
         cb()
Beispiel #2
0
 def remote_clipboard_changed(item):
     assert can_clipboard
     ensure_item_selected(clipboard_submenu, item)
     label = item.get_label()
     remote_clipboard = LABEL_TO_NAME.get(label)
     old_state = self.client.clipboard_enabled
     clipboardlog("remote_clipboard_changed(%s) remote_clipboard=%s, old_state=%s", item, remote_clipboard, old_state)
     send_tokens = False
     if remote_clipboard is not None:
         #clipboard is not disabled
         if self.client.clipboard_helper is None:
             self.client.setup_clipboard_helper(TranslatedClipboardProtocolHelper)
         self.client.clipboard_helper.remote_clipboard = remote_clipboard
         self.client.clipboard_helper.remote_clipboards = [remote_clipboard]
         send_tokens = True
         new_state = True
         selections = [remote_clipboard]
     else:
         self.client.clipboard_helper = None
         send_tokens = False
         new_state = False
         selections = []
     clipboardlog("remote_clipboard_changed(%s) label=%s, remote_clipboard=%s, old_state=%s, new_state=%s",
              item, label, remote_clipboard, old_state, new_state)
     if new_state!=old_state:
         self.client.clipboard_enabled = new_state
         self.client.emit("clipboard-toggled")
         send_tokens = True
     #tell the server what to look for:
     #(now that "clipboard-toggled" has re-enabled clipboard if necessary)
     self.client.send_clipboard_selections(selections)
     if send_tokens and self.client.clipboard_helper:
         self.client.clipboard_helper.send_all_tokens()
Beispiel #3
0
 def remote_clipboard_changed(item):
     assert can_clipboard
     ensure_item_selected(clipboard_submenu, item)
     label = item.get_label()
     remote_clipboard = LABEL_TO_NAME.get(label)
     old_state = self.client.clipboard_enabled
     log("remote_clipboard_changed(%s) remote_clipboard=%s, old_state=%s", item, remote_clipboard, old_state)
     send_tokens = False
     if remote_clipboard is not None:
         #clipboard is not disabled
         if self.client.clipboard_helper is None:
             self.client.setup_clipboard_helper(TranslatedClipboardProtocolHelper)
         self.client.clipboard_helper.remote_clipboard = remote_clipboard
         send_tokens = True
         new_state = True
     else:
         self.client.clipboard_helper = None
         send_tokens = False
         new_state = False
     log("remote_clipboard_changed(%s) label=%s, remote_clipboard=%s, old_state=%s, new_state=%s",
              item, label, remote_clipboard, old_state, new_state)
     if new_state!=old_state:
         self.client.clipboard_enabled = new_state
         self.client.emit("clipboard-toggled")
         send_tokens = True
     if send_tokens and self.client.clipboard_helper:
         self.client.clipboard_helper.send_all_tokens()
Beispiel #4
0
 def remote_clipboard_changed(item):
     assert can_clipboard
     ensure_item_selected(clipboard_submenu, item)
     label = item.get_label()
     remote_clipboard = LABEL_TO_NAME.get(label)
     old_state = self.client.clipboard_enabled
     log(
         "remote_clipboard_changed(%s) remote_clipboard=%s, old_state=%s",
         item, remote_clipboard, old_state)
     send_tokens = False
     if remote_clipboard is not None:
         #clipboard is not disabled
         if self.client.clipboard_helper is None:
             self.client.setup_clipboard_helper(
                 TranslatedClipboardProtocolHelper)
         self.client.clipboard_helper.remote_clipboard = remote_clipboard
         send_tokens = True
         new_state = True
     else:
         self.client.clipboard_helper = None
         send_tokens = False
         new_state = False
     log(
         "remote_clipboard_changed(%s) label=%s, remote_clipboard=%s, old_state=%s, new_state=%s",
         item, label, remote_clipboard, old_state, new_state)
     if new_state != old_state:
         self.client.clipboard_enabled = new_state
         self.client.emit("clipboard-toggled")
         send_tokens = True
     if send_tokens and self.client.clipboard_helper:
         self.client.clipboard_helper.send_all_tokens()
Beispiel #5
0
 def encoding_changed(item):
     ensure_item_selected(encodings_submenu, item)
     enc = NAME_TO_ENCODING.get(item.get_label())
     log("encoding_changed(%s) enc=%s, current=%s", item, enc,
         encodings_submenu.get_current_encoding())
     if enc is not None and encodings_submenu.get_current_encoding(
     ) != enc:
         encodings_submenu.set_encoding(enc)
Beispiel #6
0
 def activate_cb(item, *args):
     webcamlog("activate_cb(%s, %s) ignore_events=%s", item, menu, menu.ignore_events)
     if not menu.ignore_events:
         try:
             menu.ignore_events = True
             ensure_item_selected(menu, item)
             cb()
         finally:
             menu.ignore_events = False
Beispiel #7
0
 def update_soundsubmenu_state(*args):
     menu.ignore_events = True
     is_on = is_on_cb()
     log("update_soundsubmenu_state%s is_on=%s", args, is_on)
     if is_on:
         if not on.get_active():
             on.set_active(True)
             ensure_item_selected(menu, on)
     else:
         if not off.get_active():
             off.set_active(True)
             ensure_item_selected(menu, off)
     menu.ignore_events = False
Beispiel #8
0
 def client_signalled_change(obj):
     menu.ignore_events = True
     is_on = is_on_cb()
     debug("sound: client_signalled_change(%s) is_on=%s", obj, is_on)
     if is_on:
         if not on.get_active():
             on.set_active(True)
             ensure_item_selected(menu, on)
     else:
         if not off.get_active():
             off.set_active(True)
             ensure_item_selected(menu, off)
     menu.ignore_events = False
Beispiel #9
0
 def client_signalled_change(obj):
     menu.ignore_events = True
     is_on = is_on_cb()
     log("sound: client_signalled_change(%s) is_on=%s", obj, is_on)
     if is_on:
         if not on.get_active():
             on.set_active(True)
             ensure_item_selected(menu, on)
     else:
         if not off.get_active():
             off.set_active(True)
             ensure_item_selected(menu, off)
     menu.ignore_events = False
Beispiel #10
0
 def encoding_changed(oitem):
     log("encoding_changed(%s)", oitem)
     item = ensure_item_selected(encodings_submenu, oitem)
     enc = NAME_TO_ENCODING.get(item.get_label())
     log("encoding_changed(%s) item=%s, enc=%s, current=%s", oitem, item, enc, encodings_submenu.get_current_encoding())
     if enc is not None and encodings_submenu.get_current_encoding()!=enc:
         encodings_submenu.set_encoding(enc)
Beispiel #11
0
 def set_layout(item):
     """ this callback updates the client (and server) if needed """
     item = ensure_item_selected(self.layout_submenu, item)
     layout = item.keyboard_layout
     variant = item.keyboard_variant
     if layout!=self.client.xkbmap_layout or variant!=self.client.xkbmap_variant:
         debug("keyboard layout selected: %s / %s", layout, variant)
         self.client.xkbmap_layout = layout
         self.client.xkbmap_variant = variant
         self.client.send_layout()
Beispiel #12
0
 def set_layout(item):
     """ this callback updates the client (and server) if needed """
     item = ensure_item_selected(self.layout_submenu, item)
     layout = item.keyboard_layout
     variant = item.keyboard_variant
     if layout != self.client.xkbmap_layout or variant != self.client.xkbmap_variant:
         log("keyboard layout selected: %s / %s", layout, variant)
         self.client.xkbmap_layout = layout
         self.client.xkbmap_variant = variant
         self.client.send_layout()
Beispiel #13
0
 def set_layout(item):
     """ this callback updates the client (and server) if needed """
     ensure_item_selected(self.layout_submenu, item)
     layout = item.keyboard_layout
     variant = item.keyboard_variant
     kh = self.client.keyboard_helper
     kh.locked = layout!="Auto"
     if layout!=kh.xkbmap_layout or variant!=kh.xkbmap_variant:
         if layout=="Auto":
             #re-detect everything:
             kh.update()
             log.info("keyboard automatic mode: %s", kh.layout_str())
             kh.send_layout()
             kh.send_keymap()
         else:
             #use layout specified and send it:
             kh.xkbmap_layout = layout
             kh.xkbmap_variant = variant
             log.info("new keyboard layout selected: %s", kh.layout_str())
             kh.send_layout()
Beispiel #14
0
 def set_layout(item):
     """ this callback updates the client (and server) if needed """
     ensure_item_selected(self.layout_submenu, item)
     layout = item.keyboard_layout
     variant = item.keyboard_variant
     kh = self.client.keyboard_helper
     kh.locked = layout != "Auto"
     if layout != kh.xkbmap_layout or variant != kh.xkbmap_variant:
         if layout == "Auto":
             #re-detect everything:
             kh.update()
             log.info("keyboard automatic mode: %s",
                      kh.layout_str())
             kh.send_layout()
             kh.send_keymap()
         else:
             #use layout specified and send it:
             kh.xkbmap_layout = layout
             kh.xkbmap_variant = variant
             log.info("new keyboard layout selected: %s",
                      kh.layout_str())
             kh.send_layout()
Beispiel #15
0
 def remote_clipboard_changed(self, item, clipboard_submenu):
     if not self._can_handle_clipboard():
         item = None
     if item is None:
         item = ([x for x in clipboard_submenu.get_children() if x.get_label()=="Disabled"]+[None])[0]
         if item is None:
             return
     #prevent infinite recursion where ensure_item_selected
     #ends up calling here again
     ich = getattr(clipboard_submenu, "_in_change_handler_", False)
     clipboardlog("remote_clipboard_changed%s already in change handler: %s, visible=%s", (ll(item), clipboard_submenu), ich, clipboard_submenu.get_visible())
     if ich: # or not clipboard_submenu.get_visible():
         return
     try:
         setattr(clipboard_submenu, "_in_change_handler_", True)
         selected_item = ensure_item_selected(clipboard_submenu, item)
         selected = selected_item.get_label()
         remote_clipboard = CLIPBOARD_LABEL_TO_NAME.get(selected)
         self.set_new_remote_clipboard(remote_clipboard)
     finally:
         setattr(clipboard_submenu, "_in_change_handler_", False)
Beispiel #16
0
 def set_compression(item):
     item = ensure_item_selected(self.compression_submenu, item)
     c = int(item.get_label().replace("None", "0"))
     if c != self.client.compression_level:
         log("setting compression level to %s", c)
         self.client.set_deflate_level(c)
Beispiel #17
0
 def submenu_uncheck(item, menu):
     if not menu.ignore_events:
         ensure_item_selected(menu, item)
Beispiel #18
0
 def set_compression(item):
     item = ensure_item_selected(self.compression_submenu, item)
     c = int(item.get_label().replace("None", "0"))
     if c!=self.client.compression_level:
         debug("setting compression level to %s", c)
         self.client.set_deflate_level(c)
Beispiel #19
0
 def scaling_activated(item):
     if scaling_submenu.updating:
         return
     ensure_item_selected(scaling_submenu, item)
     self.client.scaleset(item.scalingvalue, item.scalingvalue)
Beispiel #20
0
 def submenu_uncheck(item, menu):
     if not menu.ignore_events:
         ensure_item_selected(menu, item)