Beispiel #1
0
    def __property_cell_func(self, col, cell, model, iter):
        cell.editor, cell.field = None, None
        cell.set_property('editable', False)
        cell.set_property('text', '')

        obj = model.get_value(iter, 0)

        if isinstance(obj, TField) and backend.is_flags(obj.ref):
            # Flag container

            cell.set_property('cell-background-gdk',
                              self.style.mid[gtk.STATE_NORMAL])

            value = backend.get_field_value_repr(obj.proto, obj.ref)

            try:
                if value:
                    cell.set_property('markup', '<tt>%s</tt>' % \
                                  gobject.markup_escape_text(unicode(value)))
            except UnicodeDecodeError:
                cell.set_property('markup', _('<tt>N/A</tt>'))


        # If we are a field or a string (a sub field of flags)
        elif isinstance(obj, (TField, TFlag)):

            cell.field = None
            cell.set_property('editable', True)
            cell.set_property('cell-background-gdk', None)

            # We have a standard field

            if isinstance(obj, TField):
                value = backend.get_field_value(obj.proto, obj.ref)

                if value is not None:
                    try:
                        value = gobject.markup_escape_text(unicode(value))
                    except UnicodeDecodeError:
                        value = None

                if not value:
                    value = _("N/A")

                cell.set_property('markup', '<tt>%s</tt>' % value)
                cell.editor = get_editor(obj.ref)

                if cell.editor:
                    cell.field = (obj.proto, obj.ref)

            elif isinstance(obj, TFlag):
                # We have a subkey of Flags

                cell.editor = BitEditor
                cell.field = (obj.proto, obj.field.ref, obj.ref)
        else:
            cell.set_property('cell-background-gdk',
                              self.style.mid[gtk.STATE_NORMAL])
    def draw_left(self, cr):
        layout = self.create_pango_layout('')
        layout.set_font_description(pango.FontDescription(self.title_font))

        attr_layout = self.create_pango_layout('')
        attr_layout.set_font_description(pango.FontDescription(self.attr_font))

        cr.move_to(4, 4)

        for protocol, color in self.protocols:
            name = backend.get_proto_name(protocol)
            layout.set_text(name)

            w, h = self.draw_box(cr, layout, fill=color)

            cr.rel_move_to(0, h + 4)

            x, y = cr.get_current_point()
            cr.move_to(x + 10, y)

            for field in backend.get_proto_fields(protocol):

                if not backend.is_showable_field(field, self.packet):
                    continue

                name = backend.get_field_name(field)
                value = str(backend.get_field_value_repr(protocol, field))

                text = '%s: %s' % (name, value)

                if len(text) > 35:
                    text = text[0:32] + "..."

                attr_layout.set_text(text)

                f_w, f_h = self.draw_text(cr, attr_layout)

                # Start point
                x, y = cr.get_current_point()
                self.fields[(protocol, name)] = [(x + f_w + 4, y + (f_h / 2.0))
                                                 ]

                cr.rel_move_to(0, f_h)

            cr.rel_move_to(-10, 10)
Beispiel #3
0
    def draw_left(self, cr):
        layout = self.create_pango_layout('')
        layout.set_font_description(pango.FontDescription(self.title_font))

        attr_layout = self.create_pango_layout('')
        attr_layout.set_font_description(pango.FontDescription(self.attr_font))

        cr.move_to(4, 4)

        for protocol, color in self.protocols:
            name = backend.get_proto_name(protocol)
            layout.set_text(name)

            w, h = self.draw_box(cr, layout, fill=color)

            cr.rel_move_to(0, h + 4)

            x, y = cr.get_current_point()
            cr.move_to(x + 10, y)

            for field in backend.get_proto_fields(protocol):

                if not backend.is_showable_field(field, self.packet):
                    continue

                name = backend.get_field_name(field)
                value = str(backend.get_field_value_repr(protocol, field))

                text = '%s: %s' % (name, value)

                if len(text) > 35:
                    text = text[0:32] + "..."

                attr_layout.set_text(text)

                f_w, f_h = self.draw_text(cr, attr_layout)

                # Start point
                x, y = cr.get_current_point()
                self.fields[(protocol, name)] = [(x + f_w + 4, y + (f_h / 2.0))]

                cr.rel_move_to(0, f_h)

            cr.rel_move_to(-10, 10)