Add support for monitors "All" to span panel over all monitors.
[lxde/lxpanel.git] / src / menu-policy.c
CommitLineData
2918994e 1/**
2 * Copyright (c) 2009 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
1a2e1173
AG
19#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
2918994e 23#include <glib.h>
24
25#include "menu-policy.h"
b31cb1d2 26#include "private.h"
2918994e 27
fc59bb30
GP
28/* support for libmenu-cache 0.4.x */
29#ifndef MENU_CACHE_CHECK_VERSION
30# ifdef HAVE_MENU_CACHE_DIR_LIST_CHILDREN
31# define MENU_CACHE_CHECK_VERSION(_a,_b,_c) (_a == 0 && _b < 5) /* < 0.5.0 */
32# else
33# define MENU_CACHE_CHECK_VERSION(_a,_b,_c) 0 /* not even 0.4.0 */
34# endif
35#endif
36
2918994e 37/* Allocate a menu cache. */
9df6826f 38MenuCache * panel_menu_cache_new(guint32* visibility_flags)
2918994e 39{
9df6826f 40 MenuCache* cache;
2dd26a83
AG
41 gboolean need_prefix = (g_getenv("XDG_MENU_PREFIX") == NULL);
42
f54249d6
AG
43#if MENU_CACHE_CHECK_VERSION(0, 5, 0)
44 /* do it the same way menu:// VFS plugin in libfm does */
2dd26a83 45 cache = menu_cache_lookup(need_prefix ? "lxde-applications.menu+hidden" : "applications.menu+hidden");
f54249d6 46#else
2dd26a83 47 cache = menu_cache_lookup(need_prefix ? "lxde-applications.menu" : "applications.menu");
f54249d6 48#endif
9df6826f
HJYP
49 if(visibility_flags)
50 {
51 if(is_in_lxde)
52 *visibility_flags = SHOW_IN_LXDE;
53 else
54 {
55 const char* de_name = g_getenv("XDG_CURRENT_DESKTOP");
56 if(de_name)
57 *visibility_flags = menu_cache_get_desktop_env_flag(cache, de_name);
58 else
59 *visibility_flags = SHOW_IN_LXDE|SHOW_IN_GNOME|SHOW_IN_KDE|SHOW_IN_XFCE;
60 }
61 }
62 return cache;
2918994e 63}
64
65/* Evaluate the visibility of a menu item. */
9df6826f 66gboolean panel_menu_item_evaluate_visibility(MenuCacheItem * item, guint32 visibility_flags)
2918994e 67{
9df6826f 68 return menu_cache_app_get_is_visible(MENU_CACHE_APP(item), visibility_flags);
2918994e 69}