1 // This file is part of GtkEveMon.
2 //
3 // GtkEveMon is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // You should have received a copy of the GNU General Public License
9 // along with GtkEveMon. If not, see <http://www.gnu.org/licenses/>.
10 
11 #ifndef GTK_PORTRAIT_HEADER
12 #define GTK_PORTRAIT_HEADER
13 
14 #include <string>
15 
16 #include <gdkmm.h>
17 #include <gtkmm.h>
18 
19 #include "net/asynchttp.h"
20 
21 /* The size of the portrait (pixels) in the GUI. */
22 #define PORTRAIT_SIZE 85
23 
24 class GtkPortrait : public Gtk::EventBox
25 {
26   private:
27     Gtk::Image image;
28     std::string char_id;
29     sigc::connection http_request;
30 
31     bool fetch_from_gtkevemon_cache (void);
32     void request_from_eve_online (void);
33     void set_from_eve_online (AsyncHttpData result);
34     bool on_button_press_myevent (GdkEventButton* event);
35     std::string get_portrait_dir (void);
36     std::string get_portrait_file (void);
37 
38     void cache_portrait (Glib::RefPtr<Gdk::Pixbuf> portrait);
39 
40   private:
41     static Glib::RefPtr<Gdk::Pixbuf> create_from_file (std::string const& fn);
42     static void save_to_file (Glib::RefPtr<Gdk::Pixbuf> pixbuf,
43         std::string const& fn);
44 
45   public:
46     GtkPortrait (void);
47     GtkPortrait (std::string const& charid);
48     ~GtkPortrait (void);
49 
50     void set (std::string const& charid);
51     void set_enable_clicks (void);
52     void update (void);
53 };
54 
55 #endif /* GTK_PORTRAIT_HEADER */
56