Remove last_open_file from tree binary widget

Following the same design as changeset 87806105f07d, last_open_file must be
removed and new is renamed into select.

issue5209
review23701002
This commit is contained in:
Cédric Krier committed 2015-12-31 14:18:22 +01:00
1 parent d07b1f1d3d
commit d913ccd274
2 files changed
+9 -15

No files matched your search

+6 -6
View File
@@ -18,7 +18,7 @@ class CellRendererBinary(gtk.GenericCellRenderer):
gobject.PARAM_READWRITE),
}
__gsignals__ = {
'new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
'select': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'open': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
@@ -35,14 +35,14 @@ class CellRendererBinary(gtk.GenericCellRenderer):
self.set_property('mode', gtk.CELL_RENDERER_MODE_EDITABLE)
self.use_filename = use_filename
if use_filename:
self.buttons = ('new', 'open', 'save', 'clear')
self.buttons = ('select', 'open', 'save', 'clear')
else:
self.buttons = ('new', 'save', 'clear')
self.buttons = ('select', 'save', 'clear')
self.clicking = ''
self.images = {}
widget = gtk.Button()
for key, stock_name in (
('new', 'tryton-find'),
('select', 'tryton-find'),
('open', 'tryton-open'),
('save', 'tryton-save-as'),
('clear', 'tryton-clear')):
@@ -91,7 +91,7 @@ class CellRendererBinary(gtk.GenericCellRenderer):
button_name = None
if not self.visible or not button_name:
return
if not self.editable and button_name in ('new', 'clear'):
if not self.editable and button_name in ('select', 'clear'):
return
if not self.size and button_name == 'save':
return
@@ -139,7 +139,7 @@ class CellRendererBinary(gtk.GenericCellRenderer):
and flags & gtk.CELL_RENDERER_SELECTED):
state = gtk.STATE_ACTIVE
shadow = gtk.SHADOW_IN
if (not self.editable and button_name in ('new', 'clear')
if (not self.editable and button_name in ('select', 'clear')
or not self.size and button_name in ('open', 'save')):
state = gtk.STATE_INSENSITIVE
pixbuf = pxbf_insens
@@ -410,11 +410,10 @@ class Binary(GenericText):
if renderer is None:
renderer = partial(CellRendererBinary, bool(self.filename))
super(Binary, self).__init__(view, attrs, renderer=renderer)
self.renderer.connect('new', self.new_binary)
self.renderer.connect('select', self.select_binary)
self.renderer.connect('open', self.open_binary)
self.renderer.connect('save', self.save_binary)
self.renderer.connect('clear', self.clear_binary)
self.last_open_file = None
def get_textual_value(self, record):
pass
@@ -449,14 +448,10 @@ class Binary(GenericText):
readonly = True
cell.set_property('editable', not readonly)
def new_binary(self, renderer, path):
def select_binary(self, renderer, path):
record, field = self._get_record_field(path)
filename = ''
if self.last_open_file:
last_id, last_filename = self.last_open_file
if last_id == record.id:
filename = last_filename
filename = file_selection(_('Open...'), filename=filename)
filename = file_selection(_('Open...'))
if filename:
field.set_client(record, open(filename, 'rb').read())
if self.filename:
@@ -484,7 +479,6 @@ class Binary(GenericText):
if type_:
type_ = type_[1:]
file_open(file_path, type_)
self.last_open_file = (record.id, file_path)
def save_binary(self, renderer, path):
filename = ''