gtk +xml tutorial why not work?

New to FreeBASIC? Post your questions here.
covid19
Posts: 31
Joined: Apr 25, 2020 20:41

Re: gtk +xml tutorial why not work?

Postby covid19 » May 10, 2020 8:08

gtk 3 and gtk 2
wich version 32 or 64 ?
covid19
Posts: 31
Joined: Apr 25, 2020 20:41

Re: gtk +xml tutorial why not work?

Postby covid19 » May 10, 2020 8:19

I USE GTK3 32BIT

i copy gtk static lib in c:\opt\gtk3 , i copy gir header in freebasic , folder inc
i modify header

Code: Select all

' GtkBuilder.bas
' GPLv3: Copyright by TJF, 2011
' (replacement for glade_gui.bas and glade-xml.bas)
' Details: http://developer.gnome.org/gtk/

'#DEFINE __USE_GTK3__


LIBPATH="C:\opt\GTK3"
'#INCLUDE ONCE "gtk/gtk.bi"
#INCLUDE ONCE "Gir/GTK-3.0.bi"
'#INCLUDE ONCE "Gir/_GLibMacros-2.0.bi"
' Note:
'  one source code, different GUIs. Choose one
'#DEFINE Ui_filename "GtkBuilder1.ui" ' simple 'Click me!' button
'#DEFINE Ui_filename "GtkBuilder2.ui" ' complex UI with notebook
'  try tab 'Buttons' -> 'Hello' button (check console output)
'  try tab 'Listview' -> sort column by clicking on header
'                     -> reorder column by dragging with mouse

SUB on_ClickButton_clicked CDECL ALIAS "on_ClickButton_clicked" ( _
  BYVAL button AS GtkButton PTR, _
  BYVAL user_data AS gpointer) EXPORT

  g_message("ClickButton clicked!")

END SUB


gtk_init( NULL, NULL )

VAR xml = gtk_builder_new()
DIM AS GError PTR mess
IF 0 = gtk_builder_add_from_file(xml, Ui_filename, @mess) THEN
  ?"Fehler/Error (GTK-Builder):"
  ?*mess->message
  END 2
END IF

gtk_builder_connect_signals( xml, NULL )
gtk_main( )

g_object_unref( xml )

END 0

this is what return

Command executed:
"C:\FreeBasic\fbc.exe" "C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas"

Compiler output:
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(9) error 42: Variable not declared, LIBPATH in 'LIBPATH="C:\opt\GTK3"'
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(25) error 42: Variable not declared, g_message in 'g_message("ClickButton clicked!")'
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(34) error 42: Variable not declared, Ui_filename in 'IF 0 = gtk_builder_add_from_file(xml, Ui_filename, @mess) THEN'

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
dodicat
Posts: 6628
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: gtk +xml tutorial why not work?

Postby dodicat » May 10, 2020 8:35

libpath should be of the form

#LIBPATH "C:\opt\GTK3"

You are using fbide, why not get the .chm help file and point fbide to it under view-settings-freebasic.
Then all you have to is is put your cursor over any keyword and press F1.
You will soon see that libpath is not a keyword.
All other errors follow on from the first.
If you use win 10 you may have to activate the .chm by right clicking it, get properties and unchecking the little box.
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: gtk +xml tutorial why not work?

Postby TJF » May 10, 2020 8:45

covid19 wrote:gtk 3 and gtk 2
wich version 32 or 64 ?

Upps, right now I found out that you installed FB32bit. The tschoony link offers 64bit only -> incompatible.

I found 32bit binaries for GTK-3.22.0 at (untested)

https://www.dropbox.com/sh/8d1qbh5dsp04 ... x-dwarf.7z

In long term, it'd be best that you either switch to 64 bit or build your own 32bit binaries.
covid19
Posts: 31
Joined: Apr 25, 2020 20:41

Re: gtk +xml tutorial why not work?

Postby covid19 » May 10, 2020 9:11

i add

#LIBPATH "C:\opt\GTK3"

but now i have this


