Here is a patch to render neso compatible with the connection manager

Please review this at http://codereview.appspot.com/4237063/

Affected files:
   M bin/neso


Index: bin/neso
===================================================================
--- a/bin/neso
+++ b/bin/neso
@@ -7,6 +7,8 @@
  import time
  import threading

+import gobject
+
  try:
      DIR = os.path.abspath(os.path.normpath(os.path.join(__file__,
          '..', '..', 'neso')))
@@ -195,11 +197,6 @@
  thread = threading.Thread(target=cron)
  thread.start()

-from tryton.config import CONFIG as CLIENT_CONFIG
-CLIENT_CONFIG.__setitem__('login.host', False, config=False)
-CLIENT_CONFIG.__setitem__('login.server', 'localhost', config=False)
-CLIENT_CONFIG.__setitem__('login.port', '8070', config=False)
-
  from tryton.gui.window.dbcreate import DBCreate
  _DBCreate_run = DBCreate.run

@@ -220,7 +217,7 @@
      liststore = gtk.ListStore(str)
      self.combo_database.set_model(liststore)
      self.refreshlist(None, self.combo_database, self.combo_database_label,
-            '127.0.0.1', 8070)
+        self.db_progressbar, '127.0.0.1', 8070)
      self.event_show_button_ok(self.dialog, None)
      return _DBBackupDrop_run(self, parent)

@@ -236,6 +233,68 @@

  DBRestore.run = DBRestore_run

+from tryton.common import refresh_dblist
+from tryton.gui.window.dblogin import DBLogin
+_DBLogin_run = DBLogin.run
+
+def DBLogin_run(self, profile_name, parent):
+    self.combo_profile.destroy()
+    self.profile_button.destroy()
+    self.profile_label.set_text('Database')
+    dbstore = gtk.ListStore(gobject.TYPE_STRING)
+    self.database_combo = gtk.ComboBox()
+    self.database_combo.set_model(dbstore)
+    cell = gtk.CellRendererText()
+    self.database_combo.pack_start(cell, True)
+    self.database_combo.add_attribute(cell, 'text', 0)
+
+    dbs = refresh_dblist('127.0.0.1', '8070')
+    if dbs:
+        for dbname in dbs:
+            dbstore.append((dbname,))
+        self.table_main.attach(self.database_combo, 1, 3, 0, 1,
+            xoptions=gtk.FILL)
+    else:
+        def db_create(button):
+            dia = DBCreate('127.0.0.1', 8070)
+            dbname = dia.run(self.dialog)
+            button.hide()
+            self.table_main.attach(self.database_combo, 1, 3, 0, 1,
+                xoptions=gtk.FILL)
+            self.database_combo.show()
+            dbstore.append((dbname,))
+        image = gtk.Image()
+        image.set_from_stock('tryton-new', gtk.ICON_SIZE_BUTTON)
+        create_button = gtk.Button(u'Create')
+        create_button.set_image(image)
+        create_button.connect('clicked', db_create)
+ self.table_main.attach(create_button, 1, 3, 0, 1, xoptions=gtk.FILL)
+
+    self.dialog.show_all()
+    self.dialog.reshow_with_initial_size()
+    res, result = None, ('', '', '', '', '')
+    while not (res in (gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT)
+            or (res == gtk.RESPONSE_OK and all(result))):
+        self.database_combo.grab_focus()
+        res = self.dialog.run()
+        database = self.database_combo.get_active()
+        if database != -1:
+            db_name = dbstore[database][0]
+            result = (self.entry_login.get_text(),
+                self.entry_password.get_text(), '127.0.0.1', 8070, db_name)
+
+    if res != gtk.RESPONSE_OK:
+        parent.present()
+        self.dialog.destroy()
+        rpc.logout()
+        from tryton.gui.main import Main
+        raise Exception('QueryCanceled')
+    parent.present()
+    self.dialog.destroy()
+    return result
+
+DBLogin.run = DBLogin_run
+
  TrytonClient.run()
  CRON_RUNNING = False
  thread.join()


--
[email protected] mailing list

Reply via email to