[ooc-compiler] Finally: A graphical GUI builder for OOC!
Brought to you by:
mva
|
From: Frank H. <hr...@te...> - 2009-01-07 00:45:19
|
Well, it has been around for some time, but I discovered it only now:
Glade-3 together with libglade. Glade-3 doesn't generate C code anymore,
only a xml description of the GUI, but libglade generates the GUI
on-the-fly. Much less coding than calling the gtk functions directly.
I first wrote a small C program:
-------------------------------
#include <gtk/gtk.h>
#include <glade/glade.h>
void Hello (GtkWidget *widget, gpointer user_data)
{ g_print("Hello, world!\n"); }
int main(int argc, char **argv)
{
GladeXML *xml;
gtk_init(&argc, &argv);
xml = glade_xml_new("gui.glade", "window", NULL);
if (!xml)
{ g_warning("unable to read or process xml file\n");
return 1;
}
glade_xml_signal_autoconnect(xml);
gtk_main();
return 0;
}
The GUI coded in 'gui.glade' is simply a window with a button which
calls the function 'Hello'.
The program is compiled and linked with
---------------------------------------
gcc -o hello_c hello_c.c -export-dynamic \
`pkg-config --cflags --libs libglade-2.0`
Accordingly, I wrote the oberon main program
--------------------------------------------
MODULE HelloWorld;
IMPORT SYSTEM, RT0, Out, Gtk, Glade;
CONST
GUIFILE = "gui.glade";
ERRXML = 1; (* xml file problem *)
VAR
argc : LONGINT;
argv : Gtk.ArgVector;
xml: Glade.XMLPtr;
PROCEDURE Hello* (widget:Gtk.WidgetPtr; data:SYSTEM.PTR);
BEGIN
Out.String("Hello, world!"); Out.Ln;
END Hello;
BEGIN
argc:= RT0.argc;
argv:= SYSTEM.VAL (Gtk.ArgVector, RT0.argv);
Gtk.init (argc, argv);
xml:= Glade.xml_new (GUIFILE, NIL, NIL);
ASSERT (xml#NIL, ERRXML);
Glade.xml_signal_autoconnect (xml);
Gtk.main;
END HelloWorld.
I wrote the interface modules too, which start with
---------------------------------------------------
MODULE Gtk [INTERFACE "C"; LINK LIB "gtk-x11-2.0" ADD_OPTION
LibGladePrefix END];
and
---
MODULE Glade [INTERFACE "C"; LINK LIB "glade-2.0" ADD_OPTION
LibGladePrefix END];
The relevant 'pkginfo.xml' lines are
------------------------------------
<define name="LibGladePrefix">-export-dynamic -L/usr/lib</define>
<define name='cflags'>-g -O2</define>
Everything compiles, but calling the executable gets me:
--------------------------------------------------------
(HelloWorld:10334): libglade-WARNING **: could not find signal handler
'Hello'.
Who is looking for that signal handler is the procedure
'Glade.xml_signal_autoconnect'.
Can anybody tell me how I make that visible?
Is the '-export-dynamic' option in the prefix in the right place?
Thanks,
--
Frank Hrebabetzky +55 / 48 / 3235 1106
Florianopolis, Brazil
|