2008-01-18 22:49:52 -05:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <pbd/failed_constructor.h>
|
|
|
|
#include <pbd/file_utils.h>
|
|
|
|
#include <ardour/ardour.h>
|
|
|
|
#include <ardour/filesystem_paths.h>
|
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (!find_file_in_search_path (ardour_search_path(), "splash.png", splash_file)) {
|
|
|
|
throw failed_constructor();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
pixbuf = Gdk::Pixbuf::create_from_file (splash_file.to_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...) {
|
|
|
|
throw failed_constructor();
|
|
|
|
}
|
2008-02-01 22:57:35 -05: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 ();
|
|
|
|
darea.signal_expose_event().connect (mem_fun (*this, &Splash::expose));
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ARDOUR::BootMessage.connect (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
|
|
|
|
Splash::on_button_release_event (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
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,
|
2008-02-16 17:43:18 -05:00
|
|
|
min ((pixbuf->get_width() - ev->area.x), ev->area.width),
|
|
|
|
min ((pixbuf->get_height() - ev->area.y), ev->area.height),
|
2008-01-18 22:49:52 -05:00
|
|
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
2008-02-16 17:43:18 -05: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);
|
|
|
|
darea.queue_draw ();
|
2008-02-16 17:43:18 -05:00
|
|
|
|
|
|
|
Glib::RefPtr<Gdk::Window> win = darea.get_window();
|
|
|
|
if (win) {
|
|
|
|
win->process_updates (true);
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
2008-01-19 00:06:33 -05:00
|
|
|
}
|