Show
Ignore:
Timestamp:
08/29/08 18:32:03 (5 years ago)
Author:
nopper
Message:

Fixing size request of plotter and reduced the total size of packet page by using a vertical toolbar

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/PacketManipulator/PM/Gui/Widgets/Plotter.py

    r3618 r3671  
    5454        super(Plotter, self).__init__() 
    5555 
     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 
    5690    def draw_text(self, cr, layout, txt): 
    5791        cr.save() 
     
    105139 
    106140    def export_to(self, fname): 
    107         WIDTH, HEIGHT = 900, 600 
     141        area = self.allocation 
     142        WIDTH, HEIGHT = area.width, area.height 
    108143 
    109144        if '.ps' in fname: 
     
    325360                name = Backend.get_field_name(field) 
    326361                value = str(Backend.get_field_value_repr(protocol, field)) 
    327  
    328                 attr_layout.set_text('%s: %s' % (name, value)) 
     362                 
     363                text = '%s: %s' % (name, value) 
     364 
     365                if len(text) > 35: 
     366                    text = text[0:32] + "..." 
     367 
     368                attr_layout.set_text(text) 
    329369 
    330370                f_w, f_h = self.draw_text(cr, attr_layout)