Command executed:
"C:\FreeBasic\fbc.exe" "C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas"

Compiler output:
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(24) error 42: Variable not declared, g_message in 'g_message("ClickButton clicked!")'
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(33) error 42: Variable not declared, Ui_filename in 'IF 0 = gtk_builder_add_from_file(xml, Ui_filename, @mess) THEN'

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: gtk +xml tutorial why not work?

Postby TJF » May 10, 2020 9:53

dodicat wrote:libpath should be of the form

#LIBPATH "C:\opt\GTK3"
Yes, sorry for that mistake.

covid19 wrote:Compiler output:
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(24) error 42: Variable not declared, g_message in 'g_message("ClickButton clicked!")'
C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas(33) error 42: Variable not declared, Ui_filename in 'IF 0 = gtk_builder_add_from_file(xml, Ui_filename, @mess) THEN'
g_message() is a GLib macro. Uncomment the line

Code: Select all

#INCLUDE ONCE "Gir/_GLibMacros-2.0.bi"

And you've to choose either of the files to load. Uncomment one of

Code: Select all

'#DEFINE Ui_filename "GtkBuilder1.ui" ' simple 'Click me!' button
#DEFINE Ui_filename "GtkBuilder2.ui" ' complex UI with notebook
covid19
Posts: 31
Joined: Apr 25, 2020 20:41

Re: gtk +xml tutorial why not work?

Postby covid19 » May 10, 2020 10:16

if uncomment this #DEFINE Ui_filename "GtkBuilder1.ui" ' simple 'Click me!' button

have this
Command executed:
"C:\FreeBasic\fbc.exe" "C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas"

Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgio-2.0
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgdk-3
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgtk-3

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)


if uncomment this #DEFINE Ui_filename "GtkBuilder2.ui" ' complex UI with notebook
have this
Command executed:
"C:\FreeBasic\fbc.exe" "C:\Users\pc\Desktop\test_freebasic\FBIDETEMP.bas"

Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgio-2.0
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgdk-3
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgtk-3

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: gtk +xml tutorial why not work?

Postby TJF » May 10, 2020 10:52

covid19 wrote:Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgio-2.0
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgdk-3
C:\FreeBasic\bin\win32\ld.exe: cannot find -lgtk-3
Fine, your code compiles now.

The error messages are coming from the next step, linker (ld.exe) now. It cannot find the matching DLL files. Make sure that the #LIBPATH points to the right folder of libgio-2.0.dll, libgdk-3.dll and libgtk-3.dll (perhaps you have to rename the dll files: libgtk-3.0.dll -> libgtk-3.dll).
covid19
Posts: 31
Joined: Apr 25, 2020 20:41

Re: gtk +xml tutorial why not work?

Postby covid19 » May 10, 2020 12:10

#LIBPATH "C:\opt\GTK3"

what have in
look here
https://ibb.co/P59Gvyx
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: gtk +xml tutorial why not work?

Postby TJF » May 10, 2020 12:34

covid19 wrote:#LIBPATH "C:\opt\GTK3"

what have in
look here
https://ibb.co/P59Gvyx
The image resolution is too low, I cannot read the text.

Note: I'm not a wodniws expert. AFAIR I never had .dll.a files (static libraries?). Instead the binaries I used years ago were .dll files (dynamic libraries?).

Sorry, at this point I cannot really help.

And: The Gir/Gtk-3.bi header is for Gtk-3.18.9. You should install that or a newer binary version. Perhaps you check the binaries I mentioned above:

https://www.dropbox.com/sh/8d1qbh5dsp04 ... x-dwarf.7z
covid19
Posts: 31
Joined: Apr 25, 2020 20:41

Re: gtk +xml tutorial why not work?

Postby covid19 » May 10, 2020 13:09

