diff options
Diffstat (limited to 'libmenu/matemenu-tree.h')
-rw-r--r-- | libmenu/matemenu-tree.h | 189 |
1 files changed, 108 insertions, 81 deletions
diff --git a/libmenu/matemenu-tree.h b/libmenu/matemenu-tree.h index cd3e45b..3fd3260 100644 --- a/libmenu/matemenu-tree.h +++ b/libmenu/matemenu-tree.h @@ -20,116 +20,143 @@ #ifndef __MATEMENU_TREE_H__ #define __MATEMENU_TREE_H__ -#include <glib.h> - -#ifdef __cplusplus -extern "C" { +#ifndef MATEMENU_I_KNOW_THIS_IS_UNSTABLE +#error "libmate-menu should only be used if you understand that it's subject to frequent change, and is not supported as a fixed API/ABI or as part of the platform" #endif -typedef struct MateMenuTree MateMenuTree; -typedef struct MateMenuTreeItem MateMenuTreeItem; +#include <gio/gdesktopappinfo.h> + +G_BEGIN_DECLS + +#define MATEMENU_TYPE_TREE (matemenu_tree_get_type ()) +#define MATEMENU_TREE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MATEMENU_TYPE_TREE, MateMenuTree)) +#define MATEMENU_TREE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MATEMENU_TYPE_TREE, MateMenuTreeClass)) +#define MATEMENU_IS_TREE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATEMENU_TYPE_TREE)) +#define MATEMENU_IS_TREE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MATEMENU_TYPE_TREE)) +#define MATEMENU_TREE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DESKTOP_APP_INFO, MateMenuTreeClass)) + +typedef struct _MateMenuTree MateMenuTree; +typedef struct _MateMenuTreeClass MateMenuTreeClass; + +struct _MateMenuTreeClass +{ + GObjectClass parent_class; +}; + +GType matemenu_tree_get_type (void) G_GNUC_CONST; + +typedef struct MateMenuTreeIter MateMenuTreeIter; typedef struct MateMenuTreeDirectory MateMenuTreeDirectory; typedef struct MateMenuTreeEntry MateMenuTreeEntry; typedef struct MateMenuTreeSeparator MateMenuTreeSeparator; typedef struct MateMenuTreeHeader MateMenuTreeHeader; typedef struct MateMenuTreeAlias MateMenuTreeAlias; -typedef void (*MateMenuTreeChangedFunc) (MateMenuTree* tree, gpointer user_data); - -typedef enum { - MATEMENU_TREE_ITEM_INVALID = 0, - MATEMENU_TREE_ITEM_DIRECTORY, - MATEMENU_TREE_ITEM_ENTRY, - MATEMENU_TREE_ITEM_SEPARATOR, - MATEMENU_TREE_ITEM_HEADER, - MATEMENU_TREE_ITEM_ALIAS +typedef enum +{ + MATEMENU_TREE_ITEM_INVALID = 0, + MATEMENU_TREE_ITEM_DIRECTORY, + MATEMENU_TREE_ITEM_ENTRY, + MATEMENU_TREE_ITEM_SEPARATOR, + MATEMENU_TREE_ITEM_HEADER, + MATEMENU_TREE_ITEM_ALIAS } MateMenuTreeItemType; -#define MATEMENU_TREE_ITEM(i) ((MateMenuTreeItem*)(i)) -#define MATEMENU_TREE_DIRECTORY(i) ((MateMenuTreeDirectory*)(i)) -#define MATEMENU_TREE_ENTRY(i) ((MateMenuTreeEntry*)(i)) -#define MATEMENU_TREE_SEPARATOR(i) ((MateMenuTreeSeparator*)(i)) -#define MATEMENU_TREE_HEADER(i) ((MateMenuTreeHeader*)(i)) -#define MATEMENU_TREE_ALIAS(i) ((MateMenuTreeAlias*)(i)) - -typedef enum { - MATEMENU_TREE_FLAGS_NONE = 0, - MATEMENU_TREE_FLAGS_INCLUDE_EXCLUDED = 1 << 0, - MATEMENU_TREE_FLAGS_SHOW_EMPTY = 1 << 1, - MATEMENU_TREE_FLAGS_INCLUDE_NODISPLAY = 1 << 2, - MATEMENU_TREE_FLAGS_SHOW_ALL_SEPARATORS = 1 << 3, - MATEMENU_TREE_FLAGS_MASK = 0x0f +GType matemenu_tree_iter_get_type (void); + +/* Explicitly skip item, it's a "hidden" base class */ +GType matemenu_tree_directory_get_type (void); +GType matemenu_tree_entry_get_type (void); +GType matemenu_tree_separator_get_type (void); +GType matemenu_tree_header_get_type (void); +GType matemenu_tree_alias_get_type (void); + +typedef enum +{ + MATEMENU_TREE_FLAGS_NONE = 0, + MATEMENU_TREE_FLAGS_INCLUDE_EXCLUDED = 1 << 0, + MATEMENU_TREE_FLAGS_INCLUDE_NODISPLAY = 1 << 1, + MATEMENU_TREE_FLAGS_INCLUDE_UNALLOCATED = 1 << 2, + /* leave some space for more include flags */ + MATEMENU_TREE_FLAGS_SHOW_EMPTY = 1 << 8, + MATEMENU_TREE_FLAGS_SHOW_ALL_SEPARATORS = 1 << 9, + /* leave some space for more show flags */ + MATEMENU_TREE_FLAGS_SORT_DISPLAY_NAME = 1 << 16 } MateMenuTreeFlags; +GType matemenu_tree_flags_get_type (void); +#define MATEMENU_TYPE_TREE_FLAGS (matemenu_tree_flags_get_type ()) -typedef enum { - #define MATEMENU_TREE_SORT_FIRST MATEMENU_TREE_SORT_NAME - MATEMENU_TREE_SORT_NAME = 0, - MATEMENU_TREE_SORT_DISPLAY_NAME - #define MATEMENU_TREE_SORT_LAST MATEMENU_TREE_SORT_DISPLAY_NAME -} MateMenuTreeSortKey; - -MateMenuTree* matemenu_tree_lookup(const char* menu_file, MateMenuTreeFlags flags); +MateMenuTree *matemenu_tree_new (const char *menu_basename, + MateMenuTreeFlags flags); -MateMenuTree* matemenu_tree_ref(MateMenuTree* tree); -void matemenu_tree_unref(MateMenuTree* tree); +MateMenuTree *matemenu_tree_new_for_path (const char *menu_path, + MateMenuTreeFlags flags); -void matemenu_tree_set_user_data(MateMenuTree* tree, gpointer user_data, GDestroyNotify dnotify); -gpointer matemenu_tree_get_user_data(MateMenuTree* tree); +gboolean matemenu_tree_load_sync (MateMenuTree *tree, + GError **error); -const char* matemenu_tree_get_menu_file(MateMenuTree* tree); -MateMenuTreeDirectory* matemenu_tree_get_root_directory(MateMenuTree* tree); -MateMenuTreeDirectory* matemenu_tree_get_directory_from_path(MateMenuTree* tree, const char* path); +const char *matemenu_tree_get_canonical_menu_path (MateMenuTree *tree); +MateMenuTreeDirectory *matemenu_tree_get_root_directory (MateMenuTree *tree); +MateMenuTreeDirectory *matemenu_tree_get_directory_from_path (MateMenuTree *tree, + const char *path); +MateMenuTreeEntry *matemenu_tree_get_entry_by_id (MateMenuTree *tree, + const char *id); -MateMenuTreeSortKey matemenu_tree_get_sort_key(MateMenuTree* tree); -void matemenu_tree_set_sort_key(MateMenuTree* tree, MateMenuTreeSortKey sort_key); +gpointer matemenu_tree_item_ref (gpointer item); +void matemenu_tree_item_unref (gpointer item); +MateMenuTreeDirectory *matemenu_tree_directory_get_parent (MateMenuTreeDirectory *directory); +const char *matemenu_tree_directory_get_name (MateMenuTreeDirectory *directory); +const char *matemenu_tree_directory_get_generic_name (MateMenuTreeDirectory *directory); +const char *matemenu_tree_directory_get_comment (MateMenuTreeDirectory *directory); +GIcon *matemenu_tree_directory_get_icon (MateMenuTreeDirectory *directory); +const char *matemenu_tree_directory_get_desktop_file_path (MateMenuTreeDirectory *directory); +const char *matemenu_tree_directory_get_menu_id (MateMenuTreeDirectory *directory); +MateMenuTree *matemenu_tree_directory_get_tree (MateMenuTreeDirectory *directory); +gboolean matemenu_tree_directory_get_is_nodisplay (MateMenuTreeDirectory *directory); -gpointer matemenu_tree_item_ref(gpointer item); -void matemenu_tree_item_unref(gpointer item); +MateMenuTreeIter *matemenu_tree_directory_iter (MateMenuTreeDirectory *directory); -void matemenu_tree_item_set_user_data(MateMenuTreeItem* item, gpointer user_data, GDestroyNotify dnotify); -gpointer matemenu_tree_item_get_user_data(MateMenuTreeItem* item); +MateMenuTreeIter *matemenu_tree_iter_ref (MateMenuTreeIter *iter); +void matemenu_tree_iter_unref (MateMenuTreeIter *iter); -MateMenuTreeItemType matemenu_tree_item_get_type(MateMenuTreeItem* item); -MateMenuTreeDirectory* matemenu_tree_item_get_parent(MateMenuTreeItem* item); +MateMenuTreeItemType matemenu_tree_iter_next (MateMenuTreeIter *iter); +MateMenuTreeDirectory *matemenu_tree_iter_get_directory (MateMenuTreeIter *iter); +MateMenuTreeEntry *matemenu_tree_iter_get_entry (MateMenuTreeIter *iter); +MateMenuTreeHeader *matemenu_tree_iter_get_header (MateMenuTreeIter *iter); +MateMenuTreeAlias *matemenu_tree_iter_get_alias (MateMenuTreeIter *iter); +MateMenuTreeSeparator *matemenu_tree_iter_get_separator (MateMenuTreeIter *iter); +char *matemenu_tree_directory_make_path (MateMenuTreeDirectory *directory, + MateMenuTreeEntry *entry); -GSList* matemenu_tree_directory_get_contents(MateMenuTreeDirectory* directory); -const char* matemenu_tree_directory_get_name(MateMenuTreeDirectory* directory); -const char* matemenu_tree_directory_get_comment(MateMenuTreeDirectory* directory); -const char* matemenu_tree_directory_get_icon(MateMenuTreeDirectory* directory); -const char* matemenu_tree_directory_get_desktop_file_path(MateMenuTreeDirectory* directory); -const char* matemenu_tree_directory_get_menu_id(MateMenuTreeDirectory* directory); -MateMenuTree* matemenu_tree_directory_get_tree(MateMenuTreeDirectory* directory); -gboolean matemenu_tree_directory_get_is_nodisplay(MateMenuTreeDirectory* directory); +GDesktopAppInfo *matemenu_tree_entry_get_app_info (MateMenuTreeEntry *entry); +MateMenuTreeDirectory *matemenu_tree_entry_get_parent (MateMenuTreeEntry *entry); +MateMenuTree *matemenu_tree_entry_get_tree (MateMenuTreeEntry *entry); -char* matemenu_tree_directory_make_path(MateMenuTreeDirectory* directory, MateMenuTreeEntry* entry); +const char *matemenu_tree_entry_get_desktop_file_path (MateMenuTreeEntry *entry); +const char *matemenu_tree_entry_get_desktop_file_id (MateMenuTreeEntry *entry); +gboolean matemenu_tree_entry_get_is_nodisplay_recurse (MateMenuTreeEntry *entry); +gboolean matemenu_tree_entry_get_is_excluded (MateMenuTreeEntry *entry); +gboolean matemenu_tree_entry_get_is_unallocated (MateMenuTreeEntry *entry); -const char* matemenu_tree_entry_get_name(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_generic_name(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_display_name(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_comment(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_icon(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_exec(MateMenuTreeEntry* entry); -gboolean matemenu_tree_entry_get_launch_in_terminal(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_desktop_file_path(MateMenuTreeEntry* entry); -const char* matemenu_tree_entry_get_desktop_file_id(MateMenuTreeEntry* entry); -gboolean matemenu_tree_entry_get_is_excluded(MateMenuTreeEntry* entry); -gboolean matemenu_tree_entry_get_is_nodisplay(MateMenuTreeEntry* entry); +MateMenuTreeDirectory *matemenu_tree_header_get_directory (MateMenuTreeHeader *header); +MateMenuTree *matemenu_tree_header_get_tree (MateMenuTreeHeader *header); +MateMenuTreeDirectory *matemenu_tree_header_get_parent (MateMenuTreeHeader *header); -MateMenuTreeDirectory* matemenu_tree_header_get_directory(MateMenuTreeHeader* header); +MateMenuTreeDirectory *matemenu_tree_alias_get_directory (MateMenuTreeAlias *alias); +MateMenuTreeItemType matemenu_tree_alias_get_aliased_item_type (MateMenuTreeAlias *alias); +MateMenuTreeDirectory *matemenu_tree_alias_get_aliased_directory (MateMenuTreeAlias *alias); +MateMenuTreeEntry *matemenu_tree_alias_get_aliased_entry (MateMenuTreeAlias *alias); +MateMenuTree *matemenu_tree_alias_get_tree (MateMenuTreeAlias *alias); +MateMenuTreeDirectory *matemenu_tree_alias_get_parent (MateMenuTreeAlias *alias); -MateMenuTreeDirectory* matemenu_tree_alias_get_directory(MateMenuTreeAlias* alias); -MateMenuTreeItem* matemenu_tree_alias_get_item(MateMenuTreeAlias* alias); +MateMenuTree *matemenu_tree_separator_get_tree (MateMenuTreeSeparator *separator); +MateMenuTreeDirectory *matemenu_tree_separator_get_parent (MateMenuTreeSeparator *separator); -void matemenu_tree_add_monitor(MateMenuTree* tree, MateMenuTreeChangedFunc callback, gpointer user_data); -void matemenu_tree_remove_monitor(MateMenuTree* tree, MateMenuTreeChangedFunc callback, gpointer user_data); - -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __MATEMENU_TREE_H__ */ |