Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(316)

Side by Side Diff: tryton/gui/window/view_form/view/form_gtk/many2many.py

Issue 157125: Remove hardcoded shortcut and activate Delete key in one2many (Closed)
Patch Set: Connect also wid_text to on_keypress Created 15 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tryton/gui/window/view_form/view/form_gtk/one2many.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #This file is part of Tryton. The COPYRIGHT file at the top level of 1 #This file is part of Tryton. The COPYRIGHT file at the top level of
2 #this repository contains the full copyright notices and license terms. 2 #this repository contains the full copyright notices and license terms.
3 import gtk 3 import gtk
4 from tryton.gui.window.view_form.screen import Screen 4 from tryton.gui.window.view_form.screen import Screen
5 from interface import WidgetInterface 5 from interface import WidgetInterface
6 from one2many import Dialog 6 from one2many import Dialog
7 import tryton.rpc as rpc 7 import tryton.rpc as rpc
8 from tryton.gui.window.win_search import WinSearch 8 from tryton.gui.window.win_search import WinSearch
9 from tryton.gui.window.view_form.widget_search.form import _LIMIT 9 from tryton.gui.window.view_form.widget_search.form import _LIMIT
10 import tryton.common as common 10 import tryton.common as common
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 label_remove = gtk.Label(_('Remove')) 50 label_remove = gtk.Label(_('Remove'))
51 hbox_remove.pack_start(label_remove) 51 hbox_remove.pack_start(label_remove)
52 self.wid_but_remove.add(hbox_remove) 52 self.wid_but_remove.add(hbox_remove)
53 self.wid_but_remove.set_relief(gtk.RELIEF_HALF) 53 self.wid_but_remove.set_relief(gtk.RELIEF_HALF)
54 self.wid_but_remove.set_focus_on_click(True) 54 self.wid_but_remove.set_focus_on_click(True)
55 self.wid_but_remove.connect('clicked', self._sig_remove) 55 self.wid_but_remove.connect('clicked', self._sig_remove)
56 hbox.pack_start(self.wid_but_remove, expand=False, fill=False) 56 hbox.pack_start(self.wid_but_remove, expand=False, fill=False)
57 57
58 self.widget.pack_start(hbox, expand=False, fill=False) 58 self.widget.pack_start(hbox, expand=False, fill=False)
59 59
60 hbox.set_focus_chain([self.wid_text])
61
60 self.screen = Screen(attrs['relation'], self._window, 62 self.screen = Screen(attrs['relation'], self._window,
61 view_type=['tree'], views_preload=attrs.get('views', {}), 63 view_type=['tree'], views_preload=attrs.get('views', {}),
62 row_activate=self._on_activate) 64 row_activate=self._on_activate)
63 65
64 self.widget.pack_start(self.screen.widget, expand=True, fill=True) 66 self.widget.pack_start(self.screen.widget, expand=True, fill=True)
65 67
68 self.screen.widget.connect('key_press_event', self.on_keypress)
69 self.wid_text.connect('key_press_event', self.on_keypress)
70
66 self.old = None 71 self.old = None
67 72
68 def grab_focus(self): 73 def grab_focus(self):
69 return self.wid_text.grab_focus() 74 return self.wid_text.grab_focus()
70 75
76 def on_keypress(self, widget, event):
77 if event.keyval == gtk.keysyms.F3:
78 self._sig_add()
79 return False
80 if event.keyval == gtk.keysyms.F2:
81 self._sig_edit()
82 if event.keyval in (gtk.keysyms.Delete, gtk.keysyms.KP_Delete) \
83 and self.screen.widget.is_focus():
timitos 2009/11/24 08:00:47 Deleting is not working with this line on Many2Man
84 self._sig_remove()
85 return False
86
71 def destroy(self): 87 def destroy(self):
72 self.screen.destroy() 88 self.screen.destroy()
73 self.widget.destroy() 89 self.widget.destroy()
74 del self.widget 90 del self.widget
75 91
76 def _sig_add(self, *args): 92 def _sig_add(self, *args):
77 domain = self._view.modelfield.domain_get(self._view.model) 93 domain = self._view.modelfield.domain_get(self._view.model)
78 context = self._view.modelfield.context_get(self._view.model) 94 context = self._view.modelfield.context_get(self._view.model)
79 value = self.wid_text.get_text() 95 value = self.wid_text.get_text()
80 96
(...skipping 18 matching lines...) Expand all
99 res_id = ids[0] 115 res_id = ids[0]
100 self.screen.load(ids) 116 self.screen.load(ids)
101 self.screen.display(res_id=res_id) 117 self.screen.display(res_id=res_id)
102 if self.screen.current_view: 118 if self.screen.current_view:
103 self.screen.current_view.set_cursor() 119 self.screen.current_view.set_cursor()
104 self.wid_text.set_text('') 120 self.wid_text.set_text('')
105 self.set_value(self._view.model, self._view.modelfield) 121 self.set_value(self._view.model, self._view.modelfield)
106 122
107 def _sig_remove(self, *args): 123 def _sig_remove(self, *args):
108 self.screen.remove() 124 self.screen.remove()
109 self.screen.display()
110 self.set_value(self._view.model, self._view.modelfield)
111 125
112 def _sig_activate(self, *args): 126 def _sig_activate(self, *args):
113 self._sig_add() 127 self._sig_add()
114 self.wid_text.grab_focus() 128 self.wid_text.grab_focus()
115 129
116 def _on_activate(self): 130 def _on_activate(self):
117 self._sig_edit() 131 self._sig_edit()
118 132
119 def _sig_edit(self): 133 def _sig_edit(self):
120 if self.screen.current_model: 134 if self.screen.current_model:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return True 178 return True
165 179
166 def display_value(self): 180 def display_value(self):
167 return self._view.modelfield.rec_name(self._view.model) 181 return self._view.modelfield.rec_name(self._view.model)
168 182
169 def set_value(self, model, model_field): 183 def set_value(self, model, model_field):
170 model_field.set_client(model, [x.id for x in self.screen.models.models]) 184 model_field.set_client(model, [x.id for x in self.screen.models.models])
171 185
172 def cancel(self): 186 def cancel(self):
173 self.old = None 187 self.old = None
OLDNEW
« no previous file with comments | « no previous file | tryton/gui/window/view_form/view/form_gtk/one2many.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b