Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / patches / xfce4-panel-plugins.patch
1 Search for xfce4 panel plugins in the directories specified
2 in XDG_DATA_DIRS and X_XFCE4_LIB_DIRS. For discussion of the
3 relevant issues, see:
4
5 https://bugzilla.xfce.org/show_bug.cgi?id=5455
6
7 Patch by Mark H Weaver <mhw@netris.org>
8
9 --- xfce4-panel-4.10.0/panel/panel-module.c.orig 2012-04-28 16:31:35.000000000 -0400
10 +++ xfce4-panel-4.10.0/panel/panel-module.c 2014-12-14 01:31:55.728107386 -0500
11 @@ -35,8 +35,14 @@
12 #include <panel/panel-plugin-external-wrapper.h>
13 #include <panel/panel-plugin-external-46.h>
14
15 -#define PANEL_PLUGINS_LIB_DIR (LIBDIR G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins")
16 -#define PANEL_PLUGINS_LIB_DIR_OLD (LIBDIR G_DIR_SEPARATOR_S "panel-plugins")
17 +#define PANEL_PLUGINS_LIB_DIR_TAIL (G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins")
18 +#define PANEL_PLUGINS_LIB_DIR_TAIL_OLD (G_DIR_SEPARATOR_S "panel-plugins")
19 +
20 +static const gchar *plugins_lib_dir_tails[] =
21 +{
22 + PANEL_PLUGINS_LIB_DIR_TAIL,
23 + PANEL_PLUGINS_LIB_DIR_TAIL_OLD
24 +};
25
26
27 typedef enum _PanelModuleRunMode PanelModuleRunMode;
28 @@ -335,21 +341,39 @@
29 /* show a messsage if the old module path key still exists */
30 g_message ("Plugin %s: The \"X-XFCE-Module-Path\" key is "
31 "ignored in \"%s\", the panel will look for the "
32 - "module in %s. See bug #5455 why this decision was made",
33 - name, filename, PANEL_PLUGINS_LIB_DIR);
34 + "module in DIR%s for each DIR in $X_XFCE4_LIB_DIRS "
35 + "(%s by default). See bug #5455 for discussion.",
36 + name, filename, PANEL_PLUGINS_LIB_DIR_TAIL, LIBDIR);
37 }
38 #endif
39
40 - path = g_module_build_path (PANEL_PLUGINS_LIB_DIR, module_name);
41 - found = g_file_test (path, G_FILE_TEST_EXISTS);
42 + /* search for module */
43 + {
44 + gchar *dirs_string;
45 + gchar **dirs;
46 + int i, j;
47 +
48 + dirs_string = (gchar *) g_getenv ("X_XFCE4_LIB_DIRS");
49 + if (!dirs_string)
50 + dirs_string = LIBDIR;
51 + dirs = g_strsplit (dirs_string, G_SEARCHPATH_SEPARATOR_S, 0);
52 +
53 + found = FALSE;
54 + path = NULL;
55 +
56 + for (i = 0; !found && dirs[i] != NULL; i++)
57 + for (j = 0; !found && j < G_N_ELEMENTS (plugins_lib_dir_tails); j++)
58 + {
59 + gchar *dir = g_strconcat (dirs[i], plugins_lib_dir_tails[j], NULL);
60 +
61 + g_free (path);
62 + path = g_module_build_path (dir, module_name);
63 + found = g_file_test (path, G_FILE_TEST_EXISTS);
64 + g_free (dir);
65 + }
66
67 - if (!found)
68 - {
69 - /* deprecated location for module plugin directories */
70 - g_free (path);
71 - path = g_module_build_path (PANEL_PLUGINS_LIB_DIR_OLD, module_name);
72 - found = g_file_test (path, G_FILE_TEST_EXISTS);
73 - }
74 + g_strfreev (dirs);
75 + }
76
77 if (G_LIKELY (found))
78 {
79 --- xfce4-panel-4.10.0/panel/panel-module-factory.c.orig 2012-04-28 16:31:35.000000000 -0400
80 +++ xfce4-panel-4.10.0/panel/panel-module-factory.c 2014-12-13 23:55:27.439404812 -0500
81 @@ -42,6 +42,11 @@
82 #define PANEL_PLUGINS_DATA_DIR (DATADIR G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins")
83 #define PANEL_PLUGINS_DATA_DIR_OLD (DATADIR G_DIR_SEPARATOR_S "panel-plugins")
84
85 +static const gchar *plugins_data_dir_tails[] =
86 +{
87 + (G_DIR_SEPARATOR_S "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins"),
88 + (G_DIR_SEPARATOR_S "xfce4" G_DIR_SEPARATOR_S "panel-plugins")
89 +};
90
91
92 static void panel_module_factory_finalize (GObject *object);
93 @@ -223,8 +228,22 @@
94 panel_module_factory_load_modules (PanelModuleFactory *factory,
95 gboolean warn_if_known)
96 {
97 + const gchar * const * system_data_dirs;
98 + int i, j;
99 +
100 panel_return_if_fail (PANEL_IS_MODULE_FACTORY (factory));
101
102 + system_data_dirs = g_get_system_data_dirs ();
103 + for (i = 0; system_data_dirs[i] != NULL; i++)
104 + for (j = 0; j < G_N_ELEMENTS (plugins_data_dir_tails); j++)
105 + {
106 + gchar *dir;
107 +
108 + dir = g_strconcat (system_data_dirs[i], plugins_data_dir_tails[j], NULL);
109 + panel_module_factory_load_modules_dir (factory, dir, warn_if_known);
110 + g_free (dir);
111 + }
112 +
113 /* load from the new and old location */
114 panel_module_factory_load_modules_dir (factory, PANEL_PLUGINS_DATA_DIR, warn_if_known);
115 panel_module_factory_load_modules_dir (factory, PANEL_PLUGINS_DATA_DIR_OLD, warn_if_known);