mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Move PropertyType into rofi-types header and add check for names pairs.
This commit is contained in:
parent
fb8f56dab3
commit
686be5856c
6 changed files with 62 additions and 35 deletions
|
@ -1,6 +1,41 @@
|
||||||
#ifndef INCLUDE_ROFI_TYPES_H
|
#ifndef INCLUDE_ROFI_TYPES_H
|
||||||
#define INCLUDE_ROFI_TYPES_H
|
#define INCLUDE_ROFI_TYPES_H
|
||||||
|
|
||||||
extern const char *PropertyTypeName[];
|
/**
|
||||||
|
* Type of property
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/** Integer */
|
||||||
|
P_INTEGER,
|
||||||
|
/** Double */
|
||||||
|
P_DOUBLE,
|
||||||
|
/** String */
|
||||||
|
P_STRING,
|
||||||
|
/** Boolean */
|
||||||
|
P_BOOLEAN,
|
||||||
|
/** Color */
|
||||||
|
P_COLOR,
|
||||||
|
/** RofiPadding */
|
||||||
|
P_PADDING,
|
||||||
|
/** Link to global setting */
|
||||||
|
P_LINK,
|
||||||
|
/** Position */
|
||||||
|
P_POSITION,
|
||||||
|
/** Highlight */
|
||||||
|
P_HIGHLIGHT,
|
||||||
|
/** List */
|
||||||
|
P_LIST,
|
||||||
|
/** Orientation */
|
||||||
|
P_ORIENTATION,
|
||||||
|
/** Number of types. */
|
||||||
|
P_NUM_TYPES,
|
||||||
|
} PropertyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This array maps PropertyType to a user-readable name.
|
||||||
|
* It is important this is kept in sync.
|
||||||
|
*/
|
||||||
|
extern const char * const PropertyTypeName[P_NUM_TYPES];
|
||||||
|
|
||||||
#endif // INCLUDE_ROFI_TYPES_H
|
#endif // INCLUDE_ROFI_TYPES_H
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <widgets/widget.h>
|
#include <widgets/widget.h>
|
||||||
#include <settings.h>
|
#include <settings.h>
|
||||||
#include "theme.h"
|
|
||||||
|
#include "rofi-types.h"
|
||||||
|
|
||||||
/** Style of text highlight */
|
/** Style of text highlight */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -95,34 +96,6 @@ typedef enum
|
||||||
ROFI_ORIENTATION_VERTICAL,
|
ROFI_ORIENTATION_VERTICAL,
|
||||||
ROFI_ORIENTATION_HORIZONTAL
|
ROFI_ORIENTATION_HORIZONTAL
|
||||||
} RofiOrientation;
|
} RofiOrientation;
|
||||||
/**
|
|
||||||
* Type of property
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
/** Integer */
|
|
||||||
P_INTEGER,
|
|
||||||
/** Double */
|
|
||||||
P_DOUBLE,
|
|
||||||
/** String */
|
|
||||||
P_STRING,
|
|
||||||
/** Boolean */
|
|
||||||
P_BOOLEAN,
|
|
||||||
/** Color */
|
|
||||||
P_COLOR,
|
|
||||||
/** RofiPadding */
|
|
||||||
P_PADDING,
|
|
||||||
/** Link to global setting */
|
|
||||||
P_LINK,
|
|
||||||
/** Position */
|
|
||||||
P_POSITION,
|
|
||||||
/** Highlight */
|
|
||||||
P_HIGHLIGHT,
|
|
||||||
/** List */
|
|
||||||
P_LIST,
|
|
||||||
/** Orientation */
|
|
||||||
P_ORIENTATION,
|
|
||||||
} PropertyType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent the color in theme.
|
* Represent the color in theme.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* Name of the property type
|
* Name of the property type
|
||||||
*/
|
*/
|
||||||
const char *PropertyTypeName[] = {
|
const char * const PropertyTypeName[P_NUM_TYPES] = {
|
||||||
/** Integer */
|
/** Integer */
|
||||||
"Integer",
|
"Integer",
|
||||||
/** Double */
|
/** Double */
|
||||||
|
@ -14,8 +14,8 @@ const char *PropertyTypeName[] = {
|
||||||
"Boolean",
|
"Boolean",
|
||||||
/** Color */
|
/** Color */
|
||||||
"Color",
|
"Color",
|
||||||
/** RofiPadding */
|
/** Padding */
|
||||||
"RofiPadding",
|
"Padding",
|
||||||
/** Link to global setting */
|
/** Link to global setting */
|
||||||
"Reference",
|
"Reference",
|
||||||
/** Position */
|
/** Position */
|
||||||
|
|
|
@ -391,7 +391,6 @@ void config_parse_cmd_options ( void )
|
||||||
|
|
||||||
static gboolean __config_parser_set_property ( XrmOption *option, const Property *p, char **error )
|
static gboolean __config_parser_set_property ( XrmOption *option, const Property *p, char **error )
|
||||||
{
|
{
|
||||||
extern const char *PropertyTypeName[];
|
|
||||||
if ( option->type == xrm_String ) {
|
if ( option->type == xrm_String ) {
|
||||||
if ( p->type != P_STRING && p->type != P_LIST ) {
|
if ( p->type != P_STRING && p->type != P_LIST ) {
|
||||||
*error = g_strdup_printf ( "Option: %s needs to be set with a string not a %s.", option->name, PropertyTypeName[p->type] );
|
*error = g_strdup_printf ( "Option: %s needs to be set with a string not a %s.", option->name, PropertyTypeName[p->type] );
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2c5f1b2654a9b4480b857cd8395af127a6c55199
|
Subproject commit 3467c6a4ee3b7a2f53dfd0e15cd72f00d782a0dd
|
|
@ -1233,6 +1233,25 @@ START_TEST ( test_prepare_path )
|
||||||
g_free ( current_dir );
|
g_free ( current_dir );
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST(test_properties_types_names)
|
||||||
|
{
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_INTEGER], "Integer");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_DOUBLE], "Double");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_STRING], "String");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_BOOLEAN], "Boolean");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_COLOR], "Color");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_PADDING], "Padding");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_LINK], "Reference");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_POSITION], "Position");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_HIGHLIGHT], "Highlight");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_LIST], "List");
|
||||||
|
ck_assert_str_eq ( PropertyTypeName[P_ORIENTATION], "Orientation");
|
||||||
|
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
static Suite * theme_parser_suite (void)
|
static Suite * theme_parser_suite (void)
|
||||||
{
|
{
|
||||||
Suite *s;
|
Suite *s;
|
||||||
|
@ -1244,6 +1263,7 @@ static Suite * theme_parser_suite (void)
|
||||||
{
|
{
|
||||||
tc_core = tcase_create("Core");
|
tc_core = tcase_create("Core");
|
||||||
tcase_add_checked_fixture(tc_core, theme_parser_setup, theme_parser_teardown);
|
tcase_add_checked_fixture(tc_core, theme_parser_setup, theme_parser_teardown);
|
||||||
|
tcase_add_test(tc_core, test_properties_types_names);
|
||||||
tcase_add_test(tc_core, test_core_empty_string);
|
tcase_add_test(tc_core, test_core_empty_string);
|
||||||
tcase_add_test(tc_core, test_core_empty_global_section);
|
tcase_add_test(tc_core, test_core_empty_global_section);
|
||||||
tcase_add_test(tc_core, test_core_empty_section);
|
tcase_add_test(tc_core, test_core_empty_section);
|
||||||
|
|
Loading…
Reference in a new issue