wlmaker
Loading...
Searching...
No Matches
gen_menu.c File Reference
#include "gen_menu.h"
#include <basedir.h>
#include <desktop-parser/desktop-parser.h>
#include <ftw.h>
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <locale.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
Include dependency graph for gen_menu.c:

Classes

struct  category_menu
struct  menu_entry
struct  category_translation

Functions

static bool add_entry_to_menu_tree (bs_avltree_t *menu_tree_ptr, struct menu_entry *menu_entry_ptr)
static struct category_menumenu_create (const char *category_ptr)
static int menu_cmp (const bs_avltree_node_t *node_ptr, const void *key_ptr)
static void menu_destroy (bs_avltree_node_t *node_ptr)
static struct menu_entryentry_create (struct desktop_parser *parser, const char *path_ptr)
static int entry_cmp (const bs_avltree_node_t *node_ptr, const void *key_ptr)
static void entry_destroy (bs_avltree_node_t *node_ptr)
static const char * category_from_entry (const struct menu_entry *menu_entry_ptr)
static bspl_array_t * array_from_entry (const struct desktop_entry *entry_ptr)
static bspl_array_t * array_from_tree (bs_avltree_t *menu_tree_ptr)
int ftw_callback (const char *path_ptr, const struct stat *statbuf_ptr, int typeflag)
bspl_array_t * wlmaker_menu_generate (const char *locale_ptr, const char *path_ptr)

Variables

static const char * category_other_ptr = "Other"
static const struct category_translation category_table []
struct desktop_parserglobal_parser
bs_avltree_t * global_menu_tree_ptr

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ add_entry_to_menu_tree()

bool add_entry_to_menu_tree ( bs_avltree_t * menu_tree_ptr,
struct menu_entry * menu_entry_ptr )
static

Adds the entry to the category menu. Creates a category menu, if needed.

◆ array_from_entry()

bspl_array_t * array_from_entry ( const struct desktop_entry * entry_ptr)
static

Returns the plist array for the menu entry.

◆ array_from_tree()

bspl_array_t * array_from_tree ( bs_avltree_t * menu_tree_ptr)
static

Creates a plist array describing the full menu.

◆ category_from_entry()

const char * category_from_entry ( const struct menu_entry * menu_entry_ptr)
static

Looks up the category name for the menu entry.

◆ entry_cmp()

int entry_cmp ( const bs_avltree_node_t * node_ptr,
const void * key_ptr )
static

Comparator for the entry.

◆ entry_create()

struct menu_entry * entry_create ( struct desktop_parser * parser,
const char * path_ptr )
static

Ctor for the entry.

◆ entry_destroy()

void entry_destroy ( bs_avltree_node_t * node_ptr)
static

Dtor for the entry.

◆ ftw_callback()

int ftw_callback ( const char * path_ptr,
const struct stat * statbuf_ptr,
int typeflag )

Attempts to parse & add each entry from the tree.

◆ menu_cmp()

int menu_cmp ( const bs_avltree_node_t * node_ptr,
const void * key_ptr )
static

comparator for the menu.

◆ menu_create()

struct category_menu * menu_create ( const char * category_ptr)
static

ctor for the menu.

◆ menu_destroy()

void menu_destroy ( bs_avltree_node_t * node_ptr)
static

Dtor for the menu.

◆ wlmaker_menu_generate()

bspl_array_t * wlmaker_menu_generate ( const char * locale_ptr,
const char * path_ptr )

Generates a menu and returns the plist structure for it.

Parameters
locale_ptrThe locale for LC_MESSAGES, or NULL.
path_ptr
Returns
The plist array, or NULL on error.

Variable Documentation

◆ category_other_ptr

const char* category_other_ptr = "Other"
static

Category to use for any entry that is not categorized.

◆ category_table

const struct category_translation category_table[]
static
Initial value:
= {
{ "AudioVideo", "Audio & Video" },
{ "Video", "Video" },
{ "Development", "Development" },
{ "Education", "Education" },
{ "Game", "Game" },
{ "Graphics", "Graphics" },
{ "Network", "Network" },
{ "Office", "Office" },
{ "Science", "Science" },
{ "Settings", "Settings" },
{ "System", "System" },
{ "Utility", "Utility" },
{ "Screensaver", "Screensaver" },
{ "TrayIcon", "Tray Icon" },
{ "Applet", "Applet" },
{ "Shell", "Shell" },
{ NULL, NULL },
}

Recognized categories.

◆ global_menu_tree_ptr

bs_avltree_t* global_menu_tree_ptr

Global: The menu tree. Used in ftw_callback.

◆ global_parser

struct desktop_parser* global_parser

Global: Parser. Used in ftw_callback.