Qbasicnews.com
October 14, 2019, 09:44:28 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Another Question about EXPORT / WAS: ...GLADE  (Read 7251 times)
fsw
Guru
**
Posts: 251


« on: January 24, 2005, 03:12:44 PM »

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
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #1 on: January 24, 2005, 04:03:08 PM »

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.
Logged

fsw
Guru
**
Posts: 251


« Reply #2 on: January 24, 2005, 07:24:06 PM »

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...
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #3 on: January 25, 2005, 03:51:41 PM »

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.
Logged

fsw
Guru
**
Posts: 251


« Reply #4 on: January 25, 2005, 04:13:25 PM »

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...
Logged
fsw
Guru
**
Posts: 251


« Reply #5 on: January 31, 2005, 04:06:34 PM »

@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.
 Shocked

on the other hand it works ( if done as described above...)  :wink:
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #6 on: January 31, 2005, 04:35:16 PM »

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.
Logged

fsw
Guru
**
Posts: 251


« Reply #7 on: January 31, 2005, 05:23:05 PM »

thanks
Logged
fsw
Guru
**
Posts: 251


« Reply #8 on: January 31, 2005, 07:27:35 PM »

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...
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #9 on: January 31, 2005, 11:17:32 PM »

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 ;)
Logged

fsw
Guru
**
Posts: 251


« Reply #10 on: February 03, 2005, 02:11:07 PM »

Quote from: "v3cz0r"
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 Wink


You're welcome   Cheesy
I compiled fbc and got the problem (exported function only accepts the return statement) with the functions solved.
Thanks for that.


Another question though:

I still need a second bas file with the exported functions in it.
Can't have the exported functions in the main file - the error occurs: 'no symbol found'.

Is this intentional ?


If so no prob, just need to know the right approach.

Thanks again for your hard work
Logged
fsw
Guru
**
Posts: 251


« Reply #11 on: February 03, 2005, 02:37:51 PM »

BTW:
While compiling fbc and the rtlib with Dev-Cpp i had to copy fbc and some other stuff (needed by fb) to the dev-cpp folder.
This way I was able to use your makefile without changes...

This said I was able to use :
gcc to compile the rtlib
and :
fbc to compile fbc_new
with the same dev environment  Shocked

So I thought: actually Dev-Cpp could be used to code FreeBASIC files.
It's already all in there (compiler output and error messages etc., don't know about the debugger though...), and open source.
The only thing needed to do is to merge/copy the fb directory structure to the dev-cpp directory one, so all libs and other files are in place.

Maybe it's even possible to take the dev-cpp sources and make a dev environment dedicated to fb (on the other hand, if the original dev-cpp is used, it's possible to compile the rtlib!).

Don't know how much work it is to make a basic-language syntax highlite-file for dev-cpp.
Another thing is that MAKE is used, and so a makefile is needed for every project  :barf:

EDIT
It seems that the syntax highliting function in dev-cpp is hardcoded.
No file found for this... :cry:
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!