Use single int for launchtaskbar mode.
[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
19#include <menu-cache.h>
20#include <glib.h>
21
22#include "menu-policy.h"
b31cb1d2 23#include "private.h"
2918994e 24
fc59bb30
GP
25/* support for libmenu-cache 0.4.x */
26#ifndef MENU_CACHE_CHECK_VERSION
27# ifdef HAVE_MENU_CACHE_DIR_LIST_CHILDREN
28# define MENU_CACHE_CHECK_VERSION(_a,_b,_c) (_a == 0 && _b < 5) /* < 0.5.0 */
29# else
30# define MENU_CACHE_CHECK_VERSION(_a,_b,_c) 0 /* not even 0.4.0 */
31# endif
32#endif
33
9df6826f
HJYP
34guint32 visibility_flags = 0;
35
2918994e 36/* Allocate a menu cache. */
9df6826f 37MenuCache * panel_menu_cache_new(guint32* visibility_flags)
2918994e 38{
9df6826f 39 MenuCache* cache;
2918994e 40 if (g_getenv("XDG_MENU_PREFIX") == NULL)
41 g_setenv("XDG_MENU_PREFIX", "lxde-", TRUE);
f54249d6
AG
42#if MENU_CACHE_CHECK_VERSION(0, 5, 0)
43 /* do it the same way menu:// VFS plugin in libfm does */
44 cache = menu_cache_lookup("applications.menu+hidden");
45#else
9df6826f 46 cache = menu_cache_lookup("applications.menu");
f54249d6 47#endif
9df6826f
HJYP
48 if(visibility_flags)
49 {
50 if(is_in_lxde)
51 *visibility_flags = SHOW_IN_LXDE;
52 else
53 {
54 const char* de_name = g_getenv("XDG_CURRENT_DESKTOP");
55 if(de_name)
56 *visibility_flags = menu_cache_get_desktop_env_flag(cache, de_name);
57 else
58 *visibility_flags = SHOW_IN_LXDE|SHOW_IN_GNOME|SHOW_IN_KDE|SHOW_IN_XFCE;
59 }
60 }
61 return cache;
2918994e 62}
63
64/* Evaluate the visibility of a menu item. */
9df6826f 65gboolean panel_menu_item_evaluate_visibility(MenuCacheItem * item, guint32 visibility_flags)
2918994e 66{
9df6826f 67 return menu_cache_app_get_is_visible(MENU_CACHE_APP(item), visibility_flags);
2918994e 68}