Mono.Mozilla on Windows

on Wednesday, September 26, 2007
Alexandre Gomes posted on his blog his experiences getting Winforms+Mono.Mozilla building and running on Windows.

First of all, I'd like to thank him for taking the time to try this out; I'm building regularly on Windows and I try to keep things simple, but things do always slip past unnoticed (especially when trying to keep linux, win+vs2k3 and win+vs2k5 in synch), so it's great to have an external pair of eyes looking at your stuff :)

He had some problems getting things up and running, so I thought I'd leave some pointers to help out those who want to test this out on Windows. Do check out his post so it's easier to follow along.


You don't need the whole mozilla shell to setup the headers, the only thing you need is
  • the xulrunner sdk
  • xpidl.exe (from the xulrunner sdk)
  • libIDL-0.6.dll and glib-1.2.dll (from the wintools zip)
There's now a make.cmd on the "build" directory that does the same as the Makefile, so the steps are:
  • unzip the xulrunner sdk somewhere
  • put xpidl.exe and the two dlls in the build directory
  • open a command prompt, go to the build directory, and run "make [path-to-xulrunnersdk]".
In the include and linker configurations, you only need to point to your newly created build\include and build\lib, respectively. These contain everything that is in the sdk plus the extra header files.

The missing nsAppDirectoryDefs header has been added, so you don't need to google for it anymore. Ooopsie :)


To run an application, you always need to have in the same directory:
  • the contents of the xulrunner runtime package
  • your app's exe :)
  • the mono.mozilla dll
  • the xulbrowser.dll
If you want to have the runtime in a different directory, you'll need to first register it: in a command prompt, go to the xulrunner runtime directory, and run "xulrunner.exe --register-global".

Then, on the build directory, run "setup-runtime.cmd [path-to-your-application-exe], which will create some directories that are required to be where your app is.

Other problems
The browser problems mentioned (unable to input text) have been fixed, so the latest version should be fine.

The Mono.Mozilla project is also fixed.

As for the TortoiseSVN problems, I use tortoise for all my work and it's always worked great :p
Of course, I've never used the _svn variant, it's too much trouble and incompatibility just to have svn with webapps on vstudio. I suggest using the regular version for fun and happiness :)

Thanks again to Alexandre, and do nag me if anything goes wrong.

Something I drew...

on Friday, September 21, 2007
Today I happened to be looking for a pic on my hd, and I came across the following picture.

First off, translation:

Top: "Citizen calling the tax service helpdesk so as not to waste the time of actually going there."
Bottom: "The good thing is you get to hear a nice lullaby while you wait."

I drew this in Photoshop, carelessly doodling, while waiting for the helpdesk callcenter to pick up my call. I think it's safe to say they weren't exactly fast.

And yes, I know, my drawing skills are, hrm, sketchy. But, I don't know, I just love this one.

Interesting conversations

on Thursday, September 06, 2007

Being a very, errr, head-in-the-clouds sort of person, I had to go in a rush to renew my ID card. It expired yesterday, and I completely forgot to renew it before today, multiple warnings from friends, family and the occasional stranger notwithstanding. It's especially bad due to the fact that I sorta need it for an official thingamajig tomorrow, so it was kinda important to have it up to date... or at least not expired :p

Immersing myself in that weird place called a citizen's shop, where all the official stuff is gathered so it's easy to do everything in one place (you know, taxes, utilities, id renewals...), I went around looking for the proper booth or desk or whatever it's called so I could take my numbered ticket, and found it, easy enough. Actually, found two. First, there's the booth where you buy the forms. Gotta take a ticket for that and wait in line. Then there's the booth where you deliver the forms. Gotta take another ticket for that and wait in line. Yes, typical. Got both tickets before going to wait by the first booth, because, as I had guessed, the line to deliver the forms was at number 403 when I got there, and my ticket had the number 490. Typical. Cue long wait, punctuated by a trip to the photo store to take pics for the card... I had figured I would have time enough to do that, so I didn't bother doing it before going there :)

My number is up, get to the counter to deliver the forms, sign the id card.

woman: "oh oh"
me: "oh oh?
woman: "you'll have to sign the form again, the signature doesn't match the one you put in the id card"
me: *looks at both and finds no differences.*
me: "where are they different?"
woman: "can't you see? they're different!"
me: "I can't see it. Ok, maybe this one is slightly rounder, is that it?"
woman: "no, don't you see? look at it"
me: "..."
woman: "the G!"
me: "..."
me: *signs again*
woman: "they're still different! this is the id card we're talking about!"
me: "ok..."
woman: "you're missing a dot there on the i"
me: *puts the dot in*

Going smoothly so far. I get my finger all blackened up for the fingerprint, she takes my old card, I get the receipt of delivery with my data and when I can pick it up, and then...

me: "so... will this receipt serve as a standin for my id card?"
woman: "no"
me: "so... what do I use if I need to identify myself?"
woman: "your driver's license will do"
me: "so... what if I don't have a driver's license?"
woman: *blank stare and pushes the buzzer to call up the next number*

These things are always so much fun.

Note: it's not that uncommon here for people not to have a driver's license, but you must carry your id card at all times. The id card expires every 5,7 years, while the driver's license lasts about 50 years without needing a renewal, so if you're 50 you can be carrying a license with a picture of you when you were 18... not a particularly trustworthy piece of identification if you ask me. :)

