Commit 3acfd456 authored by Christian Persch's avatar Christian Persch

libdocument: Add portal helper function

Add ev_should_use_portal() copied from gtk+, which tries to find
out whether the portal should be used.
parent b718b09e
...@@ -172,6 +172,10 @@ ...@@ -172,6 +172,10 @@
<title>Index of new symbols in 3.18</title> <title>Index of new symbols in 3.18</title>
<xi:include href="xml/api-index-3.18.xml"><xi:fallback /></xi:include> <xi:include href="xml/api-index-3.18.xml"><xi:fallback /></xi:include>
</index> </index>
<index id="api-index-3-30" role="3.30">
<title>Index of new symbols in 3.30</title>
<xi:include href="xml/api-index-3.30.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
......
...@@ -784,6 +784,11 @@ ev_init ...@@ -784,6 +784,11 @@ ev_init
ev_shutdown ev_shutdown
</SECTION> </SECTION>
<SECTION>
<FILE>ev-portal</FILE>
ev_should_use_portal
</SECTION>
<SECTION> <SECTION>
<FILE>ev-mapping</FILE> <FILE>ev-mapping</FILE>
EvMapping EvMapping
......
...@@ -40,6 +40,7 @@ INST_H_SRC_FILES = \ ...@@ -40,6 +40,7 @@ INST_H_SRC_FILES = \
ev-mapping-list.h \ ev-mapping-list.h \
ev-media.h \ ev-media.h \
ev-page.h \ ev-page.h \
ev-portal.h \
ev-render-context.h \ ev-render-context.h \
ev-selection.h \ ev-selection.h \
ev-transition-effect.h ev-transition-effect.h
...@@ -86,6 +87,7 @@ libevdocument3_la_SOURCES= \ ...@@ -86,6 +87,7 @@ libevdocument3_la_SOURCES= \
ev-media.c \ ev-media.c \
ev-module.c \ ev-module.c \
ev-page.c \ ev-page.c \
ev-portal.c \
ev-render-context.c \ ev-render-context.c \
ev-selection.c \ ev-selection.c \
ev-transition-effect.c \ ev-transition-effect.c \
......
/*
* Evince is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* Evince is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "ev-portal.h"
/* Copied from gtk+, under LGPL2.1+ */
/**
* ev_should_use_portal:
*
* Checks whether evince should use the portal.
*
* Returns: whether evince should use the portal
*
* Since: 3.30
*/
gboolean
ev_should_use_portal (void)
{
static const char *use_portal = NULL;
if (G_UNLIKELY (use_portal == NULL))
{
char *path;
path = g_build_filename (g_get_user_runtime_dir (), "flatpak-info", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
use_portal = "1";
else
{
use_portal = g_getenv ("GTK_USE_PORTAL");
if (!use_portal)
use_portal = "";
}
g_free (path);
}
return use_portal[0] == '1';
}
/*
* Copyright © 2018 Christian Persch
*
* Evince is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* Evince is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if !defined (__EV_EVINCE_DOCUMENT_H_INSIDE__) && !defined (EVINCE_COMPILATION)
#error "Only <evince-document.h> can be included directly."
#endif
#ifndef EV_PORTAL_H
#define EV_PORTAL_H
#include <glib.h>
G_BEGIN_DECLS
gboolean ev_should_use_portal (void);
G_END_DECLS
#endif /* EV_PORTAL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment