GtkDialog - tips
LMAO tasmod!tasmod wrote:Excellent stuff.
Image in frame, how does that work for syntax ?
Sad, doesn't work.
Puppy Linux Blog - contact me for access
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I posted a howto here for building a simple gtkdialog frontend to a command line program from a template (I forgot to add radio buttons - oops)
http://www.murga-linux.com/puppy/viewtopic.php?t=45474
another thing I found useful was to use pfind to search for files containing gtkdialog (the list more than filled my screen)
any feedback is welcome
http://www.murga-linux.com/puppy/viewtopic.php?t=45474
another thing I found useful was to use pfind to search for files containing gtkdialog (the list more than filled my screen)
any feedback is welcome
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
more interactivity
Hy.
After i hammered puppypdf for 4.3 release to work, i was thinking on redooing it in gtkdialog for three reasons. First is that newer puppy aps are using gtkdialog, looks better, and all secondly becouse i use some ps2pdf features for optimization so i was thinking why not include them in the gui.
Thirs is that i prefer to have a one step aproach intead of the wizard style of puppypdf.
So as i never touched gtkdialog before i hacked together something which is pre-prealpha. just i cant get one thing going.
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?
Any ideas are welcome.
please consider that it may be rewritt4en to use eventdriven mode
After i hammered puppypdf for 4.3 release to work, i was thinking on redooing it in gtkdialog for three reasons. First is that newer puppy aps are using gtkdialog, looks better, and all secondly becouse i use some ps2pdf features for optimization so i was thinking why not include them in the gui.
Thirs is that i prefer to have a one step aproach intead of the wizard style of puppypdf.
So as i never touched gtkdialog before i hacked together something which is pre-prealpha. just i cant get one thing going.
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?
Code: Select all
#! /bin/bash
TITLE="PPDF 0.1.2"
ORIGIFILE=""
PDFFILE=""
GUI="yes"
function ppdf_convert() {
TMPFILE="/tmp/tmp.ps"
if [ "$GUI" = "yes" ]; then
`Xdialog --timeout 2 --msgbox "STARTING CONVERSION" 0 0`
else
echo "STARTING CONVERSION"
fi
ABIW_OUT=`abiword --to=ps --to-name=$TMPFILE $ORIGIFILE`
PSPDFOUT=`ps2pdf -dPDFSETTINGS=/$OPTIMIZE $TMPFILE $PDFFILE`
if [ "$GUI" = "yes" ]; then
`Xdialog --timeout 2 --msgbox "FINISHED" 0 0`
else
echo "FINISHED"
fi
}
export DIALOG='
<window title="'$TITLE'" icon-name="gtk-dnd">
<vbox>
<hbox>
<pixmap icon_size="8">
<input file stock="gtk-dnd"></input>
</pixmap>
<vbox>
<text use-markup="true">
<label>"<b>'$TITLE'</b>"</label>
</text>
<text>
<label>Convert TXT, RTF, DOC, HTML ... etc, to PDF</label>
</text>
</vbox>
</hbox>
<hbox>
<text>
<label>Original file:</label>
</text>
<entry accept="filename">
<variable>ORIGIFILE</variable>
<input>echo $ORIGIFILE</input>
</entry>
<button>
<input file icon="gtk-open"></input>
<action type="fileselect">ORIGIFILE</action>
<action>refresh:ORIGIFILE</action>
<action>echo $PDFFILE</action>
</button>
</hbox>
<hbox>
<text>
<label>PDF file:</label>
</text>
<entry accept="savefilename">
<variable>PDFFILE</variable>
<input>echo $PDFFILE</input>
</entry>
<button>
<input file icon="gtk-open"></input>
<action type="fileselect">PDFFILE</action>
<action type="refresh">PDFFILE</action>
</button>
</hbox>
<hbox>
<text>
<label>Optimize for:</label>
</text>
<combobox>
<variable>OPTIMIZE</variable>
<item>default</item>
<item>screen</item>
<item>ebook</item>
<item>printer</item>
<item>prepress</item>
</combobox>
</hbox>
<hbox>
<button>
<label>Create PDF</label>
<action type="exit">OK</action>
</button>
<button cancel>
</button>
</hbox>
</vbox>
</window>'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog3 --program DIALOG); do
eval $STATEMENTS
done
IFS=$I
if [ "$EXIT" = "OK" ]; then
ppdf_convert
else
echo "Canceled"
fi
please consider that it may be rewritt4en to use eventdriven mode
Re: more interactivity
nikin,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?
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
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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
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
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
[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 -
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"
Maybe.. but i still would like to write a good programAnother possibility is just to convert it directly without the second box to "originalfile.name.pdf" -probably what most would do
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.
idid try this... with nno luck.<action>FUNCTION-TO-CONVERT-ORIGINALFILENAME-TO-PDF</action>
Then in the second box put <default>$NEW-VARIABLE-CREATED-BY-FUNCTION(originalfile.name.pdf)</default>
The value justwont get in the box.
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
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
- Attachments
-
- pdfprint.tar.gz
- (1.41 KiB) Downloaded 1877 times
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
and i would suggest
this makes the program multiuser compatible. Even if it is not yet used like that.
Thanks again.
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
Code: Select all
cd ~/my-documents
Thanks again.
Perhaps this is the problem - your code is using "entry accept"
try this-Code: Select all
<entry accept="savefilename"> <variable>PDFFILE</variable> <input>echo $PDFFILE</input> </entry>
Code: Select all
<entry activates-default="true">
<default>$PDFFILE</default>
<variable>PDFFILE</variable>
</entry>
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
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
- Attachments
-
- pdfprint-1.tar.gz
- (1.45 KiB) Downloaded 1905 times
Sorry I am kind of new in this.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>
Can you please explain what this changes?
Dear 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
Slowly you can claim to be the author of the program as the number of line writen by you exceed the original
I am ok with the pascal aproach 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
one question:
why do you export ORIGIFILE and not PDFFILE ?
Bests
nikin
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
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
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
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
nikin-
I was away from Puppy and could only give you some general hints before.
Here's a quick concept code I put together.
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.
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>
'
There are probably other ways to do this and Gtkdialog is sometimes very mysterious.
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.
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.
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
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
- Attachments
-
- pdfprint.tar.gz
- (1.82 KiB) Downloaded 1837 times