Merge lp:~gtg-contributors/gtg/bug495246 into lp:~gtg/gtg/old-trunk

Proposed by Joao ascenso on 2011-04-08
Status: Rejected
Rejected by: Izidor Matušov on 2012-07-13
Proposed branch: lp:~gtg-contributors/gtg/bug495246
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 222 lines (+122/-13) (has conflicts)
4 files modified
AUTHORS (+4/-0)
CHANGELOG (+1/-0)
GTG/gtk/editor/editor.py (+45/-13)
GTG/gtk/editor/taskview.py (+72/-0)
Text conflict in AUTHORS
To merge this branch: bzr merge lp:~gtg-contributors/gtg/bug495246
Reviewer Review Type Date Requested Status
Izidor Matušov code + running the code 2011-04-08 Resubmit on 2011-08-15
Review via email: mp+56881@code.launchpad.net

Description of the change

Fixed bug 495246

Changes the tag menu in the task editor for a check box menu. The bug also asked for ordered itens, but im my tests all itens were already ordered automatically.

To post a comment you must log in.
Izidor Matušov (izidor) wrote :

Hi Joao,

Nobody reviews your code so far, I'll do it now :-) It looks great and also works great for adding new tags. There are just one problem which should be fixed:

Removing tags does not work well, mostly the task has more than one instance of that tag. You probably use iterators not in the way as it was meant: (I've got this error)

/home/iyo/downloads/bug495246/GTG/gtk/editor/taskview.py:743: GtkWarning: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created.
You must use marks, character numbers, or line numbers to preserve a position across buffer modifications.
You can apply tags and insert marks without invalidating your iterators,
but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset)
will invalidate all outstanding iterators
  if start.get_offset() <= offset2 <= end.get_offset():

review: Resubmit (code + running the code)
Joao ascenso (joaoricardoascenso) wrote :

Changed the owner to gtg-contributors, fell free to change it. I did it some time ago and had some problems that are a connected to the way the editor works. Editor has some issues detecting tags in the text, Just try to write a log task with the same tag over-repeated and it only detects some instances of the tag.

With the revision of the editor, as stated by lionel, its a great time to look at it again

lp:~gtg-contributors/gtg/bug495246 updated on 2011-11-06
936. By Izidor Matušov on 2011-11-06

Updating algorithm for removing tags

Izidor Matušov (izidor) wrote :

I played with the algorithm for removing today and updated it. Now it works in two steps:

1) remove highlighted tag
2) remove other occurrences of the tag as well, although they are not highlighted (yet)

Small testing:

I have a task with lot of '@money' tag: http://is.gd/VqlNkR

And I want to remove that tag and properly I get this window: http://is.gd/7hiTd2

Please, test it and see how it will work for you.

By the way: shouldn't be all occurrences of a tag highlighted?

Joao ascenso (joaoricardoascenso) wrote :

Sorry izidor, only saw this now.

Cumprimentos

João Ascenso

2011/11/6 Izidor Matušov <email address hidden>

> I played with the algorithm for removing today and updated it. Now it
> works in two steps:
>
> 1) remove highlighted tag
> 2) remove other occurrences of the tag as well, although they are not
> highlighted (yet)
>
> Small testing:
>
> I have a task with lot of '@money' tag: http://is.gd/VqlNkR
>
> And I want to remove that tag and properly I get this window:
> http://is.gd/7hiTd2
>
> Please, test it and see how it will work for you.
>

i'll try to check it tommorow, im busy has hell because im at the last days
of a project

>
> By the way: shouldn't be all occurrences of a tag highlighted?
>

there are a few issues with the task editor, when i was adding that feature
there was someone helping me (cant remember who, sorry) he told me that the
editor had that issues and suggested in a near future to be re-visioned and
optimized. It has some issues and sometimes only tags the last occurrence
of a tag. I believe it has to do with the way it iterates thought the text
and colors it. It may be a nice thing for me to focus on the hack metting

> --
> https://code.launchpad.net/~gtg-contributors/gtg/bug495246/+merge/56881<https://code.launchpad.net/%7Egtg-contributors/gtg/bug495246/+merge/56881>
> You proposed lp:~gtg-contributors/gtg/bug495246 for merging.
>

Izidor Matušov (izidor) wrote :

There wasn't activity for almost a year, closing this merge request as REJECTED. If you want to finish your patch, feel free to reopen it.

Unmerged revisions

936. By Izidor Matušov on 2011-11-06

Updating algorithm for removing tags

935. By joaoascenso <joaoascenso@seph-mint> on 2011-04-08

commit 2

