minor changes

This commit is contained in:
Ward Nakchbandi (Cosmic Fusion) 2023-07-01 23:20:30 +03:00
parent 2d81a1b8b4
commit 5434b0b8c6
5 changed files with 48 additions and 9 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "pika-drivers" name = "pika-drivers"
version = "0.3.1" version = "0.3.2"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -8,7 +8,9 @@ install:
cp -vf target/release/pika-drivers $(DESTDIR)/usr/bin/ cp -vf target/release/pika-drivers $(DESTDIR)/usr/bin/
chmod 755 $(DESTDIR)/usr/bin/pika-drivers chmod 755 $(DESTDIR)/usr/bin/pika-drivers
mkdir -p $(DESTDIR)/usr/lib/pika/drivers/ mkdir -p $(DESTDIR)/usr/lib/pika/drivers/
mkdir -p $(DESTDIR)/usr/share/glib-2.0/schemas/
cp data/*.sh $(DESTDIR)/usr/lib/pika/drivers/ cp data/*.sh $(DESTDIR)/usr/lib/pika/drivers/
cp data/*.xml $(DESTDIR)/usr/share/glib-2.0/schemas/
chmod 755 $(DESTDIR)/usr/lib/pika/drivers/*.sh chmod 755 $(DESTDIR)/usr/lib/pika/drivers/*.sh
mkdir -p $(DESTDIR)/usr/share/applications mkdir -p $(DESTDIR)/usr/share/applications
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<schemalist>
<schema id="com.pika.drivers" path="/com/pika/drivers/">
<key name="window-width" type="i">
<default>1200</default>
<summary>Default window width</summary>
</key>
<key name="window-height" type="i">
<default>600</default>
<summary>Default window height</summary>
</key>
<key name="is-maximized" type="b">
<default>false</default>
<summary>Default window maximized behaviour</summary>
</key>
</schema>
</schemalist>

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
pika-drivers (0.3.1-99pika1.lunar) lunar; urgency=medium pika-drivers (0.3.2-99pika1.lunar) lunar; urgency=medium
* initial release * initial release

View File

@ -9,7 +9,7 @@ use gdk::Display;
const PROJECT_VERSION: &str = env!("CARGO_PKG_VERSION"); const PROJECT_VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() { fn main() {
let application = Application::new(Some("com.pika.drivers"), Default::default()); let application = gtk::Application::new(Some("com.pika.drivers"), Default::default());
application.connect_startup(|app| { application.connect_startup(|app| {
// The CSS "magic" happens here. // The CSS "magic" happens here.
let provider = CssProvider::new(); let provider = CssProvider::new();
@ -29,11 +29,12 @@ fn main() {
} }
fn build_ui(app: &Application) { fn build_ui(app: &gtk::Application) {
gtk::glib::set_prgname(Some("Pika Drivers")); gtk::glib::set_prgname(Some("Pika Drivers"));
glib::set_application_name("Pika Drivers"); glib::set_application_name("Pika Drivers");
let glib_settings = gio::Settings::new("com.pika.drivers");
let loading_box = gtk::Box::builder() let loading_box = gtk::Box::builder()
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
@ -87,13 +88,20 @@ fn build_ui(app: &Application) {
.application(app) .application(app)
.child(&loading_box) .child(&loading_box)
.icon_name("pika-drivers") .icon_name("pika-drivers")
.default_width(1200) .default_width(glib_settings.int("window-width"))
.default_height(600) .default_height(glib_settings.int("window-height"))
.width_request(700) .width_request(700)
.height_request(500) .height_request(500)
.startup_id("pika-drivers") .startup_id("pika-drivers")
.hide_on_close(true)
.build(); .build();
if glib_settings.boolean("is-maximized") == true {
window.maximize()
}
let credits_window_box = gtk::Box::builder() let credits_window_box = gtk::Box::builder()
.orientation(Orientation::Vertical) .orientation(Orientation::Vertical)
.build(); .build();
@ -151,7 +159,11 @@ fn build_ui(app: &Application) {
window_title_bar.pack_end(&credits_button.clone()); window_title_bar.pack_end(&credits_button.clone());
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
window.connect_hide(clone!(@weak window => move |_| window.destroy()));
credits_button.connect_clicked(clone!(@weak credits_button => move |_| credits_window.show())); credits_button.connect_clicked(clone!(@weak credits_button => move |_| credits_window.show()));
let (sender, receiver) = MainContext::channel(Priority::default()); let (sender, receiver) = MainContext::channel(Priority::default());
window.connect_show(move |_| { window.connect_show(move |_| {
@ -300,7 +312,8 @@ fn get_drivers(main_window: &ApplicationWindow, ubuntu_drivers_list_utf8: String
.build(); .build();
let driver_label = gtk::Label::builder() let driver_label = gtk::Label::builder()
.margin_top(35) .margin_top(26)
.margin_bottom(5)
.build(); .build();
driver_label.add_css_class("startLabel"); driver_label.add_css_class("startLabel");
@ -435,8 +448,15 @@ fn get_drivers(main_window: &ApplicationWindow, ubuntu_drivers_list_utf8: String
driver_button.connect_clicked(clone!(@weak driver_button => move |_| modify_package(&driver_string, &driver_button_icon))); driver_button.connect_clicked(clone!(@weak driver_button => move |_| modify_package(&driver_string, &driver_button_icon)));
main_window.set_child(Some(&window_box)); main_window.set_child(Some(&window_box));
} }
} }
fn save_window_size(window: &ApplicationWindow, glib_settings: &gio::Settings) {
let size = window.default_size();
glib_settings.set_int("window-width", size.0);
glib_settings.set_int("window-height", size.1);
glib_settings.set_boolean("is-maximized", window.is_maximized());
}