summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/glibext/constants.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-07-14 13:06:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-07-14 13:06:20 (GMT)
commit6c751d40ab1b84a6979c143ed47702207edebed8 (patch)
treee789491530d641f89e574f8eacb4f0e66bd93a91 /plugins/pychrysalide/glibext/constants.c
parentde82c8165e61e3c19be184dbc00f66bfc7479c76 (diff)
Updated the Python bindings for the loaded panel interface.
Diffstat (limited to 'plugins/pychrysalide/glibext/constants.c')
-rw-r--r--plugins/pychrysalide/glibext/constants.c135
1 files changed, 117 insertions, 18 deletions
diff --git a/plugins/pychrysalide/glibext/constants.c b/plugins/pychrysalide/glibext/constants.c
index 47bd00d..a7938cb 100644
--- a/plugins/pychrysalide/glibext/constants.c
+++ b/plugins/pychrysalide/glibext/constants.c
@@ -25,9 +25,11 @@
#include "constants.h"
+#include <i18n.h>
#include <glibext/linesegment.h>
#include <glibext/gbinportion.h>
#include <glibext/gbufferline.h>
+#include <glibext/gloadedpanel.h>
#include "../helpers.h"
@@ -148,6 +150,105 @@ int convert_to_portion_access_rights(PyObject *arg, void *dst)
* *
* Paramètres : type = type dont le dictionnaire est à compléter. *
* *
+* Description : Définit les constantes relatives aux lignes de tampon. *
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool define_buffer_line_constants(PyTypeObject *type)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *values; /* Groupe de valeurs à établir */
+
+ values = PyDict_New();
+
+ result = add_const_to_group(values, "NONE", BLF_NONE);
+ if (result) result = add_const_to_group(values, "HAS_CODE", BLF_HAS_CODE);
+ if (result) result = add_const_to_group(values, "IS_LABEL", BLF_IS_LABEL);
+ if (result) result = add_const_to_group(values, "ENTRYPOINT", BLF_ENTRYPOINT);
+ if (result) result = add_const_to_group(values, "BOOKMARK", BLF_BOOKMARK);
+ if (result) result = add_const_to_group(values, "WIDTH_MANAGER", BLF_WIDTH_MANAGER);
+ if (result) result = add_const_to_group(values, "ALL", BLF_ALL);
+
+ if (!result)
+ {
+ Py_DECREF(values);
+ goto exit;
+ }
+
+ result = attach_constants_group_to_type(type, true, "BufferLineFlags", values,
+ "Optional flags linked to a rendering line.");
+
+ exit:
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : arg = argument quelconque à tenter de convertir. *
+* dst = destination des valeurs récupérées en cas de succès. *
+* *
+* Description : Tente de convertir en constante BufferLineFlags. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_buffer_line_flags(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+ unsigned long value; /* Valeur transcrite */
+
+ result = PyObject_IsInstance(arg, (PyObject *)&PyLong_Type);
+
+ switch (result)
+ {
+ case -1:
+ /* L'exception est déjà fixée par Python */
+ result = 0;
+ break;
+
+ case 0:
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to BufferLineFlags");
+ break;
+
+ case 1:
+ value = PyLong_AsUnsignedLong(arg);
+
+ if ((value & BLF_ALL) != value)
+ {
+ PyErr_SetString(PyExc_TypeError, "invalid value for BufferLineFlags");
+ result = 0;
+ }
+
+ else
+ *((BufferLineFlags *)dst) = value;
+
+ break;
+
+ default:
+ assert(false);
+ break;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type dont le dictionnaire est à compléter. *
+* *
* Description : Définit les constantes relatives aux segments de ligne. *
* *
* Retour : true en cas de succès de l'opération, false sinon. *
@@ -258,7 +359,7 @@ int convert_to_rendering_tag_type(PyObject *arg, void *dst)
* *
* Paramètres : type = type dont le dictionnaire est à compléter. *
* *
-* Description : Définit les constantes relatives aux lignes de tampon. *
+* Description : Définit les constantes relatives aux panneaux de chargement. *
* *
* Retour : true en cas de succès de l'opération, false sinon. *
* *
@@ -266,20 +367,17 @@ int convert_to_rendering_tag_type(PyObject *arg, void *dst)
* *
******************************************************************************/
-bool define_buffer_line_constants(PyTypeObject *type)
+bool define_loaded_panel_constants(PyTypeObject *type)
{
bool result; /* Bilan à retourner */
PyObject *values; /* Groupe de valeurs à établir */
values = PyDict_New();
- result = add_const_to_group(values, "NONE", BLF_NONE);
- if (result) result = add_const_to_group(values, "HAS_CODE", BLF_HAS_CODE);
- if (result) result = add_const_to_group(values, "IS_LABEL", BLF_IS_LABEL);
- if (result) result = add_const_to_group(values, "ENTRYPOINT", BLF_ENTRYPOINT);
- if (result) result = add_const_to_group(values, "BOOKMARK", BLF_BOOKMARK);
- if (result) result = add_const_to_group(values, "WIDTH_MANAGER", BLF_WIDTH_MANAGER);
- if (result) result = add_const_to_group(values, "ALL", BLF_ALL);
+ result = add_const_to_group(values, "RAW", SPT_RAW);
+ if (result) result = add_const_to_group(values, "TOP", SPT_TOP);
+ if (result) result = add_const_to_group(values, "CENTER", SPT_CENTER);
+ if (result) result = add_const_to_group(values, "BOTTOM", SPT_BOTTOM);
if (!result)
{
@@ -287,8 +385,8 @@ bool define_buffer_line_constants(PyTypeObject *type)
goto exit;
}
- result = attach_constants_group_to_type(type, true, "BufferLineFlags", values,
- "Optional flags linked to a rendering line.");
+ result = attach_constants_group_to_type(type, false, "ScrollPositionTweak", values,
+ "Details for adjusting the displayed position while scrolling.");
exit:
@@ -302,7 +400,7 @@ bool define_buffer_line_constants(PyTypeObject *type)
* Paramètres : arg = argument quelconque à tenter de convertir. *
* dst = destination des valeurs récupérées en cas de succès. *
* *
-* Description : Tente de convertir en constante BufferLineFlags. *
+* Description : Tente de convertir en constante ScrollPositionTweak. *
* *
* Retour : Bilan de l'opération, voire indications supplémentaires. *
* *
@@ -310,10 +408,10 @@ bool define_buffer_line_constants(PyTypeObject *type)
* *
******************************************************************************/
-int convert_to_buffer_line_flags(PyObject *arg, void *dst)
+int convert_to_scroll_position_tweak(PyObject *arg, void *dst)
{
int result; /* Bilan à retourner */
- unsigned long value; /* Valeur transcrite */
+ unsigned long value; /* Valeur récupérée */
result = PyObject_IsInstance(arg, (PyObject *)&PyLong_Type);
@@ -325,20 +423,21 @@ int convert_to_buffer_line_flags(PyObject *arg, void *dst)
break;
case 0:
- PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to BufferLineFlags");
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to ScrollPositionTweak");
break;
case 1:
+
value = PyLong_AsUnsignedLong(arg);
- if ((value & BLF_ALL) != value)
+ if (!IS_VALID_STP(value))
{
- PyErr_SetString(PyExc_TypeError, "invalid value for BufferLineFlags");
result = 0;
+ PyErr_SetString(PyExc_ValueError, _("invalid position tweak"));
}
else
- *((BufferLineFlags *)dst) = value;
+ *((ScrollPositionTweak *)dst) = value;
break;