summaryrefslogtreecommitdiff
path: root/wx+/image_holder.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-07-22 11:37:03 -0400
committerB Stack <bgstack15@gmail.com>2020-07-22 11:37:03 -0400
commitc95b3937fef3e2c63768f1b3b1dc2c898f23d91d (patch)
tree10260e25ae905564f7978b83fc4e316670f987c6 /wx+/image_holder.h
parentMerge branch '10.25' into 'master' (diff)
downloadFreeFileSync-c95b3937fef3e2c63768f1b3b1dc2c898f23d91d.tar.gz
FreeFileSync-c95b3937fef3e2c63768f1b3b1dc2c898f23d91d.tar.bz2
FreeFileSync-c95b3937fef3e2c63768f1b3b1dc2c898f23d91d.zip
add upstream 11.0
Diffstat (limited to 'wx+/image_holder.h')
-rw-r--r--wx+/image_holder.h22
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
bgstack15