Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Question about EXPORT / WAS: ...GLADE
#1
Wanted to play with GLADE and I'm stuck right now because I can't get the "glade_xml_new" function to read the xml file.

In C, the function goes:
Code:
GladeXML *glade_xml_new (const char *fname, const char *root, const char *domain)
so I translated it to:
Code:
declare function glade_xml_new cdecl Alias "glade_xml_new" LIB "libglade-2.0" ( fname as string ptr, root as string ptr, domain as string ptr) as GladeXML ptr
and I call it with:
Code:
dim xml as GladeXML ptr
dim xmlfile as string
xml = glade_xml_new (sadd(xmlfile), NULL, NULL)
Has somebody a solution for me?
Thanks
Reply
#2
Every char * argument must to be declared as BYVAL ... AS STRING, string ptr as BYREF will pass a pointer to a pointer to a string descriptor.
Reply
#3
Thanks Victor, this works now.
I'm able to call a window which is defined in a xml file.

BUT there is still a bug:
I define the window signal (event) in this xml file, and connect it with:
glade_xml_signal_autoconnect (xml)

After compiling and starting the app a window appears :bounce: but on the cmd line I get the warning message 'signal function not found' because it searches for my function name.

Is there a solution for this?
How can I make the function name public (export)?
Thanks

EDIT: I also made a obj file out of the function and linked it with the exe, but the function is still not found...
Reply
#4
I was checking GLADE better, pretty interesting.

Yeah, there's no way to export symbols on EXE's, only DLL's, so i added the EXPORT keyword now, functions can be declared as (in v0.11):

function myfunc cdecl alias "MyFunc" (...) as sometype export

FB will add the directive to the asm output and will tell LD to export the dynamic symbols, so using GLADE or any lib that can't find the functions at compile-time, will be possible.
Reply
#5
Victor,
YOU ROCK MAN :king:

Playing around with gtk/glade is not too bad, it's a different approach to have your widget description in a xml file.
Wanted to use signals described in this xml file, and with the new version it should work.
Otherwise I have to use 'gtk_signal_connect_object' and it doesn't would make sense to use glade at all.

Again, that's fantastic news.
Can't wait for the new version.
:bounce:
Can't wait...
:bounce:
Can't wait...
:bounce:
Can't wait...
Reply
#6
@Victor
don't know if it's intentional, but the exported function needs always to be in a separate bas file, no export function allowed in main bas file...

Also the exported function only accepts the return statement:

my_func = Whatever

This said if I need more stuff to be executed I need to call a second function:

my_func = Whatever ()

and add all my stuff into the second function.
:o

on the other hand it works ( if done as described above...) :wink:
Reply
#7
Yeah, i found that when trying Glade myself yesterday, stupid LD -export directive needs a white-space between each item, the fix is on CVS, you will have to compile the compiler yourself, sorry.. a new release may take time to be done..

Code:
option explicit

#include "gtk.bi"
#include "glade-xml.bi"

sub on_window1_destroy cdecl alias "on_window1_destroy" (byval object as GtkObject ptr, byval user_data as gpointer ) export
    gtk_main_quit()
end sub

sub on_button1_clicked cdecl alias "on_button1_clicked" (byval object as GtkObject ptr, byval user_data as gpointer ) export
    gtk_main_quit()
end sub

    
    dim xml as GladeXML ptr

    gtk_init( NULL, NULL )

    xml = glade_xml_new( "test.xml", NULL, NULL )

    dim toplevel as GtkWidget ptr

    toplevel = glade_xml_get_widget( xml, "window1" )
    gtk_widget_show_all( toplevel )
    g_signal_connect( toplevel, "delete-event", @gtk_main_quit, NULL )
    glade_xml_signal_autoconnect( xml )
    gtk_main( )

    'g_object_unref( xml )

    end 0

That will work when the fix is used.
Reply
#8
thanks
Reply
#9
BTW:
AFAIK g_signal_connect is not needed because of glade_xml_signal_autoconnect( xml ).
At least it works for me with:
<signal name="delete_event" handler="main_quit"/>
inside the xml file. ("main_quit" is my function name)
Suppose default event names need to be used like "delete_event", because if I rename it, it doesn't work anymore...
Reply
#10
I translated that code from the gladewin32 project's dev-cpp example, i've no knowledge of Gtk+, i just did a plain translation to test stuff.

Glade is way cool, btw, thanks for pointing me it ;)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)