mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Add user data page
This commit is contained in:
2
data/icons/dot-symbolic.svg
Normal file
2
data/icons/dot-symbolic.svg
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 11 8 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#222222"/></svg>
|
||||
|
After Width: | Height: | Size: 256 B |
4
data/icons/folder-templates-symbolic.svg
Normal file
4
data/icons/folder-templates-symbolic.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m 5 1 c -1.644531 0 -3 1.355469 -3 3 v 6.996094 h 1 v -0.996094 h 1 v -6 c 0 -0.570312 0.429688 -1 1 -1 h 4 v 1.5 c 0 1 0.5 1.5 1.5 1.5 h 1.5 v 7 h 1 v 1 h 1 v -8.5 c 0 -0.265625 -0.105469 -0.519531 -0.292969 -0.707031 l -3.5 -3.5 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 z m 8 13 h -1 v 0.992188 h -1 v 1 h 1 v -0.992188 h 1 z m -2 0.992188 v -1 h -1 v 1 z m -1 0 h -1 v 1 h 1 z m -1 0 v -1 h -1 v 1 z m -1 0 h -1 v 1 h 1 z m -1 0 v -1 h -1 v 1 z m -1 0 h -1 v 1 h 1 z m -1 0 v -1 h -1 v 1 z m -1 0 h -1 v 1 h 1 z m -1 0 v -1 h -1 v 1 z m 0 -1 h 1 v -1 h -1 z m 0 -1 v -1 h -1 v 1 z m 0 -1 h 1 v -1 h -1 z m 0 0" fill="#2e3436"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 795 B |
2
data/icons/vertical-arrows-long-symbolic.svg
Normal file
2
data/icons/vertical-arrows-long-symbolic.svg
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#222222" fill-rule="evenodd"><path d="m 1 3.914062 c 0.003906 -0.257812 0.105469 -0.511718 0.304688 -0.703124 l 3 -2.917969 c 0.386718 -0.3789065 1.003906 -0.3789065 1.394531 0 l 3 2.917969 c 0.394531 0.382812 0.402343 1.015624 0.019531 1.414062 c -0.386719 0.394531 -1.019531 0.402344 -1.417969 0.015625 l -1.300781 -1.265625 v 6.550781 c 0 1.332031 -2 1.332031 -2 0 v -6.550781 l -1.300781 1.269531 c -0.398438 0.382813 -1.03125 0.375 -1.414063 -0.019531 c -0.195312 -0.199219 -0.289062 -0.457031 -0.285156 -0.710938 z m 0 0"/><path d="m 7 11.941406 c 0.003906 0.253906 0.105469 0.507813 0.304688 0.703125 l 3 2.917969 c 0.386718 0.375 1.003906 0.375 1.394531 0 l 3 -2.917969 c 0.394531 -0.386719 0.402343 -1.019531 0.019531 -1.414062 c -0.386719 -0.398438 -1.019531 -0.40625 -1.417969 -0.019531 l -1.300781 1.265624 v -6.550781 c 0 -1.332031 -2 -1.332031 -2 0 v 6.550781 l -1.300781 -1.265624 c -0.398438 -0.386719 -1.03125 -0.378907 -1.414063 0.015624 c -0.195312 0.199219 -0.289062 0.457032 -0.285156 0.710938 z m 0 0"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -24,6 +24,7 @@ import time
|
||||
|
||||
from gi.repository import Adw, Gdk, Gio, GLib, Gtk
|
||||
from .packages_page import PackagesPage
|
||||
from .user_data_page import UserDataPage
|
||||
from .const import Config
|
||||
from .error_toast import ErrorToast
|
||||
from .status_box import StatusBox
|
||||
@@ -74,6 +75,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
file_drop = Gtk.DropTarget.new(Gio.File, Gdk.DragAction.COPY)
|
||||
self.pages = {
|
||||
self.packages_row: PackagesPage,
|
||||
|
||||
self.user_data_row: UserDataPage,
|
||||
}
|
||||
|
||||
# Apply
|
||||
|
||||
@@ -11,6 +11,8 @@ blueprints = custom_target('blueprints',
|
||||
'packages_page/packages_page.blp',
|
||||
'filters_page/filters_page.blp',
|
||||
'properties_page/properties_page.blp',
|
||||
'user_data_page/user_data_page.blp',
|
||||
'widgets/data_box.blp',
|
||||
'change_version_page/change_version_page.blp',
|
||||
),
|
||||
output: '.',
|
||||
@@ -62,6 +64,8 @@ warehouse_sources = [
|
||||
'filters_page/filters_page.py',
|
||||
'properties_page/properties_page.py',
|
||||
'change_version_page/change_version_page.py',
|
||||
'user_data_page/user_data_page.py',
|
||||
'widgets/data_box.py',
|
||||
'../data/style.css',
|
||||
]
|
||||
|
||||
|
||||
254
src/user_data_page/user_data_page.blp
Normal file
254
src/user_data_page/user_data_page.blp
Normal file
@@ -0,0 +1,254 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $UserDataPage : Adw.BreakpointBin {
|
||||
// title: _("User Data");
|
||||
width-request: 1;
|
||||
height-request: 1;
|
||||
|
||||
Adw.Breakpoint {
|
||||
condition ("max-width: 585")
|
||||
|
||||
setters {
|
||||
header_bar.show-title: false;
|
||||
switcher_bar.reveal: true;
|
||||
switcher_bar.visible: true;
|
||||
}
|
||||
}
|
||||
|
||||
Adw.ToolbarView {
|
||||
[top]
|
||||
Adw.HeaderBar header_bar {
|
||||
title-widget:
|
||||
Adw.ViewSwitcher {
|
||||
stack: stack;
|
||||
policy: wide;
|
||||
}
|
||||
;
|
||||
[start]
|
||||
ToggleButton search_button {
|
||||
icon-name: "system-search-symbolic";
|
||||
tooltip-text: _("Search User Data");
|
||||
}
|
||||
[end]
|
||||
MenuButton sort_button {
|
||||
popover: sort_pop;
|
||||
icon-name: "vertical-arrows-long-symbolic";
|
||||
tooltip-text: _("Sort User Data");
|
||||
}
|
||||
[end]
|
||||
ToggleButton select_button {
|
||||
icon-name: "selection-mode-symbolic";
|
||||
tooltip-text: _("Select User Data");
|
||||
}
|
||||
}
|
||||
[top]
|
||||
Adw.Clamp {
|
||||
SearchBar search_bar {
|
||||
search-mode-enabled: bind search_button.active bidirectional;
|
||||
key-capture-widget: template;
|
||||
|
||||
SearchEntry search_entry {
|
||||
hexpand: true;
|
||||
placeholder-text: _("Search User Data");
|
||||
}
|
||||
}
|
||||
}
|
||||
[bottom]
|
||||
Revealer {
|
||||
reveal-child: bind select_button.active;
|
||||
transition-type: slide_up;
|
||||
[center]
|
||||
Box bottom_bar {
|
||||
styles ["toolbar"]
|
||||
hexpand: true;
|
||||
homogeneous: true;
|
||||
Button select_all_button {
|
||||
styles ["raised"]
|
||||
Adw.ButtonContent {
|
||||
icon-name: "selection-mode-symbolic";
|
||||
label: _("Select All");
|
||||
can-shrink: true;
|
||||
}
|
||||
}
|
||||
Button copy_button {
|
||||
styles ["raised"]
|
||||
Adw.ButtonContent {
|
||||
icon-name: "edit-copy-symbolic";
|
||||
label: _("Copy");
|
||||
can-shrink: true;
|
||||
}
|
||||
}
|
||||
Button uninstall_button {
|
||||
styles ["raised"]
|
||||
Adw.ButtonContent {
|
||||
icon-name: "user-trash-symbolic";
|
||||
label: _("Uninstall");
|
||||
can-shrink: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[bottom]
|
||||
Adw.ViewSwitcherBar switcher_bar {
|
||||
stack: stack;
|
||||
visible: false;
|
||||
}
|
||||
Adw.ViewStack stack {
|
||||
Adw.ViewStackPage {
|
||||
name: "active";
|
||||
title: _("Active Data");
|
||||
icon-name: "file-manager-symbolic";
|
||||
child:
|
||||
ScrolledWindow {
|
||||
Box {
|
||||
orientation: vertical;
|
||||
Box {
|
||||
orientation: vertical;
|
||||
margin-start: 24;
|
||||
margin-end: 24;
|
||||
Label {
|
||||
label: _("Active User Data");
|
||||
styles ["title-1"]
|
||||
hexpand: true;
|
||||
halign: start;
|
||||
}
|
||||
Label {
|
||||
label: "32 Items - 39.7 GB";
|
||||
styles ["title-3"]
|
||||
hexpand: true;
|
||||
halign: start;
|
||||
}
|
||||
}
|
||||
Separator {
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-top: 9;
|
||||
margin-bottom: 6;
|
||||
}
|
||||
FlowBox flow_box {
|
||||
styles ["boxed-list"]
|
||||
homogeneous: true;
|
||||
valign: start;
|
||||
selection-mode: none;
|
||||
max-children-per-line: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-bottom: 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
Adw.ViewStackPage {
|
||||
name: "leftover";
|
||||
title: _("Leftover Data");
|
||||
icon-name: "folder-templates-symbolic";
|
||||
child:
|
||||
ScrolledWindow {
|
||||
Box {
|
||||
orientation: vertical;
|
||||
Box {
|
||||
orientation: vertical;
|
||||
margin-start: 24;
|
||||
margin-end: 24;
|
||||
Label {
|
||||
label: _("Leftover User Data");
|
||||
styles ["title-1"]
|
||||
hexpand: true;
|
||||
halign: start;
|
||||
}
|
||||
Label {
|
||||
label: "25 Items - 18.6 GB";
|
||||
styles ["title-3"]
|
||||
hexpand: true;
|
||||
halign: start;
|
||||
}
|
||||
}
|
||||
Separator {
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-top: 9;
|
||||
margin-bottom: 6;
|
||||
}
|
||||
FlowBox {
|
||||
styles ["boxed-list"]
|
||||
homogeneous: true;
|
||||
valign: start;
|
||||
selection-mode: none;
|
||||
max-children-per-line: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
margin-bottom: 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Popover sort_pop {
|
||||
styles ["menu"]
|
||||
Box {
|
||||
orientation: vertical;
|
||||
margin-start: 6;
|
||||
margin-end: 6;
|
||||
margin-top: 6;
|
||||
margin-bottom: 6;
|
||||
Box {
|
||||
homogeneous: true;
|
||||
spacing: 3;
|
||||
ToggleButton asc {
|
||||
styles ["flat"]
|
||||
label: _("Ascending");
|
||||
can-focus: bind asc.active inverted;
|
||||
can-target: bind asc.active inverted;
|
||||
}
|
||||
ToggleButton dsc {
|
||||
styles ["flat"]
|
||||
label: _("Descending");
|
||||
active: bind asc.active inverted bidirectional;
|
||||
can-focus: bind dsc.active inverted;
|
||||
can-target: bind dsc.active inverted;
|
||||
}
|
||||
}
|
||||
Separator {
|
||||
}
|
||||
Box sort_list {
|
||||
orientation: vertical;
|
||||
ToggleButton sort_name {
|
||||
styles ["flat"]
|
||||
can-focus: bind sort_name.active inverted;
|
||||
can-target: bind sort_name.active inverted;
|
||||
Label {
|
||||
styles ["body"]
|
||||
halign: start;
|
||||
label: _("Sort By Name");
|
||||
}
|
||||
}
|
||||
ToggleButton sort_id {
|
||||
styles ["flat"]
|
||||
can-focus: bind sort_id.active inverted;
|
||||
can-target: bind sort_id.active inverted;
|
||||
Label {
|
||||
styles ["body"]
|
||||
halign: start;
|
||||
label: _("Sort By ID");
|
||||
}
|
||||
}
|
||||
ToggleButton sort_size {
|
||||
active: true;
|
||||
can-focus: bind sort_size.active inverted;
|
||||
can-target: bind sort_size.active inverted;
|
||||
styles ["flat"]
|
||||
Label {
|
||||
styles ["body"]
|
||||
halign: start;
|
||||
label: _("Sort By Size");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/user_data_page/user_data_page.py
Normal file
58
src/user_data_page/user_data_page.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from gi.repository import Adw, Gtk, GLib, Gio, Pango
|
||||
from .host_info import HostInfo
|
||||
from .error_toast import ErrorToast
|
||||
from .data_box import DataBox
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/user_data_page/user_data_page.ui")
|
||||
class UserDataPage(Adw.BreakpointBin):
|
||||
__gtype_name__ = 'UserDataPage'
|
||||
gtc = Gtk.Template.Child
|
||||
select_button = gtc()
|
||||
flow_box = gtc()
|
||||
sort_pop = gtc()
|
||||
sort_list = gtc()
|
||||
sort_name = gtc()
|
||||
sort_id = gtc()
|
||||
sort_size = gtc()
|
||||
|
||||
# Referred to in the main window
|
||||
# It is used to determine if a new page should be made or not
|
||||
# This must be set to the created object from within the class's __init__ method
|
||||
instance = None
|
||||
|
||||
def set_selection_mode(self, is_enabled):
|
||||
i = 0
|
||||
while row := self.flow_box.get_child_at_index(i):
|
||||
i += 1
|
||||
row = row.get_child()
|
||||
row.check_button.set_visible(is_enabled)
|
||||
row.check_button.set_active(False)
|
||||
|
||||
def sort_handler(self, button):
|
||||
if button.get_active() == False:
|
||||
return
|
||||
self.sort_name.set_active(self.sort_name is button)
|
||||
self.sort_id.set_active(self.sort_id is button)
|
||||
self.sort_size.set_active(self.sort_size is button)
|
||||
if button is self.sort_name:
|
||||
self.sort_id.grab_focus()
|
||||
else:
|
||||
self.sort_name.grab_focus()
|
||||
|
||||
def __init__(self, main_window, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Apply
|
||||
self.__class__.instance = self
|
||||
|
||||
for i in range(10):
|
||||
box = DataBox(main_window, "/home/heliguy/.var/app/io.github.io.github.flattool.Warehouse/")
|
||||
self.flow_box.append(box)
|
||||
self.flow_box.get_child_at_index(i).set_focusable(False)
|
||||
|
||||
# self.select_button.connect("toggled", lambda *_: self.set_selection_mode(self.select_button.get_active()))
|
||||
# self.flow_box.connect("child-activated", lambda _, item: (cb := (row := item.get_child()).check_button).set_active((not cb.get_active()) if row.get_activatable() else False))
|
||||
|
||||
self.sort_name.connect("toggled", self.sort_handler)
|
||||
self.sort_id.connect("toggled", self.sort_handler)
|
||||
self.sort_size.connect("toggled", self.sort_handler)
|
||||
@@ -9,7 +9,9 @@
|
||||
<file preprocess="xml-stripblanks">filters_page/filters_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">properties_page/properties_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">change_version_page/change_version_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">user_data_page/user_data_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">widgets/status_box.ui</file>
|
||||
<file preprocess="xml-stripblanks">widgets/data_box.ui</file>
|
||||
<!-- <file preprocess="xml-stripblanks">../data/io.github.flattool.Warehouse.metainfo.xml.in</file> -->
|
||||
</gresource>
|
||||
<gresource prefix="/io/github/flattool/Warehouse/icons/scalable/actions/">
|
||||
@@ -49,5 +51,8 @@
|
||||
<file preprocess="xml-stripblanks" alias="error-small-symbolic.svg">../data/icons/error-small-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks" alias="copy-symbolic.svg">../data/icons/copy-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks" alias="double-ended-arrows-vertical-symbolic.svg">../data/icons/double-ended-arrows-vertical-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks" alias="vertical-arrows-long-symbolic.svg">../data/icons/vertical-arrows-long-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks" alias="dot-symbolic.svg">../data/icons/dot-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks" alias="folder-templates-symbolic.svg">../data/icons/folder-templates-symbolic.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
77
src/widgets/data_box.blp
Normal file
77
src/widgets/data_box.blp
Normal file
@@ -0,0 +1,77 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $DataBox : ListBox {
|
||||
selection-mode: none;
|
||||
styles ["boxed-list"]
|
||||
Adw.ActionRow row {
|
||||
activatable: bind check_button.visible;
|
||||
width-request: 275;
|
||||
[child]
|
||||
Box root_box {
|
||||
orientation: vertical;
|
||||
Box title_box {
|
||||
margin-top: 12;
|
||||
margin-bottom: 12;
|
||||
Image app_icon {
|
||||
margin-start: 12;
|
||||
margin-end: 12;
|
||||
icon-name: "application-x-executable-symbolic";
|
||||
icon-size: large;
|
||||
}
|
||||
Box label_box {
|
||||
orientation: vertical;
|
||||
Label title_label {
|
||||
label: "No Title Set";
|
||||
hexpand: true;
|
||||
halign: start;
|
||||
ellipsize: middle;
|
||||
margin-end: 12;
|
||||
styles ["title-4"]
|
||||
}
|
||||
Label subtitle_label {
|
||||
label: "No subtitle set";
|
||||
hexpand: true;
|
||||
halign: start;
|
||||
ellipsize: middle;
|
||||
margin-end: 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
Box content_box {
|
||||
spacing: 6;
|
||||
margin-start: 12;
|
||||
margin-end: 6;
|
||||
margin-bottom: 6;
|
||||
Label size_label {
|
||||
label: "No size set";
|
||||
halign: start;
|
||||
hexpand: true;
|
||||
}
|
||||
Button copy_button {
|
||||
icon-name: "copy-symbolic";
|
||||
tooltip-text: _("Copy Path");
|
||||
visible: bind check_button.visible inverted;
|
||||
styles ["flat", "circular"]
|
||||
}
|
||||
Button open_button {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open User Data");
|
||||
visible: bind check_button.visible inverted;
|
||||
styles ["flat", "circular"]
|
||||
}
|
||||
Button trash_button {
|
||||
icon-name: "user-trash-symbolic";
|
||||
tooltip-text: _("Trash User Data");
|
||||
visible: bind check_button.visible inverted;
|
||||
styles ["flat", "circular"]
|
||||
}
|
||||
CheckButton check_button {
|
||||
visible: false;
|
||||
sensitive: bind check_button.visible;
|
||||
styles ["selection-mode"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
src/widgets/data_box.py
Normal file
13
src/widgets/data_box.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from gi.repository import Adw, Gtk, GLib, Gio, Pango
|
||||
from .host_info import HostInfo
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/widgets/data_box.ui")
|
||||
class DataBox(Gtk.ListBox):
|
||||
__gtype_name__ = 'DataBox'
|
||||
gtc = Gtk.Template.Child
|
||||
|
||||
title_label = gtc()
|
||||
check_button = gtc()
|
||||
|
||||
def __init__(self, main_window, path, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
Reference in New Issue
Block a user