refactor(UI): remove unused structs and simplify GTK theme handling

This commit is contained in:
Alexandr Stelnykovych
2025-12-08 17:58:58 +02:00
parent 9a2b4f6256
commit 8c19468e32
4 changed files with 7 additions and 30 deletions

View File

@@ -186,14 +186,3 @@ impl std::convert::TryFrom<Response> for Message {
}
}
}
#[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,
}

View File

@@ -329,9 +329,6 @@ pub trait PortmasterExt<R: Runtime> {
fn portmaster(&self) -> &PortmasterInterface<R>;
}
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct Config {}
impl<R: Runtime, T: Manager<R>> PortmasterExt<R> for T {
fn portmaster(&self) -> &PortmasterInterface<R> {
self.state::<PortmasterInterface<R>>().inner()

View File

@@ -67,7 +67,7 @@ pub fn create_main_window(app: &AppHandle) -> Result<WebviewWindow> {
// Issue: https://github.com/safing/portmaster/issues/1909
// Additional info: https://github.com/tauri-apps/tauri/issues/6162#issuecomment-1423304398
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(true);
});

View File

@@ -3,7 +3,7 @@ use dataurl::DataUrl;
use gdk_pixbuf::{Pixbuf, PixbufError};
use gtk_sys::{
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 std::collections::HashMap;
@@ -20,8 +20,6 @@ use thiserror::Error;
use ini::{Ini, ParseOption};
static mut GTK_DEFAULT_THEME: Option<*mut GtkIconTheme> = None;
lazy_static! {
static ref APP_INFO_CACHE: Arc<RwLock<HashMap<String, Option<AppInfo>>>> =
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)> {
unsafe {
if GTK_DEFAULT_THEME.is_none() {
let theme = gtk_icon_theme_get_default();
if theme.is_null() {
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);
}
// gtk_icon_theme_get_default() is lightweight - it returns a borrowed reference to GTK's singleton icon theme
let theme = unsafe { gtk_icon_theme_get_default() };
if theme.is_null() {
return Err(Error::new(ErrorKind::Other, "GTK not initialized").into());
}
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 icon_info = gtk_icon_theme_lookup_icon(
GTK_DEFAULT_THEME.unwrap(),
theme,
c_str.as_ptr() as *const c_char,
size as c_int,
0,