RooJSolutions http://roojs.com/index.php/View.html en http://roojs.com/Roojscom/templates/images/roojs_square_logo_150.png RSS: RooJSolutions - /index.php 150 150 More on syntax checking vala - and a nice video 2015-05-20 00:00:00 http://roojs.com/index.php/View/286/More_on_syntax_checking_vala__and_a_nice_video.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> <div> As I wrote last week. I had added full syntax checking to the editor. So it runs a full compile check as you type.</div> <div>Here's a nice video of it working...</div> <div> <iframe width="420" height="315" src="https://www.youtube.com/embed/w6W8lrI0nyE" frameborder="0" allowfullscreen=""></iframe> </div> <div> <br> </div> <div> After the initial joy of adding this to code, I soon realized it had a fatal flaw, read on to find out more..</div> <div> <br> </div> Fetching Resources from github in the App Builder and fake web servers 2015-05-09 00:00:00 http://roojs.com/index.php/View/285/Fetching_Resources_from_github_in_the_App_Builder_and_fake_web_servers.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> <div>My final words this week on the builder - handling resources, and fake web servers</div><div><br></div><div>While I talked in the other posts about how the builder extracts the API for various components from the libvala library and the vapi files, some information that the builder requires has to be manually, created or fetched from other locations.</div><div><br></div><div>When the Builder was written in seed, it basically looked at the source code directory, and read files relative to the source code. For the Vala version however, it's not expected to know about the source code directory, so I had to use a different approach.</div><div><br></div> libvala testing code and extracting API from the vapis 2015-05-08 00:00:00 http://roojs.com/index.php/View/284/libvala_testing_code_and_extracting_API_from_the_vapis.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> <div>And the next part in the series. Gir and Vala structures, Nothing like a slow day to write a few blog posts.&nbsp;</div><div><br></div><div>The App Builder was originally designed to build applications using seed (the gobject introspection webkit javascript engines bindings), One of the key elements of how this was done involved introspecting the Gtk API, and extracting all the properties, signals and class structure.</div><div><br></div><div>In this post I will go through the history of how I extracted the API information on Gtk, initially from Gobject introspection and GIR files, upto the current version which uses libvala to get the correct API direct from the vapi files.</div><div><br></div><div><br></div> App Builder - Database based Plugin builders for Web components. 2015-05-07 00:00:00 http://roojs.com/index.php/View/283/App_Builder__Database_based_Plugin_builders_for_Web_components.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> <div><div>It's been a busy month, unfortunately not for our paid work, which has dropped down to a trickle. Taking advantage of this I've been building more into our App Builder. This post hopefully is the first in a series about some of those additions.</div><div>The Primary purposes of our Builder is</div><div><ul><li>A WYSIWYG tool for web applications using both Bootstrap or the RooJS libraries.</li><li>A new visual way of building Gnome/Gtk Applications&nbsp;</li></ul></div><div>In working towards these goals the builder has moved forward in a few directions. the first one that this blog post talks about is generating User interfaces from Database Schemas.</div></div><div><br></div> Gtk3 introspection updates and Unusable Unity.. 2011-04-25 00:00:00 http://roojs.com/index.php/View/236/Gtk3_introspection_updates_and_Unusable_Unity.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> <div><font size="2">Well, as Gnome 3 is out, it has to be tested.&nbsp;Luckily&nbsp;I've not got a huge deployment to sort out, but as I have a few applications that use Gtk, I thought it was about time I upgraded one of my machines to see what chaos I will have to deal with in the future.</font></div><div><font size="2"><br></font></div><div><font size="2">So it was one of my Ubuntu boxes that got the pleasure of a Natty and <a href="https://launchpad.net/~gnome3-team/+archive/gnome3">Gnome3 PPA</a> upgrade. (I use debian on my other development box, which actually got destroyed last week with a complete disk failure, although I suspect the motherboard may have problems... It's getting old like me...)</font></div><div><font size="2"><br></font></div><div><font size="2">Upgrading to Natty is not to bad, from what I remember it only took a small amount of brain surgery to get it to boot correctly after the upgrade. But once up, you get the pleasure of the Unity desktop. My first impressions where not to hot on unity, my wife uses it on her netbook, it's great there, after the initial shock of me upgrading without her knowing, she actually said it was alot better than compiz. Although she missed the special effects.</font></div><div><font size="2"><br></font></div><div><font size="2">But after using Unity on the big screens, it just became unbearable. Detached menus may seem like a cool idea, and are quite handy on a netbook, but they are an absolute nightmare when using things like gimp on dual head full HD monitors, my wrists hurt after a few minutes....&nbsp;</font></div><div><font size="2"><br></font></div><div><font size="2">Along with the removal of the Applications/Places/System menu's which while klunky are still handy for quickly finding applications. A classic example of this Alleyoop Memory Checker, a very nice wrapper around valgrind. In the Unity world if you do not know the name of the application, then finding it is a huge mouse journey around big icons.&nbsp;</font></div><div><font size="2"><br></font></div><div><font size="2">As for the left icon menu, all I can say is that I'm not the worlds best designer (although at least I did study it), but it's so graphically noisy that it unusable. It's basically a bad re-invention of Docky/Cairo Dock, which do far better jobs at providing a similar task role.&nbsp;</font></div><div><font size="2"><br></font></div><div><font size="2">So after all that I did try and get gnome-shell going, but unfortunatly the Gnome3 PPA build is not currrently working, and also has a rather nasty habit removing all usable desktop enviroments. I ended up adding xterm to one of the /etc/Xorg/X.sessiond files and starting up gnome-panel, mutter and docky to produce a usable desktop for the time being, while I wait to test out the latest gnome-shell.</font></div><h3><font size="2">So on with the harder stuff.. - Gtk3 and introspection.</font></h3><div><font size="2">One of the key applications I use to develop is<a href="http://www.roojs.org/blog.php/app.Builder.js.html"> app.Builder.js</a> , it's a drag/drop interface to build web applications, that also allows you to fill in all the code and associate it clearly with the element and event occuring. It's written in Javascript, and uses Gnome seed to run on the desktop. As I've mentioned before Seed is a bridge layer between the Webkit Javascript engine, and Gobject-introspection, the now standard way to interface Gnome/Gtk/Glib etc. projects to non-C languages, eg. Python, Javascript (and others...)</font></div><div><font size="2"><br></font></div><div><font size="2">With the introduction of Gtk3, GObject introspection has also been updated, and the updated mix between the two had quite a few knock on effects to the builder I had written using Gtk2 and pre-0.9 versions of Gobject introspections. Heres a general summary of the changes.</font></div><h3><font size="2">TreeIter and TextIter&nbsp;</font></h3><div><font size="2">The latest version of GObject introspection has a feature called caller allocates, this basically means that previously with Seed we had to create an instance of a TreeIter, the the TreeIter call would be of type 'inout' (eg. the Iter would be sent into the method, and returned out)</font></div><div><font size="2"><br></font></div><div><font size="2">eg. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</font></div><pre><font size="2">var iter = new Gtk.TreeIter();<br></font><font size="2">model.get_iter_from_string(iter, path);<br></font><font size="2">// iter would now contain the tree iter for that path..</font></pre><div><font size="2"><br></font></div><div><font size="2">In newer versions, the iter is an 'out' value, which means you have to create an object for the iter to be added to. eg.</font></div><pre><font size="2">var iret = {};<br></font><font size="2">model.get_iter_from_string(iret, path);<br></font><font size="2">// iret.iter now contains the tree iter.</font></pre><div><font size="2"><br></font></div><h3><font size="2">TreeSelection&nbsp;</font></h3><div><font size="2">since the get_selected method for a GtkTreeSelection now has 2 out values, the call has change from</font></div><div><font size="2"><br></font></div><div><font size="2">OLD:</font></div><pre><font size="2">var iter = new Gtk.TreeIter();<br></font><font size="2">selection.get_selected(model, iter);</font></pre><div><font size="2"><br></font></div><div><font size="2">NEW</font></div><pre><font size="2">var sret = {};<br></font><font size="2">selection.get_selected(sret);<br></font><font size="2">// sret now contains { model: **THE MODEL**, iter: **THE ITER** }</font></pre><div><font size="2"><br></font></div><h3><font size="2">TreeModel get_value</font></h3><div><font size="2"><br></font></div><div><font size="2">Since get_value does not have a return value, seed with return the 'out' values as the return object.</font></div><div><font size="2"><br></font></div><div><font size="2">OLD:</font></div><pre><font size="2">var value = new GObject.Value('');<br></font><font size="2">model.get_value(iter, 2, value);<br></font><font size="2">print(value.value);</font></pre><div><font size="2"><br></font></div><div><font size="2">NEW</font></div><pre><font size="2">var str = model.get_value(iter, 2).value.get_string();<br></font><font size="2">print(str);</font></pre><div><font size="2"><br></font></div><h3><font size="2">Drag pixmap becomes surfaces</font></h3><div><span style="font-size: small; ">This is a pure Gtk3 API change (BC break)</span></div><div><font size="2"><br></font></div><div><font size="2">OLD:</font></div><pre><font size="2">var pix = widget.create_row_drag_icon ( path);<br></font><font size="2">Gtk.drag_set_icon_pixmap (ctx, pix.get_colormap(), &nbsp; pix, &nbsp;null, ..... )</font></pre><div><font size="2"><br></font></div><div><font size="2">NEW:</font></div><pre><font size="2">var pix = widget.create_row_drag_icon ( path);<br></font><font size="2">Gtk.drag_set_icon_surface(ctx, pix);</font></pre><h3><font size="2">Drag drop data passing..</font></h3><div><font size="2"><br></font></div><div><font size="2">The drag drop signals appear to work ok, however I've not managed to get the data to go back and forth,&nbsp;</font></div><div><font size="2">a quick workaround is to just use some form of global variable to store the current dragged item (I doubt you will get more than one dragged item at once..)</font></div><div><font size="2"><br></font></div><h3><font size="2">Drag drop API</font></h3><div><span style="font-size: small; ">alot of these appear to have played musical chairs.</span></div><pre><font size="2">GtkWidget.prototype.drag_source_set -&gt; Gtk.drag_source_set</font><font size="2"><br></font><font size="2">Gtk.drag_source_set_target_list -&gt; GtkWidget.prototype.drag_source_set_target_list<br></font><font size="2">Gtk.drag_dest_set -&gt; GtkWidget.prototype.drag_dest_set</font></pre><div><font size="2"><br></font></div><h3><font size="2">Internal Seed changes</font></h3><div><font size="2"><br></font></div><div><font size="2">I've added a few more fixes to Seed in the last few weeks, mostly to handle compiling correctly and detecting the correct version of introspection. for the most part it's working fine, however I'm still a bit baffled by a Glib memory corruption bug, which occured after multiple model.set_value and model.get_value calls. After running valgrind, I managed to stop the corruption occuring by increasing the allocated size for a struct by 1 byte&nbsp;</font></div><div><font size="2">Around line 546 and 640 of seed-engine.c the change goes something like this.</font></div><pre><font size="2">- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;out_args[n_out_args].v_pointer = g_malloc0 (size);<br></font><font size="2">+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;out_args[n_out_args].v_pointer = g_malloc0 (size+ 1);</font></pre><div><font size="2"><br></font></div><div><font size="2">Arround line 738 of seed-structs.c &nbsp;</font></div><pre><font size="2">- &nbsp;object = g_slice_alloc0 (size);<br></font><font size="2">+ &nbsp;object = g_slice_alloc0 (size +1);</font></pre><div><font size="2">&nbsp;</font></div><div><font size="2"><br></font></div><div><font size="2"><br></font></div><div style="font-size: 13px; "><br></div> GtkDjs, daily builds, added libraries and much more.. 2007-08-07 17:42:45 http://roojs.com/index.php/View/152/GtkDjs_daily_builds_added_libraries_and_much_more.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> <h3>Daily builds / downloads available</h3>I've set up a cron job now, so all the bindings and binaries are built daily, you can download them from here.<br /><a href="http://devel.akbkhome.com/gtkjs/gtkjs_snapshot.tar.bz2">http://devel.akbkhome.com/gtkjs/gtkjs_snapshot.tar.bz2</a><br />This includes gtkjs, mjs and jsfastcgi, In theory it would not take too much to build this on Windows... - Send me the fixes if you attempt it...<br /><br />Just download, unzip and try out <br /><pre>./gtkjs test/filetree.ds</pre>etc.<br /><br />the <a href="http://www.akbkhome.com/gtkDjs/">gtkdjs Documentation</a> is updated daily to match<br /><br />And I still need a better name for the project;)<br /><br /><br /><h3>Closure and scoping fixes. </h3>After seeing a post on the <a href="news://news.digitalmars.com/DMDScript">DMDScript newsgroup</a> concerning closures and scoping issues, I spent quite a while looking at the issue. <br /><br />The basic problem, was that the original DMDscript code was designed to create a cache of function definitions, and re-use them whenever they where refered to. Along with this, they had no concept of creationScope. so variables in the creating scope where not available. Fixing this involved quite a few changes to the compiler and runtime. Basically creating new Function instances when they are found, rather than only once at compile time. Along with storing the scope inside the Function instance. so when they are called they understand the correct scope. Anyway standard Javascript scoping, and closures all work as expected.<br /><br /><br /><h3>Undefined Warnings improved</h3>I mentioned in my last post that I added Warnings when undefined variables where accessed, I've modified this slightly as undefined is a valid type in Javascript, so unassigned arguments to a function call are flagged as undefined, but accessing them should not issue a warning. So only when the scope.Get(variablename) calls return null, rather than a Value.vtype[V_UNDEFINED] flag this warning now.<br /><h3>LibSoup extension </h3>LibSoup provides HTTP support, at present, basic sync requests work, the code is there for async calls, but I've not tested it yet. test code is in tests/Soup/.<br /><br />This little bit of code get's my web site, and shows headers, then extracts all thehref from all the &lt;a&gt; tags.<br /><pre>var sess = new Soup.SessionSync();<br /><br />var msg = new Soup.Message(&quot;GET&quot;, &quot;http://www.akbkhome.com/&quot;);<br />status = sess.sendMessage(msg);<br /><br />println(&quot;Status is &quot; + status);<br />println(&quot;ResponseHeaders is &quot; + msg.responseHeaders.toSource());<br /><br /><br />var imp = new Dom.Implementation;<br />var doc = imp.createHtmlDocFromMemory(msg.response);<br />var a_s = doc.getElementsByTagName(&quot;a&quot;);<br />for(var i =0; i &lt; a_s.length; i++) {<br /> println(&quot;got href: &quot; + a_s.item(i).getAttribute(&quot;href&quot;));<br />}<br /></pre><h3>XML2 limited support</h3>To enable parsing of html documents for Gdome, I've added limited support for XML2, it's mostly used by the Gdome method: <span style="font-weight: bold;">Dom.Implementation.prototype.createHtmlDocFromMemory( String htmltext )</span><br />The Generator code is currently tied into the libxml header files on my system.. this needs fixing so it uses the gtkwrap download script. (but the code is a nice example of how to automatically create bindings based on .h files..)<br /><br /><br /><h3>Gtk.SourceView support</h3>In preperation for testing text editing (and eventually self-editing / morphing of applications), I've bound the GtkSourceView widget. Unlike the standard Leds editor which uses scintilla, I thought I'd try and see if using GtkSourceView would prove more robust. - The bindings had already been done for GtkD, so there was not much to change to the APILookupSourceView.txt code. I only used the full name &quot;sourceview&quot; rather than &quot;gsv&quot;<br /><br /><h3>Handling of missing functions and Libraries improved</h3>When I was testing GtkToolbar on one of my machines which had an old Gtk library, I discovered a segfault when it called a newer function that did not exist in the old library. To fix this, the Loader.d file now binds a simple function that throws and exception to any method it can not bind. So you can catch in javascript any call to unsupported methods in a library.<br /><br /><br /><h3>Phobos Path module added</h3>all the methods from <a href="http://www.digitalmars.com/d/phobos/std_path.html">std.path</a> are now exported to javascript, and in the manual. This enables a few usefull functions like<br /><br /><pre>var file = &quot;/etc/passwd&quot;<br />println(&quot;Directory = &quot; + Path.getDirName(file));<br />println(&quot;Filename = &quot; + Path.getBaseName(file));<br />println(&quot;combined filename = &quot; + Path.join(&quot;etc&quot;,&quot;passwd&quot;));<br /></pre><br /><h3>Regex Fixes</h3>In testing extjs parsing, I came across two bugs in D's regex implementation, that prevented it's loading.<br /><ul><li>forgetful parsing (?:abc|cde|xyz) - the fix for this was trivial and is in D's bugtracker, and there is a modified regex file in the dmdscript distribution.</li><li>the use of special chars in character range matching after the '-'. eg. [\w-\*] and [\w-\.] which should be interpreted as [\w\*-] and [\w\.-]. These currently parse correctly however I've not got round to fixing the implementation properly so they are pretty broken at present. (basically matching everything from \w onwards...) - the bugs in D's bugtraker, but the fix is not... I may get back to this...</li></ul><h3>Simplified exporting of Structures</h3>One of the missing pieces for the Gtk Bindings, that I came accross with jLeds, was the event structures had not been bound. Since they are very simple structs, and you only need to get access to their properties, I developed a new action for the wrap file &quot;structDump&quot; which autogenerates the class file, forces the full Struct definition to be written and writes getter methods for all the exportable properties.<br /><br /><h3>Bindings builder flexibility</h3>Since we now have about 20 libraries bound, the Wrapping builder script can take a little while on slow systems to build all the bindings code. So I've added the ability to specify which APILookup files to action.<br />eg. to build LibSoup you can do.<br /><pre>sh buildit.sh APILookupGLib.txt APILookupGObject.txt APILookupSoup.txt </pre>It cant do the dependancy resolution yet, so you have to list all the pre-requisite packages so it has access to all the required types when building the library you need.<br /><br />The struct parser is also a little more robust now, handling comments and lists of elements eg.<br />ushort x, y;<br /><br /><br /><br /><h3>Minor Gtk Fixes</h3><ul><li><span style="font-weight: bold;">G.Object.setProperty(String key, Any value)</span> now works, and converts value into G.Values automatically.</li><li><span style="font-weight: bold;">GtkTreePath[] Gtk.TreeSelection.prototype.getSelectedRows(Gtk.TreeModel model) </span>now works - although I need to look at generic ways to generate array of Objects from GList..</li><li><span style="font-weight: bold;">new Gtk.TreeStore(Array coltypes) </span>now works (where coltypes is either an array of strings, or G.Types.) - this works along with the other constructor methods - eg. varargs......</li><li><span style="font-weight: bold;">Gtk.TreeStore.prototype.set(Gtk.TreeIter row, Array values)</span> now works to quickly set the values of a tree row, rather than calling <span style="font-weight: bold;">set(GtkTreeIter row, Number col, Mixed value)</span></li><li><span style="font-weight: bold;">Gtk.Container.prototype.remove(Number item)</span> and <span style="font-weight: bold;">Gtk.Container.prototype.remove(Gtk.Widget widget)</span> are now working - I need to change this slightly, so you can remove all by sending '0' as the item, and waiting until it returns false...</li><li>Most ofthe GtkEvent Structures are now exported, and all the properties are available as getters.</li><li><span style="font-weight: bold;">new GdkColor(Number color) </span>is based on 0xRRGGBB hexidecimal values, rather than longintegers.. (you can use the long version to do more precise colours: <span style="font-weight: bold;">new GdkColor(Number red, Number green , Number blue);</span></li><li><span style="font-weight: bold;">new Gdk.Pixbuf(Array xpmdata)</span> is now supported so converting xpm data for use as icons is very simple (just replace &quot;const char**&quot; with &quot;var&quot;)</li></ul><br /><br /><h3>ExtJs loading</h3>One of the goals is to make the engine compatible with existing code out there, a nice test of this was extjs, which it can now load correctly (with a few lines of javascript prefixing the loading).I've not actually tested any of the functionality yet, as XmlHttpRequest needs building from the libsoup bindings.<br /><br /><h3>jLeds port underway..</h3>What's a language without an editor (or an email client - if you know the old joke about every application eventually evolves until it can read email.).. So partly to test the bindings I've started looking at porting Leds to gtkjs - the code is in tests/jLeds, and gives a good example of some of the new Javascript2 features, along with the gtk bindings.<br /><br /><br />Try the newsgroup if you need support.<br /><a href="news://news.digitalmars.com/DMDScript">news://news.digitalmars.com/DMDScript</a><br /><br /> gtkds - more updates and better debugging.. 2007-07-31 23:08:00 http://roojs.com/index.php/View/151/gtkds__more_updates_and_better_debugging.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> Add one feature, and create a few bugs.. seems like it's always the way..<br /><br />The two features added over the weekend where class syntax support and include support. My initial effort proved to be a little off the mark. <br /><br />Read on if you want to know the nitty gritty details about writing an interperted language runtime... Along with a list of the Gtk binding improvements..<span style="font-weight: bold;"><br /></span><p /><br /> Compairing Adobe AIR to dmdscript / fastcgijs / gtkjs 2007-07-28 22:36:00 http://roojs.com/index.php/View/150/Compairing_Adobe_AIR_to_dmdscript__fastcgijs__gtkjs.html <a href="http://roojs.com/index.php/View.html">Article originally from rooJSolutions blog</a><br/> A good friend of mine asked what's the difference between the dmdscript/fastcgijs/gtkjs stuff I'm doing and Adobe AIR.<br /><br />I've not really looked at Adobe AIR much, noticed that it was mentioned on the extjs site, so I thought I'd do a quick &quot;what's the difference&quot;..<br /><br />So what's the key differences<br /><br />For Adobe AIR<br /><ul><li>Backed by a huge company with unknown reasons for hooking you in.</li><li>Lot's of support for Adobe technology, but any other libraries, you can forget about.</li><li>Probably written in C++ or C, so there are probably a few nice security holes difficult to find in the memory allocation. Even if you did have access to the source - it would be a pretty complex task to write bindings for libraries.<br /></li><li>Great support for Windows, pretty good for Mac, and bugger all for other un*x's</li></ul>For GtkJs / Fastcgijs / dmdscript<br /><ul><li>Absolutly no support ;) - obviously only done, because it's interesting and fun!<br /></li><li>Lots of support for any open source library, as long as you are willing to waste a few days working out how mindblowingly simple it is to write bindings.</li><li>Written in D, which makes it pretty secure (well if you fix some of the bugs in my generator to do a small amount of sanity checks). And due to the fact that it's so similar in syntax to Javascript that makes the whole process of moving slow parts into compiled code considerable simpler than any other scripted language..</li><li>Great support for linux, and it might just work on any other platform, as long as you can find someone who knows those platforms.<br /></li></ul> Personally I think the Adobe AIR idea is pretty good, Javascript is a good basis for a language. But to be honest for the reasons above, I would not touch it with a barge pole..<br />