def restorebackup_clicked(self, widget): zipfile = self.fcButtonRestore.get_filename() if zipfile: if backup.restore_backup(zipfile): msg = messages.MSG_RESTORE_SUCCES InfoDialog(msg, self._parent) gtk.main_quit() else: msg = messages.MSG_RESTORE_FAILED InfoDialog(msg, self._parent)
def do_operation(self, print_action, save_path=None): userinfo = common.get_own_address() if not tools.check_user_info(self, userinfo["name"]): return # Show a message to the user if the original image is not found and # can't be shown on the pedigree if config.get("printing.pedigree-image") and self.pigeon.image is not None: if not os.path.exists(self.pigeon.image): msg = (_("Cannot find image '%s'"), _("You need to edit the pigeon and select the correct " "path or restore the original image on your computer."), "") # In some very old versions, an empty image was stored as an # empty string instead of None. Don't show this message in cases # like this ofcourse. if not self.pigeon.image == "": InfoDialog(msg, self, self.pigeon.image) PedigreeReport, PedigreeReportOptions = get_pedigree() psize = common.get_pagesize_from_opts() opts = PedigreeReportOptions(psize, print_action=print_action, filename=save_path, parent=self) try: report(PedigreeReport, opts, self.pigeon, userinfo) except ReportError as exc: ErrorDialog((exc.value.split("\n")[0], _("You probably don't have write permissions on this folder."), _("Error")) )
def makebackup_clicked(self, widget): folder = self.fcButtonCreate.get_current_folder() if folder: if backup.make_backup(folder): msg = messages.MSG_BACKUP_SUCCES else: msg = messages.MSG_BACKUP_FAILED InfoDialog(msg, self._parent)
def _finish_options(self, restart=False, set_default=False): arrows = self.widgets.chkArrows.get_active() stats = self.widgets.chkStats.get_active() toolbar = self.widgets.chkToolbar.get_active() statusbar = self.widgets.chkStatusbar.get_active() self.emit("interface-changed", arrows, stats, toolbar, statusbar) if restart: InfoDialog(messages.MSG_RESTART_APP, self.widgets.optionsdialog) if not set_default: self.widgets.optionsdialog.destroy()
def menuupdate_activate(self, widget): logger.debug(common.get_function_name()) try: new, msg = update.update() except update.UpdateError as exc: new = False msg = str(exc) title = _("Search for updates...") if new: if QuestionDialog((msg, _("Go to the website?"), title), self).run(): webbrowser.open(const.DOWNLOADURL) else: InfoDialog((msg, None, title), self)
def on_addtopedigree_clicked(self, widget): result = self.widgets.resultview.get_selected() text = "%se %s %s %s." % (result["placed"], result["point"], result["out"], _("Pigeons")[0].lower()) for index, field in enumerate(self.pigeon.get_extra()): if field == "": database.update_pigeon(self.pigeon.pindex, {"extra%s" % (index + 1): text}) pigeonparser.parser.update_pigeon(self.pigeon.pindex) component.get("DetailsView").set_details(self.pigeon) break else: InfoDialog( (_("No empty space found in pedigree details."), "", ""), self._parent, None)
def quit_program(self, widget=None, event=None, bckp=True): try: database.session.optimize_database() except Exception as exc: logger.error("Database optimizing failed: %s", exc) database.session.close() x, y = self.get_position() w, h = self.get_size() config.set("interface.window-x", x) config.set("interface.window-y", y) config.set("interface.window-w", w) config.set("interface.window-h", h) if config.get("backup.automatic-backup") and bckp: daysInSeconds = config.get("backup.interval") * 24 * 60 * 60 if time.time() - config.get("backup.last") >= daysInSeconds: if backup.make_backup(config.get("backup.location")): InfoDialog(messages.MSG_BACKUP_SUCCES, self) else: InfoDialog(messages.MSG_BACKUP_FAILED, self) config.set("backup.last", time.time()) config.save() gtk.main_quit()
def run_ui(dbcode): formatter = logging.Formatter(const.LOG_FORMAT) handler = GtkLogHandler() handler.setFormatter(formatter) handler.setLevel(logging.CRITICAL) logger.addHandler(handler) logger.debug("Python version: %s" % ".".join(map(str, sys.version_info[:3]))) logger.debug("GTK+ version: %s" % ".".join(map(str, gtk.gtk_version))) logger.debug("PyGTK version: %s" % ".".join(map(str, gtk.pygtk_version))) setup_icons() from pigeonplanner import database if dbcode == database.DATABASE_TOO_NEW: from pigeonplanner import messages from pigeonplanner.ui.messagedialog import ErrorDialog ErrorDialog(messages.MSG_NEW_DATABASE) sys.exit(0) elif dbcode == database.DATABASE_CHANGED: from pigeonplanner import messages from pigeonplanner.ui.messagedialog import InfoDialog InfoDialog(messages.MSG_UPDATED_DATABASE) elif dbcode == database.DATABASE_ERROR: from pigeonplanner import messages from pigeonplanner.ui.messagedialog import ErrorDialog ErrorDialog(messages.MSG_ERROR_DATABASE) sys.exit(0) # Import widgets that are used in GtkBuilder files from pigeonplanner.ui.widgets import statusbar from pigeonplanner.ui.widgets import checkbutton from pigeonplanner.ui.widgets import latlongentry from pigeonplanner.ui import mainwindow mainwindow.MainWindow() from pigeonplanner.core import config if config.get("options.check-for-updates"): updatethread = Thread(None, search_updates, None) updatethread.start() gtk.main()
def on_goto_pigeon(self, widget, pigeon): if not component.get("Treeview").select_pigeon(None, pigeon.get_pindex()): InfoDialog(messages.MSG_NO_PIGEON, self._parent)
def _select_pigeon(self, widget, pigeon, parent): pindex = pigeon.get_pindex() if not component.get("Treeview").select_pigeon(None, pindex): InfoDialog(messages.MSG_NO_PIGEON, parent)