mirror of
https://gitlab.gnome.org/GNOME/evince
synced 2024-06-30 22:54:23 +00:00
libdocument: Add portal helper function
Add ev_should_use_portal() copied from gtk+, which tries to find out whether the portal should be used.
This commit is contained in:
parent
454a350963
commit
fdc8c4375d
53
libdocument/ev-portal.c
Normal file
53
libdocument/ev-portal.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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';
|
||||
}
|
33
libdocument/ev-portal.h
Normal file
33
libdocument/ev-portal.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (EVINCE_COMPILATION)
|
||||
#error "This is a private header."
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "ev-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
EV_PRIVATE
|
||||
gboolean ev_should_use_portal (void);
|
||||
|
||||
G_END_DECLS
|
|
@ -37,6 +37,7 @@ headers = files(
|
|||
'ev-mapping-list.h',
|
||||
'ev-media.h',
|
||||
'ev-page.h',
|
||||
'ev-portal.h',
|
||||
'ev-render-context.h',
|
||||
'ev-selection.h',
|
||||
'ev-transition-effect.h',
|
||||
|
@ -83,6 +84,7 @@ sources = files(
|
|||
'ev-media.c',
|
||||
'ev-module.c',
|
||||
'ev-page.c',
|
||||
'ev-portal.c',
|
||||
'ev-render-context.c',
|
||||
'ev-selection.c',
|
||||
'ev-transition-effect.c',
|
||||
|
|
Loading…
Reference in New Issue
Block a user