| | 56 | def do_size_request(self, req): |
| | 57 | w, h = self.get_requested_size() |
| | 58 | req.width = w; req.height = h |
| | 59 | |
| | 60 | def get_requested_size(self): |
| | 61 | # Get the requested size of the hex view part |
| | 62 | layout = self.create_pango_layout('FF') |
| | 63 | layout.set_font_description(pango.FontDescription(self.hex_font)) |
| | 64 | |
| | 65 | atom_w, atom_h = layout.get_pixel_size() |
| | 66 | |
| | 67 | req_w = (atom_w + 4) * (16 + 1) |
| | 68 | req_h = (atom_h + 4) * (16 + 1) |
| | 69 | |
| | 70 | layout.set_font_description(pango.FontDescription(self.attr_font)) |
| | 71 | layout.set_text('A') |
| | 72 | |
| | 73 | atom_w, atom_h = layout.get_pixel_size() |
| | 74 | |
| | 75 | fields = 0 |
| | 76 | protos = [proto for proto in self.packet.get_protocols()] |
| | 77 | |
| | 78 | for proto in protos: |
| | 79 | for field in Backend.get_proto_fields(proto): |
| | 80 | fields += 1 |
| | 81 | |
| | 82 | protos = len(protos) |
| | 83 | |
| | 84 | req_w += 10 + (atom_w * 35) # 35 characters for attributes |
| | 85 | req_h = max(req_h, (fields + protos) * (atom_h + 4)) |
| | 86 | |
| | 87 | print req_w, req_h |
| | 88 | return int(req_w), int(req_h) |
| | 89 | |