934. By joaoascenso <joaoascenso@seph-mint> on 2011-04-08

coded a fix to bug#495246 and other possible related problems

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AUTHORS'
2--- AUTHORS 2011-09-25 13:17:30 +0000
3+++ AUTHORS 2011-11-06 13:05:27 +0000
4@@ -75,6 +75,10 @@
5 * Daniel Neel <dneelyep@gmail.com>
6 * Ivan Evtukhovich <evtuhovich@gmail.com>
7 * Madhumitha Viswanathan <madhuvishy@gmail.com>
8+<<<<<<< TREE
9 * Fabio Prina <fabio@nimsh.com>
10 * François <https://launchpad.net/~unpeudescience> (no email provided)
11 * Marcos Lenharo <https://launchpad.net/~lenharo-h> (no email provided)
12+=======
13+* Joao Ascenso <joaoricardoascenso@gmail.com>
14+>>>>>>> MERGE-SOURCE
15
16=== modified file 'CHANGELOG'
17--- CHANGELOG 2011-08-12 14:11:35 +0000
18+++ CHANGELOG 2011-11-06 13:05:27 +0000
19@@ -1,4 +1,5 @@
20 ????-??-?? Getting Things GNOME! ?.?.?
21+ * Changed the tag menu list in task editing to be a list of checkboxes
22 * Fixed crash traceback when pressing 'delete' key, by Jeff Oliver
23 * Added link to web documentation in Help menu, by Ronan Jouchet
24 * Fixed bug with data consistency #579189, by Marko Kevac
25
26=== modified file 'GTG/gtk/editor/editor.py'
27--- GTG/gtk/editor/editor.py 2011-10-30 09:30:17 +0000
28+++ GTG/gtk/editor/editor.py 2011-11-06 13:05:27 +0000
29@@ -158,6 +158,9 @@
30 self.plugin_api = PluginAPI(self.req, self.vmanager, self)
31 self.pengine.register_api(self.plugin_api)
32 self.pengine.onTaskLoad(self.plugin_api)
33+
34+ #menu itens for the checkboxmenu
35+ self.menu = gtk.Menu()
36
37 #Putting the refresh callback at the end make the start a lot faster
38 self.textview.refresh_callback(self.refresh_editor)
39@@ -323,26 +326,41 @@
40 if startdate != prevdate or type(startdate) is not type(prevdate):
41 zedate = str(startdate).replace("-",date_separator)
42 self.startdate_widget.set_text(zedate)
43- #Refreshing the tag list in the insert tag button
44+ self.refresh_menu()
45+ if refreshtext:
46+ self.textview.modified(refresheditor=False)
47+ if to_save:
48+ self.light_save()
49+
50+ #Refreshing the tag Checkboxlist in the insert tag button
51+ def refresh_menu(self):
52+
53+ menu = self.menu
54+ menu = gtk.Menu()
55 taglist = self.req.get_used_tags()
56- menu = gtk.Menu()
57+ tasktaglist = self.task.get_tags()
58 tag_count = 0
59 for tagname in taglist:
60 tag_object = self.req.get_tag(tagname)
61- if not tag_object.is_special() and \
62- not self.task.has_tags(tag_list=[tagname]):
63+ if not tag_object.is_special():
64 tag_count += 1
65- mi = gtk.MenuItem(label = tagname, use_underline=False)
66- mi.connect("activate", self.inserttag, tagname)
67+ #bug#495246 change to a checkbox
68+ mi = gtk.CheckMenuItem(tagname)
69+ #if its an active tag, check the checkbox
70+ if self.task.has_tags(tag_list=[tagname]):
71+ mi.set_active(True)
72+ mi.connect("activate", self.inserttag, tagname, mi.get_active())
73+ #save the label of the button
74+ mi.set_data("label", tagname)
75 mi.show()
76 menu.append(mi)
77 if tag_count > 0 :
78 self.inserttag_button.set_menu(menu)
79-
80- if refreshtext:
81- self.textview.modified(refresheditor=False)
82- if to_save:
83- self.light_save()
84+ else:
85+ menu=gtk.Menu()
86+ #avoids a bug with the last tag allways showing, but shows an empty menu
87+ #need the oposite of self.inserttag_button.set_menu(menu)
88+ self.inserttag_button.set_menu(menu)
89
90 def date_changed(self,widget,data):
91 text = widget.get_text()
92@@ -462,9 +480,23 @@
93 else :
94 self.textview.insert_text(" @",itera)
95 self.textview.grab_focus()
96+
97
98- def inserttag(self,widget,tag) : #pylint: disable-msg=W0613
99- self.textview.insert_tags([tag])
100+ #tag - name of the tag clicked @example
101+ #state - boolean that represents the state of the checkbox
102+ #missing automatic detecting of a previous same name tag after removing
103+ #unless a tag is manualy changed, in that case it detects and adds
104+ def inserttag(self,widget,tag,state) : #pylint: disable-msg=W0613
105+
106+ #note that the boolean is inversed
107+ #if its a tag that's not active, insert it
108+ if not state:
109+ self.textview.insert_tags([tag])
110+ #if its active remove it
111+ else:
112+ self.textview.remove_tagbyname(tag)
113+
114+ self.textview.refresh_callback(self.refresh_editor)
115 self.textview.grab_focus()
116
117 def save(self) :
118
119=== modified file 'GTG/gtk/editor/taskview.py'
120--- GTG/gtk/editor/taskview.py 2011-08-26 15:20:31 +0000
121+++ GTG/gtk/editor/taskview.py 2011-11-06 13:05:27 +0000
122@@ -37,6 +37,7 @@
123
124 from GTG.gtk.editor import taskviewserial
125 from GTG.tools import openurl
126+from GTG.tools.tags import extract_tags_from_text
127
128
129 separators = [' ', '.', ',', '/', '\n', '\t', '!', '?', ';', '\0']
130@@ -608,6 +609,7 @@
131 for ta in tags :
132 #removing deleted tags
133 if ta.get_data('is_tag') :
134+
135 tagname = ta.get_data('tagname')
136 old_tags.append(tagname)
137 buff.remove_tag(ta,start,end)
138@@ -680,7 +682,12 @@
139 # we remove tags that are not in the description anymore
140 for t in old_tags :
141 if not t in new_tags :
142+ #update window to update cheklist of tags
143 self.remove_tag_callback(t)
144+ #refresh the window to update the taglistcheckbox
145+ self.refresh(self.get_title())
146+
147+
148
149 def is_at_title(self,buff,itera) :
150 to_return = False
151@@ -694,6 +701,71 @@
152 to_return = True
153 return to_return
154
155+ # Remove tag object
156+ # Have to be in a separate function because we need to break from two cycles
157+ def _remove_tagobj_byname(self, tag_to_delete):
158+ buff = self.get_buffer()
159+ it = buff.get_start_iter()
160+ table = buff.get_tag_table()
161+ while not it.is_end():
162+ if it.begins_tag():
163+ tags = it.get_toggled_tags(True)
164+ for tag in tags:
165+ if not tag.get_data('is_tag'):
166+ continue
167+
168+ tagname = tag.get_data('tagname')
169+ if tag_to_delete != tagname:
170+ continue
171+
172+ self.remove_tag_callback(tagname)
173+ buff.remove_tag(tag, buff.get_start_iter(), buff.get_end_iter())
174+ table.remove(tag)
175+
176+ #Removing the marks if they exist
177+ mark1 = buff.get_mark(tagname)
178+ temp_it = it.copy();
179+ temp_it2 = it.copy();
180+ it.forward_cursor_positions(len(tagname))
181+ if mark1 :
182+ buff.delete(temp_it,buff.get_iter_at_mark(mark1))
183+ buff.delete_mark_by_name(tagname)
184+ mark2 = buff.get_mark("/%s"%tagname)
185+ if mark2 :
186+ buff.delete(temp_it2,buff.get_iter_at_mark(mark2))
187+ buff.delete_mark_by_name("/%s"%tagname)
188+ return
189+ # Move forward
190+ it.forward_char()
191+
192+ #remove a all ocurrences of the tag in the text
193+ #used to remove the tags when you click the checkbox
194+ def remove_tagbyname(self, tag_to_delete):
195+
196+ self._remove_tagobj_byname(tag_to_delete)
197+
198+ # Remove any other text
199+ buff = self.get_buffer()
200+ changed = True
201+ while changed:
202+ changed = False
203+ it = buff.get_start_iter()
204+ while not it.is_end():
205+ if it.get_char() == '@':
206+ end_it = it.copy()
207+ end_it.forward_chars(len(tag_to_delete)+1)
208+ text = it.get_text(end_it)
209+ tags = extract_tags_from_text(text)
210+
211+ if tags[0] == tag_to_delete:
212+ # After deleting, iterators are not valid anymore
213+ # We have to start again
214+ buff.delete(it, end_it)
215+ changed = True
216+ break
217+
218+ it.forward_char()
219+
220 #When the user removes a selection, we remove subtasks and @tags
221 #from this selection
222 def _delete_range(self,buff,start,end) :

Subscribers

People subscribed via source and target branches

to status/vote changes: