summaryrefslogtreecommitdiff
path: root/mate-panel/panel-modules.c
blob: af26d63450adc0a51e67b5f92289aa59ccc56c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * panel-modules.c
 *
 * Copyright (C) 2010 Vincent Untz <vuntz@gnome.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 * Authors:
 *      Vincent Untz <vuntz@gnome.org>
 */

#include <config.h>
#include <gio/gio.h>

#include <libmate-panel-applet-private/panel-applets-manager-dbus.h>

#include "panel-applets-manager.h"
#include "panel-modules.h"

static void
panel_modules_ensure_extension_points_registered (void)
{
	static gboolean registered_extensions = FALSE;
	GIOExtensionPoint *ep;

	if (!registered_extensions) {
		registered_extensions = TRUE;

		ep = g_io_extension_point_register (MATE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME);
		g_io_extension_point_set_required_type (ep, PANEL_TYPE_APPLETS_MANAGER);
	}
 }

void
panel_modules_ensure_loaded (void)
{
	static gboolean loaded_dirs = FALSE;
	const char *module_path;

	panel_modules_ensure_extension_points_registered ();

	if (!loaded_dirs) {
		GList *modules;
		loaded_dirs = TRUE;

		/* We load the modules explicitly instead of using scan_all
		 * so that we can leak a reference to them.  This prevents them
		 * from getting unloaded later (something they aren't designed
		 * to cope with) */
		modules = g_io_modules_load_all_in_directory (PANEL_MODULES_DIR);
		g_list_free (modules);

		module_path = g_getenv ("MATE_PANEL_EXTRA_MODULES");

		if (module_path) {
			gchar **paths;
			int i;

			paths = g_strsplit (module_path, ":", 0);

			for (i = 0; paths[i] != NULL; i++) {
				modules = g_io_modules_load_all_in_directory (paths[i]);
				g_list_free (modules);
			}

			g_strfreev (paths);
		}

		mate_panel_applets_manager_dbus_get_type ();
	}
}