Page 2 of 76

Re: more interactivity

Posted: Fri 18 Sep 2009, 21:37
by seaside
nikin wrote: When i open a file in the first box, i would like to automatically fill the save box with originalfile.name.pdf

I cant figure out how to do that?
nikin,

Not sure if this would work, but what about adding a function for the first box like this-

<action>FUNCTION-TO-CONVERT-ORIGINALFILENAME-TO-PDF</action>

Then in the second box put <default>$NEW-VARIABLE-CREATED-BY-FUNCTION(originalfile.name.pdf)</default>

Another possibility is just to convert it directly without the second box to "originalfile.name.pdf" -probably what most would do :D

Posted: Fri 18 Sep 2009, 23:14
by technosaurus
if it is from input such as gtkpdf /path/to/file.extension

put either '$1.pdf' or $1.pdf as default

but this would give you "file.extension.pdf"

there are several bash scripts available to remove extensions using for instance basename and sed

it would look like
DEFAULTFILENAME=......$1
then use $DEFAULTFILENAME in the default section

I don't have my puppypc right now but googling "remove extensions basename sed" give a bunch of examples

Posted: Sat 19 Sep 2009, 00:28
by seaside
[quote="technosaurus"
I don't have my puppypc right now but googling "remove extensions basename sed" give a bunch of examples[/quote]

You probably could -

Code: Select all

PDFVARNAME="`basename $ORIGINALNAME | cut -d. -f1`.pdf"

Posted: Sat 19 Sep 2009, 11:48
by nikin
Another possibility is just to convert it directly without the second box to "originalfile.name.pdf" -probably what most would do
Maybe.. but i still would like to write a good program :P

There is a slight misunderstanding on what i need help in.
Thanks for the tips for file name generation...but what i need is the way how to make gtkdialog use that name.
<action>FUNCTION-TO-CONVERT-ORIGINALFILENAME-TO-PDF</action>

Then in the second box put <default>$NEW-VARIABLE-CREATED-BY-FUNCTION(originalfile.name.pdf)</default>
idid try this... with nno luck.
The value justwont get in the box.

Posted: Sat 19 Sep 2009, 12:40
by vovchik
Dear nikin,

Please have a look at the attachment. I added some default file name handling and made pdfprint suitable for use in Rox using a right click on html, doc, rtf and txt (Customize Menu in Rox after a right click on one of those files and create a symlink to pdfprint). It works. Thanks for producing it.

With kind regards,
vovchik

Posted: Sat 19 Sep 2009, 15:26
by nikin
Dear vovchik

Nice addition to the code. Thank you.
I think after i get this "filename in gtkdialog" thing done, we can release it. I also consider to add more ps2pdf options to the program.

One thing:

you have written

Code: Select all

cd /root/my-documents
and i would suggest

Code: Select all

cd ~/my-documents
this makes the program multiuser compatible. Even if it is not yet used like that.

Thanks again.

Posted: Sat 19 Sep 2009, 15:47
by seaside
Perhaps this is the problem - your code is using "entry accept"

Code: Select all

<entry accept="savefilename">
   <variable>PDFFILE</variable>
   <input>echo $PDFFILE</input>
      </entry> 
try this-

Code: Select all

 <entry activates-default="true">
        <default>$PDFFILE</default>
        <variable>PDFFILE</variable>
      </entry>

Posted: Sat 19 Sep 2009, 16:53
by vovchik
Dear nikin,

I think this is a nice and useful little app. I restructured the code a little, mostly for optics but also to relegate the processing to functions and to make a minimal main, since I am an old Pascal/Modula freak. Have you tried seaside's suggestion? I am about to.

With kind regards,
vovchik

Posted: Sat 19 Sep 2009, 16:54
by nikin
Perhaps this is the problem - your code is using "entry accept"

Quote:
Code:

Code: Select all

<entry accept="savefilename">
   <variable>PDFFILE</variable>
   <input>echo $PDFFILE</input>
      </entry>

try this-

Code:

Code: Select all

 <entry activates-default="true">
        <default>$PDFFILE</default>
        <variable>PDFFILE</variable>
      </entry>
Sorry I am kind of new in this.
Can you please explain what this changes?

Posted: Sat 19 Sep 2009, 17:13
by nikin
Dear nikin,

I think this is a nice and useful little app. I restructured the code a little, mostly for optics but also to relegate the processing to functions and to make a minimal main, since I am an old Pascal/Modula freak. Have you tried seaside's suggestion? I am about to.

With kind regards,
vovchik
Dear vovchik,

Slowly you can claim to be the author of the program :P as the number of line writen by you exceed the original :)
I am ok with the pascal aproach :P maybe the processPDF could be merged into the connverter routine... but thats all.
I didnt try. i don't realy understand. what that would change, as this is the first time i touch gtkdialog :P

one question:
why do you export ORIGIFILE and not PDFFILE ?

Bests :P

nikin

Posted: Sat 19 Sep 2009, 17:26
by vovchik
Dear nikin,

The program is yours - I added a lot of comments, I think. The reason I export ORIGIFILE in the original init vars is so that the dialog will know about it. PDFFILE is also exported, but that happens in the function fix_filename(), once we have determined whether or not we have anything passed on the command line. In the latest version, it is the last line in that function.

I think it this script could be linked to the copnversion program nicely. I am having a problem getting graphics to print in html2pdf conversion, but it may be that my ghostscript settings are bad. I will check.

