def __on_drag_data(self, widget, ctx, x, y, data, info, time): "drag-data-received callback" if data and data.format == 8: proto = data.data if backend.get_proto(proto): ServiceBus().call('pm.sessions', 'create_edit_session', data.data) ctx.finish(True, False, time) return True ctx.finish(False, False, time)
def append_packet(self, packet, coords=None): """ Append a packet (or better a protocol) to the current packet @param packet a MetaPacket or a str @param coords a tuple (x, y) or True for appending after selection or None @return True if the packet is appended """ assert isinstance(packet, (basestring, backend.MetaPacket)), \ "A string or MetaPacket instance is required" if isinstance(packet, basestring): packet = backend.get_proto(packet) if not packet: return False packet = backend.MetaPacket(packet()) ret = None where = -1 # append as default if isinstance(coords, tuple) and len(coords) == 2: ret = self.tree.get_dest_row_at_pos(*coords) if ret: path, pos = ret # because it's a treeview with only one child for row where = len(path) if pos == gtk.TREE_VIEW_DROP_BEFORE or \ pos == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE: where -= 1 elif not ret and coords == True: model, iter = self.tree.get_selection().get_selected() path = self.store.get_path(iter) where = len(path) # Now try to insert this stuff into the packet if self.session.packet.insert(packet, where): self.session.reload_container(self.session.packet) self.session.reload_editors() return True return False
def get_active_protocol(self): "@return the active protocol class or None" if self.get_active() <= 0: return None iter = self.get_active_iter() if iter: proto_str = self.store.get_value(iter, 1) return backend.get_proto(proto_str) return None
def append_packet(self, packet, coords=None): """ Append a packet to the sequence @param packet a MetaPacket or a str @param coords a tuple (x, y) or True for appending after selection or None @return True if the packet is appended """ if self.merging: return False assert isinstance(packet, (basestring, backend.MetaPacket)), \ "A string or MetaPacket instance is required" if isinstance(packet, basestring): protoklass = backend.get_proto(packet) if not protoklass: return False packet = backend.MetaPacket(protoklass()) ret = None if isinstance(coords, tuple) and len(coords) == 2: ret = self.tree.get_dest_row_at_pos(*coords) if ret: path, pos = ret iter = self.store.get_iter(path) if pos == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE or \ pos == gtk.TREE_VIEW_DROP_INTO_OR_AFTER: self.store.prepend(iter, [packet]) elif pos == gtk.TREE_VIEW_DROP_BEFORE: self.store.insert_before(None, iter, [packet]) elif pos == gtk.TREE_VIEW_DROP_AFTER: self.store.insert_after(None, iter, [packet]) elif not ret and coords == True: model, iter = self.tree.get_selection().get_selected() if iter: self.store.insert_after(None, iter, [packet]) else: self.store.append(None, [packet]) else: self.store.append(None, [packet]) return True
def __impl_create_edit_session(self, packet): if isinstance(packet, basestring): packet = backend.get_proto(packet)() packet = backend.MetaPacket(packet) return self.__impl_create_sequence_session([packet])