ok dont worry i understund , is 2 day i try to see an example and i am not , first beginner in the world (thinking i am a sysadmin) , ahahahhaha
i am sorry but probably i will study another language
the comunity of free basic is very beautifull and i give my thankz at all for comprehension , but freebasic is very shi....... i think freebasic without this comunity probably will be stop develop many year ago .
immagine all tool for develop somthing , take gambas install it , instal some library and start to develop , QT install ambient e start to draw GUI and develop C++, visualstudio 2019 with VB or C# , the same.
i propose to change the name FreeBASIC to FreeAdvanced , only for graduated programmer not for beginner , and remove a Horse , and insert turtle
I hope this post will be read by the freebasic developers

P.S. i like the example of freebasic ahahahhahaha LOL ahahahahhahahahahaha
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: gtk +xml tutorial why not work?

Postby systemctl » May 10, 2020 13:41

covid19 wrote:i would create a crossplatform app iup work in linux ?? ....


Of course. It uses GTK+ underlying so your app will look not any different than if you used GTK+ directly.
Xusinboy Bekchanov
Posts: 243
Joined: Jul 26, 2018 18:28

Re: gtk +xml tutorial why not work?

Postby Xusinboy Bekchanov » May 11, 2020 6:35

This code compiles without problems for me.

Code: Select all

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'< main program generated by utility                 GTK+tobac2 V2.2.0 >
'< Hauptprogramm erzeugt von                                           >
'< Generated at / Generierung am                     2010-09-06, 01:24 >
' ---------------------------------------------------------------------
'< Program info:                                                       >
CONST PROG_NAME = "Scribble" '                                         >
CONST PROG_DESC = "Zeichenprogramm" '                                  >
CONST PROG_VERS = "0.0" '                                              >
CONST PROG_YEAR = "2010" '                                             >
CONST PROG_AUTH = "TJF" '                                              >
CONST PROG_MAIL = "Thomas.Freiherr@gmx.net" '                          >
CONST PROG_WEBS = "members.aon.at/tjf" '                               >
'<                                                                     >
'< Description / Beschreibung:                                         >
'< Beispiel DrawArea, einfaches Zeichenprogramm                        >
'<                                                                     >
'< License / Lizenz:                                                   >
'<                                                                     >
'< Redistribution and use in source and binary forms, with or          >
'< without modification, are permitted provided that the following     >
'< conditions are met:                                                 >
'<                                                                     >
'< * Redistributions of source code must retain the above              >
'< copyright notice, this list of conditions and the following         >
'< disclaimer.                                                         >
'<                                                                     >
'< * Redistributions in binary form must reproduce the above           >
'< copyright notice, this list of conditions and the following         >
'< disclaimer in the documentation and/or other materials provided     >
'< with the distribution.                                              >
'<                                                                     >
'< * Neither the name of the author nor the names of its               >
'< contributors may be used to endorse or promote products derived     >
'< from this software without specific prior written permission.       >
'<                                                                     >
'< THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS                  >
'< AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED                 >
'< WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES   >
'< OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE             >
'< ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER               >
'< OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     >
'< SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT    >
'< LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF    >
'< USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED     >
'< AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT         >
'< LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN   >
'< ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE     >
'< POSSIBILITY OF SUCH DAMAGE.                                         >
'<                                                                     >
' ---------------------------------------------------------------------
'< Please prefer GNU GENERAL PUBLIC LICENSE to support open software.  >
'< For more information please visit:               http://www.fsf.org >
'<                                                                     >
'< Bitte bevorzugen Sie die GNU GENERAL PUBLIC LICENSE und             >
'< unterstuetzen Sie mit Ihrem Programm die freie Software             >
'< Mehr Informationen finden Sie unter:             http://www.fsf.org >
' ---------------------------------------------------------------------
'<  GTK+tobac:             general init / Allgemeine Initialisierungen >
  '  #INCLUDE "gtk/GTK-2.18.6_TJF.bi" '   GTK+library / GTK+ Bibliothek >
  #include once "gtk/gtk.bi"
    gtk_init(@__FB_ARGC__, @__FB_ARGV__) '     start GKT / GTK starten >
'<  GTK+tobac:                                   end block / Blockende >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

