442
443
if res == gtk.RESPONSE_OK:
443
444
protocol = protocol[protocol_widget.get_active_text()]
444
445
url = '%s%s:%s' % ((protocol).strip(), (host_widget.get_text()).strip(), (port_widget.get_text()).strip())
445
server_widget.set_text(url)
446
iter = server_liststore.get_iter_root()
448
if server_liststore.get_value(iter, 0)==url:
449
combo_server.set_active_iter(iter)
451
iter = server_liststore.iter_next(iter)
453
iter = server_liststore.append([url])
454
combo_server.set_active_iter(iter)
457
466
def refreshlist(self, widget, db_widget, entry_db, label, url, butconnect=False):
458
467
return _refresh_dblist(db_widget, entry_db, label, butconnect, url)
460
def refreshlist_ask(self,widget, server_widget, db_widget, entry_db, label, butconnect = False, url=False, parent=None):
461
url = _server_ask(server_widget, parent) or url
469
def refreshlist_ask(self,widget, combo_server, server_liststore, db_widget, entry_db, label, butconnect = False, url=False, parent=None):
470
url = _server_ask(combo_server, server_liststore, parent) or url
471
return self.refreshlist(widget, db_widget, entry_db, label, url, butconnect)
472
def refreshserver(self,widget, combo_server, server_liststore, db_widget, entry_db,
473
label, butconnect = False, url=False, parent=None):
474
url = combo_server.get_active_text()
462
475
return self.refreshlist(widget, db_widget, entry_db, label, url, butconnect)
464
477
def run(self, dbname=None, parent=None):
473
486
img = self.ui.get_object('image_tinyerp')
474
487
img.set_from_file(common.terp_path_pixmaps('openerp.png'))
475
login = self.ui.get_object('ent_login')
488
ent_login = self.ui.get_object('ent_login')
476
489
passwd = self.ui.get_object('ent_passwd')
477
server_widget = self.ui.get_object('ent_server')
490
ent_server = self.ui.get_object('ent_server')
478
491
but_connect = self.ui.get_object('button_connect')
479
492
combo_db = self.ui.get_object('combo_db')
493
combo_server = self.ui.get_object('combo_server')
480
494
entry_db = self.ui.get_object('ent_db_login')
481
495
change_button = self.ui.get_object('but_server')
482
496
label = self.ui.get_object('combo_label')
497
combo_label_server = self.ui.get_object('combo_label_server')
483
498
# db_entry = self.ui.get_object('ent_db_login')
487
host = options.options['login.server']
488
port = options.options['login.port']
489
protocol = options.options['login.protocol']
502
combo_label_server.hide()
504
server_liststore = gtk.ListStore(str)
505
server_liststore.clear()
508
url_str = options.options['login.urls']
510
_protocol = options.options.get('login.protocol', 'socket://')
511
_port = options.options.get('login.port', '8070')
512
_server = options.options.get('login.server', 'localhost')
513
url_str = "%s%s:%s" % (_protocol, _server, _port)
516
urlparts = url_str.split(",")
518
server_liststore.append([url])
520
(protocol, rest) = url.split("://", 1)
521
protocol = protocol + "://"
522
host, port = rest.split(":", 1)
524
urls.append((protocol, host, port))
527
protocol, host, port= urls[0]
491
529
url = '%s%s:%s' % (protocol, host, port)
492
server_widget.set_text(url)
493
login.set_text(options.options['login.login'])
530
ent_server.set_text(url)
532
combo_server.set_model(server_liststore)
533
username = options.options['login.login']
534
ent_login.set_text(username)
536
cell = gtk.CellRendererText()
537
combo_server.pack_start(cell, True)
538
combo_server.add_attribute(cell, 'text', 0)
540
lasturl = options.options.get('login.url', '')
543
iter = server_liststore.get_iter_root()
545
if server_liststore.get_value(iter, 0)==lasturl:
546
combo_server.set_active_iter(iter)
548
iter = server_liststore.iter_next(iter)
495
550
# construct the list of available db and select the last one used
496
551
liststore = gtk.ListStore(str)
500
555
combo_db.add_attribute(cell, 'text', 0)
502
557
res = self.refreshlist(None, combo_db, entry_db, label, url, but_connect)
503
change_button.connect_after('clicked', self.refreshlist_ask, server_widget, combo_db, entry_db, label, but_connect, url, win)
558
change_button.connect_after('clicked', self.refreshlist_ask, combo_server, server_liststore, combo_db, entry_db, label, but_connect, url, win)
559
combo_server.connect_after('changed', self.refreshserver, combo_server, server_liststore, combo_db, entry_db, label, but_connect, url, win)
506
562
iter = liststore.get_iter_root()
511
567
iter = liststore.iter_next(iter)
514
m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', server_widget.get_text() or '')
571
if combo_server.flags() & gtk.VISIBLE:
572
server_url = combo_server.get_active_text()
574
server_url = ent_server.get_text()
576
m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', server_url or '')
516
579
if combo_db.flags() & gtk.VISIBLE:
517
580
dbname = combo_db.get_active_text()
519
582
dbname = entry_db.get_text()
585
iter = server_liststore.get_iter_root()
587
urls.append(server_liststore.get_value(iter, 0))
588
iter = server_liststore.iter_next(iter)
590
options.options['login.urls'] = string.join(urls, ',')
591
options.options['login.url'] = server_url
521
592
options.options['login.server'] = m.group(2)
522
options.options['login.login'] = login.get_text()
593
options.options['login.login'] = ent_login.get_text()
523
594
options.options['login.port'] = m.group(3)
524
595
options.options['login.protocol'] = m.group(1)
525
596
options.options['login.db'] = dbname
526
result = (login.get_text(), passwd.get_text(), m.group(2), m.group(3), m.group(1), dbname)
597
result = (ent_login.get_text(), passwd.get_text(), m.group(2), m.group(3), m.group(1), dbname)