[gnome-text-editor] page: only use getuid() on UNIX



commit 73f16feced5429880a3e276d118d673c19740a3d
Author: Christian Hergert <chergert redhat com>
Date:   Wed Aug 10 12:36:52 2022 -0700

    page: only use getuid() on UNIX
    
    We could probably limit this to __linux__, but I'd expect portals to
    become a thing on non-Linux too as Wayland progresses there.
    
    Fixes #450

 src/editor-page.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/editor-page.c b/src/editor-page.c
index d211532..d4e3e5c 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -22,10 +22,12 @@
 
 #include "config.h"
 
-#include <adwaita.h>
-#include <glib/gi18n.h>
 #include <unistd.h>
 
+#include <glib/gi18n.h>
+
+#include <adwaita.h>
+
 #include "editor-application-private.h"
 #include "editor-document-private.h"
 #include "editor-info-bar-private.h"
@@ -1018,7 +1020,9 @@ editor_page_dup_title (EditorPage *self)
 gchar *
 editor_page_dup_subtitle (EditorPage *self)
 {
+#ifdef G_OS_UNIX
   static char *docportal = NULL;
+#endif
   g_autoptr(GFile) dir = NULL;
   const char *peek;
   GFile *file;
@@ -1026,8 +1030,10 @@ editor_page_dup_subtitle (EditorPage *self)
   g_return_val_if_fail (EDITOR_IS_PAGE (self), NULL);
   g_return_val_if_fail (EDITOR_IS_DOCUMENT (self->document), NULL);
 
+#ifdef G_OS_UNIX
   if (docportal == NULL)
     docportal = g_strdup_printf ("/run/user/%u/doc/", getuid ());
+#endif
 
   file = editor_document_get_file (self->document);
 
@@ -1051,8 +1057,11 @@ editor_page_dup_subtitle (EditorPage *self)
     }
 
   peek = g_file_peek_path (dir);
+
+#ifdef G_OS_UNIX
   if (g_str_has_prefix (peek, docportal))
     return g_strdup (_("Document Portal"));
+#endif
 
   return _editor_path_collapse (peek);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]