Could Puppy use a gtkDialog exec. or function library?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

Could Puppy use a gtkDialog exec. or function library?

#1 Post by sunburnt »

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: Select all

#!/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 Tue 16 Mar 2010, 03:13, edited 4 times in total.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

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/viewto ... h&id=25758
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].

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

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.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#4 Post by 8-bit »

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: Select all

    <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.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#5 Post by sunburnt »

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: Select all

<action>save_geometry</action>
Does the same thing as this:

Code: Select all

<action signal="button-press-event">save_geometry</action>
However... This exit code does make the "killWindow" routine unneeded:

Code: Select all

<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, 21:19, edited 1 time in total.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#6 Post by technosaurus »

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
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].

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#7 Post by sunburnt »

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.

Post Reply