Vala programming

Programming issues and discussion
simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Vala programming

Postby simargl » 28 Aug 2013, 07:35

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:

simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Re: Vala programming

Postby simargl » 24 Oct 2013, 09:06

Testing new HeaderBar widget from gtk 3.10

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

Image

simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Re: Vala programming

Postby simargl » 07 Nov 2013, 12:42

Gtk.Stack sample in Vala with animated transition.

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

Image

rgb1
Competent
Posts: 37
Joined: 07 Oct 2013, 03:49

Re: Vala programming

Postby rgb1 » 28 Jan 2014, 03:26

Hey simargl, could you post some more vala documentation sources here and some tips and guides if possible. It would be appreciated.

simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Re: Vala programming

Postby simargl » 28 Jan 2014, 14:45

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.

rgb1
Competent
Posts: 37
Joined: 07 Oct 2013, 03:49

Re: Vala programming

Postby rgb1 » 29 Jan 2014, 03:21

Thank you for the template. I also found a large amount of samples on the wiki.gnome.org

efgee
Expert
Posts: 115
Joined: 29 Dec 2013, 20:58

Re: Vala programming

Postby efgee » 29 Jan 2014, 20:33

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...

simargl
Site Admin
Posts: 466
Joined: 16 May 2013, 10:54
Contact:

Re: Vala programming

Postby simargl » 19 Mar 2014, 17:43

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 73 times

efgee
Expert
Posts: 115
Joined: 29 Dec 2013, 20:58

Re: Vala programming

Postby efgee » 20 Mar 2014, 00:47

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.

Scooby
Site Admin
Posts: 826
Joined: 09 Sep 2013, 16:52

Re: Vala programming

Postby Scooby » 13 Apr 2014, 19:15

Anybody know how to get fixed character width font in a vala TextView?


Return to “Scripting and Programming”

Who is online

Users browsing this forum: No registered users and 1 guest

cron