Questions tagged [vala]

Vala is an object-oriented programming language that allows modern programming techniques to be used to write applications that run on the GNOME runtime libraries, particularly GLib and GObject. Vala is syntactically similar to C#, and is compiled to C which is then compiled to a native binary using the C compiler of the platform.

Filter by
Sorted by
Tagged with
0 votes
0 answers
33 views

Write into stdin, read from stdout Subprocess/Process in Glib/GTK Vala

I have a test bash/sh script. It simply shows a question and reads answer from console, then it shows output: #!/bin/bash # Ask the user for their name echo Hello, who am I talking to? read varname ...
user1078796's user avatar
0 votes
0 answers
25 views

How do I make a Gtk4 application with a menu bar in Vala?

I attempted to make a simple Gtk4 application, and I tried to add a menu bar with a menu that does two things: print “Hello, World” and quit. The code compiles as expected with the command valac --pkg=...
AthanasiusOfAlex's user avatar
0 votes
1 answer
50 views

gtk4 styleprovider vs set_css_classes

What is the current correct way to use css in Gtk 4.12.3 wayland? Am getting conflicting information about StyleContext, where some docs say its depreciated, while others say its OK for the Display. I'...
stayfrostypeople's user avatar
0 votes
1 answer
216 views

Looking for an example how to use ColumnView in GTK4 with editable cells

I'm looking for any examples of using ColumnView with any kind of model, where each cell will be a EditableLabel which effectively will update the model. I really appreciate any help here :(
Łukasz Grabski's user avatar
0 votes
1 answer
30 views

Replace a paintable with another in vala Gtk4