Desafio Literário

on Wednesday, September 05, 2007

Pois é, andava eu a espreitar os vários blogs do, quando dou de caras com um Meme Literário no blog do Luís Nabais, Stat(ing) My Mind.

"Que interessante", pensei eu, enquanto mastigava uma noz (a propósito, spoiler warning, a resposta é Dune, é a cena quando o Duque acaba de ser apanhado e está a perder a consciência, e prepara-se para envenenar o médico, convencido que este é o Barão, até já estou a ver a cena toda na cabeça... :) )

Mastigando mais um bocadinho de noz, lá cliquei no blog da pec, que me levou ao blog da Maria Antunes, que me apontou para o blog da clau, que citou o blog da nika_liu (mázinha mázinha, que não meteu o link, tssk tssk), que mencionou o blog da Miss K (bolas bolas também sem link), sendo que, a esta altura, já a noz era uma memória e tive que parar para caçar mais umas tantas.

"Deveras interessante", pensei eu outra vez, com novo fornecimento de nozes. Não quis perder mais tempo, e resolvi entrar também na brincadeira, pelo que estiquei o braço e... tive que me levantar porque não tinha nenhum livro à mão. :p

*saca um livro da prateleira e abre-o na página 161*

"...", pensei eu. A página inteira tem exactamente três pontos finais. Complicated. Bem, não é propriamente a quinta frase completa, mas what the heck :p

"Antes do espectáculo desta noite, quero pedir á nossa convidada, capitoa Wong, que pronuncie algumas palavras ou recite algo."

As regras são as seguintes:

1. Pegar no livro mais próximo
2. Abri-lo na página 161
3. Procurar a 5ª frase completa
4. Colocar a frase no blog
5. Não escolher a melhor frase nem o melhor livro (usar o mais próximo)
6. Passar o desafio a cinco pessoas

O desafio está lançado! Essa de passar o desafio a cinco pessoas é mais complicatida, por isso deixo a quem o apanhar :)

PS: Hei-de colocar o nome do livro num comentário a este post, para não estragar a brincadeira a quem ler isto daqui a uns tempos ^_^

Windows Forms WebControl and Mozilla

on Tuesday, September 04, 2007
It's been a while since I've blogged about the status of Mono's MWF WebControl - I kept adding stuff, then I wanted to settle it down on the tree, and then I went on vacation and ran out of net (but not out of fish.. yum!). So now that I'm fed up with fish and my net is back, let's talk about the latest webcontrol milestone.

The code is split up into three components: the WebBrowser and related classes inside MWF (Mono's winforms implementation); Mono.Mozilla, a new class library on the tree that gets called from MWF; and xulbrowser, a c/c++ library that actually does all the talking to mozilla.

Since a picture is worth a thousand words, the image on the right gives an overview of how these components relate to one another. I didn't want to clutter it too much with arrows, so I didn't put arrows upwards, but of course the communication goes both ways.

Mono.Mozilla is essentially a managed wrapper that exposes an interface to MWF so that the WebBrowser* classes can call methods like Navigate, and register for events coming from mozilla. This interface is the only publicly accessible way to talk to the browser windows, so that things are nice and neat and the wrapper can be free to hide those little pesky details that WebBrowser and friends don't really care about.

Although Mono.Mozilla is, well, Mozilla-oriented, it is neatly divided into two namespaces: Mono.WebBrowser, where the public interface resides, and Mono.Mozilla, where the pinvokes to the unmanaged library reside, so you'll never see the Mono.Mozilla namespace called from inside MWF directly. This has the nice side effect of making it easier (or at least doable) to plug in another browser toolkit in the future if need be.

So what's done and working right now on WebControl? Well, the easiest way to implement an API is to have test applications, so I plucked up the UsingTheWebControl sample from msdn and added it to our roster of winforms test apps. From it's description:
This sample contains three tabs. The first tab demonstrates the use of the WebBrowser control in a simple browser application.

The second tab uses the WebBrowser control as a local HTML document viewer.

The third tab demonstrates the use of the WebBrowser.Document HTMLDocument model, together with the WebBrowser.ObjectForScripting prorperty, to implement Form-to-Browser two-way communication. In this scenario, the WebBrowser control is used to load an HTML document template that is populated with data managed by the Form, as a means of supporting custom printing of application data.

The WebBrowser control on Mono is complete enough for the sample to work with the first two tabs, i.e., loading, refreshing, navigation are all there, as well as focus, activation, mouse and key events so that you can actually browse the web (as opposed to, say, just looking at it... which is a fine thing to do in itself, sure, but probably not that useful in the long run). Https support is already in as well.

This sample is particularly nice in that it hits a lot of not-so-used areas, such as manipulating the Document to load custom data. This, btw, is done on the third tab, which isn't working yet.

The sample is available from the /winforms/webbrowser/UsingWebBrowser directory on svn trunk. To get it working, you will need to use the latest mono on svn.

You will also need to get the /mozembed directory from svn, which contains the xulbrowser library. Just build mono, do the usual, make, make install on /mozembed, make the UsingWebBrowser-port directory, and then go to bin and run the application there.