 been asked to talk about user interfaces in Guile, how to build them and what you can use them for. So that's what I'm going to do. Can everybody hear me? We can't see all the slides. Well, does anyone know how to change so we can? Just change the resolution to 1024. How do you do that in Geeks? What have you done? It's GaborQ. OK. Terminal. We don't have it. OK, I don't know. These are just normal problems that you get when you're doing presentations. What works on your machine never works on an overhead projector. I suggest we go with it, actually. F11? What does F11 do? I think it's full screen. The windows full screen? Well, you can have half the screen like that. Is that better? Yeah. There you go. Yeah, OK. We'll run with it. So, what is a user interface? A user interface is the means by which the user and the computer interact. Typical examples are a shell, which all GNU slash Linux systems have, at least all that I'm aware of. The REPL, which is common for Guile users. And, of course, graphical user interfaces. What does a user expect from their interface? Normally, they want a means to give commands to the system. They've got to be able to tell the computer how to do something and when to do it. They want a means to determine the current state of the system. For example, in a shell, you type ls to see what files there are in the current directory. And a means to get hints about what commands might be appropriate for the current status. So, for example, in a shell, you have modern shells anyway. You've got tab completion, so you can hit the tab key and it will give you a list of possible ways to complete that command. When you're talking about graphical user interfaces, the users expect something somewhat more. A graphical user interface user, he normally wants instantaneous, not when I say instantaneous, what I mean is automatic updates without any perceptible delay. And that should happen without the user actually having to do anything. Whereas a shell user is quite happy to have to type ls again to see what files may have in the last five seconds appeared or deleted. Guru users don't like that. They want to see things when something changes, they want to see it automatically appear on their screen. They want automatic notifications of successes. In the shell, we don't normally like that. If something works after giving in a shell command, we expect it to silently return zero and get on with the next thing. We don't like it saying stupid things. Guru users, however, prefer normally the ones I've seen, they prefer to see some kind of confirmation that that command worked. They want explicit and verbose notifications of failures. If something doesn't work, they want a very verbose pop-up or something to say that didn't work. Context-sensitive prompts, so they like to see that something... Well, if a command is not appropriate to be entered at that time, then that command should not be there. The button should be grayed out or not even there at all. That's something that you have to think about if you're writing a graphical interface is to only present what is appropriate for the current state. Confidence indicators, if there is a command that is going to take a long time, then they want some kind of indication that the machine is doing something and hasn't just sort of hung. So the exercise which I was charged with undertaking was to write a graphical installer for Geeks SD. We want an alternative to the shell or the REPL because currently on Geeks SD1 the described way in the manual is a number of shell commands to partition your disk, set up file systems, et cetera, et cetera, et cetera. Although many people are quite happy doing that, we think it would lower the barriers to entry if people who find those ways not so easy had an alternative means of doing it. That's what we want. We want to give Geeks SD a graphical installer so that you can install it from a bare machine. But we don't want to force that on people. We want to still give the traditional old timers a way of installing manually and I believe we should actually allow for a compromise if people like doing part of the job themselves they can do but for the other bits which are either too hard or too much of a hassle they can give that off to the program to do for them. So the acceptance criteria were that the installer should be written in Gael because everything else in Geeks is in Gael and Ludo wasn't going to make an exception for me. It should allow a complete installation from nothing, a machine with an empty disk, without having to use a shell or a REPL. But as I said, to allow experienced guys to use it if they want to. Right, it should be available in their own language and keymap. It's just nothing more annoying when you're installing machines and the key layout that you've got in front of you doesn't conform to the keymap that the machine is using. So if you're using a French keyboard, you hit the A key and a Q pops up that annoys the French people. And the same with the Germans, with the Q and the Z being swapped over. So we want to be able to provide a way to get their own language and their own keymap. It should work on an 80x25 terminal because some machines don't have anything bigger especially some of these little boxes that you see these days. And we want it to be intuitive as possible so that you don't really need anyone to tell you how to use it. More or less straightforward. So how does it work when you're setting up geeks? Well, the task you've got to do, you've got to partition the disk. You must have at least one partition. You've got to say where those partitions or where the file systems on those partitions should be mounted. You've got to tell them what kind of file system that you want. What parameters. Time zone is something that needs to be chosen for the system. The locale, the default locale, obviously each user can set their own one, but the system locale needs to be chosen. Packages, there might be some standard packages. Well, there will be some standard packages that should be available for the entire system as Ricardo said. Usually they're installed. Most packages are installed in the user profile so they don't affect all users. Services, which I think somebody else is talking about services later on so I won't go into too much detail about those, but they need to be chosen. You've got to generate the config. Normally you need a network because geeks is installed over the network. Then you've got to set the whole thing in motion. Those are the things you've got to do. A couple of constraints for this exercise. We cannot rely on any particular video drivers being available because all systems these days have different video systems. We cannot say this install is only going to work if you've got an SGI or an ATI or God knows what. You've got to use the lowest common denominator so that it'll be there when you've got pretty well a bare kernel. Of course we want to keep the installation images small as possible because it has to fit on a USB device. Although they're quite large these days they're not infinite. How does it look so far? That's really a shame that we can't get the entire... Why is it that these overhead projector systems never work? I don't know. How about that? That's more or less what it looks like. There's a menu on the main screen. I can demonstrate this to people who are interested afterwards but actually demonstrating it in real life now won't be... I don't think there'll be the time for that. There's a menu which you can do the steps individually. If a user doesn't want to do the steps individually they can choose the bottom one and it'll do everything and all its dependencies at once. That's the easy way for inexperienced people. But as I said we've got these commands here. That's keyboard for F10 so change the keyboard map. F9 to change the language. So if you want it in German or French or whatever you can or at least you will be when translators have done their job. And if you want a shell you can hit F1 and you will get out to a shell and when you hit exit, when you type exit in that shell you'll come back to where you left off. And those three hotkeys will be available throughout the whole process so you can do that at any time. And because we can't use a video driver we decided to use curses. You're probably familiar with curses. It's a GNU package and it provides an abstraction around the terminal capabilities. Each terminal in the world has a different way of being controlled and curses abstracts that out. So there is a common way to for example draw a box on the screen or move the cursor to position XY on the screen etc etc. It also has a couple of higher level libraries which I might talk about a little bit better but the main curses library is a CAPI. However, as I said earlier, this has got to be written in Gail. So fortunately there is a package called Gail in curses. I think that is Mike Graham here. There he is right at the back. He's the maintainer of Gail in curses. And that is what we've used. And just very briefly going into how those menus work in curses or Gail in curses. It has the means to display a menu like this. The user can move up and down and select items in the menu. If you were writing it in C that would be the interface. Well, you have to create an array of items. Populate that array with a name and description. Create the menu, do whatever you want with the menu and when you've finished it's your responsibility to free that menu and the lines that you can't see down here because of this system you've then got to free the items if you don't want it to leak memory. How do you do that in Gail in curses? Similar way, well how would you do it? Similar way, create a list of names, list of descriptions. Then in this case I've used a map and a lambda expression to create a list of items, each of which is a pair and then create your menu here. So in theory you can do that with Gail in curses and there was a similar thing for forms if you want to create a form entry system which I have done. My experience with them wasn't that successful unfortunately. I found that first of all the way in which the forms and menus in incurses are structured does not really lend themselves to scheme. I found that they were somewhat inflexible. The early versions were actually tended to crash every now and then especially when the garbage collector ran at inappropriate moments and I sent Mike there a few patches and it's got a lot better in recent releases. But I'm still not confident that all the bugs have been ironed out. There are, I have noticed occasions where it works most of the time but then when the garbage collector runs when you don't expect it then suddenly it crashes. And even if that system, those problems have been fixed as I say I don't really think that the interface lends itself to scheme programming. Oh and I'm not absolutely convinced that all the memory leaks have been ironed out. Perhaps we can talk afterwards Mike but yeah I don't mean to pour cold water on your efforts. But anyway either rightly or wrongly I decided not to use the forms and menus libraries of guile incurses. I wrote my own which did an equivalent thing. Small set of modules which did more or less the same written entirely in scheme but using the base curses. So I'm still using guile incurses. I'm just not using their forms and menus implementation. Okay thank you. Well that's an example of how it does it. As we're running out of time I'll skip that but I think that way is a lot easier than the previous way that I showed you. Human factors we have to consider in user interfaces. This was an early screenshot of something I sent out for testing. This form actually got a lot of negative feedback from the people I asked to test and I think the reason is obvious. There are too many controls on this screen. Some of them are not even appropriate. People didn't know what these buttons were going to do which is understandable. It doesn't say. In fact when you check actually runs FSCK, write will run MKFS to create the file system and no, recreate does that. Write would run, yeah, exactly. If you don't know what it's going to do then it's probably a poor design. So that's one lesson that we learned. Don't write your user interfaces too complicated and that's been in the new version. That's been changed quite considerably. Tech info. Yeah, we need to have a system to turn tech info into something that curses can display. Those of you who are familiar with Gile know that there is this existing function called techy fragment to S techy which converts things like, again we can't see this whole thing. The days of our lives with a bold in tech info into something more scheme friendly which is a start of a paragraph, the days of and in bold is hour and we're no longer bold here. That's existing in tech info, in Gile. I had to write a new procedure to actually turn this thing into something that curses will play nicely with and I can show you that later if you're interested. So the status so far, what's been done? Well, we've got a reasonably complete curses based installer. It has been sent out for first testing. Users have reported that it does work. They have been able to do a complete installation of Geeks SD without having to resort to a shell and I believe those people have used different hardware and different network systems etc etc. So it basically all works. Problems? Well as I said earlier, the problems that I find is that we are lacking on Gile bindings. Another problem I found is that we there is no current way that I've found to get the kernel to tell us when something has changed. I have to poll it and that is not a nice way of doing things. This is a brief procedure I wrote to get around the first problem, the lack of bindings. What I basically have to do is screen scrape commands. So run a command in a pipe and collect the output that comes on to standard out and then post process it. Also not nice but it does work. Here's how I do my polling for changes. I just use SIG alarm to poll every second. Again not nice but it works but what can one do without the infrastructure? What we don't have yet in the system is mouse support that I'm trying to work out. I'm actually finding that unfortunately where as it can work on a next term you don't have a next term when you boot up your machine. You've got a frame buffer terminal and I'm not sure if that can work with that. LVM, full disk encryption that's not supported as yet and neither is adding users. A lot of people said they want an option to add users. I normally consider that a post installation task but some people like to do it at the time of installation apparently. Here's some ideas that some people came up with and I'm still trying to work out whether they're good ideas or not. Tool tips so that if you hover the mouse over a button that you might get some text saying what it's going to do or you select that button without actually activating it. Switch to question time. Questions? And the new speaker should set up. Okay, so perhaps the new system can come. So, yeah. Okay, questions? Yes? If you had so much trouble with writing Gile end curses, why do you consider writing the end curses things in C and then expose the high level interface to Gile? Well, that's basically what Gile end curses does or tries to do. I didn't have that much trouble writing the menus in Gile. When I wrote my own libraries to do that I had a lot more trouble using the Gile end curses interface. That's the tool they don't.