diff options
-rw-r--r-- | imagethumbnail.py | 427 |
1 files changed, 223 insertions, 204 deletions
diff --git a/imagethumbnail.py b/imagethumbnail.py index bdeffa8..50fdcbb 100644 --- a/imagethumbnail.py +++ b/imagethumbnail.py @@ -32,8 +32,7 @@ from gi.repository import Gdk from gi.repository import GObject from gi.repository import Pango from gi.repository import GdkPixbuf - -#from glib import GError +from gi.repository import Gio from sugar3 import mime from sugar3.activity import activity @@ -46,9 +45,6 @@ from sugar3.activity.widgets import StopButton from gettext import gettext as _ -#from jarabe.journal.journaltoolbox import MainToolbox, DetailToolbox -#from jarabe.journal.detailview import DetailView - COLUMN_TITLE = 0 COLUMN_JOBJECT = 3 COLUMN_IMAGE = 0 @@ -58,10 +54,23 @@ max_file = 1000 _logger = logging.getLogger('image-thumbnail') +def get_mounts(): + + volume_monitor = Gio.VolumeMonitor.get() + + mounts = [] + for mount in volume_monitor.get_mounts(): + description = {} + description['mount_path'] = mount.get_default_location().get_path() + description['label'] = mount.get_name() + mounts.append(description) + + return mounts + class ImageThumbnail(activity.Activity): """The entry point to the Activity""" - def __init__(self, handle, create_jobject=True): + def __init__(self, handle, create_jobject = True): activity.Activity.__init__(self, handle) @@ -73,29 +82,29 @@ class ImageThumbnail(activity.Activity): self.canvas.props.show_tabs = True self.canvas.show() - self.last_col=0 - cols=3 - # FIXME: module object has no attribute mounts - #ds_mounts = datastore.mounts() - #check if externmal media used in journal - #if len(ds_mounts)==1 and ds_mounts[0]['id']==1:cols=4 - - self.ls_journal=[] - self.tv_journal=[] - self.col_journal=[] - self.column_table=[] - self.scroll=[] - self.vbox=[] - self.hidden=[] - self.image=[[],[],[],[],[]] - self.btn_delete=[[],[],[],[],[]] - self.btn_show=[[],[],[],[],[]] - self.title_entry=[[],[],[],[],[]] - self.tab_label=[] + self.last_col = 0 + cols = 3 + ds_mounts = get_mounts() + # check if externmal media used in journal + if ds_mounts: cols = 4 + + self.ls_journal = [] + self.tv_journal = [] + self.col_journal = [] + self.column_table = [] + self.scroll = [] + self.vbox = [] + self.hidden = [] + self.image = [[],[],[],[],[]] + self.btn_delete = [[],[],[],[],[]] + self.btn_show = [[],[],[],[],[]] + self.title_entry = [[],[],[],[],[]] + self.tab_label = [] for col in range(cols): - self.ls_journal.append( Gtk.ListStore(GObject.TYPE_STRING, + self.ls_journal.append( + Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_UINT64, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT)) @@ -119,13 +128,13 @@ class ImageThumbnail(activity.Activity): # label_attributes.insert(Pango.AttrSize(14000, 0, -1)) # label_attributes.insert(Pango.AttrForeground(65535, 65535, 65535, 0, -1)) - if col==0: + if col == 0: self.tab_label.append(Gtk.Label(_("Journal"))) - elif col==1: + elif col == 1: self.tab_label.append(Gtk.Label(_("Files"))) - elif (cols==4 and col==2): + elif (cols == 4 and col == 2): self.tab_label.append(Gtk.Label(_("External"))) else: @@ -135,16 +144,17 @@ class ImageThumbnail(activity.Activity): #self.tab_label[col].set_attributes(label_attributes) #self.tab_label[col].show() #self.tv_journal[col].show() - if col==0:self.load_journal_table(col) + if col == 0: self.load_journal_table(col) else: self.load_file_table(col) - num=self.ls_journal[col].iter_n_children(None) + num = self.ls_journal[col].iter_n_children(None) - if num==0: + if num == 0: #dummy elements for no external files - self.column_table.append( Gtk.Table(1,1, homogeneous=False)) - self.scroll.append(Gtk.ScrolledWindow(hadjustment=None, vadjustment=None)) - self.vbox.append(Gtk.VBox(homogeneous=True, spacing=5)) + self.column_table.append( Gtk.Table(1, 1, homogeneous = False)) + self.scroll.append(Gtk.ScrolledWindow(hadjustment = None, + vadjustment = None)) + self.vbox.append(Gtk.VBox(homogeneous = True, spacing=5)) self.canvas.append_page(self.vbox[col],self.tab_label[col]) self.tab_label[col].hide() self.vbox[col].hide() @@ -154,44 +164,49 @@ class ImageThumbnail(activity.Activity): self.tab_label[col].show() self.tv_journal[col].show() - self.column_table.append( Gtk.Table(rows=num, columns=3, homogeneous=False)) - self.scroll.append(Gtk.ScrolledWindow( hadjustment=None, vadjustment=None)) - self.scroll[col].set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + self.column_table.append( Gtk.Table(rows = num, + columns = 3, homogeneous = False)) + self.scroll.append(Gtk.ScrolledWindow(hadjustment = None, + vadjustment = None)) + self.scroll[col].set_policy(Gtk.PolicyType.AUTOMATIC, + Gtk.PolicyType.AUTOMATIC) iter = self.ls_journal[col].get_iter_first() n=0 - while(iter!=None): - tv=self.tv_journal[col] + while(iter != None): + tv = self.tv_journal[col] model = tv.get_model() jobject = model.get_value(iter,COLUMN_JOBJECT) - i=n-(3*int(n/3)) - j=2*int(n/3) - image_table = Gtk.Table(rows=2, columns=2, homogeneous=False) + i = n - (3 * int(n / 3)) + j = 2 * int( n / 3) + image_table = Gtk.Table(rows = 2, columns = 2, homogeneous = False) self.image[col].append( Gtk.Image()) image_table.attach(self.image[col][n], 0, 2, 0, 1, - xoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, - xpadding=5, ypadding=5) + xoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + xpadding = 5, ypadding = 5) self.btn_show[col].append(Gtk.Button(_("Show File"))) self.btn_show[col][n].connect('button_press_event', - self.show_button_press_event_cb, col,n) - + self.show_button_press_event_cb, col,n) + image_table.attach(self.btn_show[col][n], 0, 1, 1, 2, xoptions = Gtk.AttachOptions.SHRINK, yoptions = Gtk.AttachOptions.SHRINK, xpadding = 5, ypadding = 5) self.btn_show[col][n].show() - if col<cols-1: + if col < cols - 1: self.btn_delete[col].append(Gtk.Button(_("Delete"))) self.btn_delete[col][n].connect('button_press_event', - self.delete_button_press_event_cb, col,n) - + self.delete_button_press_event_cb, col,n) + image_table.attach(self.btn_delete[col][n], 1, 2, 1, 2, xoptions = Gtk.AttachOptions.SHRINK, yoptions = Gtk.AttachOptions.SHRINK, @@ -202,11 +217,14 @@ class ImageThumbnail(activity.Activity): image_table.show() self.column_table[col].attach(image_table, i, i+1, j+1, j+2, - xoptions = Gtk.AttachOptions.FILL | - Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND | - Gtk.AttachOptions.SHRINK, xpadding = 5, ypadding = 5) - + xoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.SHRINK, + xpadding = 5, ypadding = 5) + self.set_form_fields(jobject,col,n) self.btn_show[col][n].props.sensitive = True @@ -252,8 +270,9 @@ class ImageThumbnail(activity.Activity): self.tv_journal[col].show() self.scroll[col]= Gtk.ScrolledWindow( - hadjustment=None, vadjustment=None) - self.scroll[col].set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + hadjustment=None, vadjustment=None) + self.scroll[col].set_policy(Gtk.PolicyType.AUTOMATIC, + Gtk.PolicyType.AUTOMATIC) self.menu_file() self.scroll[col].show() self.vbox[col] = Gtk.VBox(homogeneous=True, spacing=5) @@ -266,7 +285,7 @@ class ImageThumbnail(activity.Activity): def remove_image(self, col,id): iter = self.ls_journal[col].get_iter_first() - n=0 + n = 0 tv = self.tv_journal[col] model = tv.get_model() self.image[col][id].hide() @@ -275,20 +294,25 @@ class ImageThumbnail(activity.Activity): self._secondary_view = Gtk.VBox() self.detail_view = Gtk.Table(5,5, homogeneous= False) - go_back=Gtk.Button(_("back")) - go_back.connect('button_press_event', self._go_back_clicked_cb, col) + go_back = Gtk.Button(_("back")) + go_back.connect('button_press_event', + self._go_back_clicked_cb, col) go_back.show() self.detail_view.attach(go_back, 0, 1, 0, 1, - xoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, + xoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, xpadding = 5, ypadding = 5) #image - self.large_image=Gtk.Image() + self.large_image = Gtk.Image() self.detail_view.attach(self.large_image, 0, 3, 1, 5, - xoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, + xoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, xpadding = 5, ypadding = 5) self.detail_view.attach(self.large_image,0,3,1,5) @@ -299,22 +323,24 @@ class ImageThumbnail(activity.Activity): title_label = Gtk.Label(_("Title")) self.detail_view.attach(title_label, 3, 4, 0, 1, - xoptions = Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + title_label.show() self.title_textview = Gtk.TextView() self.title_textview.set_wrap_mode(Gtk.WrapMode.WORD) self.detail_view.attach(self.title_textview, 4, 5, 0, 1, - xoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.EXPAND | - Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + self.title_textview.props.accepts_tab = False self.title_textview.show() @@ -322,22 +348,24 @@ class ImageThumbnail(activity.Activity): description_label = Gtk.Label(_("Description")) self.detail_view.attach(description_label, 3, 4, 1, 2, - xoptions = Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + description_label.show() self.description_textview = Gtk.TextView() self.description_textview.set_wrap_mode(Gtk.WrapMode.WORD) self.detail_view.attach(self.description_textview, 4, 5, 1, 2, - xoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + self.description_textview.props.accepts_tab = False self.description_textview.show() @@ -345,22 +373,24 @@ class ImageThumbnail(activity.Activity): mtime_label = Gtk.Label(_("Created")) self.detail_view.attach(mtime_label, 3, 4, 2,3, - xoptions = Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + mtime_label.show() self.mtime_textview = Gtk.TextView() self.mtime_textview.set_wrap_mode(Gtk.WrapMode.WORD) self.detail_view.attach(self.mtime_textview, 4, 5, 2,3, - xoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + self.mtime_textview.props.accepts_tab = False self.mtime_textview.show() @@ -368,22 +398,24 @@ class ImageThumbnail(activity.Activity): mime_label= Gtk.Label(_("Type")) self.detail_view.attach(mime_label, 3, 4, 3,4, - xoptions = Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + mime_label.show() self.mime_textview = Gtk.TextView() self.mime_textview.set_wrap_mode(Gtk.WrapMode.WORD) self.detail_view.attach(self.mime_textview, 4, 5, 3,4, - xoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - yoptions = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | - Gtk.AttachOptions.SHRINK, - xpadding = 10, ypadding = 10) - + xoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + yoptions = Gtk.AttachOptions.EXPAND | + Gtk.AttachOptions.FILL | + Gtk.AttachOptions.SHRINK, + xpadding = 10, ypadding = 10) + self.mime_textview.props.accepts_tab = False self.mime_textview.show() @@ -395,35 +427,35 @@ class ImageThumbnail(activity.Activity): # Need to get the full set of properties iter = self.ls_journal[col].get_iter_first() - n=0 + n = 0 tv = self.tv_journal[col] model = tv.get_model() - while(iter!=None and n<(row)): - iter=self.ls_journal[col].iter_next(iter) - n+=1 + while(iter != None and n < (row)): + iter = self.ls_journal[col].iter_next(iter) + n += 1 jobject = model.get_value(iter,COLUMN_JOBJECT) - object_id=jobject.get_object_id() - metadata=jobject.get_file_metadata() + object_id = jobject.get_object_id() + metadata = jobject.get_file_metadata() try: - scaled_buf=self.show_image(jobject.get_file_path()) + scaled_buf = self.show_image(jobject.get_file_path()) self.large_image.set_from_pixbuf(scaled_buf) except Exception: logging.error('Exception while displaying entry:\n' + \ ''.join(traceback.format_exception(*sys.exc_info()))) - title_textbuf=self.title_textview.get_buffer() - if metadata['title']!=None: title_textbuf.set_text(metadata['title']) - desc_textbuf=self.description_textview.get_buffer() + title_textbuf = self.title_textview.get_buffer() + if metadata['title'] != None: title_textbuf.set_text(metadata['title']) + desc_textbuf = self.description_textview.get_buffer() if metadata['description']!=None: desc_textbuf.set_text(metadata['description']) - mime_textbuf=self.mime_textview.get_buffer() + mime_textbuf = self.mime_textview.get_buffer() mime_textbuf.set_text(metadata['mime_type']) - mtime_textbuf=self.mtime_textview.get_buffer() + mtime_textbuf = self.mtime_textview.get_buffer() #time from curent mtime=time.asctime(time.localtime(float(metadata['timestamp']))) mtime_textbuf.set_text(str(mtime)) @@ -431,7 +463,7 @@ class ImageThumbnail(activity.Activity): self._secondary_view.show() self.vbox_view.show() self.canvas.set_current_page(len(self.vbox)) - self.last_col=col + self.last_col = col def _go_back_clicked_cb(self,entry,event,col): @@ -441,20 +473,20 @@ class ImageThumbnail(activity.Activity): def delete_button_press_event_cb(self, entry, event, col,id): - i=0 + i = 0 tv = self.tv_journal[col] model = tv.get_model() iter = self.ls_journal[col].get_iter_first() - while(i<id): + while(i < id): iter = self.ls_journal[col].iter_next(iter) - i+=1 + i += 1 - if not iter==None: + if not iter == None: jobject = model.get_value(iter,COLUMN_JOBJECT) self.ls_journal[col].remove(iter) - if col==0: + if col == 0: datastore.delete(jobject.get_object_id()) else: @@ -465,23 +497,23 @@ class ImageThumbnail(activity.Activity): self.remove_image(col,id) self.tv_journal[col].grab_focus() - self.last_col=col + self.last_col = col - def close(self, skip_save=False): + def close(self, skip_save = False): "Override the close method so we don't try to create a Journal entry." - activity.Activity.close(self, True) + activity.Activity.close(self, True) - def set_form_fields(self, jobject, col=0,id=0): + def set_form_fields(self, jobject, col = 0, id = 0): #no title #self.title_entry[col][id].set_text(jobject.get_title()) - if col==0: - self.create_preview(jobject.get_object_id(),col,id) + if col == 0: + self.create_preview(jobject.get_object_id(), col, id) else: - filename=jobject.get_file_path() - self.show_image(filename,col,id) + filename = jobject.get_file_path() + self.show_image(filename, col, id) - def create_preview(self, object_id,col,id): + def create_preview(self, object_id, col, id): jobject = datastore.get(object_id) @@ -515,69 +547,65 @@ class ImageThumbnail(activity.Activity): def load_file_table(self,col): - self.num=0 - # FIXME: module object has no attribute mounts - ''' - if col==2: - ds_mounts = datastore.mounts() - #check if externmal media used in journal - if len(ds_mounts)==1 and ds_mounts[0]['id']==1: - #file= Popen(["./test.sh",""],stdout=PIPE) - #test=file.stdout - self.load_files('/media',col) - if self.num==0: + self.num = 0 + if col == 2: + ds_mounts = get_mounts() + + if ds_mounts: + for mount in ds_mounts: + self.load_files(mount['mount_path'], col) + else: self.tab_label[col].hide() - elif col==1:''' - if col==1: + elif col == 1: self.load_files('/home/olpc',col) else: - f=open('olpc.files','r') + f = open('olpc.files','r') for line in f: - line=line.strip() - print self.num - self.load_files('/home/olpc/'+line,col) - if self.num>max_file: break + line = line.strip() + self.load_files(os.path.join('/home/olpc', line), col) + if self.num > max_file: break f.close() # FIXME: object has no attribute SORT_DESCENDING #self.ls_journal[col].set_sort_column_id(COLUMN_MTIME, Gtk.SORT_DESCENDING) - def load_files(self,dir,col): + def load_files(self, dir, col): - for path, dirnames, filenames in os.walk(dir,True): - if dir=='/media': - f=open('media.files','r') + for path, dirnames, filenames in os.walk(dir, True): + + if dir == '/home/olpc' : + f = open('olpc.files','r') for line in f: - line=line.strip() + line = line.strip() if line in dirnames: dirnames.remove(line) f.close() - if dir=='/home/olpc' : - f=open('olpc.files','r') + else: + f = open('media.files','r') for line in f: - line=line.strip() + line = line.strip() if line in dirnames: dirnames.remove(line) f.close() for filename in filenames: - file_name=os.path.join(path,filename) + file_name = os.path.join(path, filename) #remove hidden file_nameexcept for readonly - pos=str.find(file_name,'/.') - if col==3:pos=-1 - name=str.find(file_name,'Cache') + pos = str.find(file_name, '/.') + if col == 3: pos = -1 + name = str.find(file_name, 'Cache') - if ((pos==-1) or name>0) and not( os.path.islink(file_name)): - if self.num>max_file: return + if ((pos == -1) or name > 0) and not( os.path.islink(file_name)): + if self.num > max_file: return try: file_mimetype = mime.get_for_file(os.path.join(path,filename)) if (file_mimetype.startswith('image/')) : #or (file_mimetype.startswith('video/')): #check for new files - self.num+=1 - mtime=os.path.getmtime(file_name) + self.num += 1 + mtime = os.path.getmtime(file_name) iter = self.ls_journal[col].append() jobject_wrapper = JobjectWrapper() jobject_wrapper.set_file_path(os.path.join(path, filename)) @@ -591,27 +619,16 @@ class ImageThumbnail(activity.Activity): self.ls_journal[col].set(iter, COLUMN_JOBJECT, jobject_wrapper) except IOError: print 'No mimetype for : %s' % (file_name) - def load_journal_table(self,col): - pass - # FIXME: module object has no attribute mounts - ''' - ds_mounts = datastore.mounts() + def load_journal_table(self, col): + + ds_mounts = get_mounts() mountpoint_id = None - if len(ds_mounts) == 1 and ds_mounts[0]['id'] == 1: - pass - else: - for mountpoint in ds_mounts: - id = mountpoint['id'] - uri = mountpoint['uri'] - if uri.startswith('/home'): - mountpoint_id = id - query = {} if mountpoint_id is not None: query['mountpoints'] = [ mountpoint_id ] - ds_objects, num_objects = datastore.find(query, properties=['uid','timestamp', - 'title', 'mime_type','description'],sorting='-timestamp') + ds_objects, num_objects = datastore.find(query, properties = ['uid','timestamp', + 'title', 'mime_type', 'description'], sorting = '-timestamp') self.ls_journal[col].clear() for i in xrange (0, num_objects, 1): @@ -621,20 +638,20 @@ class ImageThumbnail(activity.Activity): iter = self.ls_journal[col].append() title = ds_objects[i].metadata['title'] self.ls_journal[col].set(iter, COLUMN_TITLE, title) - jobject_wrapper=JobjectWrapper() + jobject_wrapper = JobjectWrapper() jobject_wrapper.set_jobject(ds_objects[i]) jobject_wrapper.set_mime_type(mime) - mtime= ds_objects[i].metadata.get('timestamp') + mtime = ds_objects[i].metadata.get('timestamp') jobject_wrapper.set_timestamp(mtime) - desc= ds_objects[i].metadata.get('description') + desc = ds_objects[i].metadata.get('description') jobject_wrapper.set_description(desc) - title= ds_objects[i].metadata.get('uid') + title = ds_objects[i].metadata.get('uid') jobject_wrapper.set_title(title) self.ls_journal[col].set(iter, COLUMN_MTIME, mtime) self.ls_journal[col].set(iter, COLUMN_JOBJECT, jobject_wrapper) size = self.get_size(ds_objects[i]) / 1024 - - self.ls_journal[col].set_sort_column_id(COLUMN_MTIME, Gtk.SORT_DESCENDING)''' + # FIXME: object has no attribute SORT_DESCENDING + #self.ls_journal[col].set_sort_column_id(COLUMN_MTIME, Gtk.SORT_DESCENDING) def get_size(self, jobject): """Return the file size for a Journal object.""" @@ -647,16 +664,18 @@ class ImageThumbnail(activity.Activity): return os.stat(path).st_size - def show_image(self, filename,col=-1, id=0): + def show_image(self, filename, col = -1, id = 0): """display a resized image in a preview""" try: - if filename==None:return - if col==-1: - scaled_buf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, style.zoom(930), style.zoom(700)) + if filename == None:return + if col == -1: + scaled_buf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, + style.zoom(930), style.zoom(700)) return scaled_buf else: - scaled_buf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, style.zoom(320), style.zoom(240)) + scaled_buf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, + style.zoom(320), style.zoom(240)) self.image[col][id].set_from_pixbuf(scaled_buf) self.image[col][id].show() except IOError: print 'Failed to open image %s' % (filename) @@ -669,18 +688,18 @@ class JobjectWrapper(): self.__jobject = None self.__file_path = None - def set_jobject(self, jobject): + def set_jobject(self, jobject): self.__jobject = jobject - def set_file_path(self, file_path): + def set_file_path(self, file_path): self.__file_path = file_path def set_title(self, filename): if self.__jobject != None: - self.__jobject.metadata['title']=filename + self.__jobject.metadata['title'] = filename else: self.__title = filename @@ -694,23 +713,23 @@ class JobjectWrapper(): def set_mime_type(self,mime_type): if self.__jobject != None: - self.__jobject.metadata['mime_type']=mime_type + self.__jobject.metadata['mime_type'] = mime_type else: - self.__mime_type =mime_type + self.__mime_type = mime_type def set_timestamp(self, time): if self.__jobject != None: - self.__jobject.metadata['timestamp']=time + self.__jobject.metadata['timestamp'] = time else: - self.__timestamp =time + self.__timestamp = time def set_description(self, desc): if self.__jobject != None: - self.__jobject.metadata['description']=desc + self.__jobject.metadata['description'] = desc else: - self.__description =desc + self.__description = desc def set_object_id(self,id): @@ -738,7 +757,7 @@ class JobjectWrapper(): return self.__jobject.metadata else: #client = gconf.client_get_default() - path=self.__file_path + path = self.__file_path return { 'uid': self.__object_id, 'title': self.__title, |