diff options
author | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2008-01-21 06:57:56 (GMT) |
---|---|---|
committer | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2008-01-21 06:57:56 (GMT) |
commit | 8b457cc86a396a1d9ffd9524aa22fc3ffc80de1f (patch) | |
tree | b54a7de1dfe291cfb36ae2be4a7e9a877181b2d0 | |
parent | 121ccc9cbda6c33666d6dd99cce9054811c4ffed (diff) |
51 final (?)
git-svn-id: http://mediamods.com/public-svn/camera-activity/tags/51@1019 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
-rw-r--r-- | NEWS | 5 | ||||
-rwxr-xr-x | activity/activity.info | 2 | ||||
-rw-r--r-- | constants.py | 40 | ||||
-rw-r--r-- | model.py | 2 | ||||
-rwxr-xr-x | record.py | 6 | ||||
-rw-r--r-- | recorded.py | 10 | ||||
-rw-r--r-- | serialize.py | 17 | ||||
-rw-r--r-- | ui.py | 22 |
8 files changed, 67 insertions, 37 deletions
@@ -1,3 +1,8 @@ +51 +* #4525 defensive techniques against translations with bad variables (jedierikb) +* #5899 fixed (jedierikb) +* tag support (jedierikb) + 50 * #5830 fix (jedierikb) * #4525 updates with fixes to .po files (jedierikb) diff --git a/activity/activity.info b/activity/activity.info index 0acd8bf..048a8b7 100755 --- a/activity/activity.info +++ b/activity/activity.info @@ -3,5 +3,5 @@ name = Record service_name = org.laptop.RecordActivity class = record.Record icon = activity-record -activity_version = 50 +activity_version = 51 show_launcher = yes
\ No newline at end of file diff --git a/constants.py b/constants.py index 1c797eb..a6a1ee8 100644 --- a/constants.py +++ b/constants.py @@ -25,6 +25,7 @@ class Constants: activityId = None recdTitle = "title" + recdTags = "tags" recdTime = "time" recdRecorderName = "photographer" recdRecorderHash = "recorderHash" @@ -67,7 +68,7 @@ class Constants: DURATION_2 = 2 DURATION_4 = 4 DURATION_6 = 6 - DURATIONS = [] + DURATIONS = [] DURATIONS.append(DURATION_2) DURATIONS.append(DURATION_4) DURATIONS.append(DURATION_6) @@ -88,9 +89,26 @@ class Constants: gfxPath = os.path.join(activity.get_bundle_path(), "gfx") soundClick = os.path.join(gfxPath, 'photoShutter.wav') - istrsTest = {} - for i in range (0,10): - istrsTest[str(i)] = str(i) + + #defensive method against variables not translated correctly + def _(s): + #todo: permanent variable + istrsTest = {} + for i in range (0,4): + istrsTest[str(i)] = str(i) + + i = s + try: + #test translating the string with many replacements + i = gt(s) + test = i % istrsTest + except: + #if it doesn't work, revert + i = s + + return i + + istrActivityName = _('Record') istrPhoto = _('Photo') istrVideo = _('Video') @@ -278,8 +296,6 @@ class Constants: for i in range (0, longestTime): self.createCountdownPng( i ) - checkInternationalStrings() - def createCountdownPng(self, num): todisk = True @@ -336,15 +352,3 @@ class Constants: img.set_from_pixmap(pixmap, None) self.__class__.countdownImgs[int(num)] = img - - - def _(self, s): - i = s - try: - #test translating the string with many replacements - i = gt(s) % self.__class__.istrTests - except: - #if it doesn't work, revert - i = s - - return i @@ -396,6 +396,8 @@ class Model: tBytes = os.stat(thumbFile)[6] recd.thumbBytes = tBytes + recd.tags = "" + #load the mediafile mediaFile = os.path.join(Instance.instancePath, recd.mediaFilename) mediaMd5 = utils.md5File( mediaFile ) @@ -108,7 +108,6 @@ class Record(activity.Activity): if ( (not recd.savedMedia) or (not recd.savedXml) ): allDone = False - self.__log__.error("somehow we didn't serialize a recd...") if (self.I_AM_CLOSING): mediaObject = recd.datastoreOb @@ -450,7 +449,9 @@ class Record(activity.Activity): recd.meshDownlodingPercent = (part+0.0)/(numparts+0.0) recd.meshDownloadingProgress = True self.ui.updateMeshProgress(True, recd) - f = open(recd.getMediaFilepath(), 'a+').write(bytes) + f = open(recd.getMediaFilepath(), 'a+') + f.write(bytes) + f.close() if part == numparts: self.__class__.log.debug('Finished receiving %s' % recd.title) @@ -487,7 +488,6 @@ class Record(activity.Activity): def _getAlbumArtCb( self, objectThatSentTheSignal, pixbuf, recd ): - self.__class__.log.debug("_getAlbumArtCb:" + str(pixbuf) + "," + str(recd)) if (pixbuf != None): imagePath = os.path.join(Instance.instancePath, "audioPicture.png") diff --git a/recorded.py b/recorded.py index 3eee5e8..488a01c 100644 --- a/recorded.py +++ b/recorded.py @@ -42,9 +42,10 @@ class Recorded: self.thumbMd5 = None self.mediaBytes = None self.thumbBytes = None + self.tags = None #flag to alert need to re-datastore the title - self.titleChange = False + self.metaChange = False #when you are datastore-serialized, you get one of these ids... self.datastoreId = None @@ -78,7 +79,12 @@ class Recorded: def setTitle( self, newTitle ): self.title = newTitle - self.titleChange = True + self.metaChange = True + + + def setTags( self, newTags ): + self.tags = newTags + self.metaChange = True def isClipboardCopyable( self ): diff --git a/serialize.py b/serialize.py index d861fc6..f86c373 100644 --- a/serialize.py +++ b/serialize.py @@ -46,6 +46,8 @@ def _loadMediaIntoHash( el, hash ): #name might have been changed in the journal, so reflect that here if (recd.title != recd.datastoreOb.metadata['title']): recd.setTitle(recd.datastoreOb.metadata['title']) + if (recd.tags != recd.datastoreOb.metadata['tags']): + recd.setTags(recd.datastoreOb.metadata['tags']) if (recd.buddy): recd.downloadedFromBuddy = True @@ -57,7 +59,6 @@ def _loadMediaIntoHash( el, hash ): def getMediaFromDatastore( recd ): if (recd.datastoreId == None): - print("RecordActivity error -- request for recd from datastore with no datastoreId") return None if (recd.datastoreOb != None): @@ -69,7 +70,6 @@ def getMediaFromDatastore( recd ): mediaObject = datastore.get( recd.datastoreId ) finally: if (mediaObject == None): - print("RecordActivity error -- request for recd from datastore returning None") return None return mediaObject @@ -112,6 +112,11 @@ def fillRecdFromNode( recd, el ): if (el.getAttributeNode(Constants.recdRecorderName) != None): recd.recorderName = el.getAttribute(Constants.recdRecorderName) + if (el.getAttributeNode(Constants.recdTags) != None): + recd.tags = el.getAttribute(Constants.recdTags) + else: + recd.tags = "" + if (el.getAttributeNode(Constants.recdRecorderHash) != None): recd.recorderHash = el.getAttribute(Constants.recdRecorderHash) @@ -274,14 +279,17 @@ def _saveMediaToDatastore( el, recd ): if (recd.datastoreId != None): #already saved to the datastore, don't need to re-rewrite the file since the mediums are immutable #However, they might have changed the name of the file - if (recd.titleChange): + if (recd.metaChange): recd.datastoreOb = getMediaFromDatastore( recd ) if (recd.datastoreOb.metadata['title'] != recd.title): recd.datastoreOb.metadata['title'] = recd.title datastore.write(recd.datastoreOb) + if (recd.datastoreOb.metadata['tags'] != recd.tags): + recd.datastoreOb.metadata['tags'] = recd.tags + datastore.write(recd.datastoreOb) #reset for the next title change if not closing... - recd.titleChange = False + recd.metaChange = False #save the title to the xml recd.savedMedia = True _saveXml( el, recd ) @@ -294,6 +302,7 @@ def _saveMediaToDatastore( el, recd ): #therefore this is only called when write_file is called by the activity superclass mediaObject = datastore.create() mediaObject.metadata['title'] = recd.title + mediaObject.metadata['tags'] = recd.tags datastorePreviewPixbuf = recd.getThumbPixbuf() if (recd.type == Constants.TYPE_AUDIO): @@ -274,8 +274,10 @@ class UI: tagsLabel.set_alignment(0, .5)
self.tagsPanel.pack_start(tagsLabel, expand=False)
self.tagsBuffer = gtk.TextBuffer()
- self.tagsField = gtk.TextView( self.tagsBuffer )
- self.tagsPanel.pack_start( self.tagsField, expand=True )
+ self.tagsBuffer.connect('changed', self._tagsBufferEditedCb)
+ self.tagsField = gtk.TextView(self.tagsBuffer)
+ self.tagsField.set_size_request( 100, 100 )
+ self.tagsPanel.pack_start(self.tagsField, expand=True)
self.infoBoxTopLeft.pack_start(self.tagsPanel, expand=True)
infoBotBox = gtk.HBox()
@@ -636,6 +638,13 @@ class UI: self.shownRecd.setTitle( self.nameTextfield.get_text() )
+ def _tagsBufferEditedCb(self, widget):
+ if (self.shownRecd != None):
+ txt = self.tagsBuffer.get_text( self.tagsBuffer.get_start_iter(), self.tagsBuffer.get_end_iter() )
+ if (txt != self.shownRecd.tags):
+ self.shownRecd.setTags( txt )
+
+
def _keyPressEventCb( self, widget, event):
#todo: trac #4144
@@ -1533,12 +1542,7 @@ class UI: def updateMeshProgress( self, progressMade, recd ):
self.resetWidgetFadeTimer()
- record.Record.log.debug("updateMeshProgress:" + str(progressMade) )
- record.Record.log.debug( "recd:" + str(recd) )
- record.Record.log.debug( "recd:" + str(self.shownRecd) )
if (self.shownRecd != recd):
- record.Record.log.debug("updateMeshProgress: self.shownRecd != recd")
-
if (self.shownRecd == None):
type = Constants.mediaTypes[recd.type][Constants.keyIstr]
if (progressMade):
@@ -1709,14 +1713,14 @@ class UI: self.photographerNameLabel.set_label( recd.recorderName )
self.nameTextfield.set_text( recd.title )
self.nameTextfield.set_sensitive( True )
+ self.tagsBuffer.set_text( recd.tags )
self.dateDateLabel.set_label( utils.getDateString(recd.time) )
self.photographerPanel.show()
self.namePanel.show()
self.datePanel.show()
self.tagsPanel.show()
- self.tagsBuffer.set_text("")
- self.tagsField.set_sensitive(False)
+ self.tagsField.set_sensitive(True)
def setWaitCursor( self, win ):
|