/' Backing pixmap for drawing area '/
DIM SHARED AS GdkPixmap PTR PIXMAP = NULL
DECLARE SUB draw_brush(BYVAL widget AS GtkWidget PTR, _
                       BYVAL x AS gdouble, _
                       BYVAL y AS gdouble)

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'< _tobac.bas modul generated by utility             GTK+tobac2 V2.2.0 >
'< Modul _tobac.bas erzeugt von                                        >
'< Generated at / Generierung am                     2010-09-06, 02:45 >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

'IF gtk_check_version(2, 16, 0) THEN
'  ?"Fehler/Error (GTK-Version): Version zu alt"
'  END -1
'END IF

DIM AS STRING GUISTR
DIM SHARED AS GtkBuilder PTR XML
DIM SHARED AS GObject PTR _
  WinScribble, Draw1, ButQuit

XML = gtk_builder_new()

SCOPE
  DIM AS GError PTR meld

  ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  '< _gui.bas modul generated by utility               GTK+tobac2 V2.2.0 >
  '< Modul _gui.bas erzeugt von                                          >
  '< Generated at / Generierung am                     2010-09-06, 02:45 >
  ' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

  GUIstr =_
  "<?xml version=""1.0""?>"+_
  "<interface>"+_
  "<requires lib=""gtk+"" version=""2.16""/>"+_
  "<!-- interface-naming-policy project-wide -->"+_
  "<object class=""GtkWindow"" id=""WinScribble"">"+_
  "<signal name=""destroy"" handler=""gtk_main_quit""/>"+_
  "<child>"+_
  "<object class=""GtkVBox"" id=""vbox1"">"+_
  "<property name=""visible"">True</property>"+_
  "<child>"+_
  "<object class=""GtkDrawingArea"" id=""Draw1"">"+_
  "<property name=""width_request"">200</property>"+_
  "<property name=""height_request"">200</property>"+_
  "<property name=""visible"">True</property>"+_
  "<property name=""events"">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>"+_
  "<signal name=""button_press_event"" handler=""on_Draw1_button_press_event""/>"+_
  "<signal name=""motion_notify_event"" handler=""on_Draw1_motion_notify_event""/>"+_
  "<signal name=""expose_event"" handler=""on_Draw1_expose_event""/>"+_
  "<signal name=""configure_event"" handler=""on_Draw1_configure_event""/>"+_
  "</object>"+_
  "<packing>"+_
  "<property name=""position"">0</property>"+_
  "</packing>"+_
  "</child>"+_
  "<child>"+_
  "<object class=""GtkButton"" id=""ButQuit"">"+_
  "<property name=""label"" translatable=""yes"">Quit</property>"+_
  "<property name=""visible"">True</property>"+_
  "<property name=""can_focus"">True</property>"+_
  "<property name=""receives_default"">True</property>"+_
  "<signal name=""clicked"" handler=""gtk_main_quit""/>"+_
  "</object>"+_
  "<packing>"+_
  "<property name=""expand"">False</property>"+_
  "<property name=""fill"">False</property>"+_
  "<property name=""position"">1</property>"+_
  "</packing>"+_
  "</child>"+_
  "</object>"+_
  "</child>"+_
  "</object>"+_
  "</interface>"
  IF 0 = gtk_builder_add_from_string(XML, SADD(GUISTR), LEN(GUISTR), @meld) THEN
    WITH *meld
      ?"Fehler/Error (GTK-Builder):"
      ?*.message
    END WITH
    END -1
  END IF
END SCOPE

WinScribble = gtk_builder_get_object(XML, "WinScribble")
Draw1 = gtk_builder_get_object(XML, "Draw1")
ButQuit = gtk_builder_get_object(XML, "ButQuit")

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'< callback modul generated by utility               GTK+tobac2 V2.2.0 >
'< callback-Modul erzeugt von                                          >
'< Generated at / Generierung am                     2010-09-06, 01:24 >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

