put man pages here at top level
[ardour2.git] / gtk2_ardour / splash.cc
blob1ed991f74b6fa59502f0ee47ab2bf0c4db8a58ca
1 #include <string>
3 #include <pbd/failed_constructor.h>
4 #include <ardour/ardour.h>
6 #include "gui_thread.h"
7 #include "splash.h"
9 #include "i18n.h"
11 using namespace Gtk;
12 using namespace Glib;
13 using namespace std;
14 using namespace ARDOUR;
16 Splash* Splash::the_splash = 0;
18 Splash::Splash ()
20 string path = find_data_file ("splash.png");
22 if (path.empty()) {
23 throw failed_constructor();
26 try {
27 pixbuf = Gdk::Pixbuf::create_from_file (path);
30 catch (...) {
31 throw failed_constructor();
34 darea.set_size_request (pixbuf->get_width(), pixbuf->get_height());
35 set_keep_above (true);
36 set_position (WIN_POS_CENTER);
37 darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
38 darea.set_double_buffered (false);
40 layout = create_pango_layout ("");
41 string str = "<b>";
42 string i18n = _("Ardour loading ...");
43 str += i18n;
44 str += "</b>";
46 layout->set_markup (str);
48 darea.show ();
49 darea.signal_expose_event().connect (mem_fun (*this, &Splash::expose));
51 add (darea);
53 set_default_size (pixbuf->get_width(), pixbuf->get_height());
54 the_splash = this;
56 ARDOUR::BootMessage.connect (mem_fun (*this, &Splash::boot_message));
59 void
60 Splash::pop_back ()
62 set_keep_above (false);
65 void
66 Splash::on_realize ()
68 Window::on_realize ();
69 get_window()->set_decorations (Gdk::WMDecoration(0));
70 layout->set_font_description (get_style()->get_font());
74 bool
75 Splash::on_button_release_event (GdkEventButton* ev)
77 hide ();
78 return true;
81 bool
82 Splash::expose (GdkEventExpose* ev)
84 RefPtr<Gdk::Window> window = darea.get_window();
86 /* note: height & width need to be constrained to the pixbuf size
87 in case a WM provides us with a screwy allocation
90 window->draw_pixbuf (get_style()->get_bg_gc (STATE_NORMAL), pixbuf,
91 ev->area.x, ev->area.y,
92 ev->area.x, ev->area.y,
93 min ((pixbuf->get_width() - ev->area.x), ev->area.width),
94 min ((pixbuf->get_height() - ev->area.y), ev->area.height),
95 Gdk::RGB_DITHER_NONE, 0, 0);
97 Glib::RefPtr<Gtk::Style> style = darea.get_style();
98 Glib::RefPtr<Gdk::GC> white = style->get_white_gc();
100 window->draw_layout (white, 10, pixbuf->get_height() - 30, layout);
102 return true;
105 void
106 Splash::boot_message (std::string msg)
108 message (msg);
111 void
112 Splash::message (const string& msg)
114 string str ("<b>");
115 str += msg;
116 str += "</b>";
118 layout->set_markup (str);
119 Glib::RefPtr<Gdk::Window> win = darea.get_window();
121 if (win) {
122 win->invalidate_rect (Gdk::Rectangle (0, darea.get_height() - 30,
123 darea.get_width(), 30), true);
124 win->process_updates (true);
125 gdk_flush ();