Closed feinap closed 1 year ago
Thank you for posting the issue, feinap.
In the tutorial, I wanted to show that a gresource (resources.c) can be used instead of a file or string. And using Gresource is the best way.
The source files are in src/tfe
.
So, I'd like you to clone the repository and use the files in this directory.
$ glib-compile-resources tfe3.gresource.xml --target=resources.c --generate-source
$ bash comp tfe3_r
$ ./a.out taketori.txt
Then a window appears.
The file comp
is a shell file.
$ cat comp
gcc `pkg-config --cflags gtk4` $1.c `pkg-config --libs gtk4`
It runs gcc with the above options.
Actually, I still don't get what you did.
But, the resources.c you wrote was probably OK.
So, a problem may be in tfe3_r.c
or compilation.
Try the way above and check your tfe3_r.c
with src/tfe/tfe3_r.c
.
Further question is also welcome.
I mean, shouldnt we write like this to use gresource:
#include "resources.c"
... ... ...
... ... ...
//build = gtk_builder_new_from_resource ("tfe3.ui");
build = gtk_builder_new_from_resource ("resources.c");
... ... ...
... ... ...
When i am using build = gtk_builder_new_from_resource ("tfe3.ui");
, we are still dependent to .ui file, yes it works very well. But we are creating a .c file from .ui, but we didnt use it in the code, just inculuded "resources.c" but actually we didnt need it at this point.
The resource compiler creates a resource from tfe3.ui.
So the content of the resource is the same as tfe3.ui.
And the resource is registered in a certain area of the executable file a.out
.
The resource can be accessed with the resource path (not file system path).
In the example tfe3_r.c
, /com/github/ToshioCP/tfe3/tfe3.ui
is the resource path.
Therefore,
build = gtk_builder_new_from_resource ("resources.c");
doesn't work.
For more information, see Gio documentation.
It seems that no further questions will be posted. The issue is now closed.
In the end of section 9 you are creating a resources.c file with gresource but in tfe3_r.c, you are not using it.
U still pointing previously created ui file. What is the point here? And after getting resource.c and compiling it with tfe3_r.c, im getting
The code is in resources.c:
if i comment out second definition, programs builds and run but i didnt understand what is the problem here.