1/* 2 * menu-cache.h 3 * 4 * libmenu-cache is a small convinient library used to access 5 * caches of freedesktop.org menus generated by menu-cache-gen. 6 * 7 * Copyright 2008 PCMan <pcman.tw@gmail.com> 8 * Copyright 2012-2014 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua> 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25#ifndef __MENU_CACHE_H__ 26#define __MENU_CACHE_H__ 27 28#include <glib.h> 29 30G_BEGIN_DECLS 31 32#define __VERSION_MAJOR @MC_VERSION_MAJOR@ 33#define __VERSION_MINOR @MC_VERSION_MINOR@ 34#define __VERSION_MICRO @MC_VERSION_MICRO@ 35 36#define MENU_CACHE_CHECK_VERSION(_a,_b,_c) \ 37 (__VERSION_MAJOR > _a || \ 38 (__VERSION_MAJOR == _a && __VERSION_MINOR > _b) || \ 39 (__VERSION_MAJOR == _a && __VERSION_MINOR == _b && __VERSION_MICRO >= _c)) 40 41#define MENU_CACHE_ITEM(x) ((MenuCacheItem*)x) 42#define MENU_CACHE_DIR(x) ((MenuCacheDir*)x) 43#define MENU_CACHE_APP(x) ((MenuCacheApp*)x) 44 45typedef struct _MenuCacheItem MenuCacheItem; 46typedef struct _MenuCacheDir MenuCacheDir; 47typedef struct _MenuCacheApp MenuCacheApp; 48typedef struct _MenuCache MenuCache; 49 50/** 51 * MenuCacheType: 52 * @MENU_CACHE_TYPE_NONE: invalid type 53 * @MENU_CACHE_TYPE_DIR: item #MenuCacheDir 54 * @MENU_CACHE_TYPE_APP: item #MenuCacheApp 55 * @MENU_CACHE_TYPE_SEP: menu separator 56 * 57 * type of #MenuCacheItem. 58 */ 59typedef enum 60{ 61 MENU_CACHE_TYPE_NONE, 62 MENU_CACHE_TYPE_DIR, 63 MENU_CACHE_TYPE_APP, 64 MENU_CACHE_TYPE_SEP 65}MenuCacheType; 66 67/** 68 * MenuCacheShowFlag: 69 * @SHOW_IN_LXDE: show in LXDE 70 * @SHOW_IN_GNOME: show in GNOME 71 * @SHOW_IN_KDE: show in KDE 72 * @SHOW_IN_XFCE: show in XFCE 73 * @SHOW_IN_ROX: show in ROX 74 * 75 * bitmask of desktop environments where the item should be visible. 76 */ 77typedef enum 78{ 79 SHOW_IN_LXDE = 1 << 0, 80 SHOW_IN_GNOME = 1 << 1, 81 SHOW_IN_KDE = 1 << 2, 82 SHOW_IN_XFCE = 1 << 3, 83 SHOW_IN_ROX = 1 << 4, 84 /*< private >*/ 85 N_KNOWN_DESKTOPS = 5 86}MenuCacheShowFlag; 87 88/** 89 * MenuCacheItemFlag: 90 * @FLAG_USE_TERMINAL: run this application in terminal 91 * @FLAG_USE_SN: use Startup Notify for this application 92 * @FLAG_IS_NODISPLAY: application is hidden from menu 93 * 94 * flags for application run. 95 */ 96typedef enum 97{ 98 FLAG_USE_TERMINAL = 1 << 0, 99 FLAG_USE_SN = 1 << 1, 100 FLAG_IS_NODISPLAY = 1 << 2 101}MenuCacheItemFlag; 102 103void menu_cache_init(int flags); 104 105MenuCache* menu_cache_lookup( const char* menu_name ); 106MenuCache* menu_cache_lookup_sync( const char* menu_name ); 107 108MenuCache* menu_cache_ref(MenuCache* cache); 109void menu_cache_unref(MenuCache* cache); 110 111gboolean menu_cache_reload( MenuCache* cache ); 112 113#ifndef G_DISABLE_DEPRECATED 114MenuCacheDir* menu_cache_get_root_dir( MenuCache* cache ); 115MenuCacheDir* menu_cache_get_dir_from_path( MenuCache* cache, const char* path ); 116#endif 117MenuCacheDir* menu_cache_dup_root_dir( MenuCache* cache ); 118MenuCacheItem* menu_cache_item_from_path( MenuCache* cache, const char* path ); 119 120typedef struct _MenuCacheNotifyId* MenuCacheNotifyId; 121typedef void (*MenuCacheReloadNotify)(MenuCache* cache, gpointer user_data); 122 123MenuCacheNotifyId menu_cache_add_reload_notify(MenuCache* cache, 124 MenuCacheReloadNotify func, 125 gpointer user_data); 126void menu_cache_remove_reload_notify(MenuCache* cache, MenuCacheNotifyId notify_id); 127 128guint32 menu_cache_get_desktop_env_flag( MenuCache* cache, const char* desktop_env ); 129 130MenuCacheItem* menu_cache_item_ref(MenuCacheItem* item); 131gboolean menu_cache_item_unref(MenuCacheItem* item); 132 133MenuCacheType menu_cache_item_get_type( MenuCacheItem* item ); 134const char* menu_cache_item_get_id( MenuCacheItem* item ); 135const char* menu_cache_item_get_name( MenuCacheItem* item ); 136const char* menu_cache_item_get_comment( MenuCacheItem* item ); 137const char* menu_cache_item_get_icon( MenuCacheItem* item ); 138 139const char* menu_cache_item_get_file_basename( MenuCacheItem* item ); 140const char* menu_cache_item_get_file_dirname( MenuCacheItem* item ); 141char* menu_cache_item_get_file_path( MenuCacheItem* item ); 142 143#ifndef G_DISABLE_DEPRECATED 144MenuCacheDir* menu_cache_item_get_parent( MenuCacheItem* item ); 145GSList* menu_cache_dir_get_children( MenuCacheDir* dir ); 146#endif 147MenuCacheDir* menu_cache_item_dup_parent( MenuCacheItem* item ); 148GSList* menu_cache_dir_list_children( MenuCacheDir* dir ); 149MenuCacheItem *menu_cache_find_child_by_id(MenuCacheDir *dir, const char *id); 150MenuCacheItem *menu_cache_find_child_by_name(MenuCacheDir *dir, const char *name); 151 152char* menu_cache_dir_make_path( MenuCacheDir* dir ); 153 154const char* menu_cache_app_get_generic_name( MenuCacheApp* app ); 155const char* menu_cache_app_get_exec( MenuCacheApp* app ); 156const char* menu_cache_app_get_working_dir( MenuCacheApp* app ); 157const char* const *menu_cache_app_get_categories(MenuCacheApp* app); 158 159guint32 menu_cache_app_get_show_flags( MenuCacheApp* app ); 160gboolean menu_cache_app_get_is_visible( MenuCacheApp* app, guint32 de_flags ); 161gboolean menu_cache_dir_is_visible(MenuCacheDir *dir); 162 163gboolean menu_cache_app_get_use_terminal( MenuCacheApp* app ); 164gboolean menu_cache_app_get_use_sn( MenuCacheApp* app ); 165 166GSList* menu_cache_list_all_apps(MenuCache* cache); 167GSList *menu_cache_list_all_for_category(MenuCache* cache, const char *category); 168GSList *menu_cache_list_all_for_keyword(MenuCache* cache, const char *keyword); 169 170MenuCacheItem *menu_cache_find_item_by_id(MenuCache *cache, const char *id); 171/* 172MenuCacheApp* menu_cache_find_app_by_exec( const char* exec ); 173*/ 174G_END_DECLS 175 176#endif 177