Foreign language interface (Re: input only event boxes)
- From: Taavi Talvik <taavi uninet ee>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-devel-list gnome org
- Subject: Foreign language interface (Re: input only event boxes)
- Date: Tue, 26 Aug 2003 19:59:08 +0300 (EEST)
On Tue, 26 Aug 2003, Owen Taylor wrote:
..deleted..
> > I am currently trying to comprehend gobject/gtk/gnome and write foreign
> > language interface for it.
> >
> > Main problem is that *many* widgets are designed for C in mind only. And
> > there is no possibility to use just
> >
> > object = create.gobject("blaah")
> > config(object,"property","value")
> >
> > which will make foreign language interface clean and simple. Definitely
> > not optimal way (performace wise, visually), but it is always possible to
> > optimize later.
>
> If you find any widgets that can't be created with g_object_new(),
> please file a bug; the goal is that as many widgets as possible
> can be created with
>
> g_object_new (G_TYPE_FOO, NULL);
>
> and that all widgets can be created with
>
> g_object_new (G_TYPE_FOO, <appropriate properties>, NULL);
>
> It's certainly not intended that you can use GTK+ without using
> methods; you can't represent gtk_widget_destroy() or any other
> action as a property sanely. But creation should be possible using
> properties.
First example from top of my head is GtkTooltips:
It would be really nice, when I can do following
Tip1 = create("GtkTooltip")
config(Tip1, "widget", ParentWidget)
config(Tip1, "tip-text", "Tooltip text comes here")
config(Tip1, "tip-private", "Tooltip private text")
...
Container1 = create("GtkContainer")
config(Container1, "element", Tip1)
config(Container1, "element", Tip2)
...
ToolTipsCollection = create("GtkTooltips")
config(ToolTipsCollection, "container", Container1)
config(ToolTipsCollection, "enabled", true)
...
destroy(ToolTipsCollection)
destroy(Container1)
destroy(Tip1)
which translates quite nicely into GObject framework. GObject framework
has all required information about existence of properties, their type.
Currently GtkTooltips don't declare any properties at all:(
Many really useful actions can be represented as poperty - for example
"visible", true|"visible",false. GObject system even has mechanics
what to do, when property changes.
----
Following is probably allready offtopic (but gives some background
information):
I am trying to create "yet another Gtk binding" for Erlang programming
language. It has quite nice general gui model. For large majority
of GTK widgets I can use same model.
GUI API consists of following:
create(ObjType, Parent, Options)
config(Obj, Options)
read(Obj,Option_Key)
destroy(Obj)
and GUI interactions are send back as asynchronous messages.
Definitely not most efficient, but my aim is not to greate fast and
efficient widgets in foreing language. I *just want to use existing
widgets*. And create/config/read/destroy interface is just enough.
Widget callbacks map quite well into asynchronous events, if I
don't do anything overly complicated (which is usually case when not
creating new widgets). Which is also usually just enough.
existing Erlang UI documentation
http://www.erlang.org/doc/r9c/lib/gs-1.5.2/doc/html/part_frame.html
my experiments on Erlang binding
http://home.uninet.ee/~taavi/files/erlang/xgs/
and just a code snippet using above principles
test3() ->
Ref = start(),
Tree= create_tree(Ref,
[{'GtkWindow', [{type, toplevel}, {title, "test 3"}, visible],
{'GtkNotebook', [visible],
[{'GtkFrame', [{label, "Frame 1"}, visible],
{'GtkHBox', [visible],
[{'GtkLabel', [{label, "Label One"}, visible]},
{'GtkTreeView',treeview, [visible],
[]
}]}},
{'GtkFrame', [{label, "Frame 2"}, visible],
{'GtkVBox', box, [visible],
[{'GtkLabel', [{label, "Label Two"}, visible]},
{'GtkButton', button, [{label, "Button 1"}, visible],[]}]
}
}
]
}
}
]),
signal_connect(button, 'clicked', blaah),
signal_connect(button, 'focus', blaah),
event_loop().
event_loop() ->
receive ->
{ObjId, Seq, button, 'clicked', Options} ->
% do something when button has clicked
{ObjId, Seq, button, 'focus', Options} ->
% do something when object focus changes
end,
event_loop().
best regards,
taavi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]