gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #03607
[Merge] lp:~nimit-svnit/gtg/cleanup-new into lp:gtg
Nimit Shah has proposed merging lp:~nimit-svnit/gtg/cleanup-new into lp:gtg.
Requested reviews:
Gtg developers (gtg)
For more details, see:
https://code.launchpad.net/~nimit-svnit/gtg/cleanup-new/+merge/119724
Some standardization of code. Just 2 folders so far: GTG/gtk/editor and GTG/gtk/browser/
--
https://code.launchpad.net/~nimit-svnit/gtg/cleanup-new/+merge/119724
Your team Gtg developers is requested to review the proposed merge of lp:~nimit-svnit/gtg/cleanup-new into lp:gtg.
=== modified file 'CHANGELOG'
--- CHANGELOG 2012-08-14 07:08:45 +0000
+++ CHANGELOG 2012-08-15 14:40:32 +0000
@@ -48,6 +48,7 @@
* Fix for bug #1027844: Fuzzy date shouldn't become start date
* Save backups into backup/ folder, creates backups of tags.xml closes #993920
* Search filter is deleted on empty search if tag_pane is closed, by Stefan Handschuh, closes #996236
+ * Some standardization of code, by Nimit Shah
2012-02-13 Getting Things GNOME! 0.2.9
* Big refractorization of code, now using liblarch
=== modified file 'GTG/gtk/backends_dialog/__init__.py'
--- GTG/gtk/backends_dialog/__init__.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/backends_dialog/__init__.py 2012-08-15 14:40:32 +0000
@@ -81,7 +81,6 @@
########################################
### INTERFACE WITH THE VIEWMANAGER #####
########################################
-
def activate(self):
'''Shows this window, refreshing the current view'''
self.dialog.show_all()
@@ -103,7 +102,6 @@
########################################
### HELPER FUNCTIONS ###################
########################################
-
def get_requester(self):
'''
Helper function: returns the requester.
@@ -126,7 +124,7 @@
'''
#NOTE: loading icons directly from the theme and scaling them results
# in blurry icons. So, instead of doing that, I'm loading them
- # directly from file.
+ # directly from file.
icon_info = self.icon_theme.lookup_icon(name, gtk.ICON_SIZE_MENU, 0)
if icon_info == None:
return None
@@ -137,7 +135,7 @@
'''
Helper function to switch between panels.
- @param panel_name: the name of the wanted panel. Choose between
+ @param panel_name: the name of the wanted panel. Choose between
"configuration" or "add"
'''
if panel_name == "configuration":
@@ -172,7 +170,6 @@
########################################
### WIDGETS AND SIGNALS ################
########################################
-
def _load_widgets_from_glade(self, builder):
'''
Loads widgets from the glade file
@@ -181,11 +178,11 @@
'''
builder.add_from_file(ViewConfig.BACKENDS_GLADE_FILE)
widgets = {
- 'dialog' : 'backends_dialog',
- 'treeview_window' : 'treeview_window',
- 'central_pane' : 'central_pane',
- 'add_button' : 'add_button',
- 'remove_button' : 'remove_button',
+ 'dialog': 'backends_dialog',
+ 'treeview_window': 'treeview_window',
+ 'central_pane': 'central_pane',
+ 'add_button': 'add_button',
+ 'remove_button': 'remove_button',
}
for attr, widget in widgets.iteritems():
setattr(self, attr, builder.get_object(widget))
@@ -216,7 +213,7 @@
def _create_widgets_for_treeview(self):
'''
- Creates the widgets for the lateral treeview displaying the
+ Creates the widgets for the lateral treeview displaying the
backends the user has added
'''
self.backends_tv = BackendsTree(self)
@@ -233,7 +230,6 @@
########################################
### EVENT HANDLING #####################
########################################
-
def on_backend_selected(self, backend_id):
'''
When a backend in the treeview gets selected, show
@@ -285,7 +281,7 @@
# pylint: disable-msg=W0613
def on_remove_button(self, widget = None, data = None):
'''
- When the remove button is pressed, a confirmation dialog is shown,
+ When the remove button is pressed, a confirmation dialog is shown,
and if the answer is positive, the backend is deleted.
'''
backend_id = self.backends_tv.get_selected_backend_id()
@@ -302,7 +298,7 @@
_("Do you really want to remove the '%s' "
"synchronization service?") % \
backend.get_human_name())
- response = dialog.run()
+ response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
#delete the backend and remove it from the lateral treeview
=== modified file 'GTG/gtk/backends_dialog/addpanel.py'
--- GTG/gtk/backends_dialog/addpanel.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/backends_dialog/addpanel.py 2012-08-15 14:40:32 +0000
@@ -25,11 +25,10 @@
class AddPanel(gtk.VBox):
- '''
+ '''
A VBox filled with gtk widgets to let the user choose a new backend.
'''
-
def __init__(self, backends_dialog):
'''
Constructor, just initializes the gtk widgets
@@ -111,7 +110,7 @@
def _fill_bottom_hbox(self, hbox):
'''
- Helper function to fill and hbox with a buttonbox, featuring
+ Helper function to fill and hbox with a buttonbox, featuring
and ok and cancel buttons.
@param hbox: the gtk.HBox to fill
@@ -170,7 +169,7 @@
backend = BackendFactory().get_backend(backend_name)
self.label_description.set_markup(backend.Backend.get_description())
- label = _('Syncing is <span color="red">disabled</span>')
+ #label = _('Syncing is <span color="red">disabled</span>')
markup = '<big><big><big><b>%s</b></big></big></big>' % \
backend.Backend.get_human_default_name()
self.label_name.set_markup(markup)
=== modified file 'GTG/gtk/backends_dialog/backendscombo.py'
--- GTG/gtk/backends_dialog/backendscombo.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/backends_dialog/backendscombo.py 2012-08-15 14:40:32 +0000
@@ -22,18 +22,17 @@
from GTG.backends import BackendFactory
-
class BackendsCombo(gtk.ComboBoxEntry):
'''
A combobox listing all the available backends types
'''
-
+
COLUMN_NAME = 0 #unique name for the backend type. It's never
# displayed, it's used to find which backend has
# been selected
COLUMN_HUMAN_NAME = 1 #human friendly name (which is localized).
- COLUMN_ICON = 2
+ COLUMN_ICON = 2
def __init__(self, backends_dialog):
'''
=== modified file 'GTG/gtk/backends_dialog/configurepanel.py'
--- GTG/gtk/backends_dialog/configurepanel.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/backends_dialog/configurepanel.py 2012-08-15 14:40:32 +0000
@@ -19,15 +19,15 @@
import gtk
-from GTG.gtk.colors import get_colored_tags_markup
-from GTG import _, ngettext
-from GTG.backends.genericbackend import GenericBackend
+#from GTG.gtk.colors import get_colored_tags_markup
+from GTG import _#,ngettext
+#from GTG.backends.genericbackend import GenericBackend
from GTG.gtk.backends_dialog.parameters_ui import ParametersUI
from GTG.backends.backendsignals import BackendSignals
class ConfigurePanel(gtk.VBox):
- '''
+ '''
A VBox that lets you configure a backend
'''
@@ -56,7 +56,7 @@
self.refresh_sync_status)
_signals.connect(_signals.BACKEND_SYNC_STARTED, self.on_sync_started)
_signals.connect(_signals.BACKEND_SYNC_ENDED, self.on_sync_ended)
-
+
def _create_widgets(self):
'''
This function fills this Vbox with widgets
@@ -83,7 +83,7 @@
"""
self.image_icon = gtk.Image()
self.image_icon.set_size_request(48, 48)
- hbox_top = gtk.HBox()
+ #hbox_top = gtk.HBox()
self.human_name_label = gtk.Label()
self.human_name_label.set_alignment(xalign = 0, yalign = 0.5)
@@ -118,7 +118,7 @@
def set_backend(self, backend_id):
'''Changes the backend to configure, refreshing this view.
-
+
@param backend_id: the id of the backend to configure
'''
self.backend = self.dialog.get_requester().get_backend(backend_id)
@@ -139,7 +139,7 @@
markup = "<big><big><big><b>%s</b></big></big></big>" % \
self.backend.get_human_name()
self.human_name_label.set_markup(markup)
-
+
def refresh_sync_button(self):
'''
Refreshes the state of the button that enables the backend
@@ -173,7 +173,7 @@
'''
self.refresh_sync_button()
self.refresh_sync_status_label()
-
+
def on_sync_button_clicked(self, sender):
'''
Signal callback when a backend is enabled/disabled via the UI button
@@ -222,7 +222,7 @@
'''
Enables/disables the gtk.Spinner, while showing/hiding it at the same
time
-
+
@param active: True if the spinner should spin
'''
self.should_spinner_be_shown = active
=== 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-08-15 14:40:32 +0000
@@ -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":
@@ -101,7 +101,7 @@
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,10 +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)
=== modified file 'GTG/gtk/browser/__init__.py'
--- GTG/gtk/browser/__init__.py 2012-08-08 14:56:18 +0000
+++ GTG/gtk/browser/__init__.py 2012-08-15 14:40:32 +0000
@@ -29,24 +29,26 @@
class GnomeConfig:
current_rep = os.path.dirname(os.path.abspath(__file__))
- GLADE_FILE = os.path.join(current_rep, "taskbrowser.glade")
- MODIFYTAGS_GLADE_FILE = os.path.join(current_rep, "modifytags_dialog.glade")
- TAGEDITOR_GLADE_FILE = os.path.join(current_rep, "tageditor.glade")
+ GLADE_FILE = os.path.join(current_rep, "taskbrowser.glade")
+ MODIFYTAGS_GLADE_FILE = os.path.join(current_rep,
+ "modifytags_dialog.glade")
+ TAGEDITOR_GLADE_FILE = os.path.join(current_rep, "tageditor.glade")
- MARK_DONE = _("Mark as Done")
- MARK_DONE_TOOLTIP = _("Mark the selected task as done")
- MARK_UNDONE = _("Mark as not Done")
- MARK_UNDONE_TOOLTIP = _("Mark the selected task as to be done")
- MARK_DISMISS = _("Dismiss")
- MARK_DISMISS_TOOLTIP = _("Mark the task as not to be done anymore")
- MARK_UNDISMISS = _("Undismiss")
- MARK_UNDISMISS_TOOLTIP = _("Mark the selected task as to be done")
- DELETE_TOOLTIP = _("Permanently remove the selected task")
- EDIT_TOOLTIP = _("Edit the selected task")
- NEW_TASK_TOOLTIP = _("Create a new task")
- NEW_SUBTASK_TOOLTIP = _("Create a new subtask")
+ MARK_DONE = _("Mark as Done")
+ MARK_DONE_TOOLTIP = _("Mark the selected task as done")
+ MARK_UNDONE = _("Mark as not Done")
+ MARK_UNDONE_TOOLTIP = _("Mark the selected task as to be done")
+ MARK_DISMISS = _("Dismiss")
+ MARK_DISMISS_TOOLTIP = _("Mark the task as not to be done anymore")
+ MARK_UNDISMISS = _("Undismiss")
+ MARK_UNDISMISS_TOOLTIP = _("Mark the selected task as to be done")
+ DELETE_TOOLTIP = _("Permanently remove the selected task")
+ EDIT_TOOLTIP = _("Edit the selected task")
+ NEW_TASK_TOOLTIP = _("Create a new task")
+ NEW_SUBTASK_TOOLTIP = _("Create a new subtask")
WORKVIEW_TOGGLE_TOOLTIP = _("Display only the currently actionable tasks")
- TAG_IN_WORKVIEW_TOGG = _("Hide this tag from the workview")
+ TAG_IN_WORKVIEW_TOGG = _("Hide this tag from the workview")
TAG_NOTIN_WORKVIEW_TOGG = _("Show this tag in the workview")
- QUICKADD_ENTRY_TOOLTIP = _("You can create, open or filter your tasks here")
- QUICKADD_ICON_TOOLTIP = _("Clear")
+ QUICKADD_ENTRY_TOOLTIP = _(
+ "You can create, open or filter your tasks here")
+ QUICKADD_ICON_TOOLTIP = _("Clear")
=== modified file 'GTG/gtk/browser/browser.py'
--- GTG/gtk/browser/browser.py 2012-08-12 23:01:10 +0000
+++ GTG/gtk/browser/browser.py 2012-08-15 14:40:32 +0000
@@ -48,8 +48,6 @@
#=== MAIN CLASS ===============================================================
-
-
class Timer:
def __init__(self, name):
@@ -405,7 +403,7 @@
### HELPER FUNCTIONS ########################################################
def open_preferences(self, widget):
self.vmanager.open_preferences(self.config)
-
+
def open_plugins(self, widget):
self.vmanager.configure_plugins()
=== modified file 'GTG/gtk/browser/custominfobar.py'
--- GTG/gtk/browser/custominfobar.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/browser/custominfobar.py 2012-08-15 14:40:32 +0000
@@ -25,7 +25,6 @@
from GTG.tools.networkmanager import is_connection_up
-
class CustomInfoBar(gtk.InfoBar):
'''
A gtk.InfoBar specialized for displaying errors and requests for
@@ -33,9 +32,10 @@
'''
- AUTHENTICATION_MESSAGE = _("The <b>%s</b> synchronization service cannot login with the "
- "supplied authentication data and has been"
- " disabled. To retry the login, re-enable the service.")
+ AUTHENTICATION_MESSAGE = _("The <b>%s</b> synchronization service cannot "
+ "login with the supplied authentication data "
+ "and has been disabled. To retry the login, "
+ "and has been")
NETWORK_MESSAGE = _("Due to a network problem, I cannot contact "
"the <b>%s</b> synchronization service.")
@@ -92,8 +92,8 @@
'''
Sets this infobar to show an error to the user
- @param error_code: the code of the error to show. Error codes are listed
- in BackendSignals
+ @param error_code: the code of the error to show. Error codes are
+ listed in BackendSignals
'''
self._populate()
self.connect("response", self._on_error_response)
@@ -102,7 +102,8 @@
if error_code == BackendSignals.ERRNO_AUTHENTICATION:
self.set_message_type(gtk.MESSAGE_ERROR)
self.label.set_markup(self.AUTHENTICATION_MESSAGE % backend_name)
- self.add_button(_('Configure synchronization service'), gtk.RESPONSE_ACCEPT)
+ self.add_button(_('Configure synchronization service'),
+ gtk.RESPONSE_ACCEPT)
self.add_button(_('Ignore'), gtk.RESPONSE_CLOSE)
elif error_code == BackendSignals.ERRNO_NETWORK:
@@ -112,7 +113,7 @@
self.label.set_markup(self.NETWORK_MESSAGE % backend_name)
#FIXME: use gtk stock button instead
self.add_button(_('Ok'), gtk.RESPONSE_CLOSE)
-
+
elif error_code == BackendSignals.ERRNO_DBUS:
self.set_message_type(gtk.MESSAGE_WARNING)
self.label.set_markup(self.DBUS_MESSAGE % backend_name)
@@ -206,5 +207,5 @@
'''
text = self.text_box.get_text()
self.dialog.destroy()
- threading.Thread(target = getattr(self.backend, self.callback),
+ threading.Thread(target = getattr(self.backend, self.callback),
args = ("set_text", text)).start()
=== modified file 'GTG/gtk/browser/modifytags_dialog.py'
--- GTG/gtk/browser/modifytags_dialog.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/browser/modifytags_dialog.py 2012-08-15 14:40:32 +0000
@@ -80,8 +80,7 @@
# FIXME: Python not reinitialize the default value of its
# parameter therefore it must be done manually. This function
# should be refractored # as far it is marked as depricated
- for subtask in task.get_self_and_all_subtasks(tasks=[]):
- subtask_id = subtask.get_id()
+ for subtask_id in task.children:
if subtask_id not in self.tasks:
self.tasks.append(subtask_id)
=== modified file 'GTG/gtk/browser/simple_color_selector.py'
--- GTG/gtk/browser/simple_color_selector.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/browser/simple_color_selector.py 2012-08-15 14:40:32 +0000
@@ -40,10 +40,12 @@
"#CE5C00", "#C4A000", "#BABDB6", "#2E3436",
]
-BUTTON_WIDTH = 36
+BUTTON_WIDTH = 36
BUTTON_HEIGHT = 24
-class SimpleColorSelectorPaletteItem(gtk.DrawingArea): # pylint: disable-msg=R0904,C0301
+
+class SimpleColorSelectorPaletteItem(gtk.DrawingArea):
+# pylint: disable-msg=R0904,C0301
"""An item of the color selecctor palette"""
def __init__(self, color=None):
@@ -61,7 +63,7 @@
alloc = self.get_allocation()
alloc_w, alloc_h = alloc[2], alloc[3]
# Drawing context
- cr_ctxt = self.window.cairo_create() # pylint: disable-msg=E1101
+ cr_ctxt = self.window.cairo_create() # pylint: disable-msg=E1101
gdkcontext = gtk.gdk.CairoContext(cr_ctxt)
# Draw rectangle
@@ -93,13 +95,12 @@
gdkcontext.stroke()
gdkcontext.set_source_rgba(0, 0, 0, 0.50)
gdkcontext.set_line_width(3.0)
- gdkcontext.move_to(pos_x , pos_y+size/2)
+ gdkcontext.move_to(pos_x, pos_y+size/2)
gdkcontext.line_to(pos_x+size/2, pos_y+size)
- gdkcontext.line_to(pos_x+size , pos_y)
+ gdkcontext.line_to(pos_x+size, pos_y)
gdkcontext.stroke()
### callbacks ###
-
def on_expose(self, widget, params): # pylint: disable-msg=W0613
"""Callback: redraws the widget when it is exposed"""
self.__draw()
@@ -109,7 +110,6 @@
self.__draw()
### PUBLIC IF ###
-
def set_color(self, color):
"""Defines the widget color"""
self.color = color
@@ -125,8 +125,8 @@
class SimpleColorSelector(gtk.VBox): # pylint: disable-msg=R0904,C0301
- """Widget displaying a palette of colors, possibly with a button allowing to
- define new colors."""
+ """Widget displaying a palette of colors, possibly with a button allowing
+ to define new colors."""
def __init__(self, width=9, colors=None, custom_colors=None):
gtk.VBox.__init__(self)
@@ -281,7 +281,6 @@
color_dialog.destroy()
# public IF
-
def has_color(self, col):
"""Returns True if the color is already present"""
return col in self.colors or col in self.custom_colors
=== 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-08-15 14:40:32 +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"""
@@ -67,14 +68,12 @@
self.show_all()
### PUBLIC API ###
-
def set_tag(self, tag):
"""Update the context menu items using the tag attributes."""
self.tag = tag
self.__build_menu()
### 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/tag_editor.py'
--- GTG/gtk/browser/tag_editor.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/browser/tag_editor.py 2012-08-15 14:40:32 +0000
@@ -267,12 +267,6 @@
self.tc_cc_colsel.connect('color-added', self.on_tc_colsel_added)
self.connect('delete-event', self.on_close)
- # allow fast closing by Escape key
- agr = gtk.AccelGroup()
- self.add_accel_group(agr)
- key, modifier = gtk.accelerator_parse('Escape')
- agr.connect_group(key, modifier, gtk.ACCEL_VISIBLE, self.on_close)
-
def __set_default_values(self):
"""Configure the widget components with their initial default values"""
# Disable some handlers while setting up the widget to avoid
@@ -313,7 +307,7 @@
for i in self.ti_bt:
self.ti_bt.remove(i)
ti_bt_img = gtk.image_new_from_icon_name(icon,
- gtk.ICON_SIZE_BUTTON)
+ gtk.ICON_SIZE_BUTTON)
ti_bt_img.show()
self.ti_bt.add(ti_bt_img)
else:
@@ -324,8 +318,8 @@
### PUBLIC API ###
def set_tag(self, tag):
"""Update the context menu items using the tag attributes."""
- # set_active emit the 'toggle' signal, so we have to disable
- # the handler when we update programmatically
+ # set_active emit the 'toggle' signal, so we have to disable the
+ # handler when we update programmatically
self.__set_default_values()
if tag is None:
self.tag = None
@@ -402,7 +396,7 @@
self.tag_icon_selector.set_remove_enabled(False)
def on_tn_entry_changed(self, widget): # pylint: disable-msg=W0613
- """ Callback: checks tag name validity and start value changes
+ """Callback: checks tag name validity and start value changes
monitoring to decide when to update a tag's name."""
self.tn_entry_last_recorded_value = self.tn_entry.get_text()
# check validity
@@ -444,12 +438,7 @@
self.config.set_lst("custom_colors", [s for s in self.custom_colors])
self.req.save_config()
- def on_close(self, widget, event, arg1=None, arg2=None, arg3=None):
- # pylint: disable-msg=W0613,R0913
- """ Callback: hide the tag editor when the close the window.
-
- Arguments arg1-arg3 are needed to satisfy callback when closing
- by Escape
- """
+ def on_close(self, widget, event): # pylint: disable-msg=W0613
+ """Callback: hide the tag editor when the close the window."""
self.vmanager.close_tag_editor()
return True
=== modified file 'GTG/gtk/browser/treeview_factory.py'
--- GTG/gtk/browser/treeview_factory.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/browser/treeview_factory.py 2012-08-15 14:40:32 +0000
@@ -29,8 +29,7 @@
from GTG.gtk.browser.CellRendererTags import CellRendererTags
from liblarch_gtk import TreeView
from GTG.gtk import colors
-from GTG.tools.dates import Date
-
+#from GTG.tools.dates import Date
class AutoExpandTreeView(TreeView):
"""TreeView which hide the expander column when not needed"""
@@ -38,7 +37,8 @@
def __init__(self, tree, desc):
TreeView.__init__(self, tree, desc)
self.show_expander = False
- self.treemodel.connect("row-has-child-toggled", self.__show_expander_col)
+ self.treemodel.connect("row-has-child-toggled",
+ self.__show_expander_col)
self.__show_expander_col(self.treemodel, None, None)
def __has_child(self, model, path, iter):
@@ -51,16 +51,17 @@
treemodel.foreach(self.__has_child)
self.set_show_expanders(self.show_expander)
+
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"
@@ -69,12 +70,11 @@
# 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
@@ -84,35 +84,36 @@
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)
for search_tag in search_parent.get_children():
tag = self.req.get_tag(search_tag)
- match = search_filter(node, parse_search_query(tag.get_attribute('query')))
+ match = search_filter(node,
+ parse_search_query(tag.get_attribute('query')))
if match and search_tag not in tags:
tags.append(tag)
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()
@@ -120,11 +121,12 @@
str_format = "<b>%s</b>"
if self._has_hidden_subtask(node):
str_format = "<span color='%s'>%s</span>"\
- % (self.unactive_color, str_format)
+ % (self.unactive_color, str_format)
title = str_format % saxutils.escape(node.get_title())
if node.get_status() == Task.STA_ACTIVE:
- count = self.mainview.node_n_children(node.get_id(), recursive=True)
+ count = self.mainview.node_n_children(node.get_id(),
+ recursive=True)
if count != 0:
title += " (%s)" % count
elif node.get_status() == Task.STA_DISMISSED:
@@ -134,35 +136,35 @@
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):
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
@@ -179,39 +181,40 @@
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:]
@@ -220,18 +223,19 @@
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())
@@ -246,8 +250,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)
@@ -259,7 +263,7 @@
############################################
######## The Factory #######################
############################################
- def tags_treeview(self,tree):
+ def tags_treeview(self, tree):
desc = {}
#Tag id
@@ -271,32 +275,36 @@
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]
+ # Allow renaming
+ # FIXME Is there any way how to disable renaming for certain tags?
+ render_text.set_property('editable', True)
+ render_text.connect("edited", self.on_rename_tag)
+ 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 = {}
@@ -304,8 +312,8 @@
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
@@ -313,13 +321,25 @@
self.enable_update_tags()
- return self.build_tag_treeview(tree,desc)
+ return self.build_tag_treeview(tree, desc)
+
+ def on_rename_tag(self, renderer, path, new_name):
+ model = self.tags_view.get_model()
+ my_iter = model.get_iter(path)
+ tag_id = model.get_value(my_iter, 0)
+ tag = self.req.get_tag(tag_id)
+
+ if tag.is_search_tag():
+ self.req.rename_tag(tag_id, new_name)
+ else:
+ print "FIXME: renaming tags is not implemented"
def enable_update_tags(self):
self.tag_cllbcks = []
tasks = self.req.get_tasks_tree()
- for event in 'node-added-inview', 'node-modified-inview', 'node-deleted-inview':
+ for event in ['node-added-inview', 'node-modified-inview',
+ 'node-deleted-inview']:
handle = tasks.register_cllbck(event, self._update_tags)
self.tag_cllbcks.append((event, handle))
@@ -342,18 +362,18 @@
if task:
for t in self.req.get_task(node_id).get_tags():
tree.refresh_node(t.get_name())
-
- def active_tasks_treeview(self,tree):
+
+ 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
@@ -364,40 +384,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
@@ -421,20 +441,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
@@ -446,18 +466,17 @@
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 = AutoExpandTreeView(tree,desc)
+
+ def build_task_treeview(self, tree, desc):
+ treeview = AutoExpandTreeView(tree, desc)
#Now that the treeview is done, we can polish
treeview.set_main_search_column('label')
treeview.set_expander_column('label')
@@ -472,19 +491,19 @@
self.unactive_color = \
treeview.style.text[gtk.STATE_INSENSITIVE].to_string()
return treeview
-
- def build_tag_treeview(self,tree,desc):
- treeview = AutoExpandTreeView(tree,desc)
+
+ def build_tag_treeview(self, tree, desc):
+ treeview = AutoExpandTreeView(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/editor/__init__.py'
--- GTG/gtk/editor/__init__.py 2012-05-23 08:55:31 +0000
+++ GTG/gtk/editor/__init__.py 2012-08-15 14:40:32 +0000
@@ -26,7 +26,7 @@
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-08 14:56:18 +0000
+++ GTG/gtk/editor/editor.py 2012-08-15 14:40:32 +0000
@@ -21,7 +21,7 @@
It's the window you see when you double-click on a Task
The main text widget is a home-made TextView called TaskView (see taskview.py)
-The rest is the logic of the widget: date changing widgets, buttons, ...
+The rest is the logic of the widget : date changing widgets, buttons, ...
"""
import time
@@ -29,7 +29,7 @@
import gtk
from GTG import _, ngettext
-from GTG.gtk.editor import GnomeConfig
+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
@@ -37,12 +37,13 @@
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])
+ 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
+ #print "size %s - %s" %(str(size[0]),str(size[1]))
+ #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(
+ GnomeConfig.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,29 +273,19 @@
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
startdate = self.task.get_start_date()
- try:
- prevdate = Date.parse(self.startdate_widget.get_text())
- update_date = startdate != prevdate
- except ValueError:
- update_date = True
-
- if update_date:
- self.startdate_widget.set_text(str(startdate))
+ prevdate = Date.parse(self.startdate_widget.get_text())
+ if startdate != prevdate:
+ self.startdate_widget.set_text(str(startdate))
#refreshing the due date field
duedate = self.task.get_due_date()
- try:
- prevdate = Date.parse(self.duedate_widget.get_text())
- update_date = duedate != prevdate
- except ValueError:
- update_date = True
-
- if update_date:
+ prevdate = Date.parse(self.duedate_widget.get_text())
+ if duedate != prevdate:
self.duedate_widget.set_text(str(duedate))
# refreshing the closed date field
@@ -297,8 +295,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 +305,28 @@
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 +352,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:
@@ -371,6 +375,13 @@
self.task.set_due_date(datetoset)
elif data == "closed":
self.task.set_closed_date(datetoset)
+
+ # Set the due date to be equal to the start date
+ # when it happens that the start date is later than the due date
+ start_date = self.task.get_start_date()
+ due_date = self.task.get_due_date()
+ if start_date and (start_date > due_date):
+ self.task.set_due_date(self.task.get_start_date())
else:
#We should write in red in the entry if the date is not valid
widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("#F00"))
@@ -380,6 +391,11 @@
"""Called when a date-changing button is clicked."""
if date_kind == GTGCalendar.DATE_KIND_DUE:
date = self.task.get_due_date()
+ start_date = self.task.get_start_date()
+ due_before_start = start_date and start_date > date
+
+ if not date or due_before_start:
+ date = self.task.get_start_date()
elif date_kind == GTGCalendar.DATE_KIND_START:
date = self.task.get_start_date()
elif date_kind == GTGCalendar.DATE_KIND_CLOSED:
@@ -405,7 +421,8 @@
all_subtasks = []
def trace_subtasks(root):
- for i in root.get_subtasks():
+ for i_id in root.children:
+ i = self.req.get_task(i_id)
if i not in all_subtasks:
all_subtasks.append(i)
trace_subtasks(i)
@@ -415,7 +432,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")
@@ -425,7 +442,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")
@@ -444,7 +461,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:
@@ -459,25 +476,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()
@@ -496,22 +513,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()
@@ -522,17 +539,18 @@
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
- #To solve that, close will just call "destroy" and the destroy signal
+ #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)
@@ -541,7 +559,8 @@
self.req.delete_task(tid)
else:
self.save()
- for i in self.task.get_subtasks():
+ for i_id in self.task.children:
+ i = self.req.get_task(i_id)
if i:
i.set_to_keep()
self.vmanager.close_task(tid)
=== modified file 'GTG/gtk/editor/taskview.py'
--- GTG/gtk/editor/taskview.py 2012-07-13 17:24:28 +0000
+++ GTG/gtk/editor/taskview.py 2012-08-15 14:40:32 +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 = '←'
@@ -83,7 +81,8 @@
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
@@ -94,11 +93,11 @@
self.failedlink = {'background': 'white', 'foreground': '#ff5454', \
'underline': pango.UNDERLINE_NONE, \
'strikethrough': False}
- self.done = {'background': 'white', 'foreground': 'gray',\
+ self.done = {'background': 'white', 'foreground': 'gray',\
'strikethrough': True}
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)
@@ -129,9 +128,10 @@
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
+ tag = b.create_tag(None, **self.get_property(linktype))
+ #pylint: disable-msg=W0142
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
+ texttag = buff.create_tag(None, **self.get_property('tag'))
+ #pylint: disable-msg=W0142
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
+ tag = buff.create_tag(None, **self.get_property('indent'))
+ #pylint: disable-msg=W0142
tag.set_data('is_indent', True)
tag.set_data('indent_level', level)
return tag
@@ -409,10 +416,10 @@
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():
@@ -434,7 +441,7 @@
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,7 +497,7 @@
stripped = title.strip(' \n\t')
return stripped
-### PRIVATE FUNCTIONS ##########################################################
+### PRIVATE FUNCTIONS #######################################################
#This function is called so frequently that we should optimize it more.
@@ -538,6 +545,7 @@
#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)
@@ -583,6 +591,7 @@
#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)
@@ -606,7 +615,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)
@@ -624,11 +634,14 @@
if url.startswith("bug #") or url.startswith("lp #"):
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,\
topoint, text=None, typ="http")
@@ -659,29 +672,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 +722,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 +734,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 +784,8 @@
# 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 +815,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 +825,17 @@
# 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
+ #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
+ 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 +847,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 +865,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 +892,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 +903,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 +922,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 +954,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 +964,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 +995,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 +1012,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 +1025,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 +1044,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 +1062,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 +1121,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 +1173,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")
+ 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 +1211,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 +1246,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 +1254,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)
@@ -1284,7 +1311,6 @@
#newiter = self.buff.get_iter_at_mark(tempm)
#self.buff.delete_mark(tempm)
#self.insert_indent(self.buff, newiter, newlevel, enter=False)
-
def backspace(self, tv):
self.buff.disconnect(self.insert_sigid)
insert_mark = self.buff.get_insert()
@@ -1319,7 +1345,8 @@
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):
+ #pylint: disable-msg=W0613
_type = ev.type
if _type == gtk.gdk.MOTION_NOTIFY:
return
@@ -1330,14 +1357,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 \
+ self.buff.get_has_selection() == False:
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 +1381,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-08-15 14:40:32 +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: