コード例 #1
0
    def load(self):    
        # load user theme.

        for theme_file in os.listdir(get_user_theme_dir()):
            full_theme_file = os.path.join(get_user_theme_dir(), theme_file)
            if full_theme_file.endswith(".ini") and os.path.isfile(full_theme_file):
                theme_file_object = ThemeFile(full_theme_file)
                self.user_themes[theme_file_object.location] = theme_file_object

        # load system themes.        
        for theme_file in os.listdir(get_system_theme_dir()):        
            full_theme_file = os.path.join(get_system_theme_dir(), theme_file)
            if full_theme_file.endswith(".ini") and os.path.isfile(full_theme_file):
                theme_file_object = ThemeFile(full_theme_file, is_system_theme = True)
                self.system_themes[theme_file_object.location] = theme_file_object
コード例 #2
0
 def get_untitled_theme(self):
     untitled_path = os.path.join(get_user_theme_dir(), "untitled.ini")
     
     if not os.path.exists(untitled_path):
         return None
     
     return ThemeFile(untitled_path)
コード例 #3
0
 def create_new_theme(self, name, copy_theme=None):
     new_theme_path = os.path.join(get_user_theme_dir(), "%s.ini" % name)
     new_theme = ThemeFile(new_theme_path)
     if copy_theme:
         new_theme.copy_theme(copy_theme)
     new_theme.set_default_name(name)    
     new_theme.set_locale_name(name)
     new_theme.save()    
     return new_theme
コード例 #4
0
 def untitled_theme(self, copy_theme=None):
     untitled_path = os.path.join(get_user_theme_dir(), "untitled.ini")
     untitled_theme = ThemeFile(untitled_path)
     
     if copy_theme:
         untitled_theme.copy_theme(copy_theme)
     
     if not os.path.exists(untitled_path):
         untitled_theme.set_default_name("untitled")    
         untitled_theme.set_locale_name(_("Untitled"))
         untitled_theme.save()    
     
     return untitled_theme
コード例 #5
0
    def get_user_themes(self):
        themes = []
        untitled_theme = ThemeFile(os.path.join(get_user_theme_dir(), "untitled.ini"))
        themes.append(untitled_theme)
        
        for item in self.user_themes.values():
            if item.get_default_name() == "untitled":
                continue
            themes.append(item)

        if not themes:
            return [self.untitled_theme(self.get_default_theme())]
        return themes
コード例 #6
0
 def delete_theme(self, name):
     theme_path = os.path.join(get_user_theme_dir(), "%s.ini" % name)
     os.remove(theme_path)
コード例 #7
0
 def rename_theme(self, name, new_name):
     theme_path = os.path.join(get_user_theme_dir(), "%s.ini" % name)
     theme = ThemeFile(theme_path)
     theme.set_locale_name(new_name)
     theme.save()
コード例 #8
0
    def is_theme_exist(self, name):
        theme_path = os.path.join(get_user_theme_dir(), "%s.ini" % name)
        if os.path.exists(theme_path):
            return True

        return False