add icon into linux build

This commit is contained in:
shahriaarrr committed 2025-12-25 16:05:46 +03:30
1 parent 1f30b66569
commit 3cafd862f9
2 files changed
+15

No files matched your search

+2
View File
@@ -24,3 +24,5 @@ target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
target_compile_features(${BINARY_NAME} PUBLIC cxx_std_17)
+13
View File
@@ -5,6 +5,10 @@
#include <gdk/gdkx.h>
#endif
#include <filesystem>
using namespace std;
using namespace std::filesystem;
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
@@ -25,6 +29,15 @@ static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
const string iconFilename = "assets/icon/1.png";
path execDir = canonical(read_symlink("/proc/self/exe")).parent_path();
path iconPath = execDir / "data/flutter_assets" / iconFilename;
gtk_window_set_icon_from_file(
window,
iconPath.c_str(),
nullptr
);
// Use a header bar when running in GNOME as this is the common style used
// by applications and is the setup most users will be using (e.g. Ubuntu