 |
Puppy Linux Discussion Forum Puppy home page: puppylinux.com
|
You last visited on Yesterday, at 11:22 pm The time now is Sun May 20, 2007 11:21 am
All times are UTC + 0 |
|
Page 2 of 2 [26 Posts] |
Goto page: Previous 1, 2 |
| Author |
Message |
jonyo

Joined: 28 Dec 2006 Posts: 414 Location: Toronto
|
Posted: Mon May 14, 2007 12:23 am Post subject:
|
|
Ohh maaan..thought I'd have a look see here & think I may have ended up in the Matrix
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 5
|
Posted: Mon May 14, 2007 8:25 am Post subject:
|
|
I will add a small IDE (a grafical programming tool) to generate programs using some templates.
The IDE will allow to create a project, open it in Glade, and edit the program that handles the events.
It also will include a list of all functions.
But before I do that, I wanted to finish the inbuilt functionality first.
I want to find a better solution for handling objects, maybe I can use a C struct (a table) to manage them.
Then you could use stuff like
button1 = gins_gtknewobject("GTKButton")
gins_gtk("window_add" , "window1" , "GINSOJECT:button1")
But this is a bit tricky, so no idea how fast I'll be in making progress.
Maybe I should start the ide first, to mayke it easier to use the already existing functionality.
Mark
|
|
Back to top
|
|
 |
