Vala VS Code integration (original) (raw)
Hi,
I installed the Vala extension from Prince Ferro and the Vala language-server and I can successfully compile and run, but I always get the error “The namespace name `Gtk’ could not be found” in the editor. How can I correct this in VS Code ?
Thanks…
foodmonkey (greg simpson) March 18, 2024, 4:30am 2
have you got any sample code?
can you supply the meson build files?
Lennart (Lennart Martens) March 20, 2024, 9:41am 3
I tried the examples / tutorial from the official Vala documentation page.
There were some problems compiling Vala code. I quit learning Vala now, I stay at old C.
foodmonkey (greg simpson) March 26, 2024, 3:11pm 4
I have vala compiling and building in vscode quite well
contact me if you want the instructions
foodmonkey (greg simpson) March 26, 2024, 3:20pm 5
check your meson.build file in your projects “src” directory
you need to add the Gtk dependency in there and then in your code you should have a line that states “using Gtk;”
heres a meson.build file
sources = files(
'MyApp.vala',
'MyAppWindow.vala',
'MyClass.vala',
'MyOtherClass.vala'
)
dependencies = [
dependency('gtk4'),
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('libadwaita-1')
]
executable(
meson.project_name(),
sources,
dependencies: dependencies,
install: true
)
and in your source file
/*
main app for your app
*/
using Gtk;
public class MyApp : Adw.Application {
// Member variables
private GLib.Settings myapp_settings;
private MyApprWindow app_window;
// Constructor
public MyApp () {
Object (application_id: "com.github.xxxx.xxxxx",
flags : GLib.ApplicationFlags.FLAGS_NONE);
}
… etc
system (system) Closed April 25, 2024, 3:20pm 6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.