[go: up one dir, main page]

Menu

[r533]: / mcomix / preferences.py  Maximize  Restore  History

Download this file

117 lines (110 with data), 4.1 kB

  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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"""preferences.py - Contains the preferences and the functions to read and write them."""
import os
import cPickle
from mcomix import constants
# All the preferences are stored here.
prefs = {
'comment extensions': constants.ACCEPTED_COMMENT_EXTENSIONS,
'auto load last file': False,
'page of last file': 1,
'path to last file': '',
'number of key presses before page turn': 3,
'auto open next archive': True,
'auto open next directory': True,
'sort by': constants.SORT_NAME,
'sort descending': False,
'bg colour': (5000, 5000, 5000),
'thumb bg colour': (5000, 5000, 5000),
'smart bg': False,
'smart thumb bg': False,
'thumbnail bg uses main colour': False,
'checkered bg for transparent images': True,
'cache': True,
'stretch': False,
'default double page': False,
'default fullscreen': False,
'zoom mode': constants.ZOOM_MODE_BEST,
'default manga mode': False,
'lens magnification': 2,
'lens size': 200,
'virtual double page for fitting images': constants.SHOW_DOUBLE_AS_ONE_TITLE | \
constants.SHOW_DOUBLE_AS_ONE_WIDE,
'double step in double page mode': True,
'show page numbers on thumbnails': True,
'thumbnail size': 80,
'create thumbnails': True,
'delay thumbnails': True,
'archive thumbnail as icon' : False,
'number of pixels to scroll per key event': 50,
'number of pixels to scroll per mouse wheel event': 50,
'slideshow delay': 3000,
'slideshow can go to next archive': True,
'number of pixels to scroll per slideshow event': 50,
'smart space scroll': True,
'invert smart scroll': False,
'flip with wheel': True,
'store recent file info': True,
'hide all': False,
'hide all in fullscreen': True,
'stored hide all values': (True, True, True, True, True),
'path of last browsed in filechooser': constants.HOME_DIR,
'last filter in main filechooser': 0,
'last filter in library filechooser': 1,
'show menubar': True,
'previous quit was quit and save': False,
'show scrollbar': True,
'show statusbar': True,
'show toolbar': True,
'show thumbnails': True,
'rotation': 0,
'auto rotate from exif': True,
'vertical flip': False,
'horizontal flip': False,
'keep transformation': False,
'replace bookmark response': None,
'brightness': 1.0,
'contrast': 1.0,
'saturation': 1.0,
'sharpness': 1.0,
'auto contrast': False,
'max pages to cache': 7,
'window height': 600,
'window width': 500,
'library cover size': 125,
'auto add books into collections': True,
'last library collection': None,
'lib window height': 600,
'lib window width': 500,
'lib sort key': constants.SORT_PATH,
'lib sort order': constants.SORT_ASCENDING,
'language': 'auto',
'statusbar fields': constants.STATUS_PAGE | constants.STATUS_RESOLUTION | \
constants.STATUS_PATH | constants.STATUS_FILENAME
}
def read_preferences_file():
"""Read preferences data from disk."""
if os.path.isfile(constants.PREFERENCE_PICKLE_PATH):
config = None
try:
config = open(constants.PREFERENCE_PICKLE_PATH, 'rb')
version = cPickle.load(config)
old_prefs = cPickle.load(config)
config.close()
except Exception:
# Gettext might not be installed yet at this point.
print ('! Corrupt preferences file "%s", deleting...' %
constants.PREFERENCE_PICKLE_PATH)
if config is not None:
config.close()
os.remove(constants.PREFERENCE_PICKLE_PATH)
else:
for key in old_prefs:
if key in prefs:
prefs[key] = old_prefs[key]
def write_preferences_file():
"""Write preference data to disk."""
config = open(constants.PREFERENCE_PICKLE_PATH, 'wb')
cPickle.dump(constants.VERSION, config, cPickle.HIGHEST_PROTOCOL)
cPickle.dump(prefs, config, cPickle.HIGHEST_PROTOCOL)
config.close()
# vim: expandtab:sw=4:ts=4