mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: clearer gpu/card model separation (#287)
This commit is contained in:
parent
72d6556906
commit
a8711802f0
@ -25,7 +25,7 @@ mod imp {
|
||||
prelude::*,
|
||||
widget::{CompositeTemplateClass, WidgetImpl},
|
||||
},
|
||||
CompositeTemplate, Label, TemplateChild,
|
||||
CompositeTemplate, Label, MenuButton, TemplateChild,
|
||||
};
|
||||
use std::{cell::RefCell, str::FromStr};
|
||||
|
||||
@ -39,9 +39,13 @@ mod imp {
|
||||
value: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
selectable: RefCell<bool>,
|
||||
#[property(get, set)]
|
||||
info_text: RefCell<String>,
|
||||
|
||||
#[template_child]
|
||||
value_label: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
info_menubutton: TemplateChild<MenuButton>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
@ -66,6 +70,12 @@ mod imp {
|
||||
|
||||
let attr_list = AttrList::from_str("0 -1 weight bold").unwrap();
|
||||
self.value_label.set_attributes(Some(&attr_list));
|
||||
|
||||
let obj = self.obj();
|
||||
obj.bind_property("info-text", &self.info_menubutton.get(), "visible")
|
||||
.transform_to(|_, text: String| Some(!text.is_empty()))
|
||||
.sync_create()
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ impl App {
|
||||
let window = ApplicationWindow::builder()
|
||||
.title("LACT")
|
||||
.default_width(600)
|
||||
.default_height(830)
|
||||
.default_height(860)
|
||||
.icon_name(APP_ID)
|
||||
.build();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
use gtk::glib::{self, object::ObjectExt, subclass::object::DerivedObjectProperties, Object};
|
||||
use lact_client::schema::{DeviceInfo, DeviceStats};
|
||||
use std::fmt::Write;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct HardwareInfoSection(ObjectSubclass<imp::HardwareInfoSection>)
|
||||
@ -16,24 +17,40 @@ impl HardwareInfoSection {
|
||||
self.reset();
|
||||
|
||||
if let Some(pci_info) = &info.pci_info {
|
||||
if let Some(name) = pci_info
|
||||
let mut gpu_model = pci_info
|
||||
.device_pci_info
|
||||
.model
|
||||
.as_deref()
|
||||
.unwrap_or("Unknown")
|
||||
.to_owned();
|
||||
let _ = write!(
|
||||
gpu_model,
|
||||
" (0x{}:0x{})",
|
||||
pci_info.device_pci_info.vendor_id, pci_info.device_pci_info.model_id
|
||||
);
|
||||
self.set_gpu_model(gpu_model);
|
||||
|
||||
let mut card_manufacturer = pci_info
|
||||
.subsystem_pci_info
|
||||
.vendor
|
||||
.as_deref()
|
||||
.unwrap_or("Unknown")
|
||||
.to_owned();
|
||||
let _ = write!(
|
||||
card_manufacturer,
|
||||
" (0x{})",
|
||||
pci_info.subsystem_pci_info.vendor_id
|
||||
);
|
||||
self.set_card_manufacturer(card_manufacturer);
|
||||
|
||||
let mut card_model = pci_info
|
||||
.subsystem_pci_info
|
||||
.model
|
||||
.as_deref()
|
||||
.or(pci_info.device_pci_info.model.as_deref())
|
||||
{
|
||||
self.set_gpu_model(name);
|
||||
}
|
||||
|
||||
if let Some(manufacturer_name) = info.pci_info.as_ref().and_then(|pci_info| {
|
||||
pci_info
|
||||
.subsystem_pci_info
|
||||
.vendor
|
||||
.as_deref()
|
||||
.or(pci_info.device_pci_info.model.as_deref())
|
||||
}) {
|
||||
self.set_gpu_manufacturer(manufacturer_name);
|
||||
}
|
||||
.unwrap_or("Unknown")
|
||||
.to_owned();
|
||||
let _ = write!(card_model, " (0x{})", pci_info.subsystem_pci_info.model_id);
|
||||
self.set_card_model(card_model);
|
||||
}
|
||||
|
||||
if let Some(drm_info) = &info.drm_info {
|
||||
@ -117,7 +134,9 @@ mod imp {
|
||||
#[property(get, set)]
|
||||
gpu_model: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
gpu_manufacturer: RefCell<String>,
|
||||
card_manufacturer: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
card_model: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
gpu_family: RefCell<String>,
|
||||
#[property(get, set)]
|
||||
|
@ -12,11 +12,18 @@ template $HardwareInfoSection: $PageSection {
|
||||
}
|
||||
|
||||
$InfoRow {
|
||||
name: "GPU Manufacturer:";
|
||||
value: bind template.gpu_manufacturer;
|
||||
name: "Card Manufacturer:";
|
||||
value: bind template.card_manufacturer;
|
||||
selectable: true;
|
||||
}
|
||||
|
||||
$InfoRow {
|
||||
name: "Card Model:";
|
||||
value: bind template.card_model;
|
||||
selectable: true;
|
||||
info-text: "The card displayed here may be of a sibling model, e.g. XT vs XTX variety. This is normal, as such models often use the same device ID, and it is not possible to differentiate between them.";
|
||||
}
|
||||
|
||||
$InfoRow {
|
||||
name: "GPU Family:";
|
||||
value: bind template.gpu_family;
|
||||
|
@ -11,6 +11,20 @@ template $InfoRow: Box {
|
||||
hexpand: true;
|
||||
}
|
||||
|
||||
MenuButton info_menubutton {
|
||||
icon-name: "dialog-information-symbolic";
|
||||
margin-start: 5;
|
||||
margin-end: 5;
|
||||
popover: Popover {
|
||||
Label {
|
||||
label: bind template.info-text;
|
||||
wrap: true;
|
||||
wrap-mode: word;
|
||||
max-width-chars: 55;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Label value_label {
|
||||
label: bind template.value;
|
||||
halign: end;
|
||||
|
Loading…
Reference in New Issue
Block a user