GTG

Merge lp:~kpytang/gtg/remove-tag-color into lp:~gtg/gtg/old-trunk

Proposed by kpytang
Status: Merged
Merged at revision: 1320
Proposed branch: lp:~kpytang/gtg/remove-tag-color
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 79 lines (+28/-3)
1 file modified
GTG/gtk/browser/simple_color_selector.py (+28/-3)
To merge this branch: bzr merge lp:~kpytang/gtg/remove-tag-color
Reviewer Review Type Date Requested Status
Parin Porecha Approve
Review via email: mp+192466@code.launchpad.net

Description of the change

Adds an extra button that allows user to remove tag colors. The original method required users to click on the tag color to select/unselect the color. Adding the extra button provides a more explicit way for users to clear the selected color.

To post a comment you must log in.
Revision history for this message
Parin Porecha (parinporecha) wrote :

The patch looks good to me

Thanks for your contribution, kpytang :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/gtk/browser/simple_color_selector.py'
2--- GTG/gtk/browser/simple_color_selector.py 2013-02-25 08:29:31 +0000
3+++ GTG/gtk/browser/simple_color_selector.py 2013-10-24 07:41:51 +0000
4@@ -229,13 +229,24 @@
5 cc_hbox.set_spacing(4)
6 self.cc_buttons.append(img)
7 # Draw the add button
8+ buttons_hbox = gtk.HBox()
9+ cc_vbox.pack_start(buttons_hbox)
10 img = gtk.Image()
11 img.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
12 self.add_button = gtk.Button()
13 self.add_button.set_image(img)
14 self.add_button.set_label(_("Add custom color"))
15- cc_vbox.pack_start(self.add_button, expand=True, fill=True)
16+ buttons_hbox.pack_start(self.add_button, expand=True, fill=False)
17 self.add_button.connect("clicked", self.on_color_add)
18+ # Draw the clear selected color button
19+ img = gtk.Image()
20+ img.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON)
21+ self.clear_button = gtk.Button()
22+ self.clear_button.set_image(img)
23+ self.clear_button.set_label(_("Clear selected color"))
24+ buttons_hbox.pack_start(self.clear_button, expand=True, fill=False)
25+ self.clear_button.connect("clicked", self.on_color_clear)
26+ self.clear_button.set_sensitive(False)
27 # hide the custom palette if no custom color is defined
28 if len(self.custom_colors) == 0:
29 self.custom_palette.hide()
30@@ -250,14 +261,26 @@
31 if self.selected_col == widget:
32 self.selected_col.set_selected(False)
33 self.selected_col = None
34+ self.clear_button.set_sensitive(False)
35 else:
36 # if previous selection: unselect
37 if self.selected_col is not None:
38 self.selected_col.set_selected(False)
39 self.selected_col = widget
40 self.selected_col.set_selected(True)
41+ self.clear_button.set_sensitive(True)
42 self.emit("color-changed")
43
44+ def on_color_clear(self, widget):
45+ """Callback: when clearing the color, reset any selected
46+ color, update the model and notify the parent"""
47+ # unselect current selection
48+ if self.selected_col is not None:
49+ self.selected_col.set_selected(False)
50+ self.selected_col = None
51+ self.clear_button.set_sensitive(False)
52+ self.emit("color-changed")
53+
54 def on_color_add(self, widget):
55 """Callback: when adding a new color, show the color definition
56 window, update the model, notifies the parent."""
57@@ -318,18 +341,20 @@
58 return self.selected_col.color
59
60 def set_selected_color(self, col):
61- """Defines the selected state of a displayed color"""
62+ """Defines the selected state of a displayed color,
63+ enables clear button when a color is selected"""
64 self.unselect_color()
65 if self.has_color(col):
66 self.buttons_lookup[col].set_selected(True)
67 self.selected_col = self.buttons_lookup[col]
68+ self.clear_button.set_sensitive(True)
69
70 def unselect_color(self):
71 """Deselect all colors"""
72 if self.selected_col is not None:
73 self.selected_col.set_selected(False)
74 self.selected_col = None
75-
76+ self.clear_button.set_sensitive(False)
77
78 gobject.type_register(SimpleColorSelector)
79 gobject.signal_new("color-changed", SimpleColorSelector,

Subscribers

People subscribed via source and target branches

to status/vote changes: