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
=== modified file 'app.py'
--- app.py 2010-07-29 05:20:15 +0000
+++ app.py 2010-08-03 23:36:50 +0000
@@ -23,8 +23,12 @@
23 pipeline = None23 pipeline = None
24 xvimagesink = None24 xvimagesink = None
25 movie = None25 movie = None
26<<<<<<< TREE
26 pic=None27 pic=None
27 self.movPath = None28 self.movPath = None
29=======
30 self.pic=None
31>>>>>>> MERGE-SOURCE
28 self.db = cPickle.load(open('data/db', 'rb'))32 self.db = cPickle.load(open('data/db', 'rb'))
29 self.ind = int(cPickle.load(open('data/num', 'rb')))33 self.ind = int(cPickle.load(open('data/num', 'rb')))
30 todayPicName = "pictures/" + str(self.ind) + ".png"34 todayPicName = "pictures/" + str(self.ind) + ".png"
@@ -32,10 +36,7 @@
3236
33 def chooseDay(cal):37 def chooseDay(cal):
34 dateTuple = cal.get_date()38 dateTuple = cal.get_date()
35 if dateTuple in self.db:39 setPic(dateTuple)
36 pic.set_from_file(self.db[dateTuple])
37 else:
38 pic.set_from_file("data/nopic.png")
3940
40 def closedown(win):41 def closedown(win):
41 print 'ind ' + str(self.ind)42 print 'ind ' + str(self.ind)
@@ -126,10 +127,8 @@
126 stillPipe.set_state(gst.STATE_NULL)127 stillPipe.set_state(gst.STATE_NULL)
127 xvimagesink.set_xwindow_id(movie.window.xid)128 xvimagesink.set_xwindow_id(movie.window.xid)
128 pipeline.set_state(gst.STATE_PLAYING)129 pipeline.set_state(gst.STATE_PLAYING)
129 pic.set_from_file(todayPicName)130 setPic(todayDate)
130 self.ind += 1131 self.ind += 1
131 takeBut.set_label("Picture taken this day.")
132 takeBut.set_sensitive(False)
133 132
134 def deletePic(deleteBut):133 def deletePic(deleteBut):
135 def getKey(dic, val):134 def getKey(dic, val):
@@ -137,7 +136,7 @@
137 date = cal.get_date()136 date = cal.get_date()
138 if date in self.db:137 if date in self.db:
139 os.remove(self.db[date])138 os.remove(self.db[date])
140 pic.set_from_file("data/nopic.png")139 setPic("")
141 if date == todayDate:140 if date == todayDate:
142 takeBut.set_label("Take today's picture")141 takeBut.set_label("Take today's picture")
143 takeBut.set_sensitive(True)142 takeBut.set_sensitive(True)
@@ -158,6 +157,30 @@
158 del self.db[date]157 del self.db[date]
159 self.ind -= 1158 self.ind -= 1
160159
160 def setPic(date):
161 if self.pic != None:
162 vbox1.remove(self.pic)
163 vbox1.remove(hbox2)
164 if date in self.db:
165 self.pic = gtk.Image()
166 self.pic.set_from_file(self.db[date])
167 takeBut.set_label("Picture taken for this day.")
168 takeBut.set_sensitive(False)
169 else:
170 if date == todayDate:
171 takeBut.set_label("Take today's picture")
172 takeBut.set_sensitive(True)
173 else:
174 takeBut.set_label("Take today's picture")
175 takeBut.set_sensitive(False)
176 self.pic = gtk.Label()
177 self.pic.set_justify(gtk.JUSTIFY_CENTER)
178 self.pic.set_markup("<span size='54000'>No Picture\nToday</span>");
179 self.pic.set_size_request(640, 480)
180 vbox1.pack_start(self.pic)
181 vbox1.pack_start(hbox2)
182 vbox1.show_all()
183
161 #Interface184 #Interface
162 win = gtk.Window(gtk.WINDOW_TOPLEVEL)185 win = gtk.Window(gtk.WINDOW_TOPLEVEL)
163 win.connect("destroy", closedown)186 win.connect("destroy", closedown)
@@ -177,17 +200,19 @@
177 hbox2 = gtk.HBox(homogeneous=True)200 hbox2 = gtk.HBox(homogeneous=True)
178 aboutBut = gtk.Button(label="About")201 aboutBut = gtk.Button(label="About")
179 aboutBut.connect("clicked", about)202 aboutBut.connect("clicked", about)
180 pic = gtk.Image()203
181 cal = gtk.Calendar()204 cal = gtk.Calendar()
182 todayDate = cal.get_date()205 todayDate = cal.get_date()
183 cal.connect("day-selected", chooseDay)206 cal.connect("day-selected", chooseDay)
207
184 takeBut = gtk.Button(label="Take today's picture")208 takeBut = gtk.Button(label="Take today's picture")
185 takeBut.connect("clicked", capture)209 takeBut.connect("clicked", capture)
210
211 setPic(todayDate)
212
186 win.add(hbox)213 win.add(hbox)
187 hbox.pack_start(vbox1, expand=False)214 hbox.pack_start(vbox1, expand=False)
188 hbox.pack_start(vbox2)215 hbox.pack_start(vbox2)
189 vbox1.pack_start(pic)
190 vbox1.pack_start(hbox2)
191 hbox2.pack_start(filmBut, expand=False)216 hbox2.pack_start(filmBut, expand=False)
192 hbox2.pack_start(deleteBut, expand=False)217 hbox2.pack_start(deleteBut, expand=False)
193 #hbox2.pack_start(shareBut)218 #hbox2.pack_start(shareBut)
@@ -196,12 +221,6 @@
196 vbox2.pack_start(movie)221 vbox2.pack_start(movie)
197 vbox2.pack_start(cal, expand=False, padding=50)222 vbox2.pack_start(cal, expand=False, padding=50)
198 vbox2.pack_start(takeBut, expand=False)223 vbox2.pack_start(takeBut, expand=False)
199 if todayDate in self.db:
200 pic.set_from_file(self.db[todayDate])
201 takeBut.set_label("Picture taken for this day.")
202 takeBut.set_sensitive(False)
203 else:
204 pic.set_from_file("data/nopic.png")
205224
206 win.show_all()225 win.show_all()
207226
@@ -210,7 +229,7 @@
210229
211 camera = gst.element_factory_make("v4l2src", "camera")230 camera = gst.element_factory_make("v4l2src", "camera")
212 camera.set_property("device", "/dev/video0")231 camera.set_property("device", "/dev/video0")
213232
214 caps = gst.Caps("video/x-raw-yuv,width=640,height=480,framerate=30/1")233 caps = gst.Caps("video/x-raw-yuv,width=640,height=480,framerate=30/1")
215 filt = gst.element_factory_make("capsfilter", "filter")234 filt = gst.element_factory_make("capsfilter", "filter")
216 filt.set_property("caps", caps)235 filt.set_property("caps", caps)
@@ -223,7 +242,6 @@
223 xvimagesink.set_xwindow_id(movie.window.xid)242 xvimagesink.set_xwindow_id(movie.window.xid)
224243
225 pipeline.set_state(gst.STATE_PLAYING)244 pipeline.set_state(gst.STATE_PLAYING)
226
227245
228start=Main()246start=Main()
229gtk.main()247gtk.main()
230248
=== modified file 'data/db'
--- data/db 2010-07-21 06:38:17 +0000
+++ data/db 2010-08-03 23:36:50 +0000
@@ -1,8 +1,2 @@
1(dp11(dp1
2(I2010
3I6
4I21
5tp2
6S'pictures/0.png'
7p3
8s.
9\ No newline at end of file2\ No newline at end of file
3.
10\ No newline at end of file4\ No newline at end of file
115
=== removed file 'data/nopic.png'
12Binary files data/nopic.png 2010-07-12 15:25:36 +0000 and data/nopic.png 1970-01-01 00:00:00 +0000 differ6Binary files data/nopic.png 2010-07-12 15:25:36 +0000 and data/nopic.png 1970-01-01 00:00:00 +0000 differ
=== modified file 'data/num'
--- data/num 2010-07-21 06:38:17 +0000
+++ data/num 2010-08-03 23:36:50 +0000
@@ -1,2 +1,2 @@
1I11I0
2.2.
3\ No newline at end of file3\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: