Updated GTK headers (GTK-2 and GTK-3)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Post by TJF »

Hi wallyg!

Thanks for testing the headers and for your report. Sorry for your trouble.

It seems that by any reason some old headers gets included and cause the duplicated definitions. I'll check this, although it isn't importand for the next FB release (since all old headers will get removed). It may take some time.

Here's how you may continue:
  • rename your gtk folder in C:\FreeBASIC\inc\ (ie -> gtk_old)
  • copy again the gtk folder from the Gtk.7z to C:\FreeBASIC\inc\.
If you like, you may try another method first. Just rename (or remove) the C:\FreeBASIC\inc\gtk\glib.bi file.
wallyg
Posts: 279
Joined: May 08, 2009 7:08
Location: Tucson Arizona

Post by wallyg »

TJF wrote:Hi wallyg!

Thanks for testing the headers and for your report. Sorry for your trouble.

It seems that by any reason some old headers gets included and cause the duplicated definitions. I'll check this, although it isn't importand for the next FB release (since all old headers will get removed). It may take some time.

Here's how you may continue:
  • rename your gtk folder in C:\FreeBASIC\inc\ (ie -> gtk_old)
  • copy again the gtk folder from the Gtk.7z to C:\FreeBASIC\inc\.
If you like, you may try another method first. Just rename (or remove) the C:\FreeBASIC\inc\gtk\glib.bi file.
Thank you. I renamed the inc/gtk folder to inc/gtk_old and reloaded Freebasic and replace it with your *.7z files and it works great now. Thank you very much for getting this to work for me and all of us in this group. Your work is greatly appreciated.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Post by AGS »

marcov wrote:
TJF wrote:
AGS wrote:As for GTK+ 3 and windows. The problem is this: there is no dbus library support for win32. GTK+ 3 uses dbus for communication purposes.
Aha. Didn't know that dbus isn't available for win32. (What about win64?).
http://sourceforge.net/projects/windbus/
It's available all right but gio uses gdbus.

I looked up the error mesage I got when using gtk+ 3 specific code.

Code: Select all

static gchar *
get_session_address_platform_specific (GError **error)
{
  gchar *ret;
#ifdef G_OS_UNIX
  /* need to handle OS X in a different way since `dbus-launch --autolaunch' probably won't work there */
  ret = get_session_address_dbus_launch (error);
#else
  /* TODO: implement for UNIX, Win32 and OS X */
  ret = NULL;
  g_set_error (error,
               G_IO_ERROR,
               G_IO_ERROR_FAILED,
               _("Cannot determine session bus address (not implemented for this OS)"));
#endif
  return ret;
}
"..not implemented for this OS" being the interesting part.

The above function is part of GDBus - GLib D-Bus Library. Right now there just are not that many Gtk+ developers working on the win32 back end.

Looking at the dated glib/gtk+ binaries at ftp.gnome.org I do not think there will be a solid gtk+ version 3 release on win32 any time soon.

If libs like goocanvas start using gtk+ 3 stuff that is not portable then gtk+ might become less usable to many a fb programmer. Which (of course) does not mean there should not be gtk+ bindings for the fb programmers using Linux.
marcov
Posts: 3504
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Post by marcov »

AGS wrote:
The above function is part of GDBus - GLib D-Bus Library. Right now there just are not that many Gtk+ developers working on the win32 back end.

Looking at the dated glib/gtk+ binaries at ftp.gnome.org I do not think there will be a solid gtk+ version 3 release on win32 any time soon.
IMHO it's a common problem with ported *nix packages. Usually they are not really designed portable (to non *nix. They often are called "portable", but that is internal *nix portability), and the big decisions have been made before the other platforms are considered.
JasonL
Posts: 11
Joined: Sep 27, 2011 17:21
Location: Essex, UK

Suicide Is Painless?

Post by JasonL »

HELP...

I copied the files into the Freebasic dirs (win 7) and whatever I compile (using FBedit) I get tons and tons of errors???


any ideas what I am doing wrong??


Thanks in advance!
JasonL
Posts: 11
Joined: Sep 27, 2011 17:21
Location: Essex, UK

Errors I am Getting....