FUNCTION on_Draw1_button_press_event CDECL ALIAS "on_Draw1_button_press_event" _
         (BYVAL widget AS GtkWidget PTR, _
          BYVAL event AS GdkEventButton PTR) AS gboolean EXPORT
  IF event->button = 1 THEN IF PIXMAP THEN draw_brush(widget, event->x, event->y)
  RETURN TRUE
END FUNCTION

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'< callback modul generated by utility               GTK+tobac2 V2.2.0 >
'< callback-Modul erzeugt von                                          >
'< Generated at / Generierung am                     2010-09-06, 01:24 >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

FUNCTION on_Draw1_motion_notify_event CDECL ALIAS "on_Draw1_motion_notify_event" _
         (BYVAL widget AS GtkWidget PTR, _
          BYVAL event AS GdkEventMotion PTR) AS gboolean EXPORT
  DIM AS INTEGER x, y
  DIM AS GdkModifierType state

  IF event->is_hint THEN
    gdk_window_get_pointer(event->window, @x, @y, @state)
  ELSE
    x = event->x
    y = event->y
    state = event->state
  END IF

  IF state AND GDK_BUTTON1_MASK THEN IF PIXMAP THEN draw_brush(widget, x, y)
  RETURN TRUE
END FUNCTION

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'< callback modul generated by utility               GTK+tobac2 V2.2.0 >
'< callback-Modul erzeugt von                                          >
'< Generated at / Generierung am                     2010-09-06, 01:24 >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

FUNCTION on_Draw1_expose_event CDECL ALIAS "on_Draw1_expose_event" _
         (BYVAL widget AS GtkWidget PTR, _
          BYVAL event AS GdkEventExpose PTR) AS gboolean EXPORT
  gdk_draw_drawable(widget->window, _
                    widget->style->fg_gc(gtk_widget_get_state(widget)), _
                    PIXMAP, _
                    event->area.x, event->area.y, _
                    event->area.x, event->area.y, _
                    event->area.width, event->area.height)
  RETURN FALSE
END FUNCTION

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'< callback modul generated by utility               GTK+tobac2 V2.2.0 >
'< callback-Modul erzeugt von                                          >
'< Generated at / Generierung am                     2010-09-06, 01:24 >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

FUNCTION on_Draw1_configure_event CDECL ALIAS "on_Draw1_configure_event" _
        (BYVAL widget AS GtkWidget PTR, _
         BYVAL event AS GdkEventConfigure PTR) AS gboolean EXPORT
  IF PIXMAP THEN g_object_unref(pixmap)

  PIXMAP = gdk_pixmap_new(widget->window, _
                          widget->allocation.width, _
                          widget->allocation.height, _
                          -1)
  gdk_draw_rectangle(PIXMAP, _
                     widget->style->white_gc, _
                     TRUE, _
                     0, 0, _
                     widget->allocation.width, _
                     widget->allocation.height)
  RETURN TRUE
END FUNCTION


SUB draw_brush(BYVAL widget AS GtkWidget PTR, _
               BYVAL x AS gdouble, _
               BYVAL y AS gdouble)
  DIM AS GdkRectangle update_rect

  update_rect.x = x - 5
  update_rect.y = y - 5
  update_rect.width = 10
  update_rect.height = 10
  gdk_draw_rectangle(PIXMAP, _
                     widget->style->black_gc, _
                     TRUE, _
                     update_rect.x, update_rect.y, _
                     update_rect.width, update_rect.height)
  gtk_widget_queue_draw_area(widget, _
                             update_rect.x, update_rect.y, _
                             update_rect.width, update_rect.height)
END SUB

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'<  GTK+tobac:   run GTK main, then end / GTK Hauptschleife, dann Ende >
    gtk_builder_connect_signals(XML, 0) '           callbacks anbinden >
    gtk_widget_show_all(GTK_WIDGET(WinScribble)) 'ptfenster darstellen >
    gtk_main() '                             main loop / Hauptschleife >
    g_object_unref(XML) '               dereference / Referenz abbauen >
'<  GTK+tobac:                                   end block / Blockende >
' vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

