gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #03725
[Merge] lp:~izidor/gtg/pep8-gtk into lp:gtg
Izidor Matušov has proposed merging lp:~izidor/gtg/pep8-gtk into lp:gtg.
Requested reviews:
Gtg developers (gtg)
For more details, see:
https://code.launchpad.net/~izidor/gtg/pep8-gtk/+merge/136066
Partial PEP8-ification of GTG/gtk folder (until I ran out of battery during refactoring :/)
--
https://code.launchpad.net/~izidor/gtg/pep8-gtk/+merge/136066
Your team Gtg developers is requested to review the proposed merge of lp:~izidor/gtg/pep8-gtk into lp:gtg.
=== modified file 'GTG/gtk/browser/CellRendererTags.py'
--- GTG/gtk/browser/CellRendererTags.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/browser/CellRendererTags.py 2012-11-25 21:29:25 +0000
@@ -32,9 +32,9 @@
class CellRendererTags(gtk.GenericCellRenderer):
__gproperties__ = {
- 'tag_list': (gobject.TYPE_PYOBJECT,\
+ 'tag_list': (gobject.TYPE_PYOBJECT,
"Tag list", "A list of tags", gobject.PARAM_READWRITE),
- 'tag': (gobject.TYPE_PYOBJECT, "Tag",\
+ 'tag': (gobject.TYPE_PYOBJECT, "Tag",
"Tag", gobject.PARAM_READWRITE),
}
@@ -66,7 +66,7 @@
if self.tag_list != None:
for my_tag in self.tag_list:
my_tag_color = my_tag.get_attribute("color")
- my_tag_icon = my_tag.get_attribute("icon")
+ my_tag_icon = my_tag.get_attribute("icon")
if my_tag_color or my_tag_icon:
count = count + 1
elif self.tag != None:
@@ -80,10 +80,10 @@
def __init__(self): #pylint: disable-msg=W0231
self.__gobject_init__()
self.tag_list = None
- self.tag = None
- self.xpad = 1
- self.ypad = 1
- self.PADDING = 1
+ self.tag = None
+ self.xpad = 1
+ self.ypad = 1
+ self.PADDING = 1
def do_set_property(self, pspec, value):
if pspec.name == "tag-list":
@@ -97,11 +97,11 @@
else:
return getattr(self, pspec.name)
- def on_render(\
- self, window, widget, background_area, cell_area, expose_area, flags):
+ def on_render(self, window, widget, background_area, cell_area,
+ expose_area, flags):
vw_tags = self.__count_viewable_tags()
- count = 0
+ count = 0
# Select source
if self.tag_list != None:
@@ -112,25 +112,25 @@
return
# Drawing context
- cr = window.cairo_create()
+ cr = window.cairo_create()
gdkcontext = gtk.gdk.CairoContext(cr)
gdkcontext.set_antialias(cairo.ANTIALIAS_NONE)
# Coordinates of the origin point
x_align = self.get_property("xalign")
y_align = self.get_property("yalign")
- orig_x = cell_area.x + int((cell_area.width - 16*vw_tags -\
+ orig_x = cell_area.x + int((cell_area.width - 16*vw_tags - \
self.PADDING*2*(vw_tags-1)) * x_align)
- orig_y = cell_area.y + int((cell_area.height - 16) * y_align)
+ orig_y = cell_area.y + int((cell_area.height - 16) * y_align)
# We draw the icons & squares
for my_tag in tags:
- my_tag_icon = my_tag.get_attribute("icon")
+ my_tag_icon = my_tag.get_attribute("icon")
my_tag_color = my_tag.get_attribute("color")
- rect_x = orig_x + self.PADDING*2*count + 16*count
- rect_y = orig_y
+ rect_x = orig_x + self.PADDING*2*count + 16*count
+ rect_y = orig_y
if my_tag_icon:
try:
@@ -162,11 +162,10 @@
if self.tag and my_tag: #pylint: disable-msg=W0631
- my_tag_icon = my_tag.get_attribute("icon")
+ my_tag_icon = my_tag.get_attribute("icon")
my_tag_color = my_tag.get_attribute("color")
- if not my_tag_icon and not my_tag_color:
-
+ if not my_tag_icon and not my_tag_color:
# Draw rounded rectangle
gdkcontext.set_source_rgba(0.95, 0.95, 0.95, 1)
self.__roundedrec(gdkcontext, rect_x, rect_y, 16, 16, 8)
@@ -183,8 +182,9 @@
count = self.__count_viewable_tags()
if count != 0:
- return (self.xpad, self.ypad, self.xpad*2 + 16*count +\
- 2*count*self.PADDING, 16 + 2*self.ypad)
+ return (self.xpad, self.ypad,
+ self.xpad*2 + 16*count + 2*count*self.PADDING,
+ 16 + 2*self.ypad)
else:
return (self.xpad, self.ypad, self.xpad*2, self.ypad*2)
=== modified file 'GTG/gtk/browser/browser.py'
--- GTG/gtk/browser/browser.py 2012-11-01 10:09:06 +0000
+++ GTG/gtk/browser/browser.py 2012-11-25 21:29:25 +0000
@@ -46,9 +46,6 @@
from GTG.tools.dates import Date
from GTG.tools.logger import Log
-#=== MAIN CLASS ===============================================================
-
-
class Timer:
@@ -96,7 +93,7 @@
# Set up models
# Active Tasks
- self.req.apply_global_filter(self.activetree,'active')
+ self.req.apply_global_filter(self.activetree, 'active')
# Tags
self.tagtree = None
self.tagtreeview = None
@@ -405,7 +402,7 @@
### HELPER FUNCTIONS ########################################################
def open_preferences(self, widget):
self.vmanager.open_preferences(self.config)
-
+
def open_plugins(self, widget):
self.vmanager.configure_plugins()
@@ -565,10 +562,10 @@
def set_view(self, viewname):
if viewname == 'default':
- self.req.unapply_global_filter(self.activetree,'workview')
+ self.req.unapply_global_filter(self.activetree, 'workview')
workview = False
elif viewname == 'workview':
- self.req.apply_global_filter(self.activetree,'workview')
+ self.req.apply_global_filter(self.activetree, 'workview')
workview = True
else:
raise Exception('Cannot set the view %s' %viewname)
@@ -613,7 +610,6 @@
### SIGNAL CALLBACKS ##########################################################
# Typically, reaction to user input & interactions with the GUI
#
-
def on_sort_column_changed(self, model):
sort_column, sort_order = model.get_sort_column_id()
@@ -755,7 +751,7 @@
colt = self.config.get("collapsed_tasks")
if tid not in colt:
colt.append(str(tid))
-
+
def on_tag_expanded(self, sender, tag):
colt = self.config.get("expanded_tags")
if tag not in colt:
@@ -980,7 +976,7 @@
def on_delete_tasks(self, widget=None, tid=None):
#If we don't have a parameter, then take the selection in the treeview
if not tid:
- #tid_to_delete is a [project,task] tuple
+ #tid_to_delete is a [project, task] tuple
tids_todelete = self.get_selected_tasks()
if not tids_todelete:
return
@@ -1110,13 +1106,13 @@
task.set_status(Task.STA_DISMISSED)
self.close_all_task_editors(uid)
- def apply_filter_on_panes(self, filter_name,refresh=True):
+ def apply_filter_on_panes(self, filter_name, refresh=True):
""" Apply filters for every pane: active tasks, closed tasks """
for pane in self.vtree_panes:
vtree = self.req.get_tasks_tree(name=pane, refresh=False)
vtree.apply_filter(filter_name, refresh=refresh)
-
- def unapply_filter_on_panes(self, filter_name,refresh=True):
+
+ def unapply_filter_on_panes(self, filter_name, refresh=True):
""" Apply filters for every pane: active tasks, closed tasks """
for pane in self.vtree_panes:
vtree = self.req.get_tasks_tree(name=pane, refresh=False)
@@ -1130,11 +1126,11 @@
#When you click on a tag, you want to unselect the tasks
new_taglist = self.get_selected_tags()
-
+
for tagname in self.applied_tags:
if tagname not in new_taglist:
- self.unapply_filter_on_panes(tagname,refresh=False)
-
+ self.unapply_filter_on_panes(tagname, refresh=False)
+
for tagname in new_taglist:
if tagname not in self.applied_tags:
self.apply_filter_on_panes(tagname)
@@ -1143,7 +1139,7 @@
tag = self.req.get_tag(tagname)
if tag.is_search_tag():
self.quickadd_entry.set_text(tag.get_attribute("query"))
-
+
self.applied_tags = new_taglist
def on_taskdone_cursor_changed(self, selection=None):
=== modified file 'GTG/gtk/browser/tag_context_menu.py'
--- GTG/gtk/browser/tag_context_menu.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/browser/tag_context_menu.py 2012-11-25 21:29:25 +0000
@@ -21,7 +21,7 @@
"""
tag_context_menu:
Implements a context (pop-up) menu for the tag item in the sidebar.
-Right now it is just a void shell It is supposed to become a more generic
+Right now it is just a void shell It is supposed to become a more generic
sidebar context for all kind of item displayed there.
Also, it is supposed to handle more complex menus (with non-std widgets,
like a color picker)
@@ -33,6 +33,7 @@
from GTG import _
+
class TagContextMenu(gtk.Menu): # pylint: disable-msg=R0904
"""Context menu fo the tag i the sidebar"""
@@ -66,15 +67,13 @@
# Make it visible
self.show_all()
- ### PUBLIC API ###
-
+ ### PUBLIC API ############################################################
def set_tag(self, tag):
"""Update the context menu items using the tag attributes."""
self.tag = tag
self.__build_menu()
- ### CALLBACKS ###
-
+ ### CALLBACKS #############################################################
def on_mi_cc_activate(self, widget): # pylint: disable-msg=W0613
"""Callback: show the tag editor upon request"""
self.vmanager.open_tag_editor(self.tag)
=== modified file 'GTG/gtk/browser/treeview_factory.py'
--- GTG/gtk/browser/treeview_factory.py 2012-11-01 10:23:05 +0000
+++ GTG/gtk/browser/treeview_factory.py 2012-11-25 21:29:25 +0000
@@ -33,14 +33,14 @@
class TreeviewFactory():
- def __init__(self,requester,config):
+ def __init__(self, requester, config):
self.req = requester
self.mainview = self.req.get_tasks_tree()
self.config = config
-
+
#Initial unactive color
- #This is a crude hack. As we don't have a reference to the
- #treeview to retrieve the style, we save that color when we
+ #This is a crude hack. As we don't have a reference to the
+ #treeview to retrieve the style, we save that color when we
#build the treeview.
self.unactive_color = "#888a85"
@@ -49,12 +49,12 @@
# Cache tags treeview for on_rename_tag callback
self.tags_view = None
-
+
#############################
#Functions for tasks columns
################################
-
- def _has_hidden_subtask(self,task):
+
+ def _has_hidden_subtask(self, task):
#not recursive
display_count = self.mainview.node_n_children(task.get_id())
real_count = 0
@@ -64,15 +64,15 @@
if sub_task and sub_task.get_status() == Task.STA_ACTIVE:
real_count = real_count + 1
return display_count < real_count
-
+
def task_bg_color(self, node, default_color):
if self.config.get('bg_color_enable'):
return colors.background_color(node.get_tags(), default_color)
else:
return None
-
+
#return an ordered list of tags of a task
- def task_tags_column(self,node):
+ def task_tags_column(self, node):
tags = node.get_tags()
search_parent = self.req.get_tag(CoreConfig.SEARCH_TAG)
@@ -84,15 +84,15 @@
tags.sort(key = lambda x: x.get_name())
return tags
-
+
#task title
def task_title_column(self, node):
return saxutils.escape(node.get_title())
-
+
#task title/label
def task_label_column(self, node):
str_format = "%s"
-
+
if node.get_status() == Task.STA_ACTIVE:
# we mark in bold tasks which are due today or as Now
days_left = node.get_days_left()
@@ -114,40 +114,40 @@
excerpt = saxutils.escape(node.get_excerpt(lines=1,
strip_tags=True, strip_subtasks=True))
title += " <span size='small' color='%s'>%s</span>" \
- % (self.unactive_color, excerpt)
+ % (self.unactive_color, excerpt)
return title
-
+
#task start date
- def task_sdate_column(self,node):
+ def task_sdate_column(self, node):
return node.get_start_date().to_readable_string()
-
- def task_duedate_column(self,node):
+
+ def task_duedate_column(self, node):
# We show the most constraining due date for task with no due dates.
if node.get_due_date() == Date.no_date():
return node.get_due_date_constraint().to_readable_string()
else:
# Other tasks show their due date (which *can* be fuzzy)
return node.get_due_date().to_readable_string()
-
- def task_cdate_column(self,node):
+
+ def task_cdate_column(self, node):
return node.get_closed_date().to_readable_string()
-
- def start_date_sorting(self,task1,task2,order):
- sort = self.__date_comp(task1,task2,'start',order)
- return sort
-
- def due_date_sorting(self,task1,task2,order):
- sort = self.__date_comp(task1,task2,'due',order)
- return sort
-
- def closed_date_sorting(self,task1,task2,order):
- sort = self.__date_comp(task1,task2,'closed',order)
- return sort
-
- def title_sorting(self,task1,task2,order):
- return cmp(task1.get_title(),task2.get_title())
-
- def __date_comp(self,task1,task2,para,order):
+
+ def start_date_sorting(self, task1, task2, order):
+ sort = self.__date_comp(task1, task2, 'start', order)
+ return sort
+
+ def due_date_sorting(self, task1, task2, order):
+ sort = self.__date_comp(task1, task2, 'due', order)
+ return sort
+
+ def closed_date_sorting(self, task1, task2, order):
+ sort = self.__date_comp(task1, task2, 'closed', order)
+ return sort
+
+ def title_sorting(self, task1, task2, order):
+ return cmp(task1.get_title(), task2.get_title())
+
+ def __date_comp(self, task1, task2, para, order):
'''This is a quite complex method to sort tasks by date,
handling fuzzy date and complex situation.
Return -1 if nid1 is before nid2, return 1 otherwise
@@ -168,39 +168,39 @@
t2 = task2.get_closed_date()
else:
raise ValueError('invalid date comparison parameter: %s')%para
- sort = cmp(t2,t1)
+ sort = cmp(t2, t1)
else:
sort = 0
-
+
#local function
def reverse_if_descending(s):
- """Make a cmp() result relative to the top instead of following
+ """Make a cmp() result relative to the top instead of following
user-specified sort direction"""
if order == gtk.SORT_ASCENDING:
return s
else:
return -1*s
- if sort == 0: # Group tasks with the same tag together for visual cleanness
+ if sort == 0: # Group tasks with the same tag together for visual cleanness
t1_tags = task1.get_tags_name()
t1_tags.sort()
t2_tags = task2.get_tags_name()
t2_tags.sort()
sort = reverse_if_descending(cmp(t1_tags, t2_tags))
-
+
if sort == 0: # Break ties by sorting by title
t1_title = task1.get_title()
t2_title = task2.get_title()
t1_title = locale.strxfrm(t1_title)
t2_title = locale.strxfrm(t2_title)
sort = reverse_if_descending(cmp(t1_title, t2_title))
-
+
return sort
-
+
#############################
#Functions for tags columns
#############################
- def tag_name(self,node):
+ def tag_name(self, node):
label = node.get_attribute("label")
if label.startswith('@'):
label = label[1:]
@@ -209,18 +209,18 @@
return "<span color='%s'>%s</span>" %(self.unactive_color, label)
else:
return label
-
- def get_tag_count(self,node):
+
+ def get_tag_count(self, node):
if node.get_id() == 'search':
return ""
else:
toreturn = node.get_active_tasks_count()
- return "<span color='%s'>%s</span>" %(self.unactive_color,toreturn)
-
- def is_tag_separator_filter(self,tag):
+ return "<span color='%s'>%s</span>" %(self.unactive_color, toreturn)
+
+ def is_tag_separator_filter(self, tag):
return tag.get_attribute('special') == 'sep'
-
- def tag_sorting(self,t1,t2,order):
+
+ def tag_sorting(self, t1, t2, order):
t1_sp = t1.get_attribute("special")
t2_sp = t2.get_attribute("special")
t1_name = locale.strxfrm(t1.get_name())
@@ -235,8 +235,8 @@
t1_order = t1.get_attribute("order")
t2_order = t2.get_attribute("order")
return cmp(t1_order, t2_order)
-
- def ontag_task_dnd(self,source,target):
+
+ def ontag_task_dnd(self, source, target):
task = self.req.get_task(source)
if target.startswith('@'):
task.add_tag(target)
@@ -248,7 +248,7 @@
############################################
######## The Factory #######################
############################################
- def tags_treeview(self,tree):
+ def tags_treeview(self, tree):
desc = {}
#Tag id
@@ -260,32 +260,32 @@
col['order'] = 0
col['sorting_func'] = self.tag_sorting
desc[col_name] = col
-
+
#Tags color
col_name = 'color'
col = {}
render_tags = CellRendererTags()
render_tags.set_property('ypad', 3)
col['title'] = _("Tags")
- col['renderer'] = ['tag',render_tags]
- col['value'] = [gobject.TYPE_PYOBJECT,lambda node: node]
+ col['renderer'] = ['tag', render_tags]
+ col['value'] = [gobject.TYPE_PYOBJECT, lambda node: node]
col['expandable'] = False
col['resizable'] = False
col['order'] = 1
desc[col_name] = col
-
+
#Tag names
col_name = 'tagname'
col = {}
render_text = gtk.CellRendererText()
render_text.set_property('ypad', 3)
- col['renderer'] = ['markup',render_text]
- col['value'] = [str,self.tag_name]
+ col['renderer'] = ['markup', render_text]
+ col['value'] = [str, self.tag_name]
col['expandable'] = True
col['new_column'] = False
col['order'] = 2
desc[col_name] = col
-
+
#Tag count
col_name = 'tagcount'
col = {}
@@ -293,26 +293,26 @@
render_text.set_property('xpad', 3)
render_text.set_property('ypad', 3)
render_text.set_property('xalign', 1.0)
- col['renderer'] = ['markup',render_text]
- col['value'] = [str,self.get_tag_count]
+ col['renderer'] = ['markup', render_text]
+ col['value'] = [str, self.get_tag_count]
col['expandable'] = False
col['new_column'] = False
col['order'] = 3
desc[col_name] = col
- return self.build_tag_treeview(tree,desc)
-
- def active_tasks_treeview(self,tree):
+ return self.build_tag_treeview(tree, desc)
+
+ def active_tasks_treeview(self, tree):
#Build the title/label/tags columns
desc = self.common_desc_for_tasks(tree)
-
+
# "startdate" column
col_name = 'startdate'
col = {}
col['title'] = _("Start date")
col['expandable'] = False
col['resizable'] = False
- col['value'] = [str,self.task_sdate_column]
+ col['value'] = [str, self.task_sdate_column]
col['order'] = 3
col['sorting_func'] = self.start_date_sorting
desc[col_name] = col
@@ -323,40 +323,40 @@
col['title'] = _("Due")
col['expandable'] = False
col['resizable'] = False
- col['value'] = [str,self.task_duedate_column]
+ col['value'] = [str, self.task_duedate_column]
col['order'] = 4
col['sorting_func'] = self.due_date_sorting
desc[col_name] = col
#Returning the treeview
- treeview = self.build_task_treeview(tree,desc)
+ treeview = self.build_task_treeview(tree, desc)
treeview.set_sort_column('duedate')
return treeview
-
- def closed_tasks_treeview(self,tree):
+
+ def closed_tasks_treeview(self, tree):
#Build the title/label/tags columns
desc = self.common_desc_for_tasks(tree)
-
+
# "startdate" column
col_name = 'closeddate'
col = {}
col['title'] = _("Closed date")
col['expandable'] = False
col['resizable'] = False
- col['value'] = [str,self.task_cdate_column]
+ col['value'] = [str, self.task_cdate_column]
col['order'] = 3
col['sorting_func'] = self.closed_date_sorting
desc[col_name] = col
#Returning the treeview
- treeview = self.build_task_treeview(tree,desc)
+ treeview = self.build_task_treeview(tree, desc)
treeview.set_sort_column('closeddate')
return treeview
-
-
+
+
#This build the first tag/title columns, common
#to both active and closed tasks treeview
- def common_desc_for_tasks(self,tree):
+ def common_desc_for_tasks(self, tree):
desc = {}
#invisible 'task_id' column
@@ -380,20 +380,20 @@
col = {}
render_text = gtk.CellRendererText()
render_text.set_property("ellipsize", pango.ELLIPSIZE_END)
- col['renderer'] = ['markup',render_text]
- col['value'] = [str,self.task_title_column]
+ col['renderer'] = ['markup', render_text]
+ col['value'] = [str, self.task_title_column]
col['visible'] = False
col['order'] = 0
col['sorting_func'] = self.title_sorting
desc[col_name] = col
-
+
# "tags" column (no title)
col_name = 'tags'
col = {}
render_tags = CellRendererTags()
render_tags.set_property('xalign', 0.0)
- col['renderer'] = ['tag_list',render_tags]
- col['value'] = [gobject.TYPE_PYOBJECT,self.task_tags_column]
+ col['renderer'] = ['tag_list', render_tags]
+ col['value'] = [gobject.TYPE_PYOBJECT, self.task_tags_column]
col['expandable'] = False
col['resizable'] = False
col['order'] = 1
@@ -405,18 +405,18 @@
col['title'] = _("Title")
render_text = gtk.CellRendererText()
render_text.set_property("ellipsize", pango.ELLIPSIZE_END)
- col['renderer'] = ['markup',render_text]
- col['value'] = [str,self.task_label_column]
+ col['renderer'] = ['markup', render_text]
+ col['value'] = [str, self.task_label_column]
col['expandable'] = True
col['resizable'] = True
col['sorting'] = 'title'
col['order'] = 2
desc[col_name] = col
return desc
-
-
- def build_task_treeview(self,tree,desc):
- treeview = TreeView(tree,desc)
+
+
+ def build_task_treeview(self, tree, desc):
+ treeview = TreeView(tree, desc)
#Now that the treeview is done, we can polish
treeview.set_main_search_column('label')
treeview.set_expander_column('label')
@@ -431,19 +431,19 @@
self.unactive_color = \
treeview.style.text[gtk.STATE_INSENSITIVE].to_string()
return treeview
-
- def build_tag_treeview(self,tree,desc):
- treeview = TreeView(tree,desc)
+
+ def build_tag_treeview(self, tree, desc):
+ treeview = TreeView(tree, desc)
# Global treeview properties
treeview.set_property("enable-tree-lines", False)
treeview.set_rules_hint(False)
treeview.set_row_separator_func(self.is_tag_separator_filter)
treeview.set_headers_visible(False)
treeview.set_dnd_name('gtg/tag-iter-str')
- treeview.set_dnd_external('gtg/task-iter-str',self.ontag_task_dnd)
+ treeview.set_dnd_external('gtg/task-iter-str', self.ontag_task_dnd)
#Updating the unactive color (same for everyone)
self.unactive_color = \
treeview.style.text[gtk.STATE_INSENSITIVE].to_string()
treeview.set_sort_column('tag_id')
self.tags_view = treeview
- return treeview
+ return treeview
=== modified file 'GTG/gtk/crashhandler.py'
--- GTG/gtk/crashhandler.py 2012-07-23 12:04:01 +0000
+++ GTG/gtk/crashhandler.py 2012-11-25 21:29:25 +0000
@@ -332,7 +332,7 @@
yield
initialize(app_name = "Getting Things GNOME!",
- message = "GTG" + info.VERSION +
+ message = "GTG" + info.VERSION +
_(" has crashed. Please report the bug on <a href=\""
"http://bugs.edge.launchpad.net/gtg\">our Launchpad page</a>."
" If you have Apport installed, it will be started for you."),
=== modified file 'GTG/gtk/delete_dialog.py'
--- GTG/gtk/delete_dialog.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/delete_dialog.py 2012-11-25 21:29:25 +0000
@@ -24,18 +24,19 @@
class DeletionUI():
-
+
MAXIMUM_TIDS_TO_SHOW = 5
+
def __init__(self, req):
self.req = req
self.tids_todelete = []
# Tags which must be updated
self.update_tags = []
# Load window tree
- self.builder = gtk.Builder()
+ self.builder = gtk.Builder()
self.builder.add_from_file(ViewConfig.DELETE_GLADE_FILE)
- signals = { "on_delete_confirm": self.on_delete_confirm,
- "on_delete_cancel": lambda x: x.hide,}
+ signals = {"on_delete_confirm": self.on_delete_confirm,
+ "on_delete_cancel": lambda x: x.hide, }
self.builder.connect_signals(signals)
def on_delete_confirm(self, widget):
@@ -43,7 +44,7 @@
otherwise, we will look which tid is selected"""
for tid in self.tids_todelete:
if self.req.has_task(tid):
- self.req.delete_task(tid,recursive=True)
+ self.req.delete_task(tid, recursive=True)
self.tids_todelete = []
# Update tags
@@ -60,10 +61,11 @@
tasklist=[]
self.update_tags = []
for tid in self.tids_todelete:
+
def recursive_list_tasks(task_list, root):
- """Populate a list of all the subtasks and
+ """Populate a list of all the subtasks and
their children, recursively.
-
+
Also collect the list of affected tags
which should be refreshed"""
if root not in task_list:
@@ -78,7 +80,7 @@
task = self.req.get_task(tid)
recursive_list_tasks(tasklist, task)
- # We fill the text and the buttons' labels according to the number
+ # We fill the text and the buttons' labels according to the number
# of tasks to delete
label = self.builder.get_object("label1")
label_text = label.get_text()
@@ -104,7 +106,7 @@
"Permanently remove tasks",
singular))
label_text = label_text[0:label_text.find(":") + 1]
-
+
#we don't want to end with just one task that doesn't fit the
# screen and a line saying "And one more task", so we go a
# little over our limit
@@ -123,7 +125,7 @@
cancel_button = self.builder.get_object("cancel")
cancel_button.grab_focus()
if delete_dialog.run() != 1:
- tasklist = []
+ tasklist = []
delete_dialog.hide()
return tasklist
else:
=== modified file 'GTG/gtk/editor/__init__.py'
--- GTG/gtk/editor/__init__.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/editor/__init__.py 2012-11-25 21:29:25 +0000
@@ -21,12 +21,12 @@
"""
import os
-from GTG import _
+from GTG import _
class GnomeConfig:
current_rep = os.path.dirname(os.path.abspath(__file__))
- GLADE_FILE = os.path.join(current_rep, "taskeditor.glade")
+ GLADE_FILE = os.path.join(current_rep, "taskeditor.glade")
MARK_DONE = _("Mark as Done")
MARK_UNDONE = _("Mark as not Done")
=== modified file 'GTG/gtk/editor/editor.py'
--- GTG/gtk/editor/editor.py 2012-08-26 16:41:47 +0000
+++ GTG/gtk/editor/editor.py 2012-11-25 21:29:25 +0000
@@ -28,21 +28,22 @@
import pango
import gtk
-from GTG import _, ngettext
-from GTG.gtk.editor import GnomeConfig
+from GTG import _, ngettext
+from GTG.gtk.editor import GnomeConfig
from GTG.gtk.editor.taskview import TaskView
from GTG.core.plugins.engine import PluginEngine
-from GTG.core.plugins.api import PluginAPI
-from GTG.core.task import Task
-from GTG.tools.dates import Date
+from GTG.core.plugins.api import PluginAPI
+from GTG.core.task import Task
+from GTG.tools.dates import Date
from GTG.gtk.editor.calendar import GTGCalendar
+
class TaskEditor:
- def __init__(self,
- requester,
- vmanager,
- task,
+ def __init__(self,
+ requester,
+ vmanager,
+ task,
taskconfig = None,
thisisnew = False,
clipboard = None):
@@ -91,13 +92,13 @@
"on_move": self.on_move,
}
self.builder.connect_signals(dic)
- self.window = self.builder.get_object("TaskEditor")
+ self.window = self.builder.get_object("TaskEditor")
#Removing the Normal textview to replace it by our own
#So don't try to change anything with glade, this is a home-made widget
textview = self.builder.get_object("textview")
scrolled = self.builder.get_object("scrolledtask")
scrolled.remove(textview)
- self.textview = TaskView(self.req, self.clipboard)
+ self.textview = TaskView(self.req, self.clipboard)
self.textview.show()
self.textview.set_subtask_callback(self.new_subtask)
self.textview.open_task_callback(self.vmanager.open_task)
@@ -106,13 +107,13 @@
scrolled.add(self.textview)
conf_font_value = self.browser_config.get("font_name")
if conf_font_value!= "":
- self.textview.modify_font(pango.FontDescription(conf_font_value))
+ self.textview.modify_font(pango.FontDescription(conf_font_value))
#Voila! it's done
- self.calendar = GTGCalendar(self.builder)
+ self.calendar = GTGCalendar(self.builder)
self.duedate_widget = self.builder.get_object("duedate_entry")
self.startdate_widget = self.builder.get_object("startdate_entry")
self.closeddate_widget = self.builder.get_object("closeddate_entry")
- self.dayleft_label = self.builder.get_object("dayleft")
+ self.dayleft_label = self.builder.get_object("dayleft")
self.tasksidebar = self.builder.get_object("tasksidebar")
# Define accelerator keys
self.init_accelerators()
@@ -169,14 +170,15 @@
if tid in self.config:
if "position" in self.config[tid]:
pos = self.config[tid]["position"]
- self.move(pos[0],pos[1])
- #print "restoring position %s %s" %(pos[0],pos[1])
+ self.move(pos[0], pos[1])
+ #print "restoring position %s %s" %(pos[0], pos[1])
if "size" in self.config[tid]:
size = self.config[tid]["size"]
#print "size %s - %s" %(str(size[0]), str(size[1]))
- #this eval(str()) is a ugly (!) hack to accept both int and str
+ #this eval(str()) is a ugly (!) hack to accept both int and
+ #str
#FIXME: Fix this!
- self.window.resize(eval(str(size[0])),eval(str(size[1])))
+ self.window.resize(eval(str(size[0])), eval(str(size[1])))
self.textview.set_editable(True)
self.window.show()
@@ -201,18 +203,21 @@
# Ctrl-Shift-N creates a new subtask
insert_subtask = self.builder.get_object("insert_subtask")
- key, mod = gtk.accelerator_parse("<Control><Shift>n")
- insert_subtask.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE)
+ key, mod = gtk.accelerator_parse("<Control><Shift>n")
+ insert_subtask.add_accelerator('clicked', agr, key, mod,
+ gtk.ACCEL_VISIBLE)
# Ctrl-D marks task as done
mark_as_done_editor = self.builder.get_object('mark_as_done_editor')
key, mod = gtk.accelerator_parse('<Control>d')
- mark_as_done_editor.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE)
+ mark_as_done_editor.add_accelerator('clicked', agr, key, mod,
+ gtk.ACCEL_VISIBLE)
# Ctrl-I marks task as dismissed
dismiss_editor = self.builder.get_object('dismiss_editor')
key, mod = gtk.accelerator_parse('<Control>i')
- dismiss_editor.add_accelerator('clicked', agr, key, mod, gtk.ACCEL_VISIBLE)
+ dismiss_editor.add_accelerator('clicked', agr, key, mod,
+ gtk.ACCEL_VISIBLE)
#Can be called at any time to reflect the status of the Task
#Refresh should never interfere with the TaskView.
@@ -224,34 +229,37 @@
if self.window == None:
return
to_save = False
- #title of the window
+ #title of the window
if title:
self.window.set_title(title)
to_save = True
else:
self.window.set_title(self.task.get_title())
- status = self.task.get_status()
+ status = self.task.get_status()
if status == Task.STA_DISMISSED:
self.donebutton.set_label(GnomeConfig.MARK_DONE)
self.donebutton.set_tooltip_text(GnomeConfig.MARK_DONE_TOOLTIP)
self.donebutton.set_icon_name("gtg-task-done")
self.dismissbutton.set_label(GnomeConfig.MARK_UNDISMISS)
- self.dismissbutton.set_tooltip_text(GnomeConfig.MARK_UNDISMISS_TOOLTIP)
+ self.dismissbutton.set_tooltip_text(
+ nomeConfig.MARK_UNDISMISS_TOOLTIP)
self.dismissbutton.set_icon_name("gtg-task-undismiss")
elif status == Task.STA_DONE:
self.donebutton.set_label(GnomeConfig.MARK_UNDONE)
self.donebutton.set_tooltip_text(GnomeConfig.MARK_UNDONE_TOOLTIP)
self.donebutton.set_icon_name("gtg-task-undone")
self.dismissbutton.set_label(GnomeConfig.MARK_DISMISS)
- self.dismissbutton.set_tooltip_text(GnomeConfig.MARK_DISMISS_TOOLTIP)
+ self.dismissbutton.set_tooltip_text(
+ GnomeConfig.MARK_DISMISS_TOOLTIP)
self.dismissbutton.set_icon_name("gtg-task-dismiss")
else:
self.donebutton.set_label(GnomeConfig.MARK_DONE)
self.donebutton.set_tooltip_text(GnomeConfig.MARK_DONE_TOOLTIP)
self.donebutton.set_icon_name("gtg-task-done")
self.dismissbutton.set_label(GnomeConfig.MARK_DISMISS)
- self.dismissbutton.set_tooltip_text(GnomeConfig.MARK_DISMISS_TOOLTIP)
+ self.dismissbutton.set_tooltip_text(
+ GnomeConfig.MARK_DISMISS_TOOLTIP)
self.dismissbutton.set_icon_name("gtg-task-dismiss")
self.donebutton.show()
self.tasksidebar.show()
@@ -265,7 +273,7 @@
else:
self.builder.get_object("label4").hide()
self.builder.get_object("hbox4").hide()
- self.builder.get_object("label2").show()
+ self.builder.get_object("label2").show()
self.builder.get_object("hbox1").show()
#refreshing the start date field
@@ -277,7 +285,7 @@
update_date = True
if update_date:
- self.startdate_widget.set_text(str(startdate))
+ self.startdate_widget.set_text(str(startdate))
#refreshing the due date field
duedate = self.task.get_due_date()
@@ -297,8 +305,8 @@
self.closeddate_widget.set_text(str(closeddate))
#refreshing the day left label
- #If the task is marked as done, we display the delay between the
- #due date and the actual closing date. If the task isn't marked
+ #If the task is marked as done, we display the delay between the
+ #due date and the actual closing date. If the task isn't marked
#as done, we display the number of days left.
if status in [Task.STA_DISMISSED, Task.STA_DONE]:
delay = self.task.get_days_late()
@@ -307,22 +315,27 @@
elif delay == 0:
txt = "Completed on time"
elif delay >= 1:
- txt = ngettext("Completed %(days)d day late", "Completed %(days)d days late", delay) % {'days': delay}
+ txt = ngettext("Completed %(days)d day late",
+ "Completed %(days)d days late", delay) % {'days': delay}
elif delay <= -1:
abs_delay = abs(delay)
- txt = ngettext("Completed %(days)d day early", "Completed %(days)d days early", abs_delay) % {'days': abs_delay}
+ txt = ngettext("Completed %(days)d day early",
+ "Completed %(days)d days early", abs_delay) % \
+ {'days': abs_delay}
else:
due_date = self.task.get_due_date()
result = due_date.days_left()
if due_date.is_fuzzy():
txt = ""
elif result > 0:
- txt = ngettext("Due tomorrow!", "%(days)d days left", result) % {'days': result}
+ txt = ngettext("Due tomorrow!", "%(days)d days left", result) \
+ % {'days': result}
elif result == 0:
txt = _("Due today!")
elif result < 0:
abs_result = abs(result)
- txt = ngettext("Due yesterday!", "Was %(days)d days ago", abs_result) % {'days': abs_result}
+ txt = ngettext("Due yesterday!", "Was %(days)d days ago",
+ abs_result) % {'days': abs_result}
window_style = self.window.get_style()
color = str(window_style.text[gtk.STATE_INSENSITIVE])
self.dayleft_label.set_markup("<span color='"+color+"'>"+txt+"</span>")
@@ -348,7 +361,7 @@
if to_save:
self.light_save()
- def date_changed(self,widget,data):
+ def date_changed(self, widget, data):
text = widget.get_text()
valid = True
if not text:
@@ -418,7 +431,7 @@
for task in all_subtasks:
self.vmanager.close_task(task.get_id())
- def dismiss(self,widget): #pylint: disable-msg=W0613
+ def dismiss(self, widget): #pylint: disable-msg=W0613
stat = self.task.get_status()
if stat == "Dismiss":
self.task.set_status("Active")
@@ -428,7 +441,7 @@
self.close_all_subtasks()
self.close(None)
- def change_status(self,widget): #pylint: disable-msg=W0613
+ def change_status(self, widget): #pylint: disable-msg=W0613
stat = self.task.get_status()
if stat == "Done":
self.task.set_status("Active")
@@ -447,7 +460,7 @@
self.vmanager.ask_delete_tasks([self.task.get_id()])
#Take the title as argument and return the subtask ID
- def new_subtask(self,title=None,tid=None):
+ def new_subtask(self, title=None, tid=None):
if tid:
self.task.add_child(tid)
elif title:
@@ -462,25 +475,25 @@
task_id = task.get_id()
self.vmanager.open_task(task_id)
- def insert_subtask(self,widget): #pylint: disable-msg=W0613
+ def insert_subtask(self, widget): #pylint: disable-msg=W0613
self.textview.insert_newtask()
self.textview.grab_focus()
- def inserttag_clicked(self,widget): #pylint: disable-msg=W0613
+ def inserttag_clicked(self, widget): #pylint: disable-msg=W0613
itera = self.textview.get_insert()
if itera.starts_line():
- self.textview.insert_text("@",itera)
+ self.textview.insert_text("@", itera)
else:
- self.textview.insert_text(" @",itera)
+ self.textview.insert_text(" @", itera)
self.textview.grab_focus()
- def inserttag(self,widget,tag): #pylint: disable-msg=W0613
+ def inserttag(self, widget, tag): #pylint: disable-msg=W0613
self.textview.insert_tags([tag])
self.textview.grab_focus()
def save(self):
self.task.set_title(self.textview.get_title())
- self.task.set_text(self.textview.get_text())
+ self.task.set_text(self.textview.get_text())
self.task.sync()
if self.config != None:
self.config.write()
@@ -499,22 +512,22 @@
if tosave:
self.save()
- #This will bring the Task Editor to front
+ #This will bring the Task Editor to front
def present(self):
self.window.present()
- def move(self,x,y):
+ def move(self, x, y):
try:
xx=int(x)
yy=int(y)
- self.window.move(xx,yy)
+ self.window.move(xx, yy)
except:
pass
def get_position(self):
return self.window.get_position()
- def on_move(self,widget,event):
+ def on_move(self, widget, event):
#saving the position
if self.config != None:
tid = self.task.get_id()
@@ -525,17 +538,19 @@
self.config[tid]["size"] = self.window.get_size()
#We define dummy variable for when close is called from a callback
- def close(self,window=None,a=None,b=None,c=None): #pylint: disable-msg=W0613
+ def close(self, window=None, a=None, b=None, c=None):
+ #pylint: disable-msg=W0613
#We should also destroy the whole taskeditor object.
if self.window:
self.window.destroy()
self.window = None
#The destroy signal is linked to the "close" button. So if we call
- #destroy in the close function, this will cause the close to be called twice
+ #destroy in the close function, this will cause the close to be called
+ #twice
#To solve that, close will just call "destroy" and the destroy signal
#Will be linked to this destruction method that will save the task
- def destruction(self,a=None):
+ def destruction(self, a=None):
#Save should be also called when buffer is modified
self.pengine.onTaskClose(self.plugin_api)
self.pengine.remove_api(self.plugin_api)
=== modified file 'GTG/gtk/editor/taskview.py'
--- GTG/gtk/editor/taskview.py 2012-10-23 09:31:00 +0000
+++ GTG/gtk/editor/taskview.py 2012-11-25 21:29:25 +0000
@@ -16,8 +16,6 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
-
-
"""
This class implements a gtk.TextView but with many other features
like hyperlink and other stuff special for GTG
@@ -40,10 +38,10 @@
from GTG.gtk.editor import taskviewserial
from GTG.tools import urlregex
-separators = [' ', ',', '\n', '\t', '!', '?', ';', '\0','(',')']
+separators = [' ', ',', '\n', '\t', '!', '?', ';', '\0', '(', ')']
#those separators are only separators if followed by a space. Else, they
#are part of the word
-specials_separators = ['.','/']
+specials_separators = ['.', '/']
bullet1_ltr = '→'
bullet1_rtl = '←'
@@ -51,22 +49,22 @@
class TaskView(gtk.TextView):
__gtype_name__ = 'HyperTextView'
- __gsignals__ = {'anchor-clicked': (gobject.SIGNAL_RUN_LAST, \
+ __gsignals__ = {'anchor-clicked': (gobject.SIGNAL_RUN_LAST,
None, (str, str, int))}
__gproperties__ = {
- 'link': (gobject.TYPE_PYOBJECT, 'link color',\
+ 'link': (gobject.TYPE_PYOBJECT, 'link color',
'link color of TextView', gobject.PARAM_READWRITE),
- 'failedlink': (gobject.TYPE_PYOBJECT, 'failed link color',\
+ 'failedlink': (gobject.TYPE_PYOBJECT, 'failed link color',
'failed link color of TextView', gobject.PARAM_READWRITE),
- 'active': (gobject.TYPE_PYOBJECT, 'active color', \
+ 'active': (gobject.TYPE_PYOBJECT, 'active color',
'active color of TextView', gobject.PARAM_READWRITE),
- 'hover': (gobject.TYPE_PYOBJECT, 'link:hover color', \
+ 'hover': (gobject.TYPE_PYOBJECT, 'link:hover color',
'link:hover color of TextView', gobject.PARAM_READWRITE),
- 'tag': (gobject.TYPE_PYOBJECT, 'tag color', \
+ 'tag': (gobject.TYPE_PYOBJECT, 'tag color',
'tag color of TextView', gobject.PARAM_READWRITE),
- 'done': (gobject.TYPE_PYOBJECT, 'link color', \
+ 'done': (gobject.TYPE_PYOBJECT, 'link color',
'link color of TextView', gobject.PARAM_READWRITE),
- 'indent': (gobject.TYPE_PYOBJECT, 'indent color', \
+ 'indent': (gobject.TYPE_PYOBJECT, 'indent color',
'indent color of TextView', gobject.PARAM_READWRITE),
}
@@ -83,22 +81,23 @@
raise AttributeError('unknown property %s' % prop.name)
#Yes, we want to redefine the buffer. Disabling pylint on that error.
- def __init__(self, requester, clipboard, buffer=None): #pylint: disable-msg=W0622
+ def __init__(self, requester, clipboard, buffer=None):
+ #pylint: disable-msg=W0622
gtk.TextView.__init__(self, buffer)
self.buff = self.get_buffer()
self.req = requester
#Buffer init
- self.link = {'background': 'white', 'foreground': '#007bff', \
- 'underline': pango.UNDERLINE_SINGLE, \
- 'strikethrough': False}
- self.failedlink = {'background': 'white', 'foreground': '#ff5454', \
- 'underline': pango.UNDERLINE_NONE, \
- 'strikethrough': False}
- self.done = {'background': 'white', 'foreground': 'gray',\
+ self.link = {'background': 'white', 'foreground': '#007bff',
+ 'underline': pango.UNDERLINE_SINGLE,
+ 'strikethrough': False}
+ self.failedlink = {'background': 'white', 'foreground': '#ff5454',
+ 'underline': pango.UNDERLINE_NONE,
+ 'strikethrough': False}
+ self.done = {'background': 'white', 'foreground': 'gray',
'strikethrough': True}
- self.active = {'background': 'light gray', 'foreground': '#ff1e00',\
+ self.active = {'background': 'light gray', 'foreground': '#ff1e00',
'underline': pango.UNDERLINE_SINGLE}
- self.hover = {'background': 'light gray'}
+ self.hover = {'background': 'light gray'}
self.tag = {'background': "#FFea00", 'foreground': 'black'}
self.indent = {'scale': 1.4, 'editable': False, 'left-margin': 10,
"accumulative-margin": True}
@@ -108,7 +107,7 @@
# but set in self.modified)
self.table = self.buff.get_tag_table()
# Tag for title
- self.title_tag = self.buff.create_tag("title", foreground="#007bff", \
+ self.title_tag = self.buff.create_tag("title", foreground="#007bff",
scale=1.6, underline=1)
self.title_tag.set_property("pixels-above-lines", 10)
self.title_tag.set_property("pixels-below-lines", 10)
@@ -125,13 +124,14 @@
#Signals
self.connect('motion-notify-event', self._motion)
- self.connect('focus-out-event', lambda w, \
- e: self.table.foreach(self.__tag_reset, e.window))
- self.insert_sigid = self.buff.connect('insert-text', \
+ self.connect('focus-out-event',
+ lambda w, e: self.table.foreach(self.__tag_reset, e.window))
+ self.insert_sigid = self.buff.connect('insert-text',
self._insert_at_cursor)
- self.delete_sigid = self.buff.connect("delete-range", self._delete_range)
- self.connect('copy-clipboard', self.copy_clipboard,"copy")
- self.connect('cut-clipboard', self.copy_clipboard,"cut")
+ self.delete_sigid = self.buff.connect("delete-range",
+ self._delete_range)
+ self.connect('copy-clipboard', self.copy_clipboard, "copy")
+ self.connect('cut-clipboard', self.copy_clipboard, "cut")
self.connect('paste-clipboard', self.paste_clipboard)
self.connect('drag-data-received', self.drag_receive)
@@ -146,8 +146,10 @@
self.mime_type = 'application/x-gtg-task'
serializer = taskviewserial.Serializer()
unserializer = taskviewserial.Unserializer(self)
- self.buff.register_serialize_format(self.mime_type, serializer.serialize, None)
- self.buff.register_deserialize_format(self.mime_type, unserializer.unserialize, None)
+ self.buff.register_serialize_format(self.mime_type,
+ serializer.serialize, None)
+ self.buff.register_deserialize_format(self.mime_type,
+ unserializer.unserialize, None)
#The list of callbacks we have to set
self.remove_tag_callback = None
@@ -156,7 +158,7 @@
self.get_subtasks = None
self.remove_subtask =None
self.__refresh_cb = None # refresh the editor window
- self.open_task = None # open another task
+ self.open_task = None # open another task
self.new_subtask_callback = None # create a subtask
self.save_task = None #This will save the task without refreshing all
@@ -185,7 +187,8 @@
#editable means that the user can edit the taskview
#this is initially set at False and then to True once the editor window
#is displayed.
- #this is used to avoid saving the task when the window is still not displayed
+ #this is used to avoid saving the task when the window is still
+ #not displayed
def set_editable(self, boule):
self.editable = boule
@@ -270,7 +273,8 @@
#reconnect
if reconnect_insert:
- self.insert_sigid = self.buff.connect('insert-text', self._insert_at_cursor)
+ self.insert_sigid = self.buff.connect('insert-text',
+ self._insert_at_cursor)
if reconnect_modified:
self.modified_sigid = self.buff.connect("changed", self.modified)
@@ -308,7 +312,6 @@
else:
return True
-
def create_anchor_tag(self, b, anchor, text=None, typ=None):
#We cannot have two tags with the same name
#That's why the link tag has no name
@@ -326,7 +329,8 @@
if linktype == 'link' and not self.check_link(anchor):
linktype = 'failedlink'
- tag = b.create_tag(None, **self.get_property(linktype)) #pylint: disable-msg=W0142
+ #pylint: disable-msg=W0142
+ tag = b.create_tag(None, **self.get_property(linktype))
tag.set_data('is_anchor', True)
tag.set_data('link', anchor)
if typ:
@@ -349,7 +353,8 @@
if ss.begins_tag(t) and ee.ends_tag(t):
already = True
if not texttag:
- texttag = buff.create_tag(None,**self.get_property('tag'))#pylint: disable-msg=W0142
+ #pylint: disable-msg=W0142
+ texttag = buff.create_tag(None, **self.get_property('tag'))
texttag.set_data('is_tag', True)
texttag.set_data('tagname', tag)
#This one is for marks
@@ -371,7 +376,8 @@
tex = buff.get_text(i_s, i_e)
if len(tex) > 0:
self.req.get_task(subtask).set_title(tex)
- texttag = self.create_anchor_tag(buff, subtask, text=tex, typ="subtask")
+ texttag = self.create_anchor_tag(buff, subtask, text=tex,
+ typ="subtask")
texttag.set_data('is_subtask', True)
texttag.set_data('child', subtask)
#This one is for marks
@@ -382,7 +388,8 @@
buff.delete_mark(e)
def create_indent_tag(self, buff, level):
- tag = buff.create_tag(None, **self.get_property('indent'))#pylint: disable-msg=W0142
+ #pylint: disable-msg=W0142
+ tag = buff.create_tag(None, **self.get_property('indent'))
tag.set_data('is_indent', True)
tag.set_data('indent_level', level)
return tag
@@ -409,10 +416,12 @@
if tt.get_data('is_tag'):
newline = False
firstline.forward_to_line_end()
- #Now we should check if the current char is a separator or not
- #Currently, we insert a space
+ # Now we should check if the current char is
+ # a separator or not
+ # Currently, we insert a space
self.insert_text(" ", firstline)
- #Now we check if this newline is empty (it contains only " " and ",")
+ # Now we check if this newline is empty
+ # (it contains only " " and ",")
# if newline:
# endline = firstline.copy()
# if not endline.ends_line():
@@ -428,13 +437,13 @@
self.insert_text("\n", firstline)
firstline = self.buff.get_iter_at_line(1)
line_mark = self.buff.create_mark("firstline", firstline, False)
- #self.tv.insert_at_mark(buf, line_mark,"\n")
+ #self.tv.insert_at_mark(buf, line_mark, "\n")
ntags = len(tag_list)
for t in tag_list:
ntags = ntags - 1
self.insert_at_mark(self.buff, line_mark, t)
if ntags != 0:
- self.insert_at_mark(self.buff, line_mark,",")
+ self.insert_at_mark(self.buff, line_mark, ",")
self.buff.delete_mark(line_mark)
self.modified(full=True)
@@ -490,9 +499,7 @@
stripped = title.strip(' \n\t')
return stripped
-### PRIVATE FUNCTIONS ##########################################################
-
-
+ ### PRIVATE FUNCTIONS #####################################################
#This function is called so frequently that we should optimize it more.
def modified(self, buff=None, full=False, refresheditor=True):
"""Called when the buffer has been modified.
@@ -538,9 +545,11 @@
#subt_list = self.get_subtasks()
#First, we remove the olds tags
tag_list = []
+
def subfunc(texttag, data=None): #pylint: disable-msg=W0613
if texttag.get_data('is_subtask'):
tag_list.append(texttag)
+
table.foreach(subfunc)
start, end = buff.get_bounds()
for t in tag_list:
@@ -583,9 +592,11 @@
#First, we remove the olds tags
tag_list = []
table = buff.get_tag_table()
+
def subfunc(texttag, data=None):
if texttag.get_data('is_anchor'):
tag_list.append(texttag)
+
table.foreach(subfunc)
for t in tag_list:
buff.remove_tag(t, start, end)
@@ -606,7 +617,8 @@
# For short URL we must add http:// prefix
if text == "www":
url = "http://" + url
- texttag = self.create_anchor_tag(buff, url, text=None, typ="http")
+ texttag = self.create_anchor_tag(buff, url, text=None,
+ typ="http")
it = prev.copy()
it.forward_chars(m.end())
buff.apply_tag(texttag, prev, it)
@@ -622,15 +634,18 @@
nbr = url.split("#")[1]
topoint = None
if url.startswith("bug #") or url.startswith("lp #"):
- topoint = "https://launchpad.net/bugs/%s" %nbr
+ topoint = "https://launchpad.net/bugs/%s" % nbr
elif url.startswith("bgo #"):
- topoint = "http://bugzilla.gnome.org/show_bug.cgi?id=%s" %nbr
+ topoint = "http://bugzilla.gnome.org/" + \
+ "show_bug.cgi?id=%s" % nbr
elif url.startswith("bko #"):
- topoint = "https://bugs.kde.org/show_bug.cgi?id=%s" %nbr
+ topoint = "https://bugs.kde.org/show_bug.cgi?id=%s" \
+ % nbr
elif url.startswith("fdo #"):
- topoint = "http://bugs.freedesktop.org/show_bug.cgi?id=%s" %nbr
+ topoint = "http://bugs.freedesktop.org/" + \
+ "show_bug.cgi?id=%s" % nbr
if topoint:
- texttag = self.create_anchor_tag(buff,\
+ texttag = self.create_anchor_tag(buff,
topoint, text=None, typ="http")
buff.apply_tag(texttag, prev, it)
@@ -659,29 +674,31 @@
mark1 = buff.get_mark(tagname)
if mark1:
offset1 = buff.get_iter_at_mark(mark1).get_offset()
- if start.get_offset() <= offset1 <= end.get_offset():
+ if start.get_offset() <= offset1 <= \
+ end.get_offset():
buff.delete_mark_by_name(tagname)
mark2 = buff.get_mark("/%s"%tagname)
if mark2:
offset2 = buff.get_iter_at_mark(mark2).get_offset()
- if start.get_offset() <= offset2 <= end.get_offset():
+ if start.get_offset() <= offset2 <= \
+ end.get_offset():
buff.delete_mark_by_name("/%s"%tagname)
it.forward_char()
# Set iterators for word
word_start = start.copy()
- word_end = start.copy()
+ word_end = start.copy()
# Set iterators for char
char_start = start.copy()
- char_end = start.copy()
+ char_end = start.copy()
char_end.forward_char()
last_char = None
# Iterate over characters of the line to get words
while char_end.compare(end) <= 0:
do_word_check = False
- my_char = buff.get_text(char_start, char_end)
+ my_char = buff.get_text(char_start, char_end)
if my_char not in separators:
last_char = my_char
word_end = char_end.copy()
@@ -707,7 +724,8 @@
#and it shouldn't start with @@ (bug 531553)
if len(my_word) > 1 and my_word[0] == '@' \
and not my_word[1] == '@':
- #self.apply_tag_tag(buff, my_word, word_start, word_end)
+ #self.apply_tag_tag(buff, my_word, word_start,
+ # word_end)
#We will add mark where tag should be applied
buff.create_mark(my_word, word_start, True)
buff.create_mark("/%s"%my_word, word_end, False)
@@ -718,7 +736,7 @@
# We set new word boundaries
word_start = char_end.copy()
- word_end = char_end.copy()
+ word_end = char_end.copy()
# Stop loop if we are at the end
if char_end.compare(end) == 0:
@@ -768,7 +786,7 @@
# buff.remove_tag(ta, start, endindent)
#Now we delete all, char after char
it = start.copy()
- while (it.get_offset() <= end.get_offset()) and (it.get_char() != '\0'):
+ while it.get_offset() <= end.get_offset() and it.get_char() != '\0':
if it.begins_tag():
tags = it.get_tags()
for ta in tags:
@@ -798,7 +816,8 @@
#now we really delete the selected stuffs
selec = self.buff.get_selection_bounds()
# if selec:
-# print "deleted text is ##%s##" %self.buff.get_text(selec[0], selec[1])#(start, end)
+# print "deleted text is ##%s##" %self.buff.get_text(selec[0],
+# selec[1])#(start, end)
# self.buff.disconnect(self.delete_sigid)
# self.disconnect(self.backspace_sigid)
# self.buff.stop_emission("delete-range")
@@ -807,16 +826,20 @@
# else:
# end.forward_char()
# self.buff.backspace(end, False, True)
-# self.delete_sigid = self.buff.connect("delete-range", self._delete_range)
+# self.delete_sigid = self.buff.connect("delete-range",
+# self._delete_range)
# self.backspace_sigid = self.connect("backspace", self.backspace)
#We return false so the parent still get the signal
return False
- #Apply the title and return an iterator after that title.buff.get_iter_at_mar
def _apply_title(self, buff, refresheditor=True):
- start = buff.get_start_iter()
- end = buff.get_end_iter()
- line_nbr = 1
+ """
+ Apply the title and return an iterator after that
+ title.buff.get_iter_at_mar
+ """
+ start = buff.get_start_iter()
+ end = buff.get_end_iter()
+ line_nbr = 1
linecount = buff.get_line_count()
# Apply the title tag on the first line
@@ -828,14 +851,14 @@
# Applying title on the first line
title_end = buff.get_iter_at_line(line_nbr-1)
title_end.forward_to_line_end()
- stripped = buff.get_text(title_start, title_end).strip('\n\t ')
+ stripped = buff.get_text(title_start, title_end).strip('\n\t ')
# Here we ignore lines that are blank
# Title is the first written line
while line_nbr <= linecount and not stripped:
- line_nbr += 1
- title_end = buff.get_iter_at_line(line_nbr-1)
+ line_nbr += 1
+ title_end = buff.get_iter_at_line(line_nbr-1)
title_end.forward_to_line_end()
- stripped = buff.get_text(title_start, title_end).strip('\n\t ')
+ stripped = buff.get_text(title_start, title_end).strip('\n\t ')
# Or to all the buffer if there is only one line
else:
title_end = end.copy()
@@ -846,8 +869,6 @@
self.refresh(buff.get_text(title_start, title_end).strip('\n\t'))
return title_end
-
-
def __newsubtask(self, buff, title, line_nbr, level=1):
anchor = self.new_subtask_callback(title)
end_i = self.write_subtask(buff, line_nbr, anchor, level=level)
@@ -875,10 +896,10 @@
#be in the subtask title
start_i = buff.get_iter_at_line(line_nbr)
start_i.forward_to_line_end()
- buff.insert(start_i,"\n")
+ buff.insert(start_i, "\n")
#Ok, now we can start working
start_i = buff.get_iter_at_line(line_nbr)
- end_i = start_i.copy()
+ end_i = start_i.copy()
#We go back at the end of the previous line
# start_i.backward_char()
# #But only if this is not the title.
@@ -886,9 +907,9 @@
# if start_i.has_tag(self.title_tag):
# start_i.forward_char()
# insert_enter = False
- start = buff.create_mark("start", start_i, True)
+ start = buff.create_mark("start", start_i, True)
end_i.forward_line()
- end = buff.create_mark("end", end_i, False)
+ end = buff.create_mark("end", end_i, False)
buff.delete(start_i, end_i)
start_i = buff.get_iter_at_mark(start)
self.insert_indent(buff, start_i, level, enter=insert_enter)
@@ -905,7 +926,8 @@
#buff.delete_mark(end)
if reconnect_insert:
- self.insert_sigid = self.buff.connect('insert-text', self._insert_at_cursor)
+ self.insert_sigid = self.buff.connect('insert-text',
+ self._insert_at_cursor)
if reconnect_modified:
self.modified_sigid = self.buff.connect("changed", self.modified)
return end_i
@@ -936,7 +958,7 @@
if line == self.buff.get_line_count():
itera.forward_to_line_end()
mark = self.buff.create_mark(None, itera, True)
- self.buff.insert(itera,"\n")
+ self.buff.insert(itera, "\n")
itera = self.buff.get_iter_at_mark(mark)
self.buff.delete_mark(mark)
@@ -946,7 +968,7 @@
enter = True
if itera.starts_line():
mark = self.buff.create_mark(None, itera, True)
- self.buff.insert(itera,"\n")
+ self.buff.insert(itera, "\n")
itera = self.buff.get_iter_at_mark(mark)
self.buff.delete_mark(mark)
enter = False
@@ -977,9 +999,9 @@
#It will be later replaced by the good one with right gravity
temp_mark = self.buff.create_mark("temp", start_i, True)
- end = buff.create_mark("end", start_i, False)
+ end = buff.create_mark("end", start_i, False)
if enter:
- buff.insert(start_i,"\n")
+ buff.insert(start_i, "\n")
#Moving the end of subtask mark to the position of the temp mark
if stag:
@@ -994,7 +1016,7 @@
#This is normally not needed and purely defensive
if itera.get_line() <= 0:
itera = buff.get_iter_at_line(1)
- start = buff.create_mark("start", itera, True)
+ start = buff.create_mark("start", itera, True)
indentation = ""
#adding two spaces by level
spaces = " "
@@ -1007,7 +1029,6 @@
self.__apply_tag_to_mark(start, end, tag=indenttag)
return end
-
def __apply_tag_to_mark(self, start, end, tag=None, name=None):
start_i = self.buff.get_iter_at_mark(start)
end_i = self.buff.get_iter_at_mark(end)
@@ -1027,9 +1048,8 @@
else:
buff.insert(ite, text)
-
def _get_indent_level(self, itera):
- line_nbr = itera.get_line()
+ line_nbr = itera.get_line()
start_line = itera.copy()
start_line.set_line(line_nbr)
tags = start_line.get_tags()
@@ -1046,10 +1066,10 @@
#First, we analyse the selection to put in our own
#GTG clipboard a selection with description of subtasks
- bounds = self.buff.get_selection_bounds()
+ bounds = self.buff.get_selection_bounds()
if not bounds:
return
- start, stop = self.buff.get_selection_bounds()
+ start, stop = self.buff.get_selection_bounds()
self.clipboard.copy(start, stop, bullet=self.bullet1)
@@ -1105,10 +1125,10 @@
#First, we will get the actual indentation value
#The nbr just before the \n
- line_nbr = itera.get_line()
+ line_nbr = itera.get_line()
start_line = itera.copy()
start_line.set_line(line_nbr)
- end_line = itera.copy()
+ end_line = itera.copy()
tags = start_line.get_tags()
subtask_nbr = None
current_indent = self._get_indent_level(itera)
@@ -1157,24 +1177,28 @@
#the "-" might be after a space
#Python 2.5 should allow both tests in one
if current_indent == 0:
- if (line.startswith('-') or line.startswith(' -')) and line.lstrip(' -').strip() != "":
+ if (line.startswith('-') or line.startswith(' -')) \
+ and line.lstrip(' -').strip() != "":
line = line.lstrip(' -')
- end_i = self.__newsubtask(self.buff, line, line_nbr)
+ end_i = self.__newsubtask(self.buff, line,
+ line_nbr)
#Here, we should increment indent level
#If we inserted enter in the middle of a line
if restofline and restofline.strip() != "":
#it means we have two subtask to create
if self.buff.get_line_count() > line_nbr+1:
#but don't merge with the next line
- itera = self.buff.get_iter_at_line(line_nbr+1)
- self.buff.insert(itera,"\n\n")
- self.__newsubtask(self.buff, restofline,\
+ itera = self.buff.get_iter_at_line(
+ line_nbr + 1)
+ self.buff.insert(itera, "\n\n")
+ self.__newsubtask(self.buff, restofline,
line_nbr+1)
else:
- self.insert_indent(self.buff, end_i, 1, enter=True)
+ self.insert_indent(self.buff, end_i, 1,
+ enter=True)
tv.emit_stop_by_name('insert-text')
else:
- self.buff.insert(itera,"\n")
+ self.buff.insert(itera, "\n")
tv.emit_stop_by_name('insert-text')
#Then, if indent > 0, we increment it
@@ -1191,22 +1215,26 @@
else:
#we first put the subtask one line below
itera2 = self.buff.get_iter_at_line(line_nbr)
- self.buff.insert(itera2,"\n")
+ self.buff.insert(itera2, "\n")
#and increment the new white line
itera2 = self.buff.get_iter_at_line(line_nbr)
- self.insert_indent(self.buff, itera2, current_indent, enter=False)
+ self.insert_indent(self.buff, itera2,
+ current_indent, enter=False)
elif current_indent == 1:
- self.insert_indent(self.buff, itera, current_indent)
+ self.insert_indent(self.buff, itera,
+ current_indent)
#we stop the signal in all cases
tv.emit_stop_by_name('insert-text')
#Then we close the tag tag
if closed_tag:
insert_mark = self.buff.get_mark("insert_point")
insert_iter = self.buff.get_iter_at_mark(insert_mark)
- self.buff.move_mark_by_name("/%s"%closed_tag, insert_iter)
+ self.buff.move_mark_by_name("/%s" % closed_tag,
+ insert_iter)
self.buff.delete_mark(insert_mark)
if cutting_subtask:
- cursor = self.buff.get_iter_at_mark(self.buff.get_insert())
+ cursor = self.buff.get_iter_at_mark(
+ self.buff.get_insert())
endl = cursor.copy()
if not endl.ends_line():
endl.forward_to_line_end()
@@ -1222,7 +1250,7 @@
if itera.starts_line():
#we are at the start of an existing subtask
#we simply move that subtask down
- self.buff.insert(itera,"\n")
+ self.buff.insert(itera, "\n")
itera2 = self.buff.get_iter_at_line(line_nbr)
self.buff.insert(itera2, tex)
itera3 = self.buff.get_iter_at_line(line_nbr)
@@ -1230,25 +1258,28 @@
self.buff.place_cursor(itera3)
tv.emit_stop_by_name('insert-text')
else:
- #self.__newsubtask(self.buff, tex, line_nbr, level=current_indent)
+ #self.__newsubtask(self.buff, tex, line_nbr,
+ # level=current_indent)
anchor = self.new_subtask_callback(tex)
self.buff.create_mark(anchor, itera, True)
self.buff.create_mark("/%s"%anchor, itera, False)
- self.insert_sigid = self.buff.connect('insert-text', self._insert_at_cursor)
+ self.insert_sigid = self.buff.connect('insert-text',
+ self._insert_at_cursor)
self.connect('key_press_event', self._keypress)
self.modified_sigid = self.buff.connect("changed", self.modified)
def _keypress(self, widget, event):
# Check for Ctrl-Return/Enter
- if event.state & gtk.gdk.CONTROL_MASK and event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
+ if event.state & gtk.gdk.CONTROL_MASK and \
+ event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
buff = self.buff
cursor_mark = buff.get_insert()
cursor_iter = buff.get_iter_at_mark(cursor_mark)
local_start = cursor_iter.copy()
for tag in local_start.get_tags():
- anchor = tag.get_data('link')
- typ = tag.get_data('type')
+ anchor = tag.get_data('link')
+ typ = tag.get_data('type')
if(anchor):
if typ == "subtask":
self.open_task(anchor)
@@ -1278,12 +1309,12 @@
self.buff.disconnect(self.delete_sigid)
#print "deintdent-delete: %s" %self.buff.get_text(startline, itera)
self.buff.delete(startline, itera)
- self.delete_sigid = self.buff.connect("delete-range", \
- self._delete_range)
#For the day when we will have different indent levels
#newiter = self.buff.get_iter_at_mark(tempm)
#self.buff.delete_mark(tempm)
#self.insert_indent(self.buff, newiter, newlevel, enter=False)
+ self.delete_sigid = self.buff.connect("delete-range",
+ self._delete_range)
def backspace(self, tv):
self.buff.disconnect(self.insert_sigid)
@@ -1298,7 +1329,7 @@
#we stopped the signal, don't forget to erase
#the selection if one
self.buff.delete_selection(True, True)
- self.insert_sigid = self.buff.connect('insert-text', \
+ self.insert_sigid = self.buff.connect('insert-text',
self._insert_at_cursor)
#The mouse is moving. We must change it to a hand when hovering over a link
@@ -1318,8 +1349,11 @@
tag_table = self.buff.get_tag_table()
tag_table.foreach(self.__tag_reset, window)
- #We clicked on a link
- def _tag_event(self, tag, view, ev, _iter, text, anchor, typ): #pylint: disable-msg=W0613
+ def _tag_event(self, tag, view, ev, _iter, text, anchor, typ):
+ """
+ We clicked on a link
+ """
+ #pylint: disable-msg=W0613
_type = ev.type
if _type == gtk.gdk.MOTION_NOTIFY:
return
@@ -1330,14 +1364,17 @@
if typ == "subtask":
self.open_task(anchor)
elif typ == "http":
- if button == 1 and self.check_link(anchor) and self.buff.get_has_selection() == False:
+ if button == 1 and self.check_link(anchor) and \
+ not self.buff.get_has_selection():
openurl(anchor)
else:
print "Unknown link type for %s" %anchor
self.emit('anchor-clicked', text, anchor, button)
- self.__set_anchor(ev.window, tag, cursor, self.get_property('hover'))
+ self.__set_anchor(ev.window, tag, cursor,
+ self.get_property('hover'))
elif button in [1, 2]:
- self.__set_anchor(ev.window, tag, cursor, self.get_property('active'))
+ self.__set_anchor(ev.window, tag, cursor,
+ self.get_property('active'))
def __tag_reset(self, tag, window):
if tag.get_data('is_anchor'):
@@ -1351,7 +1388,8 @@
linktype = 'link'
else:
linktype = 'failedlink'
- self.__set_anchor(window, tag, editing_cursor, self.get_property(linktype))
+ self.__set_anchor(window, tag, editing_cursor,
+ self.get_property(linktype))
def __set_anchor(self, window, tag, cursor, prop):
window.set_cursor(cursor)
=== modified file 'GTG/gtk/editor/taskviewserial.py'
--- GTG/gtk/editor/taskviewserial.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/editor/taskviewserial.py 2012-11-25 21:29:25 +0000
@@ -107,8 +107,8 @@
elif ta.get_data('is_subtask'):
#The current gtkTextTag is a subtask
tagname = "subtask"
- subt = doc.createElement(tagname)
- target = ta.get_data('child')
+ subt = doc.createElement(tagname)
+ target = ta.get_data('child')
subt.appendChild(doc.createTextNode(target))
parent.appendChild(subt)
parent.appendChild(doc.createTextNode("\n"))
@@ -187,7 +187,7 @@
#parse the XML and put the content in the buffer
def parsexml(self, buf, ite, element):
start = buf.create_mark(None, ite, True)
- end = buf.create_mark(None, ite, False)
+ end = buf.create_mark(None, ite, False)
subtasks = self.tv.get_subtasks()
taglist2 = []
if element: