UI Look & Feel support

goran.krampe at bluefish.se goran.krampe at bluefish.se
Sat Feb 7 14:58:23 UTC 2004


Hi Andre!

"Andre Schnoor" <andre.schnoor at web.de> wrote:
> Hi,
> 
> I'm an old Smalltalker and have been around with st80 since 1988. =
> Currently I'm doing some work with VW, which is absolutely great, but =
> too expensive for an early stage startup project.=20
> 
> I like the openness and portability of Squeak and am evaluating if it =
> could be a platform for serious development and deployment of "shrink =
> wrapped" end user applications on Win32, MacOS 9, OS X and Linux =
> (knowledge based music composition in my case, hell of a complex domain =
> with a high demand on graphical user interaction).=20
> 
> I could not yet find any conventional UI and Look & Feel support for =
> squeak. With "conventional UI" I mean something that an average user can =
> instantly recognize as something he is already familiar with.=20

This issue pops up now and then - people talk, and up until now nothing
has happened. It is of course due to the "need" - noone has yet felt a
strong need.
  
> I experienced that users decide within 30 seconds after opening a new =
> application if they stay with it or go away. So I believe they should =
> better see something familiar ;-)
> 
> Where can I find resources for such kind of UI for Squeak? Do they =
> exist?

Well, no - they don't exist *yet*. I know there was a Gtk/Qt-Squeak
project done a long time back. Somewhere on my disk I probably have a
tar-file with it. IIRC it was a hacked VM so it didn't really catch on.
I also know that Lesser Software in Germany has made some stuff - but it
is not available.

Anyway - as a nice coincidence (talk about timing) - just the other day
I decided to start playing with making a plugin for Gtk2!

The idea is to make Gtk2 fully usable from within Squeak and thus have
the ability to build Gtk2 apps that can run on at least Linux and Win32.

I am taking the Simplest Thing That Could Possibly Work approach. What
it can do currently is that I can use Glade (GTK UI designer tool) and
build myself a UI, save that as a .glade file (XML), paste that XML into
Squeak and call the plugin like this:

GtkTest new loadXML: '<?xml version="1.0" standalone="no"?> <!--*- mode:
xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">Squeak GtkPlugin</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <child>
    <widget class="GtkButton" id="button4">
      <property name="visible">True</property>
      <property name="can_focus">True</property>
      <property name="label" translatable="yes">Tada!</property>
      <property name="use_underline">True</property>
      <property name="relief">GTK_RELIEF_NORMAL</property>
    </widget>
  </child>
</widget>
</glade-interface>'

The above is just a small UI - a single window with a button. But I have
made more complex UIs and they work just fine. What happens when the
above is run? Well, the plugin uses libglade (which in turn uses
libxml2) which parses the XML description and builds a Gtk2 UI from it
and opens it up in a window of its own. The UI is fully active, but
doesn't "do anything".

The next issue is the so called "event loop". Gtk2 needs to paint itself
and handle events. The problem is that either we are executing in the
plugin (and Squeak stands still) or we are in Squeak and the plugin
stands still. The best solution is to spawn a thread in the plugin that
is running Gtk2 - but I need to learn more to do that. :)

But Gtk2 has a "call this function often to drive your own event
loop"-mechanism which can be used instead. So I "solved" it by simply
using a background Process in Squeak to call that function every say
5ms. It works pretty good for now.

So far this is *very* little code. And I am a complete plugin newbie,
and my C-knowledge is quite rusty. So even if the initial progress was
fast I have no idea how long the next cruical step will take:

- Hooking up the events/signals/callbacks so that the UIs can actually
do something.

I have a plan though. :) And lots of related code to look at. Perhaps I
can get this to work in a week or two, not sure.

Ok, so what do we have in a week or two?

- We can build UIs in Glade (Glade runs on Linux and Win32 at least), we
can of course handwrite the Glade XML too.
- We can using the call shown above open up multiple Gtk windows from
inside Squeak that run in their own windows.
- We can handle the events in Squeak.
- Apart from a normal Squeak you will have a very small Gtkplugin and
the Gtk2 runtime. The full Gtk2 2.2.4 runtime for Win32 is a 5Mb
download with a pretty installer. We can of course pick out the pieces
we use in an app and bundle it.
- We still can't manipulate the Gtk UI objects dynamically. That would
need more plugin code.
- I have this running in Win32 but AFAIK it should work fine on Linux
and other unices and I think MacOS/X. MacOS 9 is probably a big no-no,
haven't seen Gtk for that.

Oh, right - I have "proof" here:

http://anakin.bluefish.se/gohu/25

Note that the window is Win32 native, but the widgets inside are painted
by Gtk2. But since it uses a theme called "wimp" it looks pretty much
like XP. Gtk2 is very, very themeable.

regards, Göran



More information about the Squeak-dev mailing list