Re: [Vala] Help: Classes cannot have multiple base classes
Hi, Le dim. 13 oct. 2019 à 04:02, Frank Chiu via vala-list a écrit : > Greetings fellows, > > I installed Vala and GTK on macOS Sierra (via Homebrew) and tried > compiling a sample GTK program. But I got tons of errors similar to the > one below. > > I’m new to Vala and I'd really appreciate any pointers, thanks! > It would be nice to post the exact command line you're using. However, if I were to guess, you should use the pkg-config name of the package rather than the gir name (in this case gtk+-3.0 instead of Gtk-3.0) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] access static method
Hi, It seems you solved your issue, but here is the answer to your question. On ث, مارس 26, 2019 at 5:07 م, Wolfgang Mauer wrote: Thanks for your answer... That's what i thought but if i try to use "valaDevelop.get_text" inside method mymethod in class abc the compiler say: /home/wolfgang/Projekte/vDevelop/valaDevelop/completion_provider.vala:59.80-59.99: error: The name `get_text' does not exist in the context of `valaDevelop.valaDevelop' This means that it's trying to lookup the get_text method in the valaDevelop class which is inside the valaDevelop namespace. There is a construct in vala for accessing this anyway, IIRC global::valaDevelop.get_text should get to the method you want. However, I think the real solution is to use sensible names for your classes/methods and not have to figure out which of the similarly named things the symbol resolver is going to pick. For instance, your valaDevelop class could be named Main. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] string format with numbered parameters
Hi, 2018-05-20 17:39 GMT+01:00 rastersoft: > Hi all: > > I want to know if it is possible to use "numbered parameters" to format an > string. I mean: let's say I have this translatable string: > > var str = _("The disk %s, with size %s, is ready").printf(disk_uid, > disk_size); > > But imagine that in language XXX it is more correct to put first the disk > size, and after the disk identifier. Is it possible to "number" the > parameters, to say "put here the second string" and "put here the first > string", to allow translators to swap the parameters in the string? You don't need to do anything, the translators can translate the above string as "xxx %2$s xx xxx xxx %1$s" to have things appear in the correct order. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Stacked arrays in Vala
Hi, Le dim. 6 mai 2018 à 19:33, rastersofta écrit : > An extra tip about the problem: I tried to use > > uint8[,] Property; > > and it seems to work as long as the outmost array has zero or one > entries; if there are two or more entries, it gives trash. > This should be the thing to do. If it doesn't work, then it is a bug. Do you get something similar to https://bugzilla.gnome.org/show_bug.cgi?id=735437 ? Does the patch there fix your problem? Abderrahim > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Confusing issue with static struct method: too many arguments to function
Hello, On Mon, 22 Jan 2018, 23:00 Michael Murphy,wrote: > I have the following which is automatically generated by bindgen. > > ```c > DistinstSector distinst_sector_megabyte(uint64_t value); > ``` > If the struct is returned (and passed as a parameter) like this in C, it should be a simple type in vala. The annotation is [SimpleType] HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] compiler warning for Variant.strv()
Hello, You can try to use the latest development version of Vala. Most of those warnings should go away. https://blogs.gnome.org/despinosa/2018/01/09/vala-warnings-output-improvements/ HTH, Abderrahim On Thu, 25 Jan 2018, 11:32 Yasushi SHOJI,wrote: > Hi, > > I have a code snippet which gets incompatible pointer type warning > from gcc. > > Is there anyway to fix this except "-Wno-incompatible-pointer-types"? > > > $ cat a.vala > using Gee; > > void main () { > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > } > > > $ valac --pkg gee-0.8 a.vala --no-color > a.vala:4.11-4.55: warning: local variable `ary' declared but never used > Variant ary = new Variant.strv({"foo", "bar", "baz"}); > ^ > /tmp/a.vala.c: In function ‘_vala_main’: > /tmp/a.vala.c:38:31: warning: passing argument 1 of > ‘g_variant_new_strv’ from incompatible pointer type > [-Wincompatible-pointer-types] > _tmp5_ = g_variant_new_strv (_tmp4_, 3); >^~ > In file included from /usr/include/glib-2.0/glib/gmessages.h:35:0, > from /usr/include/glib-2.0/glib.h:62, > from /tmp/a.vala.c:5: > /usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const > gchar * const* {aka const char * const*}’ but argument is of type > ‘gchar ** {aka char **}’ > GVariant * g_variant_new_strv > (const gchar * const *strv, > ^~ > Compilation succeeded - 1 warning(s) > -- > yashi > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] i18n help
Hello, the N_ macro doesn't translate the string, it just marks it for translation so it ends up in the po file. You also need to call _ (a.k.a. gettext) to actually get the translation. Attached is a patch to fix this for moserial. HTH, Abderrahim 2017-12-22 19:03 GMT+01:00 Dr. Michael J. Chudobiak <m...@avtechpulse.com>: > Hi all, > > I'm having trouble with i18n. The _("") macros in my program work, but the > N_("") ones (for initializing string arrays) don't. Any pointers on what the > issue could be? > > This is the program: > https://git.gnome.org/browse/moserial > > If you run it, see if the Help > About > License text comes out in your > language... It doesn't if I run: > > LC_ALL=fr_CA moserial > > > - Mike > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list From 4e2673eb1c160e67ed6fe06f38c7b0687759d1c9 Mon Sep 17 00:00:00 2001 From: Abderrahim Kitouni <a.kito...@gmail.com> Date: Thu, 28 Dec 2017 09:38:01 +0100 Subject: [PATCH] correctly call gettext constants translated with N_ need to call _ when used. --- src/MainWindow.vala | 4 ++-- src/MoUtils.vala| 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 47bec6a..9a4036f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -762,14 +762,14 @@ public class moserial.MainWindow : Gtk.Window //Have to extend Gtk.Winow to get private void showAboutDialog () { -string license_trans = license[0] + "\n" + license[1] + "\n" + license[2]; +string license_trans = _(license[0]) + "\n" + _(license[1]) + "\n" + _(license[2]); show_about_dialog (gtkWindow, "version", Config.VERSION, "copyright", "Copyright © 2009-2017\nMichael J. Chudobiak\n<m...@svn.gnome.org>", "comments", _("A serial terminal for the GNOME desktop, optimized for logging and file capture."), "authors", authors, - "translator-credits", translators, + "translator-credits", _(translators), "logo-icon-name", "moserial", "wrap-license", true, "license", license_trans, diff --git a/src/MoUtils.vala b/src/MoUtils.vala index 3c66ac3..773475f 100644 --- a/src/MoUtils.vala +++ b/src/MoUtils.vala @@ -104,7 +104,7 @@ public class MoUtils : GLib.Object foreach (string val_item in val_array) { TreeIter iter; Model.append(out iter); -Model.set(iter,0,val_item); +Model.set(iter, 0, _(val_item)); } Combo.set_model(Model); CellRenderer Cell = new CellRendererText(); -- 2.11.0 ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Using libgnomekbdui from Vala
Hi, both your errors seem to be caused by missing information from the gir file. It should include the pkg-config package (--pkg-export option of g-ir-scanner) and the header file (--c-include option). HTH, Abderrahim On ر, سبت 14, 2016 at 4:08 م, Gergely Polonkaiwrote: Hello, I’d like to use libgnomekbdui from my Vala project, so I can display the current keyboard layout, but I ran into several problems. If I specify --pkg=Gkbd-3.0 (this is the GIR name, no VAPI is available), libkbdui doesn’t get linked, so my GtkTemplate can’t create the GkbdKeyboardDrawing widget. If I add the library to LD_PRELOAD, the widget loads fine. Now if I try to create a GtkChild: [GtkChild] private Gkbd.KeyboardDrawing keyboard_drawing; valac will try to include Gkbd-3.0.h which doesn’t exist (the header name is libgnomekbd/gkbd-keyboard-drawing.h). I’m using Vala 0.30, but I can upgrade to latest if necessary. Best, Gergely ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] spawn like a terminal
Hello, It seems that pipetty from https://github.com/kilobyte/kbtin does what you want, take a look and try to port it to vala. HTH, Abderrahim On خ, سبت 15, 2016 at 11:18 م, rastersoftwrote: Hi all: I want to launch a process and receive its output. But this process (a "make" that runs valac and gcc) seems to detect whether it is running in a terminal or using pipes, and in the second case it refuses to send ANSI color codes. I want to receive that codes and show them in the text. How can I trick the application into thinking that it is in a terminal? ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Incorrect C code generated
Hi Le mar 22 mars 2016 20:37, Dmitry Golovina écrit : > Hello! > > Discussed today on the IRC channel, also posting it to the mailing list. > > I don't know if it is a vala bug or I am just using things incorrectly. > > Here is my code: > > struct N { > int i; > } > class ClassA : Object { > public N a { get; set; } > public ClassA(N a) { > this.a = a; > } > } > class ClassB : Object { > public Value b { get; set; } > public ClassB(Value b) { > this.b = b; > } > } > class Main { > static void main() { > var a = new ClassA({ 1 }); > var b = new ClassB(a.a); > b.notify["b"].connect((obj, prop) => { a.a = (N)b.b; }); > A random idea: try casting to (N?) instead. HTH ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Mixing C with vala
Hello, Le mer 23 sept. 2015 23:21, Daniel Brendlea écrit : > The second gist is a gist that contains a main.vala, and a > gereon-page.c and a gereon-page.h . those files are generated by vala > with the -C and -h-flags. Additionally there is a gereon.vapi that > describes the methods of Page towards the vala-compiler. This example > does not work beacause the unreferencing methods in the C-stage of > main.vala is "gereon_page_unref()" instead of "g_object_unref()". Why > is that? > > https://gist.github.com/grindhold/f2a39dab2dd1c172b355 > > Thanks in advance. I'd really like to understand what happens. The problem is the vapi. It should be public class Page : GLib.Object { One more thing: You don't need to keep the Vala generated code and modify it; a better solution would be to declare the methods you want to implement in C as extern and implement them in another file HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Json.Searializable implementation troubles
Hello Luc, Le 8 août 2015 06:39, Luc Chante luc.cha...@gmail.com a écrit : Hi, I'm trying to implement Json.Serializable interface. For the moment, I've just made a lazy implementation (see the attached file), which mocks default behavior of Glib.Object serialization. To test : [...] There is 2 issues : The 'list_properties' is never called (it doesn't override the base one). You are using the new keyword, which means it's a new method (unrelated to any method with the same name in a base class or interface). For implementing an abstract method, you don't need any modifier; for overriding a virtual method, use override I'm not sure about the rest, I never used it. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Is has_type_id = false needed in a VAPI binding of an enum?
Hello, Le 28 avr. 2015 11:41, Al Thomas astav...@yahoo.co.uk a écrit : I'm pretty sure has_type_id = false isn't needed in an enum mapping in a VAPI file. I have tried both false and true values and there is no difference in the running of the test program I created. The test program just just prints the enum values. I have also binary compared the program and both versions are identical. So I'm pretty sure it isn't needed, but before I remove those particular CCode attributes from the enum examples in https://wiki.gnome.org/Projects/Vala/LegacyBindings I wanted to check here. I believe it's needed. Try defining a property in a GObject with the enum type to see if there is a difference. Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Using a C library
Le 21 avr. 2015 12:19, Al Thomas astav...@yahoo.co.uk a écrit : I've had a quick search and it looks as though a libspotify.pc file exists, e.g. [...] you rename spotify.vala to spotify.vapi and try compiling with: Shouldn't that be libspotify.vapi ? ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] VAPI to GIR
Hello, I think it's not possible to convert from vapi to gir. But if this is a vala library, you can generate the gir at the same time as the vapi by using the --gir option of valac. HTH, Abderrahim 2015-03-24 13:31 GMT+01:00 Konstantin P. ria.freelan...@gmail.com: Hello. I have some vala library (with generated VAPI). This is possible to convert VAPI to GIR for using it in Python app, or I need to write GIR by hand? ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How do I access command line arguments from a main block?
Hello, Le 21 févr. 2015 06:20, Guillaume Poirier-Morency guillaumepoiriermore...@gmail.com a écrit : You missed the vala-list in CC in your answer, so I will just repeat myself. By 'main block', I meant the experimental main block feature. I am well aware of how arguments are accessed usually, but I would like to know how it is done it this particular case. Looks like this is not possible. You'll have to use a main method. https://git.gnome.org/browse/vala/tree/vala/valaparser.vala#n2177 Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Debugging Vala w/ CMake
Hi, Le 5 févr. 2015 20:11, Steven Oliver oliver.ste...@gmail.com a écrit : The instructions I found on the Vala webiste actually work very well for the example given [1]. My problem is when combining those with the CMake files from Jakob Westhoff [2] that are so popular these days, I always get the error that you can't combine the valac option -C with --save-temps. Does anyone know a way to do both without breaking my existing CMake setup? You don't need both. Either is enough. You just need g (for both vala and C compilers) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] constructor in peas plugin
Hello, 2014-05-11 18:11 GMT+01:00 rastersoft ras...@rastersoft.com: Hi all: I'm creating a plugin for Gedit using Vala, and found that the constructor is not called. Is this a bug, or a feature? It is a feature that you shouldn't use ;-) You should use the GLib way when writing a library (or plugin) for use with C/GLib applications [citation needed]. In short, the creation method (i.e. ValaWindow() here) should only set properties (via a GLib.Object() call); the rest goes into the constuctor ( construct { ... } ). (In the case of a plugin you can omit the creation method altogether, and have only the constructor). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to implement the get_type method of Gst.URIHandler interface in vala?
Hi, I've looked at thé gst docs and the vfunc for get_uri_type is called get_type. HTH, On March 16, 2014 9:19:34 AM CET, Luca Bruno lethalma...@gmail.com wrote: I don't understand what you mean by gstreamer uses get_type, can you point to the specific C method? On Sat, Mar 15, 2014 at 4:05 PM, Lei Miao leimia...@gmail.com wrote: Thank you for the response. I could implement get_uri_type, but the problem is that gstreamer uses get_type. If I can implement get_type in vala, then I don't have to modify gstreamer code. Regards, LM On Mar 14, 2014 5:30 PM, Luca Bruno lethalma...@gmail.com wrote: I don't understand why you are using get_type. Implement get_uri_type. On Fri, Mar 14, 2014 at 10:21 PM, Lei Miao leimia...@gmail.com wrote: Hi, I am trying to write a gstreamer 1.0 plugin using vala. However, I am having trouble to implement the get_type() method of the Gst.URIHandler interface defined here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstUriHandler.html#GstURIHandlerInterface . In particular, my class inherits Gst.bin and implements Gst.URIHandler interface: public class StreamingSource: Gst.Bin, Gst.URIHandler { ... public URIType get_type (Type type) { return URIType.SRC; } ... } When I compile the vala code to c code, I get the following error: StreamingSource.get_type hides inherited method `GLib.Object.get_type'. Use the `new' keyword if hiding was intentional public URIType get_type (Type type) { return URIType.SRC; } The problem seems to be that GLib.Object also has a method called get_type. So in this case, does anybody know how I can implement the get_type method of Gst.URIHandler? It's worth noting that according to this link: http://references.valadoc.org/#!api=gstreamer-1.0/Gst.URIHandler , the method is called get_uri_type() instead. This is inconsistent with the gstreamer 1.0 reference manual. In fact, Gstreamer code has both methods defined, but it uses get_type() for element registration. Regards, LM ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list -- www.debian.org - The Universal Operating System -- www.debian.org - The Universal Operating System ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Printfing an object
Hello Donn, 2013/11/17 Donn donn.in...@gmail.com Plus, how could I get that printf %p address (e.g 0x7fff70ffbb98) into a string variable? %p.printf(your_object) btw, you don't need when dealing with instances of classes, and if your classes inherit from GLib.Object, you can use your_object.get_type().name() (I'm writing this from memory, there may be an error) to get the type name. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] GLib.Rex Pattern
Hello, Le vendredi 5 avril 2013, Daniel Espinosa a écrit : I'm using: class Ip : Object { public static string PATTERN=(([0-2]?[0-5]{1,2})|([0-1]\d\d)|(\d \d))\.(([0-2]?[0-5]{1,2})|([0-1]\d\d)|(\d \d))\.[0-2]?[0-5]{1,2}\.(([0-2]?[0-5]{1,2})|([0-1]\d\d)|(\d\d)) } On compile I get error for invalid scape sequence. \d is an invalid escape sequence. Since you need a backslash, you need to either escape it (by doubling it) or use a literal string HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Check conditionals versions of Vala
Hello, Le mercredi 6 février 2013, Olivier Duchateau a écrit : Hi, I wonder, if it exists preprocessors in Vala, or if it exists macro like GLIB_CHECK_VERSION, but known by valac ? I don't find any responses. There are macros named GLIB_2_XX defined if glib version (as passed to --target-glib option to the compiler) is greater than 2.XX. You can use them for conditional compilation. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Using vala, libgda, and waf
Hi, في ح، 10-06-2012 عند 00:22 -0400 ، كتب Steven Oliver: I have a very very simple pet project I'm writing and I want to integrate some storage in a DB using libgda or GnomeDB (not real sure what it's official name is now). I've pasted the basics of the top of my wscript file. I cannot for the life of me figure out how to get waf to recognize libgda. I'm still on Fedora 15 so I only have up to libgda-4.0, which is fine, because if I can't get it to work having 5 won't help me any. I've tried several different opts.load statements in the below code including libgda, libgda4, libgda-4.0. Does anyone know what the right statement is??? (This has actually nothing to do with vala, it's really a waf question.) Anyway, you need to use conf.check_cfg like it is done for glib, something like: conf.check_cfg(package = 'libgda-4.0', uselib_store = 'GDA', mandatory = True, args = '--cflags --libs') and use GDA in the uselib for your application. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to use [ModuleInit] and GTypeModule?
في ج، 17-02-2012 عند 07:33 +0800 ، كتب PCMan: The sample here did not mention GTypeModule and did not contain [ModuleInit], either. https://live.gnome.org/Vala/TypeModules Yes, this page doesn't talk about GTypeModule, it did in the distant past, but no longer. See an old version here: https://live.gnome.org/action/recall/Vala/TypeModules?action=recallrev=5 Though its title is TypeModules, it did not show how to use GTypeModule. I tried to google for some exmples and found that three is an undocumented attribute [ModuleInit]. http://swik.net/GNOME/Planet+GNOME/Abderrahim+Kitouni:+Writing+Anjuta+plugins+in+Vala How to use this correctly? Or should it be used? It depends on what you want to do: if you want to be able to load plugins then it is probably better to use libpeas (but you can use GModule and GTypeModule directly if you want), if on the other hand you only want to write a plugin, it should be enough to annotate the function that is called by the plugin loader with [ModuleInit]. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Help with metadata file
Hello, في خ، 19-01-2012 عند 18:23 -0800 ، كتب Eric Gregory: Hi, I'm trying to generate a working Vapi for WebKitGtk-3, but I've run into a problem: cast macros. GCC is choking because it cannot find WEBKIT_DOMHTML_ELEMENT which is expected -- the actual name is WEBKIT_DOM_HTML_ELEMENT (note the underscore.) This appears to be due to the lack of CamelCase on the class name. I was able to get the type check macro to work with the following: WebKitDOMHTMLElement type_check_function=WEBKIT_DOM_IS_HTML_ELEMENT But I'm not having any luck with the cast function. Is there a way to specify this manually? It looks like the problem is the lack of nested namespace support in gir: the type check function WEBKIT_DOM_IS_HTML_ELEMENT says that HTMLElement is part of the WebkitDOM (or Webkit.DOM) namespace. So the solution would be to move this class (and similar classes) to a namespace. Looking briefly at other metadata (they are in the vapi/metadata directory in vala git), it seems the following (untested) would do it: DOM* parent=Webkit.DOM name=DOM(.+) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Set a RGBA colourmap on Gtk.Window
في خ، 19-01-2012 عند 21:29 + ، كتب David Gomes: Thanks for the links. So I read them and I did this: Visual terminal_visual = this.get_screen ().get_rgba_visual (); my_terminal.set_visual (terminal_visual); my_terminal.set_background_transparent (true); I did it, but I still get the wallpaper as background, instead of real transparency, so I can see underneath windows. What am I doing wrong? Thanks. I don't know. Maybe you need to set the property on the main window. This would perhaps be better answered by gtk/vte devs. Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [SimpleType] public struct Integer : uint {} does not work
في ر، 18-01-2012 عند 17:56 +0100 ، كتب Henrik /KaarPoSoft: Dear all, I am trying to create a new type in vala, like typedef in C. I have created the following file called i.vala: code [SimpleType] public struct Integer : uint { } public static int main (string[] args) {return 0;} /code Adding [CCode (has_type_id=false)] should let you compile your program, but this is probably a bug that should be fixed. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Set a RGBA colourmap on Gtk.Window
في ر، 18-01-2012 عند 16:55 + ، كتب David Gomes: Hey, I read the following on Valadoc here: http://valadoc.org/vte-2.90/Vte.Terminal.background_transparent.html, Note: When using a compositing window manager, you should instead set a RGBA colourmap on the toplevel window, so you get real transparency. Now my doubt is how to set an RGBA colormap on a widget or on a Gtk.Window? See the following methods: http://valadoc.org/gdk-3.0/Gdk.Screen.get_rgba_visual.html http://valadoc.org/gtk+-3.0/Gtk.Widget.set_visual.html HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] (no subject)
في ر، 18-01-2012 عند 10:28 -0800 ، كتب Geoff Johnson: Later on in the code I want to use n_part but whenever I do I get the following error during compile: julia.vala:166.21-166.30: error: Relational operation not supported for types `int' and `null' for (i = 0; i n_part; i++) { Are you sure i is already defined before? If not, that would explain this error message (although I'd expect another error before this one). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] (no subject)
في ر، 18-01-2012 عند 11:18 -0800 ، كتب Geoff Johnson: In the class right before the constructor I've declared the property using: public int n_part { get; set; default=0; } and as mentioned, I'm able to use it without error inside of the constructor. I'm talking about i, not the property. You wrote: for (i = 0; i n_part; i++) { shouldn't that be: for (var i = 0; i n_part; i++) { ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Genie and extra '\n' in some strings
Hello, في خ، 05-01-2012 عند 18:54 +0100 ، كتب Piotr Borkowski: Hi. I was playing around with Vala and Genie and I noticed that in the case of Genie, the compiler adds an extra '\ n' sequence at the end of some strings. Is that supposed to be? As you can see, in both cases the newline is added to a print'ed string, so I guess it is intentional. btw, print in genie is a statement (like in python 2), see http://live.gnome.org/Genie HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Crazy Vala callback behavior
Hello في ح، 18-12-2011 عند 00:32 +0100 ، كتب Matthias Klumpp: Hi! This is a bit difficult to reproduce, so I'm not sure if this really is a bug. I am mixing Vala and C code. I implement an internal class in Vala, which defines the following callback: public signal Results request_whatprovides (uint filters, uint provides, [CCode (array_length = false, array_null_terminated = true)] string[] search); AFAIK, signals with return values aren't supported in Vala. Another important thing you didn't mention is what is result (is it a class, a struct). And since you're talking about a callback, maybe you meant delegate instead of signal. Please explain what you want to do rather than how you think you should do it, it's better for helping you. This callback is used to forward requests to a C library, which is itself loaded as GModule, but I don't think this matter. Anyway, I would expect that I need to implement a callback in C using these parameters: I think you really mean a delegate, and if so, your callback should have the arguments (guint filters, guint provides, gchar** search, gpointer user_data), and return a Results* if Results is a reference type, and have the arguments (guint filters, guint provides, gchar** search, Results* result, gpointer user_data) if Results is a struct. xy_request_whatprovides_cb (BackendProxy *sender, PkBitfield filters, PkProvidesEnum provides, gchar** search, gpointer user_data) Why are you using different types for the arguments? You should probably have bindings for the library that is used by both you app and the loadable module. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Debugging
Hello, في س، 17-12-2011 عند 11:41 -0500 ، كتب Brian Duffy: Okay, that was enlightening. I certainly am glad that I have some way to investigate the clutter property but I can't help but wonder how hard it would be for gdb to be able to print that value if I can print it right from my vala code to the external console with a simple printf statement. I guess it gets back to the fact that gdb is for debugging C and has no knowledge of the hoops Vala is jumping through to get its printf function to print out the value of that property. I see that as a problem, but not as big a problem as writing my app in C versus Vala ;-) That's it. I have written a gdb patch to add support for vala. It still doesn't support properties, but I hope you can find it useful. http://mail.gnome.org/archives/vala-list/2010-December/msg00121.html (I'm not sure it still applies on the latest version, but it shouldn't be too hard to fix) If there is interest in this, I'll try to improve it. Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Debugging
في ح، 18-12-2011 عند 09:33 -0500 ، كتب Brian Duffy: Hi Abderrahim , Well, I certainly am interested! I'm trying to setup the best environment I can for developing an application in Vala. Not having to look up accessor methods to call, or insert printf statements in my code to debug would be a big help to me. Let me try to apply your patch to the latest version of gdb and I'll let you know what I come up with. Attached you'll find the patch rebased on the latest version from the git mirror. HTH, Abderrahim gdb-vala-20111218.diff.gz Description: GNU Zip compressed data ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Debugging
في ح، 18-12-2011 عند 13:07 -0500 ، كتب Brian Duffy: Applied the patch to gdb 7.3.1 (Fedora 16) Ran gdb on my vala executable file This executable is just the clutter-demo.vala from vala home page With unpatched gdb the print clutter_actor_get_width(r) line works but not with this patched version. Obviously, the goal is print r.width This is probably because something changed in gdb between my patch and the release. I'll try to look at this. (gdb) print r.width There is no member named width. This currently only works with public fields. (gdb) print clutter_actor_get_width(r) Internal error: `self' is not an aggregate It looks like it didn't find the function, I'll see if I can reproduce this. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Delegates thread-safe
Hello, في خ، 15-12-2011 عند 15:42 -0200 ، كتب Alexandre Rosenfeld: Hey guys, I was recently creating a program where a delegate is passed around and then executed inside different threads. The delegate itself was thread-safe, I wasn't using anything that would cause a problem if it was called from multiple threads. However the program kept crashing with memory violations which were caused by objects that were previously freed. Before going any further, are you using owned delegates? If not, you should. (but this may not be the only reason) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Allocate memory for a struct pointer
Hello, في ث، 06-12-2011 عند 16:26 +0100 ، كتب Guenther Niess: Hi, I'm quite new and have a problem to initialize a struct. In the tutorial and faq there are ways, but I think I have to manage the memory manually in order to use libxml. Here is an example of allocating the struct manually: public struct MyStruct { int i; int j; } public void main () { MyStruct* str = malloc (sizeof (MyStruct)); *str = MyStruct () {i = 1, j = 2}; print (%d %d\n, str-i, str-j); delete str; } I'm not sure about your use case, but if you only need this struct pointer inside a function, you can probably simply allocate your struct normally and pass its address. MyStruct str = ...; some_function (str); HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] how to pass a List by reference?
في ج، 14-10-2011 عند 10:26 -0300 ، كتب Leonardo Ferreira Fontenelle: As I told in a previous email, I come from a Python background, and never wrote anything in C+GLib. When I learned Vala, I used Libgee first, and only then I found out about GLib's lists, sequences and so on. Could anyone please tell me which are the coincidences and differences in the GLib and Libgee, and which are the pros and cons of each? You should use libgee unless you have a good reason not to. The only reason I see is interoperability (and it is a very good one). For example, if you want to use libraries that use the GLib collections, it may be better to use GLib everywhere and not have to convert. Another example is if you're writing a library and want it to be usable from gobject-introspection: libgee doesn't work well (if at all) with introspection. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] VAPI Generation Problems
Hello Andrew, You have more than one problem here, see below 2011/10/10 Andrew Higginson at.higgin...@gmail.com: My Gio-2.0.gir file is available here, and it is the latest in Ubuntu 11.10 (libglib2.0 package version 2.30.0) : http://db.tt/e621C6EA As far as I know, vapigen still cannot parse the gio gir correctly (nor the gtk one). So you probably need to pass at least --pkg gtk+-3.0 to vapigen. I tried to use the --pkg switches on the command line, and simply used all the packages that were listed in the Meta-3.0.gir file in the include tags. So I ran the following command: vapigen --library libmutter --pkg atk --pkg clutter-1.0 --pkg cogl-1.0 --pkg glib-2.0 --pkg gmodule-2.0 --pkg gobject-2.0 --pkg gdk-3.0 --pkg gdk-pixbuf-2.0 --pkg gio-2.0 --pkg gtk+-3.0 --pkg json-glib-1.0 --pkg pango --pkg pangocairo --pkg cairo --pkg x11 /usr/share/gir-1.0/Meta-3.0.gir You don't need to pass all these, --pkg gtk+-3.0 --pkg clutter-1.0 should be enough. However, this still doesn't solve the problem. And again the libmutter.vapi file is empty :( The problem here is that the Meta-3.0.gir incorrectly reports the packages it provides (it reports gtk+-3.0 and clutter-1.0, where it should report libmutter (or mutter-plugins, or both. I'm not sure)), so it is ignored (since we've already included gtk and clutter). This should be fixed in mutter. and btw, they don't include the headers either, that should be fixed as well. At this point, I get the following errors: Meta-3.0.gir:1581.45-1581.45: error: The type name `X.KeySym' could not be found type name=xlib.KeySym c:type=KeySym/ ^ Meta-3.0.gir:1584.49-1584.49: error: The type name `X.KeyCode' could not be found type name=xlib.KeyCode c:type=KeyCode/ ^ The problem here is that the vala bindings for x11 don't have KeySym and KeyCode (they are replaced by ulong and uchar). The simplest way is to skip MetaKeyBinding (assuming you don't need it). This is done by creating a file Meta-3.0.metadata containing KeyBinding skip and pass the directory containing this file to vapigen using --metadatadir. At this point, you have a non-empty libmutter.vapi (I didn't test it, so not sure it works). There are still crtitical warning (that seem to be related to the fact that cogl-pango is put in the same vapi as cogl, but they're harmless afaict). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Transfer of delegates
Hello, في ر، 05-10-2011 عند 17:15 +0200 ، كتب tomw: Hi, I know that there has been some discussion on this subject. Reading through [1] and [2] I tried the following approach to pass a delegate method to a class and to execute it there like: [...] What am I missing? Any enlightenment appreciated... You need either: unowned Handler handle; public MyClass (Handler? handle) { this.handle = handle; } or Handler handle; public MyClass (owned Handler? handle) { this.handle = (owned) handle; } (the latter is probably what you want). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] vala-gen-introspection/vapigen probem
في س، 01-10-2011 عند 14:33 -0700 ، كتب bsquared: Test compile: valac --vapidir ../vapi --pkg Couchdb-glib-1.0 libcouchtests.vala I think the problem is that you need the .vapi to have the same name as the .pc (i.e. couchdb-glib rather than Couchdb-glib-1.0) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to write a responsive GTK+ app that reads a file in the background?
Hello Leonardo, 2011/9/29 Leonardo Ferreira Fontenelle leonar...@gnome.org: I'm trying to port a small Python GTK+ application to Vala. Overall, I have succeeded, with some very interesting performance gains. But in some cases the search may take a few seconds to finish, while the application reads data from the disk. I tried using an async method to keep the user interface responsive, but it didn't work: until the search is completed, the user can't even move the cursor in the text entry widget. What am I missing? Simply declaring your method async doesn't make it automatically use async i/o. If I understand correctly, the function that takes time is get_matches, you need to either execute it in another thread, using something like: Gee.TreeSetint32 matches = null; Thread.createvoid(() = { matches = get_matches (words); Idle.add (search.callback); }); yield; or make get_matches (and possibly other methods it calls) async, and use the async versions of the i/o functions you call (assuming you use GIO), and call it like: Gee.TreeSetint32 matches = yield get_matches(); HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] parsing an xml file
في ن، 19-09-2011 عند 21:46 + ، كتب Dennis Kerrisk: Hi, I am new to vala, and would like to know how to parse an xml file into string variables? Here is an example xml file I need to parse: In addition to what others have pointed out, see the following: http://live.gnome.org/Vala/MarkupSample http://live.gnome.org/XML HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Help with json de/serialization
في ح، 04-09-2011 عند 20:22 -0700 ، كتب bsquared: Hello, I am trying to move some JSON to GLib.Object descendant but cannot seem to figure it out. The JSON is the .couchapprc file which looks like this: { env : { default : { db : http://localhost:5984/mydb; }, prod : { db : http://admin:passw...@myhost.com/mydb; } } } The first problem I had was in defining the target object. It looks like a Mapstring, Object. I defined an object and collection: class CouchApp.Env : Glib.Object { string db; } Mapstring, CouchApp.Env env_map = new mapstring, CouchApp.Env (); Then I get the env member Object: Json.Object o = p.get_root ().get_object ().get_member (env).get_object (); loop through the env members with: o.foreach_member((o,s,n) = { [...] }); But I get an error [1] when I call this in the loop: Json.gobject_deserialize (CouchApp.Env, n) * So, what am I doing wrong here? the above should be Json.gobject_deserialize (typeof(CouchApp.Env), n) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] asynchronous call with DBus
Hello, في س، 27-08-2011 عند 18:02 +0200 ، كتب rastersoft: Hi all: I'm working with DBus and Vala, and I've been able to call to a method in UDisks; but now I want to do that call in an asynchronous manner, because it needs some time to be completed (format a disk). I tried something like this: [DBus (name = org.freedesktop.UDisks.Device)] interface Device_if : GLib.Object { public abstract async void FilesystemCreate(string type, string[] options) throws IOError; } Device_if my_device = Bus.get_proxy_syncDevice_if (BusType.SYSTEM, org.freedesktop.UDisks,device_name); my_device.FilesystemCreate(reiserfs,null); and it worked; the problem is that I don't know how to know when the call ended. In the documentation I can't find any signal to connect to. Just add another argument to your call ;-) my_device.FilesystemCreate.begin (reiserfs,null, () = { // do whatever you want when the operation is finished }); see http://live.gnome.org/Vala/Tutorial#Asynchronous_Methods (and btw, I think you can use vala-ish method name filesystem_create and valac will correctly translate it). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] General-purpose Makefile for building Vala projects (was: Does anyone know how to use parvala?)
Hello, في خ، 25-08-2011 عند 21:35 +0200 ، كتب Carl: Funny you should say that, i'm working on a cross platform, native building tool too :-) I'm not crazy about make autoconfigure intlool (and the perl requirement) and all the dependencies (all the shell tools perl, libxml... )whereas the point is, in most case, to invoke gcc (and friends : ld ar pkgconfig...) with the proper parameters. So I decided to get down to it : building c and vala projects with only gcc (and friends). No shell script, no perl, no configuration generation. And no modification to my source folders : no file added, generated or cleaned. If the tool has to generate files, it will create its own temp folder. Way cleaner, way safer. Each project is described declaratively with a easily readable and parsable yaml file Wait a minute. Did you hear about buildj? http://live.gnome.org/BuilDj It would be best to use the same format (it's also yaml based) rather than invent your own (proposals for extending the format or other comments are welcome). We have an implementation using waf, but we'd love to see other implementations. (incomplete specification) http://live.gnome.org/BuilDj/Spec (mailing list) http://mail.gnome.org/mailman/listinfo/buildj-list Cheers, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] extract translatable strings from VALA files
في خ، 25-08-2011 عند 17:06 +0200 ، كتب Christoph Mende: On Wed, 2011-08-24 at 22:52 +0200, rastersoft wrote: Hi all: I've been able to extract the translatable strings from VALA files using xgettext -o po/untitled.pot -L c# -k_ *.vala Your shell stops interpreting right at the #, because it thinks you're starting a comment. To actually pass the # put it in . No, it doesn't: try running 'echo c#' in a terminal ;-) It starts a comment only if it is after a space (and maybe after other things, I'm not sure). But you're right, it's better to quote a # anyway. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Does anyone know how to use parvala?
في ن، 22-08-2011 عند 17:13 -0700 ، كتب Damien Radtke: It's linked to at the bottom of this pagehttps://live.gnome.org/Vala/Documentation/ParallelBuilds, but its documentation is non-existent. Any tips on how to use it in a project? The same way you would use valac: if you copy it in your path and copy parvala.mk so it can find it (it looks in ../share/parvala/ relative to where the parvala script is located), you can build with something like make -s VALAC=parvala (assuming automake) or make your configure script look for parvala before valac. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] The name `type' does not exist in the context of `Xml.XPath.Object*'
في ج، 19-08-2011 عند 22:39 -0700 ، كتب Joseph Montanez: I was able to resolve it I had a complete brain fart on the fact libxml is not gobject. So I switched the var to unowned and the datatype. // Search for Posts Xml.XPath.order_doc_elements (doc); var xpath = new Xml.XPath.Context(doc); unowned Xml.XPath.Object results = xpath.eval(//content); This has nothing to do with the fact that it isn't a gobject. The returned object is a pointer so you need to make sure whether it needs to be freed or not. And for accessing a field from a pointer you use - instead of . so your code would use results-type etc. Of course, if you are sure it doesn't need to be freed then it's better to assign it to an unowned reference. (and if it should, then assign it to an owned reference). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] How to unload, reload, or unregister a Module?
Hello Joseph, Michael; في ج، 19-08-2011 عند 18:04 +0100 ، كتب Michael Brown: Re-added the list. You should look at the documentation for TypeModulehttp://valadoc.org/references/gobject-2.0/0.11.5/GLib.TypeModule.html. Basically you subclass this, and implement the load/unload methods to use Module http://valadoc.org/references/gmodule-2.0/0.11.5/GLib.Module.html. In the load method you construct Module, and in unload you assign null to the member referencing it, causing an unref and deletion. That in turn unloads the actual code. I'm wondering if it isn't better to just use libpeas. Unless you need something special or don't want to depend on an external library, it is IMHO better to use something already there than reinventing the wheel. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Fwd: Problem installing vtg under Debian Sid
Hello, في ج، 12-08-2011 عند 09:25 +0200 ، كتب Andrea Del Signore: If you still want to do a local install download vala toys 0.12.1 that I just released and then: ./configure --prefix=$HOME/.local make make install after that you have to copy the vtg setting schema in the system dir (you need the root account) and recompile all the schemas: sudo cp data/org.gnome.gedit.plugins.vala-toys.gschema.xml /usr/share/glib-2.0/schemas/ sudo glib-compile-schemas Instead of doing this, you could add ~/.local/share to the XDG_DATA_DIRS environment variable, by using something like: export XDG_DATA_DIRS=~/.local/share:$XDG_DATA_DIRS in a terminal and then running gedit from that terminal (you can also add this to your .bashrc to avoid doing it every time). I don't know if it's possible to tell gdm/gnome-session to set this for us so it works without running from a terminal, that's what I'm using. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Why is my menubar not showing up?
في ج، 29-07-2011 عند 21:19 +0200 ، كتب Fred van Zwieten: Hi. I try to make a menubar, taking examples from vala toolbar demo and a pygtk tutorial. I have this sample code: using Gtk; class menusystem : Gtk.Window { public menusystem () { this.title = Menu System Demo; this.destroy.connect (Gtk.main_quit); set_default_size (600, 600); var menubar = new MenuBar(); var file_menu = new Menu(); var quit_item=new MenuItem.with_mnemonic(_Quit); file_menu.append(quit_item); quit_item.activate.connect(Gtk.main_quit); var file_launcher=new MenuItem.with_mnemonic(_File); file_launcher.set_submenu(file_menu); menubar.append(file_launcher); var vbox = new VBox (false, 0); vbox.pack_start (menubar,false,false,0); add (menubar); You probably want add (vbox) instead of add (menubar) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] complication error: Unbable to serialize a callback(by delegate) for Dbus(using GDBus)
On 14 يول, 2011 م 01:08, Tal Hadad wrote: This doesn't make any sense... Take a look in this example: http://live.gnome.org/Vala/DBusClientSamples/Waiting This method is a callback when the list of names is ready(because it's asyns method). Also, it doesn't make any sense that DBus ask the client for the list of addresses... What I suggested is to declare your function as: public abstract string[] list_names (); i.e. with no argument and a string[] as return type. But since you're talking about async, you may try to add async to this definition: public async abstract string[] list_names (); (btw, I don't know DBus, I'm just trying to help) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] complication error: Unbable to serialize a callback(by delegate) for Dbus(using GDBus)
Hello, 2011/7/13 Tal Hadad tal...@hotmail.com: I'm trying to write a client for MPRIS 2.0 specs, and one of my TODO list is to get all Media players which activated. This is done by passing all DBus addresses and check if it's in the format of org.mpris.MediaPlayer2.*. For doing this, I need to add callback to method list_names in interface /org/freedesktop/DBus(which I called MasterDBus) in org.freedesktop.DBus. This is a relevant part of my code: [DBus (name = org.freedesktop.DBus)] public interface MasterDBus { public abstract void list_names (MDBusCallBack cb); After a quick look at the specification, I think this method takes no argument and returns a string[]. That's probably the problem. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Question regarding passing a strings as arguments to a method
Hello, 2011/7/11 Serge Hulne serge.hu...@gmail.com: If one has a look at the C code generated by Vala for the following two examples, it appears that the unowned keyword has no influence on the way the string b (of type gchar*) is passed to f(). In both cases, it is passed as a pointer (without duplication). Therefore it seems to me that the Vala tutorial is slightly misleading and should read: - In Vala strings are always passed by address. A string in Vala is a *reference* type [1] and therefore passed by reference. The documentation is correct here, it may just need to point out clearly that fact. HTH, Abderrahim [1] it is a bit special because it is immutable, and thus copied whenever there is a new strong reference to it ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Question regarding passing a strings as arguments to a method
Hello, On 11 يول, 2011 م 05:15, Serge Hulne wrote: All right, But it is a rather odd class indeed then, because: 1) I dont't think it has the value null when unassigned. It does (or at least it should). 2) It derogates to the rule according to which the default behaviour in an assignment between class types is by reference (when a string is assigned to another, the default is to copy the data, unless it is explicitly declared unowned) Not really: the default behaviour in an assignment is to either increment the refcount or copy (depending on whether the class is refcounted or not), except that if the class isn't refcounted and isn't immutable (GLib.List for example) you'll need to explicitly copy it. But since string is immutable (and this is where it is special, though you can make your class behave so), it will be implicitly copied. 3) When a string is created, it does not require the use of the keyword new ( it is: string s = hello; not: string s = new string(hello); ) This is just because of the existence of string literals. If there were list literals in vala, you could create a list without using the new keyword. (I think there are list literals in the dova profile). 4) Yet, it is passed by reference in a function call. Like any other class ;-) Since the string class, seems to behave unlike any other class, perhaps its singular behaviour ought to be emphasized in the documentation. So yes, it is a bit unusual, but once you understand how vala works, you'll find it more logical. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Vala : Suggestion for improvement : String Class wrapper for strings in Vala : Addendum
Hello, على 21 يون, 2011 م 07:18, كتب Serge Hulne: Apparently string a = hello; string * b = a; and : string a = hello; unowned string b = a; appear to be translated by Vala into the exact same C code. Are these two ways to declare the same thing or is this just a bug which happens to work perchance ? Not exactly the same thing, but the difference is relatively subtle: unowned means that the variable doesn't own the reference, that is, it doesn't need to be freed when the variable goes out of scope; a pointer, however, means that vala doesn't do the memory management at all, it's the *programmer's* responsibility to free the reference (or not) before the variable goes out of scope (using the delete statement). For example, with unowned string b = a.dup (); the compiler will report an error, while with string* b = a.dup (); it won't, and you need to explicitly delete b; after you're done with it. Generally, if you're optimizing your program to reduce copying, it's better to use an unowned reference rather than a pointer. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] What is the right syntax for defining pointers or references or aliases in Vala ?
Hi, على 21 يون, 2011 م 08:08, كتب Christian Siefkes: On 06/21/2011 08:00 PM, Jim Nelson wrote: Actually, string.strip() (which uses g_strstrip) returns a new string. Yes, string.strip() returns a new string, but string._strip() [note the underscore] doesn't return anything and just modifies the calling string in-place. Both of them exist in the string API. I'd argue that _strip() should be private. I guess it isn't because of a bug in valac or something. Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Is this the right syntax for defining pointers in Vala ?
Hello, 2011/6/20 Serge Hulne serge.hu...@gmail.com: Is this the right syntax for defining pointers in Vala ? I think the following is better: using Posix; void main (string[] argv) { string a = hello; string* b = a; strcpy(b, bye); Posix.stdout.printf(a = %s\n, a); Posix.stdout.printf(b = %s\n, b); } HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] GLib.List again
Hello, 2011/5/20, Jan Spurný jspu...@seznam.cz: Hi, I have another question regarding manual writing VAPI files for existing C libraries using GLib.List. Now I have troubles with a method which acts similarly like many of the GList's methods - it takes GList * parameter and returns it's new value - which may or may not be the same as the given parameter, but it MUST be used. The only difference is that in my case the metod belongs to some other Compact class - so I can't use [ReturnsModifiedPointer] attribute and without it vala will think that return value is something new and at the end of the scope it will try to free them both. It looks like this: I think this is something valac can't do for you, so you need to write some ugly code: Using the same notation as your example, you'd need to define your method as: public GLib.ListX run(owned GLib.ListX list); (owned tells valac that a value passed to this function doesn't need to be freed) and then you call it as: list = foo_bar.run ((owned) list); (and if you forget the (owned) cast, you'll get an error telling you to explicitly copy) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] GLib.List
Hello, (my comments are inline, and please keep the discussion on list) 2011/5/19 Jan Spurný jspu...@seznam.cz: Hi, thanks again for your reply, Did you have any problem with the following? it should be the first thing you try (and is likely the correct thing): [CCode (cheader_filename = oldlib.h)] public static GLib.ListX old_lib_make_x_list(); Thanks for your reply, but unfortunately, it really WAS the first thing I did - but because X is not reference counted, it resulted in errors like this: oldlib.vapi:61.33-61.36: error: duplicating X instance, use unowned variable or explicitly invoke copy method public static GLib.ListX old_lib_make_x_list(); ^ Yeah, this error message is misleading. You should put unowned in your loop and not in the bindings, i.e. foreach(unowned X myx in old_lib_make_x_list()) { ... } ok, that makes sense.. unfortunately, it won't help me much - it's probably my fault, I should've explained it better - I'm using GLib.ListX returned from Are you sure you aren't iterating over the returned list anywhere? The error message you got suggests you are. (but maybe I'm mistaken) oldlib almost exclusively only to pass it to another oldlib function, so what I really need to do is something like this: void vala_func() { var list = old_lib_make_x_list(); var list2 = old_lib_filter_list(list); var list3 = old_lib_obscure_function_xy(list, list2); old_lib_supercomplicated_function(list2, list3); } which in c (c99) I would write like this: void c_func() { GList *list = old_lib_make_x_list(); GList *list2 = old_lib_filter_list(list); GList *list3 = old_lib_obscure_function_xy(list, list2); old_lib_supercomplicated_function(list2, list3); // old_lib_destroy_x_list destroys the list (by a call to g_list_free) but // also the contents (by a call to x_destroy for each element) old_lib_destroy_x_list(list); old_lib_destroy_x_list(list2); old_lib_destroy_x_list(list3); } This should be exactly the the expected result (that is, if you don't mind that valac uses __g_list_free__x_destroy_ instead of old_lib_destroy_x_list) So I need some way how to get the return value of old_lib list generating functions and at the same time to make sure the list gets destroyed.. In general, you shouldn't worry much about memory management: if this is something that is normally done in Vala (in your example, the user should free both the list and its contents), just declare it normally. Please tell me if this is confusing, I'm not really good in english, so if this doesn't make sense, I'll try to write some minimal piece of code which could demonstrate my problem more clearly. Your english is fine :-) And yes, a minimal reproduction of your problem would really help. Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] GLib.List
Hello, (my comments are inline, and please keep the discussion on list) 2011/5/19 Jan Spurný jspu...@seznam.cz: Hi, thanks again for your reply, Did you have any problem with the following? it should be the first thing you try (and is likely the correct thing): [CCode (cheader_filename = oldlib.h)] public static GLib.ListX old_lib_make_x_list(); Thanks for your reply, but unfortunately, it really WAS the first thing I did - but because X is not reference counted, it resulted in errors like this: oldlib.vapi:61.33-61.36: error: duplicating X instance, use unowned variable or explicitly invoke copy method public static GLib.ListX old_lib_make_x_list(); ^ Yeah, this error message is misleading. You should put unowned in your loop and not in the bindings, i.e. foreach(unowned X myx in old_lib_make_x_list()) { ... } ok, that makes sense.. unfortunately, it won't help me much - it's probably my fault, I should've explained it better - I'm using GLib.ListX returned from Are you sure you aren't iterating over the returned list anywhere? The error message you got suggests you are. (but maybe I'm mistaken) oldlib almost exclusively only to pass it to another oldlib function, so what I really need to do is something like this: void vala_func() { var list = old_lib_make_x_list(); var list2 = old_lib_filter_list(list); var list3 = old_lib_obscure_function_xy(list, list2); old_lib_supercomplicated_function(list2, list3); } which in c (c99) I would write like this: void c_func() { GList *list = old_lib_make_x_list(); GList *list2 = old_lib_filter_list(list); GList *list3 = old_lib_obscure_function_xy(list, list2); old_lib_supercomplicated_function(list2, list3); // old_lib_destroy_x_list destroys the list (by a call to g_list_free) but // also the contents (by a call to x_destroy for each element) old_lib_destroy_x_list(list); old_lib_destroy_x_list(list2); old_lib_destroy_x_list(list3); } This should be exactly the the expected result (that is, if you don't mind that valac uses __g_list_free__x_destroy_ instead of old_lib_destroy_x_list) So I need some way how to get the return value of old_lib list generating functions and at the same time to make sure the list gets destroyed.. In general, you shouldn't worry much about memory management: if this is something that is normally done in Vala (in your example, the user should free both the list and its contents), just declare it normally. Please tell me if this is confusing, I'm not really good in english, so if this doesn't make sense, I'll try to write some minimal piece of code which could demonstrate my problem more clearly. Your english is fine :-) And yes, a minimal reproduction of your problem would really help. Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] GLib.List
Hello, 2011/5/17 Jan Spurný jspu...@seznam.cz: Hi, I'm writing a new library in vala, and that library uses our old library which is written in c. Until now I was able to write VAPI files for everything in the old library, but now I stumbled on a big problem - some functions in the old library returns GLib.List with some dynamicaly allocated structs (Compact class in vala terminology) as data members. Something like this: [...] But now I'm trying to use the result of old_lib_make_x_list in vala and there it all fails. The VAPI file looks something like this: [...] Now I have probably two, equaly wrong possibilities. Either let vala manage things (it can't of course..): Another possibility is to let vala actually manage things ;-) Did you have any problem with the following? it should be the first thing you try (and is likely the correct thing): [CCode (cheader_filename = oldlib.h)] public static GLib.ListX old_lib_make_x_list(); HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Preprocessing directives in glib-2.0.vapi
Hello, 2011/5/12 JM interfl...@gmx.net: Hello In glib-2.0.vapi the binding for a GMappedFile looks like this: [...] The new unref_function is for glib versions higher than 2.22 (according to documentation). I have 2.28. Is the developer supposed to give the condition GLIB_2_22 himself? Or is the vala compiler supposed to do that? At least I can say that it is now only working correctly, if I add the -D GLIB_2_22 to the compiler args myself. You're not supposed to define it directly, rather you set --target-glib, and valac will define all the GLIB_2_xx variables up to the target version (starting from 2.14 IIRC) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Remove line numbers from logging
Hi, 2011/4/29 Ricardo Gladwell ricardo.gladw...@gmail.com: Hi Guys I'm writing some code that uses the GLib log, debug, message etc. static methods. Is there anyway to disable/remove the pre-pending of file name and line number to these outputs so that instead of: [vain] DefaultVainExecution.vala:18: Scanning for projects... I just print: [vain] Scanning for projects... This is because of the [Diagnostics] annotation, I'm not sure if we should really have it for everything (one could argue that it's only useful for debug), but it's this way. Anyway, the workaround I see is to write your own logging functions that call logv directly. HTH, Abderrahim. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Qt/C++ and Vala interoperability
Hello, 2011/4/24, Michael 'Mickey' Lauer mic...@vanille-media.de: Hi folks, some guys in the freesmartphone.org community have just launched a new telephony client project which is going to use Qt Quick as UI. While Qt can talk DBus fine, it's much more wordy and less convenient than using it from Vala. We have invested so much time in Vala that we want to do the business logic in Vala rather than in C++. Therefore we need a way to bridge between Qt and Vala. My idea was to write a script that scans for Qt signals and slots and creates stubs that handle the parameter conversion from/to Vala. Has anyone ever did that? I'd rather base on something existing before starting from scratch. I remember seeing a blog post on planet kde some time ago talking about using GobjectIntrospection to use a GObject based library from a Qt application: http://www.kdedevelopers.org/node/3878 While searching for the link I also found this: http://live.gnome.org/GObjectIntrospection/GObjectConsume Not sure they are relevant as I don't speak C++, but I hope they can help you. Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] extern function prototype gets rearranged
Hello, في ج، 15-04-2011 عند 22:34 +0100 ، كتب Sam Thursfield: Hi! I've encountered a weird bug/feature which is breaking everything. [...] compile this, and you'll see test_value_get_date() is declared in the C code like this: void test_value_get_date (TestValue *self, GDate* result); However, it's extern for a reason, and the C function prototype is to return a GDate *, not ... whatever this function is doing. Then, you should declare it as returning GLib.Date? You may also question the fact that it is declared as a struct in the vapi and not as a compact class, but I think it would be easier to just declare your function to return GLib.Date? HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Invalid assignment from owned expression to unowned variable
Hello, On Thu, Apr 14, 2011 at 6:45 PM, Joseph Montanez jmonta...@gorilla3d.com wrote: I got it, I needed public void dostuff (out unowned Soup.Message msg) and then I could do: dostuff(out msg); No you shouldn't. You probably need to transfer ownership as in: public void dostuff (out unowned Soup.Message msg) { ... msg = (owned) ...; } btw, why using an out argument? If you need to return only one value, it'd be easier to use a return value instead. في ج، 15-04-2011 عند 10:18 -0700 ، كتب Joseph Montanez: Actually when I access anything from msg, it just segment faults :( https://gist.github.com/922060 What's this? Why do you think you need 'out' here? You should simply remove the 'out' keyword (and 'unowned' as well, since it would be unowned by default). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Invalid assignment from owned expression to unowned variable
Hello, في خ، 14-04-2011 عند 07:58 -0700 ، كتب Joseph Montanez: I am trying to pass Soup.Message msg as a reference to another function but I end up getting Invalid assignment from owned expression to unowned variable. I tried void default_handlertwo (Soup.Server server, Soup.Message msg, string path, GLib.HashTable? query, Soup.ClientContext client) public void dostuff (out Soup.Message msg) //and then dostuff(out msg); //I tried casting (owned) on it as well dostuff((owned) msg); Are you sure the problem is here? I'd guess the problem is when you assign the result to msg in the dostuff method. Can you try putting the (owned) cast there? HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] generate deps file without first knowing dependencies?
Hello, في ر، 06-04-2011 عند 22:35 +0900 ، كتب Jon Rosebaugh: (Basically, I want to use https://github.com/apenwarr/redo to build, instead of a Makefile. I've come up with a rule to automatically build the fast-vapi from a .vala as required, but I still need to find a way to determine which .vapi files are needed to compile a given .vala down to C.) The way it is implemented in parvala (in the contrib directory in vala sources) is that you pass all fast vapis to valac. The deps file is only used for determining whether to recompile a given file, not to determine which vapis are used. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] shouldn't be sizeof expression is a constant?
Hello, في ث، 29-03-2011 عند 05:36 +0200 ، كتب Leonhard Küper: Hallo const int c = sizeof(int); this code is not compiled. Why? It's allowed in C I've got a similar Problem. I've tryed to complie: private const double MAX_RG B = (double)uint16.MAX; The problem here is that uint16.MAX isn't declared as a constant in the VAPI, this is probably a bug. My vala is expecting a ulong. Also sizeof apparently isn't considered a constant in Vala. Which means you cannot use const. This works for me: ulong c = sizeof(int); I'm sorry, but I don't understand. :( Should I generaly do not use constants? How do I use them? a sizeof expression isn't considered constant. I'm not sure whether this is intentional or just a bug. Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Notify, weird problem...
Hello, في ث، 29-03-2011 عند 12:17 +0300 ، كتب Dmitriy Kovalenko: I came across this, too. This is due to a API change in libnotify (that is what Juerg Billeter said). Workaround: use the --vapidir=DIRECTORY option when compiling and let DIRECTORY contain the vala-0.10.x version of libnotify.vapi. Hi, when can we expect true corrections this in 0.11.x? thanks Probably never ;-) Vala 0.11.x works only with libnotify 0.7.x. If you want to use libnotify 0.5.x, you should either use the vapi from 0.10.x, or use 0.10.x entirely. Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Setting up a GLib main loop with custom Sources with Vala 0.11.7
Hello, (See below for my attempts at improving your workarounds) في ن، 28-03-2011 عند 06:23 -0500 ، كتب Jim Peters: For reference, I have a Glib main loop with custom Source instances working now, in case anyone else needs to do it. With the 0.11.7 compiler I had to make a number of work-arounds for compiler bugs and limitations, and I had to hack my glib VAPI file. It is not ideal but it works (although I haven't checked for leaks yet). Hopefully in later versions these hacks won't be necessary. Probably this isn't the best way of solving these problems, but since I know no better ... - Change SourcePrepareFunc in the VAPI to use 'int*' instead of 'out int' for the timeout, and change the calling code accordingly: [CCode (has_target = false)] public delegate bool SourcePrepareFunc (Source source, int* timeout_); This works around bug 645838. Using 'out int' would be better in the long run. Another (better IMO) workaround is not to use a lambda expression and use a method instead. - Add a constructor for SourceFuncs in the VAPI, and implement g_source_funcs_new and g_source_funcs_free in C: [...] Note that GLib expects SourceFuncs to be static data, i.e. it doesn't copy it or do any ownership stuff. So the caller has to make sure it stays around as long as the Source remains active. That's not right, we can't have an additional C code other than what there is in glib. You can probably make it a struct instead: it will be allocated/freed automatically (as it is a value type), and could then be statically allocated. - Pass a 'guessed' size value to the Source superclass constructor. The Source constructor wants to know the size of the object constructed. The code 'sizeof(MySource)' gives the size of a pointer, not the size of the structure, so it doesn't seem possible to get this value in Vala. So I pass 256 for now which is more than enough. A workaround I see here (but that would still be a hack), is to have a new constant named SIZE in GLib.Source defined as (untested): [CCode (cname=sizeof(GSource)] public const int SIZE; and use that in the constructor (assuming you don't need additional fields in your source). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] vala compiler crash at GEE lists
في ث، 22-03-2011 عند 19:17 +0100 ، كتب Pavol Klačanský: Hi, why this not works? I looked at shotwell code, and it is written same way in it It would be easier to help you if you can post a simple and self-contained example that's not working. With just an error message, one cannot understand your problem. (since it's talking about GVariant, I guess it has something to do with DBus?) Regards, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] vala + gtk+-3.0 ?
Hello, في ر، 23-03-2011 عند 20:20 +0900 ، كتب san hoi: vala : 0.10.7 os : fedora 15 I try to compile customwidget sample in gtk+-3.0. ( http://live.gnome.org/Vala/CustomWidgetSamples#Subclassing_Gtk.Widget ) but it cannot work. [...] Is there vala's tutorial page for gtk+-3.0? And is this bug in gtk+-3.0.vapi binding? Thank you in advance for any help. No, it's just that most of the examples haven't been ported to gtk3 yet. You can try to update them by looking at the Gtk3 migration guide (it's for C, but maybe it can help) http://library.gnome.org/devel/gtk/unstable/gtk-migrating-2-to-3.html HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] two dimensional arrays
Hello, في ح، 20-03-2011 عند 13:37 +0100 ، كتب Pavol Klačanský: Why this doesn't work? I need some help with two dimensonal arrays class test : GLib.Object { struct Field { string name; string val; } public static int main(string[] args) { int row = 0, col, cols = 5; Field[,] results = {}; valac really doesn't like this declaration, but since you know how many lines and columns you have, it's better to just declare them here: Field[,] results = new Field[10,5] (that said, valac should complain politely instead of crashing) do { for (col = 0; col cols; col++) { results[row] += Field() { name = test, val = bug }; And here too, you seem to be misunderstanding how multidimensional arrays work in Vala, they have the same number of columns for every line. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [Genie] Problem with creating GtkSwitch widget
في خ، 17-03-2011 عند 10:02 +0200 ، كتب Dmitriy Kovalenko: Vala 0.11.7.1-263a8 and libgtk3.0-dev is installed (Ubuntu 10.10) Please help me to understand what is this. thanks I guess you don't have gtk 3.0 ;-p An important thing you're didn't tell is the version of libgtk3.0-dev you have installed. It's probably a development version (2.9x) that doesn't have the widget you want. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] delegates + struct initializer problem
في ث، 15-03-2011 عند 01:53 +0300 ، كتب Maga Abdurakhmanov: Hi! I'm using structure with delegate field. When I assign that field with structure initializer, then call to delegate is failed. Am I doing something wrong or is this a bug in vala? Here is the code demonstrating problem: delegate void func(); class test_class : Object { public void method() { stdout.printf(method is called\n); } } struct wrapper { unowned func f; } int main(string[] args) { var t = new test_class(); wrapper w = { f : t.method }; Well, I don't know this syntax. So either it's some obscure syntax that is buggy, or it is a coincidence that you program compiles. Either way, this is a bug in the compiler (it should either generate correct code or report an error). Anyway, the more conventional syntax wrapper w = wrapper () {f = t.method}; works. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Creating a binding for a non-glib library and using delegate to map a function pointer
في ح، 13-03-2011 عند 17:54 +0100 ، كتب Luca Dionisi: Another important point: you shouldn't use has_target=false if the library you are binding has user_data arguments, so your FunctionDelegate should be defined as public delegate void* FunctionDelegate (); And generally, you should try to avoid using void* if possible. For example, if it makes sense for your library, you can use a generic delegate. I don't get how this would map a prototype like: void foobar(void *(*f)(void *), void *user_data); We have a 'void *(*f)(void *)', it's a callback that only takes a user_data parameter (which is implicit in vala) and returns a pointer, at first it would be bound as: public delegate void* FunctionDelegate (); public void foobar (FunctionDelegate f); then, if the type of the return value can be known at compile time, i.e. the delegate isn't supposed to return a random pointer, you can convert this to generics using something like (untested): public delegate G FunctionDelegateG (); public void foobarG (FunctionDelegateG f); To be explicit in real world, I want to make a binding for GNU Pth. In their header there is: extern pth_t pth_spawn(pth_attr_t, void *(*)(void *), void *); It's better to look at their documentation rather than their header :-) Otherwise, I think what I said above applies. You can also take a look at how this is done in the GLib threading API for inspiration ;-) http://git.gnome.org/browse/vala/tree/vapi/glib-2.0.vapi#n1777 HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Creating a binding for a non-glib library and using delegate to map a function pointer
في ج، 11-03-2011 عند 16:25 +0100 ، كتب Luca Dionisi: Perhaps I got the point where I was wrong. On Fri, Mar 11, 2011 at 12:42 PM, Luca Dionisi luca.dion...@gmail.com wrote: First pass, I prepared a direct mapping vapi. libfoo.vapi[http://pastebin.com/rZb6JqAZ] [IMPORTANT note: if I don't miss something, I have [to create a delegate, named FunctionDelegate, in the vapi [file in order to map the function pointer argument. Another way to do that is to define the delegate in another vala source file and include it in the compilation where libfoo.vapi is used. I think it would be better to just create a new header that you reference in the vapi, it would be easier to distribute with your wrapping library. Another important point: you shouldn't use has_target=false if the library you are binding has user_data arguments, so your FunctionDelegate should be defined as public delegate void* FunctionDelegate (); And generally, you should try to avoid using void* if possible. For example, if it makes sense for your library, you can use a generic delegate. HTH, Abderrahim P.S. It may be more productive to ask questions directly on real-world libraries rather than making a little foo library. P.P.S. For little files like these, it would be better to inline or attach them, so people can read them when offline. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Regression on async with nullable out parameters
في س، 12-03-2011 عند 11:56 +0800 ، كتب Nor Jaidi Tuah: The following crashed when compiled with Vala 0.11.6. This is a regression since it works with 0.9.x. [...] When the while expression is changed to while ((line = yield input.read_line_async (100, cancellable, null)) != null) { then it works. i.e. out length doesn't work, but null does. Is this a known regression? This is a bug in the bindings: length shouldn't be nullable in this case. Please file a bug so it isn't forgotten. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] problem with Object.get_class()
Hello, I thought I've already answered this, but maybe I forgot. في ث، 08-03-2011 عند 15:49 +0300 ، كتب Maga Abdurakhmanov: Any ideas? Is this a bug in Vala? Shouldn't x.get_class() return an instance of ObjectClass ? It should and it does in my tests :-) The problem is that calling g_type_class_ref on the returned ObjectClass returns null. I don't know exactly why, but I see the warning at C compilation as a hint that there may be a bug in the bindings: why g_type_class_ref is the ref function of GLib.TypeClass, when the former is supposed to take a GType as a parameter. Anyway, here is my answer, I found it in the drafts folder: 2011/3/3 Maga Abdurakhmanov maq...@gmail.com: It works when changed the line: ObjectClass objectClass = t1.get_class(); to: ObjectClass objectClass = (ObjectClass)t; I consider this to be a hack (and it may cause you trouble). I think you should either use unowned ObjectClass objectClass = t1.get_class(); if you have an object, or ObjectClass objectClass = t.class_ref(); HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Abuse of unowned?
Hello, في ث، 08-03-2011 عند 02:49 + ، كتب Pg Dr Hj Norjaidi bin Pg Tuah: The following code crashes when compiled with 0.11.6 due to an attempt to deallocate the static string bar (https://bugzilla.gnome.org/show_bug.cgi?id=642350). struct Foo { public string foo; public string bar; } void main() { Foo f = Foo() {foo = foo, bar = N_(bar)}; } As a work around, I change the struct strings to unowned. Thus: struct Foo { public unowned string foo; public unowned string bar; } That seems to work. But I'm apprehensive here. Is my workaround safe? Am I abusing unowned? I'd say you should just take care, your workaround is not inherently unsafe, and isn't really an abuse (I'd call that aggressive optimisation). You should make sure that the strings you assign to these fields aren't going to be freed somewhere else. For example, if they are always static strings, you should be fine. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] correct char ** binding
Hello, في ث، 08-03-2011 عند 17:57 +0100 ، كتب Jan Spurny: Hi Frederik, 'out string' will not work - that was the first thing I tried - problem is that if I would have used 'out string' in 'setup' function, the generated C code will pass some temporary variable to 'setup' and not the location of the required location. That is the reason why I've included that long explanation how it works. Maybe I was not clear enough, so let me explain again: 1) 'setup' functions takes 'location' of 'char*' destionation variable and stores it along with 'name' in 'SomeParser' structure 2) 'run' then does the parsing and fills all locations described by their names by previous 'setup' calls 3) now all destionations registered with 'setup' are filled I see two solutions here: either you use ref (even if it wasn't really supposed to be used like this, it assumes the reference is valid), or you use pointers. I feel pointers are the right thing to do here, but you should take care with memory management. I'd use: public void setup(string name, string** location); and then you use it: string a = null; x.setup(variable_a, a); Using ref would probably work as well, but I prefer pointers as that will make it clear to the user of the API that there is something unusual here. Another thing - I know that 'char *' is 'string', but why 'string a_str = a;' does not work? You shouldn't know that ;-) Although they map to the same thing in C, they are different things in Vala. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] question on async methods
Hello, في ر، 02-03-2011 عند 16:30 +0100 ، كتب Luca Dionisi: What I guess is that: . when a async method never calls a yield, then it is implicit a yield at the end of the method . the implicit continuation is implicitly registered with the MainLoop perhaps with a higher priority than Idle. Is my interpretation correct? More or less: when an async method never yields, it isn't necessarily running in the main loop, in this case it schedules its completion as an idle [1], since otherwise it won't be considered async (i.e. it will keep running until it's finished, and if it was called from an async method using the yield keyword, flow passes back to the async method that called it). Otherwise (when it has already been run from the mainloop), it can complete in the . Is this behavior wanted? I guess it is. I find it particularly annoying because I would prefer to implement my own scheduler instead of relying on MainLoop. Well, this was mainly done with async IO in mind, so if you need a very specific scheduling, maybe you should look at alternatives. HTH, Abderrahim [1] it does this using g_simple_async_result_complete_in_idle, see http://library.gnome.org/devel/gio/stable/GSimpleAsyncResult.html#g-simple-async-result-complete-in-idle ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Coroutines in vala: libtask, pthread or simply async?
Hello, في ج، 25-02-2011 عند 19:45 +0100 ، كتب Luca Dionisi: 1. In a synchronous method the app instantiate some sort of scheduler. It may be a MainLoop or something else that I can implement by myself. Right, but I think a MainLoop is enough for most purposes (you can make a custom GSource for implementing whatever policy you want, although after a quick look at the current bindings they may be unusable right now). Furthermore: 1. The asynchronous methods can call normal methods, but only if those callee won't ever need to yield. I'm not sure I understand this one. 2. An asynchronous method can call another async method with yield. In this way it will wait for the return value. 3. A method (sync or async) can call an async method with begin(). In this way it will, say, launch another independent pseudo-thread. 4. If async method A wants to call method B and B wants to call async method C and then pass the return value to A, then B has to be async and all the calls have to use the yield keyword. (at least it seems so to me, for the tests I did) Yes, the other way is to have method B call method C synchronously, that is start a recursive main loop for that call. IIRC, this was planned to be done in vala, but it's still not implemented. You can do it manually, but if you are using async methods in the first place, you shouldn't need this sort of hacks. Is this [one of] the way that this feature is supposed to be used? There is one thing I would need to be able to do. When some code starts a new async call with begin() (I would call this launching a pseudo-thread, or is there some better expression?) I would like that code to be able, in future, to tell the scheduler to kill that pseudo-thread. It should work like this: 1. a pseudo-thread A creates a new thread with xyz.begin() 2. xyz might call some other async method with yield qwe() 3. qwe wants to let other tasks to work; so it registers qwe.callback with the scheduler and then yields. 4. the scheduler eventually gives the control back to the pseudo-thread A. 5. A asks the scheduler to kill the psuedo-thread xyz, that it created. 6. How can the scheduler know that in order to kill xyz it just has to remove qwe.callback from its queue? The proper way for a pseudo-thread (and no, I don't know the proper way to say this) to terminate is to return, i.e. if you use yield in an async method, it is suspended, but resources it has allocated aren't freed, so if the callback isn't called, you get a memory leak. So you need to tell the async method to terminate, rather than kill it, otherwise you're in trouble ;-) I'm not sure what's the best way to do this, but that's what you'd need to do. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [Genie] bug: stacking classifiers
Hello, في ث، 22-02-2011 عند 13:53 -0500 ، كتب Arc Riley: The following code works in Genie: [CCode (cprefix=FOO_)] class Foo The following code does not: [Compact] [CCode (cprefix=FOO_)] class Foo Every combination I've tried fails, noting the problem being the [ on the second line. I don't know how it is exactly supposed to be, but the following works: [Compact, CCode (cprefix=FOO_)] class Foo HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Ctags support?
Hello, في س، 12-02-2011 عند 16:24 -0600 ، كتب Damien Radtke: Does anyone know if there's a ctags build that supports vala? Anjuta IDE [1] has a fork of ctags named anjuta-tags that supports vala (if libvala is available). So if you have anjuta installed, you can use that. There is also an old patch for adding vala support in my blog [2], but I believe it doesn't work anymore (I only updated the anjuta copy). HTH, Abderrahim [1] http://anjuta.org/ [2] http://abderrahim.arablug.org/blog/archives/4-Vala-support-for-ctags.html ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] [valencia] error while make. vala-1.0 not found
Hello, في ر، 09-02-2011 عند 11:25 +0100 ، كتب blue hut: Hello, I tried to install valencia and got an error while make. I am using Ubuntu 10.10 and i think i installed all dependencies. This is what i get after typing make: Package vala-1.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `vala-1.0.pc' to the PKG_CONFIG_PATH environment variable No package 'vala-1.0' found make: *** [libvalencia.so] Fehler 1 This is most likely because the version of valencia you've downloaded is too old (made for vala 0.8.x). HTH, Abderrahim P.S. in the future, please try to put any relevant info (here, the fact that you're compiling valencia) somewhere in the subject. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Virtual methods in interfaces
Hello, في ج، 28-01-2011 عند 18:30 +1030 ، كتب James Moschou: But see this is just a workaround. What I want is for the subclass to inherit the interface and the interface implementation from the base class, and override certain aspects. But what you have to do instead is reimplement the interface, and override everything again. The two are the same thing in these examples because they are so trivial. But consider: You almost got me with this one, but still I think I'm right :-p You just found a bug in valac, but let's see your output. For the subclass you got : subclass - virtual interface - other virtual Segmentation fault here I get this instead (using the tip of switch-to-gir branch, which is based on 0.11.3): subclass - virtual class - other virtual Segmentation fault So the second one is correct (i.e. has probably been fixed meanwhile). However, the third one still fails (the abstract interface method implemented as non-virtual method). Using gdb, I found out that it is an infinite recursion problem and commenting out the line : iface-abstract_function = (void (*)(Interface*)) interface_abstract_function; in the generated code makes it work as expected (i.e. I get class - abstract). So you just have found a bug (rather 2, but one is already fixed). It might be a good idea to test all combinations of abstract/virtual/implemented as virtual/normally implemented, etc. with latest vala and report exactly what works and what doesn't. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Virtual methods in interfaces
Hello, في خ، 27-01-2011 عند 16:13 +1030 ، كتب James Moschou: On 25 January 2011 23:36, Abderrahim Kitouni a.kito...@gmail.com wrote: but if you remove the override keyword, it works ;-) So now the question is : is this intentional? I always thought that you don't need override when implementing an abstract method (and need override when there is already an implementation), but it seems I was wrong. This probably needs an answer from Jürg (and the rationale to be added somewhere in the documentation). I'm aware that it works if you don't use the override keyword, and it does seem unintentional, considering that the behaviour of abstract/virtual/override/new is pretty well defined for normal class inheritance, and vala emits warnings if you don't do it correctly. I'm not sure it's completely unintentional, Vala can be such an awkward language at some times (but we still love it ;-)). See below. This issue is actually a precursor to my real question, which I don't think has come up before on this list exactly, although similar threads have touched on it. I really want to be able to define a class as implementing an interface with default implementations of virtual methods, and have subclasses of that class override the virtual methods. So: [...] But I suspect this is impossible with the way GObject is designed, which would be a shame. Nothing is impossible in Vala, things just happen to be weird ;-p You won't believe the answer is so easy, I've tried many ways before finding the correct answer (I've even written a long paragraph trying to argue how it could be possible in GObject). You just need to declare that your subclass implements the interface (and of course remove the override keyword). So the following code: interface Interface { public virtual void function () { print (interface\n); } } class Class : Object, Interface {} class Subclass : Class, Interface { public void function () { print (subclass\n); } } var bc = new Class(); bc.function(); var sc = new Subclass(); sc.function(); prints: interface subclass HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Virtual methods in interfaces
Hi, في ث، 25-01-2011 عند 21:35 +1030 ، كتب James Moschou: Is is possible to mark methods as virtual in interfaces, as a mechanism of providing default implementations? If I do interface Interface { public virtual void function () { // Default } } class Class : Object, Interface { public override void function () { // Custom } } The compiler says that no method to override was found. but if you remove the override keyword, it works ;-) So now the question is : is this intentional? I always thought that you don't need override when implementing an abstract method (and need override when there is already an implementation), but it seems I was wrong. This probably needs an answer from Jürg (and the rationale to be added somewhere in the documentation). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] vapi Autoupdate
Hello, في خ، 20-01-2011 عند 17:54 -0600 ، كتب Daniel Espinosa: Is it recommended to allow a library like GDA to update its Vala's vapi on build and install? Any sugestions? Ideally, the vapi should be taken care of by the original library, but this isn't always feasible (often maintainers don't want to be bothered with this Vala thing). And btw, if GDA does have a gir (as most gobject libraries do), it may be a better idea to generate the vapi from the gir directly (it'll reduce duplication: you fix the annotations once and every binding profits). This functionality is still considered experimental, but should mostly work with recent Vala (=0.11.2). HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] V4l2 - STREAMON Fails
Hi, It's not clear what your problem is, can you explain exactly what you did, what you expected, and what error you got? Anyway, see below for a guess at a solution. في ر، 19-01-2011 عند 21:42 +0800 ، كتب Ervin: One thing i noticed in the converted c code are following lines: ... BufferType type = 0; ... type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl (self-priv-fd, VIDIOC_STREAMON, type) == (-1)) { } ... Why is the BufferType not converted to something like enum v4l2_buf_type? That's probably a bug in the vapi, try adding cname to the CCode annotation like : [CCode (cprefix=V4L2_BUF_TYPE_, cname=enum v4l2_buf_type)] and should the parameter type in my ioctl be prepended with , thus making it type? I'm confused, is this supposed to be a question or an affirmation? Anyway, if it should be type, then you should write it as type in the vala file. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] uint8[] GObject properties
Hello, في خ، 20-01-2011 عند 22:13 -0600 ، كتب W. Michael Petullo: I have written a GObject class that has the following property: [...] private uint8[] _thumbnail; [...] public uint8[] thumbnail { get { return _thumbnail; } set { _thumbnail = value; } } [...] When I run my application, I see: (lt-dpapview:13731): GLib-GObject-WARNING **: g_object_set_valist: object class `ValaDPAPRecord' has no property named `thumbnail' But, if I replace uint8[] with string, then I see no such error at runtime. When I inspect the generated C source, I find that there is no reference to thumbnail in _get and _set_property() when it is declared as a uint8[]. Is this expected? Yes, not all properties are registered with gobject. I don't know if this is documented somewhere, but here is the source code: http://git.gnome.org/browse/vala/tree/codegen/valagobjectmodule.vala#n695 In short, it won't be registered if it is private or static, if it is a delegate with target, _if it is an array_ (except for string[]), or if it is a struct that isn't registered with gtype. You should be able to use _get_thumbnail and _set_thumbnail from C, it's just that you cannot use g_object_set and g_object_get. What type should be used for properties that hold binary data, possibly read using GLib.FileUtils.get_data()? That's a good question, to which I have no answer. uint8[] started being used systematically for binary data only recently, so I doubt you'll find a definitive answer. You can create a wrapper type (i.e. a struct containing it as it's only field), but there may be there is a better way. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Gda GdaSet vapi error
في ر، 12-01-2011 عند 10:10 -0600 ، كتب Daniel Espinosa: The following function have the following C signature: gboolean http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean gda_set_set_holder_value http://library.gnome.org/devel/libgda/stable/GdaSet.html#gda-set-set-holder-value (*GdaSet http://library.gnome.org/devel/libgda/stable/GdaSet.html *set*, *GError http://library.gnome.org/devel/glib/unstable/glib-Error-Reporting.html#GError **error*, *const gchar http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gchar *holder_id*, *...*); but in vapi is: public bool set_holder_value (string holder_id) throws GLib.Error; How can I change update it? You need to add something like : gda_set_set_holder_value ellipsis=1 to the metadata file (and regenerate the vapi). I'm not sure it will work as there is no fixed convention for varargs methods throwing errors, but I think this is your best bet. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Different flags for vapi generation
Hello, في ن، 10-01-2011 عند 18:52 -0800 ، كتب Anatol Pomozov: Hi, I see several different flags for 'valac' that look similar --library --fast-vapi --vapi --internal-vapi/internal-header --vapi (use with --library) is probably the one you need, and generates a standard vapi. (if you pass --library without --vapi, then the vapi is still generated and uses the same name as the library. I'm not sure if this is still intended to be used, or is just for compatibility with older valac that doesn't have --vapi). --internal-vapi generates a vapi that includes internal API, and is useful if you compile parts of your program separately from the rest and still want to use internal API. (not sure this is still useful now that we have fast vapi). --fast-vapi is relatively new, and is supposed to allow parallel compilation of vala code. See http://live.gnome.org/Vala/Documentation/ParallelBuilds --internal-header doesn't generate a vapi, but generates a C header containing internal API, this is only useful if your program is written in both C and Vala and you want to call vala code from C. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] uuid binding
Hello, في ث، 04-01-2011 عند 13:49 +0100 ، كتب Pavol Klačanský: Hi, is there working uuid bindings? http://mike.trausch.us/blog/2009/02/18/vala-bindings-for-non-gobject-type-c-libraries/ explains how to write such a vapi, I'm not sure it's still working, but I guess it won't be difficult to update if it isn't the case. (you can always ask for help here) HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Gee Bindings not working
Hi, في ث، 04-01-2011 عند 16:08 +0300 ، كتب Ndubi Abenga: I was trying to compile a small program that uses libgee, but I suddenly started getting the following error: error: Package `gee-1.0' not found in specified Vala API directories or GObject-Introspection GIR directories It seems that valac cannot find gee-1.0.vapi, if you can find it manually (it should be in some $prefix/share/vala/vapi) try to pass the containing directory to valac with --vapidir and see if it works. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Can't compile vtg trunk r846 - missing generic type arguments
Hello, في ر، 22-12-2010 عند 15:16 + ، كتب Dennis Ostermann: Hi I tried to compile vtg from trunk with vala-0.11.2. Sadly it's fails with: [...] completionengine.vala:250.22-250.39: error: cannot infer generic type argument for type parameter `GLib.Thread.create_full.T' _parser_thread = Thread.create_full (this.parse_sources, 0, true, false, ThreadPriority.LOW); Look at the return type of parse_sources, and add it to create_full like : _parser_thread = Thread.create_fullvoid* (...); HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list