Branch data Line data Source code
1 : : // SPDX-License-Identifier: GPL-3.0-or-later
2 : : // SPDX-FileCopyrightText: Andy Holmes <andrew.g.r.holmes@gmail.com>
3 : :
4 : : #include "config.h"
5 : :
6 : : #include <glib/gi18n.h>
7 : : #include <libportal/portal.h>
8 : : #include <valent.h>
9 : :
10 : :
11 : : static void
12 : 0 : valent_plugin_init (void)
13 : : {
14 : 0 : PeasEngine *engine = peas_engine_get_default ();
15 : 0 : g_autofree char *xdg_plugin_dir = NULL;
16 : :
17 : : /* The package plugin directory, typically `$LIBDIR/valent/plugins`. */
18 : 0 : peas_engine_add_search_path (engine, VALENT_PLUGINSDIR, NULL);
19 : :
20 : : /* The user plugin directory as reported by XDG directories. If in a Flatpak,
21 : : * this will be `~/.var/app/APPLICATION_ID/data/PACKAGE_NAME/plugins`. */
22 : 0 : xdg_plugin_dir = g_build_filename (g_get_user_data_dir (),
23 : : PACKAGE_NAME, "plugins", NULL);
24 : 0 : peas_engine_add_search_path (engine, xdg_plugin_dir, NULL);
25 : :
26 : : /* The real user plugin directory, regardless of XDG environment variables.
27 : : * This will always be `~/.local/share/PACKAGE_NAME/plugins`. */
28 : 0 : if (xdp_portal_running_under_flatpak ())
29 : : {
30 : 0 : g_autofree char *real_plugin_dir = NULL;
31 : :
32 : 0 : real_plugin_dir = g_build_filename (g_get_home_dir (), ".local", "share",
33 : : PACKAGE_NAME, "plugins", NULL);
34 : 0 : peas_engine_add_search_path (engine, real_plugin_dir, NULL);
35 : : }
36 : 0 : }
37 : :
38 : : int
39 : 0 : main (int argc,
40 : : char *argv[])
41 : : {
42 : 0 : int ret;
43 : 0 : g_autoptr (GApplication) service = NULL;
44 : :
45 : : /* Initialize Translations */
46 : 0 : bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
47 : 0 : bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
48 : 0 : textdomain (GETTEXT_PACKAGE);
49 : :
50 : : /* Initialize Valent */
51 : 0 : valent_debug_init ();
52 : 0 : valent_plugin_init ();
53 : :
54 : 0 : if (g_getenv ("VALENT_HEADLESS") != NULL || !valent_ui_init ())
55 : 0 : g_debug ("Valent running in headless mode");
56 : :
57 : : /* Run and cleanup, before returning */
58 : 0 : g_set_application_name ("Valent");
59 : 0 : service = _valent_application_new ();
60 : 0 : ret = g_application_run (G_APPLICATION (service), argc, argv);
61 : :
62 : 0 : valent_debug_clear ();
63 : :
64 : 0 : return ret;
65 : : }
|