from gi.repository import Gdk
import logging
import pprint
+import ConfigParser
+import StringIO
from wand.image import Image
from wand.color import Color
return (max_width, max_height)
+#-------------------------------------------------------------------------
+def get_title_from_ini(ini_file):
+
+ log.debug("Reading %r ...", ini_file)
+ if not os.path.isfile(ini_file):
+ return None
+
+ f = None
+ content = None
+ try:
+ f = open(ini_file)
+ content = f.read()
+ finally:
+ f.close()
+
+ if not content:
+ return None
+
+ content = "[__config__]\n" + content
+ ini_fp = StringIO.StringIO(content)
+ config = ConfigParser.RawConfigParser()
+ try:
+ config.readfp(ini_fp)
+ except Exception as e:
+ log.error("Got a %s on evaluating %r: %s", e.__class__.__name__,
+ ini_file, e)
+ return None
+
+ if config.has_section('__config__') and config.has_option('__config__', 'title'):
+ ini_title = config.get('__config__', 'title').strip()
+ if ini_title:
+ return ini_title
+
+ return None
+
#-------------------------------------------------------------------------
bg_dirs = [
#'/home/fbrehm/Bilder/Wallpaper',
log.debug("New title from comment: %r", title)
break
+inf_file = re.sub(r'\.[^\.]*$', '.inf', wpaper)
+if os .path.exists(inf_file):
+ inf_title = get_title_from_ini(inf_file)
+ if inf_title:
+ inf_title = inf_title.strip()
+ if inf_title:
+ inf_title = inf_title.decode('utf-8')
+ log.debug("Got title %r from %r.", inf_title, inf_file)
+ title = inf_title
+
(screen_width, screen_height) = get_max_monitor_geometry()
new_height = screen_height
new_width = int(float(old_img.width) / float(old_img.height) * float(screen_height))