summaryrefslogtreecommitdiff
path: root/src/eom-util.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2025-07-24 09:23:56 -0400
committerVictor Kareh <[email protected]>2025-08-05 18:42:54 +0000
commit75d7f546d53f6bf50190e206c39c8eddd258d298 (patch)
treedd6a6e741ed2117bfea141b4b598ba9afffed318 /src/eom-util.c
parentbe3bbcc4144c69d0f65ab07aeb3e4e69e74d12a9 (diff)
downloadeom-75d7f546d53f6bf50190e206c39c8eddd258d298.tar.bz2
eom-75d7f546d53f6bf50190e206c39c8eddd258d298.tar.xz
EomUtil: Add helper to get content type from GFileInfos
This prefers the real content type, but automatically falls back to the fast content type the other one isn't set in the GFileInfo. Backported from https://gitlab.gnome.org/GNOME/eog/-/commit/4f80d090fd8f27c8d430dfe5931ea53446643ec7
Diffstat (limited to 'src/eom-util.c')
-rw-r--r--src/eom-util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/eom-util.c b/src/eom-util.c
index e914223..a839f6f 100644
--- a/src/eom-util.c
+++ b/src/eom-util.c
@@ -482,3 +482,21 @@ eom_notebook_scroll_event_cb (GtkWidget *widget,
return TRUE;
}
+
+const char*
+eom_util_get_content_type_with_fallback (GFileInfo *file_info)
+{
+ g_return_val_if_fail (file_info != NULL, NULL);
+
+ if (g_file_info_has_attribute (file_info,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
+ return g_file_info_get_content_type (file_info);
+ else if (g_file_info_has_attribute (file_info,
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE))
+ return g_file_info_get_attribute_string (file_info,
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+ else
+ g_warn_if_reached ();
+
+ return NULL;
+}