Im New here and with no Idea of how do.
I Done many programs in VB.NET but only for Windows at moment I need to work in Linux too and the alternative is FreeBASIC and GTK for GUI.
Can someone make an example of How Use GTKTextView in FreeBASIC ?
This is a base where I want work, FreeBASIC Code with XML Glade
' START CONST '
' This part make a Const when can be used inside the program
CONST PROJ_NAME = "GTK_TEXT_VIEW"
' END CONST '
' When you compile the program he need path of external library
' then you can define the path inside the program
' If the case are (__FB_WIN32__) Mean Windows
#IF DEFINED(__FB_WIN32__)
#LIBPATH "C:\msys64\mingw64\lib"
' If you use anothe OS with different Path then you can put here like
' this default path of Linux
#ELSE
#LIBPATH "/usr/lib"
#ENDIF
' END define Library PATH
' DEFINE the GTK Header where you can use the GTK Library
' This Line define the GTK Version 3.00
#DEFINE __USE_GTK3__
' Including the GTK Header
#INCLUDE "gtk/gtk.bi"
gtk_init(@__FB_ARGC__, @__FB_ARGV__)
#INCLUDE "libintl.bi"
bindtextdomain(PROJ_NAME, EXEPATH & "/locale")
bind_textdomain_codeset(PROJ_NAME, "UTF-8")
textdomain(PROJ_NAME)
'--------------------------------------------------------------------------'
' Now we ave to set the object to bind
SCOPE
VAR er = gtk_check_version_(3, 24, 0)
IF er THEN
?"Error (GTK-Version):"
?*er
END 1
END IF
END SCOPE
DIM SHARED AS GtkBuilder PTR XML
DIM SHARED AS GObject PTR MainWindow, TextView_Left, TextView_Right, _
ButtonLeftToRight, ButtonRightToLeft, ButtonWriteInsideLeft, _
ButtonWriteInsideRight, ButtonExit
XML = gtk_builder_new()
SCOPE
DIM AS GError PTR meld
IF 0 = gtk_builder_add_from_file(XML, "gtk_Text_View.glade", @meld) THEN
WITH *meld
?"Error (GTK-Builder):"
?*.message
END WITH
g_error_free(meld)
END 2
END IF
END SCOPE
MainWindow = gtk_builder_get_object(XML, "MainWindow")
TextView_Left = gtk_builder_get_object(XML, "TextView_Left")
TextView_Right = gtk_builder_get_object(XML, "TextView_Right")
ButtonLeftToRight = gtk_builder_get_object(XML, "ButtonLeftToRight")
ButtonRightToLeft = gtk_builder_get_object(XML, "ButtonRightToLeft")
ButtonWriteInsideLeft = gtk_builder_get_object(XML, "ButtonWriteInsideLeft")
ButtonWriteInsideRight = gtk_builder_get_object(XML, "ButtonWriteInsideRight")
ButtonExit = gtk_builder_get_object(XML, "ButtonExit")
'End Define Var and Objects
'Now we ave to make the Handler
SUB on_ButtonLeftToRight_clicked CDECL ALIAS "on_ButtonLeftToRight_clicked" ( _
BYVAL menuitem AS GtkMenuItem PTR, _
BYVAL user_data AS gpointer) EXPORT
END SUB
SUB on_ButtonRightToLeft_clicked CDECL ALIAS "on_ButtonRightToLeft_clicked" ( _
BYVAL menuitem AS GtkMenuItem PTR, _
BYVAL user_data AS gpointer) EXPORT
END SUB
SUB on_ButtonWriteInsideLeft_clicked CDECL ALIAS "on_ButtonWriteInsideLeft_clicked" ( _
BYVAL menuitem AS GtkMenuItem PTR, _
BYVAL user_data AS gpointer) EXPORT
END SUB
SUB on_ButtonWriteInsideRight_clicked CDECL ALIAS "on_ButtonWriteInsideRight_clicked" ( _
BYVAL menuitem AS GtkMenuItem PTR, _
BYVAL user_data AS gpointer) EXPORT
END SUB
SUB on_ButtonExit_clicked CDECL ALIAS "on_ButtonExit_clicked" ( _
BYVAL menuitem AS GtkMenuItem PTR, _
BYVAL user_data AS gpointer) EXPORT
end
END SUB
gtk_builder_connect_signals(XML, 0)
gtk_widget_show_all(GTK_WIDGET(MainWindow))
gtk_main()
g_object_unref(XML)
And here the XML Glade File
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="MainWindow">
<property name="can-focus">False</property>
<child>
<object class="GtkFixed">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkScrolledWindow" id="Scroll_Left">
<property name="width-request">200</property>
<property name="height-request">200</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="TextView_Left">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
<packing>
<property name="x">5</property>
<property name="y">25</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="Scroll_Right">
<property name="width-request">200</property>
<property name="height-request">200</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="TextView_Right">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
<packing>
<property name="x">220</property>
<property name="y">25</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ButtonLeftToRight">
<property name="label" translatable="yes">Left To Right</property>
<property name="width-request">100</property>
<property name="height-request">30</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_ButtonLeftToRight_clicked" swapped="no"/>
</object>
<packing>
<property name="x">10</property>
<property name="y">230</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ButtonRightToLeft">
<property name="label" translatable="yes">Right To Left</property>
<property name="width-request">100</property>
<property name="height-request">30</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_ButtonRightToLeft_clicked" swapped="no"/>
</object>
<packing>
<property name="x">120</property>
<property name="y">230</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ButtonExit">
<property name="label" translatable="yes">Exit</property>
<property name="width-request">100</property>
<property name="height-request">30</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_ButtonExit_clicked" swapped="no"/>
</object>
<packing>
<property name="x">320</property>
<property name="y">270</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ButtonWriteInsideRight">
<property name="label" translatable="yes">Write Right</property>
<property name="width-request">100</property>
<property name="height-request">30</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_ButtonWriteInsideRight_clicked" swapped="no"/>
</object>
<packing>
<property name="x">120</property>
<property name="y">270</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ButtonWriteInsideLeft">
<property name="label" translatable="yes">Write Left</property>
<property name="width-request">100</property>
<property name="height-request">30</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_ButtonWriteInsideLeft_clicked" swapped="no"/>
</object>
<packing>
<property name="x">10</property>
<property name="y">270</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width-request">35</property>
<property name="height-request">25</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Left</property>
</object>
<packing>
<property name="x">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width-request">40</property>
<property name="height-request">25</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Right</property>
</object>
<packing>
<property name="x">220</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
Thank you for your Help
Hello for read GTK_Text_View in FreeBASIC you have to use a syntax like C
Before you have to set the Var and Pointer because you cant read directly the TextView but only the Buffer.
then you have to get the buffer from glade interface
And now using the Iter for know the Offset where start and end the text you can extract the text from buffer
DIM AS GtkTextIter start_, end_
ReadSource_Text is a String variable with * before you can put text from a pointer
End Explanation.
There you have your code with missing part: You can copy and paste inside to your program and compile for see how work