aboutsummaryrefslogtreecommitdiff
path: root/src/mods.h
blob: dab5a1565ec572613b17c99f72dfc66ae16cded4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <glib.h>
#include <thread>
#include <mutex>
#include <vector>
#include <string>
#include <gtkmm.h>
#include <libbible.h>

using namespace std;

class Header;

/*
 * Credit goes to the Xiphos project for this part of the code:
 * https://github.com/crosswire/xiphos/
 */

class Mods : public Gtk::Frame, public libbible::Status
{
public:
    Mods(Header *header, Gtk::Window *window);
    virtual ~Mods();

    void displayMain();
    void displayDownload();
    
    // This is for Status. Huzzah for multiple inheritance!
    virtual void update(unsigned long totalBytes, unsigned long completedBytes, std::string message);

protected:
    Header *header;
    Gtk::Window *window;
    std::map<std::string, std::vector<std::string>> modsAvailable;

    Gtk::MessageDialog progressDialog;
    Gtk::ProgressBar progressBar;
    Glib::Dispatcher dispatcher;
    mutable std::mutex progressMutex;
    double fracDone;
    std::string message;
    std::thread *worker;
    bool complete;
    void getStatus(double *fractionDone, std::string *mess, bool *isComplete) const;
    void onNotify();

    void showProgress(std::string message);
    void endProgress();

};