Add properties page

This commit is contained in:
heliguy
2024-07-05 23:15:58 -04:00
parent 1dca8bd73e
commit 3f23d2a666
6 changed files with 103 additions and 10 deletions

View File

@@ -7,7 +7,8 @@ blueprints = custom_target('blueprints',
'widgets/app_row.blp',
'gtk/help-overlay.blp',
'main_window/window.blp',
'packages_page/packages_page.blp'
'packages_page/packages_page.blp',
'properties_page/properties_page.blp',
),
output: '.',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
@@ -54,6 +55,7 @@ warehouse_sources = [
'widgets/error_toast.py',
'main_window/window.py',
'packages_page/packages_page.py',
'properties_page/properties_page.py',
'../data/style.css',
]

View File

@@ -101,12 +101,7 @@ template $PackagesPage : Adw.BreakpointBin {
}
;
content:
Adw.NavigationPage {
title: "Properties";
Adw.StatusPage {
title: "Properties Panel";
}
}
$PropertiesPage properties_page {}
;
}
}

View File

@@ -2,6 +2,7 @@ from gi.repository import Adw, Gtk#, GLib, Gio, Pango
from .host_info import HostInfo
from .app_row import AppRow
from .error_toast import ErrorToast
from .properties_page import PropertiesPage
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/packages_page/packages_page.ui")
class PackagesPage(Adw.BreakpointBin):
@@ -12,7 +13,9 @@ class PackagesPage(Adw.BreakpointBin):
refresh_button = gtc()
search_bar = gtc()
search_entry = gtc()
packages_split = gtc()
packages_list_box = gtc()
properties_page = gtc()
# Referred to in the main window
# It is used to determine if a new page should be made or not
@@ -27,7 +30,7 @@ class PackagesPage(Adw.BreakpointBin):
self.packages_list_box.select_row(first_row)
def row_select_handler(self, list_box, row):
print(row.get_title())
self.properties_page.set_properties(row.package)
def filter_func(self, row):
search_text = self.search_entry.get_text().lower()
@@ -55,4 +58,3 @@ class PackagesPage(Adw.BreakpointBin):
self.search_entry.connect("search-changed", lambda *_: self.packages_list_box.invalidate_filter())
self.search_bar.set_key_capture_widget(main_window)
self.packages_list_box.connect("row-activated", self.row_select_handler)

View File

@@ -0,0 +1,70 @@
using Gtk 4.0;
using Adw 1;
template $PropertiesPage : Adw.NavigationPage {
title: "Properties";
Adw.ToolbarView {
[top]
Adw.HeaderBar {
}
ScrolledWindow {
Adw.Clamp {
Box {
margin-start: 12;
margin-end: 12;
margin-bottom: 12;
orientation: vertical;
halign: fill;
hexpand: true;
Image app_icon {
pixel-size: 100;
margin-bottom: 18;
icon-name: "application-x-executable-symbolic";
styles["icon-dropshadow"]
}
Label name {
styles ["title-1"]
selectable: true;
wrap: true;
wrap-mode: word_char;
justify: center;
margin-bottom: 12;
margin-start: 6;
margin-end: 6;
}
Label description {
styles ["title-4"]
selectable: true;
wrap: true;
wrap-mode: word_char;
justify: center;
margin-bottom: 18;
margin-start: 6;
margin-end: 6;
}
Box {
spacing: 6;
homogeneous: true;
margin-bottom: 12;
halign: center;
Button open_app_button {
styles ["suggested-action", "pill"]
can-shrink: true;
label: "Open";
}
Button uninstall_button {
styles ["pill"]
can-shrink: true;
label: "Uninstall";
}
}
}
}
}
}
}

View File

@@ -0,0 +1,23 @@
from gi.repository import Adw, Gtk#, GLib, Gio, Pango
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/properties_page/properties_page.ui")
class PropertiesPage(Adw.NavigationPage):
__gtype_name__ = 'PropertiesPage'
gtc = Gtk.Template.Child
app_icon = gtc()
name = gtc()
description = gtc()
def set_properties(self, package):
self.set_title(package.info["id"])
self.name.set_label(package.info["name"])
pkg_description = package.info["description"]
self.description.set_visible(pkg_description != "")
self.description.set_label(pkg_description)
if package.icon_path:
self.app_icon.set_from_file(package.icon_path)
else:
self.app_icon.set_from_icon_name("application-x-executable-symbolic")
def __init__(self, **kwargs):
super().__init__(**kwargs)

View File

@@ -2,10 +2,11 @@
<gresources>
<gresource prefix="/io/github/flattool/Warehouse">
<file>../data/style.css</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">widgets/app_row.ui</file>
<file preprocess="xml-stripblanks">main_window/window.ui</file>
<file preprocess="xml-stripblanks">packages_page/packages_page.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">properties_page/properties_page.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/">