GTG

Merge lp:~mrasmus/gtg/bug-348907-fix into lp:~gtg/gtg/old-trunk

Proposed by Matthew Rasmus
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mrasmus/gtg/bug-348907-fix
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 173 lines (+70/-3)
2 files modified
GTG/taskbrowser/browser.py (+69/-3)
GTG/taskbrowser/taskbrowser.glade (+1/-0)
To merge this branch: bzr merge lp:~mrasmus/gtg/bug-348907-fix
Reviewer Review Type Date Requested Status
Bertrand Rousseau (community) Needs Information
Luca Invernizzi Pending
Review via email: mp+17521@code.launchpad.net

This proposal supersedes a proposal from 2009-12-29.

To post a comment you must log in.
Revision history for this message
Luca Invernizzi (invernizzi) wrote : Posted in a previous version of this proposal

Plenty of comments, that's awesome!

review: Approve
Revision history for this message
Luca Invernizzi (invernizzi) : Posted in a previous version of this proposal
review: Abstain
Revision history for this message
Bertrand Rousseau (bertrand-rousseau) wrote :

Your patch replaces "self.clipboard = clipboard.TaskClipboard(self.req)" by "self.clipboard = clipboard.TaskClipboard()". Do you willingly wanted to do that? Or have your branch diverged from the tree? Please make sure you have merge the tree into your branch and that this is the correct behavior. People working on the clipboard should probably give their advice here (since I know clipboard handling can be a tricky thing).

Otherwise, I'm ok with your patch.

review: Needs Information
lp:~mrasmus/gtg/bug-348907-fix updated
517. By Matthew Rasmus

Fixed conflict with trunk.

518. By Matthew Rasmus

