Re: Wrapping GTK+

new topic     » goto parent     » topic index » view thread      » older message » newer message

Pete replied to my question:


>>[1. Is there a DLL for GTK+? ]
>
>libgtk.so


Here's the bit of code I'm currently struggling with. The value displayed
for gtk is 0, so it doesn't seem to be connecting. As a result, the code
fails at the first c_proc.

I've tried alternate values, such as:

   "/usr/lib/libgtk.so"

and paths to all the other GTK libraries I could find. "/usr/lib/libgtk.so"
is (as you know) actually a link to the library. I've got permissions to the
link, but I didn't bother checking if I had permissions to the library.
I've coded a number of small GTK programs in C under the same user login, so
I imagine that it's not a permissions problem.

Thanks!

-- David Cuny


-- gtktest.exu

include dll.e

-- try to link to a dll
atom gtk
gtk = open_dll("libgtk.so")

-- check value - this always returns 0  sad
? gtk

-- declare functions
constant
gtk_init = define_c_proc( gtk, "gtk_init", {C_POINTER, C_POINTER} ),
gtk_window_new = define_c_func( gtk, "gtk_window_new", {C_POINTER,
C_POINTER}, C_POINTER ),
gtk_window_set_title = define_c_func( gtk, "gtk_window_set_title",
{C_POINTER}, C_POINTER ),
gtk_container_border_width = define_c_func( gtk,
"gtk_container_border_width", {C_POINTER,C_LONG}, C_POINTER ),
gtk_button_new_with_label = define_c_func( gtk, "gtk_button_new_with_label",
{C_POINTER}, C_POINTER ),
gtk_widget_show = define_c_proc( gtk, "gtk_widget_show", {C_POINTER} ),
gtk_container_add = define_c_proc( gtk, "gtk_container_add", {C_POINTER,
C_POINTER} ),
gtk_main = define_c_proc( gtk, "gtk_main", {} )

constant
GTK_WINDOW_TOPLEVEL = 1 -- this might be 2

atom window, button

-- initialization
c_proc( gtk_init, { 0, 0 } )

-- create the toplevel window
window = c_func( gtk_window_new, {GTK_WINDOW_TOPLEVEL} )

-- title
c_proc( gtk_window_set_title, {window, allocate_string("Push Button") )

-- border
-- perhaps the prototype's #2 arg uses C_INT; I didn't really check
c_proc( gtk_container_border_width, {window, 50} )

-- create a button
button = c_func( gtk_button_new_with_label, {allocate_string("Button")} )

-- show the button (but not visible yet)
c_proc( gtk_widget_show, {button} )

-- add the button to the window
c_proc( gtk_container_add, {window, button} )

-- add button to window
c_proc( gtk_widget_show, {window} )

-- main loop
c_proc( gtk_main, {} )

-- return code of zero
abort(0)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu