~ubuntu-branches/debian/lenny/linuxdcpp/lenny

« back to all changes in this revision

Viewing changes to linux/hashdialog.cc

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis
  • Date: 2006-12-08 15:50:58 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061208155058-tgl4tv9qhurow54z
Tags: 0.0.1.cvs20061208-1
* New upstream release
* Dropped patch for tightening linking, a solution has been implemented
  upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
Hash::Hash() : DialogEntry("Hash", "hash.glade")
24
24
{
25
 
        TimerManager::getInstance()->addListener(this);
26
 
 
27
25
        string tmp;
28
26
        startTime = GET_TICK();
29
27
        HashManager::getInstance()->getStats(tmp, startBytes, startFiles);
30
28
        HashManager::getInstance()->setPriority(Thread::NORMAL);
31
 
        updateStats_gui();
 
29
        updateStats_gui("", 0, 0, 0);
 
30
 
 
31
        TimerManager::getInstance()->addListener(this);
32
32
}
33
33
 
34
34
Hash::~Hash()
37
37
        TimerManager::getInstance()->removeListener(this);
38
38
}
39
39
 
40
 
void Hash::updateStats_gui()
 
40
void Hash::updateStats_gui(string file, int64_t bytes, size_t files, u_int32_t tick)
41
41
{
42
 
        string file;
43
 
        int64_t bytes = 0;
44
 
        size_t files = 0;
45
 
        u_int32_t tick = GET_TICK();
46
 
 
47
 
        HashManager::getInstance()->getStats(file, bytes, files);
48
42
        if (bytes > startBytes)
49
43
                startBytes = bytes;
50
44
 
69
63
                        gtk_label_set_text(GTK_LABEL(getWidget("labelTime")),"-:--:-- left");
70
64
                else
71
65
                {
72
 
                        double ss = bytes / speedStat;
 
66
                        double ss = (double)bytes / speedStat;
73
67
                        gtk_label_set_text(GTK_LABEL(getWidget("labelTime")), string(Util::formatSeconds((int64_t)ss) + " left").c_str());
74
68
                }
75
69
        }
96
90
 
97
91
void Hash::on(TimerManagerListener::Second, u_int32_t tics) throw()
98
92
{
99
 
        WulforManager::get()->dispatchGuiFunc(new Func0<Hash>(this, &Hash::updateStats_gui));
 
93
        string file;
 
94
        int64_t bytes = 0;
 
95
        size_t files = 0;
 
96
 
 
97
        HashManager::getInstance()->getStats(file, bytes, files);
 
98
 
 
99
        typedef Func4<Hash, string, int64_t, size_t, u_int32_t> F4;
 
100
        F4 *func = new F4(this, &Hash::updateStats_gui, file, bytes, files, GET_TICK());
 
101
        WulforManager::get()->dispatchGuiFunc(func);
100
102
}