def __friend_selected_cb(self, menu_item, buddy): logging.debug("__friend_selected_cb") file_name = model.get_file(self._metadata["uid"]) if not file_name or not os.path.exists(file_name): logging.warn("Entries without a file cannot be sent.") self.emit("volume-error", _("Entries without a file cannot be sent."), _("Warning")) return title = str(self._metadata["title"]) description = str(self._metadata.get("description", "")) mime_type = str(self._metadata["mime_type"]) if not mime_type: mime_type = mime.get_for_file(file_name) filetransfer.start_transfer(buddy, file_name, title, description, mime_type)
def __friend_selected_cb(self, menu_item, buddy): logging.debug('__friend_selected_cb') file_name = model.get_file(self._metadata['uid']) if not file_name or not os.path.exists(file_name): logging.warn('Entries without a file cannot be sent.') self.emit('volume-error', _('Entries without a file cannot be sent.'), _('Warning')) return title = str(self._metadata['title']) description = str(self._metadata.get('description', '')) mime_type = str(self._metadata['mime_type']) if not mime_type: mime_type = mime.get_for_file(file_name) filetransfer.start_transfer(buddy, file_name, title, description, mime_type)
def _add_selection(self, object_id, selection): if not selection.get_data(): return selection_data = selection.get_data() selection_type_atom = selection.get_data_type() selection_type = selection_type_atom.name() logging.debug('ClipboardTray: adding type %r', selection_type) cb_service = clipboard.get_instance() if selection_type == 'text/uri-list': uris = selection.get_uris() if len(uris) > 1: raise NotImplementedError('Multiple uris in text/uri-list' ' still not supported.') file_name = uris[0] buddies = neighborhood.get_model().get_buddies() mime_type = mime.get_for_file(file_name) title = os.path.basename(file_name) dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.YES_NO, "Do you want to start file transfer ?") response = dialog.run() dialog.destroy() if response == Gtk.ResponseType.YES: for buddy in buddies: if buddy != get_owner_instance(): filetransfer.start_transfer(buddy, file_name, title, "dummy", mime_type) cb_service.add_object_format(object_id, selection_type, uris[0], on_disk=True) else: cb_service.add_object_format(object_id, selection_type, selection_data, on_disk=False)