ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Is there any documentation on how to create this in Vala? I am clueless, as there is a HUGE lack of documentation on Vala in general, and even the little documentation there is is only partially written, except for this.
I decided to stick to Vala as my beginner's programming language to study, as it includes the necessary content I need (object-oriented, GNOME/GTK friendly) and I am studying it all I can. I am not posting any code right now; I plan to take other members' advice here and slowly write/test code before it goes into a new project.
Again: Any help is appreciated in creating a "Hello World" GTK window using Vala.
I'm not trying to push you, but you can also check out Python (a relatively beginner-friendly language). They have GTK+ bindings for it (and Qt bindings, too).
I'm not trying to push you, but you can also check out Python (a relatively beginner-friendly language). They have GTK+ bindings for it (and Qt bindings, too).
Python (as well as Perl in this case) are wrong choices - because too many forum participants know them.
Instead of python, you should have suggested genie. Compiles like vala, even uses the vala precompiler (or whatever it's called), but looks more like python and is even less well-documented than vala.
Instead of python, you should have suggested genie. Compiles like vala, even uses the vala precompiler (or whatever it's called), but looks more like python and is even less well-documented than vala.
I don't know Vala and never heard of Genie. Mostly because I'm more interested in Qt.
using GLib;
using Gtk;
public class HelloWorld : Object {
public static int main(string[] args) {
Gtk.init(ref args);
var window = new Window(WindowType.TOPLEVEL);
var label = new Label("Hello World");
window.title = "Hello World";
window.set_default_size(640, 480);
window.position = WindowPosition.CENTER;
window.destroy.connect(Gtk.main_quit);
window.add(label);
window.show_all();
Gtk.main();
return 0;
}
}
Except for one problem:
Code:
HelloWorldGtk.vala:2.7-2.9: error: The namespace name `Gtk' could not be found
Is there some library I have to install? I already have libgtk3.0-dev installed.
using GLib;
using Gtk;
public class HelloWorld : Object {
public static int main(string[] args) {
Gtk.init(ref args);
var window = new Window(WindowType.TOPLEVEL);
var label = new Label("Hello World");
window.title = "Hello World";
window.set_default_size(640, 480);
window.position = WindowPosition.CENTER;
window.destroy.connect(Gtk.main_quit);
window.add(label);
window.show_all();
Gtk.main();
return 0;
}
}
Except for one problem:
Code:
HelloWorldGtk.vala:2.7-2.9: error: The namespace name `Gtk' could not be found
Is there some library I have to install? I already have libgtk3.0-dev installed.
Yeah, I kind of figured that Vala didn't know about GTK3 (yet), however, I do know that some programs (e.g. Mutter) that are part of the GNOME Shell JHBuild moduleset actually depend on Vala and have components written in Vala.
And also: If you type:
Code:
using GLib;
at the beginning of the program, you can just type "Object" since the compiler already knows that it's under GLib if you use GLib.
Last edited by Kenny_Strawn; 10-16-2010 at 02:16 PM.
Okay, I also have libgtk2.0-dev installed, so I used it instead. I also found conflicting objects, (GLib.Object and Gtk.Object), so I had to specify "GLib.Object". After that, it compiled successfully. The one thing I like about Vala's error messages is that they're easy for newbies to understand, unlike GCC's. At least so far.
Of course, that doesn't mean I might run into some that aren't so.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.