As for seaside's proposal, I will check my little gtkialog "manual" - a short but useful synopsis of most commands written in French (with examples). I think it is posted in earlier pages of this topic. Otherwise look up my posts. It will be there somehwere. If you don't find it, I can post it again.

With kind regards,
vovchik

Posted: Sat 19 Sep 2009, 18:48
by vovchik
Dear nikin,

This is the link to the gtkdialog manual:

http://www.murga-linux.com/puppy/viewt ... p?t=40420

I found the examples very instructive - since they show syntax. The author also explains a few things nicely.

With kind regards,
vovchik

Posted: Sun 20 Sep 2009, 02:53
by seaside
nikin-

I was away from Puppy and could only give you some general hints before.

Here's a quick concept code I put together.

Code: Select all

#! /usr/sbin/gtkdialog -e
## gtkdialog3 has to be linked to gtkdialog in usr/sbin
ORIGINALFILE=root/somewhere/somefilename.doc

function change_pdf() {

PDFFILE="`basename $ORIGINALFILE | cut -d. -f1`.pdf" 
echo $PDFFILE
}

export MAIN_DIALOG='
<vbox>
<entry>
<input>echo $ORIGINALFILE</input>
<variable>ORIGINALFILE</variable>
<action>change_pdf</action>
</entry>
<entry>
<input>change_pdf</input>
<variable>PDFFILE</variable>
</entry>
  <button>
    <label>Exit</label>
  </button>
</vbox>
'

After the original file name is selected in the first box, the function change_pdf will convert the original file name to "original file basename".pdf and it will appear in the second box and all the variables are retained.

There are probably other ways to do this and Gtkdialog is sometimes very mysterious. :D

Posted: Sun 20 Sep 2009, 05:03
by sunburnt
Very good zigbert! This is Wiki material for sure...
I made some script libraries years ago to make gtkDialog easier.
The author of gtkDialog said: "It`s a very bad program I wrote years ago."
I agree, it`s not a very good setup, but then I hate XML stye script anyway...
Basic style command lines are far easier to understand and use by anyone.

Posted: Sun 20 Sep 2009, 09:19
by vovchik
Dear nikin,

I added a help screen to PPDF. I think we could modify the text to make it more informative, but it's a start.

With kind regards,
vovchik

Posted: Sun 20 Sep 2009, 12:08
by nikin
Dear seaside:
I was away from Puppy and could only give you some general hints before.

Here's a quick concept code I put together.
Almost working
I haked it together so dat it works. Some UTF compatibility problems stil emerge.. but i willfix them .

Modified

Code: Select all

#! /usr/sbin/gtkdialog -e
## gtkdialog3 has to be linked to gtkdialog in usr/sbin

function change_pdf() {

PDFFILE="`basename $ORIGINALFILE | cut -d. -f1`.pdf"
export PDFFILE
echo $PDFFILE
}

export MAIN_DIALOG='
<vbox>
<entry>
<input>echo $ORIGINALFILE</input>
<variable>ORIGINALFILE</variable>
<action>change_pdf</action>
<action>refresh:PDFFILE</action>
</entry>
<entry>
<input>change_pdf</input>
<variable>PDFFILE</variable>
</entry>
  <button>
    <label>Exit</label>
  </button>
</vbox>
'


Thank you for the hint. :D

Posted: Sun 20 Sep 2009, 12:15
by nikin
Dear nikin,

I added a help screen to PPDF. I think we could modify the text to make it more informative, but it's a start.

With kind regards,
vovchik
Dear vovchik,

Nice addition again... after i get home from work, i will put it together with the code i built from seaside's source.

Question:
Should i include the capability do password protect the genared pdf?

Posted: Sun 20 Sep 2009, 13:22
by vovchik
Dear nikin,

With seaside's mods and all of our ideas, I think we will have a nice and useful program for Puppy. Password protection is not a bad idea - my only problem is that I password protected a few pdfs a few years ago and no longer remember the password :(.

Good luck... I am eager to see the results.

With kind regards,
vovchik

ppdf 0.1.5

Posted: Mon 21 Sep 2009, 03:13
by nikin
Hi everyone!

I had some time and done the folowing:

- merged seaside's idea.
- merged vovchik's last version
- reworked the code to work in event driven mode
- rewritten help text.
- Changed Help box button from CANCEL to CLOSE
- Changed main dialog button from CANCEL to QUIT
- The program now tries to automatically create the gtkdialog link

Get it, test it, comment on it.
And i would like to thank everyone who helped :)
I reached my original goals by now.

Now its time for ideas on how to improove.
The main thing in my mind is to make it possible to add opening and editing passwords

bytheway its called ppdf becouse it is written to replace puppypdf

i would like to make 1.8 the first release so any bugreports are highly welcommed.

And i think this program begins to get a nice gtkdialog example. only if i could comment inside the dialogdescriptions.

its 5 am ...ihaveto sleep. :cry:

Bests

nikin

    Posted: Mon 21 Sep 2009, 07:21
    by vovchik
    Dear nikin,

    Nice work. We do have a little problem now in that the parameter passing from the command line for ORIGIFILE does not work. Try dropping a file (e.g. doc) onto ppdf. The filename should show up in the Original input box - as it did before. Now it does not, so it cannot be used as a "handler" in ROX. I am looking into it. When you wake up and have time, please also have a look....

    With kind regards,
    vovchik