Esempio n. 1
0
    def __init__(self, view, attrs):
        super(MultiSelection, self).__init__(view, attrs)

        if int(attrs.get('yexpand', self.expand)):
            self.widget = Gtk.ScrolledWindow()
            self.widget.set_policy(Gtk.PolicyType.AUTOMATIC,
                                   Gtk.PolicyType.AUTOMATIC)
            self.widget.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        else:
            self.widget = Gtk.VBox()
        self.widget.set_size_request(100, 100)
        self.widget.get_accessible().set_name(attrs.get('string', ''))
        widget_class(self.widget, 'multiselection', True)
        self.model = Gtk.ListStore(GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
        self.tree = self.mnemonic_widget = TreeViewControl()
        self.tree.set_model(self.model)
        self.tree.set_search_column(1)
        self.tree.connect('focus-out-event', lambda *a: self._focus_out())
        self.tree.set_headers_visible(False)
        selection = self.tree.get_selection()
        selection.set_mode(Gtk.SelectionMode.MULTIPLE)
        selection.connect('changed', self.changed)
        self.widget.add(self.tree)
        name_column = Gtk.TreeViewColumn()
        name_cell = Gtk.CellRendererText()
        name_column.pack_start(name_cell, expand=True)
        name_column.add_attribute(name_cell, 'text', 1)
        self.tree.append_column(name_column)

        self.nullable_widget = False
        self.init_selection()
Esempio n. 2
0
    def display(self):
        super(DictWidget, self).display()

        if not self.field:
            return

        record_id = self.record.id if self.record else None
        if record_id != self._record_id:
            for key in list(self.fields.keys()):
                self._sig_remove(None, key, modified=False)
            self._record_id = record_id

        value = self.field.get_client(self.record) if self.field else {}
        new_key_names = set(value.keys()) - set(self.field.keys)
        if new_key_names:
            self.field.add_keys(list(new_key_names), self.record)
        decoder = PYSONDecoder()
        for key, val in sorted(value.items()):
            if key not in self.field.keys:
                continue
            if key not in self.fields:
                self.add_line(key)
            widget = self.fields[key]
            widget.set_value(val)
            widget.set_readonly(self._readonly)
            key_domain = decoder.decode(self.field.keys[key].get('domain')
                                        or '[]')
            widget_class(widget.widget, 'invalid',
                         not eval_domain(key_domain, value))
        for key in set(self.fields.keys()) - set(value.keys()):
            self._sig_remove(None, key, modified=False)

        self._set_button_sensitive()
Esempio n. 3
0
 def state_set(self, record):
     super(Label, self).state_set(record)
     if 'name' in self.attrs and record:
         field = record.group.fields[self.attrs['name']]
     else:
         field = None
     if not self.attrs.get('string', True) and field:
         if record:
             text = field.get_client(record) or ''
         else:
             text = ''
         self.set_text(text)
     if record:
         state_changes = record.expr_eval(self.attrs.get('states', {}))
     else:
         state_changes = {}
     required = ((field and field.attrs.get('required'))
                 or state_changes.get('required'))
     readonly = ((field and field.attrs.get('readonly'))
                 or state_changes.get('readonly'))
     attrlist = common.get_label_attributes(readonly, required)
     if field is not None:
         self._format_set(record, field, attrlist)
     self.set_attributes(attrlist)
     widget_class(self, 'readonly', readonly)
     widget_class(self, 'required', required)
Esempio n. 4
0
    def update(self, view, buttons):
        tooltips = common.Tooltips()
        for button in buttons:
            self._get_button(button)

        self.screen = Screen(view['model'], mode=[], context=self.context)
        self.screen.add_view(view)
        self.screen.switch_view()
        self.screen.widget.show()
        self.screen.signal_connect(self, 'group-changed', self._record_changed)

        title = Gtk.Label(label=common.ellipsize(self.name, 80),
                          halign=Gtk.Align.START,
                          margin=5,
                          ellipsize=Pango.EllipsizeMode.END)
        tooltips.set_tip(title, self.name)
        title.set_size_request(0, -1)  # Allow overflow
        title.show()

        hbox = Gtk.HBox()
        hbox.pack_start(title, expand=True, fill=True, padding=0)
        hbox.show()

        frame = Gtk.Frame()
        frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        widget_class(frame, 'wizard-title', True)
        frame.add(hbox)
        frame.show()

        self.widget.pack_start(frame, expand=False, fill=True, padding=3)

        if self.toolbar_box:
            self.widget.pack_start(self.toolbar_box,
                                   expand=False,
                                   fill=True,
                                   padding=0)

        viewport = Gtk.Viewport()
        viewport.set_shadow_type(Gtk.ShadowType.NONE)
        viewport.add(self.screen.widget)
        viewport.show()
        self.scrolledwindow = Gtk.ScrolledWindow()
        self.scrolledwindow.set_shadow_type(Gtk.ShadowType.NONE)
        self.scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
                                       Gtk.PolicyType.AUTOMATIC)
        self.scrolledwindow.add(viewport)
        self.scrolledwindow.show()

        self.widget.pack_start(self.scrolledwindow,
                               expand=True,
                               fill=True,
                               padding=0)

        self.create_info_bar()
        self.widget.pack_start(self.info_bar,
                               expand=False,
                               fill=True,
                               padding=0)