Post by JasonL »

  • C:\Program Files\FreeBASIC\fbc -s console "buttons.bas"
    C:\Program Files\FreeBASIC\inc\gtk\glib\gmacros.bi(12) error 4: Duplicated definition, G_GNUC_FUNCTION in '#define G_GNUC_FUNCTION ""'
    C:\Program Files\FreeBASIC\inc\gtk\glib\gmacros.bi(13) error 4: Duplicated definition, G_GNUC_PRETTY_FUNCTION in '#define G_GNUC_PRETTY_FUNCTION ""'
    C:\Program Files\FreeBASIC\inc\gtk\glib\gmacros.bi(14) error 4: Duplicated definition, G_STRLOC in '#define G_STRLOC ":" + str$(__LINE__)'
    C:\Program Files\FreeBASIC\inc\gtk\glib\gmacros.bi(15) error 4: Duplicated definition, FALSE in '#define FALSE 0'
    C:\Program Files\FreeBASIC\inc\gtk\glib\gmacros.bi(16) error 4: Duplicated definition, TRUE in '#define TRUE 1'
    C:\Program Files\FreeBASIC\inc\gtk\glib\config.bi(19) error 4: Duplicated definition, G_GINT16_MODIFIER in '#define G_GINT16_MODIFIER "h"'
    C:\Program Files\FreeBASIC\inc\gtk\glib\config.bi(20) error 4: Duplicated definition, G_GINT16_FORMAT in '#define G_GINT16_FORMAT "hi"'
    C:\Program Files\FreeBASIC\inc\gtk\glib\config.bi(21) error 4: Duplicated definition, G_GUINT16_FORMAT in '#define G_GUINT16_FORMAT "hu"'
    C:\Program Files\FreeBASIC\inc\gtk\glib\config.bi(26) error 4: Duplicated definition, G_GINT32_MODIFIER in '#define G_GINT32_MODIFIER ""'
    C:\Program Files\FreeBASIC\inc\gtk\glib\config.bi(27) error 4: Duplicated definition, G_GINT32_FORMAT in '#define G_GINT32_FORMAT "i"'
    C:\Program Files\FreeBASIC\inc\gtk\glib\config.bi(27) error 123: Too many errors, exiting

    Build error(s)
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Suicide Is Painless?

Post by TJF »

JasonL wrote:I get tons and tons of errors???


any ideas what I am doing wrong??
Yes, see wallyg post above ... We cannot mix the old and new files (because glib.bi gets included twice).

Either
  • rename or remove .../freebasic/inc/gtk/glib.bi or
  • rename or remove the complete .../freebasic/inc/gtk/ folder and install the new files again
Good luck!
VANYA
Posts: 1889
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by VANYA »

