Remove idiocy.
[ardour2.git] / gtk2_ardour / splash.cc
blobbba754dc108f07afbdca8e432d7bbeabfac21605
1 #include <string>
3 #include "pbd/failed_constructor.h"
4 #include "pbd/file_utils.h"
5 #include "ardour/ardour.h"
6 #include "ardour/filesystem_paths.h"
8 #include "gui_thread.h"
9 #include "splash.h"
11 #include "i18n.h"
13 using namespace Gtk;
14 using namespace Glib;
15 using namespace PBD;
16 using namespace std;
17 using namespace ARDOUR;
19 Splash* Splash::the_splash = 0;
21 Splash::Splash ()
23 sys::path splash_file;
25 if (!find_file_in_search_path (ardour_search_path() + system_data_search_path(), "splash.png", splash_file)) {
26 throw failed_constructor();
29 try {
30 pixbuf = Gdk::Pixbuf::create_from_file (splash_file.to_string());
33 catch (...) {
34 throw failed_constructor();
37 darea.set_size_request (pixbuf->get_width(), pixbuf->get_height());
38 set_keep_above (true);
39 set_position (WIN_POS_CENTER);
40 darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
41 darea.set_double_buffered (false);
43 layout = create_pango_layout ("");
44 string str = "<b>";
45 string i18n = _("Ardour loading ...");
46 str += i18n;
47 str += "</b>";
49 layout->set_markup (str);
51 darea.show ();
52 darea.signal_expose_event().connect (mem_fun (*this, &Splash::expose));
54 add (darea);
56 set_default_size (pixbuf->get_width(), pixbuf->get_height());
57 the_splash = this;
59 ARDOUR::BootMessage.connect (mem_fun (*this, &Splash::boot_message));
62 void
63 Splash::pop_back ()
65 set_keep_above (false);
68 void
69 Splash::on_realize ()
71 Window::on_realize ();
72 get_window()->set_decorations (Gdk::WMDecoration(0));
73 layout->set_font_description (get_style()->get_font());
77 bool
78 Splash::on_button_release_event (GdkEventButton*)
80 hide ();
81 return true;
84 bool
85 Splash::expose (GdkEventExpose* ev)
87 RefPtr<Gdk::Window> window = darea.get_window();
89 /* note: height & width need to be constrained to the pixbuf size
90 in case a WM provides us with a screwy allocation
93 window->draw_pixbuf (get_style()->get_bg_gc (STATE_NORMAL), pixbuf,
94 ev->area.x, ev->area.y,
95 ev->area.x, ev->area.y,
96 min ((pixbuf->get_width() - ev->area.x), ev->area.width),
97 min ((pixbuf->get_height() - ev->area.y), ev->area.height),
98 Gdk::RGB_DITHER_NONE, 0, 0);
100 Glib::RefPtr<Gtk::Style> style = darea.get_style();
101 Glib::RefPtr<Gdk::GC> white = style->get_white_gc();
103 window->draw_layout (white, 10, pixbuf->get_height() - 30, layout);
105 return true;
108 void
109 Splash::boot_message (std::string msg)
111 message (msg);
114 void
115 Splash::message (const string& msg)
117 string str ("<b>");
118 str += msg;
119 str += "</b>";
121 layout->set_markup (str);
122 Glib::RefPtr<Gdk::Window> win = darea.get_window();
124 if (win) {
125 win->invalidate_rect (Gdk::Rectangle (0, darea.get_height() - 30,
126 darea.get_width(), 30), true);
127 win->process_updates (true);
128 gdk_flush ();