Merge lp://staging/~bryce/gtg/code-cleanup into lp://staging/~gtg/gtg/old-trunk
- code-cleanup
- Merge into old-trunk
Proposed by
Bryce Harrington
Status: | Merged |
---|---|
Merge reported by: | Luca Invernizzi |
Merged at revision: | not available |
Proposed branch: | lp://staging/~bryce/gtg/code-cleanup |
Merge into: | lp://staging/~gtg/gtg/old-trunk |
Diff against target: |
211 lines (+26/-27) 4 files modified
GTG/core/requester.py (+1/-0) GTG/taskeditor/editor.py (+13/-14) GTG/taskeditor/taskview.py (+9/-10) GTG/taskeditor/taskviewserial.py (+3/-3) |
To merge this branch: | bzr merge lp://staging/~bryce/gtg/code-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Luca Invernizzi (community) | Approve | ||
Review via email: mp+19068@code.staging.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote : | # |
Revision history for this message
Luca Invernizzi (invernizzi) : | # |
review:
Approve
- 589. By Luca Invernizzi
-
Bryce's code cleanup
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'GTG/core/requester.py' | |||
2 | --- GTG/core/requester.py 2009-12-26 20:57:17 +0000 | |||
3 | +++ GTG/core/requester.py 2010-02-11 01:59:13 +0000 | |||
4 | @@ -83,6 +83,7 @@ | |||
5 | 83 | task will have no tags. | 83 | task will have no tags. |
6 | 84 | @param newtask: C{True} if this is creating a new task that never | 84 | @param newtask: C{True} if this is creating a new task that never |
7 | 85 | existed, C{False} if importing an existing task from a backend. | 85 | existed, C{False} if importing an existing task from a backend. |
8 | 86 | @return: A task. | ||
9 | 86 | """ | 87 | """ |
10 | 87 | task = self.ds.new_task(pid=pid, newtask=newtask) | 88 | task = self.ds.new_task(pid=pid, newtask=newtask) |
11 | 88 | if tags: | 89 | if tags: |
12 | 89 | 90 | ||
13 | === modified file 'GTG/taskeditor/editor.py' | |||
14 | --- GTG/taskeditor/editor.py 2010-01-21 17:34:00 +0000 | |||
15 | +++ GTG/taskeditor/editor.py 2010-02-11 01:59:13 +0000 | |||
16 | @@ -19,9 +19,9 @@ | |||
17 | 19 | 19 | ||
18 | 20 | #This is the TaskEditor | 20 | #This is the TaskEditor |
19 | 21 | # | 21 | # |
21 | 22 | #It's the window you see when you double-clic on a Task | 22 | #It's the window you see when you double-click on a Task |
22 | 23 | #The main text widget is a home-made TextView called TaskView (see taskview.py) | 23 | #The main text widget is a home-made TextView called TaskView (see taskview.py) |
24 | 24 | #The rest are the logic of the widget : date changing widgets, buttons, ... | 24 | #The rest is the logic of the widget : date changing widgets, buttons, ... |
25 | 25 | import sys | 25 | import sys |
26 | 26 | import time | 26 | import time |
27 | 27 | 27 | ||
28 | @@ -50,7 +50,7 @@ | |||
29 | 50 | #delete_callback is the function called on deletion | 50 | #delete_callback is the function called on deletion |
30 | 51 | #close_callback is the function called on close | 51 | #close_callback is the function called on close |
31 | 52 | #opentask_callback is the function to open a new editor | 52 | #opentask_callback is the function to open a new editor |
33 | 53 | #tasktitle_callbakc is called when title change | 53 | #tasktitle_callback is called when title changes |
34 | 54 | #notes is experimental (bool) | 54 | #notes is experimental (bool) |
35 | 55 | #taskconfig is a ConfigObj dic to save infos about tasks | 55 | #taskconfig is a ConfigObj dic to save infos about tasks |
36 | 56 | #thisisnew is True when a new task is created and opened | 56 | #thisisnew is True when a new task is created and opened |
37 | @@ -69,10 +69,10 @@ | |||
38 | 69 | self.dismissbutton = self.builder.get_object("dismiss_editor") | 69 | self.dismissbutton = self.builder.get_object("dismiss_editor") |
39 | 70 | self.deletebutton = self.builder.get_object("delete_editor") | 70 | self.deletebutton = self.builder.get_object("delete_editor") |
40 | 71 | self.deletebutton.set_tooltip_text(GnomeConfig.DELETE_TOOLTIP) | 71 | self.deletebutton.set_tooltip_text(GnomeConfig.DELETE_TOOLTIP) |
45 | 72 | self.deletebutton = self.builder.get_object("insert_subtask") | 72 | self.subtask_button = self.builder.get_object("insert_subtask") |
46 | 73 | self.deletebutton.set_tooltip_text(GnomeConfig.SUBTASK_TOOLTIP) | 73 | self.subtask_button.set_tooltip_text(GnomeConfig.SUBTASK_TOOLTIP) |
47 | 74 | self.deletebutton = self.builder.get_object("inserttag") | 74 | self.inserttag_button = self.builder.get_object("inserttag") |
48 | 75 | self.deletebutton.set_tooltip_text(GnomeConfig.TAG_TOOLTIP) | 75 | self.inserttag_button.set_tooltip_text(GnomeConfig.TAG_TOOLTIP) |
49 | 76 | #Create our dictionary and connect it | 76 | #Create our dictionary and connect it |
50 | 77 | dic = { | 77 | dic = { |
51 | 78 | "mark_as_done_clicked" : self.change_status, | 78 | "mark_as_done_clicked" : self.change_status, |
52 | @@ -122,7 +122,6 @@ | |||
53 | 122 | self.duedate_widget = self.builder.get_object("duedate_entry") | 122 | self.duedate_widget = self.builder.get_object("duedate_entry") |
54 | 123 | self.startdate_widget = self.builder.get_object("startdate_entry") | 123 | self.startdate_widget = self.builder.get_object("startdate_entry") |
55 | 124 | self.dayleft_label = self.builder.get_object("dayleft") | 124 | self.dayleft_label = self.builder.get_object("dayleft") |
56 | 125 | self.inserttag_button = self.builder.get_object("inserttag") | ||
57 | 126 | self.tasksidebar = self.builder.get_object("tasksidebar") | 125 | self.tasksidebar = self.builder.get_object("tasksidebar") |
58 | 127 | self.keepnote_button = self.builder.get_object("keepnote") | 126 | self.keepnote_button = self.builder.get_object("keepnote") |
59 | 128 | if not notes : | 127 | if not notes : |
60 | @@ -249,11 +248,11 @@ | |||
61 | 249 | dismiss_editor.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE) | 248 | dismiss_editor.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE) |
62 | 250 | 249 | ||
63 | 251 | 250 | ||
66 | 252 | #Can be called at any time to reflect the status of the Task | 251 | #Can be called at any time to reflect the status of the Task. |
67 | 253 | #Refresh should never interfer with the TaskView | 252 | #Refresh should never interfere with the TaskView. |
68 | 254 | #If a title is passed as a parameter, it will become | 253 | #If a title is passed as a parameter, it will become |
71 | 255 | #The new window title. If not, we will look for the task title | 254 | #the new window title. If not, we will look for the task title. |
72 | 256 | #Refreshtext is wheter or not we should refresh the TaskView | 255 | #Refreshtext is whether or not we should refresh the TaskView |
73 | 257 | #(doing it all the time is dangerous if the task is empty) | 256 | #(doing it all the time is dangerous if the task is empty) |
74 | 258 | def refresh_editor(self, title=None, refreshtext=False): | 257 | def refresh_editor(self, title=None, refreshtext=False): |
75 | 259 | to_save = False | 258 | to_save = False |
76 | @@ -399,7 +398,7 @@ | |||
77 | 399 | self.calendar.grab_add() | 398 | self.calendar.grab_add() |
78 | 400 | #We grab the pointer in the calendar | 399 | #We grab the pointer in the calendar |
79 | 401 | gdk.pointer_grab(self.calendar.window, True,gdk.BUTTON1_MASK|gdk.MOD2_MASK) | 400 | gdk.pointer_grab(self.calendar.window, True,gdk.BUTTON1_MASK|gdk.MOD2_MASK) |
81 | 402 | #we will close the calendar if the user clic outside | 401 | #we will close the calendar if the user clicks outside |
82 | 403 | 402 | ||
83 | 404 | if not isinstance(toset, dates.FuzzyDate): | 403 | if not isinstance(toset, dates.FuzzyDate): |
84 | 405 | if not toset: | 404 | if not toset: |
85 | @@ -598,7 +597,7 @@ | |||
86 | 598 | 597 | ||
87 | 599 | 598 | ||
88 | 600 | def __focus_out(self,w=None,e=None) : #pylint: disable-msg=W0613 | 599 | def __focus_out(self,w=None,e=None) : #pylint: disable-msg=W0613 |
90 | 601 | #We should only close if the pointer clic is out of the calendar ! | 600 | #We should only close if the pointer click is out of the calendar ! |
91 | 602 | p = self.calendar.window.get_pointer() | 601 | p = self.calendar.window.get_pointer() |
92 | 603 | s = self.calendar.get_size() | 602 | s = self.calendar.get_size() |
93 | 604 | if not(0 <= p[0] <= s[0] and 0 <= p[1] <= s[1]) : | 603 | if not(0 <= p[0] <= s[0] and 0 <= p[1] <= s[1]) : |
94 | 605 | 604 | ||
95 | === modified file 'GTG/taskeditor/taskview.py' | |||
96 | --- GTG/taskeditor/taskview.py 2010-01-10 11:45:45 +0000 | |||
97 | +++ GTG/taskeditor/taskview.py 2010-02-11 01:59:13 +0000 | |||
98 | @@ -20,9 +20,9 @@ | |||
99 | 20 | 20 | ||
100 | 21 | #This is a class taken originally from | 21 | #This is a class taken originally from |
101 | 22 | #http://trac.atzm.org/index.cgi/wiki/PyGTK | 22 | #http://trac.atzm.org/index.cgi/wiki/PyGTK |
103 | 23 | #It was in Japanese and I didn't understood anything but the code. | 23 | #It was in Japanese and I didn't understand anything but the code. |
104 | 24 | 24 | ||
106 | 25 | #This class implement a gtk.TextView but with many other features | 25 | #This class implements a gtk.TextView but with many other features |
107 | 26 | #like hyperlink and others stuffs special for GTG | 26 | #like hyperlink and others stuffs special for GTG |
108 | 27 | # | 27 | # |
109 | 28 | #For your information, a gtkTextView always contains a gtk.TextBuffer which | 28 | #For your information, a gtkTextView always contains a gtk.TextBuffer which |
110 | @@ -538,7 +538,6 @@ | |||
111 | 538 | #Detect URL in the tasks | 538 | #Detect URL in the tasks |
112 | 539 | #It's ugly... | 539 | #It's ugly... |
113 | 540 | def _detect_url(self,buff,start,end) : | 540 | def _detect_url(self,buff,start,end) : |
114 | 541 | #firtst, we remove the old tags : | ||
115 | 542 | #subt_list = self.get_subtasks() | 541 | #subt_list = self.get_subtasks() |
116 | 543 | #First, we remove the olds tags | 542 | #First, we remove the olds tags |
117 | 544 | tag_list = [] | 543 | tag_list = [] |
118 | @@ -587,7 +586,7 @@ | |||
119 | 587 | 586 | ||
120 | 588 | 587 | ||
121 | 589 | 588 | ||
123 | 590 | #Detect tags in buff in the regio between start iter and end iter | 589 | #Detect tags in buff in the region between start iter and end iter |
124 | 591 | def _detect_tag(self,buff,start,end) : | 590 | def _detect_tag(self,buff,start,end) : |
125 | 592 | # Removing already existing tag in the current selection | 591 | # Removing already existing tag in the current selection |
126 | 593 | # out of the tag table | 592 | # out of the tag table |
127 | @@ -596,7 +595,7 @@ | |||
128 | 596 | old_tags = [] | 595 | old_tags = [] |
129 | 597 | new_tags = [] | 596 | new_tags = [] |
130 | 598 | #We must be strictly < than the end_offset. If not, we might | 597 | #We must be strictly < than the end_offset. If not, we might |
132 | 599 | #found the beginning of a tag on the nextline | 598 | #find the beginning of a tag on the nextline |
133 | 600 | while (it.get_offset() < end.get_offset()) and (it.get_char() != '\0'): | 599 | while (it.get_offset() < end.get_offset()) and (it.get_char() != '\0'): |
134 | 601 | if it.begins_tag() : | 600 | if it.begins_tag() : |
135 | 602 | tags = it.get_toggled_tags(True) | 601 | tags = it.get_toggled_tags(True) |
136 | @@ -687,7 +686,7 @@ | |||
137 | 687 | to_return = True | 686 | to_return = True |
138 | 688 | return to_return | 687 | return to_return |
139 | 689 | 688 | ||
141 | 690 | #When the user remove a selection, we remove subtasks and @tags | 689 | #When the user removes a selection, we remove subtasks and @tags |
142 | 691 | #from this selection | 690 | #from this selection |
143 | 692 | def _delete_range(self,buff,start,end) : | 691 | def _delete_range(self,buff,start,end) : |
144 | 693 | # #If we are at the beginning of a mark, put this mark at the end | 692 | # #If we are at the beginning of a mark, put this mark at the end |
145 | @@ -914,7 +913,7 @@ | |||
146 | 914 | itera = buff.get_iter_at_mark(temp_mark) | 913 | itera = buff.get_iter_at_mark(temp_mark) |
147 | 915 | buff.move_mark_by_name("/%s"%subtid,itera) | 914 | buff.move_mark_by_name("/%s"%subtid,itera) |
148 | 916 | buff.delete_mark(temp_mark) | 915 | buff.delete_mark(temp_mark) |
150 | 917 | #The mark has right gravity but because we putted it on the left | 916 | #The mark has right gravity but because we put it on the left |
151 | 918 | #of the newly inserted \n, it will not move anymore. | 917 | #of the newly inserted \n, it will not move anymore. |
152 | 919 | 918 | ||
153 | 920 | itera = buff.get_iter_at_mark(end) | 919 | itera = buff.get_iter_at_mark(end) |
154 | @@ -1017,7 +1016,7 @@ | |||
155 | 1017 | #we keep the normal pasting by not interupting the signal | 1016 | #we keep the normal pasting by not interupting the signal |
156 | 1018 | self.clipboard.clear() | 1017 | self.clipboard.clear() |
157 | 1019 | 1018 | ||
159 | 1020 | #Function called each time the user input a letter | 1019 | #Function called each time the user inputs a letter |
160 | 1021 | def _insert_at_cursor(self, tv, itera, tex, leng) : | 1020 | def _insert_at_cursor(self, tv, itera, tex, leng) : |
161 | 1022 | #We don't paste the bullet | 1021 | #We don't paste the bullet |
162 | 1023 | if tex.strip() != self.bullet1 : | 1022 | if tex.strip() != self.bullet1 : |
163 | @@ -1214,7 +1213,7 @@ | |||
164 | 1214 | self.buff.disconnect(self.insert_sigid) | 1213 | self.buff.disconnect(self.insert_sigid) |
165 | 1215 | insert_mark = self.buff.get_insert() | 1214 | insert_mark = self.buff.get_insert() |
166 | 1216 | insert_iter = self.buff.get_iter_at_mark(insert_mark) | 1215 | insert_iter = self.buff.get_iter_at_mark(insert_mark) |
168 | 1217 | #All that craps to find if we are at the end of an indent tag | 1216 | #All this crap to find if we are at the end of an indent tag |
169 | 1218 | if insert_iter.ends_tag() : | 1217 | if insert_iter.ends_tag() : |
170 | 1219 | for t in insert_iter.get_toggled_tags(False) : | 1218 | for t in insert_iter.get_toggled_tags(False) : |
171 | 1220 | if t.get_data('is_indent') : | 1219 | if t.get_data('is_indent') : |
172 | @@ -1226,7 +1225,7 @@ | |||
173 | 1226 | self.insert_sigid = self.buff.connect('insert-text', \ | 1225 | self.insert_sigid = self.buff.connect('insert-text', \ |
174 | 1227 | self._insert_at_cursor) | 1226 | self._insert_at_cursor) |
175 | 1228 | 1227 | ||
177 | 1229 | #The mouse is moving. We must change it to a hand when hovering a link | 1228 | #The mouse is moving. We must change it to a hand when hovering over a link |
178 | 1230 | def _motion(self, view, ev): | 1229 | def _motion(self, view, ev): |
179 | 1231 | window = ev.window | 1230 | window = ev.window |
180 | 1232 | x, y, _ = window.get_pointer() | 1231 | x, y, _ = window.get_pointer() |
181 | 1233 | 1232 | ||
182 | === modified file 'GTG/taskeditor/taskviewserial.py' | |||
183 | --- GTG/taskeditor/taskviewserial.py 2010-01-07 16:30:30 +0000 | |||
184 | +++ GTG/taskeditor/taskviewserial.py 2010-02-11 01:59:13 +0000 | |||
185 | @@ -72,7 +72,7 @@ | |||
186 | 72 | while not buffer_end: | 72 | while not buffer_end: |
187 | 73 | if tag is None: | 73 | if tag is None: |
188 | 74 | # We are not in a tag context | 74 | # We are not in a tag context |
190 | 75 | # Get list of know tags witch begin here | 75 | # Get list of know tags which begin here |
191 | 76 | # and are not already process | 76 | # and are not already process |
192 | 77 | tags = [] | 77 | tags = [] |
193 | 78 | for ta in it.get_tags(): | 78 | for ta in it.get_tags(): |
194 | @@ -135,7 +135,7 @@ | |||
195 | 135 | if last_val and last_val.nodeType == 3 and \ | 135 | if last_val and last_val.nodeType == 3 and \ |
196 | 136 | last_val.nodeValue[-1] != '\n': | 136 | last_val.nodeValue[-1] != '\n': |
197 | 137 | parent.appendChild(doc.createTextNode('\n')) | 137 | parent.appendChild(doc.createTextNode('\n')) |
199 | 138 | #This function concatenate all the adjacent text node of the XML | 138 | #This function concatenates all the adjacent text node of the XML |
200 | 139 | parent.normalize() | 139 | parent.normalize() |
201 | 140 | return parent | 140 | return parent |
202 | 141 | 141 | ||
203 | @@ -163,7 +163,7 @@ | |||
204 | 163 | 163 | ||
205 | 164 | #Insert a list of subtasks at the end of the buffer | 164 | #Insert a list of subtasks at the end of the buffer |
206 | 165 | def insert_subtasks(self, buff, st_list): | 165 | def insert_subtasks(self, buff, st_list): |
208 | 166 | #It the lastline of the buffer is not empty, we add an extra \n | 166 | #If the lastline of the buffer is not empty, we add an extra \n |
209 | 167 | end_end = buff.get_end_iter() | 167 | end_end = buff.get_end_iter() |
210 | 168 | end_line = end_end.get_line() | 168 | end_line = end_end.get_line() |
211 | 169 | start_end = buff.get_iter_at_line(end_line) | 169 | start_end = buff.get_iter_at_line(end_line) |
Spelling fixes and a couple code cleanup type things