refactor(UI): remove unused structs and simplify GTK theme handling
This commit is contained in:
@@ -185,15 +185,4 @@ impl std::convert::TryFrom<Response> for Message {
|
|||||||
Response::Done => Ok(Message{id: 0, cmd: "done".to_string(), key: None, payload: None}),
|
Response::Done => Ok(Message{id: 0, cmd: "done".to_string(), key: None, payload: None}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
|
||||||
#[serde(rename_all = "UPPERCASE")]
|
|
||||||
pub struct Record {
|
|
||||||
pub created: u64,
|
|
||||||
pub deleted: u64,
|
|
||||||
pub expires: u64,
|
|
||||||
pub modified: u64,
|
|
||||||
pub key: String,
|
|
||||||
}
|
}
|
||||||
@@ -329,9 +329,6 @@ pub trait PortmasterExt<R: Runtime> {
|
|||||||
fn portmaster(&self) -> &PortmasterInterface<R>;
|
fn portmaster(&self) -> &PortmasterInterface<R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
|
||||||
pub struct Config {}
|
|
||||||
|
|
||||||
impl<R: Runtime, T: Manager<R>> PortmasterExt<R> for T {
|
impl<R: Runtime, T: Manager<R>> PortmasterExt<R> for T {
|
||||||
fn portmaster(&self) -> &PortmasterInterface<R> {
|
fn portmaster(&self) -> &PortmasterInterface<R> {
|
||||||
self.state::<PortmasterInterface<R>>().inner()
|
self.state::<PortmasterInterface<R>>().inner()
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ pub fn create_main_window(app: &AppHandle) -> Result<WebviewWindow> {
|
|||||||
// Issue: https://github.com/safing/portmaster/issues/1909
|
// Issue: https://github.com/safing/portmaster/issues/1909
|
||||||
// Additional info: https://github.com/tauri-apps/tauri/issues/6162#issuecomment-1423304398
|
// Additional info: https://github.com/tauri-apps/tauri/issues/6162#issuecomment-1423304398
|
||||||
let win_clone = win.clone();
|
let win_clone = win.clone();
|
||||||
win.listen("tauri://focus", move |event| {
|
win.listen("tauri://focus", move |_event| {
|
||||||
let _ = win_clone.set_resizable(false);
|
let _ = win_clone.set_resizable(false);
|
||||||
let _ = win_clone.set_resizable(true);
|
let _ = win_clone.set_resizable(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use dataurl::DataUrl;
|
|||||||
use gdk_pixbuf::{Pixbuf, PixbufError};
|
use gdk_pixbuf::{Pixbuf, PixbufError};
|
||||||
use gtk_sys::{
|
use gtk_sys::{
|
||||||
gtk_icon_info_free, gtk_icon_info_get_filename, gtk_icon_theme_get_default,
|
gtk_icon_info_free, gtk_icon_info_get_filename, gtk_icon_theme_get_default,
|
||||||
gtk_icon_theme_lookup_icon, GtkIconTheme,
|
gtk_icon_theme_lookup_icon,
|
||||||
};
|
};
|
||||||
use log::{debug, error};
|
use log::{debug, error};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -20,8 +20,6 @@ use thiserror::Error;
|
|||||||
|
|
||||||
use ini::{Ini, ParseOption};
|
use ini::{Ini, ParseOption};
|
||||||
|
|
||||||
static mut GTK_DEFAULT_THEME: Option<*mut GtkIconTheme> = None;
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref APP_INFO_CACHE: Arc<RwLock<HashMap<String, Option<AppInfo>>>> =
|
static ref APP_INFO_CACHE: Arc<RwLock<HashMap<String, Option<AppInfo>>>> =
|
||||||
Arc::new(RwLock::new(HashMap::new()));
|
Arc::new(RwLock::new(HashMap::new()));
|
||||||
@@ -352,17 +350,10 @@ fn parse_app_info(props: &ini::Properties) -> AppInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_icon_as_png_dataurl(name: &str, size: i8) -> Result<(String, String)> {
|
fn get_icon_as_png_dataurl(name: &str, size: i8) -> Result<(String, String)> {
|
||||||
unsafe {
|
// gtk_icon_theme_get_default() is lightweight - it returns a borrowed reference to GTK's singleton icon theme
|
||||||
if GTK_DEFAULT_THEME.is_none() {
|
let theme = unsafe { gtk_icon_theme_get_default() };
|
||||||
let theme = gtk_icon_theme_get_default();
|
if theme.is_null() {
|
||||||
if theme.is_null() {
|
return Err(Error::new(ErrorKind::Other, "GTK not initialized").into());
|
||||||
debug!("You have to initialize GTK!");
|
|
||||||
return Err(Error::new(ErrorKind::Other, "You have to initialize GTK!").into());
|
|
||||||
}
|
|
||||||
|
|
||||||
let theme = gtk_icon_theme_get_default();
|
|
||||||
GTK_DEFAULT_THEME = Some(theme);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut icons = Vec::new();
|
let mut icons = Vec::new();
|
||||||
@@ -402,7 +393,7 @@ fn get_icon_as_png_dataurl(name: &str, size: i8) -> Result<(String, String)> {
|
|||||||
let c_str = CString::new(name).unwrap();
|
let c_str = CString::new(name).unwrap();
|
||||||
|
|
||||||
let icon_info = gtk_icon_theme_lookup_icon(
|
let icon_info = gtk_icon_theme_lookup_icon(
|
||||||
GTK_DEFAULT_THEME.unwrap(),
|
theme,
|
||||||
c_str.as_ptr() as *const c_char,
|
c_str.as_ptr() as *const c_char,
|
||||||
size as c_int,
|
size as c_int,
|
||||||
0,
|
0,
|
||||||
|
|||||||
Reference in New Issue
Block a user