wlmaker
Loading...
Searching...
No Matches
desktop-parser.h File Reference
#include <libbase/libbase.h>
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for desktop-parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  desktop_entry

Enumerations

enum  desktop_entry_type { DESKTOP_ENTRY_TYPE_UNKNOWN = 0 , DESKTOP_ENTRY_TYPE_APPLICATION = 1 , DESKTOP_ENTRY_TYPE_LINK = 2 , DESKTOP_ENTRY_TYPE_DIRECTORY = 3 }

Functions

struct desktop_parserdesktop_parser_create (const char *locale_ptr)
void desktop_parser_destroy (struct desktop_parser *parser)
int desktop_parser_file_to_entry (const struct desktop_parser *parser, const char *fname_ptr, struct desktop_entry *entry_ptr)
int desktop_parser_string_to_entry (const struct desktop_parser *parser, const char *string_ptr, struct desktop_entry *entry_ptr)
void desktop_parser_entry_release (struct desktop_entry *entry_ptr)

Variables

const bs_test_set_t desktop_parser_test_set

Detailed Description

Simple parser for FreeDesktop .desktop files, to provide application- specific information within a compositor and for constructing application menus. Depends on libinih-dev.

Reference:

Currently built to support the necessary keys for building the root menu for Wayland Maker. Specifically, that includes:

  • [*] Type
  • [*] NoDisplay
  • [*] Hidden
  • [*] Terminal
  • [*] Exec
  • [*] Name
  • [*] Categories
  • [*] TryExec
  • [*] Path

Further improvements:

  • Handle the f, u, ... specifiers.
  • Add support for "numeric" type. Though, it's currently unused for .desktop.
  • Use the "Terminal" flag and construct a command that executes in terminal.

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.

Enumeration Type Documentation

◆ desktop_entry_type

Permissible values for Type=....

Function Documentation

◆ desktop_parser_create()

struct desktop_parser * desktop_parser_create ( const char * locale_ptr)

Creates a desktop parser, using the provided locale.

Parameters
locale_ptrLocale set for LC_MESSAGES. See setlocale(3).
Returns
Pointer to the desktop parser, or NULL on error. Must be destroyed by calling desktop_parser_destroy.

◆ desktop_parser_destroy()

void desktop_parser_destroy ( struct desktop_parser * parser)

Destroys the desktop parser.

Parameters
parser

◆ desktop_parser_entry_release()

void desktop_parser_entry_release ( struct desktop_entry * entry_ptr)

Releases the resources associated to the entry.

Parameters
entry_ptr

◆ desktop_parser_file_to_entry()

int desktop_parser_file_to_entry ( const struct desktop_parser * parser,
const char * fname_ptr,
struct desktop_entry * entry_ptr )

Parses a file into the provided entry.

Parameters
parser
fname_ptr
entry_ptr
Returns
0 on success, or the line number where the parser failed.

◆ desktop_parser_string_to_entry()

int desktop_parser_string_to_entry ( const struct desktop_parser * parser,
const char * string_ptr,
struct desktop_entry * entry_ptr )

Parses an in-memory string into the provided entry.

Parameters
parser
string_ptr
entry_ptr
Returns
0 on success, or the line number where the parser failed.

Variable Documentation

◆ desktop_parser_test_set

const bs_test_set_t desktop_parser_test_set
extern

Unit test set.