~flimm/epidermis/icon-theme-bugfix

« back to all changes in this revision

Viewing changes to epidermis/pigments/theme_preview.py

  • Committer: David D Lowe
  • Date: 2011-04-25 16:03:53 UTC
  • Revision ID: daviddlowe.flimm@gmail.com-20110425160353-jxt4biv1xuvy8xij
Check that theme exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
    themePath = os.path.normpath(os.path.abspath(themePath))
86
86
    split = os.path.split(themePath)
87
87
    
88
 
    with _ThemeNameCollisionResolver(themePath) as theme:
 
88
    with _ThemeNameCollisionResolver(themePath, "metacity") as theme:
89
89
        
90
90
        # Set default GTK and Icon theme to keep consistent results
91
91
        settings = gtk.settings_get_default()
329
329
    and destroyed after use.
330
330
    """
331
331
    
332
 
    def __init__(self, theme_path):
 
332
    def __init__(self, theme_path, theme_type=None):
333
333
        self._theme_path = os.path.normpath(os.path.abspath(theme_path))
 
334
        is_gtk = os.path.exists(os.path.join(self._theme_path, "gtk-2.0/gtkrc"))
 
335
        is_metacity = os.path.exists(os.path.join(self._theme_path, "metacity-1"))
 
336
        if not is_gtk and not is_metacity:
 
337
            raise(Exception("Not a Metacity or GTK theme"))
 
338
        if theme_type == "metacity" and not is_metacity:
 
339
            raise(Exception("Not a Metacity theme"))
 
340
        if theme_type == "gtk" and not is_gtk:
 
341
            raise(Exception("Not a GTK theme"))
334
342
    
335
343
    def __enter__(self):
336
344
        # Find theme and create a symbolic link in ~/.themes if necessary