summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/FileManager/DirectoryView.cpp2
-rw-r--r--Applications/SystemMonitor/ProcessModel.cpp2
-rw-r--r--Libraries/LibGUI/FileIconProvider.cpp17
-rw-r--r--Libraries/LibGUI/FileIconProvider.h1
-rw-r--r--Libraries/LibGUI/RunningProcessesModel.cpp2
-rw-r--r--Services/SystemMenu/main.cpp2
6 files changed, 20 insertions, 6 deletions
diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp
index d5268b7bc5..6145ba1241 100644
--- a/Applications/FileManager/DirectoryView.cpp
+++ b/Applications/FileManager/DirectoryView.cpp
@@ -46,7 +46,7 @@ namespace FileManager {
NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(const LauncherHandler&)> launch_handler)
{
- auto icon = GUI::FileIconProvider::icon_for_path(details().executable).bitmap_for_size(16);
+ auto icon = GUI::FileIconProvider::icon_for_executable(details().executable).bitmap_for_size(16);
return GUI::Action::create(details().name, move(icon), [this, launch_handler = move(launch_handler)](auto&) {
launch_handler(*this);
});
diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp
index d4c6db21bd..657560b102 100644
--- a/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Applications/SystemMonitor/ProcessModel.cpp
@@ -276,7 +276,7 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
if (role == GUI::ModelRole::Display) {
switch (index.column()) {
case Column::Icon: {
- auto icon = GUI::FileIconProvider::icon_for_path(thread.current_state.executable);
+ auto icon = GUI::FileIconProvider::icon_for_executable(thread.current_state.executable);
if (auto* bitmap = icon.bitmap_for_size(16))
return *bitmap;
return *m_generic_process_icon;
diff --git a/Libraries/LibGUI/FileIconProvider.cpp b/Libraries/LibGUI/FileIconProvider.cpp
index 3994167c96..08fc827620 100644
--- a/Libraries/LibGUI/FileIconProvider.cpp
+++ b/Libraries/LibGUI/FileIconProvider.cpp
@@ -58,6 +58,15 @@ static RefPtr<Gfx::Bitmap> s_symlink_emblem_small;
static HashMap<String, Icon> s_filetype_icons;
static HashMap<String, Vector<String>> s_filetype_patterns;
+static void initialize_executable_icon_if_needed()
+{
+ static bool initialized = false;
+ if (initialized)
+ return;
+ initialized = true;
+ s_executable_icon = Icon::default_icon("filetype-executable");
+}
+
static void initialize_if_needed()
{
static bool s_initialized = false;
@@ -78,9 +87,11 @@ static void initialize_if_needed()
s_file_icon = Icon::default_icon("filetype-unknown");
s_symlink_icon = Icon::default_icon("filetype-symlink");
s_socket_icon = Icon::default_icon("filetype-socket");
- s_executable_icon = Icon::default_icon("filetype-executable");
+
s_filetype_image_icon = Icon::default_icon("filetype-image");
+ initialize_executable_icon_if_needed();
+
for (auto& filetype : config->keys("Icons")) {
s_filetype_icons.set(filetype, Icon::default_icon(String::formatted("filetype-{}", filetype)));
s_filetype_patterns.set(filetype, config->read_entry("Icons", filetype).split(','));
@@ -127,13 +138,15 @@ Icon FileIconProvider::icon_for_path(const String& path)
return icon_for_path(path, stat.st_mode);
}
-static Icon icon_for_executable(const String& path)
+Icon FileIconProvider::icon_for_executable(const String& path)
{
static HashMap<String, Icon> app_icon_cache;
if (auto it = app_icon_cache.find(path); it != app_icon_cache.end())
return it->value;
+ initialize_executable_icon_if_needed();
+
// If the icon for an app isn't in the cache we attempt to load the file as an ELF image and extract
// the serenity_app_icon_* sections which should contain the icons as raw PNG data. In the future it would
// be better if the binary signalled the image format being used or we deduced it, e.g. using magic bytes.
diff --git a/Libraries/LibGUI/FileIconProvider.h b/Libraries/LibGUI/FileIconProvider.h
index 6d278154e1..ca3938b537 100644
--- a/Libraries/LibGUI/FileIconProvider.h
+++ b/Libraries/LibGUI/FileIconProvider.h
@@ -36,6 +36,7 @@ class FileIconProvider {
public:
static Icon icon_for_path(const String&, mode_t);
static Icon icon_for_path(const String&);
+ static Icon icon_for_executable(const String&);
static Icon filetype_image_icon();
static Icon directory_icon();
diff --git a/Libraries/LibGUI/RunningProcessesModel.cpp b/Libraries/LibGUI/RunningProcessesModel.cpp
index 2305262a80..fe10a09cde 100644
--- a/Libraries/LibGUI/RunningProcessesModel.cpp
+++ b/Libraries/LibGUI/RunningProcessesModel.cpp
@@ -55,7 +55,7 @@ void RunningProcessesModel::update()
Process process;
process.pid = it.value.pid;
process.uid = it.value.uid;
- process.icon = FileIconProvider::icon_for_path(it.value.executable).bitmap_for_size(16);
+ process.icon = FileIconProvider::icon_for_executable(it.value.executable).bitmap_for_size(16);
process.name = it.value.name;
m_processes.append(move(process));
}
diff --git a/Services/SystemMenu/main.cpp b/Services/SystemMenu/main.cpp
index fc63bf3d24..59d0c29bb6 100644
--- a/Services/SystemMenu/main.cpp
+++ b/Services/SystemMenu/main.cpp
@@ -141,7 +141,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
// Then we create and insert all the app menu items into the right place.
int app_identifier = 0;
for (const auto& app : g_apps) {
- auto icon = GUI::FileIconProvider::icon_for_path(app.executable).bitmap_for_size(16);
+ auto icon = GUI::FileIconProvider::icon_for_executable(app.executable).bitmap_for_size(16);
#ifdef SYSTEM_MENU_DEBUG
if (icon)