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
1=== modified file 'GTG/gtk/browser/tag_editor.py'
2--- GTG/gtk/browser/tag_editor.py 2012-05-04 20:49:39 +0000
3+++ GTG/gtk/browser/tag_editor.py 2012-06-02 19:41:20 +0000
4@@ -37,6 +37,7 @@
5 from GTG import _
6 from GTG.gtk.browser.simple_color_selector import SimpleColorSelector
7
8+
9 class TagIconSelector(gtk.Window): # pylint: disable-msg=R0904
10 """
11 TagIconSelector is intended as a floating window that allows to select
12@@ -107,19 +108,17 @@
13 self.loaded = True
14
15 ### PUBLIC IF ###
16-
17 def set_remove_enabled(self, enable):
18 """Disable/enable the remove button"""
19 self.remove_bt.set_sensitive(enable)
20
21 ### callbacks ###
22-
23 def on_selection_changed(self, widget): # pylint: disable-msg=W0613
24 """Callback: update the model according to the selected icon. Also
25 notifies the parent widget."""
26 my_path = self.symbol_iv.get_selected_items()
27 if len(my_path)>0:
28- my_iter = self.symbol_model.get_iter(my_path[0])
29+ my_iter = self.symbol_model.get_iter(my_path[0])
30 self.selected_icon = self.symbol_model.get_value(my_iter, 1)
31 else:
32 self.selected_icon = None
33@@ -133,7 +132,6 @@
34 self.close_selector()
35
36 ### PUBLIC IF ###
37-
38 def show_at_position(self, pos_x, pos_y):
39 """Displays the window at a specific point on the screen"""
40 if not self.loaded:
41@@ -268,7 +266,13 @@
42 self.tc_cc_colsel.connect('color-changed', self.on_tc_colsel_changed)
43 self.tc_cc_colsel.connect('color-added', self.on_tc_colsel_added)
44 self.connect('delete-event', self.on_close)
45-
46+
47+ # allow fast closing by Escape key
48+ agr = gtk.AccelGroup()
49+ self.add_accel_group(agr)
50+ key, modifier = gtk.accelerator_parse('Escape')
51+ agr.connect_group(key, modifier, gtk.ACCEL_VISIBLE, self.on_close)
52+
53 def __set_default_values(self):
54 """Configure the widget components with their initial default values"""
55 # Disable some handlers while setting up the widget to avoid
56@@ -308,7 +312,8 @@
57 if icon is not None:
58 for i in self.ti_bt:
59 self.ti_bt.remove(i)
60- ti_bt_img = gtk.image_new_from_icon_name(icon, gtk.ICON_SIZE_BUTTON)
61+ ti_bt_img = gtk.image_new_from_icon_name(icon,
62+ gtk.ICON_SIZE_BUTTON)
63 ti_bt_img.show()
64 self.ti_bt.add(ti_bt_img)
65 else:
66@@ -317,11 +322,10 @@
67 self.ti_bt.add(self.ti_bt_label)
68
69 ### PUBLIC API ###
70-
71 def set_tag(self, tag):
72 """Update the context menu items using the tag attributes."""
73- # set_active emit the 'toggle' signal, so we have to disable the handler
74- # when we update programmatically
75+ # set_active emit the 'toggle' signal, so we have to disable
76+ # the handler when we update programmatically
77 self.__set_default_values()
78 if tag is None:
79 self.tag = None
80@@ -355,7 +359,6 @@
81 self.tn_entry.handler_unblock(self.tn_entry_clicked_hid)
82
83 ### CALLBACKS ###
84-
85 def watch_tn_entry_changes(self):
86 """Monitors the value changes in the tag name entry. If no updates have
87 been noticed after 1 second, request an update."""
88@@ -399,8 +402,8 @@
89 self.tag_icon_selector.set_remove_enabled(False)
90
91 def on_tn_entry_changed(self, widget): # pylint: disable-msg=W0613
92- """Callback: checks tag name validity and start value changes monitoring
93- to decide when to update a tag's name."""
94+ """ Callback: checks tag name validity and start value changes
95+ monitoring to decide when to update a tag's name."""
96 self.tn_entry_last_recorded_value = self.tn_entry.get_text()
97 # check validity
98 if self.tn_entry_last_recorded_value.strip() == "":
99@@ -441,7 +444,12 @@
100 self.config.set_lst("custom_colors", [s for s in self.custom_colors])
101 self.req.save_config()
102
103- def on_close(self, widget, event): # pylint: disable-msg=W0613
104- """Callback: hide the tag editor when the close the window."""
105+ def on_close(self, widget, event, arg1=None, arg2=None, arg3=None):
106+ # pylint: disable-msg=W0613,R0913
107+ """ Callback: hide the tag editor when the close the window.
108+
109+ Arguments arg1-arg3 are needed to satisfy callback when closing
110+ by Escape
111+ """
112 self.vmanager.close_tag_editor()
113 return True

Subscribers

People subscribed via source and target branches

to status/vote changes: