View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017095 | Scribus | Scripter | public | 2023-12-27 13:29 | 2024-01-07 16:24 |
Reporter | ale | Assigned To | ale | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 1.7.0.svn | ||||
Fixed in Version | 1.6.1.svn | ||||
Summary | 0017095: Scripter: add the return values for getObjectType | ||||
Description | specify the possible return values for the scripter's getObjectType() function | ||||
Tags | patch | ||||
Patch | Yes | ||||
|
get_object_type.diff (1,573 bytes)
diff --git a/scribus/plugins/scriptplugin/cmdgetprop.h b/scribus/plugins/scriptplugin/cmdgetprop.h index b13ae591a..226c18000 100644 --- a/scribus/plugins/scriptplugin/cmdgetprop.h +++ b/scribus/plugins/scriptplugin/cmdgetprop.h @@ -17,6 +17,15 @@ PyDoc_STRVAR(scribus_getobjecttype__doc__, QT_TR_NOOP("getObjectType([\"name\"]) -> string\n\ \n\ Get type of object \"name\" as a string.\n\ +\n\ +The possible result values are:\n\ +\n\ +'TextFrame', 'PathText', 'ImageFrame',\n\ +'Line', 'Polygon', 'Polyline',\n\ +'LatexFrame', 'OSGFrame', 'Symbol',\n\ +'Group', 'RegularPolygon', 'Arc',\n\ +'Spiral', 'Table', 'NoteFrame',\n\ +'Multiple'\n\ ")); /** Get Object Type of name. */ PyObject *scribus_getobjecttype(PyObject * /*self*/, PyObject* args); @@ -168,6 +177,7 @@ PyObject *scribus_getcornerradius(PyObject * /*self*/, PyObject* args); /*! docstring */ PyDoc_STRVAR(scribus_getimagecolorspace__doc__, QT_TR_NOOP("getImageColorSpace([\"name\"]) -> integer\n\ +\n\ Returns the color space for the image loaded in image frame \"name\" as \n\ one of following integer constants: CSPACE_RGB (0), CSPACE_CMYK (1), \n\ CSPACE_GRAY (2), CSPACE_DUOTONE (3) or CSPACE_MONOCHROME (4).\n\ @@ -261,6 +271,7 @@ PyObject *scribus_getallobjects(PyObject * /*self*/, PyObject* args, PyObject *k /*! docstring */ PyDoc_STRVAR(scribus_getobjectattributes__doc__, QT_TR_NOOP("getObjectAttributes([\"name\"]) -> list\n\ +\n\ Returns a list containing all attributes of object \"name\".\n\ ")); PyObject *scribus_getobjectattributes(PyObject * /*self*/, PyObject* args); |
|
That makes me realize the return values for this function should be constants so we can refer use to some ITEMTYPESTR_* constants instead of listing values manually. |
|
yes, the return value is not correct. but i fear that at this point we can't change that... well, we could deprecate all the getObject... / setObject... and replace them (through deprecation) with getItem... / setItem... and give them a sane interface. but, before making such a big change, i would seriously think about recreating the scripter based on pybind11, using names that are pythonic (underscores instead of camel case) and probably encapsulate the function in object rather than having a flat namespace with all the functions in it. a few years ago i have created a prototype and it was rather easy to create a new scripter. i stopped because: - it was not possible to correctly communicate with qt for python and the scribus qt (at that time this was one of my main goals: having non modal dialogs in the scripts; but now i know that it's probably possible by sharing one single instance of qt for python; and it's not really an important goal for me anymore) - i could not manage to create at the same time an internal c++ high level "API" that would have simplified the creation of high level code for scribus itself; but i dropped this goal for now.) so, if there is interest for it, i can revive the project and make a proposal for a new scripter |
|
p.s.: sorry, i misunderstood you a bit... you want to add constants for the strings... which would be doable... but it would be even be better if the return value would be an int that matches an enum... |
|
>> but it would be even be better if the return value would be an int that matches an enum Yeah, we even already have ITEMTYPE_* constants for that. |
|
In the meantime I applied your patch, any other improvement will be another issue. |
Date Modified | Username | Field | Change |
---|---|---|---|
2023-12-27 13:29 | ale | New Issue | |
2023-12-27 13:29 | ale | Tag Attached: patch | |
2023-12-27 13:29 | ale | File Added: get_object_type.diff | |
2023-12-27 15:18 | jghali | Note Added: 0050701 | |
2023-12-27 21:34 | ale | Note Added: 0050703 | |
2023-12-27 22:00 | ale | Note Added: 0050704 | |
2024-01-02 23:26 | jghali | Note Added: 0050775 | |
2024-01-02 23:31 | jghali | Summary | [PATCH] scripter: add the return values for getObjectType => Scripter: add the return values for getObjectType |
2024-01-02 23:32 | jghali | Assigned To | => jghali |
2024-01-02 23:32 | jghali | Status | new => resolved |
2024-01-02 23:32 | jghali | Resolution | open => fixed |
2024-01-02 23:32 | jghali | Fixed in Version | => 1.6.1.svn |
2024-01-02 23:32 | jghali | Note Added: 0050776 | |
2024-01-02 23:32 | jghali | Assigned To | jghali => ale |
2024-01-07 16:24 | cbradney | Status | resolved => closed |