Vala

How to output GStreamer video to Gdk.Pixbuf using Vala?

倖福魔咒の 提交于 2019-12-12 04:53:08
问题 I am using GStreamer 1.0 in my program to play video from file. And I want to output it to Gdk.Pixbuf to add it to Image to display it. But I can't figure out how to use it properly. Here is what I tried to do, but it won't compile: this.pipeline = new Pipeline ("mypipeline"); this.src = ElementFactory.make ("filesrc", "video"); src.set("location", downloadFileName); this.sink = ElementFactory.make ("gdkpixbufsink", "sink"); this.pipeline.add_many (this.src, this.sink); this.src.link (this

How to INSERT information into a Sqlite database using Genie Programming Language?

家住魔仙堡 提交于 2019-12-12 02:26:30
问题 This question is a spin off a previous question here in which a database was created. However, when it comes to add information to that dataset I can go manually adding information or going via a programmatically way. The latter is my choice for a didactic reason. The equivalent of what I am trying to do in python is: for x in cursor.execute(sql): lastid = x[0] # Insert data into the instructions table sql = 'INSERT INTO Instructions (recipeID,instructions) VALUES( %s,"Brown hamburger. Stir

How to repair “error: gdk-pixbuf/gdk-pixdata.h: No such file or directory?”

三世轮回 提交于 2019-12-12 01:37:48
问题 I need to rotate a Pixbuf. The vala code contains using Gst, GLib, Posix, Sqlite, Gdk; public class RotateSaveImage { public void RotateSaveImage(string input, string output) { var img = new Pixbuf.from_file(input); var rotate_image = img.rotate_simple(PixbufRotation.CLOCKWISE); rotate_image.save(output, "jpeg"); } } The makefile contains test_VALAFLAGS = --vapidir=@VAPIDIR@ --pkg gstreamer-0.10 --pkg glib-2.0 --pkg gio-2.0 --pkg posix --thread --pkg gstreamer-app-0.10 --pkg sqlite3 --pkg gtk

Read/write file pipes in vala/glib

霸气de小男生 提交于 2019-12-12 01:13:24
问题 I am using the glib vala function glib.process.spawn_async_with_pipes()(http://references.valadoc.org/#!api=glib-2.0/GLib.Process.spawn_async_with_pipes), which outputs some ints corresponding to stdin, stdout, and stderr. How would I use these pipes in Vala? 回答1: Modified example which also writes stuff to stdin: private static bool process_line (IOChannel channel, IOCondition condition, string stream_name) { if (condition == IOCondition.HUP) { stdout.printf ("%s: The fd has been closed.\n",

Does Vala support self-invoking?

試著忘記壹切 提交于 2019-12-11 21:20:33
问题 Is there any way that Vala supports Self Invoking? Either with a class, or with a method? Javascript supports self invoking like below. Which is what im looking for. (function(){ // some code… })(); I'm attempting to load a class into a hashmap for dynamically loading. 回答1: using Gee; [CCode (has_target = false)] delegate void MyDelegate(); int main() { var map = new HashMap<string, MyDelegate>(); map["one"] = () => { stdout.printf("1\n"); }; map["two"] = () => { stdout.printf("2\n"); };

Genie howto repeat a string N times as an string array

丶灬走出姿态 提交于 2019-12-11 20:35:41
问题 I write this code, repeatc for repeat char to char array. it works. repeats for repeat string N times to an string array. but repeat string to string array core dumped. A, A, A, AB, AB, AB, *** Error in `./untitled': free(): invalid pointer: 0x0000000000400f3d *** .... .... Aborted (core dumped) why? my code: // --cc='gcc' [indent=4] init var carray = repeatc ('A', 3) for i in carray do stdout.printf ("%c, ", i) // A, A, A stdout.putc ('\n') var sarray = repeats ("AB", 3) for i in sarray do

Trouble using HTTP POST with libsoup

北城余情 提交于 2019-12-11 18:23:56
问题 I am trying to log on to my tt-rss server using libsoup. Since version 1.5.3 it only supports HTTP POST to receive data. Basically I only need to do something like this with libsoup: curl -d '{"op":"login","user":"you","password":"xxx"}' http://example.dom/tt-rss/api/ But all the code examples written in vala using POST are outdated and don't compile anymore. For example the last one on this page, Transmission RPC Interface: https://wiki.gnome.org/Projects/Vala/JsonSample Here is my code: var

[genie/vala]: How to Sort using a custom comparator?

余生颓废 提交于 2019-12-11 13:12:38
问题 genie! how to Sort an array (or list) of strings in order of descending length, and in ascending lexicographic order for strings of equal length. my data is datas : array of string = { "cold", "z", "bpples", "pallalala", "apples", "xccv" } 回答1: Genie and Vala's built-in array type is not very friendly since it really a C array underneath. You'd have to use C's qsort function to do it. I would recommend you use a Gee.List instead, which has a nice sort method that takes a comparator: var list

gtk+-3.0 not found issue

跟風遠走 提交于 2019-12-11 12:57:42
问题 I'm writing program using Vala language. When I try to build a .deb package on Launchpad, I get this error CMake can't find valac package gtk+-3.0 . It uses valac version 0.30 . Though it does find it, when I do this on my computer (use cmake to build). This is first time I try to build .deb package, so I'm a bit confused with what to do... Can anyone tell me how to fix this? Thanks in advance. 回答1: The error is quite clear, CMake can't find the pkg-config package named 'gtk+-3.0'. You have

Vala: determine generic type inside List at runtime

吃可爱长大的小学妹 提交于 2019-12-11 11:56:23
问题 I am new to Vala and playing around a bit. Currently I am looking for a way to determine the type parameter of a generic list at runtime. The code below uses 'reflection' to print the properties of the Locations class. However, I am not able to determine at runtime that this list contains instances of string. Is there a way to do this? Or is this not supported in Vala? using Gee; class Locations : Object { public string numFound { get; set; } public ArrayList<string> docs { get; set; } } void