[Kde-graphics-devel] Re: Using libksane from a non-graphical application

Kåre Särs kare.sars at iki.fi
Wed Apr 27 09:09:10 CEST 2011


On Tuesday 26 April 2011 13:26:25 Ben Martin wrote:
> Hi,
>   I decided to allow libferris to mount scanners at long last. The
> basics of this exposure is to configure sane and grab an image to jpg or
> png. The code in skanlite does very similar things, but as a filesystem
> I don't create any graphical interface. 
> 
>   It turns out that things work well from the console, though the calls
> to KMessageBox::sorry() in KSaneWidgetPrivate::oneFinalScanDone() are
> quite deadly as the dialog is not shown and the whole thing seems to
> hang there. A visit to gdb shows that the dialog is up and not shown in
> the backtrace.
> 
>   Inside imageReady() I call scanCancel() to try to avoid these
> KMessageBoxes but it seems I get two scanDone() signals anyway and the
> second one complains that the ADF is out of ammo and thus the
> KMessageBox is attempted by libksane.

I guess it would not bee to much of a problem to disable those message boxes.

I have a hunch that you will need an X server running to be able to create a 
QWidget... 

> 
>   About the only other thing I see that would be handy is a 
> QList< QString > getDeviceNames() const;
> sort of method to enumerate the scanners. This assumes that there is any
> interest in allowing non graphical clients to pick at libksane. Other
> than that libksane allows fairly straightforward scanning from the
> console. :)

"QList< QString > getDeviceNames() const;" is actually a feature that I have 
had in the plans for some time, but I have not had enough of an itch to do it 
(nobody using it). It should not be a big problem to implement.

The proper way to it would be to have a "void initGetDeviceList() const;" that 
initiates the thread and a signal that returns the device list. This because 
the getting of the list can take several seconds. Then a convenience function 
that sits and waits for the signal to be returned.

I'll add an entry to the feature plan before the soft freeze and we can check 
what it needs to disable the dialogs and add the getDeviceNames().



> 
> (oh, I'm not on list, please CC relies if any).

Sure, I'm happy if somebody wants to use/improve libksane :)

> 
> 

/Kåre


More information about the Kde-graphics-devel mailing list