Esempio n. 5
0
    def display(self):
        super(DictWidget, self).display()

        if not self.field:
            return

        record_id = self.record.id if self.record else None
        if record_id != self._record_id:
            for key in list(self.fields.keys()):
                self._sig_remove(None, key, modified=False)
            self._record_id = record_id

        value = self.field.get_client(self.record) if self.field else {}
        new_key_names = set(value.keys()) - set(self.field.keys)
        if new_key_names:
            self.field.add_keys(list(new_key_names), self.record)
        decoder = PYSONDecoder()

        # ABDC: Allow dictschema to be ordered by a sequence
        value_ordered = OrderedDict()
        use_sequence = any(
            x[1].get('sequence_order', None) for x in self.field.keys.items())
        if use_sequence:
            for skey, svalues in sorted(self.field.keys.items(),
                    key=lambda x: x[1]['sequence_order']):
                if skey not in value:
                    continue
                value_ordered[skey] = value[skey]

        def _loop_order_hook():
            if use_sequence:
                return value_ordered.items()
            else:
                return ((key, val) for key, val in sorted(value.items()))

        for key, val in _loop_order_hook():
            if key not in self.field.keys:
                continue
            if key not in self.fields:
                self.add_line(key)
            widget = self.fields[key]
            widget.set_value(val)
            widget.set_readonly(self._readonly)
            key_domain = decoder.decode(
                self.field.keys[key].get('domain') or '[]')
            widget_class(
                widget.widget, 'invalid', not eval_domain(key_domain, value))
        for key in set(self.fields.keys()) - set(value.keys()):
            self._sig_remove(None, key, modified=False)

        self._set_button_sensitive()
Esempio n. 6
0
    def make_title_bar(self):
        tooltips = common.Tooltips()
        self.title = title = Gtk.Label(label=common.ellipsize(self.name, 80),
                                       halign=Gtk.Align.START,
                                       margin=5,
                                       ellipsize=Pango.EllipsizeMode.END)
        tooltips.set_tip(title, self.name)
        title.set_size_request(0, -1)  # Allow overflow
        title.show()

        menu = Gtk.MenuButton.new()
        # JCA : Allow to hide tab menu
        if not self.screen.context.get('disable_main_menu', None):
            menu.set_relief(Gtk.ReliefStyle.NONE)
            menu.set_popup(self.set_menu_form())
        menu.show()

        self.status_label = Gtk.Label(margin=5, halign=Gtk.Align.END)
        widget_class(self.status_label, 'status', True)
        self.status_label.show()

        hbox = Gtk.HBox()
        hbox.pack_start(title, expand=True, fill=True, padding=0)
        hbox.pack_start(self.status_label, expand=False, fill=True, padding=0)
        hbox.show()

        frame = Gtk.Frame()
        frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        widget_class(frame, 'window-title', True)
        frame.add(hbox)
        frame.show()

        frame_menu = Gtk.Frame()
        frame_menu.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        frame_menu.add(menu)
        frame_menu.show()

        title_box = Gtk.HBox()
        title_box.pack_start(frame_menu, expand=False, fill=True, padding=0)
        title_box.pack_start(frame, expand=True, fill=True, padding=0)
        title_box.show()
        return title_box
