Merge lp:~dwt/photostory/no-pic into lp:~photostory/photostory/trunk

Proposed by David Turner
Status: Merged
Merged at revision: 11
Proposed branch: lp:~dwt/photostory/no-pic
Merge into: lp:~photostory/photostory/trunk
Diff against target: 160 lines (+39/-27) (has conflicts)
3 files modified
app.py (+37/-19)
data/db (+1/-7)
data/num (+1/-1)
Text conflict in app.py
To merge this branch: bzr merge lp:~dwt/photostory/no-pic
Reviewer Review Type Date Requested Status
Joel Auterson Approve
Josh Brown Approve
Review via email: mp+30912@code.launchpad.net

Description of the change

This branch gets rid of the nopic.png and replaces it with a Label instead (Bug #608370)

Furthermore it extracts a new function setPic() which helps clean up the excessive amounts of "pic.set_from_file" calls.

To post a comment you must log in.
lp:~dwt/photostory/no-pic updated
8. By David <david@david-laptop>

Oops, didn't actually change app.py. It should be correct this time.

9. By David <david@david-laptop>

Made the font color to be the default system font color since if the user is using a dark theme, previously the text would be unreadable.

Revision history for this message
Josh Brown (joshbrown) wrote :

Haven't tested it but the code looks good to me.

review: Approve
lp:~dwt/photostory/no-pic updated
10. By David Turner

The button to take the picture was unselectable after going to a date that had a picture, and would not go back to selectable. Also fixed a bug with taking a picture, and the label would not get replaced by the new image.

Revision history for this message
Joel Auterson (joel-auterson) wrote :

If I take a picture, the label on the now-insensitive button changes to 'Picture taken for this day'. If I change the day to one in the future, it remains the same - please change this. It should change to the original label ('Take today's picture', I think) and be insensitive. :)

review: Needs Fixing
lp:~dwt/photostory/no-pic updated
11. By David Turner

Fixed the 'Take today's picture' button

Revision history for this message
Joel Auterson (joel-auterson) wrote :

If David has indeed fixed the button then this is good to be merged.

Good man.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app.py'
2--- app.py 2010-07-29 05:20:15 +0000
3+++ app.py 2010-08-03 23:36:50 +0000
4@@ -23,8 +23,12 @@
5 pipeline = None
6 xvimagesink = None
7 movie = None
8+<<<<<<< TREE
9 pic=None
10 self.movPath = None
11+=======
12+ self.pic=None
13+>>>>>>> MERGE-SOURCE
14 self.db = cPickle.load(open('data/db', 'rb'))
15 self.ind = int(cPickle.load(open('data/num', 'rb')))
16 todayPicName = "pictures/" + str(self.ind) + ".png"
17@@ -32,10 +36,7 @@
18
19 def chooseDay(cal):
20 dateTuple = cal.get_date()
21- if dateTuple in self.db:
22- pic.set_from_file(self.db[dateTuple])
23- else:
24- pic.set_from_file("data/nopic.png")
25+ setPic(dateTuple)
26
27 def closedown(win):
28 print 'ind ' + str(self.ind)
29@@ -126,10 +127,8 @@
30 stillPipe.set_state(gst.STATE_NULL)
31 xvimagesink.set_xwindow_id(movie.window.xid)
32 pipeline.set_state(gst.STATE_PLAYING)
33- pic.set_from_file(todayPicName)
34+ setPic(todayDate)
35 self.ind += 1
36- takeBut.set_label("Picture taken this day.")
37- takeBut.set_sensitive(False)
38
39 def deletePic(deleteBut):
40 def getKey(dic, val):
41@@ -137,7 +136,7 @@
42 date = cal.get_date()
43 if date in self.db:
44 os.remove(self.db[date])
45- pic.set_from_file("data/nopic.png")
46+ setPic("")
47 if date == todayDate:
48 takeBut.set_label("Take today's picture")
49 takeBut.set_sensitive(True)
50@@ -158,6 +157,30 @@
51 del self.db[date]
52 self.ind -= 1
53
54+ def setPic(date):
55+ if self.pic != None:
56+ vbox1.remove(self.pic)
57+ vbox1.remove(hbox2)
58+ if date in self.db:
59+ self.pic = gtk.Image()
60+ self.pic.set_from_file(self.db[date])
61+ takeBut.set_label("Picture taken for this day.")
62+ takeBut.set_sensitive(False)
63+ else:
64+ if date == todayDate:
65+ takeBut.set_label("Take today's picture")
66+ takeBut.set_sensitive(True)
67+ else:
68+ takeBut.set_label("Take today's picture")
69+ takeBut.set_sensitive(False)
70+ self.pic = gtk.Label()
71+ self.pic.set_justify(gtk.JUSTIFY_CENTER)
72+ self.pic.set_markup("<span size='54000'>No Picture\nToday</span>");
73+ self.pic.set_size_request(640, 480)
74+ vbox1.pack_start(self.pic)
75+ vbox1.pack_start(hbox2)
76+ vbox1.show_all()
77+
78 #Interface
79 win = gtk.Window(gtk.WINDOW_TOPLEVEL)
80 win.connect("destroy", closedown)
81@@ -177,17 +200,19 @@
82 hbox2 = gtk.HBox(homogeneous=True)
83 aboutBut = gtk.Button(label="About")
84 aboutBut.connect("clicked", about)
85- pic = gtk.Image()
86+
87 cal = gtk.Calendar()
88 todayDate = cal.get_date()
89 cal.connect("day-selected", chooseDay)
90+
91 takeBut = gtk.Button(label="Take today's picture")
92 takeBut.connect("clicked", capture)
93+
94+ setPic(todayDate)
95+
96 win.add(hbox)
97 hbox.pack_start(vbox1, expand=False)
98 hbox.pack_start(vbox2)
99- vbox1.pack_start(pic)
100- vbox1.pack_start(hbox2)
101 hbox2.pack_start(filmBut, expand=False)
102 hbox2.pack_start(deleteBut, expand=False)
103 #hbox2.pack_start(shareBut)
104@@ -196,12 +221,6 @@
105 vbox2.pack_start(movie)
106 vbox2.pack_start(cal, expand=False, padding=50)
107 vbox2.pack_start(takeBut, expand=False)
108- if todayDate in self.db:
109- pic.set_from_file(self.db[todayDate])
110- takeBut.set_label("Picture taken for this day.")
111- takeBut.set_sensitive(False)
112- else:
113- pic.set_from_file("data/nopic.png")
114
115 win.show_all()
116
117@@ -210,7 +229,7 @@
118
119 camera = gst.element_factory_make("v4l2src", "camera")
120 camera.set_property("device", "/dev/video0")
121-
122+
123 caps = gst.Caps("video/x-raw-yuv,width=640,height=480,framerate=30/1")
124 filt = gst.element_factory_make("capsfilter", "filter")
125 filt.set_property("caps", caps)
126@@ -223,7 +242,6 @@
127 xvimagesink.set_xwindow_id(movie.window.xid)
128
129 pipeline.set_state(gst.STATE_PLAYING)
130-
131
132 start=Main()
133 gtk.main()
134
135=== modified file 'data/db'
136--- data/db 2010-07-21 06:38:17 +0000
137+++ data/db 2010-08-03 23:36:50 +0000
138@@ -1,8 +1,2 @@
139 (dp1
140-(I2010
141-I6
142-I21
143-tp2
144-S'pictures/0.png'
145-p3
146-s.
147\ No newline at end of file
148+.
149\ No newline at end of file
150
151=== removed file 'data/nopic.png'
152Binary files data/nopic.png 2010-07-12 15:25:36 +0000 and data/nopic.png 1970-01-01 00:00:00 +0000 differ
153=== modified file 'data/num'
154--- data/num 2010-07-21 06:38:17 +0000
155+++ data/num 2010-08-03 23:36:50 +0000
156@@ -1,2 +1,2 @@
157-I1
158+I0
159 .
160\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: