summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/core
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-12-11 14:29:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-12-11 14:29:09 (GMT)
commit57e3511bbc5fce4eedfad7b57e775338b3eed56a (patch)
tree218201453a1ddd6b219c936dc83e33647377e443 /plugins/pychrysalide/core
parent4e0a2b71a5937b7382dc14881672a13b84afddac (diff)
Updated the Python API to use properly handled constants.
Diffstat (limited to 'plugins/pychrysalide/core')
-rw-r--r--plugins/pychrysalide/core/constants.c50
-rw-r--r--plugins/pychrysalide/core/constants.h3
-rw-r--r--plugins/pychrysalide/core/params.c39
3 files changed, 55 insertions, 37 deletions
diff --git a/plugins/pychrysalide/core/constants.c b/plugins/pychrysalide/core/constants.c
index 99abf95..5699f19 100644
--- a/plugins/pychrysalide/core/constants.c
+++ b/plugins/pychrysalide/core/constants.c
@@ -26,6 +26,7 @@
#include <core/logs.h>
+#include <core/params.h>
#include "../helpers.h"
@@ -129,3 +130,52 @@ int convert_to_log_message_type(PyObject *arg, void *dst)
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont le dictionnaire est à compléter. *
+* *
+* Description : Définit les constantes pour les désignations de paramètres. *
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool define_core_params_constants(PyObject *module)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *strdict; /* Groupe de chaînes constantes*/
+
+ result = create_string_constants_group_to_module(module, "MainParameterKeys",
+ "Keys referring to main configuration parameters.", &strdict);
+
+ if (result) result = extend_string_constants_group(strdict, "FORMAT_NO_NAME", MPK_FORMAT_NO_NAME);
+ if (result) result = extend_string_constants_group(strdict, "INTERNAL_THEME", MPK_INTERNAL_THEME);
+ if (result) result = extend_string_constants_group(strdict, "TITLE_BAR", MPK_TITLE_BAR);
+ if (result) result = extend_string_constants_group(strdict, "LAST_PROJECT", MPK_LAST_PROJECT);
+ if (result) result = extend_string_constants_group(strdict, "SKIP_EXIT_MSG", MPK_SKIP_EXIT_MSG);
+ if (result) result = extend_string_constants_group(strdict, "MAXIMIZED", MPK_MAXIMIZED);
+ if (result) result = extend_string_constants_group(strdict, "ELLIPSIS_HEADER", MPK_ELLIPSIS_HEADER);
+ if (result) result = extend_string_constants_group(strdict, "ELLIPSIS_TAB", MPK_ELLIPSIS_TAB);
+ if (result) result = extend_string_constants_group(strdict, "WELCOME_STARTUP", MPK_WELCOME_STARTUP);
+ if (result) result = extend_string_constants_group(strdict, "WELCOME_CHECK", MPK_WELCOME_CHECK);
+ if (result) result = extend_string_constants_group(strdict, "LABEL_OFFSET", MPK_LABEL_OFFSET);
+ if (result) result = extend_string_constants_group(strdict, "HEX_PADDING", MPK_HEX_PADDING);
+ if (result) result = extend_string_constants_group(strdict, "SELECTION_LINE", MPK_SELECTION_LINE);
+ if (result) result = extend_string_constants_group(strdict, "TOOLTIP_MAX_CALLS", MPK_TOOLTIP_MAX_CALLS);
+ if (result) result = extend_string_constants_group(strdict, "TOOLTIP_MAX_STRINGS", MPK_TOOLTIP_MAX_STRINGS);
+ if (result) result = extend_string_constants_group(strdict, "HEX_UPPER_CASE", MPK_HEX_UPPER_CASE);
+ if (result) result = extend_string_constants_group(strdict, "LINK_DEFAULT", MPK_LINK_DEFAULT);
+ if (result) result = extend_string_constants_group(strdict, "LINK_BRANCH_TRUE", MPK_LINK_BRANCH_TRUE);
+ if (result) result = extend_string_constants_group(strdict, "LINK_BRANCH_FALSE", MPK_LINK_BRANCH_FALSE);
+ if (result) result = extend_string_constants_group(strdict, "LINK_LOOP", MPK_LINK_LOOP);
+ if (result) result = extend_string_constants_group(strdict, "KEYBINDINGS_EDIT", MPK_KEYBINDINGS_EDIT);
+ if (result) result = extend_string_constants_group(strdict, "TMPDIR", MPK_TMPDIR);
+ if (result) result = extend_string_constants_group(strdict, "AUTO_SAVE", MPK_AUTO_SAVE);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/core/constants.h b/plugins/pychrysalide/core/constants.h
index 6ed6fbb..783af98 100644
--- a/plugins/pychrysalide/core/constants.h
+++ b/plugins/pychrysalide/core/constants.h
@@ -37,6 +37,9 @@ bool define_core_logs_constants(PyObject *);
/* Tente de convertir en constante LogMessageType. */
int convert_to_log_message_type(PyObject *, void *);
+/* Définit les constantes pour les désignations de paramètres. */
+bool define_core_params_constants(PyObject *);
+
#endif /* _PLUGINS_PYCHRYSALIDE_CORE_CONSTANTS_H */
diff --git a/plugins/pychrysalide/core/params.c b/plugins/pychrysalide/core/params.c
index cb8c9f1..4a0513d 100644
--- a/plugins/pychrysalide/core/params.c
+++ b/plugins/pychrysalide/core/params.c
@@ -31,6 +31,7 @@
#include <core/params.h>
+#include "constants.h"
#include "../access.h"
#include "../helpers.h"
@@ -39,9 +40,6 @@
/* Fournit la version du programme global. */
static PyObject *py_params_get_main_configuration(PyObject *, PyObject *);
-/* Définit les constantes pour les paramètres. */
-static bool py_params_define_constants(PyObject *);
-
/******************************************************************************
@@ -84,35 +82,6 @@ static PyObject *py_params_get_main_configuration(PyObject *self, PyObject *args
/******************************************************************************
* *
-* Paramètres : dict = dictionnaire de module à compléter. *
-* *
-* Description : Définit les constantes pour les paramètres. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool py_params_define_constants(PyObject *dict)
-{
- bool result; /* Bilan à retourner */
-
- result = true;
-
- result &= PyModDict_AddStringMacro(dict, MPK_LAST_PROJECT);
- result &= PyModDict_AddStringMacro(dict, MPK_ELLIPSIS_HEADER);
- result &= PyModDict_AddStringMacro(dict, MPK_ELLIPSIS_TAB);
- result &= PyModDict_AddStringMacro(dict, MPK_KEYBINDINGS_EDIT);
- result &= PyModDict_AddStringMacro(dict, MPK_AUTO_SAVE);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : - *
* *
* Description : Définit une extension du module 'core' à compléter. *
@@ -127,7 +96,6 @@ bool populate_core_module_with_params(void)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Module à recompléter */
- PyObject *dict; /* Dictionnaire dudit module */
static PyMethodDef py_params_methods[] = {
PARAMS_GET_MAIN_CONFIGURATION_METHOD,
@@ -139,10 +107,7 @@ bool populate_core_module_with_params(void)
result = register_python_module_methods(module, py_params_methods);
if (result)
- {
- dict = PyModule_GetDict(module);
- result = py_params_define_constants(dict);
- }
+ define_core_params_constants(module);
return result;