Missing GTK+2 API

Linux specific forum
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Missing GTK+2 API

Post by grabiller »

Hi,

As I'm working on an application that will be cross-platform (Windows/Linux/MacOSX), I'm starting to port my Windows GUI code to Linux in wich I'm using a lot of controls subclassing.

Having then started to learn the GTK+2 API, I've discovered that some functions are not recognized by PureBasic.

For instance, for a StringGadget (entry/editable under gtk), I've been able to use gtk_entry_get_layout_() to retrieve the PangoLayout but I've been unable to use gtk_entry_layout_index_to_text_index_() or gtk_entry_text_index_to_layout_index_() as those are not recognized by PureBasic.

What should I do to use/add to the list of recognized GTK+2 function by PureBasic ?

Thanks in advance,
Cheers,
Guy.

ps: I'm using PB 4.61 (x64) on Ubuntu 12.04.1
guy rabiller | radfac founder / ceo | raafal.org
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Missing GTK+2 API

Post by Guimauve »

Hello grabiller,

When you discover a GTK API are not recognized by PureBasic you have to do something like this :

Code: Select all

ImportC "-gtk"
  
  gdk_event_handler_set(*func, *mdata, *notify)
  g_signal_connect(instance, signal.p-utf8, *fn, *vdata, destroy = 0, flags = 0) As "g_signal_connect_data"
  g_object_set_data_(*Widget.GtkWidget, strData.p-utf8, *userdata) As "g_object_set_data"
  g_object_get_data_(*Widget.GtkWidget, strData.p-utf8) As "g_object_get_data"
  g_object_set_property_(*widget, Property.p-utf8, *val) As "g_object_set_property"  
  
EndImport
Best regards
Guimauve
Dear Optimist, Pessimist,
and Realist,

While you guys were
busy arguing about the
glass of water, I DRANK IT !

Sincerely,
the Opportunist
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Missing GTK+2 API

Post by grabiller »

Ah, thanks a lot.

Is there a way to permanently add the functions into some PureBasic config/db files or something so we dont have to add the code or use additionnel includes files ?

Cheers,
Guy.
guy rabiller | radfac founder / ceo | raafal.org
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Missing GTK+2 API

Post by Shardik »

grabiller wrote:What should I do to use/add to the list of recognized GTK+2 function by PureBasic ?
You have to add these ImportC statements to your programs.

Code: Select all

ImportC ""
  gtk_entry_layout_index_to_text_index(*Entry.GtkEntry, LayoutIndex.I)
  gtk_entry_text_index_to_layout_index(*Entry.GtkEntry, TextIndex.I)
EndImport
grabiller wrote:Is there a way to permanently add the functions into some PureBasic config/db files or something so we dont have to add the code or use additionnel includes files ?
You should put these lines into an include file.
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Missing GTK+2 API

Post by grabiller »

Yes, thanks.

I thought there was some way to include the missing apis into some config files for PureBasic to be permanently 'aware' of the new apis entries without ressorting to include files.

Cheers,
Guy.
guy rabiller | radfac founder / ceo | raafal.org
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Missing GTK+2 API

Post by Shardik »

grabiller wrote:I thought there was some way to include the missing apis into some config files for PureBasic to be permanently 'aware' of the new apis entries without ressorting to include files.
One possibility would be to automatically add the ImportC statements by a special IDE tool to each new source file opened in the PB IDE. You will need PB 5.00 Beta 2 for this. Take a look into freak's posting:
http://www.purebasic.fr/english/viewtop ... 24&start=7
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Missing GTK+2 API

Post by grabiller »

Hi,

Thanks for the info, indeed this will be very practical.

That said I've found the pbsoimporter tool wich seems to be the answer to my needs, I'll investigate further.

Cheers,
Guy.
guy rabiller | radfac founder / ceo | raafal.org
Post Reply