I want to make my app change image for another when a button is clicked vala with Gtk4. public class Main : Object { public static int main() { var app = new Gtk.Application ("...
xihh's user avatar
  • 169
0 votes
0 answers
27 views

What does the class keyword do to a method in Vala?

I noticed that Gtk.Widget.set_css_name is declared as public class void set_css_name (string name) which makes sense because in C the argument is a GtkWidgetClass* and not a GtkWidget*. This means ...
eyelash's user avatar
  • 3,287
0 votes
0 answers
12 views

Giving vala a variable to function doesn't pass right

Helo, I've the following code: int column2 = 0 + ((z - 1) % 2 * 2); The variable column2 has definitive the value 2. grid.attach(label_name, column2, row2, 1, ...
ubik41's user avatar
  • 13
0 votes
0 answers
106 views

Simple image viewer with Vala and GTK4

I'm trying to code a very simple image viewer component with zoom and pan features. My code looks like this so far: namespace Image { public class ImageViewerPanningArea : Gtk.Widget { ...
Łukasz Grabski's user avatar
0 votes
0 answers
28 views

How to make gstreamer play audio from binary data

I'm trying to play a sound effect whenever a user presses a button. The sound effect is stored in gresource at /org/Adiee5Productions/Title/rsc/sound.wav. I've never used gstreamer before and so far, ...
Adiee5's user avatar
  • 1
0 votes
1 answer
83 views

Gtk4 GridView Vala

I'm trying to make a GridView of images which may or may not be draggable based on context But I'm unable to even make the object as the parameters for the constructor don't make sense to me How do I ...
pp2yttD's user avatar
0 votes
0 answers
32 views

Gtk.ListBox - How to change Text Field from row_activated?

Helo, I have a main window. public class Window : Gtk.ApplicationWindow { [GtkChild] private unowned Gtk.ListBox listbox_jobs; private unowned Gtk.Grid grid_right; There I have a Gtk....
ubik41's user avatar
  • 13
0 votes
1 answer
32 views

JSON Serialize - Modify Resulting Property Name

I am trying to use this library to serialize a class I wrote. Valadoc : gobject_to_data. Suppose I have a class written like this: public class MyObject : Object { public string property_name { ...
Milly's user avatar
  • 1
1 vote
0 answers
413 views

How can I install and import a shared library using the Meson Build system and Vala?

The Problem I am currently studying app development with Vala using GTK and Libadwaita. As there are patterns I will need in many of my apps, I want to create a shared library. So I created a library ...
user avatar
0 votes
1 answer
41 views

How to resolve X11 event type originating in root window in Vala?

I am trying to resolve the type of an event originating in the X11 root window from a Vala GTK application. The problem I'm having is that I can only ever see GDK_NOTHING for the to_string conversion ...
migdsb's user avatar
  • 687
0 votes
0 answers
54 views

Looking for something like exec() in vala

In vala, there is the command Process.spawn_command_line_sync(). But my problem is that I want to use libreoffice to convert an .odt file to .pdf. So i need all the programs in /usr/bin. The command ...
ubik41's user avatar
  • 13
0 votes
1 answer
82 views

Why Vala Compiler Throws Errors When Using Question Mark (?) Operator?

I tried to build G4Music (https://gitlab.gnome.org/neithern/g4music) following its instructions but I got many syntax errors. As you can see GTK-4.0 is marked as not found. However I have installed ...
jplc's user avatar
  • 354
0 votes
0 answers
33 views

Why does GLib.File.new_for_uri (url) fail in vala but not whilst using the same url with curl

Why does the following fail with uncaught error: HTTP Client Error: Forbidden (g-io-error-quark, 14): static int main (string[] args) { string url = "https://www.netfilter.org/projects/...
Wayne's user avatar
  • 914
0 votes
1 answer
47 views

How do I get this code to update every 5 minutes?

So, I have this code for monitoring some stats of my laptop and I just wanted it to live update but after days trying I'm kind of giving up, here's the part of the code I want to update, feel free to ...
Azure's user avatar
  • 1
0 votes
1 answer
110 views

How do I use Gio library in Vala?

I'm building a Gtk application in Vala and would like to use the Gio library and more specifically the g_app_info_get_all() function. I am able to achieve this in C as follows: #include <gtk/gtk.h&...
AbP's user avatar
  • 35
0 votes
1 answer
72 views

How to retrieve current color from a Cario Context in Vala?

I need to retrieve the current color before applying a new color so that later on I can replace it back. var old_color = ctx.something ()? ctx.set_source_rgb (new_color.r, new_color.g, new_color.b);// ...
Wayne's user avatar
  • 914
0 votes
1 answer
30 views

How to retrieve the first key from Gee.SortedMap in Vala?

How do I retrieve the first key from Gee.SortedMap in Vala? For example if I have Gee.SortedMap<int, string> foo = new Gee.TreeMap<int, string> (); I want to get the first key, i.e. the ...
Wayne's user avatar
  • 914
0 votes
1 answer
54 views

How to retrieve struct (boxed) items from Gee.Map in Vala?

I have the following sample code. A Map with (Foo) class items, and a Map with (Bar) struct items: public class Maps { Gee.Map<Foo?, int> map1 = new Gee.HashMap<Foo?, int> (); Gee....
Wayne's user avatar
  • 914
1 vote
1 answer
139 views

Difference between Array and List in Vala

As stated in the title, what is major difference between GLib.Array and GLib.List in Vala language? They look very similar in the tutorial pages.
rnso's user avatar
  • 23.8k
0 votes
1 answer
65 views

How to get source code of a WebPage in Vala

I'm trying to save the source code of a web page (after rendering) in vala using WebKit (I can use only webkit2gtk-4.0 like package) but I'm able only to get the uri. Anyone know how to help me ?
PhRef's user avatar
  • 9
0 votes
1 answer
138 views

Why GtkWidget is not being found

I have following simple application which creates a window with Label, Entry and Button: using Gtk; public static int main(string[] args) { Gtk.init(ref args); var mywin = new ...
rnso's user avatar
  • 23.8k
1 vote
2 answers
54 views

How to install Mx libraries

I am trying Mx toolkit demo code on this page but I get following error: $ valac --pkg mx-1.0 mxgui.vala mxgui.vala:4.7-4.8: error: The namespace name `Mx' could not be found using Mx; ^^ ...
rnso's user avatar
  • 23.8k
1 vote
1 answer
33 views

Why identifier expected with this demo code

I am trying demo code from this page: public class My_combobox{ private Gtk.ListStore liststore; private ComboBox combobox; liststore = new Gtk.ListStore(1, typeof (string)); Gtk....
rnso's user avatar
  • 23.8k
0 votes
1 answer
60 views

Can valac link object files to executable

I have 2 object files from which I want to create an executable. I see that I can do it with gcc as follows: gcc main.vala.o statlib.o -lm -lglib-2.0 main.vala.o is created with valac using command ...
rnso's user avatar
  • 23.8k
0 votes
1 answer
289 views

Why so many undefined references coming [duplicate]

I am trying to call a C function (statslib statistical library) from vala file. My main.vala file is as follows: extern double sum(double[] doublelist, int len); public static void main(string[] ...
rnso's user avatar
  • 23.8k
1 vote
1 answer
51 views

Why `as` keyword is not casting in this code

as keyword is used in Vala for casting as mentioned on this page. I see it being used in following code on this page: FileOutputStream os = ios.output_stream as FileOutputStream; However, it is not ...
rnso's user avatar
  • 23.8k
1 vote
1 answer
61 views

Do Gee collections (libgee) count references to stored data? (Gee and its memory management.)

class ABC { public int a; public int b; public int c; } Gee.HashMap<int, ABC> p; void fn() { p = new Gee.HashMap<int, ABC>(); var x = new ABC(); x.a = 3123; ...
НЕВСКИЙ БЛЯДИНА's user avatar
1 vote
1 answer
178 views

Not able to call C functions from Vala

I am trying to use this C statistics library in Vala. The C file with all statistical functions are in statlib.c. I used method given in a simple example given here. My code is in main.vala, which is ...
rnso's user avatar
  • 23.8k
1 vote
1 answer
67 views

What is @ as part of main function argument

I see following code on this page: int main(string[]@a) {print("Manganese");return 0;} Why it is not following: int main(string[] args) {print("Manganese");return 0;} What ...
rnso's user avatar
  • 23.8k
1 vote
1 answer
139 views

Why filestream.close not available

I see following code example on this Vala documentation page: public static int main (string[] args) { // Opens "foo.txt" for reading ("r") FileStream stream = FileStream....
rnso's user avatar
  • 23.8k
1 vote
1 answer
91 views

Demo Code on main page showing click not found

I am trying to compile demonstration code on the main page of Vala programming language int main (string[] args) { var app = new Gtk.Application( "com.example.App", ...
rnso's user avatar
  • 23.8k
0 votes
1 answer
84 views

Executables not running on double clicking

I am able to compile and create executables with Vala programming language and Gtk. The GUI executables run okay from command line with command: ./myGuiAppl However, when I double click on them in ...
rnso's user avatar
  • 23.8k
2 votes
2 answers
75 views

Why string is not being written to file here

I am trying following code: public static void main(){ var file = FileStream.open("string.txt", "rw"); assert (file != null); try{ file.puts (new DateTime....
rnso's user avatar
  • 23.8k
2 votes
1 answer
176 views

How to use C++ library in Vala

I want to use vega library for working on dicom files. Sample code from its website is as follows: #include <string> #include "vega/dictionary/dictionary.h" #include "vega/dicom/...
rnso's user avatar
  • 23.8k
0 votes
1 answer
271 views

GTK4 Vala - show FileChooserDialog

I am playing around with Vala and GTK4. FileChooserDialog is not working for me using Gtk; int main (string[] argv) { // Create a new application var app = new Gtk....
user1608721's user avatar
0 votes
1 answer
43 views

Why missing generic type arguments here?

I am trying following simple code where a HashTable is created in main and sent to another function. There a list of all keys is to be created and printed: public static void hashtable2list(HashTable ...
rnso's user avatar
  • 23.8k
0 votes
1 answer
43 views

Why segmentation fault in this HashTable code in Vala?

I am trying following code of creating and showing a simple HashTable in Vala: public static void myshowHashTable(HashTable sht){ stdout.printf("Size of sent hashtable: %d", (int)sht....
rnso's user avatar
  • 23.8k
0 votes
1 answer
187 views

error: field ‘parent_instance’ has incomplete type GtkLabel parent_instance;

Problem: I want to make a Gtk.Label child but it seems I cannot make a child of that type. I checked here to find a possible fix, but I cannot get my head around it. What should I do in my case to fix ...
Vysp3r's user avatar
  • 37
0 votes
1 answer
55 views

How to connect GtkModelButton

Helo, I've got the following .ui file: <child> <object class="GtkModelButton" id="button_neworder"> <property name="can_focus">True</property&...
ubik41's user avatar
  • 13
1 vote
0 answers
84 views

Why an array of structs containing a pointer member has to be const?

This question actually arose when I was using the OptionEntry struct which happens to have a void* field. So the example below is not too hypothetical. struct Item { public string name; public ...
semicolon's user avatar
0 votes
1 answer
328 views

Setting Test Environment Variables With Vala and Meson

Hello Stackoverflow Community, So I am trying to set environment vars for a database test in a vala project, but I can't find evidence of the variable anywhere. I also tried setting command line args ...
BQPIncomplete's user avatar
0 votes
1 answer
118 views

How to use GCrypt AES128 in Vala?

I tried with this code but the result is not as expected, maybe I am wrong somewhere, please help. gcrypt.vapi from: https://gitlab.gnome.org/GNOME/vala-extra-vapis using GCrypt; using Posix; void ...
ThinhBuzz's user avatar
2 votes
2 answers
796 views

Vala - How to set color of Gtk4.Label programatically?

I have a Gtk4 Gtk.Label. I want to change it's color & size attribute programatically. The markup way <span foreground='red' size='large'> is easy to use. But after some time, I want to ...
eminfedar's user avatar
  • 620
1 vote
1 answer
315 views

Vala - Bytes convert to string?

I have a GLib.Bytes object. I want to print it and use it as a string like this: Bytes bytes = new Bytes({65, 66, 67}); print(bytes); // <-- ERROR How can I convert it to string?
eminfedar's user avatar
  • 620
1 vote
1 answer
185 views

Vala - How to join string[] to string?

I have a string array: string[] arr = {"Hello", "World"}; I want to print it or convert it to a string like: print(arr.join(",")); > "Hello,World" How can ...
eminfedar's user avatar
  • 620
0 votes
1 answer
103 views

How to pass widget and data from one file to another file in different class?

Beginner-level questions. I’m creating a counter application (first application from The 7 Tasks). I created this application in one file and it is working fine. Following is the code. class ...
Kiran's user avatar
  • 448

1
2 3 4 5
20