-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macro cant choose what to use gtk4.Window00 or adw.Window00 when using connect signal with LibAdwaita #188
Comments
Have you tried without import std/with |
Yes, I can reproduce it without the use of the with module. I have to investigate the mconnect macro, will see if we can somehow prefix the low level types with the module name. |
That seems to be a hard problem. We have not only to add module prefixes in the mconnect macro, but also for all the types in the gisup files. I already tried, but then it stops working. So this seems to be a task that takes more than one weekend... A different approach would be to rename types from adwaita module, e.g. AdwWindow and such. I guess this will be additional necessary, to prevent name conflicts. We did such a renaming already in early days for one type, I think it was GApplication. Without that rename we had to always use "import gio except Application". But we should try to fix the mconnect macro too. |
You may have seen https://discourse.gnome.org/t/is-someone-using-libadwaita-or-knows-what-it-is/7899/3 So the recommended fix is really to use full module prefixes for all data types used in the mconnect macro. Fixing gimplgob.nim seems to be not that hard. But we have to fix the generation of the gisup files too, which then should contain lines like
with that manually edited line I get your program to compile and run, after fixing proc windowOnClose() to return a bool, and glib import. import gintro/[gtk4, gdk4, gobject, glib, gio, pango, adw]
import std/with
proc windowOnClose(self: PreferencesWindow, mainWindow: adw.ApplicationWindow): bool =
echo "windowOnClose"
mainWindow.close()
return gdk4.EVENT_PROPAGATE # window will not close with gdk4.EVENT_STOP
proc activate(app: gtk4.Application) =
adw.init()
let mainWindow = adw.newApplicationWindow(app)
let
window = adw.newPreferencesWindow()
window.connect("close_request", windowOnClose, mainWindow)
with window:
# add createPage(window)
title = "Main"
defaultSize = (100, 400)
show
proc main() =
let app = newApplication("org.gtk.example")
app.connect("activate", activate)
discard run(app)
main() With return gdk4.EVENT_PROPAGATE window can be closed, but program continues to run. So it seems that you have to do some investigations how libadwaita is used correctly. I think two years ago I was not able to find examples at all. I hope I can fix the gisup file generation this weekend. Unfortunately this in a larger and not really easy change. I guess it should work, as gobject-introspection can provide the module names. But we have to change the gen.nim script at many locations, so there is much room for bugs, and we may break other peoples code. At least after that change we will have to do a lot of testing. |
Wanna add this doesnt block me anymore, If it's too hard to solve, it can be postponed for later, or use a simple solution using aliases. And yes, as was said there https://discourse.gnome.org/t/is-someone-using-libadwaita-or-knows-what-it-is/7899/3 adwaita will be used in any new GTK 4 project, its very important lib. P.S. I recently started a new nim GTK Adwaita project https://github.com/gavr123456789/gtk-task-manager, a simple TODO with time tracking, and I really like how fast it turns out to develop an application on Nim GTK, the working version was done to be about 3 hours(a). I think we need to stop sending all newcomers to other frameworks. |
Currently I have the hope that it is not that hard. Have done some investigations this morning. Main task is to fix proc genPars(), which is a very large proc. So first I was disscouraged, but now I have the impression that we have to fix only a few locations. My fear is always that we may break code of the few other gintro users with such larger changes. But I think we should do it. Maybe renaming some ADW types too additional to avoid the except imports. Will try to continue work this evening. |
No, had not worked this weekend, sorry. And the weather was fine here in Germany, so I had to do some sports. It was not that difficult to get all the module prefixes in the gisup files, but then we get the prefixes at many locations in all the modules as well. That does not only look very ugly, but also stops them from working, as a lot substitutions does not work any longer. And main problem, the modules changes so drastically that diff does not work any longer, so we have no clue what is happening and there is a gigantic room for regressions and bugs. So my feeling is, that we have to fix the gen.nim script to really only add prefixes to the gisup files and leave the rest unchanged. Have you already seriously considered using GTK with Rust instead of Nim? My feeling is that the Rust GTK bindings are better, and most importantly we get them for free, because the Rust people do the work for us. Considering all the trouble with Mr. Rumpf I should really look again on some other languages. There is not only Zig, VLang or Jai -- Kotlin is promising and a good choice for Android. But there are many more of course, Julia seems to be interesing and has a really large community already... |
The good news is, that I think that I have successfully modified the gen.nim file so that it creates gisup files with all the module prefixes and leave the modules itself unchanged. I was just going to test that, when I discovered that I have overwritten the modified gimplgobj.nim which I created a week ago with some of the tests I did in the last days. So I have to recreate the new gimplgobj.nim which shall work with full module prefixes tomorrow. Should be not hard, I think I can remember the few fixes I did a week ago. So hopefully I can send you all the files for your testings tomorrow. |
Sorry, we still have an issue with connectArgs.nim example. In gimplgob.nim ats = at.owner.strVal & '.' & at.toStrLit.strVal # v0.9.7 fails for that example. owner seems not to work for "ref O". If you have some good Nim macro understanding, I could ship new gimplgob.nim and gen.nim, and you can try debug yourself. I have not really an idea currently, so it may take some time. I think at least gen.nim works now. For gio.nim and two webkit modules diff shown differences for v0.9.6 and the new ones, but size of modules is identical, so I guess it is only a difference in the order of procs, and not in the content itself. I will try a few hours more to fix gimplgob.nim, and when I don't get it working I will ship it with that bug. |
Well, this seems to compile and work: var ats: string # v0.9.7
if at.kind == nnkRefTy:
ats = at.getType[0].strVal & " " & at.getType[1].owner.strVal & '.' & at.getType[1].strVal
else:
ats = at.owner.strVal & '.' & at.toStrLit.strVal Looks not very nice. Have you a better idea. And I wonder why we need this construct for the optional argument of connect() when argument is a ref type. Maybe we need it elsewhere too? Have to watch Tagesschau in German TV now. Maybe I can really ship it this evening. |
OK, I have decided to ship this fix. Please note that it is not yet the official version 0.9.7, so you have to install it with nimble install gintro@#head Maybe make a backup of the directory ~/.nimble/pkgs/gintro-0.9.6/gintro before. The file changes of this fix are not that large, but still I have some fear that the fix may break some other peoples projects. At least our examples including the SDT tool and Nim-Chess seems to compile and work still. File gimplgobj.nim is changed so that it works with the new gisup files with the module name prefixes:
The changes in gen.nim are not that big, but make the file gen.nim again more ugly:
The diff tools shows still some differences for a few modules:
I was not able to avoid that. Seems to be only the order of the content. Maybe you can do a more detailed content investigation. I have currently no good idea to do that, you may load the output of diff in an editor and then compare lines or blocks to verify that the content is equal. |
thanks, will check tomorrow |
Sorry for late. Have error during install gintro head:
Still can successfully install not head gintro |
Thanks for testing, will investigate that soon. |
Sorry, I can verify your issue easily. Seems that I did some late fixes and forget to do a final test, or maybe did the test with outdated data :-(
It is not really surprising that there are some new issues, as the latest changes for full namespace use in mconnect() macro are not tiny, but it is really bad that I have not tested more carefully. I guess I was too tired, as that latest fix took me 18 hours total, and the latest anger with the Nim management fully demotivated me. I guess you have seen it, e.g. at StefanSalewski/NimProgrammingBook#10 |
I have removed that assert statement in line 980. I think I had un-commented it after doing the last test, and so the error occurred. I think that simple fix is good enough for now. With that fix we get exactly the files that I have tested some days ago. The actual problem are types like cstring, int8 and some more from system module. That types are generated by proc mangleType(). I think it should be very unlikely that these types should generate problems in the mconnect() macro. Theoretical problems could occur, e.g. if another module defines these types too. So a better patch would be to modify proc mangleType() to use an additional boolean parameter that decides if it should return a type name with module prefix or not, and then we would have to check all the locations where the proc is called and had to decide if module prefix is needed or not. Not too much work, but than we have to compile and run all the examples again. I think we can delay that work to a later time, when we have decided if we want to continue Nim and gintro at all. Note you need nimble install gintro@#head still. |
installing gintro@#head now works but my project https://github.com/gavr123456789/gtk-task-manager doesnt build anymore. stack trace: (most recent call last)
/home/gavr/.nimble/pkgs/gintro-#head/gintro/gimplgobj.nim(93, 13) mconnect
/home/gavr/Projects/gtk-task-manager/src/Utils.nim(105, 22) template/generic instantiation of `connect` from here
/home/gavr/.nimble/pkgs/gintro-#head/gintro/gimplgobj.nim(93, 13) Error: node is not a symbol
Tip: 5 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: TaskManager
... Execution failed with exit code 1
... Command: /usr/bin/nim c --colors:on --noNimblePath -d:NimblePkgVersion=0.1.0 --path:'/home/gavr/.nimble/pkgs/gintro-#head' --path:/home/gavr/.nimble/pkgs/print-1.0.1 --hints:off -o:/home/gavr/Projects/gtk-task-manager/TaskManager /home/gavr/Projects/gtk-task-manager/src/TaskManager.nim |
Yes and its terrible, Rust is too low level for GUI programming. |
Thanks for testing. I had the feeling that we may get problems, but the available test does not show it. I assume it is related to the issue which I initially had with the connect_args.nim example, fix was var ats: string # v0.9.7
if at.kind == nnkRefTy:
ats = at.getType[0].strVal & " " & at.getType[1].owner.strVal & '.' & at.getType[1].strVal
else:
ats = at.owner.strVal & '.' & at.toStrLit.strVal I do not really understand the getType() stuff well, the above code was more a guessed fix. I will try to compile your taskmanager and see where the issue is located. Yes, Rust is really low level, I have seen some Rust GTK code and did not liked it. For passing strings to GTK libs they really do some("MyLabel"). But still I think the Rust GTK bindings are the best, Rust GTK may fully replace Vala, which gintro can not do currently, as it uses Proxy objects. And unfortunately the whole GTK community has not grown due to the GTK4 release. And Mr. Bassi has been fired! I have currently not much hope for GTK and for Nim, both seems to shrink instead to grow. Have you seen https://forum.nim-lang.org/t/8590#55874 He is a long time Nim observer and a smart guy, and at least some of his observations are true. |
OK, after installing the print package I can compile your taskmanager: nim c TaskManager.nim revealBtnSetTabName.connect("clicked", openFileEntry, (newTabNameReveal, tabNameEntry)) I was not aware that passing tuples have ever worked. So obviously we have no test for that. Was it not possible to locate the source of the problem for you? Compiler show it as Utils.nim(105, 22) template/generic instantiation of So we have to fix the tuple case in gimplgob.nim somehow. Have you an idea how the tuple optional argument have worked at all? How is it passed? As a ref? And what is its life time, have we to copy it. Well I wrote the mconnect macro in 2016, no one was willing to help, and I was glad that I got a first prototype to work. And basically we have still that first prototype. I really can not believe that tuples have worked, as I have no idea how it can work. But without module name prefixes it was all simpler. I am still not happy with all the module name prefixes for the mconnect macro, as it made all more complicated. And gintro was initially designed to avoid namespaces in a way similar as Nim does it. Works well for ordinary code. But for macros the user seems to have no possibility to specify namespaces. Is some of your Telegram people a real macro wizard? Is that a russian group only? I will not try, as I was told that Telegram is what russian mafia uses, maybe Telegram is not even legal in Germany. Will investigate this issue tomorrow. |
It doesn't really matter to me whether proxy objects are used or not. Of course, nim is an ideal candidate to replace vala because of the ability to directly control the generation of c code (generate gobject the same way vala does it), but this would require enormous effort. The most important thing for any bindings to GTK now is the ability to use GTK 4 and LibAdwaita, the rest is not so important. I agree with all this, but I do not consider critical shortcomings, as for me nim is clearly becoming more popular. For example, the recent kickstarter project Goodboy Galaxy is very impressive. Also judging by the talk from Mamy Ratsimbazafy, nim can be successfully used in production.
All this is absolutely not important compared to what the language has achieved now. It really has three declared parameters Efficient Expressive Elegant. While remaining a high-level language similar to scripting, nim tries very hard to be on par with system languages like Rust and Zig in speed (arc, orc, view with some borrowing etc), unfortunately I do not know other similar languages except maybe Vala, but it has an even smaller community, and a strong lack of libraries. For me, the biggest problem with nim is the IDE support, autocompletion works terribly, renaming just doesn't work, type hints don't work on the variable declaration line, they say that incremental compilation will greatly improve this. |
Ahah, I didn't think I'd meet a person who believes. This is propaganda, as well as the fact that all the hacks in the world are done by Russian hackers. The Russian mafia no longer exists, after the 90s it came to power and has been there for the last 20 years. The government tried to block telegram on the territory of Russia because telegram refused to transfer encryption keys (which do not exist) which resulted in a very funny situation https://meduza.io/en/cards/russia-is-trying-to-block-telegram-but-it-s-failing-why . As a result, they did not succeed, the ban was lifted. Sorry for some offtop here. |
And in case it is not obvious for you: We generally use ref objects when we have to pass multiple values as optional arguments. I think in the past people tried tuples and failed, and I told them to use a ref object. But of course tuple support would be fine, unfortunately I do not know how tuples are passed.
Proxy objects have overhead, and restrictions. I had a discussion with Mr. Droege, The Rust people tried really hard to avoid proxies. When I started gintro in 2016 I could not imagine that avoiding proxies can be possible, and I still have no idea how it may work. It is hard, as Mr. Droege told me. Some months ago a Vala guys, I think a medicinal doctor, tried to do real low level stuff with gintro. Which was not working nice due to the proxies, we should have an issue about that, maybe he closed it.
Unfortunately I have not seen him in the Forum any more since maybe one year. The other Status people are nearly never present in the Forum or IRC. So many people left unfortunately. Of course, Nim is still the best universal languages for me. There are some others for special purpose, Rust for OS development, Julia for nummerics, Kotlin for web. Python for calling C libs. Zig as C replacement. Go as a very restricted something. Vlang and Jai are not really useful yet. Maybe Crystal is closest to Nim. |
There are 2 groups, general (English) and russian, although mostly russians are sitting in the general, but you will never know about it.
In fact, yes, I recently said that I want to study macros in order to do something similar to https://github.com/glurp/nimgtkdsl and I need to find out how to identify all the descendants of an object to find out if it is the heir of Gtk.Box in the computer time, and to my surprise haxscramper gave me a ready-made macro for this: https://t.me/ru_nim_talks/42808 |
Yes, I was just about to write about it, as I mentioned in my tweet where I sorted out all the languages that have GTK bindings now https://twitter.com/gavr123456789/status/1443345004043411456 and https://twitter.com/gavr123456789/status/1443347658467430409
But before that I only knew about the repository https://github.com/jhass/crystal-gobject, now I have found https://github.com/hugopl/gtk4.cr PS I keep a record of all GTK bindings in this repository https://github.com/gavr123456789/GTK-info I really don't like the concentration of the Crystal author on the OOP paradigm. Here 2 issues why I hate crystal design decisions: [RFC] Pipe Operator, Implementation of "lonely operator". I don't like modern Java like OOP at all, I think Nim has an almost perfect paradigm of something between all three procedural functionally and OOP. The only true OOP in my opinion was in Smalltalk. Here is a short article from another Smalltalk fan about Nim http://goran .krampe.se/2014/10/29/nim-and-oo/ |
Yes, I still know GoranKrampe, he was available when I started with Nim in 2014. haxscramper. Yes, I think he is a really smart guy, when you get good contacts to him he may help you with macro stuff. I think there is one more, called ElegantBeef, and of course PMunch. And maybe Yardanico, also from Russia, he is smart, but I am not sure if he uses macros a lot. Will continue investigation the tuple issue later this day. In case that you do not know, my approach to debug gimplgob.nim is to enable the two echo statements for r1 and r2. Then we see what is generated and what is wrong, at least for the case that the macro execution does not crash before. In that case we have to disable a few lines of the macro code before. Another approach is to compile with an option like "expandMacro", that should show the macro stuff too. My guess is, that for the tuple case, we can somehow split the return value from getType(), somehow insert the module namespace prefixes, and join it again. Similar like the code which I provided above, which was needed for the connect_args.nim test file. But of course all that is ugly and guess-work. Maybe some people from your Telegram groups have a better idea. |
Yes, only un-commenting the echo statements does not help much in this case, as the processing terminates early. Issue is the line ats = at.owner.strVal & '.' & at.toStrLit.strVal With
We get as output when compiling
So first question is, how we can best add module name prefixes to such tuples, where tuple can have many components of course, not only two as in your case. And other question is lifetime of the tuple. That seems to be really not that easy. |
And is (Revealer, Entry) a valid data type name at all? I really wonder why tuples may have worked before for you. For other people they seem to have never worked, and I myself never tested tuple at all, as I guessed that there may be a lot of problems. And a plain ref object is so easy :-) Have to do some real work now, sorry. |
Hmm, ofc
Idk, I started to using it from the very beginning. |
Maybe you can make some suggestions (with code examples) how we can support tuples with full namespaces. If you have absolutely no idea, you may ask in the Telegram groups. The only possible solution that I see is writing a lot of macro code -- for tuple constructor case, for real tuples, and then also for array and seq parameters. And all that for value types and ref types. That is really ugly and much room for errors. Maybe there is another way, but I do not see one currently. |
Yesterday I was wondering if maybe only the use of parseStmt() in the mconnect macro is the problem, and if use of "quote do" instead or constructing the whole macro with AST functions only could avoid the namespace problems. But I don't think so. A possible solution is of course that we ignore namespaces for your tuples, like
For most cases that should work, as long as the tuple does not contain a field with a type which generates name space conflicts. At least with that patch your taskmanager would compile, but only when I uncomment #row.add footerBox I have no idea what that is and how that add() has ever worked. There are a lot of such procs in adw module, but all have longer names. Maybe it was an older libadw version? For the tuple case, I would have to check what exactly its lifetime is. Maybe it works? |
Have you already made some progress? I just found some minimal motivation again to test "quote do:" import macros
import gintro/[gtk4, adw]
macro genProc(arg: typed): untyped =
let argType = arg.getType
result = quote do:
proc p(x: `argType`) =
echo typeof(x)
echo sizeof(x)
var s: string
var w: gtk4.Window
genProc(w)
p(w) That compiles for me indeed. So replacing parseStmt() in gimplgob.nim with "quote do" may solve our issue with the namespace of the optional connect() argument. Well I am not really sure, but have some hope at least. Will you be able to do that alone? Maybe it would be better to even avoid "quote do" as I read some years ago that that construct can have issues, so we may construct the full mconnect() directly with AST functions. But I have no idea how difficult that may be, maybe that would take us some weeks fulltime? I really do not know. |
OK, as it is still not clear who is working on a fully rewrite of the mconnect() macro in gimplgobj.nim and when the rewritten macro will arrive, I have added the plain nnkTupleConstr fix. So tuples should work as before as long as the tuples do not contain conflicting types. From the macro generated code we can see that tuples are copied into a ref, so lifetime should be OK. At least your taskmanager compiles now again, when the add() call is commented out. I have done no other tests, but as the tests have not used tuples before, there should be no new problems. nimble install gintro@#head |
Thank you so much.
So |
Unfortunately, I couldn't figure out how gintro works and I don't have the context of the name conflict problem. |
It is just a macro issue, at least it seems so. For fixing it it is not necessary to understand gen.nim. I used in 2016 parseStmt() for mconnect(), as it was that time the only solution that I could work with myself. I can remember that in 2017 or 2018, when I had a problem with that, and I asked on IRC or Forum, Araq just told me not to use string operations and parseStmt, but AST manipulation. Now I understand his advice better. So we can rewrite it to use "quote do" as a first solution, which should be not that difficult. And later rewrite it to use only AST manipulation, which is too hard for me currently. For libadwaita, I recently asked in GTK forum about it. They told me that it is not really released yet. Gentoo Linux does not ship it yet. And I have to learn it still. Let me know if there are still issues like missing symbols. For me it compiles currently, my libadwaita install was 3 weeks ago from git sources. |
It looks like my other project(https://github.com/gavr123456789/Katana/blob/master/REWRITE/widgets/in_to_search_and_reveal.nim#L68 ) has the same problem, > nim r --hints=off katana.nim
/home/gavr/Projects/Katana/REWRITE/gtk_utils/set_file_row_for_file.nim(23, 36) Warning: implicit conversion to 'cstring' from a non-const location: name(fileInfo); this will become a compile time error in the future [CStringConv]
/home/gavr/Projects/Katana/REWRITE/widgets/in_to_search_and_reveal.nim(44, 38) Warning: implicit conversion to 'cstring' from a non-const location: "*" & text(entry) & "*"; this will become a compile time error in the future [CStringConv]
/home/gavr/Projects/Katana/REWRITE/widgets/in_to_search_and_reveal.nim(46, 26) Warning: implicit conversion to 'cstring' from a non-const location: text(entry); this will become a compile time error in the future [CStringConv]
stack trace: (most recent call last)
/home/gavr/.nimble/pkgs/gintro-#head/gintro/gimplgobj.nim(96, 13) mconnect
/home/gavr/Projects/Katana/REWRITE/widgets/in_to_search_and_reveal.nim(68, 8) template/generic instantiation of `connect` from here
/home/gavr/.nimble/pkgs/gintro-#head/gintro/gimplgobj.nim(96, 13) Error: node is not a symbol
gavr@arch ~/P/K/REWRITE (master) [1]> I will try just replace tuple with object now |
That is strange. But maybe not fully unexpected. I said before, that a lot of containers like arrays or sequences are concerned when used for the optional arg, that is why it is so hard to fix. Maybe in that example you are not using a nnkTupleConstr for on the fly tuples, but a readymade tuple, or a ref tuple? I will investigate, maybe I can provide a similar plain patch like before. But we should really rewrite the macro. |
After making 2 replacements of tuples for objects, I managed to compile everything. |
You are using the with macro, that seems to be the issue here. I told all people not to use tuples, but there seems to be a desire to use them. And now that I learned from you that they have worked before, I would like to keep that working, and maybe a few other people are using tuples too. Some people told me that tuples have not worked for them in the past, maybe they have done it different than you do it? The example connect_args.nim was the initial example for passing arguments, and it contained four different cases, which did not contain tuples. That is why I was surprised that tuples have worked at all. So, when we really should decide that we want to continue using Nim and gintro, then we should indeed rewrite the macro. Maybe we can also support arrays and sequences, beside tuples. Maybe even other containers like tables? |
Your initial issue was revealBtnSetTabName.connect("clicked", openFileEntry, (newTabNameReveal, tabNameEntry)) And now entry.connect("search-changed", entryChanged, (fm: fm, searchBar: searchBar)) That is a different tuple construction, and needs a different fix unfortunately. |
I really wonder where you learned that notation. I have never seen that before. When we rewrite it to entry.connect("search-changed", entryChanged, (fm, searchBar)) and do a similar rewrite in file list_view.nim at three locations than nim c main_view.nim compiles fine. I assume that is the main file? Can you tell us where you learned that notation and what the purpose of it is? I may fix the mconnect macro for that case too. |
https://nim-lang.org/docs/tut1.html#advanced-types-tuples person = (name: "Peter", age: 30)
# Person and PersonX are equivalent
personX = person
# Create a tuple with anonymous fields:
personY = ("Peter", 30) |
Ah yes I remember, I read that in 2014, and may have used that notation myself. But now I wonder if the field names have some actual purpose, or are fully redundant. I have to reread the manual, and then I will try to add one more plain fix to the mconnect macro. |
offtop question, but is there a way to create gobjects with properties from gintro? GObject is needed for ListView. ListView works in the Model -> View paradigm, for this it is necessary that all objects of the model support observable in order to re-render the corresponding elements of the list by tracking changes in the model. Each property of GObject is observable by default. There is a default implementation of ListModel - ListStore https://docs.gtk.org/gio/class.ListStore.html which works with GObject. So for creating any list with model of custom objects I need to create a GObject. Its hard to imagine an app that dont use lists |
I think declaring new GObjects with new custom properties is not supported by gobject-introspection directly. In C this is often done with C macros, which we would have to recreate. We did this for oldgtk3 for a few macros. But first we need a small complete C code example so that we can test. |
From manual:
Actually I did not remember the second sentence. I have patched that case also now:
I hope that all your programs compile now. As we two seems to be currently the only gintro users, maybe then it is good enough for now. nimble install gintro@#head |
Now example from the first message here says error: /home/gavr/Projects/gtk-task-manager/sas.nim(14, 9) template/generic instantiation of `connect` from here
/usr/lib/nim/core/macros.nim(540, 92) Error: undeclared identifier: 'gboolean'
candidates (edit distance, scope distance); see '--spellSuggest':
(1, 5): 'boolean' [proc declared in /home/gavr/.nimble/pkgs/gintro-#head/gintro/gobject.nim(1535, 6)] Here new one: import gintro/[gtk4, gobject, gio, pango, adw, glib, gdk4]
import std/with
proc windowOnClose(self: adw.ApplicationWindow, x: string) =
echo x
proc activate(app: gtk4.Application) =
adw.init()
let
window = adw.newApplicationWindow(app)
header = adw.newHeaderBar()
mainBox = newBox(Orientation.vertical, 0)
tabBar = newTabBar()
tabView = newTabView()
tabBar.view = tabView
window.connect("close_request", windowOnClose, "test")
with mainBox:
append header
append tabBar
append tabView
with window:
content = mainBox
title = ""
defaultSize = (100, 300)
show
proc main() =
let app = newApplication("org.gtk.example")
app.connect("activate", activate)
discard run(app)
main() Error: /home/gavr/Projects/gtk-task-manager/sas.nim(19, 9) template/generic instantiation of `connect` from here
/usr/lib/nim/core/macros.nim(542, 16) Error: expression 'windowOnClose(cast[adw.ApplicationWindow](h),
cast[ptr system.string](user_data)[])' has no type (or is ambiguous) |
I told you that your first example was incorrect, and I provided working code:
For your code above, fix is proc windowOnClose(self: adw.ApplicationWindow, x: string): bool =
echo x
return gdk4.EVENT_PROPAGATE So it compiles for me. But indeed guessing the reason for errors is not easy always. |
Oh, I completely forgot. All works for me too. And you're right, it's impossible to figure out how to fix it from such an error message. I think can be closed now, thank you, now its possible to save state of application on close event, to open from the last stage gavr123456789/Dela@ecb4454#diff-d6408b27e7a7e4a9d8fa5aba5b8ffaa82f513000aa85da4f172ff823a9fc2a32R10. |
Here minimal example:
Here I want to main window close when preference window close.
Error:
The text was updated successfully, but these errors were encountered: