Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 30 Jul 2014, 19:55
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 63 [942 Posts]   Goto page: Previous 1, 2, 3, 4, ..., 61, 62, 63 Next
Author Message
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Wed 05 Aug 2009, 06:25    Post subject:  

Excellent stuff.

Image in frame, how does that work for syntax ?

Sad, doesn't work.

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool
Back to top
View user's profile Send private message Visit poster's website 
01micko


Joined: 11 Oct 2008
Posts: 7785
Location: qld

PostPosted: Wed 05 Aug 2009, 06:41    Post subject:  

tasmod wrote:
Excellent stuff.

Image in frame, how does that work for syntax ?

Sad, doesn't work.


LMAO tasmod!

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4284

PostPosted: Mon 14 Sep 2009, 10:20    Post subject:  

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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5650
Location: Valåmoen, Norway

PostPosted: Mon 14 Sep 2009, 13:38    Post subject:  

technosaurus
I have put a link to your page in the main post.
Thank you!!!

Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Fri 18 Sep 2009, 14:59    Post subject: 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 Razz 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:


#! /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



Any ideas are welcome.

please consider that it may be rewritt4en to use eventdriven mode
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Fri 18 Sep 2009, 17:37    Post subject: Re: more interactivity  

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 Very Happy
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4284

PostPosted: Fri 18 Sep 2009, 19:14    Post subject:  

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

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Fri 18 Sep 2009, 20:28    Post subject:  

[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:

PDFVARNAME="`basename $ORIGINALNAME | cut -d. -f1`.pdf"
Back to top
View user's profile Send private message 
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Sat 19 Sep 2009, 07:48    Post subject:  

Quote:

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 Razz

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.

Quote:

<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.
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Sat 19 Sep 2009, 08:40    Post subject:  

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
pdfprint.tar.gz
Description 
gz

 Download 
Filename  pdfprint.tar.gz 
Filesize  1.41 KB 
Downloaded  1081 Time(s) 
Back to top
View user's profile Send private message 
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Sat 19 Sep 2009, 11:26    Post subject:  

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:

cd /root/my-documents


and i would suggest

Code:

cd ~/my-documents


this makes the program multiuser compatible. Even if it is not yet used like that.

Thanks again.
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sat 19 Sep 2009, 11:47    Post subject:  

Perhaps this is the problem - your code is using "entry accept"

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


try this-

Code:
 <entry activates-default="true">
        <default>$PDFFILE</default>
        <variable>PDFFILE</variable>
      </entry>
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Sat 19 Sep 2009, 12:53    Post subject:  

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
pdfprint-1.tar.gz
Description 
gz

 Download 
Filename  pdfprint-1.tar.gz 
Filesize  1.45 KB 
Downloaded  1078 Time(s) 
Back to top
View user's profile Send private message 
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Sat 19 Sep 2009, 12:54    Post subject:  

Quote:
Perhaps this is the problem - your code is using "entry accept"

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



try this-

Code:
Code:
 <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?
Back to top
View user's profile Send private message 
nikin

Joined: 14 Sep 2009
Posts: 18

PostPosted: Sat 19 Sep 2009, 13:13    Post subject:  

Quote:
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 Razz as the number of line writen by you exceed the original Smile
I am ok with the pascal aproach Razz 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 Razz

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

Bests Razz

nikin
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 63 [942 Posts]   Goto page: Previous 1, 2, 3, 4, ..., 61, 62, 63 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1260s ][ Queries: 13 (0.0276s) ][ GZIP on ]