mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-04-26 12:21:43 +00:00
ui: add game entries
This commit is contained in:
parent
cbc536c23e
commit
d91f38c80e
9 changed files with 132 additions and 4 deletions
33
ui/rsc/entry.ui
Normal file
33
ui/rsc/entry.ui
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="LSEntry" parent="GtkListBoxRow">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="margin-top">8</property>
|
||||
<property name="margin-bottom">8</property>
|
||||
<property name="spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="halign">start</property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="label"
|
||||
bind-source="LSEntry" bind-property="exe" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="delete">
|
||||
<property name="icon-name">user-trash-symbolic</property>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
<class name="circular"/>
|
||||
<class name="destructive-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
|
|
@ -15,7 +15,28 @@
|
|||
</child>
|
||||
|
||||
<!-- Content -->
|
||||
<!-- TODO: content -->
|
||||
<property name="content">
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="vscrollbar-policy">automatic</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="profiles">
|
||||
<property name="selection-mode">browse</property>
|
||||
<property name="css-classes">navigation-sidebar</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
<!-- Footer -->
|
||||
<child type="bottom">
|
||||
|
|
@ -26,7 +47,7 @@
|
|||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<object class="GtkButton" id="create">
|
||||
<property name="label">Create New Profile</property>
|
||||
<property name="css-classes">suggested-action</property>
|
||||
</object>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/gay/pancake/lsfg-vk/">
|
||||
<file compressed="true" preprocess="xml-stripblanks">entry.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">window.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">pane/main.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">pane/sidebar.ui</file>
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ pub fn load_config() -> Result<(), anyhow::Error> {
|
|||
while rx.try_recv().is_ok() {}
|
||||
|
||||
// write the configuration
|
||||
eprintln!("Saving configuration...");
|
||||
if let Ok(config) = config.try_read() {
|
||||
if let Err(e) = save_config(&config) {
|
||||
eprintln!("Failed to save configuration: {}", e);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,17 @@ fn build_ui(app: &adw::Application) {
|
|||
let window = wrapper::Window::new(app);
|
||||
window.set_application(Some(app));
|
||||
|
||||
// load profiles from configuration
|
||||
let sidebar = window.imp().sidebar.imp();
|
||||
|
||||
let config = config::get_config()
|
||||
.expect("Failed to get configuration");
|
||||
for game in config.game.iter() {
|
||||
let entry = wrapper::entry::Entry::new();
|
||||
entry.set_exe(game.exe.clone());
|
||||
sidebar.profiles.append(&entry);
|
||||
}
|
||||
|
||||
// register main pane signals
|
||||
let main = window.imp().main.imp();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use gtk;
|
|||
use adw;
|
||||
use gtk::glib::types::StaticTypeExt;
|
||||
|
||||
pub mod entry;
|
||||
pub mod pane;
|
||||
pub mod pref;
|
||||
|
||||
|
|
|
|||
18
ui/src/wrapper/entry.rs
Normal file
18
ui/src/wrapper/entry.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use gtk::glib;
|
||||
use gtk;
|
||||
|
||||
pub mod entry;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Entry(ObjectSubclass<entry::Entry>)
|
||||
@extends
|
||||
gtk::ListBoxRow, gtk::Widget,
|
||||
@implements
|
||||
gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl Entry {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
41
ui/src/wrapper/entry/entry.rs
Normal file
41
ui/src/wrapper/entry/entry.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use std::cell::RefCell;
|
||||
|
||||
use gtk::glib;
|
||||
use gtk::subclass::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
|
||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||
#[properties(wrapper_type = super::Entry)]
|
||||
#[template(resource = "/gay/pancake/lsfg-vk/entry.ui")]
|
||||
pub struct Entry {
|
||||
#[property(get, set)]
|
||||
exe: RefCell<String>,
|
||||
|
||||
#[template_child]
|
||||
pub delete: TemplateChild<gtk::Button>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Entry {
|
||||
const NAME: &'static str = "LSEntry";
|
||||
type Type = super::Entry;
|
||||
type ParentType = gtk::ListBoxRow;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::derived_properties]
|
||||
impl ObjectImpl for Entry {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for Entry {}
|
||||
impl ListBoxRowImpl for Entry {}
|
||||
|
|
@ -5,7 +5,10 @@ use adw::subclass::prelude::*;
|
|||
#[derive(gtk::CompositeTemplate, Default)]
|
||||
#[template(resource = "/gay/pancake/lsfg-vk/pane/sidebar.ui")]
|
||||
pub struct PaneSidebar {
|
||||
|
||||
#[template_child]
|
||||
pub profiles: TemplateChild<gtk::ListBox>,
|
||||
#[template_child]
|
||||
pub create: TemplateChild<gtk::Button>
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue