Exemplo n.º 1
0
 def showDialog(self):
     self.DialogContainer.setVisible(True)
     self.DialogContainer.createPeer(self.Toolkit, None)
     Helper.prepare_new_install(self.ctx)
     # get os env
     self.register_new_item(self.ctx)
     self.DialogContainer.execute()
Exemplo n.º 2
0
 def showDialog(self):
     self.DialogContainer.setVisible(True)
     self.DialogContainer.createPeer(self.Toolkit, None)
     res = Helper.prepare_new_install(self.ctx)
     if str(res) == "SNAP":
         self.messageBox("You're running from snap.\nPreparation for snap is required.\n Close your LibreOffice and run {}/lotc-modify-snap.sh via terminal.".format(getenv("HOME")), "Snap preparation required", MsgType=INFOBOX)
     # get os env
     self.register_new_item(self.ctx)
     self.DialogContainer.execute()
Exemplo n.º 3
0
 def alter_installed_themes(self, userdir):
     for theme in self.installed_themes:
         if theme["name"] == "active-theme":
             if exists(userdir + "/lotc-themes/active-theme/manifest.xml"):
                 self.active_theme = Helper.parse_manifest(userdir + "/lotc-themes/active-theme")["name"]
             else:
                 self.active_theme = "Default LibreOffice"
             print("remove active-theme from list")
             self.installed_themes.remove(theme)
             break
Exemplo n.º 4
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
Exemplo n.º 5
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)