tested samples (Windows 7 home edition , compilier: Latest stable)
Glade_gui.bas
error 24: File not found, "gtk/libglade/glade-xml.bi" in '#include "gtk/libglade/glade-xml.bi"
glade_xml.bas
error 24: File not found, "gtk/libglade/glade-xml.bi" in '#include "gtk/libglade/glade-xml.bi"
gooCanvas\demo-table
In my opinion: bad drawing, the brake Scroll
gooCanvas\goocanvas-2.0.0
In my opinion: bad drawing, the brake Scroll
Tutorials\filesel.bas
Invalid assignment/conversion in 'file_name = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs))'
Tutorials\list.bas
When you click the left mouse button crashes
Tutorials\spinbutton.bas
When you spend your mouse over the numbers disappear spinbutton
Tutorials\text.bas
FbTemp.bas(11) error 41: Variable not declared, gtk_text_set_editable in 'gtk_text_set_editable (GTK_TEXT (text), GTK_TOGGLE_BUTTON (checkbutton)->active)'
FbTemp.bas(17) error 41: Variable not declared, gtk_text_set_word_wrap in 'gtk_text_set_word_wrap (GTK_TEXT (text), GTK_TOGGLE_BUTTON (checkbutton)->active)'
FbTemp.bas(73) error 41: Variable not declared, gtk_text_new in 'text = gtk_text_new (NULL, NULL)'
FbTemp.bas(73) warning 4(1): Suspicious pointer assignment
FbTemp.bas(74) error 67: Array not dimensioned, before '(' in 'gtk_text_set_editable (GTK_TEXT (text), TRUE)'
FbTemp.bas(79) error 41: Variable not declared, GTK_TEXT in 'vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj)'
FbTemp.bas(79) warning 1(1): Passing scalar as pointer, at parameter 1 of GTK_VSCROLLBAR_NEW()
FbTemp.bas(100) error 41: Variable not declared, gtk_text_freeze in 'gtk_text_freeze (GTK_TEXT (text))'
FbTemp.bas(103) error 41: Variable not declared, gtk_text_insert in 'gtk_text_insert (GTK_TEXT (text), NULL, @text->style->black, NULL, "Supports ", -1)'
FbTemp.bas(104) error 67: Array not dimensioned, before '(' in 'gtk_text_insert (GTK_TEXT (text), NULL, @val_color, NULL, "colored ", -1)'
FbTemp.bas(105) error 67: Array not dimensioned, before '(' in 'gtk_text_insert (GTK_TEXT (text), NULL, @text->style->black, NULL, "text and different ", -1)'
FbTemp.bas(106) error 67: Array not dimensioned, before '(' in 'gtk_text_insert (GTK_TEXT (text), fixed_font, @text->style->black, NULL, !"fonts\n\n", -1)'
FbTemp.bas(106) error 123: Too many errors, exiting
Tutorials\tree.bas
FbTemp.bas(21) error 41: Variable not declared, GTK_TREE in 'g_print (!"%s called for item %s->%p, level %d\n", signame, s_name, item, GTK_TREE (item->parent)->level)'
FbTemp.bas(40) error 56: Illegal specification, at parameter 1 (tree) of cb_selection_changed() in 'Sub cb_selection_changed Cdecl(Byval tree As GtkTree Ptr)'
FbTemp.bas(48) error 29: Expected pointer, before '->' in 'i = tree->selection'
FbTemp.bas(48) warning 4(1): Suspicious pointer assignment
FbTemp.bas(59) error 67: Array not dimensioned, before '(' in 'g_print (!"\t%s on level %d\n", s_name, GTK_TREE (item->parent)->level)'
FbTemp.bas(92) error 41: Variable not declared, gtk_tree_new in 'tree = gtk_tree_new ()'
FbTemp.bas(92) warning 4(1): Suspicious pointer assignment
FbTemp.bas(101) error 41: Variable not declared, gtk_tree_set_selection_mode in 'gtk_tree_set_selection_mode (GTK_TREE (tree), GTK_SELECTION_MULTIPLE)'
FbTemp.bas(112) error 41: Variable not declared, gtk_tree_item_new_with_label in 'item = gtk_tree_item_new_with_label (cast(gchar Ptr, itemnames(i)))'
FbTemp.bas(112) warning 4(1): Suspicious pointer assignment
FbTemp.bas(120) error 41: Variable not declared, gtk_tree_append in 'gtk_tree_append (GTK_TREE (tree), item)'
FbTemp.bas(124) warning 4(1): Suspicious pointer assignment
FbTemp.bas(124) error 3: Expected End-of-Line, found '(' in 'subtree = gtk_tree_new ()'
FbTemp.bas(133) error 67: Array not dimensioned, before '(' in 'gtk_tree_set_selection_mode (GTK_TREE (subtree), GTK_SELECTION_SINGLE)'
FbTemp.bas(133) error 123: Too many errors, exiting
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by TJF »

@VANYA, thanks for your report! It seems that you've tested all examples. Good job.

Just to make it clear:
VANYA wrote:... compilier: Latest stable ...
= fbc 0.23?

Regarding your tests
  • Tutorials/text.bas:
    No such file in my examples? (It seems that you mixed old examples and new headers.)
  • Glade_gui.bas and glade_xml.bas:
    No such files in my examples? I removed them because libglade is deprecated. They're replaced by .../examples/libraries/Gtk/GtkBuilder.bas.
  • list.bas, tree.bas, filesel.bas:
    These widgets are deprecated. That_s why I moved the examples in to the .../examples/libraries/Gtk2/Tutorials_deprecated folder. Use GtkFileChooser, GtkListView and GtkTreeView instead. (Find examples for GtkFileChooser and GtkListView in .../examples/libraries/Gtk/GtkBuilder.bas by using GtkBuilder2.ui.)
  • spinbutton.bas:
    Which GTK version do you use? (Compile and execute .../examples/libraries/Gtk/GtkVersionCheck.bas.) Did you compile the updated example from the archive in the first post here?
  • gooCanvas:
    I don't understand '... the brake Scroll'. (And I need info about GTK / Cairo versions.)
