Re: [Vala] Need Help with GLib.OptionEntry
Hi Karsten, this is happening, because you left out the third field in each entry of your array, which corresponds to the option flags: http://developer.gnome.org/glib/2.28/glib-Commandline-option-parser.html#GOptionFlags I pasted your code here and had a close look on the compiler's output. Then you can see that the errors start with the filename. So the compiler complains about a string (list), two booleans (interactive and conserve) and finally an integer (start). The compiler is fine with the first two entries in your array (pre and post). The difference between the first two entries and the others is the member 'flags': { "post", 0, 1,<- this one } So if you provide a field value for the other entries, then you're set: { "list", 'l', 0, ...}, { "interactive", 'i', 0, ...}, { "conserve", 'c', 0, ...}, { "start", 's', 0, ...} Hope this helped. Best, Gilzad - original Nachricht Betreff: [Vala] Need Help with GLib.OptionEntry Gesendet: Mo, 18. Apr 2011 Von: K. König > Hi, > > I write a program which need command line arguments. I want to > implement this feature with the command line parser of the GLib. I read > the C and the Vala reference of the related topics but get an error > with the C compiler. Maybe knows somebody what goes wrong. > > > Error messages: > > error: incompatible types when initializing type enum > using type char ** > error: incompatible types when initializing type enum > using type gboolean * > error: incompatible types when initializing type enum > using type gboolean * > error: incompatible types when initializing type enum > using type gint * > > > An here is the related code: > > string pre; > string post; > string filename; > bool interactive; > bool conserve; > int start; > > const OptionEntry[] entries = { > { "pre", 0, 1, OptionArg.STRING, ref pre, "set prefix that will be > placed to the left of the number", "PREFIX" }, { "post", 0, 1, > OptionArg.STRING, ref post, "set postfix that will be placed to the > left of the number", "POSTFIX" }, { "list", 'l', OptionArg.FILENAME, > ref filename, "use a list of files instead of all files in the > directory", "LIST" }, { "interactive", 'i', OptionArg.NONE, ref > interactive, "choose which files should be renamed interactive", > null }, { "conserve", 'c', OptionArg.NONE, ref conserve, "conserve file > extension", null }, { "start", 's', OptionArg.INT, ref start, "set > startnumber", "START" } }; > > static int main(string[] args) { > var opt_context = new OptionContext("- Options for simpleRenamer"); > > opt_context.set_help_enabled(true); > opt_context.add_main_entries(entries, null); > > try { > opt_context.parse(ref args); > } > catch(OptionError error) { > stdout.printf("%s", error.message); > } > > return 0; > } > > > Regards, > > Karsten > ___ > vala-list mailing list > vala-list@gnome.org > http://mail.gnome.org/mailman/listinfo/vala-list > --- original Nachricht Ende ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] global mouse pos / multitouch
Hi all, I'm having a hard time finding out how to get the global mouse position in vala. Using Gtk, I was only able to get the coordinates inside a shown window. To use Xcb, I seem to be missing the knowledge about the required members. And using X11 bindings, I fail at the point, where I try to declare X.WindowAttributes, which I'd need to pass as a reference. Trying this.. X.Display display = new X.Display(); X.WindowAttributes windowAttributes; display.get_window_attributes(display.default_root_window(), out windowAttributes); .. the compiler (v0.17) says: mouse_position.vala.c:(.text+0x12e): undefined reference to `window_attributes_destroy' Ideally I'd use a library to receive many mouse positions at a time. I believe there should be a way as Gnome 2.30.2 already supports 2-finger scrolling. If not, my hope is that I'll be flooded with events for each finger. If I'm not totally wrong, uTouch would require a newer Gtk, so I can't use it. Thanks a bunch for any hint. gilzad -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] global mouse pos / multitouch
Hello, a very basic answer to this would be the following example: X.Display display = new X.Display(); X.Event event = X.Event(); X.Window window = display.default_root_window(); display.query_pointer(window, out window, out event.xbutton.subwindow, out event.xbutton.x_root, out event.xbutton.y_root, out event.xbutton.x, out event.xbutton.y, out event.xbutton.state); print("Mouse Coordinates: " + event.xbutton.x.to_string() + "," + event.xbutton.y.to_string() + "\n"); I have derived the code from this example in C: http://ubuntuforums.org/showpost.php?p=4110065&postcount=7 Also, the x11.vapi has to be extended by the following binding to make the code work: [CCode (cname = "XQueryPointer")] public bool query_pointer (Window w, out Window root_return, out Window child_return, out int root_x_return, out int root_y_return, out int win_x_return, out int win_y_return, out uint mask_return); However, on multitouch devices it won't work. For some reason, the coordinates won't be passed to the application as soon as you place two or more fingers on the touchpad. I tested that temporarily in a silly loop. Any idea how to approach for multitouch devices? Thanks, gilzad Original-Nachricht > Datum: Tue, 05 Jun 2012 16:48:47 +0200 > Von: "Gilzad Hamuni" > An: vala-list@gnome.org > Betreff: [Vala] global mouse pos / multitouch > Hi all, > > I'm having a hard time finding out how to get the global mouse position in > vala. > > Using Gtk, I was only able to get the coordinates inside a shown window. > To use Xcb, I seem to be missing the knowledge about the required members. > And using X11 bindings, I fail at the point, where I try to declare > X.WindowAttributes, which I'd need to pass as a reference. > > Trying this.. > > X.Display display = new X.Display(); > X.WindowAttributes windowAttributes; > display.get_window_attributes(display.default_root_window(), out > windowAttributes); > > .. the compiler (v0.17) says: > mouse_position.vala.c:(.text+0x12e): undefined reference to > `window_attributes_destroy' > > Ideally I'd use a library to receive many mouse positions at a time. I > believe there should be a way as Gnome 2.30.2 already supports 2-finger > scrolling. If not, my hope is that I'll be flooded with events for each > finger. > If I'm not totally wrong, uTouch would require a newer Gtk, so I can't use > it. > > Thanks a bunch for any hint. > > > gilzad > -- > NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! > > Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a > ___ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Rv: C to Vala
If I understand correctly, that approach requires an intermediate bytecode either from Java or from .NET to finally create sourcecode. Alas, in the OP's case the best we can get would be native machine code (being different for x64, i386, arm, etc) so the parser wouldn't be able to stick to one static 'syntax', even if it would support Vala as an output. I'm guessing here, but: If it's possible to automatically generate vapi's out of g-object-based libraries, then a similar tool might be able to create vala-code out of g-object-based sourcecode. But I'm really just guessing here, not knowing anything about the effort behind it. At least the need for such a tool (that turns C-code into Vala just before C-code is generated again) proves that vala is a favourable language :) Interesting though that XMLVM can create Objective-C-code. Gilzad Original-Nachricht > Datum: Thu, 20 Sep 2012 12:09:39 -0700 > Von: Eric Gregory > An: Mario Daniel Ruiz Saavedra > CC: Vala List > Betreff: Re: [Vala] Rv: C to Vala > On Thu, Sep 20, 2012 at 12:01 PM, Mario Daniel Ruiz Saavedra < > desideran...@rocketmail.com> wrote: > > > > > > > Unlikely. You are confusing translate with transform. Please argue > > properly. > > > > > He's right though -- the relationship between C and Vala is not 1:1 unless > the C code was generated by valac. Converting arbitrary C code into Vala > is possible, but unwieldy. > > A professor from my college days did a project that converts between > various languages. It's quite complex, but amazingly all the conversion > is > done in XSLT. I'd recommend checking it out to see what kind of territory > you're wading into here: http://xmlvm.org > > - Eric ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Examples in documentation
Hi all, maybe it's already there and I missed to see it. Is it possible to have some account on an existing valadoc-page, so one could add code-examples online rather than working with the markup locally? Knowing that vala is still evolving, I'm facing one issue that probably could be solved rapidly. Except of the given tutorials, if someone wants to implement some feature in his application, he either has to 1) guess how he'd use the vala bindings (requires firm experience with glib) or 2) he has to derive the vala-code from some existing C-code, that is using the same library or 3) crawl through some existing vala-projects that would offer an example, somewhere deep inside their source. Now, once a dev has achieved to have some working code, he might want to share this as an example, so others will quickly find out how to use function X from vapi Y. Wouldn't it boost vala's easy-to-efficient-ratio, if code-examples were attached to the documentation (like on msdn or php.net)? Maybe it could be some great advertising, too "Wow, that's just a three-liner!". Sorry if this has been discussed before, I couldn't find anything related after a quick search. Best, Gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Access GTKText
Hi list, I've compiled and tested this C-tutorial that shows how to have different fonts, colors and and sizes in a single text box: http://www.gtk.org/tutorial1.2/gtk_tut-14.html GtkWidget *text; ... text = gtk_text_new (NULL, NULL); ... fixed_font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-140-*-*-*-*-*-*"); ... gtk_text_insert (GTK_TEXT (text), fixed_font, &text->style->black, NULL,"Hello\n", -1); Now I'd like to do the same in Vala. I've looked through valadoc and what valencia's completion would provide. But I couldn't find the keywords I expected in the Gtk namespace. Basically, I need an object that provides the gtk_text_insert(...) function, which allows me to add formatted text immediately. VteTerminal, SourceView and TextView seem to be too limited, as they doesn't seem to provide such a function. Or am I just to blind to find a substitude that is as rich? My understanding of creating GIR and VAPIs is not sufficient, but I think I wouldn't have to do this for gtktext.h, because the whole gtk-library is available to vala already? I'll be happy about any input. Thanks a bunch in advance. gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Access GTKText
Perfect! Thank you so much for the info and the helpful example file! Interesting to learn that insert_with_tags(..) can receive many parameters of a TextTag in order to apply many properties (red, bold, fixed) at once. Thanks once again for the great help. Best, gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Check if event-handler is registered already
Hi all, suppose I have a class that can take callbacks to invoke them in case of any event: public signal void DataReceived(uint8 byte); //... DataReceived(byte); ...and I have a client that registers its handler to it: someInstance.DataReceived.connect(OnDataReceived); //... private void OnDataReceived(uint8 byte) { //do something. } ..how can I check if my handler was registered already to avoid it from being registered a several times? I'd like to do something like this: if( !someInstance.DataReceived.handler_is_connected(OnDataReceived) ) { someInstance.DataReceived.connect(OnDataReceived); } Thanks in advance for any hint. gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Check if event-handler is registered already
Hi again, this was a GLib-related question, but for some reason I hadn't been careful enough, which made me ask here. Sorry. The answer is: You have to memorize the given handler ID, if you like to check whether your handler is registered already. Then you can use GLib.SignalHandler(instance, handlerId) to find out if the handler is connected: ulong dataReceivedHandler = 0; if(!SignalHandler.is_connected(someInstance, dataReceivedHandler)) { dataReceivedHandler = someInstance.DataReceived.connect(OnDataReceived); } private void OnDataReceived(uint8 byte) { //do something. } It's safe to start off by checking a handler ID whose value is 0, because SignalHandler.is_connected() will return false then. Best, gilzad Gesendet: Dienstag, 15. Juli 2014 um 15:07 Uhr Von: "Gilzad Hamuni" An: vala-list@gnome.org Betreff: [Vala] Check if event-handler is registered already Hi all, suppose I have a class that can take callbacks to invoke them in case of any event: public signal void DataReceived(uint8 byte); //... DataReceived(byte); ...and I have a client that registers its handler to it: someInstance.DataReceived.connect(OnDataReceived); //... private void OnDataReceived(uint8 byte) { //do something. } ..how can I check if my handler was registered already to avoid it from being registered a several times? I'd like to do something like this: if( !someInstance.DataReceived.handler_is_connected(OnDataReceived) ) { someInstance.DataReceived.connect(OnDataReceived); } Thanks in advance for any hint. gilzad ___ 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
[Vala] Disconnect socket connection
Hi all, I've written a little tcp client class and it works well, except that I can't disconnect an existing connection. private SocketClient client; private SocketConnection conn; public void Connect() { client = new SocketClient(); conn = client.connect(socketAddress, null); } public void Disconnect() { stdout.printf("TcpClient.Disconnect(): Disconnecting...\n");//I do arrive here. conn.socket.close(); conn.close(); conn.dispose(); client.dispose(); conn = null; client = null; //no exception/assertion will occour. All the commands will be executed but won't affect the connection. } None of what I'm trying here does really disconnect my connection. I traced it in Wireshark and nothing happens (no RST). Even nulling the instance of my own Tcp client doesn't help. Unless I close my whole application, only then the connection will be terminated. But I can't force the user to close the application just to disconnect and connect again. I'll be glad about any help. Thanks. gilzaderrordomain Error { MESSAGE } //compile with: valac --pkg=gio-2.0 tcpClient.vala public class TcpClient { private InetAddress inetAddress; private int port; private SocketConnection conn; private SocketClient client; public signal void DataReceived(uint8 byte); public signal void Disconnected(); private bool connected = false; public TcpClient () { //stdout.printf("TcpClient: Instantiated.\n"); } public void Connect(string ipAddress, int port) throws IOError { inetAddress = new InetAddress.from_string(ipAddress); this.port = port; client = new SocketClient(); stdout.printf("TcpClient: Trying to connect to "+inetAddress.to_string()+":"+port.to_string()+"...\n"); try { process_request(); } catch (Error e) { stderr.printf("TcpClient.Connect(): Starting reading process failed.\n\t"+e.message+"\n"); } } /** * Reports whether the connection got * terminated either by the client or by the host. */ public void Disconnect() { if(!conn.closed) { try { stdout.printf("TcpClient.Disconnect(): Disconnecting...\n"); conn.socket.close(); conn.close(); this.connected = false;//set state first! Disconnected();//then fire event to anounce the state. conn.dispose(); client.dispose(); conn = null; client = null; } catch (GLib.IOError e) { stderr.printf("TcpClient.Disconnect(): Had trouble closing the connection. Stopped reading anyway.\n\t"+e.message+"n"); } } else { stdout.printf("TcpClient.Disconnect(): Already disconnected.\n"); } } public bool Connected { get { return this.connected; } } public void Write(string message) { if(connected) { //stdout.printf("TcpClient: Trying to write \""+message+"\" into the stream.\n"); try { conn.output_stream.write(message.data, null); } catch (GLib.IOError e) { stderr.printf("TcpClient.Write(): Couldn't write \""+message+"\" into stream.\n\t"+e.message+"\n"); Disconnect(); } //stdout.printf("TcpClient: Done writing \""+message+"\" into the stream.\n"); } else { stdout.printf("tcpClient.Write(): Not connected. Won't send \""+message+"\".\n"); } } public void WriteByte(uint8 byte) { if(connected) { //stdout.printf("tcpClient.WriteByte(): Sending \""+byte.to_string()+"\"...\n"); try { conn.output_stream.write(new uint8[]{byte}); } catch (GLib.IOError e) { stderr.printf("TcpClient.WriteByte(): Couldn't write byte \""+byte.to_string()+"\" into stream.\n\t"+e.message+"\n"); Disconnect(); } } else { stdout.printf("tcpClient.WriteByte(): Not connected. Won't send \""+byte.to_string()+"\".\n"); } } private void process_request () throws Error { InetSocketAddress socketAddress = new InetSocketAddress(inetAddress, (uint16)port); try { conn = client.connect(socketAddress, null); if(!conn.closed) { stdout.printf("TcpClient: Connected.\n"); connected = true; } } catch (GLib.Error e) { stderr.printf("TcpClient.process_request(): Could not establish connection.\n\t"+e.message+"\n"); //Disconnect(); return; } // we set the socket back to blocking here for the convenience // of DataInputStream //conn.socket.set_blocking (true); DataInputStream input = new DataInputStream (conn.input_stream); ThreadFunc run = () => { while(connected) { try { uint8 byte = input.read_byte(null); DataReceived(byte); stdout.printf(((unichar)byte).to_string()); } catch (GLib.IOError e) { stderr.printf("tcpClient.process_request(): Had trouble reading input byte.\n\t"+e.message+"\n"); Disconnect(); return null; } } return null; }; new Thread("readThread", run); } } ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Disconnect socket connection
Thanks a bunch, Andrew! The Socket class' shutdown() helped. I'm not sure if I can use the ThreadedSocketService for client side connections though. But it's a good idea for another project, where my application is the server. So thanks for both. :) Best gilzad Gesendet: Dienstag, 29. Juli 2014 um 00:29 Uhr Von: "Andrew Benton" An: "Gilzad Hamuni" Betreff: Re: [Vala] Disconnect socket connection Try using the Socket class' shutdown() method. http://www.valadoc.org/gio-2.0/GLib.Socket.shutdown.html I don't have time to try it out atm. I also know that if you use the ThreadedSocketService, you can get a connection to shutdown whenever then run() delegate returns. That could make your job easier. Thanks, Andrew On 7/28/2014 11:12 AM, Gilzad Hamuni wrote: Hi all, I've written a little tcp client class and it works well, except that I can't disconnect an existing connection. private SocketClient client; private SocketConnection conn; public void Connect() { client = new SocketClient(); conn = client.connect(socketAddress, null); } public void Disconnect() { stdout.printf("TcpClient.Disconnect(): Disconnecting...\n");//I do arrive here. conn.socket.close(); conn.close(); conn.dispose(); client.dispose(); conn = null; client = null; //no exception/assertion will occour. All the commands will be executed but won't affect the connection. } None of what I'm trying here does really disconnect my connection. I traced it in Wireshark and nothing happens (no RST). Even nulling the instance of my own Tcp client doesn't help. Unless I close my whole application, only then the connection will be terminated. But I can't force the user to close the application just to disconnect and connect again. I'll be glad about any help. Thanks. gilzad ___ vala-list mailing listvala-l...@gnome.org[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
[Vala] Pass params through threads_add_idle()
Hi all, I'm trying to pass a parameter to a function that I call through threads_add_idle(). But threads_add_idle() obviously accepts only a SourceFunc. I can't pick up the data from a global variable. So I tried using closures from where I'd pass the needed parameter: private void ThreadedFunc(uint 8 byte) { Gdk.threads_add_idle(()=> { GuiWorker(byte); return false; }); } But then the class of GuiWorker is not instantiated, so I get an assertion during runtime (self != null). If I don't try to pass the parameter and just pass 'GuiWorker' to threads_add_idle() directly (given 'GuiWorker' doesn't take any params then), then the instance does exist. Before that, when I used the deprecated methods Gdk.threads_enter() and Gdk.threads_leave(), I could help myself by doing whatever I wanted in between. But how can I work with threads_add_idle() now? The vala bindings omit its second parameter 'data', so I'd be glad if you could tell me how do it 'the right way'. Thanks a bunch. gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Pass params through threads_add_idle()
Thanks a bunch, Luca. Passing parameters through closures does work using GLib.Idle.add() instead of Gdk.threads_add_idle(). That helped, thanks again. Best, gilzad Gesendet: Mittwoch, 27. August 2014 um 21:22 Uhr Von: "Luca Bruno" An: "Gilzad Hamuni" Cc: "Vala List" Betreff: Re: [Vala] Pass params through threads_add_idle() Use Idle.add. On Wed, Aug 27, 2014 at 8:11 PM, Gilzad Hamuni wrote:Hi all, I'm trying to pass a parameter to a function that I call through threads_add_idle(). But threads_add_idle() obviously accepts only a SourceFunc. I can't pick up the data from a global variable. So I tried using closures from where I'd pass the needed parameter: private void ThreadedFunc(uint 8 byte) { Gdk.threads_add_idle(()=> { GuiWorker(byte); return false; }); } But then the class of GuiWorker is not instantiated, so I get an assertion during runtime (self != null). If I don't try to pass the parameter and just pass 'GuiWorker' to threads_add_idle() directly (given 'GuiWorker' doesn't take any params then), then the instance does exist. Before that, when I used the deprecated methods Gdk.threads_enter() and Gdk.threads_leave(), I could help myself by doing whatever I wanted in between. But how can I work with threads_add_idle() now? The vala bindings omit its second parameter 'data', so I'd be glad if you could tell me how do it 'the right way'. Thanks a bunch. gilzad ___ vala-list mailing list vala-list@gnome.org[vala-list@gnome.org] https://mail.gnome.org/mailman/listinfo/vala-list -- www.debian.org[http://www.debian.org] - The Universal Operating System ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Gdk.RGBA in text tag - possible leak?
Hi all, while accessing the color properties of a text tag, I noticed that the memory usage constantly goes up. I've reduced it all down to a little example that I attached/uploaded [1] (gdk_rgba.vala) along with a dump of valgrind [2]. Yet I'm not very sure if that's really a bug, so I'm asking here first. Of course I'll file a bug if you advise me to. In the uploaded example I simply print "tag.foreground_rgba.to_string()" to stdout, which constantly raises the use of the memory. Skipping this step will keep the usage at a static level [3]. Following a hint [4] I exported "G_SLICE=always-malloc" to keep the memory usage as tight as possible. I've tested the example-code and made the dumps on: Linux 3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13) x86_64 GNU/Linux GTK 3.8.4-1 Vala 0.28.0 Furthermore I tested the same code on a VM and saw that the memory usage raises there, too: Linux 3.16.0-4-586 #1 Debian 3.16.7-ckt2-1 (2014-12-08) i686 GNU/Linux GTK 3.12.2-3+b1 Vala 0.26.0 I'll be glad about any hint. Let me know if I can do anything. Thanks in advance gilzad [1] https://gist.github.com/anonymous/4233fcf7325112b961e5 [2] https://gist.github.com/anonymous/c2aa76f2155daeb3acd7 [3] https://gist.github.com/anonymous/bb9265e42fdeaa04a540 [4] http://blog.kosmokaryote.org/2013/04/technology-memory-leakage-and-vala.htmlusing Gtk; //compile with: valac --save-temps -g --pkg gtk+-3.0 --pkg gee-0.8 gdk_rgba.vala void main(string[] args) { Gtk.init(ref args); TextView textView; Gtk.TextBuffer buffer; Gtk.TextIter startIter, endIter; Window win; string tagName = ""; textView = new TextView(); buffer = textView.buffer; int loopCounter = 0; weak Gdk.RGBA tmpColor = Gdk.RGBA(); Timer timer = new Timer(); timer.start(); double time_elapsed = timer.elapsed(); while (true) { tagName = "tag_" + (loopCounter++).to_string();//create a unique tagname. buffer.set_text(tagName.to_string()+"\n", -1);//write "tag_" into buffer Gtk.TextTag tag = buffer.create_tag(tagName);//create a tag named "tag_" tmpColor.parse("blue");//choose some random color tag.foreground_rgba = tmpColor;//assign it to the yet uninitialized foreground_rgba of the texttag. // *** The leak occours here. Skipping the following line will keep the memory usage static (== no leakage). *** stdout.printf(tag.foreground_rgba.to_string()+"\n");//most simple access without buffering leads to memleak //string strColor = tag.foreground_rgba.to_string();//so does buffering to a string... //weak Gdk.RGBA tmpColor2 = tag.foreground_rgba;//..and buffering to a variable of the original type. // ** The leak occours above *** buffer.get_start_iter(out startIter); buffer.get_end_iter(out endIter); buffer.apply_tag(tag, startIter, endIter);//apply the tag from the beginning to the end of the written text. //when done, delete everything. Gee.ArrayList tagList = new Gee.ArrayList(); buffer.tag_table.foreach((tmpTag) => { tagList.add(tmpTag); } );//fetch all created texttags foreach(TextTag tmpTag in tagList) { tmpTag.foreground_rgba.free(); buffer.tag_table.remove(tmpTag);//remove the tags from the buffer. else they'll remain even after clearing it. } buffer.delete(ref startIter, ref endIter);//remove all written text. if( timer.elapsed() >= (time_elapsed+10) )//after ~10 seconds... break;//..exit the while-loop. } {//we don't really want to arrive here. the loop above matters. win = new Window(); win.destroy.connect (Gtk.main_quit); win.title = "Gdk.RGBA leakage"; win.border_width = 5; win.window_position = WindowPosition.CENTER; win.set_default_size(655, 480); win.add(textView); win.show_all(); Gtk.main(); } } ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Gdk.RGBA in text tag - possible leak?
> Gesendet: Montag, 18. Mai 2015 um 16:12 Uhr > Von: "Al Thomas" > > > From: Gilzad Hamuni > > In the uploaded example I simply print > > "tag.foreground_rgba.to_string()" to stdout, which constantly raises > > the use of the memory. Skipping this step will keep the usage at a static > > level > > [3]. > > > > I'll be glad about any hint. Let me know if I can do anything. > I don't understand why you have a weak reference: > > weak Gdk.RGBA tmpColor = Gdk.RGBA(); > > outside of your loop that uses the reference. See > https://wiki.gnome.org/Projects/Vala/ReferenceHandling > > As a hint I would try removing 'weak': > > Gdk.RGBA tmpColor = Gdk.RGBA(); > Thanks Al, if I understand correctly, then there's no use for 'weak' there as the scope for that declaration ends with the program. But it doesn't affect the memory consumption in the loop. I really went ahead and removed it now just to be sure. Still reading from "tag.foreground_rgba" consumes more memory through the loop. Best, gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Gdk.RGBA in text tag - possible leak?
> Gesendet: Montag, 18. Mai 2015 um 18:19 Uhr > Von: "Al Thomas" > > > From: Gilzad Hamuni > > Sent: Monday, 18 May 2015, 16:16 > > > >> Gesendet: Montag, 18. Mai 2015 um 16:12 Uhr > >> Von: "Al Thomas" > >> As a hint I would try removing 'weak': > >> > >> Gdk.RGBA tmpColor = Gdk.RGBA(); > >> > > Thanks Al, > > > > if I understand correctly, then there's no use for 'weak' there as > > the scope for that declaration ends with the program. But it doesn't affect > > the memory consumption in the loop. I really went ahead and removed it now > > just > > to be sure. > > > Hmm, Vala memory management is scope based reference counting. See > https://wiki.gnome.org/Projects/Vala/Tutorial#Destruction > [...] > So I don't understand why your code in the loop after the comment > //when done, delete everything > is necessary. Hi Al, I have to clear the buffer's tag table and its text to ensure that the raising memory consumption doesn't from from there. However, in this example I didn't have to iterate through the tag_table for just one tag. That's a leftover, I've refactored that. > Or why you are using weak parameter types (generics) in Gee.ArrayList. Since I wasn't sure which portion of my code would not free memory, I found it acceptable to have Vala/Glib attempt to free memory "too" often for the moment (obviously Vala avoids double-freeing itself). I realize the weak keyword makes no difference here memory-wise (and runtime-wise probably for the worse). "Over-engineered" puts it well. > > Still reading from "tag.foreground_rgba" consumes more > > memory through the loop. > to_string() doesn't just read, it will need memory to create the string. I > believe this should be freed when it > goes out of scope I see, so my comment "without buffering" was incorrect for that line. But I can say that printing (42).to_string() won't raise the memory usage in that loop. > You may still have found a bug, but try refactoring your code a bit more > first. Yes, there was too much going on for a showcase, sorry. I hope the attached file does a better job showing the possible leak. [1] is the vgdump for the case where I suspect leaking. [2] is the vgdump when not accessing tag.foreground_rgba . Thanks again & best, gilzad [1] https://gist.github.com/anonymous/f1aead08848226949f48 [2] https://gist.github.com/anonymous/27dbad1f09568a1e8211 using Gtk; //compile with: valac --save-temps -g --pkg gtk+-3.0 gdk_rgba.vala void main(string[] args) { Gtk.init(ref args); TextView textView; Gtk.TextBuffer buffer; Gtk.TextIter startIter, endIter; Window win; string tagName = ""; textView = new TextView(); buffer = textView.buffer; int loopCounter = 0; Gdk.RGBA tmpColor = Gdk.RGBA(); Timer timer = new Timer(); timer.start(); double time_began = timer.elapsed(); while (true) { tagName = "tag_" + (loopCounter++).to_string();//create a unique tagname. buffer.set_text(tagName.to_string()+"\n", -1);//write "tag_" into buffer Gtk.TextTag tag = buffer.create_tag(tagName);//create a tag named "tag_" tmpColor.parse("blue");//choose some color tag.foreground_rgba = tmpColor;//assign it to the yet uninitialized foreground_rgba of the texttag. {// *** The leak occours here. Skipping the following line will keep the memory usage static (== no leakage). *** stdout.printf(tag.foreground_rgba.to_string()+"\n");//accessing the rgba-member seems to memleak //weak Gdk.RGBA tmpColor2 = tag.foreground_rgba;//..so does buffering to a variable of the original type. }// ** The leak occours above *** //stdout.printf( "Not accessing TextTag.foreground_rgba. " + (42).to_string() + "\n" ); buffer.get_start_iter(out startIter); buffer.get_end_iter(out endIter); buffer.apply_tag(tag, startIter, endIter);//apply the tag from the beginning to the end of the written text. buffer.tag_table.remove(tag);//remove the tag from the buffer. clearing just the buffer will still keep created tags. buffer.delete(ref startIter, ref endIter);//remove all written text. if( timer.elapsed() >= (time_began+20) )//after ~20 seconds... break;//..exit the while-loop. } {//we don't really want to arrive here. the loop above matters. win = new Window(); win.destroy.connect (Gtk.main_quit); win.title = "Gdk.RGBA leakage"; win.border_width = 5; win.window_position = WindowPosition.CENTER; win.set_default_size(655, 480); win.add(textView); win.show_all(); Gtk.main(); } } ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Gdk.RGBA in text tag - possible leak?
> Gesendet: Mittwoch, 20. Mai 2015 um 02:22 Uhr > Von: "Nor Jaidi Tuah" > > You have found a Vala bug. > > > g_object_get (_tmp26_, "foreground-rgba", &_tmp27_, NULL); > > From > https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-get > > --snip > void > g_object_get (gpointer object, > const gchar *first_property_name, > ...); > > Gets properties of an object. > > In general, a copy is made of the property contents and the caller is > responsible for freeing the memory in the appropriate manner for the > type, for instance by calling g_free() or g_object_unref(). > --endsnip Thanks Nor and Al, based on your help I filed a bug now: https://bugzilla.gnome.org/show_bug.cgi?id=749651 > Gesendet: Mittwoch, 20. Mai 2015 um 01:07 Uhr > Von: "Al Thomas" > Are you saying the if you don't manually clear > the buffer's tag table and its text you get a second memory leak? From what I > > understand you have done the work and found the line that causes the leak. So > there > is no need to continue freeing the buffer manually? If the text buffer grows without me clearing it, then that would be normal. But subjectively I expect that by clearing the buffer its tag table should be cleared as well, which doesn't happen. That's why I clear the tag table manually. I've had a brief discussion about it on the GTK mailing list. https://www.mail-archive.com/gtk-app-devel-list@gnome.org/msg19188.html It appears to be known in some way, so I'm not too sure if that's yet another/unrelated leakage. Thanks again to both of you. Best, gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] No foreach through HashMap ?
Hi all, I'm not sure if I've read it somewhere already, so I have to ask again (sorry). Isn't it possible to iterate though a Gee.HashMap if its key and value are of the same type? Having Gee.HashMap foo = new Gee.HashMap(); //I can't do foreach(Gee.Map.Entry bar in foo){} ..because I get the error: Cannot convert from `int' to `string' foreach(Gee.Map.Entry bar in foo) ^^ ..where the key seems to be treated as an int here. $valac --version Vala 0.29.1 If that's expected behavior, do you know any practical workarounds? Thanks a bunch. gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] No foreach through HashMap ?
Hi Al, > Gesendet: Montag, 07. September 2015 um 19:33 Uhr > Von: "Al Thomas" > An: Vala-list [...] > foreach(Gee.Map.Entry bar in foo){} > would be > > > foreach(var bar in foo.entries){} Ok, this is embarrassing. I even checked against working examples of my own and instead of noting the member ".entries" I started suspecting all kinds of different stuff. Guess I got codeblind. Glad there's still someone who woke me up. Thanks again and sorry for this. gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] Nest ncurses in a Gtk window?
Hi list, sorry to ask if this has been answered before, I might have chosen the wrong terms while searching. Is it possible to nest curses into a Gtk.Window? I was thinking of cascading it into a Vte and put that into a Gtk.Window but my thoughts kind of got stuck how to approach correctly in Vala. Background: I wrote a Gtk application that emulates a specific terminal using a Gtk.TextView to display and format everything. Turns out it's not as responsive as it should be and I blame my early choice for the rather complex TextView. So I'd probably exchange the TextView by something that is more suitable for terminal displays. However, people shall be able to see the content in a Gtk.Window. That's where I'm stuck. Any advice? Thanks a bunch in advance gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Nest ncurses in a Gtk window?
Hey Guillaume, thanks for the response. I probably should use Vte. I used TextView until now, because I'm not sure if Vte offers some features I need. For instance, I have to draw lines on top of written text (no text based characters, real cairo stuff). For that I need to be able to get the cursor location from the text window. Whilst TextView.get_iter_location() offers the X- and Y-coordinates, Vte.get_cursor_position() only tells me at which column and row the cursor stands. I might be able to do the calculation (font-width * columns, font-height * rows) to estimate the graphical coordinates. However, I wasn't sure if I knew enough to go ahead this way. Not knowing much about curses either, I was pondering if it might be the better option then. Still not sure where to go, to be honest. Best gilzad > Gesendet: Samstag, 05. Dezember 2015 um 04:41 Uhr > Von: "Guillaume Poirier-Morency" > An: vala-list@gnome.org > Betreff: Re: [Vala] Nest ncurses in a Gtk window? > > Why don't you use Vte? It's designed to embed terminal http://valadoc.o > rg/#!api=vte-2.91/Vte.Terminal > > Sorry if you have received two messages, I did not send the first one > through the mailing list. > > Le vendredi 04 décembre 2015 à 19:32 +0100, Gilzad Hamuni a écrit : > > Hi list, > > > > sorry to ask if this has been answered before, I might have chosen > > the wrong terms while searching. > > > > Is it possible to nest curses into a Gtk.Window? > > > > I was thinking of cascading it into a Vte and put that into a > > Gtk.Window but my thoughts kind of got stuck how to approach > > correctly in Vala. > > > > Background: > > I wrote a Gtk application that emulates a specific terminal using a > > Gtk.TextView to display and format everything. Turns out it's not as > > responsive as it should be and I blame my early choice for the rather > > complex TextView. So I'd probably exchange the TextView by something > > that is more suitable for terminal displays. However, people shall be > > able to see the content in a Gtk.Window. That's where I'm stuck. Any > > advice? > > > > Thanks a bunch in advance > > > > gilzad > > ___ > > vala-list mailing list > > vala-list@gnome.org > > https://mail.gnome.org/mailman/listinfo/vala-list > -- > Guillaume Poirier-Morency > > Étudiant au baccalauréat en Informatique à l'Université de Montréal > Développeur d'application web > > Mon blog: https://arteymix.github.io/ > Mon projet de coopérative: https://pittoresque.github.io/ > Clé PGP: B1AD6EA5 > ___ > 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
[Vala] pass signal to covered window
Hi list, if I have two windows layered on top of each other, the lower window can't fetch the mouse signals as these will go to the upper one. How can I pass the e.g. a button_pressed event on to the lower layer? TextView textView = new TextView(); DrawingArea drawingArea = new DrawingArea(); fixedWindow = new Gtk.Fixed(); fixedWindow.put(textView, 0, 0); fixedWindow.put(drawingArea, 0, 0);//putting drawing area on top of text view drawingArea.button_press_event.connect( ... );// How can I fire a button_press event to the textView? Thanks in advance, gilzad ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] pass signal to covered window
Just for the integrity of this topic. One solution to pass/fire an event programmatically is to use GLib.Signal.emit_by_name(), e.g.: drawingArea.button_press_event.connect( (event) => { GLib.Signal.emit_by_name(textView, "button-press-event", event); } ); However, if the signal of interest expects a callback with a boolean return value (button-press-event does), you'll get the warning "value location for 'gboolean' passed as NULL". If I try to provide the value 5 (that is G_TYPE_BOOLEAN) as the fourth parameter for emit_by_name(), then the application crashes right after emitting the signal. I don't quite know how to translate/use GLib's signal_emitv() to/in Vala either. But for now I got my problem solved without passing signals at all. Best, gilzad > Gesendet: Montag, 01. Februar 2016 um 18:22 Uhr > Von: "Gilzad Hamuni" > An: Vala-list > Betreff: [Vala] pass signal to covered window > > Hi list, > > if I have two windows layered on top of each other, the lower window can't > fetch the mouse signals as these will go to the upper one. How can I pass the > e.g. a button_pressed event on to the lower layer? > > > > TextView textView = new TextView(); > > DrawingArea drawingArea = new DrawingArea(); > > fixedWindow = new Gtk.Fixed(); > fixedWindow.put(textView, 0, 0); > fixedWindow.put(drawingArea, 0, 0);//putting drawing area on top of text view > > drawingArea.button_press_event.connect( ... );// How can I fire a > button_press event to the textView? > > > Thanks in advance, > > gilzad > ___ > 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] pass signal to covered window
Oh, that was too easy to think of. Still learning.. Thanks, Ben :) Gesendet: Freitag, 05. Februar 2016 um 18:22 Uhr Von: "Ben Iofel" An: "Gilzad Hamuni" , Vala-list Betreff: Re: [Vala] pass signal to covered window To emit signals in Vala, you just call them like methods textView.button_press_event (); On Fri, Feb 5, 2016 at 9:06 AM Gilzad Hamuni wrote:Just for the integrity of this topic. One solution to pass/fire an event programmatically is to use GLib.Signal.emit_by_name(), e.g.: drawingArea.button_press_event.connect( (event) => { GLib.Signal.emit_by_name(textView, "button-press-event", event); } ); However, if the signal of interest expects a callback with a boolean return value (button-press-event does), you'll get the warning "value location for 'gboolean' passed as NULL". If I try to provide the value 5 (that is G_TYPE_BOOLEAN) as the fourth parameter for emit_by_name(), then the application crashes right after emitting the signal. I don't quite know how to translate/use GLib's signal_emitv() to/in Vala either. But for now I got my problem solved without passing signals at all. Best, gilzad > Gesendet: Montag, 01. Februar 2016 um 18:22 Uhr > Von: "Gilzad Hamuni" > An: Vala-list > Betreff: [Vala] pass signal to covered window > > Hi list, > > if I have two windows layered on top of each other, the lower window can't > fetch the mouse signals as these will go to the upper one. How can I pass the > e.g. a button_pressed event on to the lower layer? > > > > TextView textView = new TextView(); > > DrawingArea drawingArea = new DrawingArea(); > > fixedWindow = new Gtk.Fixed(); > fixedWindow.put(textView, 0, 0); > fixedWindow.put(drawingArea, 0, 0);//putting drawing area on top of text view > > drawingArea.button_press_event.connect( ... );// How can I fire a > button_press event to the textView? > > > Thanks in advance, > > gilzad > ___ > vala-list mailing list > vala-list@gnome.org[vala-list@gnome.org] > https://mail.gnome.org/mailman/listinfo/vala-list[https://mail.gnome.org/mailman/listinfo/vala-list] > ___ vala-list mailing list vala-list@gnome.org[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] Is there any usable editor for Vala?
Hi Matthias, hi Jonathan, here's a version of valencia-0.8 that I applied the patches for gedit >=3.12 on [1]. I got the patches from here [2]. The only additional change I applied to the code, is to make the jump-forth and jump-back feature work with the Alt_R-key (Alt_Gr+Left, Alt_Gr+Right). Before that it was mapped to Alt (MOD1_MASK), which seems to be reserved in the current versions of gedit by now. Note that you might need to update the following line in the Makefile to match your current Vala version: LIBVALA=libvala-0.32 ..where libvala-0.32 stands for the current Vala version 0.31.1 . I haven't found any portion of the valencia-code that would try to access any "enable-delete" member in an obvious way. However, given the fact that my version of valencia works with gedit-3.14, there might be a chance for you to have it work with gedit-3.18, too. Hope that helps. Best, gilzad [1] http://gilzad.de/linux-stuff/valencia_0.8_post_gtk3.12.zip [2] https://bugzilla.gnome.org/show_bug.cgi?id=724173 > Gesendet: Freitag, 19. Februar 2016 um 21:34 Uhr > Von: "Jonathan Moerman" > An: "Matthias Berndt" , vala-list@gnome.org > Betreff: Re: [Vala] Is there any usable editor for Vala? > > Valencia isn't limited to vala 0.24 (I've only used it with >= 0.28), you > can build it for 0.30 by running "LIBVALA=libvala-0.30 make" (or by > modifying the Makefile). > That error probably isn't related to Valencia, I mentioned that I'm using > Gedit 3.10 because I simply don't know if it will compile and run with > newer versions of Gedit. > I never meant that you should install 3.10, I should have been more clear. > > Jonathan Moerman > > 2016-02-19 21:15 GMT+01:00 Matthias Berndt : > > > > > I don't know what version of gedit you're using, but > >>> https://github.com/JMoerman/valencia-1 works for me. (I'm using gedit > >>> 3.10) > >>> > >> > >> I'll second this. Gedit + Valencia have worked very nicely for me. It's > >> true that there hasn't been much development of Valencia recently, but I've > >> found it does everything I want it to. > >> > >> Unfortunately I can't reproduce that. After going through the trouble of > > installing gedit 3.10 and vala 0.24 (Fedora comes with gedit 3.18 and vala > > 0.30) and getting Valencia to compile, it crashes gedit on startup. > > $ gedit > > > > (gedit:23465): GLib-GIO-ERROR **: Settings schema > > 'org.gnome.nautilus.preferences' does not contain a key named > > 'enable-delete' > > Trace/Breakpoint ausgelöst (Speicherabzug geschrieben) > > > > Cheers, Matthias > > > > > ___ > 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] request to add another example to Projects/Vala/ListExample
Hi, just want to say that this is some precious info that I needed to learn yet. As a C#-guy I wonder from a "user's" point of view: If List implies strdup(), wouldn't it be consistent to automatically compare with strcmp() upon removing, too? Or am I making dangerous assumptions that are not so smart in the end? I might be spoiled by too much comfort. gilzad > Gesendet: Freitag, 18. März 2016 um 22:33 Uhr > Von: MohanR > HI, > I screwed-up that comment. sorry for that. I tried to upload a new > version of that page, but wiki says I'm not allowed. Please help to > update that page. > int main(string[] args) { > List list0 = new List(); > List list1 = new List(); > list0.append("helloworld"); /* g_strdup() takes place */ > list1.append("helloworld"); /* no g_strdup() */ > stdout.printf("list0.length=%u, list1.length=%u\n", > list0.length(), /* length=1 */ > list1.length()); /* length=1 */ > list0.remove("helloworld"); /* wont work as expected */ > list1.remove("helloworld"); /* works as expected */ > stdout.printf("list0.length=%u, list1.length=%u\n", > list0.length(), /* still length=1 */ > list1.length()); /* length=0 */ > list0.delete_link(list0.find_custom("helloworld", strcmp)); > stdout.printf("list0.length=%u, list1.length=%u\n", > list0.length(), /* length=0 */ > list1.length()); /* length=0 */ > return 0; > } > Thanks, > Mohan R > On Fri, 2016-03-18 at 20:37 +0100, Luca Bruno wrote: > > Hi, > > thanks a lot for your contribution. The wiki is open, you can > > register and edit it freely! :) > > > > Also pay attention to the comment about "how" and "how". In C, they > > are equivalent because those are const strings and have the same > > address. But with List they get copied. However with > > List they would be equal. It would be better if you > > could reword that comment about pointing to the ownership of the List > > elements > > > > On Fri, Mar 18, 2016 at 8:26 PM, MohanR wrote: > > > Hi, > > > > > > I'm a beginner in vala. I would like to add the following example > > > to > > > this wiki link to make other beginners understand important thing > > > about > > > List. > > > > > > https://wiki.gnome.org/Projects/Vala/ListSample > > > > > > int main(string[] args) { > > > List mylist = new List(); > > > mylist.append("hi"); > > > mylist.append("how"); > > > mylist.append("are"); > > > mylist.append("you"); > > > > > > /* prints length: 4 */ > > > stdout.printf("length: %u\n", mylist.length()); > > > > > > /* following wont work as expected because in > > > * C universe, "how" and "how" is not equal > > > */ > > > mylist.remove("how"); > > > > > > /* still prints length: 4 */ > > > stdout.printf("length: %u\n", mylist.length()); > > > > > > /* works because "how" and "how" is equal > > > * according to strcmp() > > > */ > > > mylist.remove_link(mylist.find_custom("how", strcmp)); > > > > > > /* prints length: 3 */ > > > stdout.printf("length: %u\n", mylist.length()); > > > > > > return 0; > > > } > > > ___ > > > vala-list mailing list > > > vala-list@gnome.org > > > https://mail.gnome.org/mailman/listinfo/vala-list > > > > > > > > > -- > > NixOS Linux > ___ > 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] request to add another example to Projects/Vala/ListExample
Hi Gergely, Yesterday I noticed that Vala 0.32.1 magically compiled my project with a stable memory consumption. I was going to say "yes, please do add an example!" but then decided to check if Mohan's use case still applies. So I wrote this: void main () { Gee.List list0 = new Gee.ArrayList(); Gee.List list1 = new Gee.ArrayList(); list0.add("helloworld"); list1.add("helloworld"); print("list0.length="+list0.size.to_string()+", list1.length="+list1.size.to_string()+"\n"); // output: list0.length=1, list1.length=1 list0.remove("helloworld"); list1.remove("helloworld"); print("list0.length="+list0.size.to_string()+", list1.length="+list1.size.to_string()+"\n"); // output: list0.length=0, list1.length=0 } So it seems that Vala does a clean job when removing items from a Gee.List now, no matter whether I use an unowned type in the generics or not. Note that I couldn't exactly resemble Mohan's example. I only get to call a ctor of an implemented type (e.g. ArrayList, not List), so my example might prove something different in the end. Just in case it's relevant for our discussion. Best, gilzad Gesendet: Mittwoch, 22. Juni 2016 um 11:10 Uhr Von: "Gergely Polonkai" An: "Gilzad Hamuni" Cc: vala Betreff: Re: [Vala] request to add another example to Projects/Vala/ListExample Hello, this is a pretty old topic, but I have the rights to edit wgo pages. If you think it is actually relevant, I can add this example to the wiki. Best, Gergely Gergely Polonkai[https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links] about.me/gergely.polonkai[https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links] 2016-03-21 15:21 GMT+01:00 Gilzad Hamuni :Hi, just want to say that this is some precious info that I needed to learn yet. As a C#-guy I wonder from a "user's" point of view: If List implies strdup(), wouldn't it be consistent to automatically compare with strcmp() upon removing, too? Or am I making dangerous assumptions that are not so smart in the end? I might be spoiled by too much comfort. gilzad > Gesendet: Freitag, 18. März 2016 um 22:33 Uhr > Von: MohanR > HI, > I screwed-up that comment. sorry for that. I tried to upload a new > version of that page, but wiki says I'm not allowed. Please help to > update that page. > int main(string[] args) { > List list0 = new List(); > List list1 = new List(); > list0.append("helloworld"); /* g_strdup() takes place */ > list1.append("helloworld"); /* no g_strdup() */ > stdout.printf("list0.length=%u, list1.length=%u\n", > list0.length(), /* length=1 */ > list1.length()); /* length=1 */ > list0.remove("helloworld"); /* wont work as expected */ > list1.remove("helloworld"); /* works as expected */ > stdout.printf("list0.length=%u, list1.length=%u\n", > list0.length(), /* still length=1 */ > list1.length()); /* length=0 */ > list0.delete_link(list0.find_custom("helloworld", strcmp)); > stdout.printf("list0.length=%u, list1.length=%u\n", > list0.length(), /* length=0 */ > list1.length()); /* length=0 */ > return 0; > } > Thanks, > Mohan R > On Fri, 2016-03-18 at 20:37 +0100, Luca Bruno wrote: > > Hi, > > thanks a lot for your contribution. The wiki is open, you can > > register and edit it freely! :) > > > > Also pay attention to the comment about "how" and "how". In C, they > > are equivalent because those are const strings and have the same> > > > address. But with List they get copied. However with > > List they would be equal. It would be better if you > > could reword that comment about pointing to the ownership of the List > > elements > > > > On Fri, Mar 18, 2016 at 8:26 PM, MohanR > > wrote: > > > Hi, > > > > > > I'm a beginner in vala. I would like to add the following example > > > to > > > this wiki link to make other beginners understand important thing > > > about > > > List. > > > > > > https://wiki.gnome.org/Projects/Vala/ListSample[https://wiki.gnome.org/Projects/Vala/ListSample] > > > > > > int main(string[] args) { > > > List mylist = n
Re: [Vala] 2 questions on valac in msys2
Hi, I can try to give you some ideas for the first question from my experiences with msys+vala (Win32). In a real linux environment we can use ldd to find out which libraries an executable depends on. $ ldd hello But in my version of msys/mingw ldd doesn't work. However, I don't update my msys to avoid conflicts with too quickly updated libraries. So you might have a working version of it by now. Another way is to use the Dependency Walker [1] which seems to be suggested among developers. I haven't had many experiences with it though. The third way I know is just trial and error. You copy your hello.exe into a different directory and call it directly from the system (outside the msys-environment). Windows will then tell you which DLL it is missing. You can then copy the requested DLL to the same directory and attempt to run hello.exe again. Windows will tell you what other DLL is missing. So you repeat this procedure until you have all the DLLs that hello.exe needs. You surely don't need to provide all DLLs from mingw, thus you'll save some space, too. If you still need to reduce the required disk space of your app+dlls, you can try to pack them with UPX [2]. Just note that some anti-virus programs used to detect self-extracting executables as harmful. Unfortunately I don't have a clue about your second question, I'm sorry. [1] http://www.dependencywalker.com/ [2] http://upx.sourceforge.net/ > Gesendet: Donnerstag, 23. Juni 2016 um 04:31 Uhr > Von: oyster > An: "vala-list@gnome.org" > Betreff: [Vala] 2 questions on valac in msys2 > > they are 2 relative questions I found in my msys2 on Windows 7 > > 1. how to distribute EXE for PC without glib/gtk/etc? Currently, I > copy all DLLs under /msys64 to the same directory where the EXE stays. > The problem is that it is not so nice, and the DLLs take up 150Mbytes! > So is there an automatic way to copy only necessary DLLs? > > 2. If I run hello_gtk.exe in the dos prompt window of Windows7, when I > close it, nothing is displayed. However, in msys2, I have changed the > current working directory to where hello_gtk.exe can be found, the I > run and close hello_gtk.exe > [code] > $ ./hello_gtk.exe > > # then I close hello_gtk.exe > > (hello_gtk.exe:43496): GLib-GObject-WARNING **: attempt to override > closure->va_marshal (63a48a20) with new marshal > (66710ea8) > [/code] > > Why? and how to eliminate it? Thanks > ___ > 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] The future of Vala
I consider myself a Vala user and I'd also welcome a donate-button if it really helps the project. Hadn't there been Vala, I most probably wouldn't get in touch with all the glib stuff as a developer. C and CPP take too much effort to gain the same goals. C# is beautiful but still wastes CPU time. Vala is beautiful and native. For me Vala is currently the only way to write native applications across different platforms. Sure I'd use a chance to show some appreciation. Greetings > Gesendet: Dienstag, 13. September 2016 um 08:46 Uhr > Von: Ulink > An: vala-list@gnome.org > Betreff: Re: [Vala] The future of Vala > > Am 2016-09-13 um 02:10 schrieb Michael Gratton: > > It really sounds like Vala needs some maintainers. > > I think there are some Vala USERS out there, which are able and willing > to help with some minor and/or simple tasks and don't know how. So the > "heavy weights" like Jürg, Luca, Evan and the like can do the important > stuff. > > A list of such "simple and boring stuff" including a general description > how to help may push Vala forward only in little steps, but remember: > 1000*0.1% = 100% :-) > > Another idea: What about a "donate" button somewhere? Vala saves much > time when programming Gtk/GLib and time==money . > > -- > Bernhard > ___ > 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