This commit is contained in:
Bertrand Chenal committed 2008-04-16 13:19:32 +02:00
commit fa89291f87
11 files changed
+75 -38

No files matched your search

+2 -2
View File
@@ -41,12 +41,12 @@ class Action(object):
return False
if not res:
return False
(type, data) = res
(type, data, print_p) = res
(fileno, fp_name) = tempfile.mkstemp('.' + type, 'tryton_')
file_d = os.fdopen(fileno, 'wb+')
file_d.write(base64.decodestring(data))
file_d.close()
file_open(fp_name, type, Main.get_main().window)
file_open(fp_name, type, Main.get_main().window, print_p=print_p)
return True
@staticmethod
+10 -2
View File
@@ -189,10 +189,13 @@ def file_selection(title, filename='', parent=None,
win.destroy()
return filenames
def file_open(filename, type, parent):
def file_open(filename, type, parent, print_p=False):
cmd = ''
if type in CONFIG['client.actions']:
cmd = CONFIG['client.actions'][type]
if print_p:
cmd = CONFIG['client.actions'][type][1]
else:
cmd = CONFIG['client.actions'][type][0]
if not cmd:
#TODO add dialog box
pass
@@ -207,6 +210,11 @@ def file_open(filename, type, parent):
file_p.close()
return
cmd = cmd % filename
if print_p:
prog, args = cmd.split(' ', 1)
args = [os.path.basename(prog)] + args.split(' ')
os.spawnv(os.P_WAIT, prog, args)
return
pid = os.fork()
if not pid:
pid = os.fork()
+9 -7
View File
@@ -38,7 +38,7 @@ def get_home_dir():
else:
return '.'
def find_path(progs):
def find_path(progs, args):
#TODO check for win32
paths = [x for x in os.environ['PATH'].split(':')
if os.path.isdir(x)]
@@ -46,7 +46,7 @@ def find_path(progs):
content = os.listdir(dir)
for prog in progs:
if prog in content:
return os.path.join(dir, prog) + ' %s'
return os.path.join(dir, prog) + ' ' + args
return ''
@@ -55,7 +55,7 @@ class ConfigManager(object):
def __init__(self):
self.options = {
'login.login': 'demo',
'login.login': 'admin',
'login.server': 'localhost',
'login.port': '8070',
'login.protocol': 'socket://',
@@ -73,10 +73,12 @@ class ConfigManager(object):
'client.form_tab_orientation': 90,
'client.lang': 'en_US',
'client.actions': {
'odt': find_path(['ooffice', 'ooffice2']),
'txt': find_path(['ooffice', 'ooffice2']),
'pdf': find_path(['evince', 'xpdf', 'gpdf',
'kpdf', 'epdfview', 'acroread'])
'odt': {0: find_path(['ooffice', 'ooffice2'], '%s'),
1: find_path(['ooffice', 'ooffice2'], '-p %s')},
'txt': {0: find_path(['ooffice', 'ooffice2'], '%s'),
1: find_path(['ooffice', 'ooffice2'], '-p %s')},
'pdf': {0: find_path(['evince', 'xpdf', 'gpdf',
'kpdf', 'epdfview', 'acroread'], '%s'), 1: ''},
},
}
parser = optparse.OptionParser(version=_("Tryton %s" % VERSION))
+29 -11
View File
@@ -22,20 +22,36 @@ class FilesActions(object):
_('Edit files actions')), expand=False, fill=True)
self.win.vbox.pack_start(gtk.HSeparator())
self.entries = {}
table = gtk.Table(len(CONFIG['client.actions']), 2)
table = gtk.Table(len(CONFIG['client.actions']) + 1, 3)
table.set_col_spacings(3)
table.set_row_spacings(3)
table.set_border_width(1)
i = 0
for extension in CONFIG['client.actions']:
table.attach(gtk.Label(_('File Type')), 0, 1, 0, 1, yoptions=False,
xoptions=gtk.FILL)
table.attach(gtk.Label(_('Open')), 1, 2, 0, 1, yoptions=False,
xoptions=gtk.FILL)
table.attach(gtk.Label(_('Print')), 2, 3, 0, 1, yoptions=False,
xoptions=gtk.FILL)
i = 1
extensions = CONFIG['client.actions'].keys()
extensions.sort()
for extension in extensions:
table.attach(gtk.Label(_('%s file: ') % extension.upper()),
0, 1, i, i + 1, yoptions = False, xoptions=gtk.FILL)
self.entries[extension] = gtk.Entry()
self.entries[extension].set_property(
0, 1, i, i + 1, yoptions=False, xoptions=gtk.FILL)
self.entries[extension] = {}
self.entries[extension][0] = gtk.Entry()
self.entries[extension][0].set_property(
'activates_default', True)
self.entries[extension].set_text(
CONFIG['client.actions'][extension])
table.attach(self.entries[extension], 1, 2, i, i + 1,
self.entries[extension][0].set_text(
CONFIG['client.actions'][extension][0])
table.attach(self.entries[extension][0], 1, 2, i, i + 1,
yoptions = False, xoptions=gtk.FILL)
self.entries[extension][1] = gtk.Entry()
self.entries[extension][1].set_property(
'activates_default', True)
self.entries[extension][1].set_text(
CONFIG['client.actions'][extension][1])
table.attach(self.entries[extension][1], 2, 3, i, i + 1,
yoptions = False, xoptions=gtk.FILL)
i += 1
self.win.vbox.pack_start(table, expand=True, fill=True)
@@ -46,8 +62,10 @@ class FilesActions(object):
res = self.win.run()
if res == gtk.RESPONSE_OK:
for extension in self.entries:
CONFIG['client.actions'][extension] = \
self.entries[extension].get_text()
CONFIG['client.actions'][extension][0] = \
self.entries[extension][0].get_text()
CONFIG['client.actions'][extension][1] = \
self.entries[extension][1].get_text()
CONFIG.save()
self.parent.present()
self.win.destroy()
+1 -2
View File
@@ -324,7 +324,6 @@ class ModelRecord(SignalEvent):
('res_model', '=', self.resource),
('res_id', '=', self.id),
])
except Exception, exception:
rpc.process_exception(exception, self.window)
except:
return 0
return self.attachment_count
+2 -1
View File
@@ -256,7 +256,8 @@ class Screen(SignalEvent):
self.hastoolbar)
except Exception, exception:
rpc.process_exception(exception, self.window)
raise
view = self.rpc.fields_view_get(view_id, view_type, self.context,
self.hastoolbar)
if self.exclude_field:
if self.exclude_field in view['fields']:
del view['fields'][self.exclude_field]
@@ -30,6 +30,8 @@ class Float(Integer):
position = entry.get_position()
new_value = value[:position] + new_text + value[position:]
try:
if new_value == '-':
return
if len(str(int(locale.atof(new_value)))) > self.digits[0]:
entry.stop_emission('insert-text')
except:
@@ -31,6 +31,8 @@ class Integer(Char):
position = entry.get_position()
new_value = value[:position] + new_text + value[position:]
try:
if new_value == '-':
return
locale.atoi(new_value)
except:
entry.stop_emission('insert-text')
@@ -55,6 +55,7 @@ class Dialog(object):
viewport.set_shadow_type(gtk.SHADOW_NONE)
scroll.add(viewport)
self.dia.show()
self.screen = Screen(model, self.dia, domain=domain, context=context,
view_type=['form'])
if obj_id:
@@ -402,7 +402,6 @@ class ParserForm(ParserInterface):
xexpand=xexpand, xfill=xfill)
elif node.localName == 'group':
container.new(int(attrs.get('col', 4)))
widget, widgets, buttons, on_write = self.parse(model, node,
fields, tooltips=tooltips)
dict_widget.update(widgets)
@@ -412,7 +411,6 @@ class ParserForm(ParserInterface):
frame.add(widget)
else:
frame = widget
container.pop()
container.wid_add(frame, colspan=int(attrs.get('colspan', 1)),
expand=int(attrs.get('expand', 0)),
rowspan=int(attrs.get('rowspan', 1)), ypadding=0,
+17 -11
View File
@@ -37,23 +37,28 @@ def db_list(host, port):
_SEMAPHORE.release()
return res
except:
_SOCK = None
return None
def db_exec(host, port, method, *args):
global _SOCK
_SEMAPHORE.acquire()
try:
if _SOCK and _SOCK.hostname != host and _SOCK.port != port:
_SOCK.disconnect()
_SOCK = None
if _SOCK is None:
_SOCK= pysocket.PySocket()
_SOCK.connect(host, port)
_SOCK.send(('db', method) + args)
res = _SOCK.receive()
finally:
_SEMAPHORE.release()
return res
try:
if _SOCK and _SOCK.hostname != host and _SOCK.port != port:
_SOCK.disconnect()
_SOCK = None
if _SOCK is None:
_SOCK= pysocket.PySocket()
_SOCK.connect(host, port)
_SOCK.send(('db', method) + args)
res = _SOCK.receive()
finally:
_SEMAPHORE.release()
return res
except:
_SOCK = None
return None
def login(username, password, host, port, database):
global _SOCK, _USER, _USERNAME, _SESSION, _DATABASE, _VIEW_CACHE, SECURE
@@ -73,6 +78,7 @@ def login(username, password, host, port, database):
finally:
_SEMAPHORE.release()
except socket.error:
_SOCK = None
_USER = 0
_SESSION = ''
return -1