Recent posts

#21
Code / Re: Scribus scripting function...
Last post by Darkoni - November 27, 2023, 12:37:16 PM


Can we continue as I have prepared Scribus fork:

https://gitlab.com/Darkoni/darkoni-scribus/-/tree/docstrings

#22
Code / Re: Scribus scripting function...
Last post by a.l.e - November 26, 2023, 08:57:03 PM
concerning the < style > ... i guess that i will have to tweak my script to convert it to &lt; style &gt; .

theoretically, < and > can be the start and html tags and should be escaped... but since they mostly work i normally don't do it.
#23
Code / Re: Scribus scripting function...
Last post by a.l.e - November 26, 2023, 08:50:29 PM
fixing the docstrings is for sure a good thing. but i find it hard to follow the all the changes you're suggesting.

since you're already using gitlab, would you mind creating a new branch with the changes, create a merge request and adding the link in here?

then we can start a review on gitlab with inline comments attached to the specific lines of code.

sadly it's not (yet) possible to accept merge requests, but if you're as lazy as i am, you can add a .diff to the url and create a diff that you can download and use for uploading to the scribus bug tracker : - )
#24
Code / Re: Scribus scripting function...
Last post by Darkoni - November 26, 2023, 08:49:18 PM
And there is another feature in Scribus code:

### 11. LINE_< style >

File: scribus/plugins/scriptplugin/cmdsetprop.h

/*! docstring */
PyDoc_STRVAR(scribus_setlinestyle__doc__,
QT_TR_NOOP("setLineStyle(style, [\"name\"])\n\
\n\
Sets the line style of the object \"name\" to the style \"style\". If \"name\"\n\
is not given the currently selected item is used.\n\
Argument for this function is number - value from 1 to 37\n\
There are few predefined constants for \"style\" - LINE_< style >.\n\
In Property Palette this feature is selected in box named 'Type of line'\n\
"));
/*! Set line end */
PyObject *scribus_setlinestyle(PyObject * /*self*/, PyObject* args);

Why is this important?

There is a nice site Scribus Scripter API

https://impagina.org/scribus-scripter-api/

"This API documentation has been generated from Scribus 1.7.0.svn (2023-11-18)."

And on one of the pages there is missing content.

https://impagina.org/scribus-scripter-api/other-style/

Missing documentation for setTableStyle and also page footer is missing.

All because of HTML tag style in Scribus code.

All becouse of text LINE_< style > in code.

Could Scribus dev team fix this minor thing?

Thanks!

Darko Nikolić
#25
Code / Scribus scripting functions do...
Last post by Darkoni - November 26, 2023, 06:53:00 PM
Hi!

When I looked at and analyzed the source code, I noticed that a dozen Scribus scripting functions had poorly formatted descriptions.

If you would be willing to correct them, I am attaching a list of errors and a list of my suggestions on how to correct them.

* currentPage() -> integer
* currentPage() -> integer
* currentPage() -> integer Returns the number of the current working page based on the section of the document.
* getImageColorSpace(["name"]) -> integer Returns the color space for the image loaded in image frame "name" as one of following integer constants: CSPACE_RGB (0), CSPACE_CMYK (1), CSPACE_GRAY (2), CSPACE_DUOTONE (3) or CSPACE_MONOCHROME (4). Returns CSPACE_UNDEFINED (-1) if no image is loaded in the frame. If "name" is not given the currently selected item is used.
* getLineCap(["name"]) -> integer (see constants)
* getLineJoin(["name"]) -> integer (see constants)
* getLineStyle(["name"]) -> integer (see constants)
* getObjectAttributes(["name"]) -> list Returns a list containing all attributes of object "name".
* getUnit() -> integer (Scribus unit constant)
* Obsolete function. Don't use it.
* setitemname(newName, ["name"])
* setitemname(newName, ["name"])
* Scribus internal.
* Scribus internal.

### 01. currentPage()

File: scribus/plugins/scriptplugin/scriptplugin.cpp

Set function name to currentPageNumberForSection() and remove spaces in front of lines

/*! docstring */
PyDoc_STRVAR(scribus_currentpagenumberforsection__doc__,
QT_TR_NOOP("currentPageNumberForSection() -> integer\n\
\n\
Returns the number of the current working page based on the section of the document.\n\
\n\
"));
/*! get actual page */
PyObject *scribus_currentpagenumberforsection(PyObject * /*self*/);

I see that currentPage and currentPageNumber calls the scribus_currentpage function.

But, when people are creating documentation from Scribus source, then they will get [/b]currentPage[/b] twice.

Like here:

https://impagina.org/scribus-scripter-api/page/

That can be fixed by adding

/*! docstring */
PyDoc_STRVAR(scribus_currentpagenumber__doc__,
QT_TR_NOOP("currentPageNumber() -> integer\n\
\n\
Returns the number of the current working page. Page numbers are counted from 1\n\
upwards, no matter what the displayed first page number of your document is.\n\
"));
/*! get actual page */
PyObject *scribus_currentpage(PyObject * /*self*/);

