示例#1
0
 def on_help_clicked(self, button):
     model, treeiter = self.tree.get_selection().get_selected()
     if treeiter is not None:
         logging.info("Open welcome.htm for %s if available",
                      model[treeiter][1])
         welcome_file = model[treeiter][5]
         if welcome_file and os.path.isfile(welcome_file):
             uri_path = pathlib.Path(welcome_file).as_uri()
             logging.info("opening " + uri_path)
             w = WelcomeView(self, uri_path, model[treeiter][3])
             w.run()
             w.destroy()
         else:
             logging.info("welcome.htm not available")
示例#2
0
 def on_install_clicked(self, button):
     logging.info("Installing keyboard")
     try:
         install_kmp(self.kmpfile, self.online, language=self.language)
         if self.viewwindow:
             self.viewwindow.refresh_installed_kmp()
         keyboardid = os.path.basename(os.path.splitext(self.kmpfile)[0])
         welcome_file = os.path.join(user_keyboard_dir(keyboardid),
                                     "welcome.htm")
         if os.path.isfile(welcome_file):
             uri_path = pathlib.Path(welcome_file).as_uri()
             logging.debug(uri_path)
             w = WelcomeView(self, uri_path, self.kbname, True)
             w.run()
             w.destroy()
         else:
             dialog = Gtk.MessageDialog(
                 self, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK,
                 _("Keyboard {name} installed").format(name=self.kbname))
             dialog.run()
             dialog.destroy()
     except InstallError as e:
         if e.status == InstallStatus.Abort:
             message = _("Keyboard {name} could not be installed.").format(name=self.kbname) \
                 + "\n\n" + _("Error Message:") + "\n %s" % (e.message)
             logging.error(message)
             message_type = Gtk.MessageType.ERROR
         else:
             message = _("Keyboard {name} could not be installed.").format(name=self.kbname) \
                 + "\n\n" + _("Warning Message:") + "\n %s" % (e.message)
             logging.warning(message)
             message_type = Gtk.MessageType.WARNING
         dialog = Gtk.MessageDialog(self, 0, message_type,
                                    Gtk.ButtonsType.OK, message)
         dialog.run()
         dialog.destroy()
     self.close()