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 Fri 29 Aug 2014, 14:36
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Could Puppy use a gtkDialog exec. or function library?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Mon 15 Mar 2010, 22:17    Post subject:  Could Puppy use a gtkDialog exec. or function library?  

There a real need to make it easier to make GUIs with gtkDialog. I suggested several things...
A thought I had was an executable or function library for support of commonly needed code.
A function library is the usual way of bringing support code into a program. But I dislike
dragging in an entire library of code into my program just for one function that may not run.
So an executable library can do pretty much the same thing ( mostly ) without loading up ram.
Here`s a start on a library: help, saving of position and size, and kill window for an exit button.
Code:
#!/bin/sh
######  Exec. library for gtkDialog

if [ "$1" = '-h' -o "$1" = '--help' ];then                                                                             # help
  echo -e \\n'###  gtkdialog.lib -e = Example GUI code.'\\n'###  List of executibles:'
  echo -e '# saveGeometry: Save GUI`s ($LEFT x $TOP) and ($WIDTH x $HEIGHT).'
  echo -e '   Argument $2 = GUI`s window title.'\\n'   Argument $3 = GUI`s path.'
  echo -e '# killWindow: Close GUI.'\\n'   Argument $2 = gtkDialog`s "export" program name.'
elif [ "$1" = '-e' ];then                                                                                                             # example
  echo -e \\n'### Example code for a GUI that remembers it`s size and position:'\\n
  echo -e '#!/bin/sh'
  echo -e '[ -e $1/GUI_geometry ]&& . $1/GUI_geometry'
  echo -e 'export GUI="'
  echo -e '<window title=\"GUI\" default_width=\"$WIDTH\" default_height=\"$HEIGHT\"><vbox>'
  echo -e '  <button><label>Exit</label><action>. gtkDialog.lib saveGeometry GUI $1</action>'
  echo -e '    <action>gtkDialog.lib killWindow GUI</action></button></vbox></window>'
  echo -e '</vbox></window>"'
  echo -e 'gtkdialog3 --program=GUI --geometry +"$LEFT"+"$TOP"'\\n
elif [ "$1" = 'saveGeometry' ];then                                                                      # save the GUIs geometry
  XWININFO=`xwininfo -stats -name $2`
  X1=`echo "$XWININFO" | grep 'Absolute upper-left X' | awk '{print $4}'`
  Y1=`echo "$XWININFO" | grep 'Absolute upper-left Y' | awk '{print $4}'`
  X2=`echo "$XWININFO" | grep 'Relative upper-left X' | awk '{print $4}'`
  Y2=`echo "$XWININFO" | grep 'Relative upper-left Y' | awk '{print $4}'`
  echo "LEFT=$(($X1-$X2))" > $3/$2_geometry ; echo "TOP=$(($Y1-$Y2))" >> $3/$2_geometry
  echo WIDTH=`echo "$XWININFO" | grep 'Width:' | awk '{print $2}'` >> $3/$2_geometry
  echo HEIGHT=`echo "$XWININFO" | grep 'Height:' | awk '{print $2}'` >> $3/$2_geometry
elif [ "$1" = 'killWindow' ];then                                                                                                 # kill the GUI
   psID=`ps |grep program=$2 |egrep -v '(grep|geany)' |awk '{print $1}'`
   [ "$psID" ]&& kill $psID
fi

I think that credits for the donors of each code chunk could be part of it as a "help-credits".

Anyone`s thoughts ??? ... Maybe Barry could add a word as to Puppy including it.
.

Last edited by sunburnt on Mon 15 Mar 2010, 23:13; edited 4 times in total
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4346

PostPosted: Mon 15 Mar 2010, 22:29    Post subject:  

Here is a set of templates for the most common uses:
http://www.murga-linux.com/puppy/viewtopic.php?t=45474

Here is a toolkit (bbgui) loosely based on them where you just declare variable names- currently for creating a gui for a single command line program, however it is easily adapted for other means
http://www.murga-linux.com/puppy/viewtopic.php?mode=attach&id=25758

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


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Mon 15 Mar 2010, 22:59    Post subject:  

technosaurus; Looks pretty well developed...
My setup was a script that read a gui-script and wrote a line of gtkdialog code at a time.
Much like yours, but it having gtkDialog code only it could also be used for a "Help".
The gui builder I made could run the gui directly, or save it as a finished gui.
It was a library like the one above with only gtkDialog code in it. Easy to maintain...
The gui-script language was much easier to write and read than gtkDialog code is.

Obviously connecting the action event signals so they do something requires more code.
Just what the above library is for, so writing that support code`s easier with reusable code.
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Mon 15 Mar 2010, 23:36    Post subject:  