' you may unref files here / ggf. Dateien hier schliessen

END 0 ' finish with return code 0 / Ende mit Returncode 0


Four things are needed for this:
1) Compiler version: 1.07.1-win32
2) gtk2 lib in the folder \FreeBASIC-1.07.1-win32\lib\win32
Here I inserted gtk2 lib, which I downloaded through mingw32:
https://drive.google.com/file/d/1JGmUSO ... sp=sharing
3) Installing the gtk2 runtime: If you use Geany Windows, he can install it himself.
4) comment line 687 in \FreeBASIC-1.07.1-win32\lib\win32\inc\glib.bi

Code: Select all

Private Sub g_mutex_locker_free(ByVal locker As GMutexLocker Ptr)
   'g_mutex_unlock(CPtr(GMutex Ptr, locker))
End Sub

Subject on this issue: https://www.freebasic.net/forum/viewtopic.php?t=26931
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: gtk +xml tutorial why not work?

Postby TJF » May 11, 2020 7:21

Thanks for testing!

Xusinboy Bekchanov wrote:2) gtk2 lib in the folder \FreeBASIC-1.07.1-win32\lib\win32
Here I inserted gtk2 lib, which I downloaded through mingw32:
https://drive.google.com/file/d/1JGmUSO ... sp=sharing
That download points to GTK-3.8.2 binaries.
Xusinboy Bekchanov wrote:3) Installing the gtk2 runtime: If you use Geany Windows, he can install it himself.
I guess those are the binaries you compiled against.
Xusinboy Bekchanov wrote:4) comment line 687 in \FreeBASIC-1.07.1-win32\lib\win32\inc\glib.bi

Code: Select all

Private Sub g_mutex_locker_free(ByVal locker As GMutexLocker Ptr)
   'g_mutex_unlock(CPtr(GMutex Ptr, locker))
End Sub

Subject on this issue: https://www.freebasic.net/forum/viewtopic.php?t=26931
It doesn't make sense to declare a private SUB in a header. You can remove all that stuff at the end of the official headers. Not just glib.bi, but also in gtk3.bi, gdk3.bi, ... It's coming from the fb-frog auto-translation. The Gir headers are free of that bload (less memory, compiling faster).
Xusinboy Bekchanov
Posts: 243
Joined: Jul 26, 2018 18:28

Re: gtk +xml tutorial why not work?

Postby Xusinboy Bekchanov » May 11, 2020 7:38

TJF wrote:Thanks for testing!

Xusinboy Bekchanov wrote:2) gtk2 lib in the folder \FreeBASIC-1.07.1-win32\lib\win32
Here I inserted gtk2 lib, which I downloaded through mingw32:
https://drive.google.com/file/d/1JGmUSO ... sp=sharing
That download points to GTK-3.8.2 binaries.

But here there are gtk 2 libraries like libgtk-win32-2.0.dll.a
TJF wrote:
Xusinboy Bekchanov wrote:3) Installing the gtk2 runtime: If you use Geany Windows, he can install it himself.
I guess those are the binaries you compiled against.

I downloaded and installed the runtime library from here (version 2.24)
https://sourceforge.net/projects/gtk-wi ... vironment/
TJF wrote:
Xusinboy Bekchanov wrote:4) comment line 687 in \FreeBASIC-1.07.1-win32\lib\win32\inc\glib.bi

Code: Select all

Private Sub g_mutex_locker_free(ByVal locker As GMutexLocker Ptr)
   'g_mutex_unlock(CPtr(GMutex Ptr, locker))
End Sub

Subject on this issue: https://www.freebasic.net/forum/viewtopic.php?t=26931
It doesn't make sense to declare a private SUB in a header. You can remove all that stuff at the end of the official headers. Not just glib.bi, but also in gtk3.bi, gdk3.bi, ... It's coming from the fb-frog auto-translation. The Gir headers are free of that bload (less memory, compiling faster).

I just checked with the headers of the official FreeBasic build (1.07.1).

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 3 guests