Esempio n. 7
0
    def display(self, record, field):
        if not field:
            self._readonly_set(self.attrs.get('readonly', True))
            self.invisible_set(self.attrs.get('invisible', False))
            self._required_set(False)
            return
        states = field.get_state_attrs(record)
        readonly = self.attrs.get('readonly', states.get('readonly', False))
        if self.view.screen.readonly:
            readonly = True
        self._readonly_set(readonly)

        # ABD: Seems to be related to a color fix (c24c86dc)
        invalidity = field.get_state_attrs(record).get('invalid', False)
        if readonly:
            self.color_set('readonly')
        elif invalidity and invalidity != 'required':
            self.color_set('invalid')
        elif invalidity and invalidity == 'required':
            self.color_set('required')
        else:
            self.color_set('normal')

        # ABD: See #3428
        self._format_set(record, field)

        widget_class(self.widget, 'readonly', readonly)
        self._required_set(not readonly and states.get('required', False))
        widget_class(self.widget, 'required', not readonly
                     and states.get('required', False))
        invalid = states.get('invalid', False)
        widget_class(self.widget, 'invalid', not readonly and invalid)
        self.invisible_set(
            self.attrs.get('invisible', states.get('invisible', False)))
Esempio n. 8
0
 def validate(self):
     valid = True
     if not self.subject.get_text():
         valid = False
         widget_class(self.subject, 'invalid', True)
         self.subject.grab_focus()
     else:
         widget_class(self.subject, 'invalid', False)
     if not self.to.get_text():
         valid = False
         widget_class(self.to, 'invalid', True)
         self.to.grab_focus()
     else:
         widget_class(self.to, 'invalid', False)
     return valid
Esempio n. 9
0
    def create_widget(self):
        widget = Gtk.ScrolledWindow()
        widget.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        widget.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        widget.set_size_request(100, 100)

        model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING)
        self.tree = TreeViewControl()
        self.tree.set_model(model)
        self.tree.set_search_column(1)
        self.tree.connect(
            'focus-out-event', lambda w, e: self.parent_widget._focus_out())
        self.tree.set_headers_visible(False)
        selection = self.tree.get_selection()
        selection.set_mode(Gtk.SelectionMode.MULTIPLE)
        selection.connect('changed', self._changed)
        widget.add(self.tree)
        widget_class(widget, 'multiselection', True)

        self.selection = self.definition['selection']
        width = 10
        if self.definition.get('sort', True):
            self.selection.sort(key=operator.itemgetter(1))
        for value, name in self.selection:
            name = str(name)
            model.append((value, name))
            width = max(width, len(name))

        widget.set_propagate_natural_width(True)
        widget.set_propagate_natural_height(True)

        name_column = Gtk.TreeViewColumn()
        name_cell = Gtk.CellRendererText()
        name_column.pack_start(name_cell, expand=True)
        name_column.add_attribute(name_cell, 'text', 1)
        self.tree.append_column(name_column)

        return widget
Esempio n. 10
0
 def set_column_widget(self,
                       column,
                       field,
                       attributes,
                       arrow=True,
                       align=0.5):
     hbox = gtk.HBox(False, 2)
     label = gtk.Label(attributes['string'])
     if field and self.editable:
         required = field.attrs.get('required')
         readonly = field.attrs.get('readonly')
         attrlist = common.get_label_attributes(readonly, required)
         label.set_attributes(attrlist)
         widget_class(label, 'readonly', readonly)
         widget_class(label, 'required', required)
     label.show()
     help = None
     if field and field.attrs.get('help'):
         help = field.attrs['help']
     elif attributes.get('help'):
         help = attributes['help']
     if help:
         tooltips = Tooltips()
         tooltips.set_tip(label, help)
         tooltips.enable()
     if arrow:
         arrow_widget = gtk.Arrow(gtk.ARROW_NONE, gtk.SHADOW_NONE)
         arrow_widget.show()
         column.arrow = arrow_widget
     hbox.pack_start(label, True, True, 0)
     if arrow:
         hbox.pack_start(arrow_widget, False, False, 0)
         column.set_clickable(True)
     hbox.show()
     column.set_widget(hbox)
     column.set_alignment(align)