VANYA
Posts: 1889
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by VANYA »

fbc 0.23 ?
Yes.

I tried 0.24 for all examples:
cannot find -lgio-2.0
cannot find -lpangocairo-1.0
you mixed old examples and new headers
Yes. But the headers I did not mix
/examples/libraries/Gtk/GtkBuilder.bas
If you include the line: #DEFINE __FB_GTK3__ ,that:

Image

If you do not include a string # DEFINE __FB_GTK3__, then compiled and executed, but while the mouse will not spend on widgets, ListView and another widgets, does not fill the rows.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by TJF »

VANYA wrote:I tried 0.24 for all examples:
cannot find -lgio-2.0
cannot find -lpangocairo-1.0
I didn't test 0.24 yet. It seems that your version still ships the old GTK 2.08 binaries (older than 5 years). You can use
  • #DEFINE __TJF_GTK_OLD__
before #INCLUDE ONCE "gtk/gtk.bi" to omit loading these new libraries.
VANYA wrote:
you mixed old examples and new headers
Yes. But the headers I did not mix
My headers are similar to the original GTK C code. When a function is removed in the C headers it'll also be removed in my FB header. That's why my headers may not contain all function calls from the old examples. And that's why I made new / updated examples for the new headers.
VANYA wrote:
/examples/libraries/Gtk/GtkBuilder.bas
If you include the line: #DEFINE __FB_GTK3__ ,that:

Image

If you do not include a string # DEFINE __FB_GTK3__, then compiled and executed...
GTK3 uses a different settings concept. It seems that your installation isn't complete. (The installation from 'http://users.freebasic-portal.de/tjf/GTK/Gtk_Bin.7z' runs on a XP SP2 system here - 95%.)

Unfortunately I cannot recommend a link to an windows GTK3 installer, since I didn't find one yet. The binaries mentioned above are partially compiled by Galeon some month ago and partially downloaded from http://www.gtk.org.
..., but while the mouse will not spend on widgets, ListView and another widgets, does not fill the rows.
This also sounds like an installation issue. GTK is missing the information how to render these lines / rows (, they should be provided by a GtkTheme). I recommend to reinstall GTK2 by this bundle and mind all instructions regarding the setup.
VANYA
Posts: 1889
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by VANYA »

The system had two different versions of GTK and probably had a conflict. I removed both and installed from the official website the latest version. Everything was normal. There are examples (not yours) that do not work.
Your examples work and are very helpful, thank you.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by TJF »

VANYA wrote:... Everything was normal. There are examples (not yours) that do not work.
Thanks for testing and reporting.
VANYA wrote:... and installed from the official website the latest version.
Please name the version you installed, so others can learn from your experience.
VANYA wrote:Your examples work and are very helpful, thank you.
You're welcome!

BTW:
I don't use GTK like it's shown in most of the examples. I design my GUIs with Glade3 and save them as GUI-XML-file. Then I use GladeToBac3 to generate (or update) a FB code frame. Then I start programming in FB by extending the code frame.

The code frame looks similar to the .../examples/libraries/Gtk/GtkBuilder.bas example. But it's separated in several files so GladeToBac3 can add (or remove) signal handlers as needed.
VANYA
Posts: 1889
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by VANYA »

Please name the version you installed, so others can learn from your experience.
2.24.8 + your
BTW:
I don't use GTK like it's shown in most of the examples. I design my GUIs with Glade3 and save them as GUI-XML-file. Then I use GladeToBac3 to generate (or update) a FB code frame. Then I start programming in FB by extending the code frame.

The code frame looks similar to the .../examples/libraries/Gtk/GtkBuilder.bas example. But it's separated in several files so GladeToBac3 can add (or remove) signal handlers as needed.
For me it is too early,I must first learn how to make themselves functions of GTK, then I can create using the visual editor
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Updated GTK headers (GTK-2 and GTK-3)

Post by TJF »

VANYA wrote:For me it is too early,I must first learn how to make themselves functions of GTK, then I can create using the visual editor
When I started coding approx 27 month ago, I had no clue neither about FB nor about GTK. By learning with Glade3 it was much easier to understand the GTK concept (packing into containers, variable placing, ...). With Glade3 I could learn by trail and error. It was much faster than studying lots of documentation (since I wasn't keen on English computer terminology).

Anyway, good luck for your project(s).
Post Reply