fix(linux): set GTK window icon from bundled app icon
This commit is contained in:
parent
c9e93f7e27
commit
136ed701a7
2 changed files with 21 additions and 0 deletions
|
|
@ -19,6 +19,24 @@ static void first_frame_cb(MyApplication* self, FlView* view) {
|
|||
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
|
||||
}
|
||||
|
||||
// GTK does not pick up an icon from the Flutter bundle; load the packaged app
|
||||
// icon so the window/taskbar shows it (X11; on Wayland the icon comes from an
|
||||
// installed .desktop file matching APPLICATION_ID).
|
||||
static void set_window_icon(GtkWindow* window) {
|
||||
g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", nullptr);
|
||||
if (exe_path == nullptr) {
|
||||
return;
|
||||
}
|
||||
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", "icon.png", nullptr);
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!gtk_window_set_icon_from_file(window, icon_path, &error)) {
|
||||
g_warning("Failed to set window icon from %s: %s", icon_path,
|
||||
error->message);
|
||||
}
|
||||
}
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
|
|
@ -53,6 +71,7 @@ static void my_application_activate(GApplication* application) {
|
|||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
set_window_icon(window);
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ flutter:
|
|||
assets:
|
||||
- assets/catalog/species.json
|
||||
- assets/logo.png
|
||||
# Bundled so the Linux runner can use it as the GTK window icon.
|
||||
- assets/icon.png
|
||||
fonts:
|
||||
# Custom seed-themed icon glyphs (chars a–k). See docs/mockups/seedks-glyphs.png.
|
||||
- family: seedks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue