Page 1 of 2

Vala programming

Posted: 28 Aug 2013, 07:35
by simargl
In this topic I will post links to some of Vala tutorials and samples for beginners like myself. When I notice something interesting will make addition here. Bellow are links to elementaryos blog and two simple Vala applications with detailed description for every line.

Blog Lazarski.me — elementary os
Part2 Hello Vala!
Part3 Hello GUI!

Index of examples:

Re: Vala programming

Posted: 24 Oct 2013, 09:06
by simargl
Testing new HeaderBar widget from gtk 3.10

headerbar.tar.gz
(4.99 KiB) Downloaded 946 times

Image

Re: Vala programming

Posted: 07 Nov 2013, 12:42
by simargl
Gtk.Stack sample in Vala with animated transition.

stack.tar.gz
(5.24 KiB) Downloaded 927 times

Image

Re: Vala programming

Posted: 28 Jan 2014, 03:26
by rgb1
Hey simargl, could you post some more vala documentation sources here and some tips and guides if possible. It would be appreciated.

Re: Vala programming

Posted: 28 Jan 2014, 14:45
by simargl
Hi, on valadoc.org you will find needed source to begin with. For example I use this as starting point script for any future program or just to test something - it will make empty 200x200 window.

Code: Select all

// valac test.vala --pkg gtk+-3.0 --target-glib=2.38

using Gtk;

class program : Gtk.Window
{
  public program()
  {
    var window = new Gtk.Window();
    window.window_position = WindowPosition.CENTER;
    window.set_default_size(200, 200);
    window.show_all();
    window.destroy.connect(Gtk.main_quit);
  }
 
  public static int main (string[] args)
  {
    Gtk.init(ref args);
    new program();
    Gtk.main();
    return 0;
  }
}

Then you could add stuff to it, for example one button and label, or two buttons bellow or beside each another, attach them to Grid, add callback methods to change label when that button is clicked, etc.

Re: Vala programming

Posted: 29 Jan 2014, 03:21
by rgb1
Thank you for the template. I also found a large amount of samples on the wiki.gnome.org

Re: Vala programming

Posted: 29 Jan 2014, 20:33
by efgee
Just be aware that some documentation is old and not updated.
(especially information in regards to Vala code).

BTW:
I'm trying to get to get GetDesktopAppInfo to work properly with Vala but any attempts to find proper Vala documentation about this was not satisfying.
What I tried to do is to use the AppInfo stuff working so I could get the app information off the ".desktop" file for an app-start application I'm working on for alphaOS. (would look similar to Gnome's implementation, not as fancy looking though...)

Trying to create more alphaOS apps that hopefully could improve alphaOS adoption by more users...

Re: Vala programming

Posted: 19 Mar 2014, 17:43
by simargl
Text viewer/editor with tabs - experiment.
Problem with this: filename variable is read from the current tab label, that means tab label must contain whole file path, and if it's too long it looks ugly. Except of that it works. Depends on Gtk3, uses Gtk.TextView so there is no support for syntax highlight. There must be better way to get filename from the currently active tab.
Image
notebook-editor-test.tar.gz
(10.58 KiB) Downloaded 840 times

Re: Vala programming

Posted: 20 Mar 2014, 00:47
by efgee
simargl wrote:Text viewer/editor with tabs - experiment.
Problem with this: filename variable is read from the current tab label, that means tab label must contain whole file path, and if it's too long it looks ugly. Except of that it works. Depends on Gtk3, uses Gtk.TextView so there is no support for syntax highlight. There must be better way to get filename from the currently active tab.


Use a dynamic array or a linked list for that.
The array/list holds filename with the whole path.
Correlate the array/list index with the tab index.
Something like that becomes tricky when tabs are closed and don't exist anymore.

If the array/list can hold a struct you could have a struct with two strings:
one for the tab and one for the window.

Tab only shows the file name (no path).
The title of the window could show the active filename with the whole path.

Re: Vala programming

Posted: 13 Apr 2014, 19:15
by Scooby
Anybody know how to get fixed character width font in a vala TextView?