now using files from oldgtk3 for bootstrapping
This commit is contained in:
parent
8fb8b21a0b
commit
f93cbad581
3 changed files with 113 additions and 21 deletions
40
README.adoc
40
README.adoc
|
|
@ -24,7 +24,7 @@ it should also work for upcoming _GTK4_.)
|
|||
|
||||
https://nim-lang.org/[Nim] is a modern universal programming language.
|
||||
|
||||
https://www.gtk.org/[GTK], also known as the _Gimp Tool Kit_ and now sometimes also called _Gnome Tool Kit_, is a Graphical User Interface library.
|
||||
https://www.gtk.org/[GTK], also known as the _Gimp Tool Kit_ and now sometimes called _Gnome Tool Kit_, is a Graphical User Interface library.
|
||||
|
||||
NOTE: Later we will insert at this location a nice picture of a fancy Nim GTK3 GUI. Such a picture is fine to attract users and indeed is a good motivation.
|
||||
But such pictures are no real evidence for the quality of a GUI toolkit -- the concrete example may look nice, while the toolkit
|
||||
|
|
@ -41,19 +41,28 @@ in the Nim package repository. _Android OS_ is currently not supported by GTK at
|
|||
|
||||
While low level Nim bindings for GTK3 are already available since a few years, this one is an attempt to
|
||||
provide real high level bindings with full type safety, full _Garbage Collector_ (_GC_) support and an idiomatic
|
||||
_Application Programming Interface_ (_API_)
|
||||
_Application Programming Interface_ (_API_).
|
||||
|
||||
The low level bindings available at https://github.com/ngtk3 where generated with the Nim tool `c2nim` directly from the _C_ header files, are already tested
|
||||
with some applications (https://github.com/ngtk3/NEd[NEd Nim Editor], https://github.com/StefanSalewski/nim-chess3[Chess Game])
|
||||
and generally work fine. Indeed missing Garbage Collector support is generally not really a problem, as widgets are generally
|
||||
put into containers and were automatically deleted together with its parents due to GTK's reference counting.
|
||||
Currently there are at least 3 sources of GTK3 bindings for Nim:
|
||||
|
||||
Still there can be some demand for really high level bindings -- so this repository tries to provide them.
|
||||
* https://github.com/ngtk3
|
||||
* https://github.com/StefanSalewski/oldgtk3
|
||||
* https://github.com/StefanSalewski/gintro
|
||||
|
||||
High level GTK3 bindings, as available for many other programming languages like _Python_, _Ruby_ or _D_ already,
|
||||
would have these advantages:
|
||||
ngtk3 was the first attempt to provide GTK3 support for Nim. It contains single repositories for all the GTK related libraries and
|
||||
is not supported by nimble package manager. It was created from GTK 3.20 headers and is now deprecated.
|
||||
|
||||
* full Garbage Collector support -- you should never have to free resources manually
|
||||
oldgtk3 is the port of ngtk3 to GTK 3.22 -- joining all libraries and providing nimble support. Some people may still prefer
|
||||
using oldgtk3. As it is generated with the Nim tool c2nim directly from the C header files without much manual intervention,
|
||||
it should be complete and contain not that much bugs. Missing Garbage Collector support is generally not really a problem, as
|
||||
widgets are generally put into containers and were automatically deleted together with its parents due to GTK's reference counting.
|
||||
|
||||
Still there can be some demand for really high level bindings -- so this gintro repository tries to provide them.
|
||||
|
||||
High level GTK3 bindings, as available for many other programming languages like _C++_, _Python_, _Ruby_ or _D_ already,
|
||||
have these advantages:
|
||||
|
||||
* full Garbage Collector or Destructor support -- you should never have to free resources manually
|
||||
* Widgets are Nim objects, so inheritance and sub-classing can be used
|
||||
* full type safety -- no needs for casts or other unsafe and dangerous operations
|
||||
|
||||
|
|
@ -106,14 +115,14 @@ These basic libraries are already partly tested:
|
|||
* Gtk
|
||||
|
||||
In best case it should be possible to add more GObject based libraries to this list without larger modifications of the generator source code.
|
||||
Unfortunately the bindings for the _cairo_ drawing library provided by {GIR} are only a minimal stub -- later we will have to extend it manually.
|
||||
Unfortunately the bindings for the _cairo_ drawing library provided by {GIR} was only a minimal stub -- we have extend it manually.
|
||||
|
||||
== How to try it out
|
||||
|
||||
Of course you will need a working Nim installation with a recent compiler version and you have to ensure that GTK and related libraries are installed on your system. For some Linux
|
||||
distributions which provide mainly pre-compiled software you may have to also install some GTK related developer files.
|
||||
|
||||
This package now supports the _Nimble Package Manager_, so ideally a plain `nimble install gintro` should do. But as this package does not
|
||||
This package supports the _Nimble Package Manager_, so ideally a plain `nimble install gintro` should do. But as this package does not
|
||||
only provide some plain text files, but uses {GIR} database query on your local computer to generate
|
||||
binding files exactly matching your system, that does not work currently. We have to download the files, compile and execute
|
||||
the `gen.nim` generator program and finally to install the generated bindings modules on your computer as a _nimble package_.
|
||||
|
|
@ -128,6 +137,13 @@ nimble prepare
|
|||
nimble install
|
||||
----
|
||||
|
||||
NOTE: Latest version of gintro package uses some files from oldgtk3 package for bootstrapping. We assume that
|
||||
users of gintro generally are not interested in low level oldgtk3 package, so we try to download only 3 single files
|
||||
from oldgtk3 package. That should work if wget or nimgrab executables are available. If it fails you should
|
||||
get a longer error message which may help you to solve the issue. If that should not work for you, you may
|
||||
copy the old file gintro.nimble.bak to gintro.nimble before calling `nimble prepare`. That would use files from
|
||||
deprecated ngtk3 repository for bootstrapping.
|
||||
|
||||
NOTE: Nimble prepare should run for about 20 seconds, it compiles and executes the generator program `gen.nim`.
|
||||
Unfortunately we can not guarantee that the generator command will be able to really build all the
|
||||
desired modules. The built process highly depends on your OS and installed GTK version. For 64 bit Linux systems
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ skipDirs = @["examples", "tests"]
|
|||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.17.0"
|
||||
requires "nim >= 0.17.2"
|
||||
|
||||
when defined(nimdistros):
|
||||
import distros
|
||||
|
|
@ -33,19 +33,30 @@ proc prep =
|
|||
mkDir("ngtk3")
|
||||
cd("ngtk3")
|
||||
|
||||
exec("git clone https://github.com/ngtk3/nim-glib")
|
||||
exec("git clone https://github.com/ngtk3/nim-gobject")
|
||||
exec("git clone https://github.com/ngtk3/nim-gir")
|
||||
|
||||
cpFile(this / "tests" / "gen.nim", td / wd / "gen.nim")
|
||||
cpFile(this / "tests" / "combinatorics.nim", td / wd / "combinatorics.nim")
|
||||
|
||||
cpFile("nim-glib/src/glib.nim", td / wd / "glib.nim")
|
||||
cpFile("nim-gobject/src/gobject.nim", td / wd / "gobject.nim")
|
||||
cpFile("nim-gir/src/gir.nim", td / wd / "gir.nim")
|
||||
|
||||
cd(td)
|
||||
cd(wd)
|
||||
|
||||
try:
|
||||
exec("wget 'https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/gobject.nim' -O gobject.nim")
|
||||
exec("wget 'https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/glib.nim' -O glib.nim")
|
||||
exec("wget 'https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/gir.nim' -O gir.nim")
|
||||
except:
|
||||
try:
|
||||
exec("nimgrab 'https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/gobject.nim' gobject.nim")
|
||||
exec("nimgrab 'https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/glib.nim' glib.nim")
|
||||
exec("nimgrab 'https://raw.githubusercontent.com/StefanSalewski/oldgtk3/master/oldgtk3/gir.nim' gir.nim")
|
||||
except:
|
||||
echo "For bootstrapping of gintro package we need the low level files gobject.nim, glib.nim and gir.nim."
|
||||
echo "We take these from package oldgtk3. As most gintro users will not need the whole oldgtk3 package"
|
||||
echo "we tried to only download these 3 single files using wget or nimgrab. But that failed."
|
||||
echo "Ensure that wget or nimgrab are available. wget should be available for Unix like systems."
|
||||
echo "Nimgrab should be available in Nim/tools directory. You may compile it with 'nim c -d:ssl nimgrab.nim'"
|
||||
echo "and put it into your search path"
|
||||
echo "For the unlikely case that you have already full oldgtk3 package installed, we will just try to continue..."
|
||||
|
||||
exec("nim c gen.nim")
|
||||
mkDir("nim_gi")
|
||||
exec(td / wd / "gen")
|
||||
|
|
|
|||
65
gintro.nimble.bak
Normal file
65
gintro.nimble.bak
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# Package
|
||||
|
||||
version = "0.2.0"
|
||||
author = "Stefan Salewski"
|
||||
description = "High level GObject-Introspection based GTK3 bindings"
|
||||
license = "MIT"
|
||||
skipDirs = @["examples", "tests"]
|
||||
|
||||
# Dependencies
|
||||
|
||||
requires "nim >= 0.17.0"
|
||||
|
||||
when defined(nimdistros):
|
||||
import distros
|
||||
if detectOs(Ubuntu) or detectOs(Debian):
|
||||
foreignDep "libgtk-3-dev"
|
||||
elif detectOs(Gentoo):
|
||||
foreignDep "gtk+" # can we specify gtk3?
|
||||
#else: we don't know the names for all the other distributions
|
||||
# foreignDep "openssl"
|
||||
|
||||
import ospaths
|
||||
|
||||
proc prep =
|
||||
let this = thisDir()
|
||||
let td = getTempDir()
|
||||
cd(td)
|
||||
let wd = "gintrosalewski"
|
||||
if dirExists(wd):
|
||||
quit("gintro: tmp directory already exists!")
|
||||
mkDir(wd)
|
||||
cd(wd)
|
||||
mkDir("ngtk3")
|
||||
cd("ngtk3")
|
||||
|
||||
exec("git clone https://github.com/ngtk3/nim-glib")
|
||||
exec("git clone https://github.com/ngtk3/nim-gobject")
|
||||
exec("git clone https://github.com/ngtk3/nim-gir")
|
||||
|
||||
cpFile(this / "tests" / "gen.nim", td / wd / "gen.nim")
|
||||
cpFile(this / "tests" / "combinatorics.nim", td / wd / "combinatorics.nim")
|
||||
|
||||
cpFile("nim-glib/src/glib.nim", td / wd / "glib.nim")
|
||||
cpFile("nim-gobject/src/gobject.nim", td / wd / "gobject.nim")
|
||||
cpFile("nim-gir/src/gir.nim", td / wd / "gir.nim")
|
||||
|
||||
cd(td)
|
||||
cd(wd)
|
||||
exec("nim c gen.nim")
|
||||
mkDir("nim_gi")
|
||||
exec(td / wd / "gen")
|
||||
let mods = listFiles("nim_gi")
|
||||
for i in mods:
|
||||
let j = i[7 .. ^1]
|
||||
cpFile(i, this / "gintro" / j)
|
||||
cd(td)
|
||||
rmDir(wd) # cleanup
|
||||
|
||||
task prepare, "preparing gintro":
|
||||
#before install:
|
||||
|
||||
echo "preparing gintro"
|
||||
prep()
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue