Vala

GLib.Notification and Gnome-shell

纵然是瞬间 提交于 2019-12-11 10:27:10
问题 I'm trying to make use of the GLib.Notification api in Synapse project https://code.launchpad.net/~jeremy-munsch/synapse-project/fix-notification/+merge/273323 It is working on some DE, except gnome-shell. My implementation is basically this : var notification = new GLib.Notification (_("Synapse - Pastebin")); notification.set_body (msg); var gicon = GLib.Icon.new_for_string ("synapse"); notification.set_icon (gicon); GLib.Application.get_default ().send_notification (null, notification); I

Vala can't find gtk+-3.0 Ubuntu 12.04

放肆的年华 提交于 2019-12-11 09:24:16
问题 I'm just starting to learn Vala (under Ubuntu 12.04), and I'm attempting to follow this tutorial; however, at the very first compilation step ( valac --pkg gtk+-3.0 gtktut.vala ), I receive this error: error: gtk+-3.0 not found in specified Vala API directories or GObject-Introspection GIR directories I can't seem to find any information about this on the Internet except that it may mean I don't have the GTK3 .vapi file (there is none in my /usr/share/vala/vapi directory); however, I can't

Gtk.DrawingArea blank when attached to Gtk.Grid

Deadly 提交于 2019-12-11 09:11:30
问题 (This is my first post, sorry if I do something wrong...) I am writing a program in Vala with which one can design a classroom. I have decided to use GTK for the GUI (Vala integrates well with this), and Cairo to draw the classroom diagram (GTK comes with this by default). I have created a 'classroom' class (a subclass of Gtk.DrawingArea), which currently should just display a square: public class Classroom : DrawingArea { private delegate void DrawMethod(); public Classroom() { this.draw

How can I monitor the ~/.local directory using Vala?

允我心安 提交于 2019-12-11 06:28:25
问题 I am trying to monitor the ~/.local directory according to the Vala documentation I can monitor the home correctly. but I can't monitor the the ~/.local. initFileMonitor V1: public void initFileMonitor(){ try { string homePath = Environment.get_home_dir(); string filePath = homePath + "/.local"; File file = File.new_for_path(filePath); FileMonitor monitor = file.monitor_directory(FileMonitorFlags.NONE, null); print ("\nMonitoring: %s\n", file.get_path ()); monitor.changed.connect ((src, dest,

Vala: Disconnecting signal handler via Handler ID from class destructor fails - Why?

主宰稳场 提交于 2019-12-11 05:29:37
问题 I'm trying to get my head around what a good practice for inter-class signals in Vala is. Somehow, there seems to be absolutely no documentation available on this topic. After learning how to connect signals to handlers weakly, the question remains, how that connection is best to be dropped, when the signal handler is destroyed. Lets consider a simple example. We have two classes, Foo and Bar , where an instance of Bar emits a signal bar_signal , that is handled by an instance of Foo .

How does string interpolation / string templates work?

…衆ロ難τιáo~ 提交于 2019-12-11 04:15:40
问题 @lf_araujo asked in this question: var dic = new dict of string, string dic["z"] = "23" dic["abc"] = "42" dic["pi"] = "3.141" for k in sorted_string_collection (dic.keys) print (@"$k: $(dic[k])") What is the function of @ in print(@ ... ) and lines_add(@ ...)? As this is applicable to both Genie and Vala, I thought it would be better suited as a stand-alone question. The conceptual question is: How does string interpolation work in Vala and Genie? 回答1: There are two options for string

Idris: How do I call Idris function from Vala/C and return a string back to C/Vala

≯℡__Kan透↙ 提交于 2019-12-11 00:15:32
问题 I have this toy project: For the UI I use Vala code that is compiled to C. So I can display a message in UI that comes from Idris. Both on Idris ans Vala/C side I have this method that sets the pointer to the Idris function. So in Vala code you can see: global::afni = fn; that sets a global variable with a pointer to Idris the function. Later in another Vala method I call: int res = global::afni(0); string da_label = @"blah $res"; Gtk.Label label = new Gtk.Label (da_label); So I call comFn

Vala interface generics compiler error

不想你离开。 提交于 2019-12-10 20:59:38
问题 I have the following small example(vala 0.18.1): namespace Learning { public interface IExample<T> { public abstract void set_to(T val); public abstract T get_to(); } public class Example : Object, IExample<double> { private double to; public void set_to(double val) { to = val; } public double get_to() { return to; } public string to_string() { return "Example: %.5f".printf(to); } } public class Test { public static void main(string[] args) { stdout.printf("Start test\n"); Example ex = new

How can I use gettext in vala?

ⅰ亾dé卋堺 提交于 2019-12-10 16:47:30
问题 When I try to use gettext in vala I get not errors or warnings from vala but I get the following error from the c compiler: /usr/include/glib-2.0/glib/gi18n-lib.h:29:2: error: #error You must define GETTEXT_PACKAGE before including gi18n-lib.h. Did you forget to include config.h? How can I fix this? 回答1: To solve this problem I had to both add -X -DGETTEXT_PACKAGE="..." to the valac command and add const string GETTEXT_PACKAGE = "..."; to the top of my source file. If I don't add that to the

How can I import other files in Vala?

限于喜欢 提交于 2019-12-08 21:14:42
问题 The question pretty much says it all- how could I import file2.vala to file1.vala ? 回答1: You don't do it directly. If you run valac file1.vala file2.vala , it is as if you compiled them in one big file. If you want to make them reusable, then you probably want a shared library. In which case, you compile one to produce a C header file and a VAPI definition: valac --vapi file1.vapi -H file1.h --library libfile1.so file1.vala The second one can then consume this: valac --pkg file1 file2.vala