add glib settings to layout

This commit is contained in:
Ward from fusion-voyager-3 2024-08-28 03:15:03 +03:00
parent 5548191eda
commit f9cbf4ddf4
4 changed files with 14 additions and 9 deletions

View File

@ -1,6 +1,6 @@
[Desktop Entry] [Desktop Entry]
Name=PikaOS Desktop Layouts Name=PikaOS Desktop Layouts
Exec=/usr/bin/pika-gnome-layouts Exec=pika-gnome-layouts
Icon=desktop Icon=desktop
Terminal=false Terminal=false
Type=Application Type=Application

View File

@ -18,7 +18,7 @@ pub fn build_ui(app: &adw::Application) {
let content_stack = gtk::Stack::builder() let content_stack = gtk::Stack::builder()
.build(); .build();
content::content(&content_stack); content::content(&content_stack, &glib_settings);
let window_toolbar = adw::ToolbarView::builder().content(&content_stack).build(); let window_toolbar = adw::ToolbarView::builder().content(&content_stack).build();

View File

@ -1,4 +1,4 @@
pub const APP_ID: &str = "com.github.pikaos-linux.pikagnomelayouts"; pub const APP_ID: &str = "com.github.pikaos-linux.pikagnomelayouts";
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_ICON: &str = "com.github.pikaos-linux.pikagnomelayouts"; pub const APP_ICON: &str = "desktop";
pub const APP_GITHUB: &str = "https://git.pika-os.com/gnome-packages/pika-gnome-layouts"; pub const APP_GITHUB: &str = "https://git.pika-os.com/gnome-packages/pika-gnome-layouts";

View File

@ -1,4 +1,4 @@
use gtk::prelude::*; use gtk::{gio as gio, glib as glib, prelude::*};
struct DesktopLayout { struct DesktopLayout {
name: String, name: String,
@ -7,6 +7,7 @@ struct DesktopLayout {
pub fn content( pub fn content(
content_stack: &gtk::Stack, content_stack: &gtk::Stack,
glib_settings: &gio::Settings
) { ) {
let content_box = gtk::Box::builder() let content_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
@ -21,23 +22,23 @@ pub fn content(
}, },
&DesktopLayout { &DesktopLayout {
name: "traditional".to_string(), name: "traditional".to_string(),
id: 0 id: 1
}, },
&DesktopLayout { &DesktopLayout {
name: "eleven".to_string(), name: "eleven".to_string(),
id: 0 id: 2
}, },
&DesktopLayout { &DesktopLayout {
name: "pineapple".to_string(), name: "pineapple".to_string(),
id: 0 id: 3
}, },
&DesktopLayout { &DesktopLayout {
name: "gnome2".to_string(), name: "gnome2".to_string(),
id: 0 id: 4
}, },
&DesktopLayout { &DesktopLayout {
name: "unity".to_string(), name: "unity".to_string(),
id: 0 id: 5
}, },
]; ];
@ -47,6 +48,8 @@ pub fn content(
let layout_grid = gtk::Grid::builder() let layout_grid = gtk::Grid::builder()
.vexpand(true) .vexpand(true)
.hexpand(true) .hexpand(true)
.row_homogeneous(true)
.column_homogeneous(true)
.build(); .build();
let previews_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Both); let previews_size_group = gtk::SizeGroup::new(gtk::SizeGroupMode::Both);
@ -60,6 +63,7 @@ pub fn content(
let layout_box = gtk::Box::builder() let layout_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
.build(); .build();
let layout_preview = gtk::Image::builder() let layout_preview = gtk::Image::builder()
.resource(format!("/com/github/pikaos-linux/pikagnomelayouts/previews/{}.svg", &layout_name)) .resource(format!("/com/github/pikaos-linux/pikagnomelayouts/previews/{}.svg", &layout_name))
.vexpand(true) .vexpand(true)
@ -73,6 +77,7 @@ pub fn content(
.group(&null_checkbutton) .group(&null_checkbutton)
.halign(gtk::Align::Center) .halign(gtk::Align::Center)
.valign(gtk::Align::Start) .valign(gtk::Align::Start)
.active(glib_settings.int("layout-num") == layout_id)
.label(t!(format!("{}_label", &layout_name))) .label(t!(format!("{}_label", &layout_name)))
.tooltip_text(t!(format!("{}_tooltip_text", &layout_name))) .tooltip_text(t!(format!("{}_tooltip_text", &layout_name)))
.build(); .build();