[Vala] regarding Gtk.Application managing a single instance app
Hello, a student of mine has been appointed to develop a copy manager. He decided to write the code in Vala and he's been consulting me since. The idea is to be able to manage several copy processes in a single window, so he's using Gtk.Application for that matter. The logic behind the single instance is (as you may suppose) that the first time the application is invoked it launches a new window with the copy widgets on it. Any new attempt to invoke the application should add a new copy to the already existing window (a window exists solely while any of the copies it handles is alive, so: if the there is no copy in progress any invocation is considered as the first one). All that being said what's happening is that the second time the app is invoked the activate method seems to be running on the first instance of the class, and since the new copy information is stored on the current instance, there is no new copy being created since the existing instance tries to create (again) it's own copy resulting on an logical error since the same copy cannot be run twice at the same time. Issues related to good programming practices have been discussed with the student already, yet I fail to understand how could the new info be passed to the existing instance. I'm hoping someone can shed some light on this. Best regards, D.H.Bahr. PS: This is the code relevant to the problem: /**/ using GLib; using Gtk; public class Main : Gtk.Application { private MainView main_view; private string operation_type; private Liststring sources; private string destination; public Main (string operation_type, Liststring sources, string destination) { Object (application_id: nova.ncopier, flags: ApplicationFlags.FLAGS_NONE); this.operation_type = operation_type; this.sources = new Liststring (); foreach (unowned string source in sources) { this.sources.append (source); } this.destination = destination; } public override void activate () { if (this.get_windows ().length () == 0) { main_view = new MainView (this.operation_type, this.sources, this.destination); this.add_window(main_view); } else { for (int i = 0; i (int) this.sources.length (); i++) { stdout.printf (%d:%s, i, this.sources.nth_data (i)); } main_view.add_operation (new OperationView (this.operation_type, this.sources, this.destination)); main_view.present (); } } static int main (string[] args) { Gtk.init (ref args); if (args.length 4) { stdout.printf (incomplete parameters\n); return 1; } else { string operation_type = ; Liststring sources = new Liststring (); string destination = ; if (args[1] == copy) { operation_type = COPYING; } sources.append (file: + args[2]); destination = file: + args[3]; return new Main (operation_type, sources, destination).run (); } } } /***/ ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] deleting folders
Hello everyone! GLib.File provides a 'delete' method to delete files and empty folders. I need to delete a non empty folder so I thought of a recursive method like this: bool remove_directory (string path) { bool flag = false; var directory = File.new_for_path (path); var enumerator = directory.enumerate_children ( FileAttribute.STANDARD_NAME, 0 ); FileInfo file_info; while ((file_info = enumerator.next_file ()) != null) { if ((file_info.get_file_type ()) == FileType.DIRECTORY) { /* What should I do here? How can I get a File from a FileInfo so I can use the 'delete' method on it? */ } } return flag; } Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] signals
Hello there! I've being experiencing a bug for a while now and I have no clue how to solve it. The situation is as follows: I have a set of classes (most of which handle some GtkWidget build from a Glade XML using a GtkBuilder instance). One of those classes has a GtkGrid and another has a GtkBox with a GtkLabel and a GtkButtonBox with two GtkButtonses. To the Grid-ish instance I add several Box-ish instances (if you catch my drift) and what I need is to be able to tell which GtkButton from which box-ish instance is being clicked. I tried using vala native signals on the box-ish class emitted when the buttons where clicked an then connect those signals in the grid-ish class, but nothing seems to happen. I hope I've made my self clear. Has anybody done something similar?? Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] signals
Victor, truth is I don't have the code on me right now and I won't have access to my email during the weekend 'cause I can only use the connexion at work. The code (at least the relevant part) looks kinda this (I promise I'll send the actual one on monday): class UIBuilder : Object { private Gtk.Builder builder private string gui = my_ui.ui ... public UIBuilder () { builder = new Gtk.Builder (); } ... public add_object (string obj) { builder.add_object_from_file(obj, gui); /* not sure that's the proper method but I think you'll get what I mean */ } ... } class Item : Object { private string name; ... private UIBuilder builder; ... private Gtk.Button ok_button; private Gtk.Button rm_button; public Gtk.Box box; ... public signal void ok_button_clicked (string name); public signal void rm_button_clicked (string name); ... public Item (string n) { name = n; builder = new UIBuilder(); builder.add_object(item_box); box = builder.get_object(item_box) as Gtk.Box; ok_button = builder.get_object(ok_button) as Gtk.Button; ok_button.clicked.connect ( () = ok_button_clicked (name)); rm_button = builder.get_object(ok_button) as Gtk.Button; rm_button.clicked.connect ( () = rm_button_clicked (name)); } } class ItemsViewport : Object { private string[] names; private UIBuilder builder; ... private Gtk.Grid grid; public ItemsViewport () { builder = new UIBuilder(); builder.add_object (items_viewport); grid = builder.get_object(item_grid) as Gtk.Grid; ... init(); } private void init () { Item item; foreach (string name in names) { item = new Item (name); grid.attach (item, ...); item.ok_button_clicked.connect (on_ok_button_clicked); item.rm_button_clicked.connect (on_ok_button_clicked); } } ... private void on_ok_button_clicked (string name) { stdout.printf (OK Button for item %s was clicked.\n, name); } private void on_rm_button_clicked (string name) { stdout.printf (RM Button for item %s was clicked.\n, name); } ... } Of course those are (mostly) not the actual variable names but is the general idea of what I am trying to do. I recall trying to use the 'ok' and 'rm' buttons as public and connecting directly to their own signals but then valac would not compile. As I said earlier I promise I'll send the actual code on monday morning. Best regards and thanks for your concern, D.H. Bahr On Fri, 2012-09-07 at 19:07 -0006, Victor wrote: Could you please paste the code somewhere, so we can try to spot the errors? This part grabs my attention: I tried using vala native signals on the box-ish class emitted when the buttons where clicked an then connect those signals in the grid-ish class, but nothing seems to happen. From what you wrote there, I guess the button instances are public fields in the box class. For handling click events, you have two options: use lambda functions and access local data from there, or use a single generic handler for all the buttons. 1) Lambda: my_button.clicked.connect ( () = { // do something... }); 2) Generic method: // Connect the handler somewhere... my_button.clicked.connect (on_button_click); void on_button_click (Gtk.Button button) { // You can do ref erence comparison here, like: if (button == my_button) { } // button's parent can be accessed using button.parent ... } You could also subclass Gtk.Button and provide your own signal there: public class MyButton : Gtk.Button { public signal void custom_signal (); public MyButton () { } public override void clicked () { custom_signal (); } } Best Regards. P.S. I speak Spanish On vie, sep 7, 2012 at 12:06 , D.H. Bahr db...@uci.cu wrote: Hello there! I've being experiencing a bug for a while now and I have no clue how to solve it. The situation is as follows: I have a set of classes (most of which handle some GtkWidget build from a Glade XML using a GtkBuilder instance). One of those classes has a GtkGrid and another has a GtkBox with a GtkLabel and a GtkButtonBox with two GtkButtonses. To the Grid-ish instance I add several Box-ish instances (if you catch my drift) and what I need is to be able to tell which GtkButton from which box-ish instance is being clicked. I tried using vala native signals on the box-ish class emitted when the buttons where clicked an then connect those signals in the grid-ish class, but nothing seems to happen. I hope I've made my self clear. Has anybody done something similar?? Best regards, D.H. Bahr 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com
[Vala] connecting signals from GtkBuilder
Hello everyone! I have an issue while trying to connect the signals from GtkBuilder object to my class' methods. This is roughly me code structure: //No namespace specified class MyClass { ... public MyClass () { builder = new Builder(); builder.add_objects_from_file(builder_file, {main_window}); ... builder.connect_signals(this); } ... public void on_signal_emited (signal signature) { ... //do stuff ... } } On Glade I connect the signal as follows: 'emit-signal': 'my_class_on_signal_emited' The code compiles just fine, at runtime I get: Gtk-WARNING **: Could not find signal handler 'my_class_on_signal_emited'. How should I name signature handlers on Vala?? Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list
[Vala] custom widget and File observer
Hello everyone! I'm working on a teaching exercise: implementing a LifeStream application (for those not aware: LifeStream is an alternative for the desktop metaphor; more info can be found on the book 'Beyond the Desktop Metaphor' published by MIT Press). The application would consist solely on a Stream Browser providing access to (and only to) user own files, that is: all files within the user dirs (e.g: Documents, Pictures, Videos, Music, Public, Download and Home directories, recursively off course). Since I don't intent to create a full working environment (yet), but only a stream browser I have come to an issue: how to ensure files not processed within the application (that is files copied/created using other file browsers or the command line shell) are included effectively on the stream data structure. My current bet is placed on the idea I can create an Observer daemon which is somehow notified that any file on the specific 'observed' directories has been accessed. Is this even possible?? The other thing I would like to ask is: I want to create a composite widget for the visual representation of file streams, something in the fashion of iTunes where there is the current file in the center of the screen and at the left of it there's a pile of the previous files and at the right there's another pile of the next files. Can use clutter for this?? Anyone has a working sample willing to share with me? Best regards and thanks for every consideration on this matter, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] printing int64 value to standard output
Hello there, how can I print an int64 variable to stdout?? int64 timestamp = 1234151912; stdout.printf(%?, timestamp); Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] printing int64 value to standard output
Thanks!! El lun, 14-05-2012 a las 10:20 -0700, Abhijit Hoskeri escribió: On Mon, May 14, 2012 at 10:09 AM, D.H. Bahr db...@uci.cu wrote: Hello there, how can I print an int64 variable to stdout?? int64 timestamp = 1234151912; stdout.printf(%?, timestamp); %lld is the format string you need. Regards, Abhijit 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] custom widget and File observer
El lun, 14-05-2012 a las 19:39 +0200, Andrea Del Signore escribió: Hi, On Mon, 2012-05-14 at 08:18 -0400, D.H. Bahr wrote: Hello everyone! I'm working on a teaching exercise: implementing a LifeStream application (for those not aware: LifeStream is an alternative for the desktop metaphor; more info can be found on the book 'Beyond the Desktop Metaphor' published by MIT Press). Nice! The application would consist solely on a Stream Browser providing access to (and only to) user own files, that is: all files within the user dirs (e.g: Documents, Pictures, Videos, Music, Public, Download and Home directories, recursively off course). Since I don't intent to create a full working environment (yet), but only a stream browser I have come to an issue: how to ensure files not processed within the application (that is files copied/created using other file browsers or the command line shell) are included effectively on the stream data structure. My current bet is placed on the idea I can create an Observer daemon which is somehow notified that any file on the specific 'observed' directories has been accessed. Is this even possible?? I think that gio has what are you looking for. Read here: http://www.valadoc.org/#!api=gio-2.0/GLib.FileMonitor Yes, I took a look at that, but It doesn't seem to notify when simple file access occurs; that is: no modification but just open a PDF document and read, that action won't be notified. Would it?? HTH, Andrea Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] regarding Gtk Builder on Vala
Hello everyone, I've suffered a deep disappointment from Vala, and I'm hoping it is something I failed to do rightly. I have an app with a Gtk 3 interface loaded from a gtk builder, but I get a seg fault on run time. The thing is the same code (and builder xml) (written in Python 2) works smoothly. Is there something I specifically need to do in Vala to load gtk3 interfaces from builder files?? Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba 10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS... CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION http://www.uci.cu http://www.facebook.com/universidad.uci http://www.flickr.com/photos/universidad_uci ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] regarding GLib.Process.spawn_async_with_pipes
El Tue, 13-03-2012 a las 11:04 +0100, Jens Georg escribió: Hi, I'm trying to write a simple GTK3 front-end for smbpasswd and I'm trying to use «GLib.Process.spawn_async_with_pipes» based on the «-s» option of smbpasswd which allows it to use stdin for password prompt. How can I send the data to «GLib.Process.spawn_async_with_pipes»' stdin? You need to set up an IOWatch on the resulting standard_input fd and check if the app is ready for receiving input; you'll probably also connect to stdout and stderr to properly interact with the command-line app. Thanks for tips , I'll check that asap.. Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! http://www.antiterroristas.cu http://justiciaparaloscinco.wordpress.com ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] vala + policykit
Hey there!! Can anyone give a tip on how to use policykit in vala? -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! http://www.antiterroristas.cu http://justiciaparaloscinco.wordpress.com ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
[Vala] howto invoke an external process
Hello everyone, this is my first email to the list. I've been looking at Vala for a while now, and I like all I see. I just a have a question right now: Is it possible to spawn an external process from Vala code in a manner similar to Python's SubProccess?? Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! http://www.antiterroristas.cu http://justiciaparaloscinco.wordpress.com ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] howto invoke an external process
A big «Thanks» to Luca, Reid, jezra and Eric, I'm thinking this should be exactly what I need. Best regards, El vie, 17-02-2012 a las 12:43 -0500, D.H. Bahr escribió: Hello everyone, this is my first email to the list. I've been looking at Vala for a while now, and I like all I see. I just a have a question right now: Is it possible to spawn an external process from Vala code in a manner similar to Python's SubProccess?? Best regards, -- Sw.E. D.H. Bahr Nova Desktop Development Leader CESOL (Free/Libre Software Centre) UCI (University of Informatics Sciences) Havana, Cuba Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! http://www.antiterroristas.cu http://justiciaparaloscinco.wordpress.com ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list