While you are talking about action event, how about a snipit of code I used in a mod of your program that I PMed to you and you never downloaded to even check it out.

Code:

    <button>
      <label>Exit</label>
      <action signal="button-press-event">save_geometry</action>
      <action type="Exit">exit 0</action>
    </button>


This particular one acts on a button press and then runs a subroutine to save a window's geometry before exiting.
I found it by examining examples and also the gtkdialog3 source code.
You would be amazed at what you can discover.
If it was documented as to how to use each and what it does, that would be even better.
KUDOs to Zigbert for trying.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 01:15    Post subject:  

8-bit; You`re right ( of course...) I looked at it, but I had to leave and forgot about it!
Basically the same function code as the exec. library has for saving the GUI geometry.
But the button code you have is more complex than the old simple <action> code.
This:
Code:
<action>save_geometry</action>

Does the same thing as this:
Code:
<action signal="button-press-event">save_geometry</action>

However... This exit code does make the "killWindow" routine unneeded:
Code:
<action type="Exit">exit 0</action>


Another point I made is that with a library you don`t have to write the same code over and over.
So the function "save_geometry" doesn`t have to be added to every GUI needing it... Nice !!!

Last edited by sunburnt on Tue 16 Mar 2010, 17:19; edited 1 time in total
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4346

PostPosted: Tue 16 Mar 2010, 17:08    Post subject:  

I designed bbgui to behave like busybox. I eventually want to get back to it and make simple frontends to all of the busybox utilities.

The whole idea behind it was to have as much code shared as possible to reduce the size, have all of the code contained in one file and operate both via symlinks or by passing the program name as $1

Where I have individual functions setup that declare all of the variables, it could instead be in a separate script (the scripting language is quite basic and explained in the header comments and template function) ... it already writes the gui file to /dev/shm (/dev/shm is always in ram so it is faster than /tmp)

to use an external file instead of a function you would just use

. /path/to/my_scripting_language.file #that is <dot><space>/... for those with bad eyes

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


Joined: 08 Jun 2005
Posts: 5016
Location: Arizona, U.S.A.

PostPosted: Tue 16 Mar 2010, 17:47    Post subject:  

technosaurus; yep, that`s what I`d like to see, more reusable routines in Puppy.
Puppy has a lot of the needed utilities now, some support for developers would be nice.
I think separate libraries for: handling files, file sys., lists, GUI routines, and gtkDialog code.
It would make for a new Puppy OS language with better syntax that`s more user friendly.
And as 8-bit pointed out in another forum thread. it would mean consistency in Puppy`s code.

Writing GUI script like this: btn "Run App." /path/to/app/file
Is much better than this: <button><label>Run App.</label><action>/path/to/app/file</action></button>

Q: I`m curious about /dev/shm I wrote a file to it just to test if it was there. Yes it is!
So it`s a usable file system, but it`s not mounted... Just too weird... Can you tell me more about it?
What`s it`s organization in ram like? How much space is allocated to it? Etc., etc., etc...
And are there any other file systems or "hidden" OS features and tricks that you know about?

I use <dot><space> ( run in same shell ) for reading in variables in settings files. Very useful...
I did think putting all the stray separate files in a BusyBox like file was a great idea.
But then I realize that everything was already in one SFS file that gathered it and compressed it.
SFS files can`t get viruses, or corrupt or delete internal files, but the SFS can corrupt and be deleted.
However the Save file can be ( and is...) the source of problems as it`s a group of loose files.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
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.0735s ][ Queries: 12 (0.0041s) ][ GZIP on ]