Managed to sneak an unnecessary empty line in the last revision...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/taskbrowser/browser.py'
2--- GTG/taskbrowser/browser.py 2010-01-07 21:09:52 +0000
3+++ GTG/taskbrowser/browser.py 2010-01-17 20:16:13 +0000
4@@ -147,6 +147,8 @@
5
6 #Shared clipboard
7 self.clipboard = clipboard.TaskClipboard(self.req)
8+
9+ self.tag_active = False
10
11 ### INIT HELPER FUNCTIONS #####################################################
12 #
13@@ -324,6 +326,8 @@
14 self.on_colorchooser_activate,
15 "on_resetcolor_activate":
16 self.on_resetcolor_activate,
17+ "on_tagcontext_deactivate":
18+ self.on_tagcontext_deactivate,
19 "on_workview_toggled":
20 self.on_workview_toggled,
21 "on_note_toggled":
22@@ -783,8 +787,15 @@
23 """Returns True if the task meets the criterion to be displayed
24 @param task: the task to assess
25 """
26-
27- tag_list, notag_only = self.get_selected_tags()
28+
29+ # Checks to see if we're working with a tag through a right click
30+ # menu item. If we are, we'll treat the tag that was selected
31+ # previous to the right click as the currently selected tag,
32+ # even if the cursor is somewhere else.
33+ if self.tag_active:
34+ tag_list, notag_only = self.previous_tag
35+ else:
36+ tag_list, notag_only = self.get_selected_tags()
37
38 if len(tag_list)==1: #include child tags
39 tag_list = tag_list[0].all_children()
40@@ -1079,9 +1090,11 @@
41 #TODO: Color chooser should be refactorized in its own class. Well, in
42 #fact we should have a TagPropertiesEditor (like for project) Also,
43 #color change should be immediate. There's no reason for a Ok/Cancel
44+ self.set_target_cursor()
45 dialog = gtk.ColorSelectionDialog('Choose color')
46 colorsel = dialog.colorsel
47 colorsel.connect("color_changed", self.on_color_changed)
48+
49 # Get previous color
50 tags, notag_only = self.get_selected_tags()
51 init_color = None
52@@ -1099,15 +1112,21 @@
53 tags, notag_only = self.get_selected_tags()
54 for t in tags:
55 t.set_attribute("color", strcolor)
56+ self.reset_cursor()
57 self.task_tv.refresh()
58 dialog.destroy()
59
60 def on_resetcolor_activate(self, widget):
61+ self.set_target_cursor()
62 tags, notag_only = self.get_selected_tags()
63 for t in tags:
64 t.del_attribute("color")
65+ self.reset_cursor()
66 self.task_tv.refresh()
67 self.tags_tv.refresh()
68+
69+ def on_tagcontext_deactivate(self, menushell):
70+ self.reset_cursor()
71
72 def on_workview_toggled(self, widget):
73 self.do_toggle_workview()
74@@ -1262,12 +1281,24 @@
75 if pthinfo is not None:
76 path, col, cellx, celly = pthinfo #pylint: disable-msg=W0612
77 treeview.grab_focus()
78+ # The location we want the cursor to return to
79+ # after we're done.
80+ self.previous_cursor = treeview.get_cursor()
81+ # For use in is_task_visible
82+ self.previous_tag = self.get_selected_tags()
83+ # Let's us know that we're working on a tag.
84+ self.tag_active = True
85+
86+ # This location is stored in case we need to work with it
87+ # later on.
88+ self.target_cursor = path, col
89 treeview.set_cursor(path, col, 0)
90 selected_tags = self.get_selected_tags()[0]
91 if len(selected_tags) > 0:
92 # Then we are looking at single, normal tag rather than
93 # the special 'All tags' or 'Tasks without tags'. We only
94 # want to popup the menu for normal tags.
95+
96 display_in_workview_item = self.tagpopup.get_children()[2]
97 selected_tag = selected_tags[0]
98 nonworkview = selected_tag.get_attribute("nonworkview")
99@@ -1278,11 +1309,22 @@
100 shown = False
101 else:
102 shown = True
103+ # HACK: CheckMenuItem.set_active() emits a toggled() when
104+ # switching between True and False, which will reset
105+ # the cursor. Using self.dont_reset to work around that.
106+ # Calling set_target_cursor after set_active() is another
107+ # option, but there's noticeable amount of lag when right
108+ # clicking tags that way.
109+ self.dont_reset = True
110 display_in_workview_item.set_active(shown)
111+ self.dont_reset = False
112 self.tagpopup.popup(None, None, None, event.button, time)
113+ else:
114+ self.reset_cursor()
115 return 1
116
117 def on_nonworkviewtag_toggled(self, widget):
118+ self.set_target_cursor()
119 tags = self.get_selected_tags()[0]
120 nonworkview_item = self.nonworkviewtag_checkbox
121 #We must inverse because the tagstore has True
122@@ -1293,6 +1335,8 @@
123 if self.priv['workview']:
124 self.task_modelfilter.refilter()
125 self.tag_modelfilter.refilter()
126+ if not self.dont_reset:
127+ self.reset_cursor()
128
129 def on_task_treeview_button_press_event(self, treeview, event):
130 if event.button == 3:
131@@ -1702,7 +1746,29 @@
132 count = count + 1 + self._count_subtask(model, c)
133 c = model.iter_next(c)
134 return count
135-
136+
137+ def reset_cursor(self):
138+ """ Returns the cursor to the tag that was selected prior
139+ to any right click action. Should be used whenever we're done
140+ working with any tag through a right click menu action.
141+ """
142+ if self.tag_active:
143+ self.tag_active = False
144+ path, col = self.previous_cursor
145+ self.tags_tv.set_cursor(path, col, 0)
146+
147+ def set_target_cursor(self):
148+ """ Selects the last tag to be right clicked.
149+
150+ We need this because the context menu will deactivate
151+ (and in turn, call reset_cursor()) before, for example, the color
152+ picker dialog begins. Should be used at the beginning of any tag
153+ editing function to remind the user which tag they're working with.
154+ """
155+ if not self.tag_active:
156+ self.tag_active = True
157+ path, col = self.target_cursor
158+ self.tags_tv.set_cursor(path, col, 0)
159
160 ### MAIN ######################################################################
161 #
162
163=== modified file 'GTG/taskbrowser/taskbrowser.glade'
164--- GTG/taskbrowser/taskbrowser.glade 2010-01-05 23:06:01 +0000
165+++ GTG/taskbrowser/taskbrowser.glade 2010-01-17 20:16:13 +0000
166@@ -762,6 +762,7 @@
167 <object class="GtkMenu" id="TagContextMenu">
168 <property name="visible">True</property>
169 <property name="no_show_all">True</property>
170+ <signal name="deactivate" handler="on_tagcontext_deactivate"/>
171 <child>
172 <object class="GtkImageMenuItem" id="colorchooser">
173 <property name="label">gtk-select-color</property>

Subscribers

People subscribed via source and target branches

to status/vote changes: