GTG

Merge lp:~izidor/gtg/close-edit-tag into lp:~gtg/gtg/old-trunk

Proposed by Izidor Matušov
Status: Merged
Merged at revision: 1189
Proposed branch: lp:~izidor/gtg/close-edit-tag
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 113 lines (+22/-14)
1 file modified
GTG/gtk/browser/tag_editor.py (+22/-14)
To merge this branch: bzr merge lp:~izidor/gtg/close-edit-tag
Reviewer Review Type Date Requested Status
Bertrand Rousseau (community) code, run Approve
Review via email: mp+108468@code.launchpad.net

Description of the change

Quickly close tag editor by pressing Escape key.

To post a comment you must log in.
Revision history for this message
Bertrand Rousseau (bertrand-rousseau) wrote :

I approve!

review: Approve (code, run)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'GTG/gtk/browser/tag_editor.py'
--- GTG/gtk/browser/tag_editor.py 2012-05-04 20:49:39 +0000
+++ GTG/gtk/browser/tag_editor.py 2012-06-02 19:41:20 +0000
@@ -37,6 +37,7 @@
37from GTG import _37from GTG import _
38from GTG.gtk.browser.simple_color_selector import SimpleColorSelector38from GTG.gtk.browser.simple_color_selector import SimpleColorSelector
3939
40
40class TagIconSelector(gtk.Window): # pylint: disable-msg=R090441class TagIconSelector(gtk.Window): # pylint: disable-msg=R0904
41 """42 """
42 TagIconSelector is intended as a floating window that allows to select43 TagIconSelector is intended as a floating window that allows to select
@@ -107,19 +108,17 @@
107 self.loaded = True108 self.loaded = True
108109
109 ### PUBLIC IF ###110 ### PUBLIC IF ###
110
111 def set_remove_enabled(self, enable):111 def set_remove_enabled(self, enable):
112 """Disable/enable the remove button"""112 """Disable/enable the remove button"""
113 self.remove_bt.set_sensitive(enable)113 self.remove_bt.set_sensitive(enable)
114114
115 ### callbacks ###115 ### callbacks ###
116
117 def on_selection_changed(self, widget): # pylint: disable-msg=W0613116 def on_selection_changed(self, widget): # pylint: disable-msg=W0613
118 """Callback: update the model according to the selected icon. Also117 """Callback: update the model according to the selected icon. Also
119 notifies the parent widget."""118 notifies the parent widget."""
120 my_path = self.symbol_iv.get_selected_items()119 my_path = self.symbol_iv.get_selected_items()
121 if len(my_path)>0:120 if len(my_path)>0:
122 my_iter = self.symbol_model.get_iter(my_path[0])121 my_iter = self.symbol_model.get_iter(my_path[0])
123 self.selected_icon = self.symbol_model.get_value(my_iter, 1)122 self.selected_icon = self.symbol_model.get_value(my_iter, 1)
124 else:123 else:
125 self.selected_icon = None124 self.selected_icon = None
@@ -133,7 +132,6 @@
133 self.close_selector()132 self.close_selector()
134133
135 ### PUBLIC IF ###134 ### PUBLIC IF ###
136
137 def show_at_position(self, pos_x, pos_y):135 def show_at_position(self, pos_x, pos_y):
138 """Displays the window at a specific point on the screen"""136 """Displays the window at a specific point on the screen"""
139 if not self.loaded:137 if not self.loaded:
@@ -268,7 +266,13 @@
268 self.tc_cc_colsel.connect('color-changed', self.on_tc_colsel_changed)266 self.tc_cc_colsel.connect('color-changed', self.on_tc_colsel_changed)
269 self.tc_cc_colsel.connect('color-added', self.on_tc_colsel_added)267 self.tc_cc_colsel.connect('color-added', self.on_tc_colsel_added)
270 self.connect('delete-event', self.on_close)268 self.connect('delete-event', self.on_close)
271 269
270 # allow fast closing by Escape key
271 agr = gtk.AccelGroup()
272 self.add_accel_group(agr)
273 key, modifier = gtk.accelerator_parse('Escape')
274 agr.connect_group(key, modifier, gtk.ACCEL_VISIBLE, self.on_close)
275
272 def __set_default_values(self):276 def __set_default_values(self):
273 """Configure the widget components with their initial default values"""277 """Configure the widget components with their initial default values"""
274 # Disable some handlers while setting up the widget to avoid278 # Disable some handlers while setting up the widget to avoid
@@ -308,7 +312,8 @@
308 if icon is not None:312 if icon is not None:
309 for i in self.ti_bt:313 for i in self.ti_bt:
310 self.ti_bt.remove(i)314 self.ti_bt.remove(i)
311 ti_bt_img = gtk.image_new_from_icon_name(icon, gtk.ICON_SIZE_BUTTON)315 ti_bt_img = gtk.image_new_from_icon_name(icon,
316 gtk.ICON_SIZE_BUTTON)
312 ti_bt_img.show()317 ti_bt_img.show()
313 self.ti_bt.add(ti_bt_img)318 self.ti_bt.add(ti_bt_img)
314 else:319 else:
@@ -317,11 +322,10 @@
317 self.ti_bt.add(self.ti_bt_label)322 self.ti_bt.add(self.ti_bt_label)
318323
319 ### PUBLIC API ###324 ### PUBLIC API ###
320
321 def set_tag(self, tag):325 def set_tag(self, tag):
322 """Update the context menu items using the tag attributes."""326 """Update the context menu items using the tag attributes."""
323 # set_active emit the 'toggle' signal, so we have to disable the handler327 # set_active emit the 'toggle' signal, so we have to disable
324 # when we update programmatically328 # the handler when we update programmatically
325 self.__set_default_values()329 self.__set_default_values()
326 if tag is None:330 if tag is None:
327 self.tag = None331 self.tag = None
@@ -355,7 +359,6 @@
355 self.tn_entry.handler_unblock(self.tn_entry_clicked_hid)359 self.tn_entry.handler_unblock(self.tn_entry_clicked_hid)
356360
357 ### CALLBACKS ###361 ### CALLBACKS ###
358
359 def watch_tn_entry_changes(self):362 def watch_tn_entry_changes(self):
360 """Monitors the value changes in the tag name entry. If no updates have363 """Monitors the value changes in the tag name entry. If no updates have
361 been noticed after 1 second, request an update."""364 been noticed after 1 second, request an update."""
@@ -399,8 +402,8 @@
399 self.tag_icon_selector.set_remove_enabled(False)402 self.tag_icon_selector.set_remove_enabled(False)
400403
401 def on_tn_entry_changed(self, widget): # pylint: disable-msg=W0613404 def on_tn_entry_changed(self, widget): # pylint: disable-msg=W0613
402 """Callback: checks tag name validity and start value changes monitoring405 """ Callback: checks tag name validity and start value changes
403 to decide when to update a tag's name."""406 monitoring to decide when to update a tag's name."""
404 self.tn_entry_last_recorded_value = self.tn_entry.get_text()407 self.tn_entry_last_recorded_value = self.tn_entry.get_text()
405 # check validity408 # check validity
406 if self.tn_entry_last_recorded_value.strip() == "":409 if self.tn_entry_last_recorded_value.strip() == "":
@@ -441,7 +444,12 @@
441 self.config.set_lst("custom_colors", [s for s in self.custom_colors])444 self.config.set_lst("custom_colors", [s for s in self.custom_colors])
442 self.req.save_config()445 self.req.save_config()
443446
444 def on_close(self, widget, event): # pylint: disable-msg=W0613447 def on_close(self, widget, event, arg1=None, arg2=None, arg3=None):
445 """Callback: hide the tag editor when the close the window."""448 # pylint: disable-msg=W0613,R0913
449 """ Callback: hide the tag editor when the close the window.
450
451 Arguments arg1-arg3 are needed to satisfy callback when closing
452 by Escape
453 """
446 self.vmanager.close_tag_editor()454 self.vmanager.close_tag_editor()
447 return True455 return True

Subscribers

People subscribed via source and target branches

to status/vote changes: