GTG

Merge lp:~atit-anand-cs/gtg/random_tag_color into lp:~gtg/gtg/old-trunk

Proposed by Atit Anand
Status: Merged
Merged at revision: 1356
Proposed branch: lp:~atit-anand-cs/gtg/random_tag_color
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 155 lines (+50/-2)
6 files modified
AUTHORS (+1/-0)
CHANGELOG (+1/-0)
GTG/gtk/browser/CellRendererTags.py (+0/-1)
GTG/gtk/browser/tag_context_menu.py (+13/-1)
GTG/gtk/browser/tag_editor.py (+5/-0)
GTG/gtk/colors.py (+30/-0)
To merge this branch: bzr merge lp:~atit-anand-cs/gtg/random_tag_color
Reviewer Review Type Date Requested Status
Nimit Shah Approve
Review via email: mp+208450@code.launchpad.net

Description of the change

Fix for the bug #644993. Automatic generation of tag color

To post a comment you must log in.
Revision history for this message
Nimit Shah (nimit-svnit) wrote :
Download full text (8.1 KiB)

On Wed, Feb 26, 2014 at 11:54 PM, Atit Anand <email address hidden>wrote:

> Atit Anand has proposed merging lp:~atit-anand-cs/gtg/random_tag_color
> into lp:gtg.
>
> Requested reviews:
> Gtg developers (gtg)
>
> For more details, see:
>
> https://code.launchpad.net/~atit-anand-cs/gtg/random_tag_color/+merge/208450
>
> Fix for the bug #644993. Automatic generation of tag color
> --
>
> https://code.launchpad.net/~atit-anand-cs/gtg/random_tag_color/+merge/208450
> Your team Gtg developers is requested to review the proposed merge of
> lp:~atit-anand-cs/gtg/random_tag_color into lp:gtg.
>
> === modified file 'AUTHORS'
> --- AUTHORS 2014-02-25 18:19:31 +0000
> +++ AUTHORS 2014-02-26 18:23:44 +0000
> @@ -131,3 +131,5 @@
> * Pawan Hegde <email address hidden>
> * Sagar Ghuge <email address hidden>
> * Sushant Raikar <email address hidden>
> +* Atit Anand <email address hidden>
> +
>
> Remove the extra blank line

> === modified file 'CHANGELOG'
> --- CHANGELOG 2014-02-25 18:38:16 +0000
> +++ CHANGELOG 2014-02-26 18:23:44 +0000
> @@ -14,6 +14,8 @@
> * Fix for bug #1248185: due label in task editor says "Due for"
> should say "Due on", by Pawan Hegde
> * Fix for bug #1282955: Clicking out side the calender widget should
> close the widget by Sagar Ghuge
> * Fix for bug #1033268: Mouseover String Incorrect, by Sushant Raikar
> + * Fix for bug #644993 : Automatic generation of tag color, by Atit
> Anand
> +
>

Remove the extra blank line

>
> 2013-11-24 Getting Things GNOME! 0.3.1
> * Fix for bug #1024473: Have 'Show Main Window' in notification area,
> by Antonio Roquentin
> @@ -43,7 +45,7 @@
> * Fix for bug #1242384: send-email: toolbar item is not removed from
> an opened task, by Fabiano Fidencio
> * Fix for bug #1029342: Give an option to remove tag color, by kpytang
> * Fixed Hamster Plugin: bugs #487582, #487585, #1236066, #1242083 and
> #1242279, by Parin Porecha
> -
> +
>

You seem to have modified an empty line (modified the number of spaces).
Correct it.

 2012-11-06 Getting Things GNOME! 0.3
> * Hide tasks with due date someday, #931376
> * New Date class by Paul Kishimoto and Izidor Matušov
>
> === modified file 'GTG/gtk/browser/CellRendererTags.py'
> --- GTG/gtk/browser/CellRendererTags.py 2013-11-25 02:37:46 +0000
> +++ GTG/gtk/browser/CellRendererTags.py 2014-02-26 18:23:44 +0000
> @@ -61,7 +61,6 @@
> def __count_viewable_tags(self):
>
> count = 0
> -
>
         if self.tag_list is not None:
