← Back to team overview

gtg-user team mailing list archive

[Merge] lp:~gtg-user/gtg/bugfix-830971 into lp:gtg


Alan Gomes Alvino has proposed merging lp:~gtg-user/gtg/bugfix-830971 into lp:gtg.

Requested reviews:
  Gtg developers (gtg)
Related bugs:
  Bug #830971 in Getting Things GNOME!: "Importing dashed lines should create subtasks immediately"

For more details, see:

What i do was before the paste on paste_clipboard method i see if the lines of the external paste has one dash at beginning(even if the beginning of line has spaces). If he was a dash at beginning of line i create a subtask.
Your team Gtg users is subscribed to branch lp:~gtg-user/gtg/bugfix-830971.
=== modified file 'GTG/gtk/editor/taskview.py'
--- GTG/gtk/editor/taskview.py	2012-05-20 19:05:20 +0000
+++ GTG/gtk/editor/taskview.py	2012-07-05 07:08:28 +0000
@@ -1089,7 +1089,27 @@
-            #we keep the normal pasting by not interupting the signal
+            #Get the text of the external clipboard
+            clipboard_text = clip.wait_for_text()
+            #Separate the text in lines
+            for line_strip in clipboard_text.split('\n'):
+                #Remove whitespaces at begining of line
+                line = line_strip.lstrip(' ')
+                #If line contain a task
+                if len(line) > 0 and line[0] == '-':
+                    #we handle ourselves the pasting
+                    self.stop_emission("paste_clipboard")
+                    #Removing dash
+                    line_without_dash = line[1:]
+                    anchor = self.new_subtask_callback(line_without_dash)
+                    mark = self.buff.get_insert()
+                    line_nbr = self.buff.get_iter_at_mark(mark).get_line()
+                    #we must paste the \n before inserting the subtask
+                    #else, we will start another subtask
+                    self.buff.insert_at_cursor("\n")
+                    self.write_subtask(self.buff, line_nbr, anchor)
     #Function called each time the user inputs a letter

Follow ups