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 16 Apr 2014, 12:49
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 4 of 6 [78 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6 Next
Author Message
MU


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

PostPosted: Sat 09 Jun 2007, 09:03    Post subject:  

Ok, I can ask my mum to send me instant coffee from germany Wink

I updated:
http://dotpups.de/dotpups/Programming/Gtkbasic-002.pup

It now includes a *simple* IDE.
It might be unstable, I encountered Xlib-errors again, but more seldom now.
I however decided to release it, as it already might help to get started.
The IDE itself does not "save" files, it just uses leafpad and Glade.
So it is not so worse, if it should crash.

You currently can create new projects (a button or a calculator), run them, modify them, dotpup them.

Not much more yet, but I think for someone completely new it is hepfull to have everything available from one interface.

Here is a screenshot:



Limitations:
occasional crashes when the "new"-dialog opens.
The Textview crashes often, if the text you load contains ":".
For this reason I wrote a function as a workaround, that replaces ":" with "-->".
Very dirty, just to avoid crashes, until I found out what the heck is going on here.

Please see it still in Prototype-stadium, but now at least somewhat usable.
You can use xkill to delete crashed windows:
http://www.murga-linux.com/puppy/viewtopic.php?mode=attach&id=217

Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Sun 10 Jun 2007, 01:06    Post subject:  

I made a very slight change to the button-release code, what might fix the xlib-errors.
At least no crash yet in my tests, but I must test more to verify it.
Updated the dotpup.
Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Sun 10 Jun 2007, 02:00    Post subject:  

updated the dotpup.
I think I could workaround the issue with ":" in the textview.

You can open the IDE project in the IDE itself, to examine it.

Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Sun 10 Jun 2007, 02:24    Post subject:  

made an error while packaging, uploaded again.
Mark
Back to top
View user's profile Send private message Visit poster's website 
DavidBell

Joined: 24 Nov 2006
Posts: 132

PostPosted: Sun 10 Jun 2007, 05:09    Post subject:  

Does the .pup contain everything needed to try, or does it need some extras? I would like to try it in the next couple of weeks.

TIA DB
Back to top
View user's profile Send private message 
MU


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

PostPosted: Sun 10 Jun 2007, 08:09    Post subject:  

You need the pup and libglade.
I think libglade is already in the PuppIso, if not, install it with pupget.

The small dotpup includes everything you need, except the list of supported Gtk-functions.
That one is in the source-dotpup
http://noforum.de/files/wxbasic/gtkbasic/Gtkbasic-0.0.2-source.tgz

The source-dotpup is a bit out of date, I'll upload a new one later.
I'm currently messing around with clists, so my sourcefolder is a bit unclean.
It is not required however, just for people who need that functionlist and want to hack the C code.

Mark
Back to top
View user's profile Send private message Visit poster's website 
BarryK
Puppy Master


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

PostPosted: Sun 10 Jun 2007, 12:42    Post subject:  

Just had a play with it ...fascinating!
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Sun 17 Jun 2007, 14:57    Post subject:  

Here is the first "stable" version.
I finally could fix the xlib-errors, my first fix was buggy.


Now you can use Gtkbasic to control space-stations Wink

Ok, there still might be smaller bugs.
If I right-click the textview in the IDE, it crashes.
But that is not a Gtkbasic problem, but one of the widget or gins.
I made some quickchecks, and it should be fixable soon.

I also added a Clist-Demo.

Clists are lists with text (pictures come later).
You can drag entries from one list to another one.
The function-calls might change, as I plan to add more stuff.

But if you will use it already, just tell me, then I use different names for backwards-compatibility.

Here is a picture of 2 clists supporting Drag'n'Drop:



Download the dotpup with everything needed:
http://dotpups.de/dotpups/Programming/Gtkbasic-002.pup (158 kb)

Download source with functionslists, only for people who want to try more than available in the example-programs of the dotpup:
http://noforum.de/files/wxbasic/gtkbasic/Gtkbasic-0.0.2-source.tgz (800 kb)
That is a snapshot not cleaned up (backups and such), so it is a bit huge.

Mark
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Mon 18 Jun 2007, 13:54    Post subject:  

My last update caused new segmentation faults caused by modified events.
Fixed this now Smile

Looks very stable now.

Mark
Back to top
View user's profile Send private message Visit poster's website 
Komodo

Joined: 30 Mar 2007
Posts: 20

PostPosted: Tue 19 Jun 2007, 13:42    Post subject:  

Mark,
I believe this may be what I have been looking for, a small linux basic language with a GUI designer that can produce attractive, advanced applications. Now maybe I can dump wxLua!

From what I understand GtkBasic is based on wxBasic, correct? Does GtkBasic support all of the wxBasic data types and language features listed at http://noforum.de/wxBasicscript-documentation/wxbasic/frameset.htm ? I'm also a little confused about when to use the gins functions verses the Gtk functions. I looked at gtkfunctions.txt and ginsfunctions.txt and they seem almost identical. So which ones would you recommend that we use?

Cheers,
Komodo
Back to top
View user's profile Send private message 
MU


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

PostPosted: Tue 19 Jun 2007, 14:40    Post subject:  

Quote:
Does GtkBasic support all of the wxBasic data types and language features listed at http://noforum.de/wxBasicscript-documentation/wxbasic/frameset.htm ?


Yes.
Also all Puppybasic-programs should run with it.

gtkfunctions.txt is a file generated by my buildscript.
It then is used to generate ginsfunctions.txt.
So that one lists the supported Gtk-functions, though some still might not work. This currently requires trial and error, until my scripts become more intelligent.
ginsfuntions.txt lists a few less, as it does not list those functions my script had to drop because of typeconversion-problems.

Now that the clists work, I hope I soon can add a list of inbuilt functions to the IDE Smile

Please be aware, that Gtkbasic is a new project, and far not as functional yet as wxLua.

You can build small wizards with it, so it often could be used as an alternative to Gtkdialog or Xdialog,
But wxLua supports a lot more widgets you need to build advanced window-layouts.
The Demos I include give a quick overview, of what currently can be done with Gtkbasic.

However, now that I got it working stable, I can concentrate again on adding more widgets and functions Smile
This bug-search was very timeconsuming.

Mark
Back to top
View user's profile Send private message Visit poster's website 
DavidBell

Joined: 24 Nov 2006
Posts: 132

PostPosted: Mon 25 Jun 2007, 19:17    Post subject:  

Hi Mark,

Even though it's still early this looks like it could be really useful. One maybe bug, sometimes I find I have to press buttons twice to make them work, or maybe hold down a bit longer on the click, I'm not sure.

Also can you tell me where to find libglade, the Glade button in the IDE doesn't seem to work and I couldn't find it in petget package manager.

One last question, is there a way to run C functions from a compiled lib?

Thanks in advance. David
Back to top
View user's profile Send private message 
BarryK
Puppy Master


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

PostPosted: Tue 26 Jun 2007, 04:46    Post subject:  

Glade support is in the 'devx_216.sfs' file, you can get it off ibiblio, download to /mnt/home, then reboot.
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Tue 26 Jun 2007, 14:21    Post subject:  

I also mad a dotpup once:
http://puppyfiles.org/dotpupsde/dotpups/Programming/Gtkdialog079-and-Glade-3.0.3/Glade-3.0.3.pup

I think it includes Glade and all required libs.
I think I renamed glade to glade3 , so you might rename it to glade.

Concerning own functions:
You cannot run functions from external .so or .dll files, as they have no interfaces in wxBasic (Gtkbasic is based on wxBasic).

But you can add own functions to Gtkbasic, if you are a bit common with C.
Look at builtin.h in the sourcepackage, I'll explain it using a function I added in the past.

A function is declared by 2 lines:
Code:
void wBuiltin_xwin_system(void);

and
Code:
   {"xwin_system",           wBuiltin_xwin_system,           1,  0},


The "1" means, that this function expects 1 argument.

"xwin" is an extension I once wrote, similar to the Gtk extension.
Now where is the code for this function?
in main.c you find:
#include "xwin.c"

So that file has my function.
Lets look at it:

Code:

void wBuiltin_xwin_system()
{


   wVariant *variant;

   variant = (wVariant *)wMalloc( sizeof( wVariant ) );

   variant = wStackPopString();
     char bufline[10240];

        char mystring[1000];
        wVariant *mylist;
        wVariant *myvariant;
        wVariant *mykey;
        int c=0;

   myvariant = (wVariant *)wMalloc( sizeof( wVariant ) );
   mylist = (wVariant *)wMalloc( sizeof( wVariant ) );

        wTableNew(mylist);
   mykey = (wVariant *)wMalloc( sizeof( wVariant ) );


        FILE *fp;
        int status;

        fp = popen(wStringChar( variant ), "r");
        if (fp == NULL){
          return;
        }

        while (!feof(fp)){
 
           fgets(bufline,10240,fp);
           //-- create a key
           sprintf( mystring,"%d" ,  c );
           wVariantFromChar( mykey, mystring ,3,3 );
           //-- create a string
           wVariantFromChar( myvariant, bufline ,4,4 );

           //-- append it to the list
           wTableInsert(mylist , mykey, myvariant ); 

           c++;

        }
        status = pclose(fp);
        if (c>0){
          wTableRemove(mylist , mykey );
        }
    //-- return the wList to wxBasic
    wVariantMove( wStackPushNothing(), mylist );
           sprintf( mystring,"%d" ,  status/256 );
           wVariantFromChar( mykey, mystring ,3,3 );
    wVariantMove( wStackPushNothing(), mykey );

    //-- cleanup   
    wVariantDeref( myvariant );
    wFree(myvariant);
    wVariantDeref( mylist );
    wFree(mylist);
    wVariantDeref( mykey );
    wFree(mykey);

    return;
}


Confused?
I'll explain it.
wxBasic internally uses variant as datatype. Variant allows to use variables without declaration, so they can be int, char or others.
In C you had to declare
char mystring[1024];
int mynumber;

In Basic you just do:
myvariable = "test"
or
myvariable = 1 + 4

When a Basic-function passes an argument to C, it is a variant lying on a stack.
So you do not pass it as it usually is done in C, like
Code:
void myfunction ( char *argument){


Instead you pass nothing directly to the function, but get the argument later.
So we must get it from there with this inbuilt function of the interpreter:
variant = wStackPopString();

As C does not know variant, we then must convert it to a standard C type.
wStringChar( variant )

It is used in a typical C function, that in this case runs the command(program) passed as argument using popen(), and then returns the result.
This result can have several lines (for example if you run "ls").
So the resulting lines then are converted to a wxBasic table/list and returned to wxBasic.

xwin.c is rather old, it were my first serious attempts to program C.
In gins.c , I meanwhile have added some more functions that simplify the use of variants, like

Code:
//-- gets an argument from the wxBasic stack and returns it as string --

gchar *getstringarg(){


and
Code:
//-- return a string to wxBasic

void returnstring(char *thestring){


If you added own functions, run
make&&make install
to compile your own Basic-interpreter Smile

Mark

Last edited by MU on Tue 26 Jun 2007, 14:43; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MU


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

PostPosted: Tue 26 Jun 2007, 14:35    Post subject:  

Buttons must be pressed a bit longer.
This is a contribution to JWM, that "eats" GDK_BUTTON_PRESS.
So I had to modify GDK_BUTTON_RELEASE to act somewhat similar.

Without this modifikation, Gtkbasic would be unusable in JWM Sad

Mark
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 4 of 6 [78 Posts]   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:  

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.0807s ][ Queries: 13 (0.0047s) ][ GZIP on ]