Hi,
I rebuilt my gui in glade and automatically connecting to signals. Therefore I need to use the lowlevel objects (with 00 suffix). Now I have the problem that i need to access the event parameter. Is there any better solution, to work with the gintro highlevel objects?
I've solved it like this:
type
GdkEventButton = object
`type`: ptr gdk.EventType
proc onSelectableMapsButtonPressEvent(self: TreeView00, e: GdkEventButton) {.signal.} =
if e.`type`[] == doubleButtonPress:
echo "Double clicked"
And another question. I've implemented multilingualism into my app. Works fine on linux, but i do not get it working on Windows (I know it's tricky with gettext on windows, but I've no idea anymore). Currently I solved this problem by creating a launcher that starts my gui application after setting the LANG environment variable.
My approach:
when defined(windows):
proc setlocale(category: int, other: cstring): cstring {.header: "<locale.h>", importc.}
var LC_ALL {.header: "<locale.h>", importc.}: int
proc bindtextdomain(domainname: cstring, dirname: cstring): cstring {.dynlib: "libintl-8.dll", importc.}
else:
proc bindtextdomain(domainname: cstring, dirname: cstring): cstring {.header: "<libintl.h>", importc.}
discard bindtextdomain("gui", os.getCurrentDir() / "locale")
disableSetlocale()
discard setlocale(LC_ALL, myLocaleIWantToSet) # Tried this with de_DE.utf8 and German_Germany.1252
[...]
let builder = newBuilder()
builder.translationDomain = "gui" #
Fine that it works at all for you.
Unfortunately I can not really help for both questions, and I am busy with adapting gintro to latest GTK 3.98.3 which will become GTK4. That adaption is some more work than expected, see
https://discourse.gnome.org/t/recent-gtk-3-98-nim-example-fails-to-compile/3262/9
https://discourse.gnome.org/t/g-arg-info-may-be-null-for-the-instace-itself/3284/6
For the second question with multilingualism: When that is a Windows problem then maybe we should ask on the GTK forum.
For glade and automatically connecting to signals, I intended to investigate that for some years already, but never managed to really do it, that is to find time and motivation. Indeed we should try to enable that without the need to access the low level objects, I will try to investigate that topic soon. Personally I do not use Glade and GTK Builder, so I do not know much about both.
Okay, got the multilingualism working on windows.
Gettext calls on windows GetThreadLocale to retrieve locale. Therefore setlocale wont work on windows. Also gettext reads out LANG and LC_ALL environment variables (if one is set, GetThreadLocale wont be called). When running in vscode integrated terminal it wont work, because vscode sets the LANG environment variable -.-
Working example without gtk:
import os
when defined(windows):
import winim
{.passL:"""-LC:\msys64\mingw64\lib -l:libintl.a -l:libiconv.a""".}
proc setlocale(category: int, other: cstring): cstring {.header: "<locale.h>", importc.}
var LC_ALL {.header: "<locale.h>", importc.}: int
else:
import posix
proc bindtextdomain(domainname: cstring, dirname: cstring): cstring {.header: "<libintl.h>", importc, cdecl.}
proc dgettext (domainname: cstring, msgid: cstring): cstring {.header: "<libintl.h>", importc, cdecl.}
discard bindtextdomain("gui", os.getCurrentDir() / "locale")
when defined(windows):
var lcid: LCID = LocaleNameToLCID("de-DE", LOCALE_ALLOW_NEUTRAL_NAMES)
discard SetThreadLocale(lcid)
else:
discard setlocale(LC_ALL, "de_DE")
echo dgettext("gui", "JOIN_CONNECT")