And changing line

{const_cast<char*>("currentPageNumber"), (PyCFunction)scribus_currentpage, METH_NOARGS, tr(scribus_currentpagenumber__doc__)},

### 02. getImageColorSpace(["name"]) -> integer

File: scribus/plugins/scriptplugin/cmdgetprop.h

/*! 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 one of following integer constants:\n\
CSPACE_RGB (0)\n\
CSPACE_CMYK (1)\n\
CSPACE_GRAY (2)\n\
CSPACE_DUOTONE (3)\n\
CSPACE_MONOCHROME (4)\n\
CSPACE_UNDEFINED (-1) if no image is loaded in the frame.\n\
If \"name\" is not given the currently selected item is used.\n\
"));
PyObject *scribus_getimagecolorspace(PyObject * /*self*/, PyObject* args);

### 03. getLineCap(["name"]) -> integer

File: scribus/plugins/scriptplugin/cmdgetprop.h

/*! docstring */
PyDoc_STRVAR(scribus_getlinecap__doc__,
QT_TR_NOOP("getLineCap([\"name\"]) -> integer\n\
\n\
Returns the line cap style of the object \"name\".\n\
If \"name\" is not given the currently selected item is used.\n\
The cap types are:\n\
CAP_FLAT, CAP_ROUND, CAP_SQUARE\n\
"));
/*! Returns cap type of the line */
PyObject *scribus_getlinecap(PyObject * /*self*/, PyObject* args);

### 04. getLineJoin(["name"]) -> integer

File: scribus/plugins/scriptplugin/cmdgetprop.h

/*! docstring */
PyDoc_STRVAR(scribus_getlinejoin__doc__,
QT_TR_NOOP("getLineJoin([\"name\"]) -> integer\n\
\n\
Returns the line join style of the object \"name\".\n\
If \"name\" is not given the currently selected item is used.\n\
The join types are:\n\
JOIN_BEVEL, JOIN_MITTER, JOIN_ROUND\n\
"));
/*! Returns join type of the line */
PyObject *scribus_getlinejoin(PyObject * /*self*/, PyObject* args);

### 05. getLineStyle(["name"]) -> integer (see constants)

File: scribus/plugins/scriptplugin/cmdgetprop.h

/*! docstring */
PyDoc_STRVAR(scribus_getlinestyle__doc__,
QT_TR_NOOP("getLineStyle([\"name\"]) -> integer\n\
\n\
Returns the line style of the object \"name\".\n\
If \"name\" is not given the currently selected item is used.\n\
Line style constants are:\n\
LINE_DASH, LINE_DASHDOT, LINE_DASHDOTDOT, LINE_DOT, LINE_SOLID\n\
"));
/*! Returns style type of the line */
PyObject *scribus_getlinestyle(PyObject * /*self*/, PyObject* args);

### 06. getObjectAttributes(["name"]) -> list

File: scribus/plugins/scriptplugin/cmdgetprop.h

/*! 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);

### 07. getUnit() -> integer

File: scribus/plugins/scriptplugin/cmddoc.h

/*! docstring */
PyDoc_STRVAR(scribus_getunit__doc__,
QT_TR_NOOP("getUnit() -> integer\n\
\n\
Returns the measurement units of the document.\n\
The returned value will be one of the UNIT_* constants:\n\
UNIT_INCHES, UNIT_MILLIMETERS, UNIT_PICAS, UNIT_POINTS.\n\
"));
/** Returns actual unit scale. */
PyObject *scribus_getunit(PyObject * /*self*/);

### 08. Obsolete function. Don't use it.

File: scribus/plugins/scriptplugin/scriptplugin.cpp

Please, comment line as it is obsolete.

// {const_cast<char*>("pageDimension"), (PyCFunction)scribus_getpagesize, METH_NOARGS, "Obsolete function. Don't use it."},

### 09. setitemname

The better name for function is setItemName

https://www.techtarget.com/whatis/definition/CamelCase

File: scribus/plugins/scriptplugin/cmdsetprop.h

/*! docstring */
PyDoc_STRVAR(scribus_setitemname__doc__,
QT_TR_NOOP("setItemName(newName, [\"name\"])\n\
\n\
Sets the name of object \"name\" to newName and returns the name applied.\n\
If \"name\" is not given the currently selected item is used.\n\
\n\
May raise NotFoundError if the object doesn't exist.\n\
"));
/*! Set newname */
PyObject *scribus_setitemname(PyObject * /*self*/, PyObject* args);

Comment line to remove call to function [/b]setNewName[/b]

File: scribus/plugins/scriptplugin/scriptplugin.cpp
// {const_cast<char*>("setNewName"), scribus_setitemname, METH_VARARGS, tr(scribus_setitemname__doc__)}, // Deprecated, was in fact never documented

### 10. Scribus internal.

File: scribus/plugins/scriptplugin/scriptplugin.cpp

Please, change

