1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
34
from view_tree import parse
39
'checkbox': gobject.TYPE_BOOLEAN
43
# Should be replaced by win_browse
46
class win_selection_class(object):
47
def __init__(self, ids, model, view=None):
48
self.glade = glade.XML(common.terp_path("terp.glade"), "win_selection",gettext.textdomain())
49
self.win = self.glade.get_widget('win_selection')
52
self.view = self.glade.get_widget('win_sel_tree')
53
self.view.get_selection().set_mode('single')
55
fields = { 'name': {'type': 'char', 'string':_('Name')} }
56
xml = '''<?xml version="1.0"?>
58
<field name="name" string="%s"></field>
59
</tree>''' % (_('Ressource Name'), _('Names'))
64
p = parse.parse(fields)
65
p.parse(xml, self.view)
66
self.view.set_expander_column(self.view.get_column(1))
67
self.fields_order = p.fields_order
69
types=[ gobject.TYPE_STRING ]
70
for x in self.fields_order:
71
types.append( fields_list_type.get(fields[x]['type'], gobject.TYPE_STRING))
72
self.model = gtk.ListStore(*types)
75
res_ids = rpc.session.rpc_exec_auth('/object', 'execute', model, 'name_get', self.ids, rpc.session.context)
77
num = self.model.append()
78
self.model.set(num, 0, res[0], 1, res[1])
82
self.view.set_model(self.model)
85
def id_name_get(self):
86
id = self.value_get(0)
88
return (id, self.value_get(1))
91
def value_get(self, col):
92
sel = self.view.get_selection().get_selected()
96
return model.get_value(iter, col)
99
button = self.win.run()
100
if button==gtk.RESPONSE_OK:
101
res = self.id_name_get()
107
def win_selection_h(from_resource, ids, model, view=None):
108
return win_selection(ids, model, view)
110
def win_selection(ids, model, view=None):
112
return rpc.session.rpc_exec_auth('/object', 'execute', model, 'name_get', ids, rpc.session.context)[0]
113
win = win_selection_class(ids, model, view)