Vala

Equivalent term for 'receiver' in languages not Objective-C

时光毁灭记忆、已成空白 提交于 2020-01-14 12:42:27
问题 In Objective-C when you have [A something] A is referred to as the 'receiver'. I am wondering what the equivalent term is in other object-orientated languages, particularly method calling ones as opposed to message passing ones. Caller/Callee refers to the actual methods themselves I think, not the object. Also I'm not sure about 'instance' as in the language I'm working with, Vala, you can actually call methods on structs and namespaces, which you wouldn't classify as objects or instances.

What is the syntax for nested generic types in Genie?

狂风中的少年 提交于 2020-01-11 11:34:12
问题 I want to declare a HasTable with string as it's key and array of int as it's value: [indent=4] init var h = new HashTable of string, array of int (str_hash, str_equal) h["a"] = {1, 2, 3} h["b"] = {5, 6, 7} Error message: nested_generic_types.gs:4.27-4.28: error: syntax error, expected line end or semicolon but got `of' var h = new HashTable of string, array of int (str_hash, str_equal) So the double of seems to confuse valac here. What is the proper syntax? 回答1: The error message is diffrent

Can't set CSS to specified widget in GTK+

白昼怎懂夜的黑 提交于 2020-01-03 04:21:12
问题 I'm using Vala with GTK+ and now I'm trying to add custom CSS to specified widget. I can add fe. backgroudn to GtkWidget but not for #sidebar #sidebar { //It doesn't work color: white; } GtkWindow { // It works background-color: red; } I'm adding class to widget like that: sidebar = new Gtk.Label("Hello"); sidebar.set_name("sidebar"); And it's changes color to GtkWindow, but not for this label. Any ideas? 回答1: I haven't programmed in Vala, but you should add class to StyleContext. This is in

Is OS detection possible with GLib?

谁说我不能喝 提交于 2019-12-31 03:19:30
问题 Is it possible to determine on which platform (GNU/Linux, Win32, OS X) my Vala app is running? 回答1: As Vala is a compiled language (as opposed to intermediate or interpreted) you can determine the platform using your favorite build tool and use conditional compilation. Something like: #if WINDOWS message ("Running on Windows"); #elif OSX message ("Running on OS X"); #elif LINUX message ("Running on GNU/Linux"); #elif POSIX message ("Running on other POSIX system"); #else message ("Running on

How do Valas closures map to Genie?

与世无争的帅哥 提交于 2019-12-30 06:41:25
问题 The Vala Tutorial has an example about DBus using anonymous methods. Bus.own_name (BusType.SESSION, "org.example.DemoService", /* name to register */ BusNameOwnerFlags.NONE, /* flags */ on_bus_aquired, /* callback function on registration succeeded */ () => {}, /* callback on name register succeeded */ () => stderr.printf ("Could not acquire name\n")); /* callback on name lost */ I am trying to rewrite this code in Genie, but could not manage to convert the two last lines. The Genie Tutorial

How can I change the font size of a Gtk.Label in vala?

青春壹個敷衍的年華 提交于 2019-12-29 07:22:08
问题 I'm a Vala/Gtk newbie and I'm trying to change the font size of a Gtk.Label, but I can't find a good way to do it. I find out that I can use the markup like this : var welcome_message = new Gtk.Label ("<span size='17000'>Hello</span>"); welcome_message.set_use_markup (true); But it seems a little hackish. What is the right way to do it ? 回答1: You could try with css, I think lately this is the preferred way. Give your label a class, then load a css. If you are going to change the font size of

How can I change the font size of a Gtk.Label in vala?

浪尽此生 提交于 2019-12-29 07:21:01
问题 I'm a Vala/Gtk newbie and I'm trying to change the font size of a Gtk.Label, but I can't find a good way to do it. I find out that I can use the markup like this : var welcome_message = new Gtk.Label ("<span size='17000'>Hello</span>"); welcome_message.set_use_markup (true); But it seems a little hackish. What is the right way to do it ? 回答1: You could try with css, I think lately this is the preferred way. Give your label a class, then load a css. If you are going to change the font size of

Vala: How to retrieve the names of all files in a zip archive without unzipping it?

萝らか妹 提交于 2019-12-25 08:13:51
问题 Is there any function in vala like zip:list_dir in erlang ? I found libgsf, but I don't want to decompress the zip file. 回答1: You can use libarchive . void check_ok (Archive.Result r) throws IOError { if (r == Archive.Result.OK) return; if (r == Archive.Result.WARN) return; throw new IOError.FAILED ("libarchive returned an error"); } int main () { try { var a = new Archive.Read (); check_ok (a.support_filter_all ()); check_ok (a.support_format_all ()); check_ok (a.open_filename ("archive.zip"

Vala: How to retrieve the names of all files in a zip archive without unzipping it?

此生再无相见时 提交于 2019-12-25 08:10:08
问题 Is there any function in vala like zip:list_dir in erlang ? I found libgsf, but I don't want to decompress the zip file. 回答1: You can use libarchive . void check_ok (Archive.Result r) throws IOError { if (r == Archive.Result.OK) return; if (r == Archive.Result.WARN) return; throw new IOError.FAILED ("libarchive returned an error"); } int main () { try { var a = new Archive.Read (); check_ok (a.support_filter_all ()); check_ok (a.support_format_all ()); check_ok (a.open_filename ("archive.zip"

Vala/Clutter texture loading with thread

有些话、适合烂在心里 提交于 2019-12-25 04:15:37
问题 I am trying to load image files in vala/clutter while running a timeout animation, using "image.set_load_async" stops the animation for a while when the file loads are requested. This is the source: // valac --thread --pkg clutter-1.0 --pkg=gio-2.0 test_1.vala -o test_1 using Clutter; class SlideImage : Clutter.Actor { protected Texture image = new Texture (); public int loaded = 0; public SlideImage (string file) { try { loaded = 1; image.set_load_async (true); image.load_finished.connect((t