GTG

Merge lp:~izidor/gtg/pep8-gtk into lp:~gtg/gtg/old-trunk

Proposed by Izidor Matušov
Status: Merged
Merged at revision: 1254
Proposed branch: lp:~izidor/gtg/pep8-gtk
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 1911 lines (+373/-323)
10 files modified
GTG/gtk/browser/CellRendererTags.py (+21/-21)
GTG/gtk/browser/browser.py (+13/-17)
GTG/gtk/browser/tag_context_menu.py (+4/-5)
GTG/gtk/browser/treeview_factory.py (+95/-95)
GTG/gtk/crashhandler.py (+1/-1)
GTG/gtk/delete_dialog.py (+12/-10)
GTG/gtk/editor/__init__.py (+2/-2)
GTG/gtk/editor/editor.py (+67/-52)
GTG/gtk/editor/taskview.py (+155/-117)
GTG/gtk/editor/taskviewserial.py (+3/-3)
To merge this branch: bzr merge lp:~izidor/gtg/pep8-gtk
Reviewer Review Type Date Requested Status
Bertrand Rousseau (community) code Approve
Review via email: mp+136066@code.launchpad.net

Description of the change

Partial PEP8-ification of GTG/gtk folder (until I ran out of battery during refactoring :/)

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

Ok for me. There are some comments that could probably be deleted here and there (mainly editor.py), but that can be done in another pass.

review: Approve (code)
Revision history for this message
Izidor Matušov (izidor) wrote :

