def update_free_space(self): """Updates the free space text on the downloads tab. amount -- the total number of bytes free. """ amount = get_available_bytes_for_movies() if app.config.get(prefs.PRESERVE_DISK_SPACE): available = (app.config.get(prefs.PRESERVE_X_GB_FREE) * 1024 * 1024 * 1024) available = amount - available if available < 0: available = available * -1.0 text = _( "%(available)s below downloads space limit (%(amount)s " "free on disk)", {"amount": displaytext.size_string(amount), "available": displaytext.size_string(available)} ) else: text = _( "%(available)s free for downloads (%(amount)s free " "on disk)", {"amount": displaytext.size_string(amount), "available": displaytext.size_string(available)} ) else: text = _("%(amount)s free on disk", {"amount": displaytext.size_string(amount)}) self._free_disk_label.set_text(text)
def accept_download_size(self, size): """Checks the download file size to see if we can accept it based on the user disk space preservation preference """ accept = True if app.config.get(prefs.PRESERVE_DISK_SPACE): if size < 0: size = 0 preserved = (app.config.get(prefs.PRESERVE_X_GB_FREE) * 1024 * 1024 * 1024) available = get_available_bytes_for_movies() - preserved accept = (size <= available) return accept
def run_dialog(): """Displays a diagnostics windows that tells a user how Miro is set up on their machine. """ window = MainDialog(_("Diagnostics")) try: items = [{ "label": _("Movies location:"), "data": app.config.get(prefs.MOVIES_DIRECTORY), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.MOVIES_DIRECTORY)) }, { "label": _("Icon cache location:"), "data": app.config.get(prefs.ICON_CACHE_DIRECTORY), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.ICON_CACHE_DIRECTORY)) }, { "label": _("Log file location:"), "data": app.config.get(prefs.LOG_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.LOG_PATHNAME)) }, { "label": _("Downloader log file location:"), "data": app.config.get(prefs.DOWNLOADER_LOG_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.DOWNLOADER_LOG_PATHNAME)) }, { "label": _("Database file location:"), "data": app.config.get(prefs.SQLITE_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.SQLITE_PATHNAME)) }, { "label": _("Crash reports location:"), "data": app.config.get(prefs.CRASH_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.CRASH_PATHNAME)) }, SEPARATOR, { "label": _("Space free on disk:"), "data": lambda: util.format_size_for_user(get_available_bytes_for_movies(), "0B", False) }, { "label": _("Database size:"), "data": lambda: util.format_size_for_user(get_database_size(), "0B", False) }, { "label": _("Total db objects in memory:"), "data": lambda: "%d" % get_database_object_count() }, SEPARATOR, { "label": _("Total db backups:"), "data": "", "button_face": _("%(databasecount)s: Delete", {"databasecount": len(app.db.get_backup_databases())}), "button_fun": delete_backups }] t = widgetset.Table(3, len(items)) t.set_column_spacing(10) for row_num, item in enumerate(items): if item is SEPARATOR: t.pack(widgetset.Label(""), 0, row_num) continue label = item.get("label") lab = widgetset.Label(label) lab.set_bold(True) t.pack(widgetutil.align_left(lab), 0, row_num) data = item.get("data") if callable(data): data = data() if not isinstance(data, basestring): data = repr(data) datalab = widgetset.Label(data) t.pack(widgetutil.align_left(datalab), 1, row_num) if item.get("button_face"): b = widgetset.Button(item["button_face"]) b.set_size(widgetconst.SIZE_SMALL) b.connect('clicked', item["button_fun"]) t.pack(widgetutil.align_left(b), 2, row_num) window.set_extra_widget(t) window.add_button(BUTTON_OK.text) window.run() finally: window.destroy()
def run_dialog(): """Displays a diagnostics windows that tells a user how Miro is set up on their machine. """ window = MainDialog(_("Diagnostics")) try: items = [ {"label": _("Movies location:"), "data": app.config.get(prefs.MOVIES_DIRECTORY), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.MOVIES_DIRECTORY))}, {"label": _("Icon cache location:"), "data": app.config.get(prefs.ICON_CACHE_DIRECTORY), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.ICON_CACHE_DIRECTORY))}, {"label": _("Log file location:"), "data": app.config.get(prefs.LOG_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.LOG_PATHNAME))}, {"label": _("Downloader log file location:"), "data": app.config.get(prefs.DOWNLOADER_LOG_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.DOWNLOADER_LOG_PATHNAME))}, {"label": _("Database file location:"), "data": app.config.get(prefs.SQLITE_PATHNAME), "button_face": SHOW, "button_fun": open_helper(app.config.get(prefs.SQLITE_PATHNAME))}, SEPARATOR, {"label": _("Space free on disk:"), "data": lambda: util.format_size_for_user(get_available_bytes_for_movies(), "0B", False)}, {"label": _("Database size:"), "data": lambda: util.format_size_for_user(get_database_size(), "0B", False)}, {"label": _("Total db objects in memory:"), "data": lambda: "%d" % get_database_object_count()}, SEPARATOR, {"label": _("Total db backups:"), "data": "", "button_face": _("%(databasecount)s: Delete", {"databasecount": len(app.db.get_backup_databases())}), "button_fun": delete_backups} ] t = widgetset.Table(3, len(items)) t.set_column_spacing(10) for row_num, item in enumerate(items): if item is SEPARATOR: t.pack(widgetset.Label(""), 0, row_num) continue label = item.get("label") lab = widgetset.Label(label) lab.set_bold(True) t.pack(widgetutil.align_left(lab), 0, row_num) data = item.get("data") if callable(data): data = data() if not isinstance(data, basestring): data = repr(data) datalab = widgetset.Label(data) t.pack(widgetutil.align_left(datalab), 1, row_num) if item.get("button_face"): b = widgetset.Button(item["button_face"]) b.set_size(widgetconst.SIZE_SMALL) b.connect('clicked', item["button_fun"]) t.pack(widgetutil.align_left(b), 2, row_num) window.set_extra_widget(t) window.add_button(BUTTON_OK.text) window.run() finally: window.destroy()