mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-15 00:34:42 +09:00
Sync current work
This commit is contained in:
@@ -3,14 +3,13 @@ import os
|
||||
import subprocess
|
||||
import pathlib
|
||||
|
||||
class functions():
|
||||
class myUtils:
|
||||
def __init__(self, window, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.main_window = window
|
||||
self.host_home = str(pathlib.Path.home())
|
||||
self.user_data_path = self.host_home + "/.var/app/"
|
||||
|
||||
def trash_folder(self, path):
|
||||
def trashFolder(self, path):
|
||||
if not os.path.exists(path):
|
||||
return 1
|
||||
try:
|
||||
@@ -19,7 +18,7 @@ class functions():
|
||||
except subprocess.CalledProcessError:
|
||||
return 2
|
||||
|
||||
def get_size_format(self, b):
|
||||
def getSizeFormat(self, b):
|
||||
factor = 1024
|
||||
suffix = "B"
|
||||
for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
|
||||
@@ -28,7 +27,7 @@ class functions():
|
||||
b /= factor
|
||||
return f"{b:.1f}{suffix}"
|
||||
|
||||
def get_directory_size(self, directory):
|
||||
def getDirectorySize(self, directory):
|
||||
"""Returns the `directory` size in bytes."""
|
||||
total = 0
|
||||
try:
|
||||
@@ -42,7 +41,7 @@ class functions():
|
||||
elif entry.is_dir():
|
||||
# if it's a directory, recursively call this function
|
||||
try:
|
||||
total += self.get_directory_size(entry.path)
|
||||
total += self.getDirectorySize(entry.path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except NotADirectoryError:
|
||||
@@ -53,7 +52,7 @@ class functions():
|
||||
return 0
|
||||
return total
|
||||
|
||||
def find_app_icon(self, app_id):
|
||||
def findAppIcon(self, app_id):
|
||||
icon_theme = Gtk.IconTheme.new()
|
||||
icon_theme.add_search_path("/var/lib/flatpak/exports/share/icons/")
|
||||
icon_theme.add_search_path(self.host_home + "/.local/share/flatpak/exports/share/icons")
|
||||
@@ -43,7 +43,7 @@ warehouse_sources = [
|
||||
'properties_window.py',
|
||||
'orphans_window.py',
|
||||
'remotes.py',
|
||||
'functions.py',
|
||||
'common.py',
|
||||
]
|
||||
|
||||
install_data(warehouse_sources, install_dir: moduledir)
|
||||
|
||||
@@ -23,7 +23,7 @@ import subprocess
|
||||
from gi.repository import Adw, Gdk, Gio, GLib, Gtk
|
||||
from .properties_window import show_properties_window
|
||||
from .orphans_window import show_orphans_window
|
||||
from .functions import functions
|
||||
from .common import myUtils
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/heliguy4599/Warehouse/window.ui")
|
||||
class WarehouseWindow(Adw.ApplicationWindow):
|
||||
@@ -258,7 +258,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
if not file_list[i] in id_list:
|
||||
row_index += 1
|
||||
select_orphans_tickbox = Gtk.CheckButton(halign=Gtk.Align.CENTER)
|
||||
orphans_row = Adw.ActionRow(title=GLib.markup_escape_text(file_list[i]), subtitle=_("~") + self.func.get_size_format(self.func.get_directory_size(f"{self.user_data_path}{file_list[i]}")))
|
||||
orphans_row = Adw.ActionRow(title=GLib.markup_escape_text(file_list[i]), subtitle=_("~") + self.my_utils.getSizeFormat(self.my_utils.getDirectorySize(f"{self.user_data_path}{file_list[i]}")))
|
||||
orphans_row.add_suffix(select_orphans_tickbox)
|
||||
orphans_row.set_activatable_widget(select_orphans_tickbox)
|
||||
select_orphans_tickbox.connect("toggled", selection_handler, orphans_row.get_title())
|
||||
@@ -458,7 +458,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
app_id = self.host_flatpaks[index][2]
|
||||
app_ref = self.host_flatpaks[index][8]
|
||||
flatpak_row = Adw.ActionRow(title=GLib.markup_escape_text(app_name))
|
||||
flatpak_row.add_prefix(self.func.find_app_icon(app_id))
|
||||
flatpak_row.add_prefix(self.my_utils.findAppIcon(app_id))
|
||||
|
||||
if (not self.show_runtimes) and "runtime" in self.host_flatpaks[index][12]:
|
||||
continue
|
||||
@@ -543,7 +543,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
app_id = self.host_flatpaks[self.selected_host_flatpak_indexes[i]][2]
|
||||
app_name = self.host_flatpaks[self.selected_host_flatpak_indexes[i]][0]
|
||||
path = f"{self.user_data_path}{app_id}"
|
||||
trash = self.func.trash_folder(None, path)
|
||||
trash = self.my_utils.trash_folder(None, path)
|
||||
if trash == 1:
|
||||
show_success = False
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("No user data for {}").format(app_name)))
|
||||
@@ -588,7 +588,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.func = functions(self)
|
||||
self.my_utils = myUtils(self)
|
||||
self.list_of_flatpaks.set_filter_func(self.filter_func)
|
||||
self.set_size_request(0, 230)
|
||||
self.generate_list_of_flatpaks()
|
||||
|
||||
Reference in New Issue
Block a user