get rid of macro/concat hack
This commit is contained in:
parent
b4f059391a
commit
b06873bf98
31
termite.cc
31
termite.cc
|
@ -778,21 +778,26 @@ char *check_match(VteTerminal *vte, int event_x, int event_y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ CONFIG LOADING */
|
/* {{{ CONFIG LOADING */
|
||||||
#define MAKE_GET_CONFIG_FUNCTION(NAME, TYPE) \
|
template<typename T>
|
||||||
static bool get_config_ ## NAME (GKeyFile *config, const char *group, const char *key, TYPE *value) { \
|
static bool get_config(T (*get)(GKeyFile *, const char *, const char *, GError **),
|
||||||
GError *error = NULL; \
|
GKeyFile *config, const char *group, const char *key, T *value) {
|
||||||
*value = g_key_file_get_ ## NAME (config, group, key, &error); \
|
GError *error = nullptr;
|
||||||
if (error) { \
|
*value = get(config, group, key, &error);
|
||||||
g_error_free(error); \
|
if (error) {
|
||||||
return false; \
|
g_error_free(error);
|
||||||
} \
|
return false;
|
||||||
return true; \
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MAKE_GET_CONFIG_FUNCTION(boolean, gboolean)
|
auto get_config_boolean(std::bind(get_config<gboolean>, g_key_file_get_boolean,
|
||||||
MAKE_GET_CONFIG_FUNCTION(integer, int)
|
_1, _2, _3, _4));
|
||||||
MAKE_GET_CONFIG_FUNCTION(string, char *)
|
auto get_config_integer(std::bind(get_config<int>, g_key_file_get_integer,
|
||||||
MAKE_GET_CONFIG_FUNCTION(double, double)
|
_1, _2, _3, _4));
|
||||||
|
auto get_config_string(std::bind(get_config<char *>, g_key_file_get_string,
|
||||||
|
_1, _2, _3, _4));
|
||||||
|
auto get_config_double(std::bind(get_config<double>, g_key_file_get_double,
|
||||||
|
_1, _2, _3, _4));
|
||||||
|
|
||||||
static bool get_config_color(GKeyFile *config, const char *key, GdkColor *color) {
|
static bool get_config_color(GKeyFile *config, const char *key, GdkColor *color) {
|
||||||
char *cfgstr;
|
char *cfgstr;
|
||||||
|
|
Loading…
Reference in New Issue