Update ConfigParser save code for Python 3
Thomas Ross
3 years ago
1496 | 1496 | def save_settings(self): |
1497 | 1497 | conf = configparser.ConfigParser(interpolation=None) |
1498 | 1498 | conf.add_section("window") |
1499 | conf.set("window", "w", self.window.get_allocation().width) | |
1500 | conf.set("window", "h", self.window.get_allocation().height) | |
1501 | conf.set("window", "toolbar", self.toolbar_show) | |
1502 | conf.set("window", "statusbar", self.statusbar_show) | |
1503 | conf.set("window", "thumbpane", self.thumbpane_show) | |
1499 | conf.set("window", "w", str(self.window.get_allocation().width)) | |
1500 | conf.set("window", "h", str(self.window.get_allocation().height)) | |
1501 | conf.set("window", "toolbar", str(self.toolbar_show)) | |
1502 | conf.set("window", "statusbar", str(self.statusbar_show)) | |
1503 | conf.set("window", "thumbpane", str(self.thumbpane_show)) | |
1504 | 1504 | conf.add_section("prefs") |
1505 | conf.set("prefs", "simple-bgcolor", self.simple_bgcolor) | |
1506 | conf.set("prefs", "bgcolor-red", self.bgcolor.red) | |
1507 | conf.set("prefs", "bgcolor-green", self.bgcolor.green) | |
1508 | conf.set("prefs", "bgcolor-blue", self.bgcolor.blue) | |
1509 | conf.set("prefs", "open_all", self.open_all_images) | |
1510 | conf.set("prefs", "hidden", self.open_hidden_files) | |
1511 | conf.set("prefs", "use_last_dir", self.use_last_dir) | |
1505 | conf.set("prefs", "simple-bgcolor", str(self.simple_bgcolor)) | |
1506 | conf.set("prefs", "bgcolor-red", str(self.bgcolor.red)) | |
1507 | conf.set("prefs", "bgcolor-green", str(self.bgcolor.green)) | |
1508 | conf.set("prefs", "bgcolor-blue", str(self.bgcolor.blue)) | |
1509 | conf.set("prefs", "open_all", str(self.open_all_images)) | |
1510 | conf.set("prefs", "hidden", str(self.open_hidden_files)) | |
1511 | conf.set("prefs", "use_last_dir", str(self.use_last_dir)) | |
1512 | 1512 | conf.set("prefs", "last_dir", self.last_dir) |
1513 | 1513 | conf.set("prefs", "fixed_dir", self.fixed_dir) |
1514 | conf.set("prefs", "open_mode", self.open_mode) | |
1515 | conf.set("prefs", "last_mode", self.last_mode) | |
1516 | conf.set("prefs", "listwrap_mode", self.listwrap_mode) | |
1517 | conf.set("prefs", "slideshow_delay", int(self.slideshow_delay)) | |
1518 | conf.set("prefs", "slideshow_random", self.slideshow_random) | |
1519 | conf.set("prefs", "zoomquality", self.zoomvalue) | |
1520 | conf.set("prefs", "quality_save", int(self.quality_save)) | |
1521 | conf.set("prefs", "disable_screensaver", self.disable_screensaver) | |
1522 | conf.set("prefs", "slideshow_in_fullscreen", self.slideshow_in_fullscreen) | |
1523 | conf.set("prefs", "confirm_delete", self.confirm_delete) | |
1524 | conf.set("prefs", "preloading_images", self.preloading_images) | |
1525 | conf.set("prefs", "savemode", self.savemode) | |
1526 | conf.set("prefs", "start_in_fullscreen", self.start_in_fullscreen) | |
1527 | conf.set("prefs", "thumbsize", self.thumbnail_size) | |
1528 | conf.set("prefs", "screenshot_delay", self.screenshot_delay) | |
1514 | conf.set("prefs", "open_mode", str(self.open_mode)) | |
1515 | conf.set("prefs", "last_mode", str(self.last_mode)) | |
1516 | conf.set("prefs", "listwrap_mode", str(self.listwrap_mode)) | |
1517 | conf.set("prefs", "slideshow_delay", str(int(self.slideshow_delay))) | |
1518 | conf.set("prefs", "slideshow_random", str(self.slideshow_random)) | |
1519 | conf.set("prefs", "zoomquality", str(self.zoomvalue)) | |
1520 | conf.set("prefs", "quality_save", str(int(self.quality_save))) | |
1521 | conf.set("prefs", "disable_screensaver", str(self.disable_screensaver)) | |
1522 | conf.set("prefs", "slideshow_in_fullscreen", str(self.slideshow_in_fullscreen)) | |
1523 | conf.set("prefs", "confirm_delete", str(self.confirm_delete)) | |
1524 | conf.set("prefs", "preloading_images", str(self.preloading_images)) | |
1525 | conf.set("prefs", "savemode", str(self.savemode)) | |
1526 | conf.set("prefs", "start_in_fullscreen", str(self.start_in_fullscreen)) | |
1527 | conf.set("prefs", "thumbsize", str(self.thumbnail_size)) | |
1528 | conf.set("prefs", "screenshot_delay", str(self.screenshot_delay)) | |
1529 | 1529 | conf.add_section("actions") |
1530 | conf.set("actions", "num_actions", len(self.action_names)) | |
1530 | conf.set("actions", "num_actions", str(len(self.action_names))) | |
1531 | 1531 | for i in range(len(self.action_names)): |
1532 | 1532 | conf.set("actions", "names[" + str(i) + "]", self.action_names[i]) |
1533 | 1533 | conf.set("actions", "commands[" + str(i) + "]", self.action_commands[i]) |
1534 | 1534 | conf.set("actions", "shortcuts[" + str(i) + "]", self.action_shortcuts[i]) |
1535 | conf.set("actions", "batch[" + str(i) + "]", self.action_batch[i]) | |
1535 | conf.set("actions", "batch[" + str(i) + "]", str(self.action_batch[i])) | |
1536 | 1536 | conf.add_section("recent") |
1537 | conf.set("recent", "num_recent", len(self.recentfiles)) | |
1537 | conf.set("recent", "num_recent", str(len(self.recentfiles))) | |
1538 | 1538 | for i in range(len(self.recentfiles)): |
1539 | conf.set("recent", "num[" + str(i) + "]", len(self.recentfiles[i])) | |
1539 | conf.set("recent", "num[" + str(i) + "]", str(len(self.recentfiles[i]))) | |
1540 | 1540 | conf.set("recent", "urls[" + str(i) + ",0]", self.recentfiles[i]) |
1541 | 1541 | if not os.path.exists(self.config_dir): |
1542 | 1542 | os.makedirs(self.config_dir) |