Skip to content

Commit 109c46f

Browse files
committed
🐛 fix: fix: icon resolution, app mode indicator, and Wayland app-id
- Fix SVG icons rendering blurry: resolve_icon_path now returns icon name (not absolute path) for hicolor theme icons, letting GTK render SVGs at correct pixel size. File-based SVGs use gdk-pixbuf for rasterization at 2x target size. - Fix app mode missing browser indicator: show application-x-executable icon with "App mode" tooltip when webapp uses built-in viewer. - Fix Wayland dock icon: change APP_ID to br.com.biglinux.webapps to match .desktop file name. Update StartupWMClass accordingly. - Reduce webapp list icon size from 64px to 48px for better proportion. - Add gdk-pixbuf dependency for high-quality SVG rasterization.
1 parent 0afaf86 commit 109c46f

7 files changed

Lines changed: 34 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ webkit6 = { version = "0.6", features = ["v2_50"] }
1919
glib = { package = "glib", version = "0.22" }
2020
gio = { package = "gio", version = "0.22" }
2121
gdk4 = { package = "gdk4", version = "0.11" }
22+
gdk-pixbuf = { package = "gdk-pixbuf", version = "0.22" }
2223
serde = { version = "1", features = ["derive"] }
2324
serde_json = "1"
2425
log = "0.4"

biglinux-webapps/usr/share/applications/br.com.biglinux.webapps.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Name[uk]=Додавання та видалення веб-програм
3030
Name[zh]=添加和删除 Web 应用
3131
Icon=big-webapps
3232
Exec=big-webapps-gui
33-
StartupWMClass=big-webapps-gui
33+
StartupWMClass=br.com.biglinux.webapps
3434
Categories=GTK;Utility;
3535
Terminal=false
3636
StartupNotify=true

crates/webapps-core/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::PathBuf;
22

33
pub const APP_VERSION: &str = "4.0.0";
4-
pub const APP_ID: &str = "com.biglinux.WebApps";
4+
pub const APP_ID: &str = "br.com.biglinux.webapps";
55

66
/// Config dir: ~/.config/biglinux-webapps/
77
pub fn config_dir() -> PathBuf {

crates/webapps-manager/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ libadwaita.workspace = true
1515
glib.workspace = true
1616
gio.workspace = true
1717
gdk4.workspace = true
18+
gdk-pixbuf.workspace = true
1819
serde.workspace = true
1920
serde_json.workspace = true
2021
log.workspace = true

crates/webapps-manager/src/service.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,20 +568,20 @@ pub fn resolve_icon_path(icon: &str) -> String {
568568
return candidate.to_string_lossy().to_string();
569569
}
570570
}
571-
// user-local hicolor
571+
// user-local hicolor — return icon name so GTK theme renders SVG at correct size
572572
let hicolor_user = local_icons.join("hicolor/scalable/apps");
573573
for ext in &["svg", "png"] {
574574
let candidate = hicolor_user.join(format!("{icon}.{ext}"));
575575
if candidate.exists() {
576-
return candidate.to_string_lossy().to_string();
576+
return icon.to_string();
577577
}
578578
}
579-
// system hicolor
579+
// system hicolor — return icon name for GTK theme lookup
580580
let hicolor_sys = PathBuf::from("/usr/share/icons/hicolor/scalable/apps");
581581
for ext in &["svg", "png"] {
582582
let candidate = hicolor_sys.join(format!("{icon}.{ext}"));
583583
if candidate.exists() {
584-
return candidate.to_string_lossy().to_string();
584+
return icon.to_string();
585585
}
586586
}
587587
// system icons dir (biglinux-specific)

crates/webapps-manager/src/webapp_row.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use libadwaita as adw;
44

55
use adw::prelude::*;
66
use gettextrs::gettext;
7-
use webapps_core::models::WebApp;
7+
use webapps_core::models::{AppMode, WebApp};
88

99
use crate::service;
1010

@@ -23,18 +23,20 @@ pub fn build_row(webapp: &WebApp, callbacks: &std::rc::Rc<RowCallbacks>) -> gtk:
2323
hbox.set_margin_start(12);
2424
hbox.set_margin_end(12);
2525

26-
// icon
26+
// icon — prefer icon name for theme lookup (crisp SVG at any size)
2727
let icon = gtk::Image::new();
28-
icon.set_pixel_size(64);
28+
icon.set_pixel_size(48);
2929
let icon_path = service::resolve_icon_path(&webapp.app_icon);
3030
let p = std::path::Path::new(&icon_path);
3131
if p.is_absolute() && p.exists() {
32-
// load from file — use paintable for SVGs to get crisp rendering
3332
if icon_path.ends_with(".svg") {
34-
if let Ok(tex) = gdk4::Texture::from_filename(p) {
35-
icon.set_paintable(Some(&tex));
36-
} else {
37-
icon.set_from_file(Some(p));
33+
// rasterize SVG at 2x target → crisp on HiDPI
34+
match gdk_pixbuf::Pixbuf::from_file_at_size(p, 192, 192) {
35+
Ok(pixbuf) => {
36+
let tex = gdk4::Texture::for_pixbuf(&pixbuf);
37+
icon.set_paintable(Some(&tex));
38+
}
39+
Err(_) => icon.set_from_file(Some(p)),
3840
}
3941
} else {
4042
icon.set_from_file(Some(p));
@@ -69,13 +71,22 @@ pub fn build_row(webapp: &WebApp, callbacks: &std::rc::Rc<RowCallbacks>) -> gtk:
6971
actions.add_css_class("linked");
7072
actions.set_valign(gtk::Align::Center);
7173

72-
// browser indicator button
73-
let browser_icon_name = webapps_core::models::Browser {
74-
browser_id: webapp.browser.clone(),
75-
is_default: false,
76-
}.icon_name();
74+
// browser indicator — show app icon for App mode, browser icon otherwise
75+
let browser_icon_name = if webapp.app_mode == AppMode::App {
76+
"application-x-executable-symbolic".to_string()
77+
} else {
78+
webapps_core::models::Browser {
79+
browser_id: webapp.browser.clone(),
80+
is_default: false,
81+
}.icon_name()
82+
};
7783
let browser_btn = gtk::Button::from_icon_name(&browser_icon_name);
78-
browser_btn.set_tooltip_text(Some(&gettext("Change browser")));
84+
let browser_tooltip = if webapp.app_mode == AppMode::App {
85+
gettext("App mode")
86+
} else {
87+
gettext("Change browser")
88+
};
89+
browser_btn.set_tooltip_text(Some(&browser_tooltip));
7990
browser_btn.add_css_class("flat");
8091
{
8192
let cb = callbacks.clone();

0 commit comments

Comments
 (0)