I didn't want to remove them because of merge/including code from Steve's GSoC editor rework.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/gtk/browser/CellRendererTags.py'
2--- GTG/gtk/browser/CellRendererTags.py 2012-05-23 08:55:31 +0000
3+++ GTG/gtk/browser/CellRendererTags.py 2012-11-25 21:29:25 +0000
4@@ -32,9 +32,9 @@
5
6 class CellRendererTags(gtk.GenericCellRenderer):
7 __gproperties__ = {
8- 'tag_list': (gobject.TYPE_PYOBJECT,\
9+ 'tag_list': (gobject.TYPE_PYOBJECT,
10 "Tag list", "A list of tags", gobject.PARAM_READWRITE),
11- 'tag': (gobject.TYPE_PYOBJECT, "Tag",\
12+ 'tag': (gobject.TYPE_PYOBJECT, "Tag",
13 "Tag", gobject.PARAM_READWRITE),
14 }
15
16@@ -66,7 +66,7 @@
17 if self.tag_list != None:
18 for my_tag in self.tag_list:
19 my_tag_color = my_tag.get_attribute("color")
20- my_tag_icon = my_tag.get_attribute("icon")
21+ my_tag_icon = my_tag.get_attribute("icon")
22 if my_tag_color or my_tag_icon:
23 count = count + 1
24 elif self.tag != None:
25@@ -80,10 +80,10 @@
26 def __init__(self): #pylint: disable-msg=W0231
27 self.__gobject_init__()
28 self.tag_list = None
29- self.tag = None
30- self.xpad = 1
31- self.ypad = 1
32- self.PADDING = 1
33+ self.tag = None
34+ self.xpad = 1
35+ self.ypad = 1
36+ self.PADDING = 1
37
38 def do_set_property(self, pspec, value):
39 if pspec.name == "tag-list":
40@@ -97,11 +97,11 @@
41 else:
42 return getattr(self, pspec.name)
43
44- def on_render(\
45- self, window, widget, background_area, cell_area, expose_area, flags):
46+ def on_render(self, window, widget, background_area, cell_area,
47+ expose_area, flags):
48
49 vw_tags = self.__count_viewable_tags()
50- count = 0
51+ count = 0
52
53 # Select source
54 if self.tag_list != None:
55@@ -112,25 +112,25 @@
56 return
57
58 # Drawing context
59- cr = window.cairo_create()
60+ cr = window.cairo_create()
61 gdkcontext = gtk.gdk.CairoContext(cr)
62 gdkcontext.set_antialias(cairo.ANTIALIAS_NONE)
63
64 # Coordinates of the origin point
65 x_align = self.get_property("xalign")
66 y_align = self.get_property("yalign")
67- orig_x = cell_area.x + int((cell_area.width - 16*vw_tags -\
68+ orig_x = cell_area.x + int((cell_area.width - 16*vw_tags - \
69 self.PADDING*2*(vw_tags-1)) * x_align)
70- orig_y = cell_area.y + int((cell_area.height - 16) * y_align)
71+ orig_y = cell_area.y + int((cell_area.height - 16) * y_align)
72
73 # We draw the icons & squares
74 for my_tag in tags:
75
76- my_tag_icon = my_tag.get_attribute("icon")
77+ my_tag_icon = my_tag.get_attribute("icon")
78 my_tag_color = my_tag.get_attribute("color")
79
80- rect_x = orig_x + self.PADDING*2*count + 16*count
81- rect_y = orig_y
82+ rect_x = orig_x + self.PADDING*2*count + 16*count
83+ rect_y = orig_y
84
85 if my_tag_icon:
86 try:
87@@ -162,11 +162,10 @@
88
89 if self.tag and my_tag: #pylint: disable-msg=W0631
90
91- my_tag_icon = my_tag.get_attribute("icon")
92+ my_tag_icon = my_tag.get_attribute("icon")
93 my_tag_color = my_tag.get_attribute("color")
94
95- if not my_tag_icon and not my_tag_color:
96-
97+ if not my_tag_icon and not my_tag_color:
98 # Draw rounded rectangle
99 gdkcontext.set_source_rgba(0.95, 0.95, 0.95, 1)
100 self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8)
101@@ -183,8 +182,9 @@
102 count = self.__count_viewable_tags()
103
104 if count != 0:
105- return (self.xpad, self.ypad, self.xpad*2 + 16*count +\
106- 2*count*self.PADDING, 16 + 2*self.ypad)
107+ return (self.xpad, self.ypad,
108+ self.xpad*2 + 16*count + 2*count*self.PADDING,
109+ 16 + 2*self.ypad)
110 else:
111 return (self.xpad, self.ypad, self.xpad*2, self.ypad*2)
112
113
114=== modified file 'GTG/gtk/browser/browser.py'
115--- GTG/gtk/browser/browser.py 2012-11-01 10:09:06 +0000
116+++ GTG/gtk/browser/browser.py 2012-11-25 21:29:25 +0000
117@@ -46,9 +46,6 @@
118 from GTG.tools.dates import Date
119 from GTG.tools.logger import Log
120
121-#=== MAIN CLASS ===============================================================
122-
123-
124
125 class Timer:
126
127@@ -96,7 +93,7 @@
128
129 # Set up models
130 # Active Tasks
131- self.req.apply_global_filter(self.activetree,'active')
132+ self.req.apply_global_filter(self.activetree, 'active')
133 # Tags
134 self.tagtree = None
135 self.tagtreeview = None
136@@ -405,7 +402,7 @@
137 ### HELPER FUNCTIONS ########################################################
138 def open_preferences(self, widget):
139 self.vmanager.open_preferences(self.config)
140-
141+
142 def open_plugins(self, widget):
143 self.vmanager.configure_plugins()
144
145@@ -565,10 +562,10 @@
146
147 def set_view(self, viewname):
148 if viewname == 'default':
149- self.req.unapply_global_filter(self.activetree,'workview')
150+ self.req.unapply_global_filter(self.activetree, 'workview')
151 workview = False
152 elif viewname == 'workview':
153- self.req.apply_global_filter(self.activetree,'workview')
154+ self.req.apply_global_filter(self.activetree, 'workview')
155 workview = True
156 else:
157 raise Exception('Cannot set the view %s' %viewname)
158@@ -613,7 +610,6 @@
159 ### SIGNAL CALLBACKS ##########################################################
160 # Typically, reaction to user input & interactions with the GUI
161 #
162-
163 def on_sort_column_changed(self, model):
164 sort_column, sort_order = model.get_sort_column_id()
165
166@@ -755,7 +751,7 @@
167 colt = self.config.get("collapsed_tasks")
168 if tid not in colt:
169 colt.append(str(tid))
170-
171+
172 def on_tag_expanded(self, sender, tag):
173 colt = self.config.get("expanded_tags")
174 if tag not in colt:
175@@ -980,7 +976,7 @@
176 def on_delete_tasks(self, widget=None, tid=None):
177 #If we don't have a parameter, then take the selection in the treeview
178 if not tid:
179- #tid_to_delete is a [project,task] tuple
180+ #tid_to_delete is a [project, task] tuple
181 tids_todelete = self.get_selected_tasks()
182 if not tids_todelete:
183 return
184@@ -1110,13 +1106,13 @@
185 task.set_status(Task.STA_DISMISSED)
186 self.close_all_task_editors(uid)
187
188- def apply_filter_on_panes(self, filter_name,refresh=True):
189+ def apply_filter_on_panes(self, filter_name, refresh=True):
190 """ Apply filters for every pane: active tasks, closed tasks """
191 for pane in self.vtree_panes:
192 vtree = self.req.get_tasks_tree(name=pane, refresh=False)
193 vtree.apply_filter(filter_name, refresh=refresh)
194-
195- def unapply_filter_on_panes(self, filter_name,refresh=True):
196+
197+ def unapply_filter_on_panes(self, filter_name, refresh=True):
198 """ Apply filters for every pane: active tasks, closed tasks """
199 for pane in self.vtree_panes:
200 vtree = self.req.get_tasks_tree(name=pane, refresh=False)
201@@ -1130,11 +1126,11 @@
202
203 #When you click on a tag, you want to unselect the tasks
204 new_taglist = self.get_selected_tags()
205-
206+
207 for tagname in self.applied_tags:
208 if tagname not in new_taglist:
209- self.unapply_filter_on_panes(tagname,refresh=False)
210-
211+ self.unapply_filter_on_panes(tagname, refresh=False)
212+
213 for tagname in new_taglist:
214 if tagname not in self.applied_tags:
215 self.apply_filter_on_panes(tagname)
216@@ -1143,7 +1139,7 @@
217 tag = self.req.get_tag(tagname)
218 if tag.is_search_tag():
219 self.quickadd_entry.set_text(tag.get_attribute("query"))
220-
221+
222 self.applied_tags = new_taglist
223
224 def on_taskdone_cursor_changed(self, selection=None):
225
226=== modified file 'GTG/gtk/browser/tag_context_menu.py'
227--- GTG/gtk/browser/tag_context_menu.py 2012-05-23 08:55:31 +0000
228+++ GTG/gtk/browser/tag_context_menu.py 2012-11-25 21:29:25 +0000
229@@ -21,7 +21,7 @@
230 """
231 tag_context_menu:
232 Implements a context (pop-up) menu for the tag item in the sidebar.
233-Right now it is just a void shell It is supposed to become a more generic
234+Right now it is just a void shell It is supposed to become a more generic
235 sidebar context for all kind of item displayed there.
236 Also, it is supposed to handle more complex menus (with non-std widgets,
237 like a color picker)
238@@ -33,6 +33,7 @@
239
240 from GTG import _
241
242+
243 class TagContextMenu(gtk.Menu): # pylint: disable-msg=R0904
244 """Context menu fo the tag i the sidebar"""
245
246@@ -66,15 +67,13 @@
247 # Make it visible
248 self.show_all()
249
250- ### PUBLIC API ###
251-
252+ ### PUBLIC API ############################################################
253 def set_tag(self, tag):
254 """Update the context menu items using the tag attributes."""
255 self.tag = tag
256 self.__build_menu()
257
258- ### CALLBACKS ###
259-
260+ ### CALLBACKS #############################################################
261 def on_mi_cc_activate(self, widget): # pylint: disable-msg=W0613
262 """Callback: show the tag editor upon request"""
263 self.vmanager.open_tag_editor(self.tag)
264
265=== modified file 'GTG/gtk/browser/treeview_factory.py'
266--- GTG/gtk/browser/treeview_factory.py 2012-11-01 10:23:05 +0000
267+++ GTG/gtk/browser/treeview_factory.py 2012-11-25 21:29:25 +0000
268@@ -33,14 +33,14 @@
269
270 class TreeviewFactory():
271
272- def __init__(self,requester,config):
273+ def __init__(self, requester, config):
274 self.req = requester
275 self.mainview = self.req.get_tasks_tree()
276 self.config = config
277-
278+
279 #Initial unactive color
280- #This is a crude hack. As we don't have a reference to the
281- #treeview to retrieve the style, we save that color when we
282+ #This is a crude hack. As we don't have a reference to the
283+ #treeview to retrieve the style, we save that color when we
284 #build the treeview.
285 self.unactive_color = "#888a85"
286
287@@ -49,12 +49,12 @@
288
289 # Cache tags treeview for on_rename_tag callback
290 self.tags_view = None
291-
292+
293 #############################
294 #Functions for tasks columns
295 ################################
296-
297- def _has_hidden_subtask(self,task):
298+
299+ def _has_hidden_subtask(self, task):
300 #not recursive
301 display_count = self.mainview.node_n_children(task.get_id())
302 real_count = 0
303@@ -64,15 +64,15 @@
304 if sub_task and sub_task.get_status() == Task.STA_ACTIVE:
305 real_count = real_count + 1
306 return display_count < real_count
307-
308+
309 def task_bg_color(self, node, default_color):
310 if self.config.get('bg_color_enable'):
311 return colors.background_color(node.get_tags(), default_color)
312 else:
313 return None
314-
315+
316 #return an ordered list of tags of a task
317- def task_tags_column(self,node):
318+ def task_tags_column(self, node):
319 tags = node.get_tags()
320
321 search_parent = self.req.get_tag(CoreConfig.SEARCH_TAG)
322@@ -84,15 +84,15 @@
323
324 tags.sort(key = lambda x: x.get_name())
325 return tags
326-
327+
328 #task title
329 def task_title_column(self, node):
330 return saxutils.escape(node.get_title())
331-
332+
333 #task title/label
334 def task_label_column(self, node):
335 str_format = "%s"
336-
337+
338 if node.get_status() == Task.STA_ACTIVE:
339 # we mark in bold tasks which are due today or as Now
340 days_left = node.get_days_left()
341@@ -114,40 +114,40 @@
342 excerpt = saxutils.escape(node.get_excerpt(lines=1,
343 strip_tags=True, strip_subtasks=True))
344 title += " <span size='small' color='%s'>%s</span>" \
345- % (self.unactive_color, excerpt)
346+ % (self.unactive_color, excerpt)
347 return title
348-
349+
350 #task start date
351- def task_sdate_column(self,node):
352+ def task_sdate_column(self, node):
353 return node.get_start_date().to_readable_string()
354-
355- def task_duedate_column(self,node):
356+
357+ def task_duedate_column(self, node):
358 # We show the most constraining due date for task with no due dates.
359 if node.get_due_date() == Date.no_date():
360 return node.get_due_date_constraint().to_readable_string()
361 else:
362 # Other tasks show their due date (which *can* be fuzzy)
363 return node.get_due_date().to_readable_string()
364-
365- def task_cdate_column(self,node):
366+
367+ def task_cdate_column(self, node):
368 return node.get_closed_date().to_readable_string()
369-
370- def start_date_sorting(self,task1,task2,order):
371- sort = self.__date_comp(task1,task2,'start',order)
372- return sort
373-
374- def due_date_sorting(self,task1,task2,order):
375- sort = self.__date_comp(task1,task2,'due',order)
376- return sort
377-
378- def closed_date_sorting(self,task1,task2,order):
379- sort = self.__date_comp(task1,task2,'closed',order)
380- return sort
381-
382- def title_sorting(self,task1,task2,order):
383- return cmp(task1.get_title(),task2.get_title())
384-
385- def __date_comp(self,task1,task2,para,order):
386+
387+ def start_date_sorting(self, task1, task2, order):
388+ sort = self.__date_comp(task1, task2, 'start', order)
389+ return sort
390+
391+ def due_date_sorting(self, task1, task2, order):
392+ sort = self.__date_comp(task1, task2, 'due', order)
393+ return sort
394+
395+ def closed_date_sorting(self, task1, task2, order):
396+ sort = self.__date_comp(task1, task2, 'closed', order)
397+ return sort
398+
399+ def title_sorting(self, task1, task2, order):
400+ return cmp(task1.get_title(), task2.get_title())
401+
402+ def __date_comp(self, task1, task2, para, order):
403 '''This is a quite complex method to sort tasks by date,
404 handling fuzzy date and complex situation.
405 Return -1 if nid1 is before nid2, return 1 otherwise
406@@ -168,39 +168,39 @@
407 t2 = task2.get_closed_date()
408 else:
409 raise ValueError('invalid date comparison parameter: %s')%para
410- sort = cmp(t2,t1)
411+ sort = cmp(t2, t1)
412 else:
413 sort = 0
414-
415+
416 #local function
417 def reverse_if_descending(s):
418- """Make a cmp() result relative to the top instead of following
419+ """Make a cmp() result relative to the top instead of following
420 user-specified sort direction"""
421 if order == gtk.SORT_ASCENDING:
422 return s
423 else:
424 return -1*s
425
426- if sort == 0: # Group tasks with the same tag together for visual cleanness
427+ if sort == 0: # Group tasks with the same tag together for visual cleanness
428 t1_tags = task1.get_tags_name()
429 t1_tags.sort()
430 t2_tags = task2.get_tags_name()
431 t2_tags.sort()
432 sort = reverse_if_descending(cmp(t1_tags, t2_tags))
433-
434+
435 if sort == 0: # Break ties by sorting by title
436 t1_title = task1.get_title()
437 t2_title = task2.get_title()
438 t1_title = locale.strxfrm(t1_title)
439 t2_title = locale.strxfrm(t2_title)
440 sort = reverse_if_descending(cmp(t1_title, t2_title))
441-
442+
443 return sort
444-
445+
446 #############################
447 #Functions for tags columns
448 #############################
449- def tag_name(self,node):
450+ def tag_name(self, node):
451 label = node.get_attribute("label")
452 if label.startswith('@'):
453 label = label[1:]
454@@ -209,18 +209,18 @@
455 return "<span color='%s'>%s</span>" %(self.unactive_color, label)
456 else:
457 return label
458-
459- def get_tag_count(self,node):
460+
461+ def get_tag_count(self, node):
462 if node.get_id() == 'search':
463 return ""
464 else:
465 toreturn = node.get_active_tasks_count()
466- return "<span color='%s'>%s</span>" %(self.unactive_color,toreturn)
467-
468- def is_tag_separator_filter(self,tag):
469+ return "<span color='%s'>%s</span>" %(self.unactive_color, toreturn)
470+
471+ def is_tag_separator_filter(self, tag):
472 return tag.get_attribute('special') == 'sep'
473-
474- def tag_sorting(self,t1,t2,order):
475+
476+ def tag_sorting(self, t1, t2, order):
477 t1_sp = t1.get_attribute("special")
478 t2_sp = t2.get_attribute("special")
479 t1_name = locale.strxfrm(t1.get_name())
480@@ -235,8 +235,8 @@
481 t1_order = t1.get_attribute("order")
482 t2_order = t2.get_attribute("order")
483 return cmp(t1_order, t2_order)
484-
485- def ontag_task_dnd(self,source,target):
486+
487+ def ontag_task_dnd(self, source, target):
488 task = self.req.get_task(source)
489 if target.startswith('@'):
490 task.add_tag(target)
491@@ -248,7 +248,7 @@
492 ############################################
493 ######## The Factory #######################
494 ############################################
495- def tags_treeview(self,tree):
496+ def tags_treeview(self, tree):
497 desc = {}
498
499 #Tag id
500@@ -260,32 +260,32 @@
501 col['order'] = 0
502 col['sorting_func'] = self.tag_sorting
503 desc[col_name] = col
504-
505+
506 #Tags color
507 col_name = 'color'
508 col = {}
509 render_tags = CellRendererTags()
510 render_tags.set_property('ypad', 3)
511 col['title'] = _("Tags")
512- col['renderer'] = ['tag',render_tags]
513- col['value'] = [gobject.TYPE_PYOBJECT,lambda node: node]
514+ col['renderer'] = ['tag', render_tags]
515+ col['value'] = [gobject.TYPE_PYOBJECT, lambda node: node]
516 col['expandable'] = False
517 col['resizable'] = False
518 col['order'] = 1
519 desc[col_name] = col
520-
521+
522 #Tag names
523 col_name = 'tagname'
524 col = {}
525 render_text = gtk.CellRendererText()
526 render_text.set_property('ypad', 3)
527- col['renderer'] = ['markup',render_text]
528- col['value'] = [str,self.tag_name]
529+ col['renderer'] = ['markup', render_text]
530+ col['value'] = [str, self.tag_name]
531 col['expandable'] = True
532 col['new_column'] = False
533 col['order'] = 2
534 desc[col_name] = col
535-
536+
537 #Tag count
538 col_name = 'tagcount'
539 col = {}
540@@ -293,26 +293,26 @@
541 render_text.set_property('xpad', 3)
542 render_text.set_property('ypad', 3)
543 render_text.set_property('xalign', 1.0)
544- col['renderer'] = ['markup',render_text]
545- col['value'] = [str,self.get_tag_count]
546+ col['renderer'] = ['markup', render_text]
547+ col['value'] = [str, self.get_tag_count]
548 col['expandable'] = False
549 col['new_column'] = False
550 col['order'] = 3
551 desc[col_name] = col
552
553- return self.build_tag_treeview(tree,desc)
554-
555- def active_tasks_treeview(self,tree):
556+ return self.build_tag_treeview(tree, desc)
557+
558+ def active_tasks_treeview(self, tree):
559 #Build the title/label/tags columns
560 desc = self.common_desc_for_tasks(tree)
561-
562+
563 # "startdate" column
564 col_name = 'startdate'
565 col = {}
566 col['title'] = _("Start date")
567 col['expandable'] = False
568 col['resizable'] = False
569- col['value'] = [str,self.task_sdate_column]
570+ col['value'] = [str, self.task_sdate_column]
571 col['order'] = 3
572 col['sorting_func'] = self.start_date_sorting
573 desc[col_name] = col
574@@ -323,40 +323,40 @@
575 col['title'] = _("Due")
576 col['expandable'] = False
577 col['resizable'] = False
578- col['value'] = [str,self.task_duedate_column]
579+ col['value'] = [str, self.task_duedate_column]
580 col['order'] = 4
581 col['sorting_func'] = self.due_date_sorting
582 desc[col_name] = col
583
584 #Returning the treeview
585- treeview = self.build_task_treeview(tree,desc)
586+ treeview = self.build_task_treeview(tree, desc)
587 treeview.set_sort_column('duedate')
588 return treeview
589-
590- def closed_tasks_treeview(self,tree):
591+
592+ def closed_tasks_treeview(self, tree):
593 #Build the title/label/tags columns
594 desc = self.common_desc_for_tasks(tree)
595-
596+
597 # "startdate" column
598 col_name = 'closeddate'
599 col = {}
600 col['title'] = _("Closed date")
601 col['expandable'] = False
602 col['resizable'] = False
603- col['value'] = [str,self.task_cdate_column]
604+ col['value'] = [str, self.task_cdate_column]
605 col['order'] = 3
606 col['sorting_func'] = self.closed_date_sorting
607 desc[col_name] = col
608
609 #Returning the treeview
610- treeview = self.build_task_treeview(tree,desc)
611+ treeview = self.build_task_treeview(tree, desc)
612 treeview.set_sort_column('closeddate')
613 return treeview
614-
615-
616+
617+
618 #This build the first tag/title columns, common
619 #to both active and closed tasks treeview
620- def common_desc_for_tasks(self,tree):
621+ def common_desc_for_tasks(self, tree):
622 desc = {}
623
624 #invisible 'task_id' column
625@@ -380,20 +380,20 @@
626 col = {}
627 render_text = gtk.CellRendererText()
628 render_text.set_property("ellipsize", pango.ELLIPSIZE_END)
629- col['renderer'] = ['markup',render_text]
630- col['value'] = [str,self.task_title_column]
631+ col['renderer'] = ['markup', render_text]
632+ col['value'] = [str, self.task_title_column]
633 col['visible'] = False
634 col['order'] = 0
635 col['sorting_func'] = self.title_sorting
636 desc[col_name] = col
637-
638+
639 # "tags" column (no title)
640 col_name = 'tags'
641 col = {}
642 render_tags = CellRendererTags()
643 render_tags.set_property('xalign', 0.0)
644- col['renderer'] = ['tag_list',render_tags]
645- col['value'] = [gobject.TYPE_PYOBJECT,self.task_tags_column]
646+ col['renderer'] = ['tag_list', render_tags]
647+ col['value'] = [gobject.TYPE_PYOBJECT, self.task_tags_column]
648 col['expandable'] = False
649 col['resizable'] = False
650 col['order'] = 1
651@@ -405,18 +405,18 @@
652 col['title'] = _("Title")
653 render_text = gtk.CellRendererText()
654 render_text.set_property("ellipsize", pango.ELLIPSIZE_END)
655- col['renderer'] = ['markup',render_text]
656- col['value'] = [str,self.task_label_column]
657+ col['renderer'] = ['markup', render_text]
658+ col['value'] = [str, self.task_label_column]
659 col['expandable'] = True
660 col['resizable'] = True
661 col['sorting'] = 'title'
662 col['order'] = 2
663 desc[col_name] = col
664 return desc
665-
666-
667- def build_task_treeview(self,tree,desc):
668- treeview = TreeView(tree,desc)
669+
670+
671+ def build_task_treeview(self, tree, desc):
672+ treeview = TreeView(tree, desc)
673 #Now that the treeview is done, we can polish
674 treeview.set_main_search_column('label')
675 treeview.set_expander_column('label')
676@@ -431,19 +431,19 @@
677 self.unactive_color = \
678 treeview.style.text[gtk.STATE_INSENSITIVE].to_string()
679 return treeview
680-
681- def build_tag_treeview(self,tree,desc):
682- treeview = TreeView(tree,desc)
683+
684+ def build_tag_treeview(self, tree, desc):
685+ treeview = TreeView(tree, desc)
686 # Global treeview properties
687 treeview.set_property("enable-tree-lines", False)
688 treeview.set_rules_hint(False)
689 treeview.set_row_separator_func(self.is_tag_separator_filter)
690 treeview.set_headers_visible(False)
691 treeview.set_dnd_name('gtg/tag-iter-str')
692- treeview.set_dnd_external('gtg/task-iter-str',self.ontag_task_dnd)
693+ treeview.set_dnd_external('gtg/task-iter-str', self.ontag_task_dnd)
694 #Updating the unactive color (same for everyone)
695 self.unactive_color = \
696 treeview.style.text[gtk.STATE_INSENSITIVE].to_string()
697 treeview.set_sort_column('tag_id')
698 self.tags_view = treeview
699- return treeview
700+ return treeview
701
702=== modified file 'GTG/gtk/crashhandler.py'
703--- GTG/gtk/crashhandler.py 2012-07-23 12:04:01 +0000
704+++ GTG/gtk/crashhandler.py 2012-11-25 21:29:25 +0000
705@@ -332,7 +332,7 @@
706 yield
707
708 initialize(app_name = "Getting Things GNOME!",
709- message = "GTG" + info.VERSION +
710+ message = "GTG" + info.VERSION +
711 _(" has crashed. Please report the bug on <a href=\""
712 "http://bugs.edge.launchpad.net/gtg\">our Launchpad page</a>."
713 " If you have Apport installed, it will be started for you."),
714
715=== modified file 'GTG/gtk/delete_dialog.py'
716--- GTG/gtk/delete_dialog.py 2012-05-23 08:55:31 +0000
717+++ GTG/gtk/delete_dialog.py 2012-11-25 21:29:25 +0000
718@@ -24,18 +24,19 @@
719
720
721 class DeletionUI():
722-
723+
724 MAXIMUM_TIDS_TO_SHOW = 5
725+
726 def __init__(self, req):
727 self.req = req
728 self.tids_todelete = []
729 # Tags which must be updated
730 self.update_tags = []
731 # Load window tree
732- self.builder = gtk.Builder()
733+ self.builder = gtk.Builder()
734 self.builder.add_from_file(ViewConfig.DELETE_GLADE_FILE)
735- signals = { "on_delete_confirm": self.on_delete_confirm,
736- "on_delete_cancel": lambda x: x.hide,}
737+ signals = {"on_delete_confirm": self.on_delete_confirm,
738+ "on_delete_cancel": lambda x: x.hide, }
739 self.builder.connect_signals(signals)
740
741 def on_delete_confirm(self, widget):
742@@ -43,7 +44,7 @@
743 otherwise, we will look which tid is selected"""
744 for tid in self.tids_todelete:
745 if self.req.has_task(tid):
746- self.req.delete_task(tid,recursive=True)
747+ self.req.delete_task(tid, recursive=True)
748 self.tids_todelete = []
749
750 # Update tags
751@@ -60,10 +61,11 @@
752 tasklist=[]
753 self.update_tags = []
754 for tid in self.tids_todelete:
755+
756 def recursive_list_tasks(task_list, root):
757- """Populate a list of all the subtasks and
758+ """Populate a list of all the subtasks and
759 their children, recursively.
760-
761+
762 Also collect the list of affected tags
763 which should be refreshed"""
764 if root not in task_list:
765@@ -78,7 +80,7 @@
766 task = self.req.get_task(tid)
767 recursive_list_tasks(tasklist, task)
768
769- # We fill the text and the buttons' labels according to the number
770+ # We fill the text and the buttons' labels according to the number
771 # of tasks to delete
772 label = self.builder.get_object("label1")
773 label_text = label.get_text()
774@@ -104,7 +106,7 @@
775 "Permanently remove tasks",
776 singular))
777 label_text = label_text[0:label_text.find(":") + 1]
778-
779+
780 #we don't want to end with just one task that doesn't fit the
781 # screen and a line saying "And one more task", so we go a
782 # little over our limit
783@@ -123,7 +125,7 @@
784 cancel_button = self.builder.get_object("cancel")
785 cancel_button.grab_focus()
786 if delete_dialog.run() != 1:
787- tasklist = []
788+ tasklist = []
789 delete_dialog.hide()
790 return tasklist
791 else:
792
793=== modified file 'GTG/gtk/editor/__init__.py'
794--- GTG/gtk/editor/__init__.py 2012-05-23 08:55:31 +0000
795+++ GTG/gtk/editor/__init__.py 2012-11-25 21:29:25 +0000
796@@ -21,12 +21,12 @@
797 """
798 import os
799
800-from GTG import _
801+from GTG import _
802
803
804 class GnomeConfig:
805 current_rep = os.path.dirname(os.path.abspath(__file__))
806- GLADE_FILE = os.path.join(current_rep, "taskeditor.glade")
807+ GLADE_FILE = os.path.join(current_rep, "taskeditor.glade")
808
809 MARK_DONE = _("Mark as Done")
810 MARK_UNDONE = _("Mark as not Done")
811
812=== modified file 'GTG/gtk/editor/editor.py'
813--- GTG/gtk/editor/editor.py 2012-08-26 16:41:47 +0000
814+++ GTG/gtk/editor/editor.py 2012-11-25 21:29:25 +0000
815@@ -28,21 +28,22 @@
816 import pango
817 import gtk
818
819-from GTG import _, ngettext
820-from GTG.gtk.editor import GnomeConfig
821+from GTG import _, ngettext
822+from GTG.gtk.editor import GnomeConfig
823 from GTG.gtk.editor.taskview import TaskView
824 from GTG.core.plugins.engine import PluginEngine
825-from GTG.core.plugins.api import PluginAPI
826-from GTG.core.task import Task
827-from GTG.tools.dates import Date
828+from GTG.core.plugins.api import PluginAPI
829+from GTG.core.task import Task
830+from GTG.tools.dates import Date
831 from GTG.gtk.editor.calendar import GTGCalendar
832
833+
834 class TaskEditor:
835
836- def __init__(self,
837- requester,
838- vmanager,
839- task,
840+ def __init__(self,
841+ requester,
842+ vmanager,
843+ task,
844 taskconfig = None,
845 thisisnew = False,
846 clipboard = None):
847@@ -91,13 +92,13 @@
848 "on_move": self.on_move,
849 }
850 self.builder.connect_signals(dic)
851- self.window = self.builder.get_object("TaskEditor")
852+ self.window = self.builder.get_object("TaskEditor")
853 #Removing the Normal textview to replace it by our own
854 #So don't try to change anything with glade, this is a home-made widget
855 textview = self.builder.get_object("textview")
856 scrolled = self.builder.get_object("scrolledtask")
857 scrolled.remove(textview)
858- self.textview = TaskView(self.req, self.clipboard)
859+ self.textview = TaskView(self.req, self.clipboard)
860 self.textview.show()
861 self.textview.set_subtask_callback(self.new_subtask)
862 self.textview.open_task_callback(self.vmanager.open_task)
863@@ -106,13 +107,13 @@
864 scrolled.add(self.textview)
865 conf_font_value = self.browser_config.get("font_name")
866 if conf_font_value!= "":
867- self.textview.modify_font(pango.FontDescription(conf_font_value))
868+ self.textview.modify_font(pango.FontDescription(conf_font_value))
869 #Voila! it's done
870- self.calendar = GTGCalendar(self.builder)
871+ self.calendar = GTGCalendar(self.builder)
872 self.duedate_widget = self.builder.get_object("duedate_entry")
873 self.startdate_widget = self.builder.get_object("startdate_entry")
874 self.closeddate_widget = self.builder.get_object("closeddate_entry")
875- self.dayleft_label = self.builder.get_object("dayleft")
876+ self.dayleft_label = self.builder.get_object("dayleft")
877 self.tasksidebar = self.builder.get_object("tasksidebar")
878 # Define accelerator keys
879 self.init_accelerators()
880@@ -169,14 +170,15 @@
881 if tid in self.config:
882 if "position" in self.config[tid]:
883 pos = self.config[tid]["position"]
884- self.move(pos[0],pos[1])
885- #print "restoring position %s %s" %(pos[0],pos[1])
886+ self.move(pos[0], pos[1])
887+ #print "restoring position %s %s" %(pos[0], pos[1])
888 if "size" in self.config[tid]:
889 size = self.config[tid]["size"]
890 #print "size %s - %s" %(str(size[0]), str(size[1]))
891- #this eval(str()) is a ugly (!) hack to accept both int and str
892+ #this eval(str()) is a ugly (!) hack to accept both int and
893+ #str
894 #FIXME: Fix this!
895- self.window.resize(eval(str(size[0])),eval(str(size[1])))
896+ self.window.resize(eval(str(size[0])), eval(str(size[1])))
897
898 self.textview.set_editable(True)
899 self.window.show()
900@@ -201,18 +203,21 @@
901
902 # Ctrl-Shift-N creates a new subtask
903 insert_subtask = self.builder.get_object("insert_subtask")
904- key, mod = gtk.accelerator_parse("<Control><Shift>n")
905- insert_subtask.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE)
906+ key, mod = gtk.accelerator_parse("<Control><Shift>n")
907+ insert_subtask.add_accelerator('clicked', agr, key, mod,
908+ gtk.ACCEL_VISIBLE)
909
910 # Ctrl-D marks task as done
911 mark_as_done_editor = self.builder.get_object('mark_as_done_editor')
912 key, mod = gtk.accelerator_parse('<Control>d')
913- mark_as_done_editor.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE)
914+ mark_as_done_editor.add_accelerator('clicked', agr, key, mod,
915+ gtk.ACCEL_VISIBLE)
916
917 # Ctrl-I marks task as dismissed
918 dismiss_editor = self.builder.get_object('dismiss_editor')
919 key, mod = gtk.accelerator_parse('<Control>i')
920- dismiss_editor.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE)
921+ dismiss_editor.add_accelerator('clicked', agr, key, mod,
922+ gtk.ACCEL_VISIBLE)
923
924 #Can be called at any time to reflect the status of the Task
925 #Refresh should never interfere with the TaskView.
926@@ -224,34 +229,37 @@
927 if self.window == None:
928 return
929 to_save = False
930- #title of the window
931+ #title of the window
932 if title:
933 self.window.set_title(title)
934 to_save = True
935 else:
936 self.window.set_title(self.task.get_title())
937
938- status = self.task.get_status()
939+ status = self.task.get_status()
940 if status == Task.STA_DISMISSED:
941 self.donebutton.set_label(GnomeConfig.MARK_DONE)
942 self.donebutton.set_tooltip_text(GnomeConfig.MARK_DONE_TOOLTIP)
943 self.donebutton.set_icon_name("gtg-task-done")
944 self.dismissbutton.set_label(GnomeConfig.MARK_UNDISMISS)
945- self.dismissbutton.set_tooltip_text(GnomeConfig.MARK_UNDISMISS_TOOLTIP)
946+ self.dismissbutton.set_tooltip_text(
947+ nomeConfig.MARK_UNDISMISS_TOOLTIP)
948 self.dismissbutton.set_icon_name("gtg-task-undismiss")
949 elif status == Task.STA_DONE:
950 self.donebutton.set_label(GnomeConfig.MARK_UNDONE)
951 self.donebutton.set_tooltip_text(GnomeConfig.MARK_UNDONE_TOOLTIP)
952 self.donebutton.set_icon_name("gtg-task-undone")
953 self.dismissbutton.set_label(GnomeConfig.MARK_DISMISS)
954- self.dismissbutton.set_tooltip_text(GnomeConfig.MARK_DISMISS_TOOLTIP)
955+ self.dismissbutton.set_tooltip_text(
956+ GnomeConfig.MARK_DISMISS_TOOLTIP)
957 self.dismissbutton.set_icon_name("gtg-task-dismiss")
958 else:
959 self.donebutton.set_label(GnomeConfig.MARK_DONE)
960 self.donebutton.set_tooltip_text(GnomeConfig.MARK_DONE_TOOLTIP)
961 self.donebutton.set_icon_name("gtg-task-done")
962 self.dismissbutton.set_label(GnomeConfig.MARK_DISMISS)
963- self.dismissbutton.set_tooltip_text(GnomeConfig.MARK_DISMISS_TOOLTIP)
964+ self.dismissbutton.set_tooltip_text(
965+ GnomeConfig.MARK_DISMISS_TOOLTIP)
966 self.dismissbutton.set_icon_name("gtg-task-dismiss")
967 self.donebutton.show()
968 self.tasksidebar.show()
969@@ -265,7 +273,7 @@
970 else:
971 self.builder.get_object("label4").hide()
972 self.builder.get_object("hbox4").hide()
973- self.builder.get_object("label2").show()
974+ self.builder.get_object("label2").show()
975 self.builder.get_object("hbox1").show()
976
977 #refreshing the start date field
978@@ -277,7 +285,7 @@
979 update_date = True
980
981 if update_date:
982- self.startdate_widget.set_text(str(startdate))
983+ self.startdate_widget.set_text(str(startdate))
984
985 #refreshing the due date field
986 duedate = self.task.get_due_date()
987@@ -297,8 +305,8 @@
988 self.closeddate_widget.set_text(str(closeddate))
989
990 #refreshing the day left label
991- #If the task is marked as done, we display the delay between the
992- #due date and the actual closing date. If the task isn't marked
993+ #If the task is marked as done, we display the delay between the
994+ #due date and the actual closing date. If the task isn't marked
995 #as done, we display the number of days left.
996 if status in [Task.STA_DISMISSED, Task.STA_DONE]:
997 delay = self.task.get_days_late()
998@@ -307,22 +315,27 @@
999 elif delay == 0:
1000 txt = "Completed on time"
1001 elif delay >= 1:
1002- txt = ngettext("Completed %(days)d day late", "Completed %(days)d days late", delay) % {'days': delay}
1003+ txt = ngettext("Completed %(days)d day late",
1004+ "Completed %(days)d days late", delay) % {'days': delay}
1005 elif delay <= -1:
1006 abs_delay = abs(delay)
1007- txt = ngettext("Completed %(days)d day early", "Completed %(days)d days early", abs_delay) % {'days': abs_delay}
1008+ txt = ngettext("Completed %(days)d day early",
1009+ "Completed %(days)d days early", abs_delay) % \
1010+ {'days': abs_delay}
1011 else:
1012 due_date = self.task.get_due_date()
1013 result = due_date.days_left()
1014 if due_date.is_fuzzy():
1015 txt = ""
1016 elif result > 0:
1017- txt = ngettext("Due tomorrow!", "%(days)d days left", result) % {'days': result}
1018+ txt = ngettext("Due tomorrow!", "%(days)d days left", result) \
1019+ % {'days': result}
1020 elif result == 0:
1021 txt = _("Due today!")
1022 elif result < 0:
1023 abs_result = abs(result)
1024- txt = ngettext("Due yesterday!", "Was %(days)d days ago", abs_result) % {'days': abs_result}
1025+ txt = ngettext("Due yesterday!", "Was %(days)d days ago",
1026+ abs_result) % {'days': abs_result}
1027 window_style = self.window.get_style()
1028 color = str(window_style.text[gtk.STATE_INSENSITIVE])
1029 self.dayleft_label.set_markup("<span color='"+color+"'>"+txt+"</span>")
1030@@ -348,7 +361,7 @@
1031 if to_save:
1032 self.light_save()
1033
1034- def date_changed(self,widget,data):
1035+ def date_changed(self, widget, data):
1036 text = widget.get_text()
1037 valid = True
1038 if not text:
1039@@ -418,7 +431,7 @@
1040 for task in all_subtasks:
1041 self.vmanager.close_task(task.get_id())
1042
1043- def dismiss(self,widget): #pylint: disable-msg=W0613
1044+ def dismiss(self, widget): #pylint: disable-msg=W0613
1045 stat = self.task.get_status()
1046 if stat == "Dismiss":
1047 self.task.set_status("Active")
1048@@ -428,7 +441,7 @@
1049 self.close_all_subtasks()
1050 self.close(None)
1051
1052- def change_status(self,widget): #pylint: disable-msg=W0613
1053+ def change_status(self, widget): #pylint: disable-msg=W0613
1054 stat = self.task.get_status()
1055 if stat == "Done":
1056 self.task.set_status("Active")
1057@@ -447,7 +460,7 @@
1058 self.vmanager.ask_delete_tasks([self.task.get_id()])
1059
1060 #Take the title as argument and return the subtask ID
1061- def new_subtask(self,title=None,tid=None):
1062+ def new_subtask(self, title=None, tid=None):
1063 if tid:
1064 self.task.add_child(tid)
1065 elif title:
1066@@ -462,25 +475,25 @@
1067 task_id = task.get_id()
1068 self.vmanager.open_task(task_id)
1069
1070- def insert_subtask(self,widget): #pylint: disable-msg=W0613
1071+ def insert_subtask(self, widget): #pylint: disable-msg=W0613
1072 self.textview.insert_newtask()
1073 self.textview.grab_focus()
1074
1075- def inserttag_clicked(self,widget): #pylint: disable-msg=W0613
1076+ def inserttag_clicked(self, widget): #pylint: disable-msg=W0613
1077 itera = self.textview.get_insert()
1078 if itera.starts_line():
1079- self.textview.insert_text("@",itera)
1080+ self.textview.insert_text("@", itera)
1081 else:
1082- self.textview.insert_text(" @",itera)
1083+ self.textview.insert_text(" @", itera)
1084 self.textview.grab_focus()
1085
1086- def inserttag(self,widget,tag): #pylint: disable-msg=W0613
1087+ def inserttag(self, widget, tag): #pylint: disable-msg=W0613
1088 self.textview.insert_tags([tag])
1089 self.textview.grab_focus()
1090
1091 def save(self):
1092 self.task.set_title(self.textview.get_title())
1093- self.task.set_text(self.textview.get_text())
1094+ self.task.set_text(self.textview.get_text())
1095 self.task.sync()
1096 if self.config != None:
1097 self.config.write()
1098@@ -499,22 +512,22 @@
1099 if tosave:
1100 self.save()
1101
1102- #This will bring the Task Editor to front
1103+ #This will bring the Task Editor to front
1104 def present(self):
1105 self.window.present()
1106
1107- def move(self,x,y):
1108+ def move(self, x, y):
1109 try:
1110 xx=int(x)
1111 yy=int(y)
1112- self.window.move(xx,yy)
1113+ self.window.move(xx, yy)
1114 except:
1115 pass
1116
1117 def get_position(self):
1118 return self.window.get_position()
1119
1120- def on_move(self,widget,event):
1121+ def on_move(self, widget, event):
1122 #saving the position
1123 if self.config != None:
1124 tid = self.task.get_id()
1125@@ -525,17 +538,19 @@
1126 self.config[tid]["size"] = self.window.get_size()
1127
1128 #We define dummy variable for when close is called from a callback
1129- def close(self,window=None,a=None,b=None,c=None): #pylint: disable-msg=W0613
1130+ def close(self, window=None, a=None, b=None, c=None):
1131+ #pylint: disable-msg=W0613
1132 #We should also destroy the whole taskeditor object.
1133 if self.window:
1134 self.window.destroy()
1135 self.window = None
1136
1137 #The destroy signal is linked to the "close" button. So if we call
1138- #destroy in the close function, this will cause the close to be called twice
1139+ #destroy in the close function, this will cause the close to be called
1140+ #twice
1141 #To solve that, close will just call "destroy" and the destroy signal
1142 #Will be linked to this destruction method that will save the task
1143- def destruction(self,a=None):
1144+ def destruction(self, a=None):
1145 #Save should be also called when buffer is modified
1146 self.pengine.onTaskClose(self.plugin_api)
1147 self.pengine.remove_api(self.plugin_api)
1148
1149=== modified file 'GTG/gtk/editor/taskview.py'
1150--- GTG/gtk/editor/taskview.py 2012-10-23 09:31:00 +0000
1151+++ GTG/gtk/editor/taskview.py 2012-11-25 21:29:25 +0000
1152@@ -16,8 +16,6 @@
1153 # You should have received a copy of the GNU General Public License along with
1154 # this program. If not, see <http://www.gnu.org/licenses/>.
1155 # -----------------------------------------------------------------------------
1156-
1157-
1158 """
1159 This class implements a gtk.TextView but with many other features
1160 like hyperlink and other stuff special for GTG
1161@@ -40,10 +38,10 @@
1162 from GTG.gtk.editor import taskviewserial
1163 from GTG.tools import urlregex
1164
1165-separators = [' ', ',', '\n', '\t', '!', '?', ';', '\0','(',')']
1166+separators = [' ', ',', '\n', '\t', '!', '?', ';', '\0', '(', ')']
1167 #those separators are only separators if followed by a space. Else, they
1168 #are part of the word
1169-specials_separators = ['.','/']
1170+specials_separators = ['.', '/']
1171
1172 bullet1_ltr = '→'
1173 bullet1_rtl = '←'
1174@@ -51,22 +49,22 @@
1175
1176 class TaskView(gtk.TextView):
1177 __gtype_name__ = 'HyperTextView'
1178- __gsignals__ = {'anchor-clicked': (gobject.SIGNAL_RUN_LAST, \
1179+ __gsignals__ = {'anchor-clicked': (gobject.SIGNAL_RUN_LAST,
1180 None, (str, str, int))}
1181 __gproperties__ = {
1182- 'link': (gobject.TYPE_PYOBJECT, 'link color',\
1183+ 'link': (gobject.TYPE_PYOBJECT, 'link color',
1184 'link color of TextView', gobject.PARAM_READWRITE),
1185- 'failedlink': (gobject.TYPE_PYOBJECT, 'failed link color',\
1186+ 'failedlink': (gobject.TYPE_PYOBJECT, 'failed link color',
1187 'failed link color of TextView', gobject.PARAM_READWRITE),
1188- 'active': (gobject.TYPE_PYOBJECT, 'active color', \
1189+ 'active': (gobject.TYPE_PYOBJECT, 'active color',
1190 'active color of TextView', gobject.PARAM_READWRITE),
1191- 'hover': (gobject.TYPE_PYOBJECT, 'link:hover color', \
1192+ 'hover': (gobject.TYPE_PYOBJECT, 'link:hover color',
1193 'link:hover color of TextView', gobject.PARAM_READWRITE),
1194- 'tag': (gobject.TYPE_PYOBJECT, 'tag color', \
1195+ 'tag': (gobject.TYPE_PYOBJECT, 'tag color',
1196 'tag color of TextView', gobject.PARAM_READWRITE),
1197- 'done': (gobject.TYPE_PYOBJECT, 'link color', \
1198+ 'done': (gobject.TYPE_PYOBJECT, 'link color',
1199 'link color of TextView', gobject.PARAM_READWRITE),
1200- 'indent': (gobject.TYPE_PYOBJECT, 'indent color', \
1201+ 'indent': (gobject.TYPE_PYOBJECT, 'indent color',
1202 'indent color of TextView', gobject.PARAM_READWRITE),
1203 }
1204
1205@@ -83,22 +81,23 @@
1206 raise AttributeError('unknown property %s' % prop.name)
1207
1208 #Yes, we want to redefine the buffer. Disabling pylint on that error.
1209- def __init__(self, requester, clipboard, buffer=None): #pylint: disable-msg=W0622
1210+ def __init__(self, requester, clipboard, buffer=None):
1211+ #pylint: disable-msg=W0622
1212 gtk.TextView.__init__(self, buffer)
1213 self.buff = self.get_buffer()
1214 self.req = requester
1215 #Buffer init
1216- self.link = {'background': 'white', 'foreground': '#007bff', \
1217- 'underline': pango.UNDERLINE_SINGLE, \
1218- 'strikethrough': False}
1219- self.failedlink = {'background': 'white', 'foreground': '#ff5454', \
1220- 'underline': pango.UNDERLINE_NONE, \
1221- 'strikethrough': False}
1222- self.done = {'background': 'white', 'foreground': 'gray',\
1223+ self.link = {'background': 'white', 'foreground': '#007bff',
1224+ 'underline': pango.UNDERLINE_SINGLE,
1225+ 'strikethrough': False}
1226+ self.failedlink = {'background': 'white', 'foreground': '#ff5454',
1227+ 'underline': pango.UNDERLINE_NONE,
1228+ 'strikethrough': False}
1229+ self.done = {'background': 'white', 'foreground': 'gray',
1230 'strikethrough': True}
1231- self.active = {'background': 'light gray', 'foreground': '#ff1e00',\
1232+ self.active = {'background': 'light gray', 'foreground': '#ff1e00',
1233 'underline': pango.UNDERLINE_SINGLE}
1234- self.hover = {'background': 'light gray'}
1235+ self.hover = {'background': 'light gray'}
1236 self.tag = {'background': "#FFea00", 'foreground': 'black'}
1237 self.indent = {'scale': 1.4, 'editable': False, 'left-margin': 10,
1238 "accumulative-margin": True}
1239@@ -108,7 +107,7 @@
1240 # but set in self.modified)
1241 self.table = self.buff.get_tag_table()
1242 # Tag for title
1243- self.title_tag = self.buff.create_tag("title", foreground="#007bff", \
1244+ self.title_tag = self.buff.create_tag("title", foreground="#007bff",
1245 scale=1.6, underline=1)
1246 self.title_tag.set_property("pixels-above-lines", 10)
1247 self.title_tag.set_property("pixels-below-lines", 10)
1248@@ -125,13 +124,14 @@
1249
1250 #Signals
1251 self.connect('motion-notify-event', self._motion)
1252- self.connect('focus-out-event', lambda w, \
1253- e: self.table.foreach(self.__tag_reset, e.window))
1254- self.insert_sigid = self.buff.connect('insert-text', \
1255+ self.connect('focus-out-event',
1256+ lambda w, e: self.table.foreach(self.__tag_reset, e.window))
1257+ self.insert_sigid = self.buff.connect('insert-text',
1258 self._insert_at_cursor)
1259- self.delete_sigid = self.buff.connect("delete-range", self._delete_range)
1260- self.connect('copy-clipboard', self.copy_clipboard,"copy")
1261- self.connect('cut-clipboard', self.copy_clipboard,"cut")
1262+ self.delete_sigid = self.buff.connect("delete-range",
1263+ self._delete_range)
1264+ self.connect('copy-clipboard', self.copy_clipboard, "copy")
1265+ self.connect('cut-clipboard', self.copy_clipboard, "cut")
1266 self.connect('paste-clipboard', self.paste_clipboard)
1267
1268 self.connect('drag-data-received', self.drag_receive)
1269@@ -146,8 +146,10 @@
1270 self.mime_type = 'application/x-gtg-task'
1271 serializer = taskviewserial.Serializer()
1272 unserializer = taskviewserial.Unserializer(self)
1273- self.buff.register_serialize_format(self.mime_type, serializer.serialize, None)
1274- self.buff.register_deserialize_format(self.mime_type, unserializer.unserialize, None)
1275+ self.buff.register_serialize_format(self.mime_type,
1276+ serializer.serialize, None)
1277+ self.buff.register_deserialize_format(self.mime_type,
1278+ unserializer.unserialize, None)
1279
1280 #The list of callbacks we have to set
1281 self.remove_tag_callback = None
1282@@ -156,7 +158,7 @@
1283 self.get_subtasks = None
1284 self.remove_subtask =None
1285 self.__refresh_cb = None # refresh the editor window
1286- self.open_task = None # open another task
1287+ self.open_task = None # open another task
1288 self.new_subtask_callback = None # create a subtask
1289 self.save_task = None #This will save the task without refreshing all
1290
1291@@ -185,7 +187,8 @@
1292 #editable means that the user can edit the taskview
1293 #this is initially set at False and then to True once the editor window
1294 #is displayed.
1295- #this is used to avoid saving the task when the window is still not displayed
1296+ #this is used to avoid saving the task when the window is still
1297+ #not displayed
1298 def set_editable(self, boule):
1299 self.editable = boule
1300
1301@@ -270,7 +273,8 @@
1302
1303 #reconnect
1304 if reconnect_insert:
1305- self.insert_sigid = self.buff.connect('insert-text', self._insert_at_cursor)
1306+ self.insert_sigid = self.buff.connect('insert-text',
1307+ self._insert_at_cursor)
1308 if reconnect_modified:
1309 self.modified_sigid = self.buff.connect("changed", self.modified)
1310
1311@@ -308,7 +312,6 @@
1312 else:
1313 return True
1314
1315-
1316 def create_anchor_tag(self, b, anchor, text=None, typ=None):
1317 #We cannot have two tags with the same name
1318 #That's why the link tag has no name
1319@@ -326,7 +329,8 @@
1320 if linktype == 'link' and not self.check_link(anchor):
1321 linktype = 'failedlink'
1322
1323- tag = b.create_tag(None, **self.get_property(linktype)) #pylint: disable-msg=W0142
1324+ #pylint: disable-msg=W0142
1325+ tag = b.create_tag(None, **self.get_property(linktype))
1326 tag.set_data('is_anchor', True)
1327 tag.set_data('link', anchor)
1328 if typ:
1329@@ -349,7 +353,8 @@
1330 if ss.begins_tag(t) and ee.ends_tag(t):
1331 already = True
1332 if not texttag:
1333- texttag = buff.create_tag(None,**self.get_property('tag'))#pylint: disable-msg=W0142
1334+ #pylint: disable-msg=W0142
1335+ texttag = buff.create_tag(None, **self.get_property('tag'))
1336 texttag.set_data('is_tag', True)
1337 texttag.set_data('tagname', tag)
1338 #This one is for marks
1339@@ -371,7 +376,8 @@
1340 tex = buff.get_text(i_s, i_e)
1341 if len(tex) > 0:
1342 self.req.get_task(subtask).set_title(tex)
1343- texttag = self.create_anchor_tag(buff, subtask, text=tex, typ="subtask")
1344+ texttag = self.create_anchor_tag(buff, subtask, text=tex,
1345+ typ="subtask")
1346 texttag.set_data('is_subtask', True)
1347 texttag.set_data('child', subtask)
1348 #This one is for marks
1349@@ -382,7 +388,8 @@
1350 buff.delete_mark(e)
1351
1352 def create_indent_tag(self, buff, level):
1353- tag = buff.create_tag(None, **self.get_property('indent'))#pylint: disable-msg=W0142
1354+ #pylint: disable-msg=W0142
1355+ tag = buff.create_tag(None, **self.get_property('indent'))
1356 tag.set_data('is_indent', True)
1357 tag.set_data('indent_level', level)
1358 return tag
1359@@ -409,10 +416,12 @@
1360 if tt.get_data('is_tag'):
1361 newline = False
1362 firstline.forward_to_line_end()
1363- #Now we should check if the current char is a separator or not
1364- #Currently, we insert a space
1365+ # Now we should check if the current char is
1366+ # a separator or not
1367+ # Currently, we insert a space
1368 self.insert_text(" ", firstline)
1369- #Now we check if this newline is empty (it contains only " " and ",")
1370+ # Now we check if this newline is empty
1371+ # (it contains only " " and ",")
1372 # if newline:
1373 # endline = firstline.copy()
1374 # if not endline.ends_line():
1375@@ -428,13 +437,13 @@
1376 self.insert_text("\n", firstline)
1377 firstline = self.buff.get_iter_at_line(1)
1378 line_mark = self.buff.create_mark("firstline", firstline, False)
1379- #self.tv.insert_at_mark(buf, line_mark,"\n")
1380+ #self.tv.insert_at_mark(buf, line_mark, "\n")
1381 ntags = len(tag_list)
1382 for t in tag_list:
1383 ntags = ntags - 1
1384 self.insert_at_mark(self.buff, line_mark, t)
1385 if ntags != 0:
1386- self.insert_at_mark(self.buff, line_mark,",")
1387+ self.insert_at_mark(self.buff, line_mark, ",")
1388 self.buff.delete_mark(line_mark)
1389 self.modified(full=True)
1390
1391@@ -490,9 +499,7 @@
1392 stripped = title.strip(' \n\t')
1393 return stripped
1394
1395-### PRIVATE FUNCTIONS ##########################################################
1396-
1397-
1398+ ### PRIVATE FUNCTIONS #####################################################
1399 #This function is called so frequently that we should optimize it more.
1400 def modified(self, buff=None, full=False, refresheditor=True):
1401 """Called when the buffer has been modified.
1402@@ -538,9 +545,11 @@
1403 #subt_list = self.get_subtasks()
1404 #First, we remove the olds tags
1405 tag_list = []
1406+
1407 def subfunc(texttag, data=None): #pylint: disable-msg=W0613
1408 if texttag.get_data('is_subtask'):
1409 tag_list.append(texttag)
1410+
1411 table.foreach(subfunc)
1412 start, end = buff.get_bounds()
1413 for t in tag_list:
1414@@ -583,9 +592,11 @@
1415 #First, we remove the olds tags
1416 tag_list = []
1417 table = buff.get_tag_table()
1418+
1419 def subfunc(texttag, data=None):
1420 if texttag.get_data('is_anchor'):
1421 tag_list.append(texttag)
1422+
1423 table.foreach(subfunc)
1424 for t in tag_list:
1425 buff.remove_tag(t, start, end)
1426@@ -606,7 +617,8 @@
1427 # For short URL we must add http:// prefix
1428 if text == "www":
1429 url = "http://" + url
1430- texttag = self.create_anchor_tag(buff, url, text=None, typ="http")
1431+ texttag = self.create_anchor_tag(buff, url, text=None,
1432+ typ="http")
1433 it = prev.copy()
1434 it.forward_chars(m.end())
1435 buff.apply_tag(texttag, prev, it)
1436@@ -622,15 +634,18 @@
1437 nbr = url.split("#")[1]
1438 topoint = None
1439 if url.startswith("bug #") or url.startswith("lp #"):
1440- topoint = "https://launchpad.net/bugs/%s" %nbr
1441+ topoint = "https://launchpad.net/bugs/%s" % nbr
1442 elif url.startswith("bgo #"):
1443- topoint = "http://bugzilla.gnome.org/show_bug.cgi?id=%s" %nbr
1444+ topoint = "http://bugzilla.gnome.org/" + \
1445+ "show_bug.cgi?id=%s" % nbr
1446 elif url.startswith("bko #"):
1447- topoint = "https://bugs.kde.org/show_bug.cgi?id=%s" %nbr
1448+ topoint = "https://bugs.kde.org/show_bug.cgi?id=%s" \
1449+ % nbr
1450 elif url.startswith("fdo #"):
1451- topoint = "http://bugs.freedesktop.org/show_bug.cgi?id=%s" %nbr
1452+ topoint = "http://bugs.freedesktop.org/" + \
1453+ "show_bug.cgi?id=%s" % nbr
1454 if topoint:
1455- texttag = self.create_anchor_tag(buff,\
1456+ texttag = self.create_anchor_tag(buff,
1457 topoint, text=None, typ="http")
1458 buff.apply_tag(texttag, prev, it)
1459
1460@@ -659,29 +674,31 @@
1461 mark1 = buff.get_mark(tagname)
1462 if mark1:
1463 offset1 = buff.get_iter_at_mark(mark1).get_offset()
1464- if start.get_offset() <= offset1 <= end.get_offset():
1465+ if start.get_offset() <= offset1 <= \
1466+ end.get_offset():
1467 buff.delete_mark_by_name(tagname)
1468 mark2 = buff.get_mark("/%s"%tagname)
1469 if mark2:
1470 offset2 = buff.get_iter_at_mark(mark2).get_offset()
1471- if start.get_offset() <= offset2 <= end.get_offset():
1472+ if start.get_offset() <= offset2 <= \
1473+ end.get_offset():
1474 buff.delete_mark_by_name("/%s"%tagname)
1475 it.forward_char()
1476
1477 # Set iterators for word
1478 word_start = start.copy()
1479- word_end = start.copy()
1480+ word_end = start.copy()
1481
1482 # Set iterators for char
1483 char_start = start.copy()
1484- char_end = start.copy()
1485+ char_end = start.copy()
1486 char_end.forward_char()
1487 last_char = None
1488
1489 # Iterate over characters of the line to get words
1490 while char_end.compare(end) <= 0:
1491 do_word_check = False
1492- my_char = buff.get_text(char_start, char_end)
1493+ my_char = buff.get_text(char_start, char_end)
1494 if my_char not in separators:
1495 last_char = my_char
1496 word_end = char_end.copy()
1497@@ -707,7 +724,8 @@
1498 #and it shouldn't start with @@ (bug 531553)
1499 if len(my_word) > 1 and my_word[0] == '@' \
1500 and not my_word[1] == '@':
1501- #self.apply_tag_tag(buff, my_word, word_start, word_end)
1502+ #self.apply_tag_tag(buff, my_word, word_start,
1503+ # word_end)
1504 #We will add mark where tag should be applied
1505 buff.create_mark(my_word, word_start, True)
1506 buff.create_mark("/%s"%my_word, word_end, False)
1507@@ -718,7 +736,7 @@
1508
1509 # We set new word boundaries
1510 word_start = char_end.copy()
1511- word_end = char_end.copy()
1512+ word_end = char_end.copy()
1513
1514 # Stop loop if we are at the end
1515 if char_end.compare(end) == 0:
1516@@ -768,7 +786,7 @@
1517 # buff.remove_tag(ta, start, endindent)
1518 #Now we delete all, char after char
1519 it = start.copy()
1520- while (it.get_offset() <= end.get_offset()) and (it.get_char() != '\0'):
1521+ while it.get_offset() <= end.get_offset() and it.get_char() != '\0':
1522 if it.begins_tag():
1523 tags = it.get_tags()
1524 for ta in tags:
1525@@ -798,7 +816,8 @@
1526 #now we really delete the selected stuffs
1527 selec = self.buff.get_selection_bounds()
1528 # if selec:
1529-# print "deleted text is ##%s##" %self.buff.get_text(selec[0], selec[1])#(start, end)
1530+# print "deleted text is ##%s##" %self.buff.get_text(selec[0],
1531+# selec[1])#(start, end)
1532 # self.buff.disconnect(self.delete_sigid)
1533 # self.disconnect(self.backspace_sigid)
1534 # self.buff.stop_emission("delete-range")
1535@@ -807,16 +826,20 @@
1536 # else:
1537 # end.forward_char()
1538 # self.buff.backspace(end, False, True)
1539-# self.delete_sigid = self.buff.connect("delete-range", self._delete_range)
1540+# self.delete_sigid = self.buff.connect("delete-range",
1541+# self._delete_range)
1542 # self.backspace_sigid = self.connect("backspace", self.backspace)
1543 #We return false so the parent still get the signal
1544 return False
1545
1546- #Apply the title and return an iterator after that title.buff.get_iter_at_mar
1547 def _apply_title(self, buff, refresheditor=True):
1548- start = buff.get_start_iter()
1549- end = buff.get_end_iter()
1550- line_nbr = 1
1551+ """
1552+ Apply the title and return an iterator after that
1553+ title.buff.get_iter_at_mar
1554+ """
1555+ start = buff.get_start_iter()
1556+ end = buff.get_end_iter()
1557+ line_nbr = 1
1558 linecount = buff.get_line_count()
1559
1560 # Apply the title tag on the first line
1561@@ -828,14 +851,14 @@
1562 # Applying title on the first line
1563 title_end = buff.get_iter_at_line(line_nbr-1)
1564 title_end.forward_to_line_end()
1565- stripped = buff.get_text(title_start, title_end).strip('\n\t ')
1566+ stripped = buff.get_text(title_start, title_end).strip('\n\t ')
1567 # Here we ignore lines that are blank
1568 # Title is the first written line
1569 while line_nbr <= linecount and not stripped:
1570- line_nbr += 1
1571- title_end = buff.get_iter_at_line(line_nbr-1)
1572+ line_nbr += 1
1573+ title_end = buff.get_iter_at_line(line_nbr-1)
1574 title_end.forward_to_line_end()
1575- stripped = buff.get_text(title_start, title_end).strip('\n\t ')
1576+ stripped = buff.get_text(title_start, title_end).strip('\n\t ')
1577 # Or to all the buffer if there is only one line
1578 else:
1579 title_end = end.copy()
1580@@ -846,8 +869,6 @@
1581 self.refresh(buff.get_text(title_start, title_end).strip('\n\t'))
1582 return title_end
1583
1584-
1585-
1586 def __newsubtask(self, buff, title, line_nbr, level=1):
1587 anchor = self.new_subtask_callback(title)
1588 end_i = self.write_subtask(buff, line_nbr, anchor, level=level)
1589@@ -875,10 +896,10 @@
1590 #be in the subtask title
1591 start_i = buff.get_iter_at_line(line_nbr)
1592 start_i.forward_to_line_end()
1593- buff.insert(start_i,"\n")
1594+ buff.insert(start_i, "\n")
1595 #Ok, now we can start working
1596 start_i = buff.get_iter_at_line(line_nbr)
1597- end_i = start_i.copy()
1598+ end_i = start_i.copy()
1599 #We go back at the end of the previous line
1600 # start_i.backward_char()
1601 # #But only if this is not the title.
1602@@ -886,9 +907,9 @@
1603 # if start_i.has_tag(self.title_tag):
1604 # start_i.forward_char()
1605 # insert_enter = False
1606- start = buff.create_mark("start", start_i, True)
1607+ start = buff.create_mark("start", start_i, True)
1608 end_i.forward_line()
1609- end = buff.create_mark("end", end_i, False)
1610+ end = buff.create_mark("end", end_i, False)
1611 buff.delete(start_i, end_i)
1612 start_i = buff.get_iter_at_mark(start)
1613 self.insert_indent(buff, start_i, level, enter=insert_enter)
1614@@ -905,7 +926,8 @@
1615 #buff.delete_mark(end)
1616
1617 if reconnect_insert:
1618- self.insert_sigid = self.buff.connect('insert-text', self._insert_at_cursor)
1619+ self.insert_sigid = self.buff.connect('insert-text',
1620+ self._insert_at_cursor)
1621 if reconnect_modified:
1622 self.modified_sigid = self.buff.connect("changed", self.modified)
1623 return end_i
1624@@ -936,7 +958,7 @@
1625 if line == self.buff.get_line_count():
1626 itera.forward_to_line_end()
1627 mark = self.buff.create_mark(None, itera, True)
1628- self.buff.insert(itera,"\n")
1629+ self.buff.insert(itera, "\n")
1630 itera = self.buff.get_iter_at_mark(mark)
1631 self.buff.delete_mark(mark)
1632
1633@@ -946,7 +968,7 @@
1634 enter = True
1635 if itera.starts_line():
1636 mark = self.buff.create_mark(None, itera, True)
1637- self.buff.insert(itera,"\n")
1638+ self.buff.insert(itera, "\n")
1639 itera = self.buff.get_iter_at_mark(mark)
1640 self.buff.delete_mark(mark)
1641 enter = False
1642@@ -977,9 +999,9 @@
1643 #It will be later replaced by the good one with right gravity
1644 temp_mark = self.buff.create_mark("temp", start_i, True)
1645
1646- end = buff.create_mark("end", start_i, False)
1647+ end = buff.create_mark("end", start_i, False)
1648 if enter:
1649- buff.insert(start_i,"\n")
1650+ buff.insert(start_i, "\n")
1651
1652 #Moving the end of subtask mark to the position of the temp mark
1653 if stag:
1654@@ -994,7 +1016,7 @@
1655 #This is normally not needed and purely defensive
1656 if itera.get_line() <= 0:
1657 itera = buff.get_iter_at_line(1)
1658- start = buff.create_mark("start", itera, True)
1659+ start = buff.create_mark("start", itera, True)
1660 indentation = ""
1661 #adding two spaces by level
1662 spaces = " "
1663@@ -1007,7 +1029,6 @@
1664 self.__apply_tag_to_mark(start, end, tag=indenttag)
1665 return end
1666
1667-
1668 def __apply_tag_to_mark(self, start, end, tag=None, name=None):
1669 start_i = self.buff.get_iter_at_mark(start)
1670 end_i = self.buff.get_iter_at_mark(end)
1671@@ -1027,9 +1048,8 @@
1672 else:
1673 buff.insert(ite, text)
1674
1675-
1676 def _get_indent_level(self, itera):
1677- line_nbr = itera.get_line()
1678+ line_nbr = itera.get_line()
1679 start_line = itera.copy()
1680 start_line.set_line(line_nbr)
1681 tags = start_line.get_tags()
1682@@ -1046,10 +1066,10 @@
1683
1684 #First, we analyse the selection to put in our own
1685 #GTG clipboard a selection with description of subtasks
1686- bounds = self.buff.get_selection_bounds()
1687+ bounds = self.buff.get_selection_bounds()
1688 if not bounds:
1689 return
1690- start, stop = self.buff.get_selection_bounds()
1691+ start, stop = self.buff.get_selection_bounds()
1692
1693 self.clipboard.copy(start, stop, bullet=self.bullet1)
1694
1695@@ -1105,10 +1125,10 @@
1696
1697 #First, we will get the actual indentation value
1698 #The nbr just before the \n
1699- line_nbr = itera.get_line()
1700+ line_nbr = itera.get_line()
1701 start_line = itera.copy()
1702 start_line.set_line(line_nbr)
1703- end_line = itera.copy()
1704+ end_line = itera.copy()
1705 tags = start_line.get_tags()
1706 subtask_nbr = None
1707 current_indent = self._get_indent_level(itera)
1708@@ -1157,24 +1177,28 @@
1709 #the "-" might be after a space
1710 #Python 2.5 should allow both tests in one
1711 if current_indent == 0:
1712- if (line.startswith('-') or line.startswith(' -')) and line.lstrip(' -').strip() != "":
1713+ if (line.startswith('-') or line.startswith(' -')) \
1714+ and line.lstrip(' -').strip() != "":
1715 line = line.lstrip(' -')
1716- end_i = self.__newsubtask(self.buff, line, line_nbr)
1717+ end_i = self.__newsubtask(self.buff, line,
1718+ line_nbr)
1719 #Here, we should increment indent level
1720 #If we inserted enter in the middle of a line
1721 if restofline and restofline.strip() != "":
1722 #it means we have two subtask to create
1723 if self.buff.get_line_count() > line_nbr+1:
1724 #but don't merge with the next line
1725- itera = self.buff.get_iter_at_line(line_nbr+1)
1726- self.buff.insert(itera,"\n\n")
1727- self.__newsubtask(self.buff, restofline,\
1728+ itera = self.buff.get_iter_at_line(
1729+ line_nbr + 1)
1730+ self.buff.insert(itera, "\n\n")
1731+ self.__newsubtask(self.buff, restofline,
1732 line_nbr+1)
1733 else:
1734- self.insert_indent(self.buff, end_i, 1, enter=True)
1735+ self.insert_indent(self.buff, end_i, 1,
1736+ enter=True)
1737 tv.emit_stop_by_name('insert-text')
1738 else:
1739- self.buff.insert(itera,"\n")
1740+ self.buff.insert(itera, "\n")
1741 tv.emit_stop_by_name('insert-text')
1742
1743 #Then, if indent > 0, we increment it
1744@@ -1191,22 +1215,26 @@
1745 else:
1746 #we first put the subtask one line below
1747 itera2 = self.buff.get_iter_at_line(line_nbr)
1748- self.buff.insert(itera2,"\n")
1749+ self.buff.insert(itera2, "\n")
1750 #and increment the new white line
1751 itera2 = self.buff.get_iter_at_line(line_nbr)
1752- self.insert_indent(self.buff, itera2, current_indent, enter=False)
1753+ self.insert_indent(self.buff, itera2,
1754+ current_indent, enter=False)
1755 elif current_indent == 1:
1756- self.insert_indent(self.buff, itera, current_indent)
1757+ self.insert_indent(self.buff, itera,
1758+ current_indent)
1759 #we stop the signal in all cases
1760 tv.emit_stop_by_name('insert-text')
1761 #Then we close the tag tag
1762 if closed_tag:
1763 insert_mark = self.buff.get_mark("insert_point")
1764 insert_iter = self.buff.get_iter_at_mark(insert_mark)
1765- self.buff.move_mark_by_name("/%s"%closed_tag, insert_iter)
1766+ self.buff.move_mark_by_name("/%s" % closed_tag,
1767+ insert_iter)
1768 self.buff.delete_mark(insert_mark)
1769 if cutting_subtask:
1770- cursor = self.buff.get_iter_at_mark(self.buff.get_insert())
1771+ cursor = self.buff.get_iter_at_mark(
1772+ self.buff.get_insert())
1773 endl = cursor.copy()
1774 if not endl.ends_line():
1775 endl.forward_to_line_end()
1776@@ -1222,7 +1250,7 @@
1777 if itera.starts_line():
1778 #we are at the start of an existing subtask
1779 #we simply move that subtask down
1780- self.buff.insert(itera,"\n")
1781+ self.buff.insert(itera, "\n")
1782 itera2 = self.buff.get_iter_at_line(line_nbr)
1783 self.buff.insert(itera2, tex)
1784 itera3 = self.buff.get_iter_at_line(line_nbr)
1785@@ -1230,25 +1258,28 @@
1786 self.buff.place_cursor(itera3)
1787 tv.emit_stop_by_name('insert-text')
1788 else:
1789- #self.__newsubtask(self.buff, tex, line_nbr, level=current_indent)
1790+ #self.__newsubtask(self.buff, tex, line_nbr,
1791+ # level=current_indent)
1792 anchor = self.new_subtask_callback(tex)
1793 self.buff.create_mark(anchor, itera, True)
1794 self.buff.create_mark("/%s"%anchor, itera, False)
1795- self.insert_sigid = self.buff.connect('insert-text', self._insert_at_cursor)
1796+ self.insert_sigid = self.buff.connect('insert-text',
1797+ self._insert_at_cursor)
1798 self.connect('key_press_event', self._keypress)
1799 self.modified_sigid = self.buff.connect("changed", self.modified)
1800
1801 def _keypress(self, widget, event):
1802 # Check for Ctrl-Return/Enter
1803- if event.state & gtk.gdk.CONTROL_MASK and event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
1804+ if event.state & gtk.gdk.CONTROL_MASK and \
1805+ event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
1806 buff = self.buff
1807 cursor_mark = buff.get_insert()
1808 cursor_iter = buff.get_iter_at_mark(cursor_mark)
1809 local_start = cursor_iter.copy()
1810
1811 for tag in local_start.get_tags():
1812- anchor = tag.get_data('link')
1813- typ = tag.get_data('type')
1814+ anchor = tag.get_data('link')
1815+ typ = tag.get_data('type')
1816 if(anchor):
1817 if typ == "subtask":
1818 self.open_task(anchor)
1819@@ -1278,12 +1309,12 @@
1820 self.buff.disconnect(self.delete_sigid)
1821 #print "deintdent-delete: %s" %self.buff.get_text(startline, itera)
1822 self.buff.delete(startline, itera)
1823- self.delete_sigid = self.buff.connect("delete-range", \
1824- self._delete_range)
1825 #For the day when we will have different indent levels
1826 #newiter = self.buff.get_iter_at_mark(tempm)
1827 #self.buff.delete_mark(tempm)
1828 #self.insert_indent(self.buff, newiter, newlevel, enter=False)
1829+ self.delete_sigid = self.buff.connect("delete-range",
1830+ self._delete_range)
1831
1832 def backspace(self, tv):
1833 self.buff.disconnect(self.insert_sigid)
1834@@ -1298,7 +1329,7 @@
1835 #we stopped the signal, don't forget to erase
1836 #the selection if one
1837 self.buff.delete_selection(True, True)
1838- self.insert_sigid = self.buff.connect('insert-text', \
1839+ self.insert_sigid = self.buff.connect('insert-text',
1840 self._insert_at_cursor)
1841
1842 #The mouse is moving. We must change it to a hand when hovering over a link
1843@@ -1318,8 +1349,11 @@
1844 tag_table = self.buff.get_tag_table()
1845 tag_table.foreach(self.__tag_reset, window)
1846
1847- #We clicked on a link
1848- def _tag_event(self, tag, view, ev, _iter, text, anchor, typ): #pylint: disable-msg=W0613
1849+ def _tag_event(self, tag, view, ev, _iter, text, anchor, typ):
1850+ """
1851+ We clicked on a link
1852+ """
1853+ #pylint: disable-msg=W0613
1854 _type = ev.type
1855 if _type == gtk.gdk.MOTION_NOTIFY:
1856 return
1857@@ -1330,14 +1364,17 @@
1858 if typ == "subtask":
1859 self.open_task(anchor)
1860 elif typ == "http":
1861- if button == 1 and self.check_link(anchor) and self.buff.get_has_selection() == False:
1862+ if button == 1 and self.check_link(anchor) and \
1863+ not self.buff.get_has_selection():
1864 openurl(anchor)
1865 else:
1866 print "Unknown link type for %s" %anchor
1867 self.emit('anchor-clicked', text, anchor, button)
1868- self.__set_anchor(ev.window, tag, cursor, self.get_property('hover'))
1869+ self.__set_anchor(ev.window, tag, cursor,
1870+ self.get_property('hover'))
1871 elif button in [1, 2]:
1872- self.__set_anchor(ev.window, tag, cursor, self.get_property('active'))
1873+ self.__set_anchor(ev.window, tag, cursor,
1874+ self.get_property('active'))
1875
1876 def __tag_reset(self, tag, window):
1877 if tag.get_data('is_anchor'):
1878@@ -1351,7 +1388,8 @@
1879 linktype = 'link'
1880 else:
1881 linktype = 'failedlink'
1882- self.__set_anchor(window, tag, editing_cursor, self.get_property(linktype))
1883+ self.__set_anchor(window, tag, editing_cursor,
1884+ self.get_property(linktype))
1885
1886 def __set_anchor(self, window, tag, cursor, prop):
1887 window.set_cursor(cursor)
1888
1889=== modified file 'GTG/gtk/editor/taskviewserial.py'
1890--- GTG/gtk/editor/taskviewserial.py 2012-05-23 08:55:31 +0000
1891+++ GTG/gtk/editor/taskviewserial.py 2012-11-25 21:29:25 +0000
1892@@ -107,8 +107,8 @@
1893 elif ta.get_data('is_subtask'):
1894 #The current gtkTextTag is a subtask
1895 tagname = "subtask"
1896- subt = doc.createElement(tagname)
1897- target = ta.get_data('child')
1898+ subt = doc.createElement(tagname)
1899+ target = ta.get_data('child')
1900 subt.appendChild(doc.createTextNode(target))
1901 parent.appendChild(subt)
1902 parent.appendChild(doc.createTextNode("\n"))
1903@@ -187,7 +187,7 @@
1904 #parse the XML and put the content in the buffer
1905 def parsexml(self, buf, ite, element):
1906 start = buf.create_mark(None, ite, True)
1907- end = buf.create_mark(None, ite, False)
1908+ end = buf.create_mark(None, ite, False)
1909 subtasks = self.tv.get_subtasks()
1910 taglist2 = []
1911 if element:

Subscribers

People subscribed via source and target branches

to status/vote changes: