clan-app: prepare icon support on linux

For some reason the icon is not shown when using the gtk backend but at
least the API calls look correct.
This commit is contained in:
Jörg Thalheim
2025-05-14 15:24:24 +02:00
parent 172d571804
commit 3eb8af34fc
4 changed files with 22 additions and 2 deletions

View File

@@ -39,6 +39,8 @@ def app_run(app_opts: ClanAppOptions) -> int:
webview = Webview(debug=app_opts.debug) webview = Webview(debug=app_opts.debug)
webview.title = "Clan App" webview.title = "Clan App"
# This seems to call the gtk api correctly but and gtk also seems to our icon, but somehow the icon is not loaded.
webview.icon = "clan-white"
def cancel_task( def cancel_task(
task_id: str, *, op_key: str task_id: str, *, op_key: str

View File

@@ -88,6 +88,9 @@ class _WebviewLibrary:
self.webview_set_title = self.lib.webview_set_title self.webview_set_title = self.lib.webview_set_title
self.webview_set_title.argtypes = [c_void_p, c_char_p] self.webview_set_title.argtypes = [c_void_p, c_char_p]
self.webview_set_icon = self.lib.webview_set_icon
self.webview_set_icon.argtypes = [c_void_p, c_char_p]
self.webview_set_size = self.lib.webview_set_size self.webview_set_size = self.lib.webview_set_size
self.webview_set_size.argtypes = [c_void_p, c_int, c_int, c_int] self.webview_set_size.argtypes = [c_void_p, c_int, c_int, c_int]

View File

@@ -84,6 +84,15 @@ class Webview:
_webview_lib.webview_set_title(self._handle, _encode_c_string(value)) _webview_lib.webview_set_title(self._handle, _encode_c_string(value))
self._title = value self._title = value
@property
def icon(self) -> str:
return self._icon
@icon.setter
def icon(self, value: str) -> None:
_webview_lib.webview_set_icon(self._handle, _encode_c_string(value))
self._icon = value
def destroy(self) -> None: def destroy(self) -> None:
for name in list(self._callbacks.keys()): for name in list(self._callbacks.keys()):
self.unbind(name) self.unbind(name)

View File

@@ -11,8 +11,8 @@ pkgs.clangStdenv.mkDerivation {
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "clan-lol"; owner = "clan-lol";
repo = "webview"; repo = "webview";
rev = "33374e1030c5e243dac491e6c0e84d32e895c2e5"; rev = "7d24f0192765b7e08f2d712fae90c046d08f318e";
sha256 = "sha256-8BgfQL0V3f2n5lq5MDwJCJo6MkVSYvJkwpKCj2tBRz8="; hash = "sha256-yokVI9tFiEEU5M/S2xAeJOghqqiCvTelLo8WLKQZsSY=";
}; };
outputs = [ outputs = [
@@ -20,6 +20,12 @@ pkgs.clangStdenv.mkDerivation {
"dev" "dev"
]; ];
enableParallelBuilding = true;
cmakeFlags = [
"-DWEBVIEW_BUILD_TESTS=OFF"
];
# Dependencies used during the build process, if any # Dependencies used during the build process, if any
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
gnumake gnumake