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 Sat 25 Oct 2014, 10:35
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
gtkbasic-0.0.2
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 2 of 6 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, 6 Next
Author Message
jonyo

Joined: 28 Dec 2006
Posts: 2727

PostPosted: Sun 13 May 2007, 20:23    Post_subject:  

Ohh maaan..thought I'd have a look see here & think I may have ended up in the Matrix Shocked Razz
Back to top
View user's profile Send_private_message 
MUguest

Joined: 09 Dec 2006
Posts: 73

PostPosted: Mon 14 May 2007, 04:25    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
View user's profile Send_private_message 
Firefox

Joined: 03 Nov 2006
Posts: 171
Location: UK

PostPosted: Mon 14 May 2007, 10:00    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
View user's profile Send_private_message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Mon 14 May 2007, 14:22    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
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Mon 14 May 2007, 18:40    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
View user's profile Send_private_message Visit_website 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Mon 14 May 2007, 19:20    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 Laughing
...I wonder though, it might not be so difficult to patch in your stuff.
Back to top
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Mon 14 May 2007, 19:29    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
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Tue 15 May 2007, 19:45    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
Smile

Mark
Back to top
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Thu 17 May 2007, 19:17    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
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Fri 18 May 2007, 21:13    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... Smile
---------------------------
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
View user's profile Send_private_message Visit_website 
DavidBell

Joined: 24 Nov 2006
Posts: 132

PostPosted: Sat 19 May 2007, 02:29    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
View user's profile Send_private_message 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 20 May 2007, 07:35    Post_subject:  

hm, yes, you could then set options like:

gtk_window_new( ... , 1+4+8 )

I will think about that, thanks Smile
Mark
Back to top
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Sun 20 May 2007, 07:40    Post_subject:  

I made a dotpup of a minimally enhanced version 002.

Download:
http://dotpups.de/dotpups/Programming/Gtkbasic-002.pup

It includes some Forum-messages as "documentation" (ahem, sorry, no real one yet).

But it has a very cool fileselection-dialog.

It is so easy to use from shellscripts:

Code:
#!/bin/bash

#--------------------------------------------------------
#-- setup the path to the dialogs

GBdialogPATH=/usr/local/Gtkbasic-002

FILECHOOSER="$GBdialogPATH/dialog-multifilechooser/GBdialog-multifilechooser"

#---------------------------------------------------------------
# modes (1-4) open file , save file , open folder , create folder
# multiselect only for mode 1


# -- open multiple files -----------------------------------

title="Open Files"
folder="/usr/share/audio"
wildcards="*.au"
mode="1"
multiselect="1"
result=`"$FILECHOOSER" "$title" "$folder" "$wildcards" "$mode" "$multiselect" 2>/dev/null`


#-- display the choice: -----------------------------------

xmessage -center "you chose:
$result

bye bye...
"


I plan to build more such dialogs.
Thats all for now, no IDE and such yet, as I'm fiddling a lot on the internal stuff, as described here (xwin_getdir):
http://wxbasic.sourceforge.net/phpBB2/viewtopic.php?t=1042


Mark
Back to top
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Mon 21 May 2007, 17:19    Post_subject:  

I updated all the Gtkbasic002 packages.

There was a bug in the way I handled Textiterators.
Those iterators thell a function, where to start and stop a modification of text.

Now you can directly adress one of 6.

Example:
Code:
 gtk("gtk_text_buffer_get_selection_bounds",":buf1" , "dummy" , "dummy" , 0, 0,0 )

Now is:
Code:
 gtk("gtk_text_buffer_get_selection_bounds",":buf1" , "1" , "2" , 0, 0,0 )


This comand "fills" Textiterator 1 and 2 with the position of the start and end of the currently selected Text in buf1.

Then you can for example delete this part of the text with:
Code:
    gtk("gtk_text_buffer_delete", ":buf1" , "1" , "2" , "1", 0,0)


As you have 6 Iterators, you also could handle a second (and third) Textbuffer, while iterators 1 and 2 are already in use.

Code:
 
 gtk("gtk_text_buffer_get_selection_bounds",":buf2" , "3" , "4" , 0, 0,0 )
 gtk("gtk_text_buffer_delete", ":buf2" , "3" , "4" , "1", 0,0)


Stupid example, but it uses the same commands with just different values just to illustrate the difference.

So you enter a number from 1 to 6 for the placeholders, that are described as TextIterators in the documentation.

Mark
Back to top
View user's profile Send_private_message Visit_website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Wed 23 May 2007, 17:30    Post_subject:  

Updated the 002 archives.

Changes:
GDK_DELETE event now will NOT be sent to the Gtk-mainloop any longer, but only detected by the Basic-program.
Reason:
In Glade, you create 2 windows.
A mainwindow and a dialog.
Window is visible, dialog not.
If you click a button, the dialog is shown.
Now the problem: If the dialog is closed, it is destroyed.
If you click the button again, the program crashes, because the dialog does not exist any more.

With the patch, you can do this:
In the mainloop, if GDK_DELETE is detected, you use
gtk("gtk_widget_hide" , "dialog" , ...)
Now this dialog becomes invisible, but is no longer destroyed, as the event is no longer processed any further.
If you wanted to destroy the dialog, you now had to call gtk("gtk_widget_destroy,...).

I included "ide.pb", which is a very rough layout-prototype of the planned ide.
It has no functionality yet, but you can click on "new" to open a dialog.
This dialog can be closed and reopened with the new gtkbasic002.

I found another bug:
Opening dialogs/other windows sometimes results in a "Xlib async error", and the program freezes.
I tried some quick tests to catch the Xlib-errors (as I did already in some xwin_ functions in Puppybasic. But I had no success yet, I must do more tests with this issue.

--------------------
another issue:
radiobuttons.
If you select the option to set one active by default, glade crashes, if you reload your project.
You then must remove that line with a texteditor.
Also Gtkbasic crashes, if you send a activate-command for a radiobutton to libglade.
Radiobuttons use gslists from Glib, so I suspect there is a library-conflict somewhere.
Must google for that bug.

-----------------------
Next "long" weekend I drive 550 km to Hamburg and must hand over my old appartment, so I will not be online (maybe just very short) or develop stuff.
I'll return monday or wednesday, not shure yet.

Mark
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 2 of 6 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, 6 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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