Example #1
0
 def refresh_installed_themes(self, userdir):
     installed_path = listdir(userdir + "/lotc-themes")
     installed_themes = []
     for item in installed_path:
         if item == "active-theme":
             installed_themes.append({
                 "name": "active-theme",
                 "location": "active-theme"
             })
         else:
             if exists(userdir + "/lotc-themes/" + item + "/manifest.xml"):
                 theme_name = Helper.parse_manifest(userdir +
                                                    "/lotc-themes/" +
                                                    item)["name"]
             else:
                 theme_name = "Default LibreOffice"
             installed_themes.append({"name": theme_name, "location": item})
     # print(installed_themes)
     return installed_themes
Example #2
0
 def showDetailDialog(self, theme_name):
     try:
         # path substitution instance
         ps = self.ctx.getServiceManager().createInstanceWithContext(
             'com.sun.star.util.PathSubstitution', self.ctx)
         # get user profile dir ($HOME/.config/libreoffice/4/user/)
         userdir = uno.fileUrlToSystemPath(
             ps.getSubstituteVariableValue("$(user)"))
         for theme in self.installed_themes:
             if theme["name"] == theme_name:
                 theme_dir = userdir + "/lotc-themes/" + theme["location"]
                 break
         theme_data = Helper.parse_manifest(theme_dir)
         if theme_data == None:
             theme_data = {
                 "author":
                 "LibreOffice",
                 "description":
                 "LibreOffice default theme",
                 "name":
                 theme_name,
                 "screenshots":
                 ["file://{}/program/intro.png".format(theme_dir)]
             }
         theme_data["theme_location"] = theme_dir
         theme_data["current_active"] = self.active_theme
         detailDialog = DetailsDialog(ctx=self.ctx, theme_data=theme_data)
     except Exception as e:
         print(e)
         traceback.print_exc()
         exit(255)
     new_active_theme = detailDialog.showDialog()
     if self.active_theme != new_active_theme:
         self.active_theme = new_active_theme
     self.installed_themes = self.refresh_installed_themes(userdir)
     self.alter_installed_themes(userdir)
     # clear first
     self.clear_theme_list()
     # then generate
     for theme in self.installed_themes:
         self.create_new_component(theme, self.active_theme)