// {const_cast<char*>("retval"), (PyCFunction)scribus_retval, METH_VARARGS, const_cast<char*>("Scribus internal.")},
// {const_cast<char*>("getval"), (PyCFunction)scribus_getval, METH_NOARGS, const_cast<char*>("Scribus internal.")},
{const_cast<char*>("retval"), (PyCFunction)scribus_retval, METH_VARARGS, tr(scribus_retval__doc__)},
{const_cast<char*>("getval"), (PyCFunction)scribus_getval, METH_NOARGS,  tr(scribus_getval__doc__)},

And add to file scribus/plugins/scriptplugin/cmdsetprop.h

/*! docstring */
PyDoc_STRVAR(scribus_retval__doc__,
QT_TR_NOOP("retval()\n\
\n\
Scribus internal.\n\
\n\
"));

and

/*! docstring */
PyDoc_STRVAR(scribus_getval__doc__,
QT_TR_NOOP("getval()\n\
\n\
Scribus internal.\n\
\n\
"));

Thanks!

Darko Nikolić
#26
Scripts and Plugins / Re: Scribus 1.7.0.svn New Scri...
Last post by a.l.e - November 26, 2023, 11:09:31 AM
hi darko

wow.

some feedback from my side:


  • guidesLock() and guidesSnap(): they need an argument -- defaulting to True -- for turning off the feature. probably the companions isGuidesLock() and isGuidesSnap() are also to be created in the same go (this is mostly an instinctive reaction: i'm not 100% sure that there is a use case for checking the state)
    finally, the commands should probably go to cmdpage, not cmdtext.
  • textFrameChainShow(): i'd rather call it showTextFramesChain() and as for the guides, it should have an argument to turn it off and a "getter" to test its state.
  • unlinkTextFrameAndCutText(): rather than creating a new function, i'd prefer to see a new named (optional) argument (cutText=False) in unlinkTextFrame().
  • selectObjectAlone(): it's indeed tedious to always need to clear the selection first. as for unlinking the text frames, i'd prefer a named argument "clearSelection=False" in selectObject, which would also "automatically" better document the "odd" behavior of selectObject()
  • placeSVGname(): i'd prefer to see placeSVG() to always return the name of the group that has been created (iirc, not trivial to do; but i think that i have an unfinished patch that goes in that direction)
  • placeSVGnameFromString(): i guess that the filename in placeSVG() should be optional and it needs a named argument svgString (or similar). probably, you saw that coming, after the previous comments : - )
  • insterHTMLFromString(): see above : - )
  • getDocumentation: you can achieve the same with python's dir (and with the inspect module it gets rather powerful: i have a script -- currently in a ḧeavy refactoring process (adding arbitrary text) -- that with the help of mkdocs produces https://impagina.org/scribus-scripter-api ).
    i'm not sure that this new command is really needed.

all in all, you seem to propose a few useful commands for the scripter api and a few others that can help in automatically setting up a "standard" environment.

nice.

if you need help for the changes i suggested just ask.
it would be nice if you could propose patches that can get into scribus!

have a nice sunday
a.l.e
#27
MacOS / Problems booting scribus 1.4.8...
Last post by André - November 25, 2023, 11:30:41 PM
Hi

I'm from Austria, so pls. excuse my English.

I installed Scribus 1.4.8 on a mini some time ago, used it a bit, but not much. I switched to a Mac mini intel 3,2GHz i7 using the  OS migration tool, all programs worked fine. But for Scribus. When I start Scribus now, it takes over ten minutes to boot and does not respond to inpute.
I thought, OK, I should be able to run Scribus 1.5.8, but OS refuses to boot it, saying I should be 10.15, not 10.14
Deleted the folder, downloaded 1.4.8 from the website, reinstalled it - same effect.

When it boots up, it seems normal speed until it comes to "loading color profiles". I have no color profiles installd, to my knowledge

Does anybody know what went wrong and help me pls?
#28
Scripts and Plugins / Scribus 1.7.0.svn New Scriptin...
Last post by Darkoni - November 25, 2023, 10:04:43 PM
Hi!

I have made a compilation of my own script functions that I needed for Scribus.

The functions are:

* guidesLock
* guidesSnap
* textFrameChainShow
* unlinkTextFrameAndCutText
* selectObjectAlone
* placeSVGname
* placeSVGnameFromString
* insertHtmlFromString
* getDocumentationIndex
* getDocumentation

More on GitLab:

https://gitlab.com/Darkoni/Scribus_170_New_Scripting_Functions/

Darko Nikolić  8)
#29
Beginner Talk / Re: Image frames with borders ...
Last post by AdmFubar - November 25, 2023, 06:37:30 PM
A quick and dirty solution for this is to add a border/frame/stroke to the image and make it transparent. You will loose a few pixels of the image from how scribus adds border to an image but this might be acceptable.
#30
Beginner Talk / Re: Image frames with borders ...
Last post by Erik96 - November 25, 2023, 10:32:33 AM
Hello utnik,
thx a lot, great. It works perfectly.
Have a great day
eryk