Esempio n. 11
0
 def display(self):
     if not self.field:
         self._readonly_set(self.attrs.get('readonly', True))
         self.invisible_set(self.attrs.get('invisible', False))
         self._required_set(False)
         return
     states = self.field.get_state_attrs(self.record)
     readonly = self.attrs.get('readonly', states.get('readonly', False))
     if self.view.screen.readonly:
         readonly = True
     self._readonly_set(readonly)
     widget_class(self.widget, 'readonly', readonly)
     self._required_set(not readonly and states.get('required', False))
     widget_class(self._required_widget, 'required', not readonly
                  and states.get('required', False))
     invalid = states.get('invalid', False)
     widget_class(self._invalid_widget, 'invalid', not readonly and invalid)
     self.invisible_set(
         self.attrs.get('invisible', states.get('invisible', False)))
Esempio n. 12
0
 def _set_label_state(self):
     attrlist = common.get_label_attributes(self._readonly, self._required)
     self.title.set_attributes(attrlist)
     widget_class(self.title, 'readonly', self._readonly)
     widget_class(self.title, 'required', self._required)
Esempio n. 13
0
    def __init__(self, name, record, prints, template=None):
        super().__init__()
        self.record = record
        self.dialog = Gtk.Dialog(transient_for=self.parent,
                                 destroy_with_parent=True)
        Main().add_window(self.dialog)
        self.dialog.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)
        self.dialog.set_default_size(*self.default_size())
        self.dialog.connect('response', self.response)

        self.dialog.set_title(_('E-mail %s') % name)

        grid = Gtk.Grid(column_spacing=3, row_spacing=3, border_width=3)
        self.dialog.vbox.pack_start(grid, expand=True, fill=True, padding=0)

        label = Gtk.Label(set_underline(_("To:")),
                          use_underline=True,
                          halign=Gtk.Align.END)
        grid.attach(label, 0, 0, 1, 1)
        self.to = EmailEntry(hexpand=True, activates_default=True)
        widget_class(self.to, 'required', True)
        label.set_mnemonic_widget(self.to)
        grid.attach(self.to, 1, 0, 1, 1)

        label = Gtk.Label(set_underline(_("Cc:")),
                          use_underline=True,
                          halign=Gtk.Align.END)
        grid.attach(label, 0, 1, 1, 1)
        self.cc = EmailEntry(hexpand=True, activates_default=True)
        label.set_mnemonic_widget(self.cc)
        grid.attach(self.cc, 1, 1, 1, 1)

        label = Gtk.Label(set_underline(_("Bcc:")),
                          use_underline=True,
                          halign=Gtk.Align.END)
        grid.attach(label, 0, 2, 1, 1)
        self.bcc = EmailEntry(hexpand=True, activates_default=True)
        label.set_mnemonic_widget(self.bcc)
        grid.attach(self.bcc, 1, 2, 1, 1)

        label = Gtk.Label(set_underline(_("Subject:")),
                          use_underline=True,
                          halign=Gtk.Align.END)
        grid.attach(label, 0, 3, 1, 1)
        self.subject = Gtk.Entry(hexpand=True, activates_default=True)
        label.set_mnemonic_widget(self.subject)
        grid.attach(self.subject, 1, 3, 1, 1)

        self.body = Gtk.TextView()
        body_frame = Gtk.Frame()
        label = Gtk.Label(set_underline(_("Body")),
                          use_underline=True,
                          halign=Gtk.Align.END)
        label.set_mnemonic_widget(self.body)
        body_frame.set_label_widget(label)
        grid.attach(body_frame, 0, 4, 2, 1)
        body_box = Gtk.VBox(hexpand=True, vexpand=True)
        body_frame.add(body_box)
        register_format(self.body)
        body_toolbar = add_toolbar(self.body)
        body_box.pack_start(body_toolbar, expand=False, fill=True, padding=0)
        body_box.pack_start(self.body, expand=True, fill=True, padding=0)

        if GtkSpell and CONFIG['client.spellcheck']:
            checker = GtkSpell.Checker()
            checker.attach(self.body)
            language = os.environ.get('LANGUAGE', 'en')
            try:
                checker.set_language(language)
            except Exception:
                logger.error('Could not set spell checker for "%s"', language)
                checker.detach()

        attachments_box = Gtk.HBox()
        grid.attach(attachments_box, 0, 5, 2, 1)

        print_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.NONE)
        print_frame.set_label(_("Reports"))
        attachments_box.pack_start(print_frame,
                                   expand=True,
                                   fill=True,
                                   padding=0)
        print_box = Gtk.VBox()
        print_frame.add(print_box)
        print_flowbox = Gtk.FlowBox(selection_mode=Gtk.SelectionMode.NONE)
        print_box.pack_start(print_flowbox,
                             expand=False,
                             fill=False,
                             padding=0)
        self.print_actions = {}
        for print_ in prints:
            print_check = Gtk.CheckButton.new_with_mnemonic(
                set_underline(print_['name']))
            self.print_actions[print_['id']] = print_check
            print_flowbox.add(print_check)

        attachment_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.NONE)
        attachment_frame.set_label(_("Attachments"))
        attachments_box.pack_start(attachment_frame,
                                   expand=True,
                                   fill=True,
                                   padding=0)
        try:
            attachments = RPCExecute('model',
                                     'ir.attachment',
                                     'search_read', [
                                         ('resource', '=', '%s,%s' %
                                          (record.model_name, record.id)),
                                         [
                                             'OR',
                                             ('data', '!=', None),
                                             ('file_id', '!=', None),
                                         ],
                                     ],
                                     0,
                                     None,
                                     None, ['rec_name'],
                                     context=record.get_context())
        except RPCException:
            logger.error('Could not fetch attachment for "%s"', record)
            attachments = []
        scrolledwindow = Gtk.ScrolledWindow()
        if len(attachments) > 2:
            scrolledwindow.set_size_request(-1, 100)
        attachment_frame.add(scrolledwindow)
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
                                  Gtk.PolicyType.AUTOMATIC)
        self.attachments = TreeViewControl()
        self.attachments.set_headers_visible(False)
        scrolledwindow.add(self.attachments)
        self.attachments.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
        self.attachments.append_column(
            Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0))
        model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_INT)
        for attachment in attachments:
            model.append((attachment['rec_name'], attachment['id']))
        self.attachments.set_model(model)
        self.attachments.set_search_column(0)

        file_frame = Gtk.Frame(shadow_type=Gtk.ShadowType.NONE)
        file_frame.set_label(_("Files"))
        attachments_box.pack_start(file_frame,
                                   expand=True,
                                   fill=True,
                                   padding=0)
        self.files = Gtk.VBox(spacing=6)
        file_frame.add(self.files)
        self._add_file_button()

        button_cancel = self.dialog.add_button(set_underline(_("Cancel")),
                                               Gtk.ResponseType.CANCEL)
        button_cancel.set_image(
            IconFactory.get_image('tryton-cancel', Gtk.IconSize.BUTTON))

        button_send = self.dialog.add_button(set_underline(_("Send")),
                                             Gtk.ResponseType.OK)
        button_send.set_image(
            IconFactory.get_image('tryton-send', Gtk.IconSize.BUTTON))
        self.dialog.set_default_response(Gtk.ResponseType.OK)

        self._fill_with(template)

        self.dialog.show_all()
        self.register()
