Merge lp:~tinchester/gnome-activity-journal/today-button-tweaks into lp:gnome-activity-journal

Proposed by Tin Tvrtkovic
Status: Merged
Merged at revision: 1146
Proposed branch: lp:~tinchester/gnome-activity-journal/today-button-tweaks
Merge into: lp:gnome-activity-journal
Diff against target: 124 lines (+40/-18)
2 files modified
src/main.py (+6/-8)
src/supporting_widgets.py (+34/-10)
To merge this branch: bzr merge lp:~tinchester/gnome-activity-journal/today-button-tweaks
Reviewer Review Type Date Requested Status
Stefano Candori Approve
Review via email: mp+44258@code.launchpad.net

Description of the change

This branch contains the today button tweak proposed on the mailing list.

To post a comment you must log in.
Revision history for this message
Stefano Candori (cando) wrote :

Tin, awesome work...merged!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main.py'
2--- src/main.py 2010-12-20 09:15:36 +0000
3+++ src/main.py 2010-12-20 18:47:11 +0000
4@@ -134,10 +134,10 @@
5 self.backward_button, ev_backward_button = DayButton.new(0)
6 self.forward_button, ev_forward_button = DayButton.new(1, sensitive=False)
7 # Widget placement
8- vbox = gtk.VBox(); hbox = gtk.HBox(); histogramhbox = gtk.HBox(); tvbox = gtk.VBox()
9+ vbox = gtk.VBox(); hbox = gtk.HBox(); histogramhbox = gtk.HBox();
10 hbox.pack_start(ev_backward_button, False, False); hbox.pack_start(self.view, True, True, 6)
11- hbox.pack_end(ev_forward_button, False, False); tvbox.pack_start(hbox, True, True, 3)
12- vbox.pack_start(self.toolbar, False, False); vbox.pack_start(tvbox, True, True, 2)
13+ hbox.pack_end(ev_forward_button, False, False);
14+ vbox.pack_start(self.toolbar, False, False); vbox.pack_start(hbox, True, True, 5)
15 histogramhbox.pack_end(self.histogram, True, True, 32); vbox.pack_end(histogramhbox, False, False)
16 self.add(vbox); self.show_all()
17 #Tray Icon
18@@ -228,12 +228,10 @@
19 def handle_button_sensitivity(self, date):
20 today = datetime.date.today()
21 if date == today:
22- return self.forward_button.set_sensitive(False)
23- elif date == today + tdelta(-1):
24+ self.forward_button.set_sensitive(False)
25+ else:
26 self.forward_button.set_leading(True)
27- else:
28- self.forward_button.set_leading(False)
29- self.forward_button.set_sensitive(True)
30+ self.forward_button.set_sensitive(True)
31
32 def on_view_button_click(self, w, button, i):
33 self.view.set_view_page(i)
34
35=== modified file 'src/supporting_widgets.py'
36--- src/supporting_widgets.py 2010-12-20 09:15:36 +0000
37+++ src/supporting_widgets.py 2010-12-20 18:47:11 +0000
38@@ -150,6 +150,7 @@
39 class DayButton(gtk.DrawingArea):
40 leading = False
41 pressed = False
42+ today_pressed = False
43 sensitive = True
44 today_hover = False
45 hover = False
46@@ -158,7 +159,7 @@
47 header_color = (1, 1, 1, 1)
48 leading_header_color = (1, 1, 1, 1)
49 internal_color = (0, 1, 0, 1)
50- arrow_color = (1,1,1,1)
51+ arrow_color = (1, 1, 1, 1)
52 arrow_color_selected = (1, 1, 1, 1)
53
54 __gsignals__ = {
55@@ -236,7 +237,9 @@
56 def on_press(self, widget, event):
57 if event.y > self.header_size:
58 self.pressed = True
59- self.queue_draw()
60+ else:
61+ self.today_pressed = True
62+ self.queue_draw()
63
64 def keyboard_clicked_sender(self, widget, event):
65 if event.keyval in (gtk.keysyms.Return, gtk.keysyms.space):
66@@ -254,6 +257,7 @@
67 elif event.y < self.header_size:
68 self.emit("jump-to-today")
69 self.pressed = False
70+ self.today_pressed = False;
71 self.queue_draw()
72 return True
73
74@@ -291,7 +295,8 @@
75 context.curve_to(x,y+h,x,y+h,x,y+h-r)
76 context.line_to(x,y+r)
77 context.curve_to(x,y,x,y,x+r,y)
78- context.set_source_rgba(*(self.leading_header_color if self.leading else self.header_color))
79+ # What's this for, exactly? Appears to have been already set.
80+ #context.set_source_rgba(*(self.leading_header_color if self.leading else self.header_color))
81 context.close_path()
82 context.rectangle(0, r, w, self.header_size)
83 context.fill()
84@@ -323,14 +328,33 @@
85 self, "arrow", arrow, True,
86 w/2-size/2, h/2 + size/2, size, size)
87 size = 7
88+
89+ # Paint today button arrows.
90 if self.sensitive and self.side > 0:
91- self.style.paint_arrow(widget.window, state, gtk.SHADOW_NONE, None,
92- self, "arrow", arrow, True,
93- w/2, self.header_size/2 - size/2, size, size)
94- self.style.paint_arrow(widget.window, state, gtk.SHADOW_OUT, None,
95- self, "arrow", arrow, True,
96- w/2-size/2, self.header_size/2 - size/2, size, size)
97- return
98+ if self.today_hover:
99+ if self.today_pressed:
100+ self.style.paint_arrow(widget.window, gtk.STATE_SELECTED, gtk.SHADOW_NONE, None,
101+ self, "arrow", arrow, True,
102+ w/2, self.header_size/2 - size/2, size, size)
103+ self.style.paint_arrow(widget.window, gtk.STATE_SELECTED, gtk.SHADOW_OUT, None,
104+ self, "arrow", arrow, True,
105+ w/2-size/2, self.header_size/2 - size/2, size, size)
106+
107+ else:
108+ self.style.paint_arrow(widget.window, state, gtk.SHADOW_NONE, None,
109+ self, "arrow", arrow, True,
110+ w/2, self.header_size/2 - size/2, size, size)
111+ self.style.paint_arrow(widget.window, state, gtk.SHADOW_OUT, None,
112+ self, "arrow", arrow, True,
113+ w/2-size/2, self.header_size/2 - size/2, size, size)
114+ else:
115+ self.style.paint_arrow(widget.window, gtk.STATE_SELECTED, gtk.SHADOW_NONE, None,
116+ self, "arrow", arrow, True,
117+ w/2, self.header_size/2 - size/2, size, size)
118+ self.style.paint_arrow(widget.window, gtk.STATE_SELECTED, gtk.SHADOW_OUT, None,
119+ self, "arrow", arrow, True,
120+ w/2-size/2, self.header_size/2 - size/2, size, size)
121+ #return
122
123
124 class SearchBox(gtk.ToolItem):