def __init__(self): short_version = '.'.join(__version__.split('.', 2)[:2]) demo_server = 'demo%s.tryton.org' % short_version demo_database = 'demo%s' % short_version self.defaults = { 'login.profile': demo_server, 'login.login': '******', 'login.host': demo_server, 'login.db': demo_database, 'login.expanded': False, 'client.title': 'Tryton', 'client.default_width': 900, 'client.default_height': 750, 'client.modepda': False, 'client.toolbar': 'default', 'client.maximize': False, 'client.save_width_height': True, 'client.save_tree_state': True, 'client.fast_tabbing': True, 'client.spellcheck': False, 'client.lang': locale.getdefaultlocale()[0], 'client.language_direction': 'ltr', 'client.email': '', 'client.can_change_accelerators': False, 'client.limit': 1000, 'roundup.url': 'http://bugs.tryton.org/', 'roundup.xmlrpc': 'roundup-xmlrpc.tryton.org', 'menu.pane': 200, 'menu.expanded': True, } self.config = {} self.options = {} self.arguments = []
def __init__(self): short_version = '.'.join(__version__.split('.', 2)[:2]) demo_server = 'demo%s.tryton.org' % short_version demo_database = 'demo%s' % short_version self.defaults = { 'login.profile': demo_server, 'login.login': '******', 'login.host': demo_server, 'login.db': demo_database, 'login.expanded': False, 'client.title': 'Tryton', 'client.modepda': False, 'client.toolbar': 'default', 'client.save_width_height': True, 'client.save_tree_state': True, 'client.fast_tabbing': True, 'client.spellcheck': False, 'client.lang': locale.getdefaultlocale()[0], 'client.language_direction': 'ltr', 'client.email': '', 'client.limit': 1000, 'client.check_version': True, 'client.bus_timeout': 10 * 60, 'icon.color': '#3465a4', 'image.max_size': 10 ** 6, 'roundup.url': 'http://bugs.tryton.org/', 'roundup.xmlrpc': 'roundup-xmlrpc.tryton.org', 'download.url': 'https://downloads.tryton.org/', 'download.frequency': 60 * 60 * 8, 'menu.pane': 200, } self.config = {} self.options = {} self.arguments = []
def __init__(self): short_version = '.'.join(__version__.split('.', 2)[:2]) demo_server = 'health.gnusolidario.org' demo_database = '' self.defaults = { 'login.profile': demo_server, 'login.login': '******', 'login.host': demo_server, 'login.db': demo_database, 'login.expanded': True, 'client.title': 'GNU Health', 'client.toolbar': 'default', 'client.maximize': False, 'client.save_width_height': True, 'client.save_tree_state': True, 'client.spellcheck': False, 'client.lang': locale.getdefaultlocale()[0], 'client.language_direction': 'ltr', 'client.email': '', 'client.can_change_accelerators': False, 'client.limit': 1000, 'client.bus_timeout': 10 * 60, 'icon.colors': '#11b0b8', 'image.max_size': 10**6, 'client.cli_position': 'top', 'menu.pane': 200, 'menu.expanded': True, } self.config = {} self.options = {} self.arguments = []
def __init__(self): short_version = '.'.join(__version__.split('.', 2)[:2]) demo_server = 'demo%s.tryton.org' % short_version demo_database = 'demo%s' % short_version self.defaults = { 'login.profile': demo_server, 'login.login': '******', 'login.host': demo_server, 'login.db': demo_database, 'login.expanded': False, 'client.title': 'Tryton', 'client.modepda': False, 'client.toolbar': 'default', 'client.save_tree_width': True, 'client.save_tree_state': True, 'client.spellcheck': False, 'client.lang': locale.getdefaultlocale()[0], 'client.language_direction': 'ltr', 'client.email': '', 'client.limit': 1000, 'client.check_version': True, 'client.bus_timeout': 10 * 60, 'icon.colors': '#3465a4,#555753,#cc0000', 'tree.colors': '#777,#dff0d8,#fcf8e3,#f2dede', 'calendar.colors': '#fff,#3465a4', 'graph.color': '#3465a4', 'image.max_size': 10**6, 'bug.url': 'https://bugs.tryton.org/', 'download.url': 'https://downloads-cdn.tryton.org/', 'download.frequency': 60 * 60 * 8, 'menu.pane': 200, } self.config = {} self.options = {} self.arguments = []
def test_server_version(cls, host, port): ''' Tests if the server version is compatible with the client version It returns None if no information on server version is available. ''' version = rpc.server_version(host, port) if not version: return None return version.split('.')[:2] == __version__.split('.')[:2]
def __init__(self): short_version = '.'.join(__version__.split('.', 2)[:2]) demo_server = 'demo%s.tryton.org' % short_version demo_database = 'demo%s' % short_version self.defaults = { 'login.profile': demo_server, 'login.login': '******', 'login.server': demo_server, 'login.port': '8000', 'login.db': demo_database, 'login.expanded': False, 'login.date': False, 'tip.autostart': False, 'tip.position': 0, 'form.toolbar': True, 'client.default_width': 900, 'client.default_height': 750, 'client.modepda': False, 'client.toolbar': 'default', 'client.maximize': False, 'client.save_width_height': True, 'client.save_tree_state': True, 'client.fast_tabbing': True, 'client.spellcheck': False, 'client.lang': locale.getdefaultlocale()[0], 'client.language_direction': 'ltr', 'client.email': '', 'client.can_change_accelerators': False, 'client.limit': 1000, 'roundup.url': 'http://bugs.tryton.org/', 'roundup.xmlrpc': 'roundup-xmlrpc.tryton.org', 'menu.pane': 200, 'menu.expanded': True, 'sentry.dsn': None, 'sentry.homepage': 'http://app.getsentry.com', } self.config = {} self.options = { 'login.host': True } self.arguments = []
def __init__(self): short_version = '.'.join(__version__.split('.', 2)[:2]) demo_server = 'health.gnusolidario.org' demo_database = 'health%s' % short_version self.defaults = { 'login.profile': demo_server, 'login.login': '******', 'login.server': demo_server, 'login.port': '8000', 'login.db': demo_database, 'login.expanded': False, 'tip.autostart': False, 'tip.position': 0, 'form.toolbar': True, 'client.title': 'GNU Health', 'client.default_width': 900, 'client.default_height': 750, 'client.modepda': False, 'client.toolbar': 'default', 'client.maximize': False, 'client.save_width_height': True, 'client.save_tree_state': True, 'client.fast_tabbing': True, 'client.spellcheck': False, 'client.lang': locale.getdefaultlocale()[0], 'client.language_direction': 'ltr', 'client.email': '', 'client.can_change_accelerators': False, 'client.limit': 1000, 'menu.pane': 200, 'menu.expanded': True, } self.config = {} self.options = { 'login.host': True } self.arguments = []
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(GNUHEALTH_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 GNU Health 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 GNU Health 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() # Use custom banner if set in the custom_banner param if (CONFIG['client.banner']): image.set_from_file(CONFIG['client.banner']) else: image.set_from_file(os.path.join(PIXMAPS_DIR, BANNER)) 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 = 'health.gnusolidario.org' self.profiles.add_section(name) self.profiles.set(name, 'host', name) self.profiles.set(name, 'port', '8000') self.profiles.set(name, 'database', 'health32') self.profiles.set(name, 'username', 'admin') 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 __init__(self): # Fake windows to avoid warning about Dialog without transient self._window = Gtk.Window() self.dialog = Gtk.Dialog(title="Tryton - " + _('Login'), modal=True) self.dialog.set_transient_for(self._window) self.dialog.set_icon(TRYTON_ICON) self.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.dialog.set_resizable(False) tooltips = common.Tooltips() button_cancel = Gtk.Button(label=_('_Cancel'), use_underline=True) tooltips.set_tip(button_cancel, _('Cancel connection to the Tryton server')) self.dialog.add_action_widget(button_cancel, Gtk.ResponseType.CANCEL) self.button_connect = Gtk.Button(label=_('C_onnect'), use_underline=True) self.button_connect.get_style_context().add_class( Gtk.STYLE_CLASS_SUGGESTED_ACTION) 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.ResponseType.OK) self.dialog.set_default_response(Gtk.ResponseType.OK) alignment = Gtk.Alignment(yalign=0, yscale=0, xscale=1) grid = Gtk.Grid(column_spacing=3, row_spacing=3) alignment.add(grid) self.dialog.vbox.pack_start(alignment, expand=True, fill=True, padding=0) image = Gtk.Image() image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png')) image.set_valign(Gtk.Align.START) overlay = Gtk.Overlay() overlay.add(image) label = Gtk.Label(label='<span color="white">%s</span>' % __version__, use_markup=True) label.props.halign = Gtk.Align.END label.props.valign = Gtk.Align.START label.props.margin_right = 10 label.props.margin_top = 5 overlay.add_overlay(label) grid.attach(overlay, 0, 0, 3, 1) self.profile_store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_BOOLEAN) self.combo_profile = Gtk.ComboBox(hexpand=True) cell = Gtk.CellRendererText() self.combo_profile.pack_start(cell, expand=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(label=set_underline(_('Profile:')), use_underline=True, halign=Gtk.Align.END) self.profile_label.set_mnemonic_widget(self.combo_profile) self.profile_button = Gtk.Button(label=set_underline(_('Manage...')), use_underline=True) self.profile_button.connect('clicked', self.profile_manage) grid.attach(self.profile_label, 0, 1, 1, 1) grid.attach(self.combo_profile, 1, 1, 1, 1) grid.attach(self.profile_button, 2, 1, 1, 1) self.expander = Gtk.Expander() self.expander.set_label(_('Host / Database information')) self.expander.connect('notify::expanded', self.expand_hostspec) grid.attach(self.expander, 0, 2, 3, 1) self.label_host = Gtk.Label(label=set_underline(_('Host:')), use_underline=True, halign=Gtk.Align.END) self.entry_host = Gtk.Entry(hexpand=True) 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) grid.attach(self.label_host, 0, 3, 1, 1) grid.attach(self.entry_host, 1, 3, 2, 1) self.label_database = Gtk.Label(label=set_underline(_('Database:')), use_underline=True, halign=Gtk.Align.END) self.entry_database = Gtk.Entry(hexpand=True) 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) grid.attach(self.label_database, 0, 4, 1, 1) grid.attach(self.entry_database, 1, 4, 2, 1) self.entry_login = Gtk.Entry(hexpand=True) self.entry_login.set_activates_default(True) grid.attach(self.entry_login, 1, 5, 2, 1) label_username = Gtk.Label(label=set_underline(_("User name:")), use_underline=True, halign=Gtk.Align.END, margin=3) label_username.set_mnemonic_widget(self.entry_login) grid.attach(label_username, 0, 5, 1, 1) # Date stuff if CONFIG['login.date']: self.label_date = Gtk.Label(label=set_underline(_("Date:")), use_underline=True, halign=Gtk.Align.END) grid.attach(self.label_date, 0, 6, 1, 1) self.entry_date = Date() self.entry_date.props.format = '%d/%m/%Y' self.entry_date.props.value = datetime.date.today() grid.attach(self.entry_date, 1, 6, 2, 1) # Profile information self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg') self.profiles = configparser.ConfigParser() 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, 'database', 'demo%s' % short_version) self.profiles.set(name, 'username', 'demo') else: try: self.profiles.read(self.profile_cfg) except configparser.ParsingError: logger.error("Fail to parse profiles.cfg", exc_info=True) for section in self.profiles.sections(): active = all( self.profiles.has_option(section, option) for option in ('host', 'database')) self.profile_store.append([section, active])
def __init__(self): # Fake windows to avoid warning about Dialog without transient self._window = gtk.Window() self.dialog = gtk.Dialog(title=_('Login'), flags=gtk.DIALOG_MODAL) self.dialog.set_transient_for(self._window) self.dialog.set_icon(TRYTON_ICON) self.dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS) tooltips = common.Tooltips() button_cancel = gtk.Button(_('_Cancel'), use_underline=True) 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) self.button_connect.get_style_context().add_class( Gtk.STYLE_CLASS_SUGGESTED_ACTION) 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(set_underline(_('Profile:'))) self.profile_label.set_use_underline(True) 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_label.set_mnemonic_widget(self.combo_profile) self.profile_button = gtk.Button(set_underline(_('Manage...')), 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) 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(set_underline(_('Host:'))) self.label_host.set_use_underline(True) 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(set_underline(_('Database:'))) self.label_database.set_use_underline(True) 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(set_underline(_("User name:"))) label_username.set_use_underline(True) 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) # Date stuff if CONFIG['login.date']: self.label_date = gtk.Label() self.label_date.set_text('Date:') self.label_date.set_justify(gtk.JUSTIFY_RIGHT) self.label_date.set_alignment(1, .5) self.label_date.set_padding(3, 3) self.table_main.attach(self.label_date, 0, 1, 8, 9, xoptions=gtk.FILL) self.entry_date = Date() self.entry_date.props.format = '%d/%m/%Y' self.entry_date.props.value = datetime.date.today() self.table_main.attach(self.entry_date, 1, 3, 8, 9) # Profile informations self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg') self.profiles = configparser.ConfigParser() 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, 'database', 'demo%s' % short_version) self.profiles.set(name, 'username', 'demo') else: try: self.profiles.read(self.profile_cfg) except configparser.ParsingError: logger.error("Fail to parse profiles.cfg", exc_info=True) for section in self.profiles.sections(): active = all(self.profiles.has_option(section, option) for option in ('host', 'database')) self.profile_store.append([section, active])
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_has_separator(True) self.dialog.set_icon(TRYTON_ICON) tooltips = common.Tooltips() button_cancel = gtk.Button(_('_Cancel')) 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')) 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_flags(gtk.CAN_DEFAULT) 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')) 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(_('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_password = gtk.Entry() self.entry_password.set_visibility(False) self.entry_password.set_activates_default(True) self.table_main.attach(self.entry_password, 1, 3, 7, 8) self.entry_login = gtk.Entry() self.entry_login.set_activates_default(True) self.table_main.attach(self.entry_login, 1, 3, 6, 7) label_password = gtk.Label(str=_("Password:"******"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) # Date stuff if CONFIG['login.date']: self.label_date = gtk.Label(str=_('Date:')) self.label_date.set_justify(gtk.JUSTIFY_RIGHT) self.label_date.set_alignment(1, .5) self.label_date.set_padding(3, 3) self.table_main.attach(self.label_date, 0, 1, 8, 9, xoptions=gtk.FILL) self.date_entry = Date() self.date_entry.props.format = '%d/%m/%Y' self.date_entry.props.value = datetime.date.today() self.table_main.attach(self.date_entry, 1, 3, 8, 9) # 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) and False: 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])