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;
|
|
|
|
|
2012-05-18 13:24:06 -04:00
|
|
|
if (!find_file_in_search_path (ardour_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());
|
2012-01-10 13:21:39 -05:00
|
|
|
pop_front ();
|
2008-01-18 22:49:52 -05:00
|
|
|
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>";
|
2010-03-14 22:31:27 -04:00
|
|
|
string i18n = string_compose (_("%1 loading ..."), PROGRAM_NAME);
|
2008-02-01 22:57:35 -05:00
|
|
|
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
|
|
|
|
2012-04-25 08:58:19 -04:00
|
|
|
ARDOUR::BootMessage.connect (msg_connection, invalidator (*this), boost::bind (&Splash::boot_message, this, _1), gui_context());
|
2008-02-02 12:22:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-10 13:21:39 -05:00
|
|
|
Splash::pop_back_for (Gtk::Window& win)
|
2008-02-02 12:22:04 -05:00
|
|
|
{
|
|
|
|
set_keep_above (false);
|
2012-01-10 13:21:39 -05:00
|
|
|
get_window()->restack (win.get_window(), false);
|
|
|
|
win.signal_hide().connect (sigc::mem_fun (*this, &Splash::pop_front));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::pop_front ()
|
|
|
|
{
|
|
|
|
set_keep_above (true);
|
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
|
|
|
}
|