Re: [Vala] Gtk.ProgressBar



----- Original Message -----

From: "webierta gmail com" <webierta gmail com>
Sent: Saturday, 11 March 2017, 18:55
Subject: [Vala] Gtk.ProgressBar

I explain: From a FileChooserDialog is selected and opens the vCard
file, and if it is too large it takes a while to analyze and import the
contacts. At that time I want to open a window or dialog (without
buttons) with a Gtk.ProgressBar that shows the progress of the
operation. And when the operation is finished, the window / dialog is
automatically closed.


Ideally you would use asynchronous, event based programming in Vala/Genie.
So something like:
1. Write an asynchronous process vCard function that runs in a background
   thread. I've not figured out the best way of doing this, but look at the
   async keyword in Vala and https://developer.gnome.org/gio/stable/ch02.html
2. Write an "app_paused" object that stores two states. The first state is
   for a Timeout source (https://valadoc.org/glib-2.0/GLib.Timeout.html) that
   will then complete and then the second state is showing a spinner dialog.
   This needs a cancel method to cancel the timer or close the dialog.
   For a progress bar you would need some kind of signalling, so more complex.
3. You combine these two by starting the "app_paused" object then call
   yield process_vCard(). When the processing is finished the code after the
   yield should call the app_paused cancel method.
It would be nice to find some good examples of this.

At the moment I have not known how to solve it, and I am using
Notify.Notification to report the process, but this requires a new
dependency (libnotify) and I prefer to use few dependencies.


From https://wiki.gnome.org/HowDoI/GNotification:
"As of GLib 2.39, it is no longer necessary to link against libnotify to 

create notifications in your application, GIO now provides an API for it: 

GNotification."

So create a Notification (https://valadoc.org/gio-2.0/GLib.Notification.html)
and send it through you GApplication send_notification method (
https://valadoc.org/gio-2.0/GLib.Application.send_notification.html )

Good luck with it,

Al


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]