2008-01-18 22:49:52 -05:00
|
|
|
#include <string>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/failed_constructor.h"
|
|
|
|
#include "pbd/file_utils.h"
|
|
|
|
#include "ardour/ardour.h"
|
|
|
|
#include "ardour/filesystem_paths.h"
|
2008-01-18 22:49:52 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
#include "gui_thread.h"
|
2008-01-18 22:49:52 -05:00
|
|
|
#include "splash.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace PBD;
|
2008-01-18 22:49:52 -05:00
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
2008-02-02 12:22:04 -05:00
|
|
|
Splash* Splash::the_splash = 0;
|
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
Splash::Splash ()
|
|
|
|
{
|
|
|
|
sys::path splash_file;
|
|
|
|
|
2008-02-21 23:13:44 -05:00
|
|
|
if (!find_file_in_search_path (ardour_search_path() + system_data_search_path(), "splash.png", splash_file)) {
|
2008-01-18 22:49:52 -05:00
|
|
|
throw failed_constructor();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
pixbuf = Gdk::Pixbuf::create_from_file (splash_file.to_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...) {
|
|
|
|
throw failed_constructor();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-19 00:06:33 -05:00
|
|
|
darea.set_size_request (pixbuf->get_width(), pixbuf->get_height());
|
2008-01-18 22:49:52 -05:00
|
|
|
set_keep_above (true);
|
|
|
|
set_position (WIN_POS_CENTER);
|
2008-01-19 00:06:33 -05:00
|
|
|
darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
|
2008-02-16 17:43:18 -05:00
|
|
|
darea.set_double_buffered (false);
|
2008-01-19 00:06:33 -05:00
|
|
|
|
|
|
|
layout = create_pango_layout ("");
|
2008-02-01 22:57:35 -05:00
|
|
|
string str = "<b>";
|
|
|
|
string i18n = _("Ardour loading ...");
|
|
|
|
str += i18n;
|
|
|
|
str += "</b>";
|
|
|
|
|
|
|
|
layout->set_markup (str);
|
2008-01-19 00:06:33 -05:00
|
|
|
|
|
|
|
darea.show ();
|
2009-12-11 18:29:48 -05:00
|
|
|
darea.signal_expose_event().connect (sigc::mem_fun (*this, &Splash::expose));
|
2008-01-19 00:06:33 -05:00
|
|
|
|
|
|
|
add (darea);
|
2008-02-02 12:22:04 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
set_default_size (pixbuf->get_width(), pixbuf->get_height());
|
2008-02-02 12:22:04 -05:00
|
|
|
the_splash = this;
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
ARDOUR::BootMessage.connect (sigc::mem_fun (*this, &Splash::boot_message));
|
2008-02-02 12:22:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::pop_back ()
|
|
|
|
{
|
|
|
|
set_keep_above (false);
|
2008-01-19 00:06:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::on_realize ()
|
|
|
|
{
|
|
|
|
Window::on_realize ();
|
2008-02-01 22:57:35 -05:00
|
|
|
get_window()->set_decorations (Gdk::WMDecoration(0));
|
2008-01-19 00:06:33 -05:00
|
|
|
layout->set_font_description (get_style()->get_font());
|
2008-01-18 22:49:52 -05:00
|
|
|
}
|
|
|
|
|
2008-01-19 00:06:33 -05:00
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Splash::on_button_release_event (GdkEventButton*)
|
2008-01-18 22:49:52 -05:00
|
|
|
{
|
|
|
|
hide ();
|
2008-01-19 00:06:33 -05:00
|
|
|
return true;
|
2008-01-18 22:49:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2008-01-19 00:06:33 -05:00
|
|
|
Splash::expose (GdkEventExpose* ev)
|
2008-01-18 22:49:52 -05:00
|
|
|
{
|
2008-01-19 00:06:33 -05:00
|
|
|
RefPtr<Gdk::Window> window = darea.get_window();
|
2008-01-18 22:49:52 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
/* note: height & width need to be constrained to the pixbuf size
|
|
|
|
in case a WM provides us with a screwy allocation
|
|
|
|
*/
|
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
window->draw_pixbuf (get_style()->get_bg_gc (STATE_NORMAL), pixbuf,
|
2008-01-18 22:49:52 -05:00
|
|
|
ev->area.x, ev->area.y,
|
|
|
|
ev->area.x, ev->area.y,
|
2009-10-14 12:10:01 -04:00
|
|
|
min ((pixbuf->get_width() - ev->area.x), ev->area.width),
|
2008-02-16 17:43:18 -05:00
|
|
|
min ((pixbuf->get_height() - ev->area.y), ev->area.height),
|
2008-01-18 22:49:52 -05:00
|
|
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
Glib::RefPtr<Gtk::Style> style = darea.get_style();
|
2008-01-19 00:06:33 -05:00
|
|
|
Glib::RefPtr<Gdk::GC> white = style->get_white_gc();
|
|
|
|
|
|
|
|
window->draw_layout (white, 10, pixbuf->get_height() - 30, layout);
|
2008-02-01 22:57:35 -05:00
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
return true;
|
|
|
|
}
|
2008-01-19 00:06:33 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
void
|
|
|
|
Splash::boot_message (std::string msg)
|
|
|
|
{
|
|
|
|
message (msg);
|
|
|
|
}
|
|
|
|
|
2008-01-19 00:06:33 -05:00
|
|
|
void
|
|
|
|
Splash::message (const string& msg)
|
|
|
|
{
|
|
|
|
string str ("<b>");
|
|
|
|
str += msg;
|
|
|
|
str += "</b>";
|
|
|
|
|
|
|
|
layout->set_markup (str);
|
2008-02-16 17:43:18 -05:00
|
|
|
Glib::RefPtr<Gdk::Window> win = darea.get_window();
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
if (win) {
|
2008-03-17 16:54:03 -04:00
|
|
|
win->invalidate_rect (Gdk::Rectangle (0, darea.get_height() - 30,
|
|
|
|
darea.get_width(), 30), true);
|
2008-02-16 17:43:18 -05:00
|
|
|
win->process_updates (true);
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
2008-01-19 00:06:33 -05:00
|
|
|
}
|