resolve window icon relative to executable path

The relative path failed because flutter run's cwd differs from
the bundle directory. Now reads /proc/self/exe to find the binary
location and builds the icon path from there.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 09:50:21 +02:00
co-authored by Claude Opus 4.6
parent fa0adb0998
commit 6314ce4ad1
+15 -6
View File
@@ -116,12 +116,21 @@ static void my_application_activate(GApplication* application) {
gtk_window_set_default_size(window, 1280, 720);
g_autoptr(GError) icon_error = nullptr;
GdkPixbuf* icon = gdk_pixbuf_new_from_file(
"data/flutter_assets/assets/logo/clide-logo-256.png", &icon_error);
if (icon != nullptr) {
gtk_window_set_icon(window, icon);
g_object_unref(icon);
// Resolve icon relative to the executable, not cwd.
{
g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
if (exe_path != nullptr) {
g_autofree gchar* exe_dir = g_path_get_dirname(exe_path);
g_autofree gchar* icon_path = g_build_filename(
exe_dir, "data", "flutter_assets", "assets", "logo",
"clide-logo-256.png", nullptr);
g_autoptr(GError) icon_error = nullptr;
GdkPixbuf* icon = gdk_pixbuf_new_from_file(icon_path, &icon_error);
if (icon != nullptr) {
gtk_window_set_icon(window, icon);
g_object_unref(icon);
}
}
}
g_autoptr(FlDartProject) project = fl_dart_project_new();