Skip to content

Commit

Permalink
Add app icon for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
petlyh committed Jun 19, 2024
1 parent f5aae1a commit 732d697
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

#include "flutter/generated_plugin_registrant.h"

#include <filesystem>

using namespace std;
using namespace std::filesystem;

struct _MyApplication {
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
Expand All @@ -20,6 +25,12 @@ static void my_application_activate(GApplication* application) {
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));

// custom icon
const string iconFilename = "assets/icon.png";
path execDir = canonical(read_symlink("/proc/self/exe")).parent_path();
path iconPath = execDir / "data/flutter_assets" / iconFilename;
gtk_window_set_icon_from_file(GTK_WINDOW(window), iconPath.c_str(), NULL);

// 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
// desktop).
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ flutter:
uses-material-design: true

assets:
- assets/icon.png
- assets/userdata-empty.dat

flutter_launcher_icons:
Expand Down

0 comments on commit 732d697

Please sign in to comment.