summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2025-07-24 09:23:56 -0400
committerVictor Kareh <[email protected]>2025-07-24 09:27:45 -0400
commit1dcda49f5ca719dfea822a34ac7925246875240f (patch)
treedd6a6e741ed2117bfea141b4b598ba9afffed318
parentbe3bbcc4144c69d0f65ab07aeb3e4e69e74d12a9 (diff)
downloadeom-1dcda49f5ca719dfea822a34ac7925246875240f.tar.bz2
eom-1dcda49f5ca719dfea822a34ac7925246875240f.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
-rw-r--r--src/eom-util.c18
-rw-r--r--src/eom-util.h3
2 files changed, 21 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;
+}
diff --git a/src/eom-util.h b/src/eom-util.h
index d08b88a..9f2c370 100644
--- a/src/eom-util.h
+++ b/src/eom-util.h
@@ -68,6 +68,9 @@ void eom_util_show_file_in_filemanager (GFile *file,
gboolean eom_notebook_scroll_event_cb (GtkWidget *notebook,
GdkEventScroll *event);
+G_GNUC_INTERNAL
+const char *eom_util_get_content_type_with_fallback (GFileInfo *file_info);
+
G_END_DECLS
#endif /* __EOM_UTIL_H__ */