mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 11:30:19 +01:00
* Code clean up.
* Removed unnecessary imports. * Adapted to PEP8.
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
from gtkmvc import Model
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
import gtk
|
||||
@@ -33,6 +32,7 @@ import gobject
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
class Ini(object):
|
||||
|
||||
def __init__(self):
|
||||
self.ini = []
|
||||
|
||||
@@ -104,9 +104,9 @@ class ConfigModel(Model):
|
||||
}
|
||||
|
||||
dictconf = {
|
||||
"save main window size" : "savewin",
|
||||
"save panes size" : "savepan",
|
||||
"main window width" : "wx",
|
||||
"save main window size": "savewin",
|
||||
"save panes size": "savepan",
|
||||
"main window width": "wx",
|
||||
"main window height": "wy",
|
||||
"horizontal panes": "h",
|
||||
"vertical panes":"v",
|
||||
@@ -166,7 +166,6 @@ class ConfigModel(Model):
|
||||
self.refresh_ext()
|
||||
return
|
||||
|
||||
|
||||
def refresh_ext(self):
|
||||
self.ext_tree = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING)
|
||||
@@ -182,7 +181,8 @@ class ConfigModel(Model):
|
||||
except:
|
||||
print "Saving preferences to %s/.pygtktalog" % self.path
|
||||
if __debug__:
|
||||
print "m_config.py: save() Saving preferences to %s/.pygtktalog" % self.path
|
||||
print "m_config.py: save() Saving preferences to",
|
||||
print "%s/.pygtktalog" % self.path
|
||||
newIni = Ini()
|
||||
|
||||
# main section
|
||||
@@ -215,7 +215,8 @@ class ConfigModel(Model):
|
||||
success = True
|
||||
except:
|
||||
if __debug__:
|
||||
print "m_config.py: save() Cannot open config file %s for writing." % (self.path, "/.pygtktalog")
|
||||
print "m_config.py: save() Cannot open config file",
|
||||
print "%s for writing." % (self.path, "/.pygtktalog")
|
||||
success = False
|
||||
f.write(newIni.show())
|
||||
f.close()
|
||||
@@ -231,16 +232,18 @@ class ConfigModel(Model):
|
||||
for sec in parser.sections():
|
||||
if sec == 'pyGTKtalog conf':
|
||||
for opt in parser.options(sec):
|
||||
i = self.dictconf[opt]
|
||||
try:
|
||||
if self.dictconf[opt] in self.dbool:
|
||||
self.confd[self.dictconf[opt]] = parser.getboolean(sec,opt)
|
||||
self.confd[i] = parser.getboolean(sec,opt)
|
||||
elif self.dictconf[opt] in self.dstring:
|
||||
self.confd[self.dictconf[opt]] = parser.get(sec,opt)
|
||||
self.confd[i] = parser.get(sec,opt)
|
||||
else:
|
||||
self.confd[self.dictconf[opt]] = parser.getint(sec,opt)
|
||||
self.confd[i] = parser.getint(sec,opt)
|
||||
except:
|
||||
if __debug__:
|
||||
print "m_config.py: load() failed to parse option:", opt
|
||||
print "m_config.py: load() failed to parse",
|
||||
print "option:", opt
|
||||
pass
|
||||
elif sec == 'pyGTKtalog recent':
|
||||
for opt in parser.options(sec):
|
||||
@@ -248,20 +251,23 @@ class ConfigModel(Model):
|
||||
r[int(opt)] = parser.get(sec,opt)
|
||||
except:
|
||||
if __debug__:
|
||||
print "m_config.py: load() failed to parse option:", opt
|
||||
print "m_config.py: load() failed to parse",
|
||||
print "option:", opt
|
||||
pass
|
||||
elif sec == 'extensions':
|
||||
self.confd['extensions'] = {}
|
||||
for opt in parser.options(sec):
|
||||
try:
|
||||
self.confd['extensions'][opt] = parser.get(sec, opt)
|
||||
self.confd['extensions'][opt] = parser.get(sec,
|
||||
opt)
|
||||
except:
|
||||
if __debug__:
|
||||
print "m_config.py: load() failed to parse option:", opt
|
||||
print "m_config.py: load() failed to parse",
|
||||
print "option:", opt
|
||||
pass
|
||||
|
||||
for i in range(1, self.RECENT_MAX + 1):
|
||||
if r.has_key(i):
|
||||
if i in r:
|
||||
self.recent.append(r[i])
|
||||
|
||||
except:
|
||||
|
||||
@@ -101,7 +101,7 @@ FIELD_TYPES=(
|
||||
(2, 'SS', 'Signed Short'),
|
||||
(4, 'SL', 'Signed Long'),
|
||||
(8, 'SR', 'Signed Ratio')
|
||||
)
|
||||
)
|
||||
|
||||
# dictionary of main EXIF tag names
|
||||
# first element of tuple is tag name, optional second element is
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
device (cd, dvd) helper
|
||||
"""
|
||||
|
||||
import string
|
||||
import os
|
||||
|
||||
|
||||
def volname(mntp):
|
||||
"""read volume name from cd/dvd"""
|
||||
dev = mountpoint_to_dev(mntp)
|
||||
@@ -42,6 +42,7 @@ def volname(mntp):
|
||||
return b
|
||||
return None
|
||||
|
||||
|
||||
def volmount(mntp):
|
||||
"""mount device, return 'ok' or error message"""
|
||||
_in,_out,_err = os.popen3("mount %s" % mntp)
|
||||
@@ -53,6 +54,7 @@ def volmount(mntp):
|
||||
else:
|
||||
return 'ok'
|
||||
|
||||
|
||||
def volumount(mntp):
|
||||
"""mount device, return 'ok' or error message"""
|
||||
_in,_out,_err = os.popen3("umount %s" % mntp)
|
||||
@@ -65,6 +67,7 @@ def volumount(mntp):
|
||||
return error.strip()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def check_mount(dev):
|
||||
"""Refresh the entries from fstab or mount."""
|
||||
mounts = os.popen('mount')
|
||||
@@ -75,6 +78,7 @@ def check_mount(dev):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def mountpoint_to_dev(mntp):
|
||||
"""guess mountpoint from fstab"""
|
||||
fstab = open("/etc/fstab")
|
||||
@@ -89,6 +93,7 @@ def mountpoint_to_dev(mntp):
|
||||
fstab.close()
|
||||
return None
|
||||
|
||||
|
||||
def eject_cd(eject_app, cd):
|
||||
"""mount device, return 'ok' or error message"""
|
||||
if len(eject_app) > 0:
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
from xml.dom.minidom import Node
|
||||
from xml.dom import minidom
|
||||
import gzip
|
||||
import os
|
||||
from datetime import date
|
||||
|
||||
class GthumbCommentParser(object):
|
||||
|
||||
def __init__(self, image_path, image_filename):
|
||||
self.path = image_path
|
||||
self.filename = image_filename
|
||||
@@ -55,21 +55,26 @@ class GthumbCommentParser(object):
|
||||
doc = minidom.parseString(xml)
|
||||
|
||||
try:
|
||||
retval['note'] = doc.getElementsByTagName('Note').item(0).childNodes.item(0).data
|
||||
retval['note'] = doc.getElementsByTagName('Note').item(0)
|
||||
retval['note'] = retval['note'].childNodes.item(0).data
|
||||
except: retval['note'] = None
|
||||
|
||||
try:
|
||||
retval['place'] = doc.getElementsByTagName('Place').item(0).childNodes.item(0).data
|
||||
retval['place'] = doc.getElementsByTagName('Place').item(0)
|
||||
retval['place'] = retval['place'].childNodes.item(0).data
|
||||
except: retval['place'] = None
|
||||
|
||||
try:
|
||||
d = doc.getElementsByTagName('Time').item(0).childNodes.item(0).data
|
||||
d = doc.getElementsByTagName('Time').item(0).childNodes
|
||||
d = d.item(0).data
|
||||
if int(d) > 0: retval['date'] = date.fromtimestamp(int(d))
|
||||
else: retval['date'] = None
|
||||
except: retval['date'] = None
|
||||
|
||||
try:
|
||||
retval['keywords'] = doc.getElementsByTagName('Keywords').item(0).childNodes.item(0).data.split(',')
|
||||
retval['keywords'] = doc.getElementsByTagName('Keywords').item(0)
|
||||
retval['keywords'] = retval['keywords'].childNodes.item(0)
|
||||
retval['keywords'] = retval['keywords'].data.split(',')
|
||||
except: pass
|
||||
|
||||
if len(retval) > 0: return retval
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
from tempfile import gettempdir
|
||||
from shutil import move, copy
|
||||
from shutil import copy
|
||||
from os import path, mkdir
|
||||
from datetime import datetime
|
||||
|
||||
import Image
|
||||
|
||||
class Img(object):
|
||||
|
||||
def __init__(self, filename=None, base=''):
|
||||
self.root = 'images'
|
||||
self.x = 160
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import re
|
||||
import EXIF
|
||||
class ParseExif(object):
|
||||
|
||||
def __init__(self, exif_dict=None, exif_file=None):
|
||||
self.camera = None
|
||||
self.date = None
|
||||
@@ -25,6 +26,7 @@ class ParseExif(object):
|
||||
f.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
def parse(self):
|
||||
try:
|
||||
self.camera = "%s" % self.exif_dict['Image Make']
|
||||
@@ -51,11 +53,13 @@ class ParseExif(object):
|
||||
self.aperture = self.aperture.replace('.',',')
|
||||
except: pass
|
||||
|
||||
try: self.exposure_program = "%s" % self.exif_dict['EXIF ExposureProgram']
|
||||
try: self.exposure_program = "%s" % \
|
||||
self.exif_dict['EXIF ExposureProgram']
|
||||
except: pass
|
||||
|
||||
try:
|
||||
self.exposure_bias = "%s" % self.exif_dict['EXIF ExposureBiasValue']
|
||||
self.exposure_bias = "%s" % \
|
||||
self.exif_dict['EXIF ExposureBiasValue']
|
||||
if len(self.exposure_bias.split("/")) == 2:
|
||||
self.exposure_bias += '.'
|
||||
self.exposure_bias = "%.1f" % eval(self.exposure_bias)
|
||||
@@ -76,7 +80,8 @@ class ParseExif(object):
|
||||
except: pass
|
||||
|
||||
try:
|
||||
self.subject_distance = "%s" % self.exif_dict['EXIF SubjectDistance']
|
||||
self.subject_distance = "%s" % \
|
||||
self.exif_dict['EXIF SubjectDistance']
|
||||
if len(self.subject_distance.split("/")) == 2:
|
||||
self.subject_distance += '.'
|
||||
self.subject_distance = "%.3f" % eval(self.subject_distance)
|
||||
@@ -95,13 +100,18 @@ class ParseExif(object):
|
||||
|
||||
try: self.resolution = "%s" % self.exif_dict['Image XResolution']
|
||||
except: pass
|
||||
try: self.resolution = self.resolution + " x %s" % self.exif_dict['Image YResolution']
|
||||
try: self.resolution = self.resolution + " x %s" % \
|
||||
self.exif_dict['Image YResolution']
|
||||
except: pass
|
||||
try: self.resolution = self.resolution + " (%s)" % self.exif_dict['Image ResolutionUnit']
|
||||
try: self.resolution = self.resolution + " (%s)" % \
|
||||
self.exif_dict['Image ResolutionUnit']
|
||||
except: pass
|
||||
|
||||
try: self.orientation = "%s" % self.exif_dict['Image Orientation']
|
||||
except: pass
|
||||
|
||||
return (self.camera, self.date, self.aperture, self.exposure_program, self.exposure_bias, self.iso, self.focal_length, self.subject_distance, self.metering_mode, self.flash, self.light_source, self.resolution, self.orientation)
|
||||
#print self.date #self.camera, self.date, self.aperture, self.exposure_program, self.exposure_bias, self.iso, self.focal_length, self.subject_distance, self.metering_mode, self.flash, self.light_source, self.resolution, self.flash, self.orientation
|
||||
return (self.camera, self.date, self.aperture, self.exposure_program,
|
||||
self.exposure_bias, self.iso, self.focal_length,
|
||||
self.subject_distance, self.metering_mode, self.flash,
|
||||
self.light_source, self.resolution, self.orientation)
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ from utils import EXIF
|
||||
import Image
|
||||
|
||||
class Thumbnail(object):
|
||||
def __init__(self, filename=None, x=160, y=160, root='thumbnails', base=''):
|
||||
|
||||
def __init__(self, filename=None, x=160, y=160,
|
||||
root='thumbnails', base=''):
|
||||
self.root = root
|
||||
self.x = x
|
||||
self.y = y
|
||||
@@ -48,16 +50,17 @@ class Thumbnail(object):
|
||||
try:
|
||||
exif = EXIF.process_file(f)
|
||||
f.close()
|
||||
if exif.has_key('JPEGThumbnail'):
|
||||
if 'JPEGThumbnail' in exif:
|
||||
thumbnail = exif['JPEGThumbnail']
|
||||
f = open(filepath,'wb')
|
||||
f.write(thumbnail)
|
||||
f.close()
|
||||
if exif.has_key('Image Orientation'):
|
||||
if 'Image Orientation' in exif:
|
||||
orientation = exif['Image Orientation'].values[0]
|
||||
if orientation > 1:
|
||||
# TODO: replace silly datetime function with tempfile
|
||||
t = path.join(gettempdir(), "thumb%d.jpg" % datetime.now().microsecond)
|
||||
ms = datetime.now().microsecond
|
||||
t = path.join(gettempdir(), "thumb%d.jpg" % ms)
|
||||
im_in = Image.open(filepath)
|
||||
im_out = None
|
||||
if orientation == 8:
|
||||
@@ -77,10 +80,14 @@ class Thumbnail(object):
|
||||
im_out = im_in.transpose(Image.FLIP_TOP_BOTTOM)
|
||||
elif orientation == 5:
|
||||
# Mirrored horizontal then rotated 90 CCW
|
||||
im_out = im_in.transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.ROTATE_90)
|
||||
op = Image.FLIP_LEFT_RIGHT
|
||||
rot = Image.ROTATE_90
|
||||
im_out = im_in.transpose(op).transpose(rot)
|
||||
elif orientation == 7:
|
||||
# Mirrored horizontal then rotated 90 CW
|
||||
im_out = im_in.transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.ROTATE_270)
|
||||
op = Image.FLIP_LEFT_RIGHT
|
||||
rot = Image.ROTATE_270
|
||||
im_out = im_in.transpose(op).transpose(rot)
|
||||
|
||||
if im_out:
|
||||
im_out.save(t, 'JPEG')
|
||||
@@ -169,17 +176,19 @@ class Thumbnail(object):
|
||||
self.x1 = int(float(self.y) * self.y / self.x)
|
||||
if float(self.y) * self.y / self.x - self.x1 > 0.49:
|
||||
self.x1 += 1
|
||||
imt = im.resize(((int(x/(y/float(self.y))),self.y)),Image.ANTIALIAS)
|
||||
imt = im.resize(((int(x/(y/float(self.y))), self.y)),
|
||||
Image.ANTIALIAS)
|
||||
elif x/self.x==y/self.y:
|
||||
# aspect ratio ok
|
||||
imt = im.resize((self.x, self.y), Image.ANTIALIAS)
|
||||
else:
|
||||
imt = im.resize((self.x,int(y/(x/float(self.x)))), 1)
|
||||
imt = im.resize((self.x, int(y/(x/float(self.x)))), 1)
|
||||
else:
|
||||
# portrait
|
||||
if factor:
|
||||
if y>self.x:
|
||||
imt = im.resize(((int(x/(y/float(self.x))),self.x)),Image.ANTIALIAS)
|
||||
imt = im.resize(((int(x/(y/float(self.x))),self.x)),
|
||||
Image.ANTIALIAS)
|
||||
else:
|
||||
imt = im
|
||||
else:
|
||||
@@ -191,7 +200,8 @@ class Thumbnail(object):
|
||||
# aspect ratio ok
|
||||
imt = im.resize((self.x1,self.y),Image.ANTIALIAS)
|
||||
else:
|
||||
imt = im.resize(((int(x/(y/float(self.y))),self.y)),Image.ANTIALIAS)
|
||||
imt = im.resize(((int(x/(y/float(self.y))), self.y)),
|
||||
Image.ANTIALIAS)
|
||||
return imt
|
||||
else:
|
||||
return im
|
||||
|
||||
@@ -29,6 +29,7 @@ import utils.globals
|
||||
class ConfigView(View):
|
||||
"""Preferences window from glade file """
|
||||
GLADE = os.path.join(utils.globals.GLADE_DIR, "config.glade")
|
||||
|
||||
def __init__(self, ctrl):
|
||||
View.__init__(self, ctrl, self.GLADE)
|
||||
return
|
||||
|
||||
@@ -31,6 +31,7 @@ class Qst(object):
|
||||
if "OK" button pressed, return "True"
|
||||
"Cancel" button return "False"
|
||||
"""
|
||||
|
||||
def __init__(self, title="", message="", secondarymsg=""):
|
||||
self.dialog = gtk.MessageDialog(
|
||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
@@ -40,6 +41,7 @@ class Qst(object):
|
||||
)
|
||||
self.dialog.set_title(title)
|
||||
self.dialog.format_secondary_text(secondarymsg)
|
||||
|
||||
def run(self):
|
||||
retval = self.dialog.run()
|
||||
self.dialog.destroy()
|
||||
@@ -49,6 +51,7 @@ class Qst(object):
|
||||
|
||||
class Inf(object):
|
||||
"""Show simple dialog for notices"""
|
||||
|
||||
def __init__(self, title="", message="", secondarymsg=""):
|
||||
self.dialog = gtk.MessageDialog(
|
||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
@@ -58,14 +61,17 @@ class Inf(object):
|
||||
)
|
||||
self.dialog.set_title(title)
|
||||
self.dialog.format_secondary_text(secondarymsg)
|
||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
||||
self.dialog.connect('response',
|
||||
lambda dialog, response: self.ret(response))
|
||||
self.dialog.show()
|
||||
|
||||
def ret(self,result):
|
||||
self.dialog.destroy()
|
||||
return True
|
||||
|
||||
class Wrn(object):
|
||||
"""Show simple dialog for warnings"""
|
||||
|
||||
def __init__(self, title="", message="", secondarymsg=""):
|
||||
self.dialog = gtk.MessageDialog(
|
||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
@@ -75,31 +81,37 @@ class Wrn(object):
|
||||
)
|
||||
self.dialog.set_title(title)
|
||||
self.dialog.format_secondary_text(secondarymsg)
|
||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
||||
self.dialog.connect('response',
|
||||
lambda dialog, response: self.ret(response))
|
||||
self.dialog.show()
|
||||
|
||||
def ret(self,result):
|
||||
self.dialog.destroy()
|
||||
return True
|
||||
|
||||
class Err(object):
|
||||
"""Show simple dialog for errors"""
|
||||
|
||||
def __init__(self, title="", message="", secondarymsg=""):
|
||||
self.dialog = gtk.MessageDialog(
|
||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
type = gtk.MESSAGE_ERROR,
|
||||
buttons = gtk.BUTTONS_CLOSE,
|
||||
message_format = message,
|
||||
)
|
||||
message_format = message)
|
||||
|
||||
self.dialog.set_title(title)
|
||||
self.dialog.format_secondary_text(secondarymsg)
|
||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
||||
self.dialog.connect('response',
|
||||
lambda dialog, response: self.ret(response))
|
||||
self.dialog.run()
|
||||
|
||||
def ret(self,result):
|
||||
self.dialog.destroy()
|
||||
return True
|
||||
|
||||
class Abt(object):
|
||||
"""Show simple about dialog"""
|
||||
|
||||
def __init__(self, name=None, ver="", title="", authors=[],licence=""):
|
||||
self.dialog = gtk.AboutDialog()
|
||||
self.dialog.set_title(title)
|
||||
@@ -107,11 +119,13 @@ class Abt(object):
|
||||
self.dialog.set_license(licence)
|
||||
self.dialog.set_name(name)
|
||||
self.dialog.set_authors(authors)
|
||||
self.dialog.connect('response', lambda dialog, response: self.dialog.destroy())
|
||||
self.dialog.connect('response',
|
||||
lambda dialog, response: self.dialog.destroy())
|
||||
self.dialog.show()
|
||||
|
||||
class InputDiskLabel(object):
|
||||
"""Sepcific dialog for quering user for a disc label"""
|
||||
|
||||
def __init__(self, label=""):
|
||||
self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade")
|
||||
self.label = ""
|
||||
@@ -131,6 +145,7 @@ class InputDiskLabel(object):
|
||||
|
||||
class InputNewName(object):
|
||||
"""Sepcific dialog for quering user for a disc label"""
|
||||
|
||||
def __init__(self, name=""):
|
||||
self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade")
|
||||
self.label = ""
|
||||
@@ -159,7 +174,9 @@ class PointDirectoryToAdd(object):
|
||||
self.volname.set_text(volname)
|
||||
self.directory = self.gladexml.get_widget("directory")
|
||||
self.directory.set_text(dirname)
|
||||
self.gladexml.signal_autoconnect({"on_browse_activate":self.show_dirchooser,"on_browse_clicked":self.show_dirchooser})
|
||||
sigs = {"on_browse_activate":self.show_dirchooser,
|
||||
"on_browse_clicked":self.show_dirchooser}
|
||||
self.gladexml.signal_autoconnect(sigs)
|
||||
|
||||
def show_dirchooser(self,widget):
|
||||
"""dialog for point the mountpoint"""
|
||||
@@ -170,9 +187,7 @@ class PointDirectoryToAdd(object):
|
||||
gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK
|
||||
)
|
||||
)
|
||||
gtk.RESPONSE_OK))
|
||||
|
||||
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
@@ -190,8 +205,11 @@ class PointDirectoryToAdd(object):
|
||||
ch = True
|
||||
result = dialog.run()
|
||||
while ch:
|
||||
if result == gtk.RESPONSE_OK and (self.volname.get_text()=='' or self.directory.get_text() == ''):
|
||||
a = Err("Error - pyGTKtalog","There are fields needed to be filled.","Cannot add directory without path and disc label.")
|
||||
if result == gtk.RESPONSE_OK and (self.volname.get_text()=='' or \
|
||||
self.directory.get_text() == ''):
|
||||
a = Err("Error - pyGTKtalog",
|
||||
"There are fields needed to be filled.",
|
||||
"Cannot add directory without path and disc label.")
|
||||
ch = True
|
||||
result = dialog.run()
|
||||
else:
|
||||
@@ -215,9 +233,7 @@ class ChooseDBFilename(object):
|
||||
gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE,
|
||||
gtk.RESPONSE_OK
|
||||
)
|
||||
)
|
||||
gtk.RESPONSE_OK))
|
||||
|
||||
self.dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
|
||||
self.dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
@@ -255,7 +271,8 @@ class ChooseDBFilename(object):
|
||||
pass
|
||||
|
||||
class LoadDBFile(object):
|
||||
"""Specific class for displaying openFile dialog. It has veryfication for file existence."""
|
||||
"""Specific class for displaying openFile dialog. It has veryfication
|
||||
for file existence."""
|
||||
|
||||
URI="file://"+os.path.abspath(os.path.curdir)
|
||||
|
||||
@@ -267,9 +284,7 @@ class LoadDBFile(object):
|
||||
gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK
|
||||
)
|
||||
)
|
||||
gtk.RESPONSE_OK))
|
||||
|
||||
self.dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
|
||||
@@ -310,7 +325,9 @@ class LoadDBFile(object):
|
||||
self.dialog.destroy()
|
||||
return filename
|
||||
except:
|
||||
a = Err("Error - pyGTKtalog","File doesn't exist.","The file that you choose does not exist. Choose another one, or cancel operation.")
|
||||
a = Err("Error - pyGTKtalog","File doesn't exist.",
|
||||
"The file that you choose does not exist." + \
|
||||
" Choose another one, or cancel operation.")
|
||||
ch = True
|
||||
res, filename = self.show_dialog()
|
||||
|
||||
@@ -329,15 +346,15 @@ class LoadImageFile(object):
|
||||
gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK
|
||||
)
|
||||
)
|
||||
gtk.RESPONSE_OK))
|
||||
self.dialog.set_select_multiple(multiple)
|
||||
self.dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
|
||||
f = gtk.FileFilter()
|
||||
f.set_name("All Images")
|
||||
for i in ['*.jpg', '*.jpeg', '*.gif', '*.png', '*.tif', '*.tiff', '*.tga', '*.pcx', '*.bmp', '*.xbm', '*.xpm', '*.jp2', '*.jpx', '*.pnm']:
|
||||
for i in ['*.jpg', '*.jpeg', '*.gif', '*.png', '*.tif', '*.tiff',
|
||||
'*.tga', '*.pcx', '*.bmp', '*.xbm', '*.xpm', '*.jp2',
|
||||
'*.jpx', '*.pnm']:
|
||||
f.add_pattern(i)
|
||||
self.dialog.add_filter(f)
|
||||
f = gtk.FileFilter()
|
||||
@@ -385,6 +402,7 @@ class LoadImageFile(object):
|
||||
|
||||
class StatsDialog(object):
|
||||
"""Sepcific dialog for display stats"""
|
||||
|
||||
def __init__(self, values={}):
|
||||
self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade")
|
||||
self.values = values
|
||||
@@ -393,7 +411,7 @@ class StatsDialog(object):
|
||||
gladexml = gtk.glade.XML(self.gladefile, "statDialog")
|
||||
dialog = gladexml.get_widget("statDialog")
|
||||
|
||||
if self.values.has_key('discs'):
|
||||
if 'discs' in self.values:
|
||||
entry = gladexml.get_widget("discs_entry")
|
||||
entry.set_text(str(self.values['discs']))
|
||||
else:
|
||||
@@ -402,7 +420,7 @@ class StatsDialog(object):
|
||||
label.hide()
|
||||
entry.hide()
|
||||
|
||||
if self.values.has_key('dirs'):
|
||||
if 'dirs' in self.values:
|
||||
entry = gladexml.get_widget("dirs_entry")
|
||||
entry.set_text(str(self.values['dirs']))
|
||||
else:
|
||||
@@ -411,11 +429,11 @@ class StatsDialog(object):
|
||||
label.hide()
|
||||
entry.hide()
|
||||
|
||||
if self.values.has_key('files'):
|
||||
if 'files' in self.values:
|
||||
entry = gladexml.get_widget("files_entry")
|
||||
entry.set_text(str(self.values['files']))
|
||||
|
||||
if self.values.has_key('size'):
|
||||
if 'size' in self.values:
|
||||
entry = gladexml.get_widget("size_entry")
|
||||
entry.set_text(str(self.values['size']))
|
||||
|
||||
@@ -425,8 +443,28 @@ class StatsDialog(object):
|
||||
return entry.get_text()
|
||||
return None
|
||||
|
||||
class TagsDialog(object):
|
||||
"""Sepcific dialog for display stats"""
|
||||
|
||||
def __init__(self):
|
||||
self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade")
|
||||
|
||||
def run(self):
|
||||
gladexml = gtk.glade.XML(self.gladefile, "tagsDialog")
|
||||
dialog = gladexml.get_widget("tagsDialog")
|
||||
|
||||
entry = gladexml.get_widget("tag_entry1")
|
||||
|
||||
result = dialog.run()
|
||||
|
||||
dialog.destroy()
|
||||
if result == gtk.RESPONSE_OK:
|
||||
return entry.get_text()
|
||||
return None
|
||||
|
||||
class EditDialog(object):
|
||||
"""Sepcific dialog for display stats"""
|
||||
|
||||
def __init__(self, values={}):
|
||||
self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade")
|
||||
self.values = values
|
||||
@@ -440,12 +478,12 @@ class EditDialog(object):
|
||||
description = gladexml.get_widget("description_text")
|
||||
note = gladexml.get_widget("note_text")
|
||||
|
||||
if self.values.has_key('description'):
|
||||
if 'description' in self.values:
|
||||
buff = gtk.TextBuffer()
|
||||
buff.set_text(str(self.values['description']))
|
||||
description.set_buffer(buff)
|
||||
|
||||
if self.values.has_key('note'):
|
||||
if 'note' in self.values:
|
||||
buff = gtk.TextBuffer()
|
||||
buff.set_text(str(self.values['note']))
|
||||
note.set_buffer(buff)
|
||||
|
||||
@@ -22,15 +22,12 @@
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
import os.path
|
||||
|
||||
import gtk
|
||||
|
||||
import utils.globals
|
||||
|
||||
class ImageView(object):
|
||||
"""simple image viewer. no scaling, no zooming, no rotating.
|
||||
simply show stupid image"""
|
||||
|
||||
def __init__(self, image_filename):
|
||||
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
image = gtk.Image()
|
||||
|
||||
Reference in New Issue
Block a user