> for my_tag in self.tag_list:
> my_tag_color = my_tag.get_attribute("color")
>
> === modified file 'GTG/gtk/browser/tag_context_menu.py'
> --- GTG/gtk/browser/tag_context_menu.py 2013-11-25 02:37:46 +0000
> +++ GTG/gtk/browser/tag_context_menu.py 2014-02-26 18:23:44 +0000
> @@ -27,7 +27,7 @@
> """
>
> from gi.repository import Gtk
> -
> +from GTG.gtk.colors import generate_tag_color, color_add, color_remove
> from GTG import _
>
>
> @@ -53,8 +53,12 @@
> # Color chooser FIXME: SHOULD BECOME A COLOR PICKER
> self.mi_cc = Gtk.MenuItem()
> self.mi_cc.set_label(_("Edit Tag..."))
> + se...

Read more...

Revision history for this message
Nimit Shah (nimit-svnit) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AUTHORS'
2--- AUTHORS 2014-02-25 18:19:31 +0000
3+++ AUTHORS 2014-02-26 19:01:27 +0000
4@@ -131,3 +131,4 @@
5 * Pawan Hegde <h.pawan@gmail.com>
6 * Sagar Ghuge <ghugesss@gmail.com>
7 * Sushant Raikar <sushantthecoder@gmail.com>
8+* Atit Anand <atit.anand.cs@gmail.com>
9
10=== modified file 'CHANGELOG'
11--- CHANGELOG 2014-02-25 18:38:16 +0000
12+++ CHANGELOG 2014-02-26 19:01:27 +0000
13@@ -14,6 +14,7 @@
14 * Fix for bug #1248185: due label in task editor says "Due for" should say "Due on", by Pawan Hegde
15 * Fix for bug #1282955: Clicking out side the calender widget should close the widget by Sagar Ghuge
16 * Fix for bug #1033268: Mouseover String Incorrect, by Sushant Raikar
17+ * Fix for bug #644993 : Automatic generation of tag color, by Atit Anand
18
19 2013-11-24 Getting Things GNOME! 0.3.1
20 * Fix for bug #1024473: Have 'Show Main Window' in notification area, by Antonio Roquentin
21
22=== modified file 'GTG/gtk/browser/CellRendererTags.py'
23--- GTG/gtk/browser/CellRendererTags.py 2013-11-25 02:37:46 +0000
24+++ GTG/gtk/browser/CellRendererTags.py 2014-02-26 19:01:27 +0000
25@@ -61,7 +61,6 @@
26 def __count_viewable_tags(self):
27
28 count = 0
29-
30 if self.tag_list is not None:
31 for my_tag in self.tag_list:
32 my_tag_color = my_tag.get_attribute("color")
33
34=== modified file 'GTG/gtk/browser/tag_context_menu.py'
35--- GTG/gtk/browser/tag_context_menu.py 2013-11-25 02:37:46 +0000
36+++ GTG/gtk/browser/tag_context_menu.py 2014-02-26 19:01:27 +0000
37@@ -27,7 +27,7 @@
38 """
39
40 from gi.repository import Gtk
41-
42+from GTG.gtk.colors import generate_tag_color, color_add, color_remove
43 from GTG import _
44
45
46@@ -53,8 +53,12 @@
47 # Color chooser FIXME: SHOULD BECOME A COLOR PICKER
48 self.mi_cc = Gtk.MenuItem()
49 self.mi_cc.set_label(_("Edit Tag..."))
50+ self.mi_ctag = Gtk.MenuItem()
51+ self.mi_ctag.set_label(_("Generate Color"))
52 self.append(self.mi_cc)
53+ self.append(self.mi_ctag)
54 self.mi_cc.connect('activate', self.on_mi_cc_activate)
55+ self.mi_ctag.connect('activate', self.on_mi_ctag_activate)
56 if self.tag.is_search_tag():
57 self.mi_del = Gtk.MenuItem()
58 self.mi_del.set_label(_("Delete"))
59@@ -74,6 +78,14 @@
60 """Callback: show the tag editor upon request"""
61 self.vmanager.open_tag_editor(self.tag)
62
63+ def on_mi_ctag_activate(self, widget):
64+ random_color = generate_tag_color()
65+ present_color = self.tag.get_attribute('color')
66+ if(present_color is not None):
67+ color_remove(present_color)
68+ self.tag.set_attribute('color', random_color)
69+ color_add(random_color)
70+
71 def on_mi_del_activate(self, widget):
72 """ delete a selected search """
73 self.req.remove_tag(self.tag.get_name())
74
75=== modified file 'GTG/gtk/browser/tag_editor.py'
76--- GTG/gtk/browser/tag_editor.py 2014-01-15 10:40:09 +0000
77+++ GTG/gtk/browser/tag_editor.py 2014-02-26 19:01:27 +0000
78@@ -32,6 +32,7 @@
79 from GTG import _
80 from GTG.gtk.browser.simple_color_selector import SimpleColorSelector
81 from GTG.tools.logger import Log
82+from GTG.gtk.colors import color_add, color_remove
83
84
85 class TagIconSelector(Gtk.Window):
86@@ -471,8 +472,12 @@
87 color = self.tc_cc_colsel.get_selected_color()
88 if self.tag is not None:
89 if color is not None:
90+ my_color = Gdk.color_parse(color)
91+ color = Gdk.Color(my_color.red, my_color.green, my_color.blue).to_string()
92+ color_add(color)
93 self.tag.set_attribute('color', color)
94 else:
95+ color_remove(self.tag.get_attribute('color'))
96 self.tag.del_attribute('color')
97
98 def on_tc_colsel_activated(self, widget, color):
99
100=== modified file 'GTG/gtk/colors.py'
101--- GTG/gtk/colors.py 2013-11-25 02:37:46 +0000
102+++ GTG/gtk/colors.py 2014-02-26 19:01:27 +0000
103@@ -19,10 +19,12 @@
104
105 from gi.repository import Gdk
106 from functools import reduce
107+import random
108
109 # Take list of Tags and give the background color that should be applied
110 # The returned color might be None (in which case, the default is used)
111
112+used_color = []
113
114 def background_color(tags, bgcolor=None):
115 if not bgcolor:
116@@ -35,6 +37,8 @@
117 blue = 0
118 for my_tag in tags:
119 my_color_str = my_tag.get_attribute("color")
120+ if my_color_str is not None and my_color_str not in used_color:
121+ used_color.append(my_color_str)
122 if my_color_str:
123 my_color = Gdk.color_parse(my_color_str)
124 color_count = color_count + 1
125@@ -90,4 +94,30 @@
126 tags_txt = reduce(lambda a, b: a + ", " + b, tag_markups)
127 return tags_txt
128
129+
130+def generate_tag_color():
131+
132+ maxvalue = 65535
133+ flag = 0
134+ while(flag == 0):
135+ red = random.randint(0, maxvalue)
136+ green = random.randint(0, maxvalue)
137+ blue = random.randint(0, maxvalue)
138+ my_color = Gdk.Color(red, green, blue).to_string()
139+ if my_color not in used_color:
140+ flag = 1
141+ used_color.append(my_color)
142+ return my_color
143+
144+
145+def color_add(present_color):
146+
147+ if present_color not in used_color:
148+ used_color.append(present_color)
149+
150+
151+def color_remove(present_color):
152+
153+ if present_color in used_color:
154+ used_color.remove(present_color)
155 # -----------------------------------------------------------------------------

Subscribers

People subscribed via source and target branches

to status/vote changes: