← Back to team overview

gtg 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"
  https://bugs.launchpad.net/gtg/+bug/830971

For more details, see:
https://code.launchpad.net/~gtg-user/gtg/bugfix-830971/+merge/113497

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.
-- 
https://code.launchpad.net/~gtg-user/gtg/bugfix-830971/+merge/113497
Your team Gtg developers is requested to review the proposed merge of lp:~gtg-user/gtg/bugfix-830971 into lp:gtg.
=== 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 @@
             self.stop_emission("paste_clipboard")
 
         else:
-            #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)
+
             self.clipboard.clear()
 
     #Function called each time the user inputs a letter


Follow ups