Esempio n. 14
0
    def __init__(self,
                 screen,
                 callback,
                 view_type='form',
                 new=False,
                 many=0,
                 domain=None,
                 context=None,
                 save_current=False,
                 title='',
                 rec_name=None):
        tooltips = common.Tooltips()
        NoModal.__init__(self)
        self.screen = screen
        self.callback = callback
        self.many = many
        self.domain = domain
        self.context = context
        self.save_current = save_current
        self.title = title
        self.prev_view = self.screen.current_view
        self.screen.screen_container.alternate_view = True
        self.screen.switch_view(view_type=view_type)
        if self.screen.current_view.view_type != view_type:
            self.destroy()
            return
        if new:
            self.screen.new(rec_name=rec_name)
        self.win = Gtk.Dialog(title=_('Link'),
                              transient_for=self.parent,
                              destroy_with_parent=True)
        Main().add_window(self.win)
        self.win.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_deletable(False)
        self.win.connect('delete-event', lambda *a: True)
        self.win.connect('close', self.close)
        self.win.connect('response', self.response)

        self.win.set_default_size(*self.default_size())

        self.accel_group = Gtk.AccelGroup()
        self.win.add_accel_group(self.accel_group)

        readonly = self.screen.readonly or self.screen.group.readonly

        self.but_ok = None
        self.but_new = None

        self._initial_value = None
        if view_type == 'form':
            if new:
                label, icon = _("Delete"), 'tryton-delete'
            else:
                label, icon = _("Cancel"), 'tryton-cancel'
                self._initial_value = self.screen.current_record.get_eval()
            self.but_cancel = self.win.add_button(set_underline(label),
                                                  Gtk.ResponseType.CANCEL)
            self.but_cancel.set_image(
                common.IconFactory.get_image(icon, Gtk.IconSize.BUTTON))
            self.but_cancel.set_always_show_image(True)

        if new and self.many:
            self.but_new = self.win.add_button(set_underline(_("New")),
                                               Gtk.ResponseType.ACCEPT)
            self.but_new.set_image(
                common.IconFactory.get_image('tryton-create',
                                             Gtk.IconSize.BUTTON))
            self.but_new.set_always_show_image(True)
            self.but_new.set_accel_path('<tryton>/Form/New', self.accel_group)

        if self.save_current:
            self.but_ok = Gtk.Button(label=_('_Save'), use_underline=True)
            self.but_ok.set_image(
                common.IconFactory.get_image('tryton-save',
                                             Gtk.IconSize.BUTTON))
            self.but_ok.set_always_show_image(True)
            self.but_ok.set_accel_path('<tryton>/Form/Save', self.accel_group)
            self.but_ok.set_can_default(True)
            self.but_ok.show()
            self.win.add_action_widget(self.but_ok, Gtk.ResponseType.OK)
            if not new:
                self.but_ok.props.sensitive = False
        else:
            self.but_ok = self.win.add_button(set_underline(_("OK")),
                                              Gtk.ResponseType.OK)
            self.but_ok.set_image(
                common.IconFactory.get_image('tryton-ok', Gtk.IconSize.BUTTON))
            self.but_ok.set_always_show_image(True)
        self.but_ok.add_accelerator('clicked', self.accel_group,
                                    Gdk.KEY_Return,
                                    Gdk.ModifierType.CONTROL_MASK,
                                    Gtk.AccelFlags.VISIBLE)
        self.win.set_default_response(Gtk.ResponseType.OK)

        self.win.set_title(self.title)

        title = Gtk.Label(label=common.ellipsize(self.title, 80),
                          halign=Gtk.Align.START,
                          margin=5,
                          ellipsize=Pango.EllipsizeMode.END)
        tooltips.set_tip(title, self.title)
        title.set_size_request(0, -1)  # Allow overflow
        title.show()

        hbox = Gtk.HBox()
        hbox.pack_start(title, expand=True, fill=True, padding=0)
        hbox.show()

        frame = Gtk.Frame()
        frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        widget_class(frame, 'window-title', True)
        frame.add(hbox)
        frame.show()

        self.win.vbox.pack_start(frame, expand=False, fill=True, padding=3)

        if view_type == 'tree':
            hbox = Gtk.HBox(homogeneous=False, spacing=0)
            hbox.set_halign(Gtk.Align.END)
            access = common.MODELACCESS[screen.model_name]

            but_switch = Gtk.Button()
            tooltips.set_tip(but_switch, _('Switch'))
            but_switch.connect('clicked', self.switch_view)
            but_switch.add(
                common.IconFactory.get_image('tryton-switch',
                                             Gtk.IconSize.SMALL_TOOLBAR))
            but_switch.set_relief(Gtk.ReliefStyle.NONE)
            hbox.pack_start(but_switch, expand=False, fill=False, padding=0)

            self.but_pre = Gtk.Button()
            tooltips.set_tip(self.but_pre, _('Previous'))
            self.but_pre.connect('clicked', self._sig_previous)
            self.but_pre.add(
                common.IconFactory.get_image('tryton-back',
                                             Gtk.IconSize.SMALL_TOOLBAR))
            self.but_pre.set_relief(Gtk.ReliefStyle.NONE)
            hbox.pack_start(self.but_pre, expand=False, fill=False, padding=0)

            self.label = Gtk.Label(label='(0,0)')
            hbox.pack_start(self.label, expand=False, fill=False, padding=0)

            self.but_next = Gtk.Button()
            tooltips.set_tip(self.but_next, _('Next'))
            self.but_next.connect('clicked', self._sig_next)
            self.but_next.add(
                common.IconFactory.get_image('tryton-forward',
                                             Gtk.IconSize.SMALL_TOOLBAR))
            self.but_next.set_relief(Gtk.ReliefStyle.NONE)
            hbox.pack_start(self.but_next, expand=False, fill=False, padding=0)

            hbox.pack_start(Gtk.VSeparator(),
                            expand=False,
                            fill=True,
                            padding=0)

            if domain is not None:
                self.wid_text = Gtk.Entry()
                self.wid_text.set_property('width_chars', 13)
                self.wid_text.connect('activate', self._sig_activate)
                self.wid_text.connect('focus-out-event', self._focus_out)
                hbox.pack_start(self.wid_text,
                                expand=True,
                                fill=True,
                                padding=0)

                self.but_add = Gtk.Button()
                tooltips.set_tip(self.but_add, _('Add'))
                self.but_add.connect('clicked', self._sig_add)
                self.but_add.add(
                    common.IconFactory.get_image('tryton-add',
                                                 Gtk.IconSize.SMALL_TOOLBAR))
                self.but_add.set_relief(Gtk.ReliefStyle.NONE)
                hbox.pack_start(self.but_add,
                                expand=False,
                                fill=False,
                                padding=0)
                if not access['read'] or readonly:
                    self.but_add.set_sensitive(False)

                self.but_remove = Gtk.Button()
                tooltips.set_tip(self.but_remove, _('Remove <Del>'))
                self.but_remove.connect('clicked', self._sig_remove, True)
                self.but_remove.add(
                    common.IconFactory.get_image('tryton-remove',
                                                 Gtk.IconSize.SMALL_TOOLBAR))
                self.but_remove.set_relief(Gtk.ReliefStyle.NONE)
                hbox.pack_start(self.but_remove,
                                expand=False,
                                fill=False,
                                padding=0)
                if not access['read'] or readonly:
                    self.but_remove.set_sensitive(False)

                hbox.pack_start(Gtk.VSeparator(),
                                expand=False,
                                fill=True,
                                padding=0)

            self.but_new = Gtk.Button()
            tooltips.set_tip(self.but_new, _('Create a new record <F3>'))
            self.but_new.connect('clicked', self._sig_new)
            self.but_new.add(
                common.IconFactory.get_image('tryton-create',
                                             Gtk.IconSize.SMALL_TOOLBAR))
            self.but_new.set_relief(Gtk.ReliefStyle.NONE)
            hbox.pack_start(self.but_new, expand=False, fill=False, padding=0)
            if not access['create'] or readonly:
                self.but_new.set_sensitive(False)

            self.but_del = Gtk.Button()
            tooltips.set_tip(self.but_del, _('Delete selected record <Del>'))
            self.but_del.connect('clicked', self._sig_remove, False)
            self.but_del.add(
                common.IconFactory.get_image('tryton-delete',
                                             Gtk.IconSize.SMALL_TOOLBAR))
            self.but_del.set_relief(Gtk.ReliefStyle.NONE)
            hbox.pack_start(self.but_del, expand=False, fill=False, padding=0)
            if not access['delete'] or readonly:
                self.but_del.set_sensitive(False)

            self.but_undel = Gtk.Button()
            tooltips.set_tip(self.but_undel,
                             _('Undelete selected record <Ins>'))
            self.but_undel.connect('clicked', self._sig_undelete)
            self.but_undel.add(
                common.IconFactory.get_image('tryton-undo',
                                             Gtk.IconSize.SMALL_TOOLBAR))
            self.but_undel.set_relief(Gtk.ReliefStyle.NONE)
            hbox.pack_start(self.but_undel,
                            expand=False,
                            fill=False,
                            padding=0)
            if not access['delete'] or readonly:
                self.but_undel.set_sensitive(False)

            but_switch.props.sensitive = screen.number_of_views > 1

            tooltips.enable()
            hbox.show_all()

            self.win.vbox.pack_start(hbox, expand=False, fill=True, padding=0)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll.set_placement(Gtk.CornerType.TOP_LEFT)
        scroll.set_shadow_type(Gtk.ShadowType.NONE)
        scroll.show()
        self.win.vbox.pack_start(scroll, expand=True, fill=True, padding=0)

        scroll.add(self.screen.screen_container.alternate_viewport)

        self.create_info_bar()
        self.win.vbox.pack_start(self.info_bar,
                                 expand=False,
                                 fill=True,
                                 padding=0)

        if view_type == 'tree':
            self.screen.signal_connect(self, 'record-message', self._sig_label)
            self.screen.screen_container.alternate_viewport.connect(
                'key-press-event', self.on_keypress)

        if self.save_current and not new:
            self.screen.signal_connect(self, 'record-message',
                                       self.activate_save)
            self.screen.signal_connect(self, 'record-modified',
                                       self.activate_save)

        self.register()
        self.show()

        self.screen.display()
        self.screen.current_view.set_cursor()