reinstate functional clocks
[ardour.git] / gtk2_ardour / splash.cc
1 #include <string>
2
3 #include <pbd/failed_constructor.h>
4 #include <ardour/ardour.h>
5
6 #include "splash.h"
7
8 #include "i18n.h"
9
10 using namespace Gtk;
11 using namespace Glib;
12 using namespace std;
13 using namespace ARDOUR;
14
15 Splash* Splash::the_splash = 0;
16
17 Splash::Splash ()
18 {
19         string path = find_data_file ("splash.png");
20
21         if (path.empty()) {
22                 throw failed_constructor();
23         }
24
25         try {
26                 pixbuf = Gdk::Pixbuf::create_from_file (path);
27         }
28
29         catch (...) {
30                 throw failed_constructor();
31         }
32         
33         darea.set_size_request (pixbuf->get_width(), pixbuf->get_height());
34         set_keep_above (true);
35         set_position (WIN_POS_CENTER);
36         darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
37
38         layout = create_pango_layout ("");
39         string str = "<b>";
40         string i18n = _("Ardour loading ...");
41         str += i18n;
42         str += "</b>";
43
44         layout->set_markup (str);
45
46         darea.show ();
47         darea.signal_expose_event().connect (mem_fun (*this, &Splash::expose));
48
49         add (darea);
50
51         the_splash = this;
52 }
53
54 void
55 Splash::pop_back ()
56 {
57         set_keep_above (false);
58 }
59
60 void
61 Splash::on_realize ()
62 {
63         Window::on_realize ();
64         get_window()->set_decorations (Gdk::WMDecoration(0));
65         layout->set_font_description (get_style()->get_font());
66 }
67
68
69 bool
70 Splash::on_button_release_event (GdkEventButton* ev)
71 {
72         hide ();
73         return true;
74 }
75
76 bool
77 Splash::expose (GdkEventExpose* ev)
78 {
79         RefPtr<Gdk::Window> window = darea.get_window();
80
81         window->draw_pixbuf (get_style()->get_bg_gc (STATE_NORMAL), pixbuf,
82                              ev->area.x, ev->area.y,
83                              ev->area.x, ev->area.y,
84                              ev->area.width, ev->area.height,
85                              Gdk::RGB_DITHER_NONE, 0, 0);
86
87         Glib::RefPtr<Gtk::Style> style = darea.get_style();
88         Glib::RefPtr<Gdk::GC> white = style->get_white_gc();
89
90         window->draw_layout (white, 10, pixbuf->get_height() - 30, layout);
91
92         return true;
93 }
94
95 void
96 Splash::message (const string& msg)
97 {
98         string str ("<b>");
99         str += msg;
100         str += "</b>";
101
102         layout->set_markup (str);
103         darea.queue_draw ();
104         get_window()->process_updates (true);
105 }