r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Red] Red language group

GrahamC
7-Sep-2011
[3188]
If it's heisenberg, that means it still might work some of the time?
Kaj
7-Sep-2011
[3189]
Yes, when you're not using it :-)
Dockimbel
7-Sep-2011
[3190]
Wave function collapsed, cat saved, bug fixed.
Kaj
7-Sep-2011
[3191x7]
Eh, the cat survived?
Added Hello World examples to the GTK repository
Here's the simplest:
Red/System [ ]

#include %GTK.reds

gtk-begin
gtk-view window label "Hello, Red/System GTK+ world!"
Here is how that is customarily written in other bindings in other 
languages:
Red/System [ ]

#include %GTK.reds

argc-reference: declare integer-reference!
argv-reference: declare handle-reference!
argc-reference/value: system/args-count
argv-reference/value: as-handle system/args-list

_gtk-begin argc-reference argv-reference

_window: gtk-new-window gtk-window-top-level
_label: as gtk-widget! 0

either as-logic _window [
	_label: gtk-new-label "Good riddens!"

	either as-logic _label [
		gtk-append-container  as gtk-container! _window  _label
	][
		print "Failed to create label.^/"
	]


 g-connect-signal  as-handle _window  "destroy"  as-integer :gtk-quit 
  none
	gtk-show-all _window
	gtk-do-events
][
	print "Failed to create window.^/"
]
I call it Goodbye Cruel World
Dockimbel
7-Sep-2011
[3198x2]
Very nice!
Cat: I chosed the optimistic option.
Kaj
7-Sep-2011
[3200]
:-)
Dockimbel
7-Sep-2011
[3201]
I hope you'll make a nice web page for your GTK binding once finished. 
It also deserves some docs for the dialect API.
Kaj
7-Sep-2011
[3202]
I'm not sure. People are not really supposed to use this binding, 
but the abstract cross-toolkit dialect you will make in Red
Dockimbel
7-Sep-2011
[3203]
Could 'gtk-begin be called in %GTK.reds directly?
Kaj
7-Sep-2011
[3204x2]
You mean without the callback wrapper?
Or you want to remove it from the dialect?
Dockimbel
7-Sep-2011
[3206]
I mean, instead of having to call it from every user script, it could 
be called as last expression in %GTK.reds source file directly?
Kaj
7-Sep-2011
[3207x2]
Probably. I'll feel more certain about it later on
Conversely, I'll probably move gtk-do-events out of gtk-view for 
flexibility
Dockimbel
7-Sep-2011
[3209x2]
People are not really supposed to use this binding

 It's a very nice binding that could motivate some C coders from Rebol 
 community (or outside) to take a closer look at Red/System and start 
 hacking with it. It could be a good way to attract new users.
Actually, it's the most sophisticated binding we have so far in Red/System.
Kaj
7-Sep-2011
[3211x2]
Yes, until the Red dialect is there, or when you really want all 
GTK features. But mostly, I need to be able to make GUIs as soon 
as possible myself
The new alias detection breaks the binding
Dockimbel
7-Sep-2011
[3213x2]
You mean it makes it crash?
Need to go to sleep now, will look into that tomorrow morning.
Oldes
8-Sep-2011
[3215x2]
just testing for a while... having:
	MagickGetImageWidth: "MagickGetImageWidth" [
		;{Returns the image width.}
		*wand     [wand!]
		return:  [integer!]
	]

When I do:
	width: MagickGetImageWidth *wand
	print ["image width: " width " " MagickGetImageWidth *wand]
I get:
	image width: 78 0000004E
I was expection:
	image width: 78 78
What do you think?
(but that's a detail... I'm still waiting for the decimal support)
Dockimbel
8-Sep-2011
[3217x3]
Curious bug, I will look into it.
BTW, you can use PRINT-WIDE instead to insert white spaces automatically.
Oldes: I can't reproduce the issue, I tried with the following test 
code:

	#import [
		"msvcrt.dll" cdecl [
			abs: "abs" [
				n 	[integer!]
				return: [integer!]
			]
		]
	]

	width: abs -78
	print ["image width: " width " " abs -78]

I get:
    image width: 78 78
Oldes
8-Sep-2011
[3220x2]
You are right, the main difference is, that I was using stdcall while 
you are using cdecl, which works as expected.
What is reqired to do to add the decimal support? Also i64 would 
be needed to fully suport multimedia libs.
Dockimbel
8-Sep-2011
[3222x4]
A lot of work. :)
It would mainly need a full backend code generator for supporting 
floating numbers. It would also require to add some runtime conversion 
with other numerical types and probably many small additions at all 
stages of compilation.
I guess it would take, at least, a full week of work to support floats 
fully.
I would be glad to work on it, but there are just too many other 
higher priority tasks currently. I won't be able to start working 
on it before October.
Kaj
8-Sep-2011
[3226]
http://www.osnews.com/comments/25143
jocko
9-Sep-2011
[3227]
Tested GTK examples under windows XP, after installation of the GTK2+ 
run time (8 MB, ... the price of portability, sigh ...)
Nice work, Kaj
Kaj
9-Sep-2011
[3228x2]
Cool, I was wondering if it worked on Windows already
I did download the Windows GTK distribution to get the library names 
right, so apparently I did it right :-)
Dockimbel
9-Sep-2011
[3230]
Good work Kaj, I tested the GTK binding examples also on Windows 
7 and it works flawlessly.
Kaj
9-Sep-2011
[3231]
That's odd, because the binding is still broken at the moment :-)
jocko
9-Sep-2011
[3232]
why do you say that the binding is broken ? It was ok this morning.
Kaj
9-Sep-2011
[3233x2]
With the Hello World examples? Slightly more complex examples don't 
currently work due to new Red bugs
Hopefully we're now dealing with the last one
jocko
9-Sep-2011
[3235]
Yes, it is ok on the example codes. On this one, only the first widget 
is displayed
gtk-begin
gtk-view window [
	"Hello World"
	label "Hello, Red/System GTK+ world!"
	button "ok"
]
Kaj
9-Sep-2011
[3236x2]
Right, there are bugs in detecting object/struct/widget types
It prints warnings when you start from a command prompt