/usr/share/gallery-uploader/galleryuploader_lib/browser.py is in gallery-uploader 2.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | import os
from gi.repository import Gio, GObject
from itertools import count
from galleryuploader_lib.thumbnails import Thumbnailer
from galleryuploader_lib.dialogs import build_builder
class Browser(object):
new_id = count().next
def __init__(self):
self.dialog_builder = build_builder('browser')
self.dialog = self.dialog_builder.get_object('dialog')
self.list = self.dialog_builder.get_object('list')
self.icons = self.dialog_builder.get_object('icons')
self.filechooser = self.dialog_builder.get_object('filechooser')
self.icons.set_text_column(1)
self.icons.set_pixbuf_column(2)
self.current_folder = Gio.File.new_for_path('.').get_path()
# print "self.current_folder", self.current_folder
self.thumbnailer = Thumbnailer()
self.thumbnailer.start()
self.populate()
self.alive = True
GObject.timeout_add(100, self.monitor)
def run(self):
resp = self.dialog.run()
self.thumbnailer.go = False
if resp:
return self.get_filenames()
else:
return None
def destroy(self):
self.alive = False
self.dialog.destroy()
def get_filenames(self):
"""
Retrieve paths corresponding to selected thumbnails.
"""
retval = []
def iterator(iconview, path, *args):
full_path = os.path.join( os.path.realpath( os.curdir ),
self.list.get_value(self.list.get_iter( path ), 1 ) )
retval.append( full_path )
self.icons.selected_foreach( iterator )
return retval
def populate(self):
self.list.clear()
curdir = os.path.realpath( os.curdir )
dir_content = os.listdir( curdir )
dir_content.sort()
self.thumbnailer.reset(dir_content, basedir=curdir)
def monitor(self):
if self.alive == False:
return False
if not self.filechooser.get_filename():
return True
if self.current_folder != self.filechooser.get_filename():
self.current_folder = self.filechooser.get_filename()
os.chdir(self.current_folder)
self.populate()
return True
while self.thumbnailer.done:
thing, uri, thumbnail = self.thumbnailer.done.pop(0)
self.list.append([self.new_id(), thing, thumbnail])
return True
|