diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-11-06 00:13:18 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-11-06 00:13:18 +0100 |
commit | ee084bbeadfcd8667590b5b22f6693fe8bd75e2f (patch) | |
tree | d84b2de657421874dc7d0e0f87197db62cc0006f | |
parent | ee137eedf5dd59a96126f02675ffe9553812a044 (diff) |
Set window icon
-rw-r--r-- | meson.build | 18 | ||||
-rw-r--r-- | src/main.cpp | 15 |
2 files changed, 28 insertions, 5 deletions
diff --git a/meson.build b/meson.build index f3bb533..5277b5c 100644 --- a/meson.build +++ b/meson.build @@ -18,15 +18,23 @@ dep = [ dependency('ayatana-appindicator3-0.1'), ] -add_project_arguments('-DGSR_VERSION="' + meson.project_version() + '"', language: ['c', 'cpp']) - -executable('gpu-screen-recorder-gtk', src, dependencies : dep, install : true) - prefix = get_option('prefix') datadir = get_option('datadir') +icons_path = join_paths(prefix, datadir, 'icons') + +executable('gpu-screen-recorder-gtk', + src, + dependencies : dep, + install : true, + cpp_args : [ + '-DGSR_ICONS_PATH="' + icons_path + '"', + '-DGSR_VERSION="' + meson.project_version() + '"' + ] +) + install_data(files('com.dec05eba.gpu_screen_recorder.desktop'), install_dir : join_paths(prefix, datadir, 'applications')) install_data(files('com.dec05eba.gpu_screen_recorder.appdata.xml'), install_dir : join_paths(prefix, datadir, 'metainfo')) -install_subdir('icons/hicolor', install_dir : join_paths(prefix, datadir, 'icons')) +install_subdir('icons/hicolor', install_dir : icons_path) gnome = import('gnome') gnome.post_install(gtk_update_icon_cache : true, update_desktop_database : true) diff --git a/src/main.cpp b/src/main.cpp index ede8406..56d5fcf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4004,6 +4004,21 @@ static void activate(GtkApplication *app, gpointer) { gtk_window_set_title(GTK_WINDOW(window), window_title.c_str()); gtk_window_set_resizable(GTK_WINDOW(window), false); + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); +#ifdef GSR_ICONS_PATH + const char *icon_path = GSR_ICONS_PATH; +#else + const char *icon_path = "/usr/share/icons"; +#endif + gtk_icon_theme_set_search_path(icon_theme, &icon_path, 1); + + const char *icon_name = "com.dec05eba.gpu_screen_recorder"; + if(!gtk_icon_theme_has_icon(icon_theme, icon_name)) + fprintf(stderr, "Error: failed to find icon %s in %s\n", icon_name, icon_path); + + gtk_window_set_default_icon_name(icon_name); + gtk_window_set_icon_name(GTK_WINDOW(window), icon_name); + select_window_userdata.app = app; audio_inputs = get_audio_devices(); |