GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Jul 31, 2014 9:40 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: estimated time
PostPosted: Thu Jun 21, 2007 11:04 am 
Offline
GTK+ Guru

Joined: Thu Nov 16, 2006 5:08 am
Posts: 259
Location: INDIA
i am doing the progressbar pulse oreintations...
like (100/filesize in bytes) and am convering file size in to float value using atof()
but for 1.2M(1221948 bytes)
100/1221948=====
taking progressbar is very slow...

and here how can i know estimated time to copy perticular size of a file...
remaining time to copy a file....

can you please help me

thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 12:17 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Why not just take the total file size and divide it by 100? Move the progress bar every time it downloads that much data. I mean, if the user is downloading a huge file, she isn't going to be expecting the bar to move too quickly.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 12:37 pm 
Offline
GTK+ Guru

Joined: Thu Nov 16, 2006 5:08 am
Posts: 259
Location: INDIA
openldev wrote:
Why not just take the total file size and divide it by 100? Move the progress bar every time it downloads that much data. I mean, if the user is downloading a huge file, she isn't going to be expecting the bar to move too quickly.

yeah i am taking total size..
Quote:
float jj=0;
gdouble new_val;
flaot prog_filesize;
jj=100/prog_filesize;
printf("jjjjjjjj %f \n",jj);
new_val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (pbar)) + jj;


here file size is 1221948.
and here how can i know estimated time to copy perticular size of a file...
remaining time to copy a file....

gor example i selected a folder of 1Gb
and copied to other file.
here a window will appeared with progressbar...
there is a progress and estimated time to copy...

after copying the 1Gb file the window will closing.

how can i do this all by programatically

thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 12:53 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
I think what you need to do is use a timer. Every so often, check how long it has been, and how much data has been transfered. From that, you can estimate how much time it will take for the rest of the data to transfer.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 1:04 pm 
Offline
GTK+ Guru

Joined: Thu Nov 16, 2006 5:08 am
Posts: 259
Location: INDIA
openldev wrote:
I think what you need to do is use a timer. Every so often, check how long it has been, and how much data has been transfered. From that, you can estimate how much time it will take for the rest of the data to transfer.


sorry i cat understand i am new to this progressbar..
can u please explin it clearly..
or else i am very glad if you are sending a sample code for me ...

thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 2:22 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Sorry, I am very busy at work, so I can't really post any sample code, but I can point you in the right direction. You can create a timeout that is called every 500 milliseconds or so:

http://developer.gnome.org/doc/API/2.0/ ... imeout-add

Then, you figure out how much of the file has been transferred thus far. If you have a global variable that is incremented every time the timeout is called, you will know about how long it has taken to transfer that much data. For example, let us assume that your file is 500KB, and when the timeout is called the second time, 100KB has already been copied. Then, we know it took 1000 milliseconds (2 timeouts * 500 milliseconds) to transfer 20% of the file. So, it should take about 4000 milliseconds to transfer the remaining 80%. You continually do this until the file is transferred.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 22, 2007 11:02 am 
Offline
GTK+ Guru

Joined: Thu Nov 16, 2006 5:08 am
Posts: 259
Location: INDIA
openldev wrote:
Sorry, I am very busy at work, so I can't really post any sample code, but I can point you in the right direction. You can create a timeout that is called every 500 milliseconds or so:

http://developer.gnome.org/doc/API/2.0/ ... imeout-add

Then, you figure out how much of the file has been transferred thus far. If you have a global variable that is incremented every time the timeout is called, you will know about how long it has taken to transfer that much data. For example, let us assume that your file is 500KB, and when the timeout is called the second time, 100KB has already been copied. Then, we know it took 1000 milliseconds (2 timeouts * 500 milliseconds) to transfer 20% of the file. So, it should take about 4000 milliseconds to transfer the remaining 80%. You continually do this until the file is transferred.


i used g_timeot_add()
ok its working but it continously pulsing... progress bar.
after reaching the end point it have to stop or close the copy window..

and am again soory to tell this..
i am unable to do the estimated time and %of receiving data..

please help with some code

thank you in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group