Firefox
Joined: 03 Nov 2006 Posts: 53 Location: UK
|
Posted: Mon May 14, 2007 2:00 pm Post subject:
|
|
Please Please make an IDE. All I want is a PET
download with an icon to press so I can follow what your
doing/explaining, from running examples/tutorials and perhaps in time
learn to code. Only it seams one has to be a programer just to install
these things in order to learn how to program!!!!
Wonderful work your doing Mark no need to rush.
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 8052 Location: Karlsruhe, Germany
|
Posted: Mon May 14, 2007 6:22 pm Post subject:
|
|
it is pretty simple.
Install libglade with petget.
Download and extract http://noforum.de/files/wxbasic/ginsbasic/ginsbasic-0.0.1.tgz
Copy the file ginsbasic001 to /usr/bin/
Then you can start the examples by typing some comands in the consolewindow.
If you extracted to /root/:
cd /root/ginsbasic-0.0.1
./testtextview.pb
or
./calc
or
./testfilechooser.pb
To edit the layout of the windows, install Glade with petget.
Run it from the menu or by typing "glade".
Then you can open one of the .gladefiles I supplied, like
/root/ginsbasic-0.0.1/calc.glade
To modify the things that happen, when a button is clicked, open calc.pb in your texteditor.
Try to play around by modifying values, to see what happens.
Tell me if it works, or if you have the same problem as Barry.
Mark
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 8052 Location: Karlsruhe, Germany
|
Posted: Mon May 14, 2007 10:40 pm Post subject:
|
|
I found out, why the calculator does not work for Barry.
He uses JWM.
JWM grabs buttonclicks.
If you replace in calc.pb
| Code: | | if event = "GDK_BUTTON_PRESS" then |
with
| Code: | | if event = "GDK_BUTTON_RELEASE" then |
Then it works better, but still erratic.
The Window will just update, after you move the mouse outside the button, or click it a second time.
Very strange behaviour.
I use Icewm, so did not encounter this problem myself.
Unfortunately I have no idea, how gins could be modified to work around this issue.
Mark
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 3319 Location: Perenjori, Western Australia
|
Posted: Mon May 14, 2007 11:20 pm Post subject:
|
|
Mark, I guess JWM's interference is because GINS
is using stdin and stdout. Perhaps we need to redesign GINS to use two
different fifo piping streams. There is 0, 1, 2 already assigned to
stderr, stdin, stdout, but 3,4,5 are available. In the long term, that
might be the best thing to do for GINS.
Mark, you sure are having coding marathons! While you're at it, why not hack FreeBasic into FreeGin
...I wonder though, it might not be so difficult to patch in your stuff.
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 8052 Location: Karlsruhe, Germany
|
Posted: Mon May 14, 2007 11:29 pm Post subject:
|
|
ginsbasic does not use stdin stdout, as in ginsbasic the gins-functions are called directly as C functions.
The external gins is not needed, the functions are compiled into in the ginsbasic-binary.
Not not using the long way of invoking the shell.
This is one of the advantages.
I could remove the complete i/o handling (thread.c is removed completely).
I think it is an Xserver issue.
The Xserver receives a mouse-signal (buttonpress).
JWM grabs it, to be able to move windows or handle the click on the windowtitle-buttons.
Then it does not "re-send" the event correctly, so that the application running in that window can receive it.
But I wonder, why this just happens with the gins functions, not with other applications.
Maybe this guess is totally wrong.
Concerning freebasic:
I think the internal handling of variables will be completely different.
Puppybasic (wxBasic) uses its own type "variant".
But some code might be usefull, like a bubblesort written in C.
The one written in Basic is quite slow.
Mark
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 8052 Location: Karlsruhe, Germany
|
Posted: Tue May 15, 2007 11:45 pm Post subject:
|
|
no update, just a short note on (slow) progress.
I now can create Gtk objects natively in Basic, without gins/glade. They also can be "mixed" with glade objects.
I now started on:
gtk_createobject("GtkButton" , "button96")
gtk("gtk_box_pack_start " , "vbox1" , "Gtk:button96" , "1" , "1","1",0)
gtk() is just the now renamed gins_gtkwidgetfunction().
gtk_createobject() will look if the objecttype (here GtkButton) is
supported by ginsbasic (this is just a matter of building a lot of
"if"s).
Then it is added to a global GList, so it remains in memory, when
the C-function returns to Basic. Also the name (button96) will be added
to such a list.
Now when you call gtk("gtk_box_pack_start , ... , "Gtk:button96" ...
then this function looks, if an argument has a ":" in it.
If yes, it uses this value to get the formerly stored object from the GList, and runs the wanted function with it.
Also this will work:
gtk("gtk_box_pack_start , ... , "Glade:button1" ...
This would use a button from the loaded glade-file instead.
I currently just checked it with this button.
I loaded a window made with glade, created this new "internal" button, and then attachedd it to the window. Works!
Now that I found a concept, there remains a lot of work.
I will have to enhance the code to support not only buttons.
And I must rewrite the script that generates gins.c , because now
it shall no longer "drop" functions that use objects as arguments.
So a lot to do for the next weekend(s).
And I should think about a new name.
Hmmm... no search-results for:
http://www.google.com/search?hl=en&q=gtkbasic
Mark
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 8052 Location: Karlsruhe, Germany
|
Posted: Thu May 17, 2007 11:17 pm Post subject:
|
|
No new download yet, just info on progress:
Working testprogram:
| Code: | //-- load file and show the window
gins_glade("test.glade")
gins_set("window1" , "100" , "100" , "<uposition>")
gins_main()
//-- test new objectstuff
//-- add new elements to a window made with glade
gtk_createobject("GtkButtonWithLabel" , "button96", "testbutton" , 0)
gtk("gtk_box_pack_start" , "vbox1" , ":button96" , "0","0","0",0)
gtk("gtk_widget_show" , ":button96" , 0 ,0,0,0,0)
gtk_createobject("GtkLabel" , "label77", "testlabel" , 0)
gtk("gtk_box_pack_start" , "vbox1" , ":label77" , "0","0","0",0)
gtk("gtk_widget_show" , ":label77" , 0 ,0,0,0,0)
//-- create a completely new window
gtk_createobject("GtkWindow" , "NewWindow", 0 , 0)
gtk("gtk_widget_show" , ":NewWindow" , 0 ,0,0,0,0)
gtk_createobject("GtkHBox" , "NewHBox", "0" , "0")
gtk("gtk_container_add" , ":NewWindow" , ":NewHBox" , "1","1","0",0 )
gtk("gtk_widget_show" , ":NewHBox" , 0 ,0,0,0,0)
gtk_createobject("GtkButtonWithLabel" , "button77", "wwwbutton" , 0)
gtk("gtk_box_pack_start" , ":NewHBox" , ":button77" , "1","1","0",0)
gtk("gtk_widget_show" , ":button77" , 0 ,0,0,0,0)
//gtk("gtk_window_resize" ,"window1" , "100" , "100", 0,0,0)
|
New Gtk-objects will be recognized by the arguments passed to a Gtk-function, if their names start with ":".
They are stored in a struct, that is iterated with help of a Glist.
Maybe it could be done also without the glist using pointers, but
I'm not experienced enough yet. That could remain for a final
code-optimization.
I now must extend this argument-type-detection for the glade-objects, too.
Then I must rewrite my buildscript, to recognize this new functionality.
When a new Gtk-widget is created, also the events will
automatically will be assigned to the "events()" function, so you can
request them like those of the glade-widgets.
Mark
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 8052 Location: Karlsruhe, Germany
|
Posted: Yesterday, at 1:13 am Post subject:
|
|
I renamed it now to gtkbasic 0.0.2.
I added a new TextView example,
that now has better support for buffers and Iterators. So you can
replace very precisely parts of a text, e.g. selected text.
I also added a Multifilechooser.
It can be run as standalone-widget (like Xdialog) from shellscripts. Example-script is included.
Note, it has "file-open" behaviour by default.
In Glade, you can choose among 4 types (File save, Select Folder, Create Folder).
I'll extend that widget later, so you can choose such options with a argument passed to the widget-script.
You can download a small binary with examples and ginsfunctions.txt, and a source-pack.
Source is for C-coders only.
http://noforum.de/files/wxbasic/gtkbasic/Gtkbasic-0.0.2.tgz
http://noforum.de/files/wxbasic/gtkbasic/Gtkbasic-0.0.2-source.tgz
Run "make install" or simply copy the file gtkbasic002 to /usr/bin.
Then type commands similar to this:
cd /whereyouextracted
./nameOfScript.pb
I had no time yet to build a small IDE, I'm sorry.
I had to write a lot of
code to wrap the objects, and there still is a lot of cleanup needed.
But now it should be already usable to write an IDE, so lets see...
---------------------------
Internals:
You now can use several objects as arguments for other objects.
This works best with those generated with the gtk_functions, not with the ones created with glade.
The code is generated automatically, I just had to replace some with
selfwritten ones (mostly the new() should not be used, use
gtk_createobject() instead).
--------
A problem I now encountered are "enums".
These are options like Gtk_window_new (TOPLEVEL | POPUP).
It seems I can not pass them as variables, what makes it complex to write a lot of "if / else" statements.
It also blows up the code (the interpreter now is already 250 kb uncompressed).
Enums are used often for creating new widgets to set default-options.
I'm not shure yet how to deal with this issue.
Mark
|
|
Back to top
|
|
 |
DavidBell
Joined: 24 Nov 2006 Posts: 76
|
Posted: Yesterday, at 6:29 am Post subject:
|
|
| Quote: | (MU) A problem I now encountered are "enums".
These are options like Gtk_window_new (TOPLEVEL | POPUP).
It seems I can not pass them as variables, what makes it complex to write a lot of "if / else" statements.
|
Not sure if this is what you mean but if the code is based on C++
then things like TOPLEVEL in this case will usually be #defines and
handled by the C preprocessor. Maybe it would be easier to make a basic
preprocessor that took an array (or .csv) of couplets for each define,
then just do a search and replace before running.
| Code: |
Eg Preprocess pseudo-code
DefineArray = (TOPLEVEL, 1),
(POPUP, 2),
(etc, 4)
....
For Each DefineArrayIndex
SearchAndReplace ProgramText, DefineArrayIndex(0), DefineArrayIndex(1)
Next
|
Might be a bit slower but probably smaller and easier to maintain in long run.
BTW you probably already know, but | is bitwise OR, but for the
purposes of passing settings like this it's effectively the same as +
DB
|
|
Back to top
|
|
 |
|
|
Page 2 of 2 [26 Posts] |
Goto page: Previous 1, 2 |
|
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You cannot delete your posts in this forum You can vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|