def __init__(self): # GTK Stuffs self.parent = common.get_toplevel_window() self.dialog = gtk.Dialog(title=_('Login'), parent=self.parent, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.dialog.set_icon(TRYTON_ICON) tooltips = common.Tooltips() button_cancel = gtk.Button(_('_Cancel'), use_underline=True) img_cancel = gtk.Image() img_cancel.set_from_stock('gtk-cancel', gtk.ICON_SIZE_BUTTON) button_cancel.set_image(img_cancel) tooltips.set_tip(button_cancel, _('Cancel connection to the Tryton server')) self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL) self.button_connect = gtk.Button(_('C_onnect'), use_underline=True) img_connect = gtk.Image() img_connect.set_from_stock('tryton-connect', gtk.ICON_SIZE_BUTTON) self.button_connect.set_image(img_connect) self.button_connect.set_can_default(True) tooltips.set_tip(self.button_connect, _('Connect the Tryton server')) self.dialog.add_action_widget(self.button_connect, gtk.RESPONSE_OK) self.dialog.set_default_response(gtk.RESPONSE_OK) alignment = gtk.Alignment(yalign=0, yscale=0, xscale=1) self.table_main = gtk.Table(3, 3, False) self.table_main.set_border_width(0) self.table_main.set_row_spacings(3) self.table_main.set_col_spacings(3) alignment.add(self.table_main) self.dialog.vbox.pack_start(alignment, True, True, 0) image = gtk.Image() image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png')) image.set_alignment(0.5, 1) ebox = gtk.EventBox() ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019")) ebox.add(image) self.table_main.attach(ebox, 0, 3, 0, 1, ypadding=2) self.profile_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) self.combo_profile = gtk.ComboBox() cell = gtk.CellRendererText() self.combo_profile.pack_start(cell, True) self.combo_profile.add_attribute(cell, 'text', 0) self.combo_profile.add_attribute(cell, 'sensitive', 1) self.combo_profile.set_model(self.profile_store) self.combo_profile.connect('changed', self.profile_changed) self.profile_label = gtk.Label(_(u'Profile:')) self.profile_label.set_justify(gtk.JUSTIFY_RIGHT) self.profile_label.set_alignment(1, 0.5) self.profile_label.set_padding(3, 3) self.profile_button = gtk.Button(_('_Manage profiles'), use_underline=True) self.profile_button.connect('clicked', self.profile_manage) self.table_main.attach(self.profile_label, 0, 1, 1, 2, xoptions=gtk.FILL) self.table_main.attach(self.combo_profile, 1, 2, 1, 2) self.table_main.attach(self.profile_button, 2, 3, 1, 2, xoptions=gtk.FILL) image = gtk.Image() image.set_from_stock('gtk-edit', gtk.ICON_SIZE_BUTTON) self.profile_button.set_image(image) self.expander = gtk.Expander() self.expander.set_label(_('Host / Database information')) self.expander.connect('notify::expanded', self.expand_hostspec) self.table_main.attach(self.expander, 0, 3, 3, 4) self.label_host = gtk.Label(_('Host:')) self.label_host.set_justify(gtk.JUSTIFY_RIGHT) self.label_host.set_alignment(1, 0.5) self.label_host.set_padding(3, 3) self.entry_host = gtk.Entry() self.entry_host.connect_after('focus-out-event', self.clear_profile_combo) self.entry_host.set_activates_default(True) self.label_host.set_mnemonic_widget(self.entry_host) self.table_main.attach(self.label_host, 0, 1, 4, 5, xoptions=gtk.FILL) self.table_main.attach(self.entry_host, 1, 3, 4, 5) self.label_database = gtk.Label(_('Database:')) self.label_database.set_justify(gtk.JUSTIFY_RIGHT) self.label_database.set_alignment(1, 0.5) self.label_database.set_padding(3, 3) self.entry_database = gtk.Entry() self.entry_database.connect_after('focus-out-event', self.clear_profile_combo) self.entry_database.set_activates_default(True) self.label_database.set_mnemonic_widget(self.entry_database) self.table_main.attach(self.label_database, 0, 1, 5, 6, xoptions=gtk.FILL) self.table_main.attach(self.entry_database, 1, 3, 5, 6) self.entry_login = gtk.Entry() self.entry_login.set_activates_default(True) self.table_main.attach(self.entry_login, 1, 3, 6, 7) label_username = gtk.Label(_("User name:")) label_username.set_alignment(1, 0.5) label_username.set_padding(3, 3) label_username.set_mnemonic_widget(self.entry_login) self.table_main.attach(label_username, 0, 1, 6, 7, xoptions=gtk.FILL) # Profile informations self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg') self.profiles = ConfigParser.SafeConfigParser({'port': '8000'}) if not os.path.exists(self.profile_cfg): short_version = '.'.join(__version__.split('.', 2)[:2]) name = 'demo%s.tryton.org' % short_version self.profiles.add_section(name) self.profiles.set(name, 'host', name) self.profiles.set(name, 'port', '8000') self.profiles.set(name, 'database', 'demo%s' % short_version) self.profiles.set(name, 'username', 'demo') else: self.profiles.read(self.profile_cfg) for section in self.profiles.sections(): active = all( self.profiles.has_option(section, option) for option in ('host', 'port', 'database')) self.profile_store.append([section, active])
def do_activate(self): if self.window: self.window.present() return self.window = Gtk.ApplicationWindow(application=self, title="Tryton") self.window.set_default_size(960, 720) self.window.maximize() self.window.set_position(Gtk.WindowPosition.CENTER) self.window.set_resizable(True) self.window.set_icon(TRYTON_ICON) self.window.connect("destroy", self.on_quit) self.window.connect("delete_event", self.on_quit) self.header = Gtk.HeaderBar.new() self.header.set_show_close_button(True) self.window.set_titlebar(self.header) self.set_title() menu = Gtk.Button.new() menu.set_relief(Gtk.ReliefStyle.NONE) menu.set_image( common.IconFactory.get_image('tryton-menu', Gtk.IconSize.BUTTON)) menu.connect('clicked', self.menu_toggle) self.header.pack_start(menu) favorite = Gtk.MenuButton.new() favorite.set_relief(Gtk.ReliefStyle.NONE) favorite.set_image( common.IconFactory.get_image('tryton-bookmarks', Gtk.IconSize.BUTTON)) self.menu_favorite = Gtk.Menu.new() favorite.set_popup(self.menu_favorite) favorite.connect('clicked', self.favorite_set) self.header.pack_start(favorite) self.set_global_search() self.header.pack_start(self.global_search_entry) self.accel_group = Gtk.AccelGroup() self.window.add_accel_group(self.accel_group) Gtk.AccelMap.add_entry('<tryton>/Form/New', Gdk.KEY_N, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Save', Gdk.KEY_S, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry( '<tryton>/Form/Duplicate', Gdk.KEY_D, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Delete', Gdk.KEY_D, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Next', Gdk.KEY_Page_Down, 0) Gtk.AccelMap.add_entry('<tryton>/Form/Previous', Gdk.KEY_Page_Up, 0) Gtk.AccelMap.add_entry('<tryton>/Form/Switch View', Gdk.KEY_L, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Close', Gdk.KEY_W, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Reload', Gdk.KEY_R, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry( '<tryton>/Form/Attachments', Gdk.KEY_T, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK) Gtk.AccelMap.add_entry( '<tryton>/Form/Notes', Gdk.KEY_O, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK) Gtk.AccelMap.add_entry( '<tryton>/Form/Relate', Gdk.KEY_R, Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Actions', Gdk.KEY_E, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Report', Gdk.KEY_P, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.add_entry('<tryton>/Form/Search', Gdk.KEY_F, Gdk.ModifierType.CONTROL_MASK) Gtk.AccelMap.load(os.path.join(get_config_dir(), 'accel.map')) self.tooltips = common.Tooltips() self.vbox = Gtk.VBox() self.window.add(self.vbox) self.buttons = {} self.info = Gtk.VBox() self.vbox.pack_start(self.info, expand=False, fill=True, padding=0) if CONFIG['client.check_version']: common.check_version(self.info) GLib.timeout_add_seconds(int(CONFIG['download.frequency']), common.check_version, self.info) self.pane = Gtk.HPaned() self.vbox.pack_start(self.pane, expand=True, fill=True, padding=0) self.pane.set_position(int(CONFIG['menu.pane'])) self.menu_screen = None self.menu = Gtk.VBox() self.menu.set_vexpand(True) self.pane.add1(self.menu) self.notebook = Gtk.Notebook() self.notebook.popup_enable() self.notebook.set_scrollable(True) self.notebook.connect_after('switch-page', self._sig_page_changt) self.pane.add2(self.notebook) self.window.show_all() self.pages = [] self.previous_pages = {} self.current_page = 0 self.last_page = 0 self.dialogs = [] self._global_run = False self._global_check_timeout_id = None self._global_update_timeout_id = None # Register plugins tryton.plugins.register() self.set_title() # Adds username/profile while password is asked try: common.Login() except Exception as exception: if (not isinstance(exception, TrytonError) or exception.faultCode != 'QueryCanceled'): common.error(exception, traceback.format_exc()) return self.quit() self.get_preferences()
def __init__(self, view, attrs): super(One2Many, self).__init__(view, attrs) self.widget = Gtk.Frame() self.widget.set_shadow_type(Gtk.ShadowType.NONE) self.widget.get_accessible().set_name(attrs.get('string', '')) vbox = Gtk.VBox(homogeneous=False, spacing=2) self.widget.add(vbox) self._readonly = True self._required = False self._position = 0 self._length = 0 self.title_box = hbox = Gtk.HBox(homogeneous=False, spacing=0) hbox.set_border_width(2) self.title = Gtk.Label(label=set_underline(attrs.get('string', '')), use_underline=True, halign=Gtk.Align.START) hbox.pack_start(self.title, expand=True, fill=True, padding=0) hbox.pack_start(Gtk.VSeparator(), expand=False, fill=True, padding=0) tooltips = common.Tooltips() but_switch = Gtk.Button(can_focus=False) 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(can_focus=False) 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(can_focus=False) 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) self.focus_out = True self.wid_completion = None if attrs.get('add_remove'): self.wid_text = Gtk.Entry() self.wid_text.set_placeholder_text(_('Search')) self.wid_text.set_property('width_chars', 13) self.wid_text.connect('focus-out-event', self._focus_out) hbox.pack_start(self.wid_text, expand=True, fill=True, padding=0) if int(self.attrs.get('completion', 1)): access = common.MODELACCESS[attrs['relation']] self.wid_completion = get_completion( search=access['read'] and access['write'], create=attrs.get('create', True) and access['create']) self.wid_completion.connect('match-selected', self._completion_match_selected) self.wid_completion.connect('action-activated', self._completion_action_activated) self.wid_text.set_completion(self.wid_completion) self.wid_text.connect('changed', self._update_completion) self.but_add = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_add, _('Add existing record')) 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) self.but_remove = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_remove, _('Remove selected record')) 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) hbox.pack_start(Gtk.VSeparator(), expand=False, fill=True, padding=0) self.but_new = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_new, _('Create a new record')) 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) self.but_open = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_open, _('Edit selected record')) self.but_open.connect('clicked', self._sig_edit) self.but_open.add( common.IconFactory.get_image('tryton-open', Gtk.IconSize.SMALL_TOOLBAR)) self.but_open.set_relief(Gtk.ReliefStyle.NONE) hbox.pack_start(self.but_open, expand=False, fill=False, padding=0) self.but_del = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_del, _('Delete selected record')) 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) self.but_undel = Gtk.Button(can_focus=False) 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) tooltips.enable() frame = Gtk.Frame() frame.add(hbox) frame.set_shadow_type(Gtk.ShadowType.OUT) vbox.pack_start(frame, expand=False, fill=True, padding=0) self.screen = Screen(attrs['relation'], mode=attrs.get('mode', 'tree,form').split(','), view_ids=attrs.get('view_ids', '').split(','), views_preload=attrs.get('views', {}), row_activate=self._on_activate, exclude_field=attrs.get('relation_field', None), limit=None) self.screen.pre_validate = bool(int(attrs.get('pre_validate', 0))) self.screen.signal_connect(self, 'record-message', self._sig_label) vbox.pack_start(self.screen.widget, expand=True, fill=True, padding=0) self.title.set_mnemonic_widget( self.screen.current_view.mnemonic_widget) self.screen.widget.connect('key_press_event', self.on_keypress) if self.attrs.get('add_remove'): self.wid_text.connect('key_press_event', self.on_keypress) but_switch.props.sensitive = self.screen.number_of_views > 1
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('delete-event', self.delete_event) 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()
def __init__(self, view, attrs): super(One2Many, self).__init__(view, attrs) self.widget = gtk.Frame() self.widget.set_shadow_type(gtk.SHADOW_NONE) self.widget.get_accessible().set_name(attrs.get('string', '')) vbox = gtk.VBox(homogeneous=False, spacing=2) self.widget.add(vbox) self._readonly = True self._required = False self._position = 0 self._length = 0 self.title_box = hbox = gtk.HBox(homogeneous=False, spacing=0) hbox.set_border_width(2) self.title = gtk.Label(set_underline(attrs.get('string', ''))) self.title.set_use_underline(True) self.title.set_alignment(0.0, 0.5) hbox.pack_start(self.title, expand=True, fill=True) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) tooltips = common.Tooltips() but_switch = gtk.Button() tooltips.set_tip(but_switch, _('Switch')) but_switch.connect('clicked', self.switch_view) img_switch = gtk.Image() img_switch.set_from_stock('tryton-fullscreen', gtk.ICON_SIZE_SMALL_TOOLBAR) img_switch.set_alignment(0.5, 0.5) but_switch.add(img_switch) but_switch.set_relief(gtk.RELIEF_NONE) hbox.pack_start(but_switch, expand=False, fill=False) self.but_pre = gtk.Button() tooltips.set_tip(self.but_pre, _('Previous')) self.but_pre.connect('clicked', self._sig_previous) img_pre = gtk.Image() img_pre.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_SMALL_TOOLBAR) img_pre.set_alignment(0.5, 0.5) self.but_pre.add(img_pre) self.but_pre.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_pre, expand=False, fill=False) self.label = gtk.Label('(0,0)') hbox.pack_start(self.label, expand=False, fill=False) self.but_next = gtk.Button() tooltips.set_tip(self.but_next, _('Next')) self.but_next.connect('clicked', self._sig_next) img_next = gtk.Image() img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_SMALL_TOOLBAR) img_next.set_alignment(0.5, 0.5) self.but_next.add(img_next) self.but_next.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_next, expand=False, fill=False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) self.focus_out = True self.wid_completion = None if attrs.get('add_remove'): self.wid_text = PlaceholderEntry() self.wid_text.set_placeholder_text(_('Search')) self.wid_text.set_property('width_chars', 13) self.wid_text.connect('focus-out-event', self._focus_out) hbox.pack_start(self.wid_text, expand=True, fill=True) if int(self.attrs.get('completion', 1)): access = common.MODELACCESS[attrs['relation']] self.wid_completion = get_completion( search=access['read'] and access['write'], create=attrs.get('create', True) and access['create']) self.wid_completion.connect('match-selected', self._completion_match_selected) self.wid_completion.connect('action-activated', self._completion_action_activated) self.wid_text.set_completion(self.wid_completion) self.wid_text.connect('changed', self._update_completion) self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add existing record')) self.but_add.connect('clicked', self._sig_add) img_add = gtk.Image() img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR) img_add.set_alignment(0.5, 0.5) self.but_add.add(img_add) self.but_add.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_add, expand=False, fill=False) self.but_remove = gtk.Button() tooltips.set_tip(self.but_remove, _('Remove selected record')) self.but_remove.connect('clicked', self._sig_remove, True) img_remove = gtk.Image() img_remove.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_SMALL_TOOLBAR) img_remove.set_alignment(0.5, 0.5) self.but_remove.add(img_remove) self.but_remove.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_remove, expand=False, fill=False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) self.but_new = gtk.Button() tooltips.set_tip(self.but_new, _('Create a new record <F3>')) self.but_new.connect('clicked', self._sig_new) img_new = gtk.Image() img_new.set_from_stock('tryton-new', gtk.ICON_SIZE_SMALL_TOOLBAR) img_new.set_alignment(0.5, 0.5) self.but_new.add(img_new) self.but_new.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_new, expand=False, fill=False) self.but_open = gtk.Button() tooltips.set_tip(self.but_open, _('Edit selected record <F2>')) self.but_open.connect('clicked', self._sig_edit) img_open = gtk.Image() img_open.set_from_stock('tryton-open', gtk.ICON_SIZE_SMALL_TOOLBAR) img_open.set_alignment(0.5, 0.5) self.but_open.add(img_open) self.but_open.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_open, expand=False, fill=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) img_del = gtk.Image() img_del.set_from_stock('tryton-delete', gtk.ICON_SIZE_SMALL_TOOLBAR) img_del.set_alignment(0.5, 0.5) self.but_del.add(img_del) self.but_del.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_del, expand=False, fill=False) self.but_undel = gtk.Button() tooltips.set_tip(self.but_undel, _('Undelete selected record <Ins>')) self.but_undel.connect('clicked', self._sig_undelete) img_undel = gtk.Image() img_undel.set_from_stock('tryton-undo', gtk.ICON_SIZE_SMALL_TOOLBAR) img_undel.set_alignment(0.5, 0.5) self.but_undel.add(img_undel) self.but_undel.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_undel, expand=False, fill=False) if attrs.get('add_remove'): hbox.set_focus_chain([self.wid_text]) else: hbox.set_focus_chain([]) tooltips.enable() frame = gtk.Frame() frame.add(hbox) frame.set_shadow_type(gtk.SHADOW_OUT) vbox.pack_start(frame, expand=False, fill=True) self.screen = Screen(attrs['relation'], mode=attrs.get('mode', 'tree,form').split(','), view_ids=attrs.get('view_ids', '').split(','), views_preload=attrs.get('views', {}), row_activate=self._on_activate, exclude_field=attrs.get('relation_field', None), limit=None) self.screen.pre_validate = bool(int(attrs.get('pre_validate', 0))) self.screen.signal_connect(self, 'record-message', self._sig_label) vbox.pack_start(self.screen.widget, expand=True, fill=True) self.title.set_mnemonic_widget( self.screen.current_view.mnemonic_widget) self.screen.widget.connect('key_press_event', self.on_keypress) if self.attrs.get('add_remove'): self.wid_text.connect('key_press_event', self.on_keypress) but_switch.props.sensitive = self.screen.number_of_views > 1
def __init__(self, view, attrs): super(Many2Many, self).__init__(view, attrs) self.widget = gtk.Frame() self.widget.set_shadow_type(gtk.SHADOW_NONE) self.widget.get_accessible().set_name(attrs.get('string', '')) vbox = gtk.VBox(homogeneous=False, spacing=5) self.widget.add(vbox) self._readonly = True self._required = False self._position = 0 hbox = gtk.HBox(homogeneous=False, spacing=0) hbox.set_border_width(2) self.title = gtk.Label(attrs.get('string', '')) self.title.set_alignment(0.0, 0.5) hbox.pack_start(self.title, expand=True, fill=True) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) tooltips = common.Tooltips() self.wid_text = PlaceholderEntry() self.wid_text.set_placeholder_text(_('Search')) self.wid_text.set_property('width_chars', 13) self.wid_text.connect('focus-out-event', lambda *a: self._focus_out()) self.focus_out = True hbox.pack_start(self.wid_text, expand=True, fill=True) if int(self.attrs.get('completion', 1)): self.wid_completion = get_completion( create=self.attrs.get('create', True) and common.MODELACCESS[self.attrs['relation']]['create']) self.wid_completion.connect('match-selected', self._completion_match_selected) self.wid_completion.connect('action-activated', self._completion_action_activated) self.wid_text.set_completion(self.wid_completion) self.wid_text.connect('changed', self._update_completion) else: self.wid_completion = None self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add existing record')) self.but_add.connect('clicked', self._sig_add) img_add = gtk.Image() img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR) img_add.set_alignment(0.5, 0.5) self.but_add.add(img_add) self.but_add.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_add, expand=False, fill=False) self.but_remove = gtk.Button() tooltips.set_tip(self.but_remove, _('Remove selected record <Del>')) self.but_remove.connect('clicked', self._sig_remove) img_remove = gtk.Image() img_remove.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_SMALL_TOOLBAR) img_remove.set_alignment(0.5, 0.5) self.but_remove.add(img_remove) self.but_remove.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_remove, expand=False, fill=False) hbox.set_focus_chain([self.wid_text]) tooltips.enable() frame = gtk.Frame() frame.add(hbox) frame.set_shadow_type(gtk.SHADOW_OUT) vbox.pack_start(frame, expand=False, fill=True) self.screen = Screen(attrs['relation'], view_ids=attrs.get('view_ids', '').split(','), mode=['tree'], views_preload=attrs.get('views', {}), row_activate=self._on_activate, limit=None) self.screen.signal_connect(self, 'record-message', self._sig_label) vbox.pack_start(self.screen.widget, expand=True, fill=True) self.screen.widget.connect('key_press_event', self.on_keypress) self.wid_text.connect('key_press_event', self.on_keypress)
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 if view_type not in (x.view_type for x in self.screen.views) and \ view_type not in self.screen.view_to_load: self.screen.add_view_id(None, view_type) self.screen.switch_view(view_type=view_type) if new: self.screen.new(rec_name=rec_name) self.win = gtk.Dialog(_('Link'), self.parent, gtk.DIALOG_DESTROY_WITH_PARENT) Main().add_window(self.win) self.win.set_position(gtk.WIN_POS_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) allocation = self.parent.get_allocation() width, height, = allocation.width, allocation.height if self.parent != self.sensible_widget: width = max(width - 150, 0) height = max(height - 150, 0) self.win.set_default_size(width, height) 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: stock_id = gtk.STOCK_DELETE else: stock_id = gtk.STOCK_CANCEL self._initial_value = self.screen.current_record.get_eval() self.but_cancel = self.win.add_button(stock_id, gtk.RESPONSE_CANCEL) self.but_cancel.set_always_show_image(True) if new and self.many: self.but_new = self.win.add_button(gtk.STOCK_NEW, gtk.RESPONSE_ACCEPT) 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(_('_Save'), use_underline=True) img_save = gtk.Image() img_save.set_from_stock('tryton-save', gtk.ICON_SIZE_BUTTON) self.but_ok.set_image(img_save) 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.RESPONSE_OK) if not new: self.but_ok.props.sensitive = False else: self.but_ok = self.win.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) self.but_ok.set_always_show_image(True) self.but_ok.add_accelerator('clicked', self.accel_group, gtk.keysyms.Return, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) self.win.set_default_response(gtk.RESPONSE_OK) self.win.set_title(self.title) title = gtk.Label() title.modify_font(pango.FontDescription("bold 12")) title.set_label(common.ellipsize(self.title, 80)) tooltips.set_tip(title, self.title) title.set_padding(20, 3) title.set_alignment(0.0, 0.5) title.set_size_request(0, -1) # Allow overflow title.set_max_width_chars(1) title.set_ellipsize(pango.ELLIPSIZE_END) title.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000")) title.show() hbox = gtk.HBox() hbox.pack_start(title, expand=True, fill=True) hbox.show() frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_ETCHED_IN) frame.add(hbox) frame.show() eb = gtk.EventBox() eb.add(frame) eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff")) eb.show() self.win.vbox.pack_start(eb, expand=False, fill=True, padding=3) if view_type == 'tree': hbox = gtk.HBox(homogeneous=False, spacing=0) access = common.MODELACCESS[screen.model_name] 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) self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add')) self.but_add.connect('clicked', self._sig_add) img_add = gtk.Image() img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR) img_add.set_alignment(0.5, 0.5) self.but_add.add(img_add) self.but_add.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_add, expand=False, fill=False) 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) img_remove = gtk.Image() img_remove.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_SMALL_TOOLBAR) img_remove.set_alignment(0.5, 0.5) self.but_remove.add(img_remove) self.but_remove.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_remove, expand=False, fill=False) if not access['read'] or readonly: self.but_remove.set_sensitive(False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) self.but_new = gtk.Button() tooltips.set_tip(self.but_new, _('Create a new record <F3>')) self.but_new.connect('clicked', self._sig_new) img_new = gtk.Image() img_new.set_from_stock('tryton-new', gtk.ICON_SIZE_SMALL_TOOLBAR) img_new.set_alignment(0.5, 0.5) self.but_new.add(img_new) self.but_new.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_new, expand=False, fill=False) 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) img_del = gtk.Image() img_del.set_from_stock('tryton-delete', gtk.ICON_SIZE_SMALL_TOOLBAR) img_del.set_alignment(0.5, 0.5) self.but_del.add(img_del) self.but_del.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_del, expand=False, fill=False) 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) img_undel = gtk.Image() img_undel.set_from_stock('tryton-undo', gtk.ICON_SIZE_SMALL_TOOLBAR) img_undel.set_alignment(0.5, 0.5) self.but_undel.add(img_undel) self.but_undel.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_undel, expand=False, fill=False) if not access['delete'] or readonly: self.but_undel.set_sensitive(False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) self.but_pre = gtk.Button() tooltips.set_tip(self.but_pre, _('Previous')) self.but_pre.connect('clicked', self._sig_previous) img_pre = gtk.Image() img_pre.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_SMALL_TOOLBAR) img_pre.set_alignment(0.5, 0.5) self.but_pre.add(img_pre) self.but_pre.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_pre, expand=False, fill=False) self.label = gtk.Label('(0,0)') hbox.pack_start(self.label, expand=False, fill=False) self.but_next = gtk.Button() tooltips.set_tip(self.but_next, _('Next')) self.but_next.connect('clicked', self._sig_next) img_next = gtk.Image() img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_SMALL_TOOLBAR) img_next.set_alignment(0.5, 0.5) self.but_next.add(img_next) self.but_next.set_relief(gtk.RELIEF_NONE) hbox.pack_start(self.but_next, expand=False, fill=False) hbox.pack_start(gtk.VSeparator(), expand=False, fill=True) but_switch = gtk.Button() tooltips.set_tip(but_switch, _('Switch')) but_switch.connect('clicked', self.switch_view) img_switch = gtk.Image() img_switch.set_from_stock('tryton-fullscreen', gtk.ICON_SIZE_SMALL_TOOLBAR) img_switch.set_alignment(0.5, 0.5) but_switch.add(img_switch) but_switch.set_relief(gtk.RELIEF_NONE) hbox.pack_start(but_switch, expand=False, fill=False) but_switch.props.sensitive = screen.number_of_views > 1 tooltips.enable() alignment = gtk.Alignment(1.0) alignment.add(hbox) alignment.show_all() self.win.vbox.pack_start(alignment, expand=False, fill=True) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.set_placement(gtk.CORNER_TOP_LEFT) scroll.set_shadow_type(gtk.SHADOW_NONE) scroll.show() self.win.vbox.pack_start(scroll, expand=True, fill=True) scroll.add(self.screen.screen_container.alternate_viewport) self.create_info_bar() self.win.vbox.pack_start(self.info_bar, False, True) 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()
def __init__(self, tab_domain): self.viewport = gtk.Viewport() self.viewport.set_shadow_type(gtk.SHADOW_NONE) self.vbox = gtk.VBox(spacing=3) self.alternate_viewport = gtk.Viewport() self.alternate_viewport.set_shadow_type(gtk.SHADOW_NONE) self.alternate_view = False self.search_window = None self.search_table = None self.last_search_text = '' self.tab_domain = tab_domain or [] tooltips = common.Tooltips() self.filter_vbox = gtk.VBox(spacing=0) self.filter_vbox.set_border_width(0) hbox = gtk.HBox(homogeneous=False, spacing=0) self.filter_button = gtk.ToggleButton() self.filter_button.set_use_underline(True) self.filter_button.set_label(_('F_ilters')) self.filter_button.set_relief(gtk.RELIEF_NONE) self.filter_button.set_alignment(0.0, 0.5) self.filter_button.connect('toggled', self.search_box) hbox.pack_start(self.filter_button, expand=False, fill=False) self.search_entry = PlaceholderEntry() self.search_entry.set_placeholder_text(_('Search')) self.search_entry.set_alignment(0.0) self.completion = gtk.EntryCompletion() self.completion.set_model(gtk.ListStore(str)) self.completion.set_text_column(0) self.completion.props.inline_selection = True self.completion.props.popup_set_width = False self.completion.set_match_func(lambda *a: True) self.completion.connect('match-selected', self.match_selected) self.search_entry.connect('activate', self.activate) self.search_entry.set_completion(self.completion) self.search_entry.connect('key-press-event', self.key_press) self.search_entry.connect('focus-in-event', self.focus_in) self.search_entry.connect('icon-press', self.icon_press) hbox.pack_start(self.search_entry, expand=True, fill=True) def popup(widget): menu = widget._menu for child in menu.children(): menu.remove(child) if not widget.props.active: menu.popdown() return def menu_position(menu): x, y = widget.window.get_origin() widget_allocation = widget.get_allocation() return (widget_allocation.x + x, widget_allocation.y + widget_allocation.height + y, False) for id_, name, domain in self.bookmarks(): menuitem = gtk.MenuItem(name) menuitem.connect('activate', self.bookmark_activate, domain) menu.add(menuitem) menu.show_all() menu.popup(None, None, menu_position, 0, 0) def deactivate(menuitem, togglebutton): togglebutton.props.active = False but_bookmark = gtk.ToggleButton() self.but_bookmark = but_bookmark tooltips.set_tip(but_bookmark, _('Show bookmarks of filters')) img_bookmark = gtk.Image() img_bookmark.set_from_stock('tryton-bookmark', gtk.ICON_SIZE_SMALL_TOOLBAR) img_bookmark.set_alignment(0.5, 0.5) but_bookmark.add(img_bookmark) but_bookmark.set_relief(gtk.RELIEF_NONE) menu = gtk.Menu() menu.set_property('reserve-toggle-size', False) menu.connect('deactivate', deactivate, but_bookmark) but_bookmark._menu = menu but_bookmark.connect('toggled', popup) hbox.pack_start(but_bookmark, expand=False, fill=False) but_prev = gtk.Button() self.but_prev = but_prev tooltips.set_tip(but_prev, _('Previous')) but_prev.connect('clicked', self.search_prev) img_prev = gtk.Image() img_prev.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_SMALL_TOOLBAR) img_prev.set_alignment(0.5, 0.5) but_prev.add(img_prev) but_prev.set_relief(gtk.RELIEF_NONE) hbox.pack_start(but_prev, expand=False, fill=False) but_next = gtk.Button() self.but_next = but_next tooltips.set_tip(but_next, _('Next')) but_next.connect('clicked', self.search_next) img_next = gtk.Image() img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_SMALL_TOOLBAR) img_next.set_alignment(0.5, 0.5) but_next.add(img_next) but_next.set_relief(gtk.RELIEF_NONE) hbox.pack_start(but_next, expand=False, fill=False) hbox.show_all() hbox.set_focus_chain([self.search_entry]) self.filter_vbox.pack_start(hbox, expand=False, fill=False) hseparator = gtk.HSeparator() hseparator.show() self.filter_vbox.pack_start(hseparator, expand=False, fill=False) if self.tab_domain: self.notebook = gtk.Notebook() self.notebook.props.homogeneous = True self.notebook.set_scrollable(True) for name, domain in self.tab_domain: label = gtk.Label('_' + name) label.set_use_underline(True) self.notebook.append_page(gtk.VBox(), label) self.filter_vbox.pack_start(self.notebook, expand=True, fill=True) self.notebook.show_all() # Set the current page before connecting to switch-page to not # trigger the search a second times. self.notebook.set_current_page(0) self.notebook.get_nth_page(0).pack_end(self.viewport) self.notebook.connect('switch-page', self.switch_page) self.notebook.connect_after('switch-page', self.switch_page_after) filter_expand = True else: self.notebook = None self.vbox.pack_end(self.viewport) filter_expand = False self.vbox.pack_start(self.filter_vbox, expand=filter_expand, fill=True) self.but_next.set_sensitive(False) self.but_prev.set_sensitive(False) tooltips.enable()
def __init__(self, widget, languages, readonly): NoModal.__init__(self) self.widget = widget self.win = Gtk.Dialog(title=_('Translation'), 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.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) cancel_button = self.win.add_button(set_underline(_("Cancel")), Gtk.ResponseType.CANCEL) cancel_button.set_image( common.IconFactory.get_image('tryton-cancel', Gtk.IconSize.BUTTON)) cancel_button.set_always_show_image(True) ok_button = self.win.add_button(set_underline(_("OK")), Gtk.ResponseType.OK) ok_button.set_image( common.IconFactory.get_image('tryton-ok', Gtk.IconSize.BUTTON)) ok_button.set_always_show_image(True) ok_button.add_accelerator('clicked', self.accel_group, Gdk.KEY_Return, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) tooltips = common.Tooltips() self.widgets = {} grid = Gtk.Grid(column_spacing=3, row_spacing=3) for i, language in enumerate(languages): label = language['name'] + _(':') label = Gtk.Label(label=label, halign=Gtk.Align.END, valign=(Gtk.Align.START if self.widget.expand else Gtk.Align.FILL)) grid.attach(label, 0, i, 1, 1) context = dict( language=language['code'], fuzzy_translation=False, ) try: value = RPCExecute('model', self.widget.record.model_name, 'read', [self.widget.record.id], [self.widget.field_name], context={'language': language['code'] })[0][self.widget.field_name] except RPCException: return context['fuzzy_translation'] = True try: fuzzy_value = RPCExecute( 'model', self.widget.record.model_name, 'read', [self.widget.record.id], [self.widget.field_name], context=context)[0][self.widget.field_name] except RPCException: return if fuzzy_value is None: fuzzy_value = '' widget = self.widget.translate_widget() label.set_mnemonic_widget(widget) self.widget.translate_widget_set(widget, fuzzy_value) self.widget.translate_widget_set_readonly(widget, True) widget.set_vexpand(self.widget.expand) widget.set_hexpand(True) grid.attach(widget, 1, i, 1, 1) editing = Gtk.CheckButton() editing.connect('toggled', self.editing_toggled, widget) editing.props.sensitive = not readonly tooltips.set_tip(editing, _('Edit')) grid.attach(editing, 2, i, 1, 1) fuzzy = Gtk.CheckButton() fuzzy.set_active(value != fuzzy_value) fuzzy.props.sensitive = False tooltips.set_tip(fuzzy, _('Fuzzy')) grid.attach(fuzzy, 4, i, 1, 1) self.widgets[language['code']] = (widget, editing, fuzzy) tooltips.enable() vbox = Gtk.VBox() vbox.pack_start(grid, expand=self.widget.expand, fill=True, padding=0) viewport = Gtk.Viewport() viewport.set_shadow_type(Gtk.ShadowType.NONE) viewport.add(vbox) scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_shadow_type(Gtk.ShadowType.NONE) scrolledwindow.add(viewport) self.win.vbox.pack_start(scrolledwindow, expand=True, fill=True, padding=0) self.win.show_all() self.register() self.show()
def __init__(self, host=None, port=None, sig_login=None): self.host = host self.port = port # GTK Stuffs self.dialog = gtk.Dialog(title=_("Create new database"), flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.WIN_POS_CENTER_ON_PARENT) self.dialog.set_has_separator(True) self.dialog.set_icon(TRYTON_ICON) # This event is needed for controlling the button_create self.dialog.connect("key-press-event", self.event_show_button_create) self.tooltips = common.Tooltips() self.dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL) self.button_create = gtk.Button(_('C_reate')) self.button_create.set_flags(gtk.CAN_DEFAULT) self.button_create.set_flags(gtk.HAS_DEFAULT) self.button_create.set_sensitive(False) img_connect = gtk.Image() img_connect.set_from_stock('tryton-new', gtk.ICON_SIZE_BUTTON) self.button_create.set_image(img_connect) self.tooltips.set_tip(self.button_create, _('Create the new database.')) self.dialog.add_action_widget(self.button_create, gtk.RESPONSE_OK) self.dialog.set_default_response(gtk.RESPONSE_OK) dialog_vbox = gtk.VBox() table = gtk.Table(9, 3, False) table.set_border_width(10) table.set_row_spacings(3) table.set_col_spacings(3) self.label_server_setup = gtk.Label() self.label_server_setup.set_markup("<b>" + _("Server Setup:") + "</b>") self.label_server_setup.set_justify(gtk.JUSTIFY_LEFT) self.label_server_setup.set_alignment(0, 1) self.label_server_setup.set_padding(9, 5) table.attach(self.label_server_setup, 0, 3, 0, 1, xoptions=gtk.FILL) self.label_server = gtk.Label(_("Server connection:")) self.label_server.set_alignment(1, 0.5) self.label_server.set_padding(3, 3) table.attach(self.label_server, 0, 1, 1, 2, xoptions=gtk.FILL) self.entry_server_connection = gtk.Entry() self.entry_server_connection.set_sensitive(False) self.entry_server_connection.unset_flags(gtk.CAN_FOCUS) self.entry_server_connection.set_editable(False) self.tooltips.set_tip( self.entry_server_connection, _("This is the URL of the server. Use server 'localhost' and port " "'8000' if the server is installed on this computer. Click on " "'Change' to change the address.")) self.button_server_change = gtk.Button(_("C_hange"), stock=None, use_underline=True) img_button_server_change = gtk.Image() img_button_server_change.set_from_stock('tryton-preferences-system', gtk.ICON_SIZE_BUTTON) self.button_server_change.set_image(img_button_server_change) table.attach(self.button_server_change, 2, 3, 1, 2, yoptions=False, xoptions=gtk.FILL) self.tooltips.set_tip(self.button_server_change, _("Setup the server connection...")) table.attach(self.entry_server_connection, 1, 2, 1, 2) self.label_serverpasswd = gtk.Label(_("Tryton Server Password:"******"This is the " "password of the Tryton server. It doesn't belong to a " "real user. This password is usually defined in the trytond " "configuration.")) self.entry_serverpasswd.connect("key-press-event", self.event_passwd_clear) self.hseparator = gtk.HSeparator() table.attach(self.hseparator, 0, 3, 3, 4, yoptions=gtk.FILL) label_dbname = gtk.Label() label_dbname.set_markup("<b>" + _("New database setup:") + "</b>") label_dbname.set_justify(gtk.JUSTIFY_LEFT) label_dbname.set_alignment(0, 1) label_dbname.set_padding(9, 5) table.attach(label_dbname, 0, 3, 4, 5, xoptions=gtk.FILL, yoptions=gtk.FILL) label_dbname = gtk.Label(_("Database name:")) label_dbname.set_justify(gtk.JUSTIFY_RIGHT) label_dbname.set_padding(3, 3) label_dbname.set_alignment(1, 0.5) table.attach(label_dbname, 0, 1, 5, 6, xoptions=gtk.FILL, yoptions=gtk.FILL) self.entry_dbname = gtk.Entry() self.entry_dbname.set_max_length(63) self.entry_dbname.set_width_chars(16) self.entry_dbname.set_activates_default(True) table.attach(self.entry_dbname, 1, 3, 5, 6, yoptions=gtk.FILL) self.tooltips.set_tip( self.entry_dbname, _("Choose the name of the new database.\n" "Allowed characters are alphanumerical or _ (underscore)\n" "You need to avoid all accents, space or special characters! " "Example: tryton")) handlerid = self.entry_dbname.connect("insert-text", self.entry_insert_text) self.entry_dbname.set_data('handlerid', handlerid) label_language = gtk.Label(_("Default language:")) label_language.set_justify(gtk.JUSTIFY_RIGHT) label_language.set_alignment(1, 0.5) label_language.set_padding(3, 3) table.attach(label_language, 0, 1, 6, 7, xoptions=gtk.FILL, yoptions=gtk.FILL) eventbox_language = gtk.EventBox() self.combo_language = gtk.combo_box_new_text() eventbox_language.add(self.combo_language) table.attach(eventbox_language, 1, 3, 6, 7, yoptions=gtk.FILL) self.tooltips.set_tip( eventbox_language, _("Choose the default " "language that will be installed for this database. You will " "be able to install new languages after installation through " "the administration menu.")) label_adminpasswd = gtk.Label(_("Admin password:"******"Choose a password for the admin user of the new database. " "With these credentials you will be later able to login into " "the database:\n" "User name: admin\n" "Password: <The password you set here>")) table.attach(self.entry_adminpasswd, 1, 3, 7, 8, yoptions=gtk.FILL) self.entry_adminpasswd.connect("key-press-event", self.event_passwd_clear) label_adminpasswd2 = gtk.Label(_("Confirm admin password:"******"Type the Admin " "password again")) table.attach(self.entry_adminpasswd2, 1, 3, 8, 9, yoptions=gtk.FILL) self.entry_adminpasswd2.connect("key-press-event", self.event_passwd_clear) self.entry_serverpasswd.grab_focus() dialog_vbox.pack_start(table) self.dialog.vbox.pack_start(dialog_vbox) self.sig_login = sig_login
def __init__(self, view, attrs): super(Many2Many, self).__init__(view, attrs) self.widget = Gtk.Frame() self.widget.set_shadow_type(Gtk.ShadowType.NONE) self.widget.get_accessible().set_name(attrs.get('string', '')) vbox = Gtk.VBox(homogeneous=False, spacing=5) self.widget.add(vbox) self._readonly = True self._required = False self._position = 0 hbox = Gtk.HBox(homogeneous=False, spacing=0) hbox.set_border_width(2) self.title = Gtk.Label(label=set_underline(attrs.get('string', '')), use_underline=True, halign=Gtk.Align.START) hbox.pack_start(self.title, expand=True, fill=True, padding=0) hbox.pack_start(Gtk.VSeparator(), expand=False, fill=True, padding=0) tooltips = common.Tooltips() self.wid_text = Gtk.Entry() self.wid_text.set_placeholder_text(_('Search')) self.wid_text.set_property('width_chars', 13) self.wid_text.connect('focus-out-event', self._focus_out) self.focus_out = True hbox.pack_start(self.wid_text, expand=True, fill=True, padding=0) if int(self.attrs.get('completion', 1)): self.wid_completion = get_completion( create=self.attrs.get('create', True) and common.MODELACCESS[self.attrs['relation']]['create']) self.wid_completion.connect('match-selected', self._completion_match_selected) self.wid_completion.connect('action-activated', self._completion_action_activated) self.wid_text.set_completion(self.wid_completion) self.wid_text.connect('changed', self._update_completion) else: self.wid_completion = None self.but_add = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_add, _('Add existing record')) 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) self.but_remove = Gtk.Button(can_focus=False) tooltips.set_tip(self.but_remove, _('Remove selected record')) self.but_remove.connect('clicked', self._sig_remove) 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) tooltips.enable() frame = Gtk.Frame() frame.add(hbox) frame.set_shadow_type(Gtk.ShadowType.OUT) vbox.pack_start(frame, expand=False, fill=True, padding=0) self.screen = Screen(attrs['relation'], view_ids=attrs.get('view_ids', '').split(','), mode=['tree'], views_preload=attrs.get('views', {}), row_activate=self._on_activate, limit=None) self.screen.signal_connect(self, 'record-message', self._sig_label) vbox.pack_start(self.screen.widget, expand=True, fill=True, padding=0) self.title.set_mnemonic_widget( self.screen.current_view.mnemonic_widget) self.screen.widget.connect('key_press_event', self.on_keypress) self.wid_text.connect('key_press_event', self.on_keypress)
def __init__(self, widget, languages, readonly): NoModal.__init__(self) self.widget = widget self.win = gtk.Dialog(_('Translation'), self.parent, gtk.DIALOG_DESTROY_WITH_PARENT) Main().add_window(self.win) self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.win.set_icon(TRYTON_ICON) self.win.connect('response', self.response) parent_allocation = self.parent.get_allocation() self.win.set_default_size(-1, min(400, parent_allocation.height)) self.accel_group = gtk.AccelGroup() self.win.add_accel_group(self.accel_group) cancel_button = self.win.add_button(set_underline(_("Cancel")), gtk.RESPONSE_CANCEL) cancel_button.set_image( common.IconFactory.get_image('tryton-cancel', gtk.ICON_SIZE_BUTTON)) cancel_button.set_always_show_image(True) ok_button = self.win.add_button(set_underline(_("OK")), gtk.RESPONSE_OK) ok_button.set_image( common.IconFactory.get_image('tryton-ok', gtk.ICON_SIZE_BUTTON)) ok_button.set_always_show_image(True) ok_button.add_accelerator('clicked', self.accel_group, gtk.keysyms.Return, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) tooltips = common.Tooltips() self.widgets = {} table = gtk.Table(len(languages), 4) table.set_homogeneous(False) table.set_col_spacings(3) table.set_row_spacings(2) table.set_border_width(1) for i, language in enumerate(languages): if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL: label = _(':') + language['name'] else: label = language['name'] + _(':') label = gtk.Label(label) label.set_alignment(1.0, 0.0 if self.widget.expand else 0.5) table.attach(label, 0, 1, i, i + 1, xoptions=gtk.FILL, xpadding=2) context = dict( language=language['code'], fuzzy_translation=False, ) try: value = RPCExecute('model', self.widget.record.model_name, 'read', [self.widget.record.id], [self.widget.field_name], context={'language': language['code'] })[0][self.widget.field_name] except RPCException: return context['fuzzy_translation'] = True try: fuzzy_value = RPCExecute( 'model', self.widget.record.model_name, 'read', [self.widget.record.id], [self.widget.field_name], context=context)[0][self.widget.field_name] except RPCException: return widget = self.widget.translate_widget() label.set_mnemonic_widget(widget) self.widget.translate_widget_set(widget, fuzzy_value) self.widget.translate_widget_set_readonly(widget, True) yopt = 0 if self.widget.expand: yopt = gtk.EXPAND | gtk.FILL table.attach(widget, 1, 2, i, i + 1, yoptions=yopt) editing = gtk.CheckButton() editing.connect('toggled', self.editing_toggled, widget) editing.props.sensitive = not readonly tooltips.set_tip(editing, _('Edit')) table.attach(editing, 2, 3, i, i + 1, xoptions=gtk.FILL) fuzzy = gtk.CheckButton() fuzzy.set_active(value != fuzzy_value) fuzzy.props.sensitive = False tooltips.set_tip(fuzzy, _('Fuzzy')) table.attach(fuzzy, 4, 5, i, i + 1, xoptions=gtk.FILL) self.widgets[language['code']] = (widget, editing, fuzzy) tooltips.enable() vbox = gtk.VBox() vbox.pack_start(table, self.widget.expand, True) viewport = gtk.Viewport() viewport.set_shadow_type(gtk.SHADOW_NONE) viewport.add(vbox) scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolledwindow.set_shadow_type(gtk.SHADOW_NONE) scrolledwindow.add(viewport) self.win.vbox.pack_start(scrolledwindow, True, True) self.win.show_all() self.register() self.show()
def __init__(self, tab_domain): self.viewport = Gtk.Viewport() self.viewport.set_shadow_type(Gtk.ShadowType.NONE) self.vbox = Gtk.VBox(spacing=3) self.alternate_viewport = Gtk.Viewport() self.alternate_viewport.set_shadow_type(Gtk.ShadowType.NONE) self.alternate_view = False self.search_popover = None self.search_grid = None self.last_search_text = '' self.tab_domain = tab_domain or [] self.tab_counter = [] tooltips = common.Tooltips() self.filter_vbox = Gtk.VBox(spacing=0) self.filter_vbox.set_border_width(0) hbox = Gtk.HBox(homogeneous=False, spacing=0) self.search_entry = Gtk.Entry() self.search_entry.set_placeholder_text(_('Search')) self.search_entry.set_alignment(0.0) self.search_entry.set_icon_from_pixbuf( Gtk.EntryIconPosition.PRIMARY, common.IconFactory.get_pixbuf('tryton-filter', Gtk.IconSize.MENU)) self.search_entry.set_icon_tooltip_text( Gtk.EntryIconPosition.PRIMARY, _('Open filters')) self.completion = Gtk.EntryCompletion() self.completion.set_model(Gtk.ListStore(str)) self.completion.set_text_column(0) self.completion.props.inline_selection = True self.completion.props.popup_set_width = False self.completion.set_match_func(lambda *a: True) self.completion.connect('match-selected', self.match_selected) self.search_entry.connect('activate', self.activate) self.search_entry.set_completion(self.completion) self.search_entry.connect('key-press-event', self.key_press) self.search_entry.connect('focus-in-event', self.focus_in) self.search_entry.connect('icon-press', self.icon_press) hbox.pack_start(self.search_entry, expand=True, fill=True, padding=0) def popup(widget): menu = widget._menu for child in menu.get_children(): menu.remove(child) if not widget.props.active: menu.popdown() return def menu_position(menu, data=None): widget_allocation = widget.get_allocation() x, y = widget.get_window().get_root_coords( widget_allocation.x, widget_allocation.y) return (x, y + widget_allocation.height, False) for id_, name, domain in self.bookmarks(): menuitem = Gtk.MenuItem(label=name) menuitem.connect('activate', self.bookmark_activate, domain) menu.add(menuitem) menu.show_all() if hasattr(menu, 'popup_at_widget'): menu.popup_at_widget( widget, Gdk.Gravity.SOUTH_WEST, Gdk.Gravity.NORTH_WEST, Gtk.get_current_event()) else: menu.popup(None, None, menu_position, 0, 0) def deactivate(menuitem, togglebutton): togglebutton.props.active = False but_bookmark = Gtk.ToggleButton() self.but_bookmark = but_bookmark tooltips.set_tip(but_bookmark, _('Show bookmarks of filters')) but_bookmark.add(common.IconFactory.get_image( 'tryton-bookmarks', Gtk.IconSize.SMALL_TOOLBAR)) but_bookmark.set_relief(Gtk.ReliefStyle.NONE) menu = Gtk.Menu() menu.set_property('reserve-toggle-size', False) menu.connect('deactivate', deactivate, but_bookmark) but_bookmark._menu = menu but_bookmark.connect('toggled', popup) hbox.pack_start(but_bookmark, expand=False, fill=False, padding=0) but_active = Gtk.ToggleButton() self.but_active = but_active self._set_active_tooltip() but_active.add(common.IconFactory.get_image( 'tryton-archive', Gtk.IconSize.SMALL_TOOLBAR)) but_active.set_relief(Gtk.ReliefStyle.NONE) but_active.connect('toggled', self.search_active) hbox.pack_start(but_active, expand=False, fill=False, padding=0) but_prev = Gtk.Button() self.but_prev = but_prev tooltips.set_tip(but_prev, _('Previous')) but_prev.connect('clicked', self.search_prev) but_prev.add(common.IconFactory.get_image( 'tryton-back', Gtk.IconSize.SMALL_TOOLBAR)) but_prev.set_relief(Gtk.ReliefStyle.NONE) hbox.pack_start(but_prev, expand=False, fill=False, padding=0) but_next = Gtk.Button() self.but_next = but_next tooltips.set_tip(but_next, _('Next')) but_next.connect('clicked', self.search_next) but_next.add(common.IconFactory.get_image( 'tryton-forward', Gtk.IconSize.SMALL_TOOLBAR)) but_next.set_relief(Gtk.ReliefStyle.NONE) hbox.pack_start(but_next, expand=False, fill=False, padding=0) hbox.show_all() self.filter_vbox.pack_start(hbox, expand=False, fill=False, padding=0) hseparator = Gtk.HSeparator() hseparator.show() self.filter_vbox.pack_start( hseparator, expand=False, fill=False, padding=0) if self.tab_domain: self.notebook = Gtk.Notebook() try: self.notebook.props.homogeneous = True except AttributeError: # No more supported by GTK+3 pass self.notebook.set_scrollable(True) for name, domain, count in self.tab_domain: hbox = Gtk.HBox(spacing=3) label = Gtk.Label(label='_' + name) label.set_use_underline(True) hbox.pack_start(label, expand=True, fill=True, padding=0) counter = Gtk.Label() hbox.pack_start(counter, expand=False, fill=True, padding=0) hbox.show_all() self.notebook.append_page(Gtk.VBox(), hbox) self.tab_counter.append(counter) self.filter_vbox.pack_start( self.notebook, expand=True, fill=True, padding=0) self.notebook.show_all() # Set the current page before connecting to switch-page to not # trigger the search a second times. self.notebook.set_current_page(0) self.notebook.get_nth_page(0).pack_end( self.viewport, expand=True, fill=True, padding=0) self.notebook.connect('switch-page', self.switch_page) self.notebook.connect_after('switch-page', self.switch_page_after) filter_expand = True else: self.notebook = None self.vbox.pack_end( self.viewport, expand=True, fill=True, padding=0) filter_expand = False self.vbox.pack_start( self.filter_vbox, expand=filter_expand, fill=True, padding=0) self.but_next.set_sensitive(False) self.but_prev.set_sensitive(False) tooltips.enable()