Fix css
This commit is contained in:
parent
ce765e30cf
commit
94801968fa
@ -6,6 +6,6 @@ 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
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gtk4 = { version = "0.7.3", features = ["blueprint"] }
|
gtk4 = { version = "0.7.3", features = ["blueprint", "v4_12"] }
|
||||||
simplelogin = { version = "0.1.0", path = "../simplelogin" }
|
simplelogin = { version = "0.1.0", path = "../simplelogin" }
|
||||||
tokio = { version = "1.33.0", features = ["full"] }
|
tokio = { version = "1.33.0", features = ["full"] }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<schemalist>
|
<schemalist>
|
||||||
<schema id="im.zander.SimpleLogin" path="/im/zander/SimpleLogin/">
|
<schema id="im.zander.SimpleLogin" path="/im/zander/SimpleLogin/">
|
||||||
<key name="api-key" type="s">
|
<key name="api-key" type="ms">
|
||||||
<default>""</default>
|
<default>nothing</default>
|
||||||
<summary>Api key</summary>
|
<summary>Api key</summary>
|
||||||
<description>The api key for the current user</description>
|
<description>The api key for the current user</description>
|
||||||
</key>
|
</key>
|
||||||
|
@ -117,9 +117,6 @@ template $LoginWindow : ApplicationWindow {
|
|||||||
receives-default: true;
|
receives-default: true;
|
||||||
truncate-multiline: true;
|
truncate-multiline: true;
|
||||||
|
|
||||||
styles [
|
|
||||||
]
|
|
||||||
|
|
||||||
layout {
|
layout {
|
||||||
column: "1";
|
column: "1";
|
||||||
row: "1";
|
row: "1";
|
||||||
|
@ -1,20 +1,34 @@
|
|||||||
use crate::login_window::LoginWindow;
|
use crate::login_window::LoginWindow;
|
||||||
|
|
||||||
use gtk4 as gtk;
|
use gtk4 as gtk;
|
||||||
use gtk::{glib, gio, prelude::*, subclass::prelude::*};
|
use gtk::{glib, gdk, gio, prelude::*, subclass::prelude::*};
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, glib::Properties)]
|
||||||
|
#[properties(wrapper_type = super::Application)]
|
||||||
pub struct Application {
|
pub struct Application {
|
||||||
pub settings: gio::Settings,
|
#[property(name = "api-key", type = Option<String>,
|
||||||
|
get = Self::api_key, set = Self::set_api_key, nullable)]
|
||||||
|
pub settings: RefCell<gio::Settings>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Application {
|
||||||
|
fn api_key(&self) -> Option<String> {
|
||||||
|
self.settings.borrow().value("api-key").get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_api_key(&self, value: Option<String>) {
|
||||||
|
_ = self.settings.borrow().set("api-key", value).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Application {
|
impl Default for Application {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
settings: gio::Settings::new(crate::APP_ID)
|
settings: RefCell::new(gio::Settings::new(crate::APP_ID)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,11 +42,22 @@ mod imp {
|
|||||||
|
|
||||||
impl ApplicationImpl for Application {
|
impl ApplicationImpl for Application {
|
||||||
fn activate(&self) {
|
fn activate(&self) {
|
||||||
let login_window = LoginWindow::new(&self.obj());
|
let css = gtk::CssProvider::new();
|
||||||
login_window.present();
|
gtk::style_context_add_provider_for_display(
|
||||||
|
&gdk::Display::default().unwrap(),
|
||||||
|
&css, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||||
|
);
|
||||||
|
css.load_from_string(include_str!("../data/global.css"));
|
||||||
|
if self.api_key().is_none() {
|
||||||
|
let login_window = LoginWindow::new(&self.obj());
|
||||||
|
login_window.present();
|
||||||
|
} else {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[glib::derived_properties]
|
||||||
impl ObjectImpl for Application {}
|
impl ObjectImpl for Application {}
|
||||||
impl GtkApplicationImpl for Application {}
|
impl GtkApplicationImpl for Application {}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,16 @@ mod application;
|
|||||||
|
|
||||||
use gtk4 as gtk;
|
use gtk4 as gtk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::glib::{self, g_message};
|
use gtk::glib::{self, g_info};
|
||||||
|
|
||||||
const APP_ID: &str = "im.zander.SimpleLogin";
|
const APP_ID: &str = "im.zander.SimpleLogin";
|
||||||
|
|
||||||
fn main() -> glib::ExitCode {
|
fn main() -> glib::ExitCode {
|
||||||
if cfg!(debug_assertions) {
|
#[cfg(debug_assertions)] {
|
||||||
|
std::env::set_var("G_MESSAGES_DEBUG", "SimpleLogin");
|
||||||
// allow us to use a test schema for debug runs
|
// allow us to use a test schema for debug runs
|
||||||
let schema_dir = concat!(env!("OUT_DIR"), "/schemas/");
|
let schema_dir = concat!(env!("OUT_DIR"), "/schemas/");
|
||||||
g_message!("SimpleLogin", "Using schema dir: \"{}\"", schema_dir);
|
g_info!("SimpleLogin", "Using schema dir: \"{}\"", schema_dir);
|
||||||
std::env::set_var("GSETTINGS_SCHEMA_DIR", schema_dir);
|
std::env::set_var("GSETTINGS_SCHEMA_DIR", schema_dir);
|
||||||
}
|
}
|
||||||
let app = application::Application::new(APP_ID);
|
let app = application::Application::new(APP_ID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user