diff options
author | B Stack <bgstack15@gmail.com> | 2020-07-22 16:56:03 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-07-22 16:56:03 +0000 |
commit | e5633fb1c0db91f01ab967330b76baf4ecdb0512 (patch) | |
tree | 10260e25ae905564f7978b83fc4e316670f987c6 /wx+/image_holder.h | |
parent | Merge branch '10.25' into 'master' (diff) | |
parent | add upstream 11.0 (diff) | |
download | FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.tar.gz FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.tar.bz2 FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.zip |
Merge branch '11.0' into 'master'11.0
add upstream 11.0
See merge request opensource-tracking/FreeFileSync!24
Diffstat (limited to 'wx+/image_holder.h')
-rw-r--r-- | wx+/image_holder.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/wx+/image_holder.h b/wx+/image_holder.h index b11ae451..32f8a863 100644 --- a/wx+/image_holder.h +++ b/wx+/image_holder.h @@ -8,7 +8,7 @@ #define IMAGE_HOLDER_H_284578426342567457 #include <memory> - + #include <gio/gio.h> //used by fs/abstract.h => check carefully before adding dependencies! //DO NOT add any wx/wx+ includes! @@ -47,6 +47,26 @@ private: std::unique_ptr<unsigned char, CLibFree> rgb_; //optional std::unique_ptr<unsigned char, CLibFree> alpha_; // }; + + +struct FileIconHolder +{ + //- GTK is NOT thread-safe! The most we can do from worker threads is retrieve a GIcon and later *try*(!) to convert it on the MAIN THREAD! >:( what a waste + //- at least g_file_query_info() *always* returns G_IS_THEMED_ICON(gicon) for native file systems => main thread won't block https://gitlab.gnome.org/GNOME/glib/blob/master/gio/glocalfileinfo.c#L1733 + //- what about G_IS_FILE_ICON(gicon), G_IS_LOADABLE_ICON(gicon)? => may block! => do NOT convert on main thread! (no big deal: doesn't seem to occur in practice) + FileIconHolder() {}; + + FileIconHolder(GIcon* gi, int maxSz) : //takes ownership! + gicon(gi), + maxSize(maxSz) {} + + struct GiconFree { void operator()(GIcon* icon) const { ::g_object_unref(icon); } }; + + std::unique_ptr<GIcon, GiconFree> gicon; + int maxSize = 0; + + explicit operator bool() const { return static_cast<bool>(gicon); } +}; } #endif //IMAGE_HOLDER_H_284578426342567457 |