Re: Using progress bar to show copying files

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

 



On Tue, Mar 29, 2005 at 04:32:52PM -0800, pan yawen wrote:
> Hi,
> I have to copy large files from a CD to the hard disk.
> 
> I want to use a progress bar to display the status of
> copying the files.
> 
> Any one has ideas about implementing this in gtk.

I've never done this before, but here's an idea:  use the GIOChannel
stuff to copy the files.  That means, create a GIOChannel for each new
file on the CD for reading and a new one for each target file...  add
them both to the main loop so they get added to the select() bitmasks.
Make your callbacks read and write a certain amount then update the
progress bar appropriately after each complete write.  By
"appropriately" I mean...  figure out in advance how much data there is
to move from one place to another and keep track of how much data you've
already moved and update the status bar according to that.  I've never
used a status bar, so I can't give you details...  but that's what the
documentation is for.

another strategy for copying the files is using a standard command (like
'cp') to do that moving.  this would be less error prone.  still update
the status bar using the same logic, but you'll only update it after
every file.  figuring out data size can be done with the stat() system
call on *nix.  I don't know how to size file data on Windows.

attach the status bar to a modal dialog with a cancel button.  associate
static read/write buffers and a "keep_on_copying" flag with the io
callbacks...  set the keep_on_copying to false when the Cancel button is
pressed.

- Ben

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux