|
Carlos Lopez |
a09598 |
/* === S Y N F I G ========================================================= */
|
|
Carlos Lopez |
a09598 |
/*! \file splash.cpp
|
|
Carlos Lopez |
a09598 |
** \brief writeme
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** $Id$
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** \legal
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2007 Chris Moore
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2008 Paul Wise
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** This package is free software; you can redistribute it and/or
|
|
Carlos Lopez |
a09598 |
** modify it under the terms of the GNU General Public License as
|
|
Carlos Lopez |
a09598 |
** published by the Free Software Foundation; either version 2 of
|
|
Carlos Lopez |
a09598 |
** the License, or (at your option) any later version.
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** This package is distributed in the hope that it will be useful,
|
|
Carlos Lopez |
a09598 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Carlos Lopez |
a09598 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Carlos Lopez |
a09598 |
** General Public License for more details.
|
|
Carlos Lopez |
a09598 |
** \endlegal
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** === N O T E S ===========================================================
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** ========================================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === H E A D E R S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#ifdef USING_PCH
|
|
Carlos Lopez |
a09598 |
# include "pch.h"
|
|
Carlos Lopez |
a09598 |
#else
|
|
Carlos Lopez |
a09598 |
#ifdef HAVE_CONFIG_H
|
|
Carlos Lopez |
a09598 |
# include <config.h></config.h>
|
|
Carlos Lopez |
a09598 |
#endif
|
|
Carlos Lopez |
a09598 |
|
|
bw |
94d8a6 |
#include <synfig general.h=""></synfig>
|
|
bw |
94d8a6 |
|
|
Carlos Lopez |
a09598 |
#include <iostream></iostream>
|
|
Carlos Lopez |
a09598 |
#include <string></string>
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#include <etl stringf=""></etl>
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#include <gtkmm image.h=""></gtkmm>
|
|
Carlos Lopez |
a09598 |
#include <gtkmm label.h=""></gtkmm>
|
|
Carlos Lopez |
a09598 |
#include <gtkmm frame.h=""></gtkmm>
|
|
Carlos Lopez |
a09598 |
#include <gtkmm fixed.h=""></gtkmm>
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
#include <gdkmm rgba.h=""></gdkmm>
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#include "splash.h"
|
|
Carlos Lopez |
a09598 |
#include "app.h"
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
abdbf2 |
#include <gui localization.h=""></gui>
|
|
Rodolfo Ribeiro Gomes |
950278 |
#include "gui/resourcehelper.h"
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#endif
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
using namespace std;
|
|
Carlos Lopez |
a09598 |
using namespace etl;
|
|
Carlos Lopez |
a09598 |
using namespace studio;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === M A C R O S ========================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#ifndef VERSION
|
|
Carlos Lopez |
a09598 |
#define VERSION "unknown"
|
|
Carlos Lopez |
a09598 |
#define PACKAGE "synfigstudio"
|
|
Carlos Lopez |
a09598 |
#endif
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#ifndef IMAGE_EXT
|
|
Carlos Lopez |
a09598 |
# define IMAGE_EXT "png"
|
|
Carlos Lopez |
a09598 |
#endif
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === G L O B A L S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === P R O C E D U R E S ================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
class studio::SplashProgress : public synfig::ProgressCallback
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
Splash &splash;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
public:
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
SplashProgress(Splash &splash):splash(splash) { }
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
virtual bool task(const std::string &task)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(splash.tasklabel)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
splash.tasklabel->set_label(task);
|
|
Carlos Lopez |
a09598 |
splash.tasklabel->show();
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
923e52 |
synfig::info(task);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
923e52 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
923e52 |
studio::App::process_all_events();
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
virtual bool error(const std::string &task)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(splash.tasklabel)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
splash.tasklabel->set_label(_("ERROR:")+task);
|
|
Carlos Lopez |
a09598 |
splash.tasklabel->show();
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
5aa5d3 |
synfig::error(task);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
5aa5d3 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
923e52 |
studio::App::process_all_events();
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
virtual bool warning(const std::string &task)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(splash.tasklabel)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
splash.tasklabel->set_label(_("WARNING:")+task);
|
|
Carlos Lopez |
a09598 |
splash.tasklabel->show();
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
5aa5d3 |
synfig::warning(task);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
5aa5d3 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
923e52 |
studio::App::process_all_events();
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
virtual bool amount_complete(int current, int total)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(splash.progressbar)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
splash.progressbar->set_fraction((float)current/(float)total);
|
|
Carlos Lopez |
a09598 |
splash.progressbar->show();
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
923e52 |
studio::App::process_all_events();
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
}; // END of class SplashProgress
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === M E T H O D S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Splash::Splash():
|
|
caryoscelus |
286c3e |
Gtk::Window(Gtk::WINDOW_TOPLEVEL)
|
|
Carlos Lopez |
a09598 |
{
|
|
Rodolfo Ribeiro Gomes |
950278 |
std::string imagepath = ResourceHelper::get_image_path() + '/';
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Create the splash image
|
|
Carlos Lopez |
a09598 |
Gtk::Image* splash_image = manage(new class Gtk::Image());
|
|
![](https://seccdn.libravatar.org/avatar/cf96cb977b96400a86a77970e83fe7671d726eab921211cd8816a1000b348955?d=retro&s=16) |
8463ca |
/* Dual-splash code:
|
|
Carlos Lopez |
d2ef64 |
srand(time(NULL));
|
|
Carlos Lopez |
d2ef64 |
const float ran = rand()/float(RAND_MAX);
|
|
Carlos Lopez |
92fc16 |
int number = 1;
|
|
Carlos Lopez |
92fc16 |
if(ran >0.499999)
|
|
Carlos Lopez |
92fc16 |
number = 2;
|
|
Carlos Lopez |
274657 |
//synfig::info("%s", strprintf("%d",number).c_str());
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
9aaa53 |
splash_image->set(imagepath+"splash_screen"+strprintf("%d",number)+"." IMAGE_EXT);
|
|
![](https://seccdn.libravatar.org/avatar/cf96cb977b96400a86a77970e83fe7671d726eab921211cd8816a1000b348955?d=retro&s=16) |
8463ca |
*/
|
|
Rodolfo Ribeiro Gomes |
950278 |
splash_image->set(imagepath + "splash_screen." IMAGE_EXT);
|
|
Carlos Lopez |
a09598 |
splash_image->set_alignment(0.5,0.5);
|
|
Carlos Lopez |
a09598 |
splash_image->set_padding(0,0);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Get the image size
|
|
Carlos Lopez |
a09598 |
int image_w = 350; int image_h = 0;
|
|
Carlos Lopez |
a09598 |
Glib::RefPtr<gdk::pixbuf> pixbuf = splash_image->get_pixbuf();</gdk::pixbuf>
|
|
Carlos Lopez |
a09598 |
if( pixbuf ){
|
|
Carlos Lopez |
a09598 |
image_w = pixbuf->get_width();
|
|
Carlos Lopez |
a09598 |
image_h = pixbuf->get_height();
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Create the progress bar
|
|
Carlos Lopez |
a09598 |
progressbar = manage(new class Gtk::ProgressBar());
|
|
Carlos Lopez |
a09598 |
progressbar->set_size_request(image_w,24);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Create the current task label
|
|
Carlos Lopez |
a09598 |
tasklabel = manage(new class Gtk::Label());
|
|
Carlos Lopez |
a09598 |
tasklabel->set_size_request(image_w,24);
|
|
Carlos Lopez |
a09598 |
tasklabel->set_use_underline(false);
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
// Create the current task label
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
versionlabel = manage(new class Gtk::Label());
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
versionlabel->set_label("" VERSION);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
versionlabel->set_size_request(image_w,24);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
versionlabel->set_use_underline(false);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
50bcb4 |
versionlabel->override_color(Gdk::RGBA("#FFFFFF"));
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
versionlabel->show();
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
|
|
Carlos Lopez |
a09598 |
// Create the Gtk::Fixed container and put all of the widgets into it
|
|
Carlos Lopez |
a09598 |
Gtk::Fixed* fixed = manage(new class Gtk::Fixed());
|
|
Carlos Lopez |
a09598 |
if( pixbuf ) fixed->put(*splash_image, 0, 0);
|
|
Carlos Lopez |
a09598 |
fixed->put(*progressbar, 0, image_h+24);
|
|
Carlos Lopez |
a09598 |
fixed->put(*tasklabel, 0, image_h);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
fa575c |
fixed->put(*versionlabel, 0, image_h-24);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Create shadow around the outside of the window
|
|
Carlos Lopez |
a09598 |
Gtk::Frame* frame = manage(new class Gtk::Frame());
|
|
Carlos Lopez |
a09598 |
frame->set_shadow_type(Gtk::SHADOW_OUT);
|
|
Carlos Lopez |
a09598 |
frame->add(*fixed);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Set up the parameters for this pop-up window
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
9aaa53 |
set_title("Synfig Studio " VERSION);
|
|
Carlos Lopez |
a09598 |
set_modal(false);
|
|
Carlos Lopez |
a09598 |
property_window_position().set_value(Gtk::WIN_POS_CENTER);
|
|
Carlos Lopez |
a09598 |
set_resizable(false);
|
|
Carlos Lopez |
a09598 |
set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
|
|
Carlos Lopez |
a09598 |
set_auto_startup_notification(false);
|
|
Carlos Lopez |
a09598 |
try {
|
|
Carlos Lopez |
a09598 |
set_icon_from_file(imagepath+"synfig_icon."+IMAGE_EXT);
|
|
Carlos Lopez |
a09598 |
} catch(...) {
|
|
Carlos Lopez |
a09598 |
synfig::warning("Unable to open "+imagepath+"synfig_icon."+IMAGE_EXT);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
add(*frame);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// show everything off
|
|
Carlos Lopez |
a09598 |
if( pixbuf ) splash_image->show();
|
|
Carlos Lopez |
a09598 |
fixed->show();
|
|
Carlos Lopez |
a09598 |
frame->show();
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// Once the splash is shown, we want startup stuff to continue as normal
|
|
Carlos Lopez |
a09598 |
signal_map().connect(sigc::mem_fun(*this, &Splash::enable_startup_notification));
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
cb=new SplashProgress(*this);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Splash::~Splash()
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
delete cb;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
synfig::ProgressCallback *
|
|
Carlos Lopez |
a09598 |
Splash::get_callback()
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
return cb;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
void
|
|
Carlos Lopez |
a09598 |
Splash::enable_startup_notification(){
|
|
Carlos Lopez |
a09598 |
set_auto_startup_notification(true);
|
|
Carlos Lopez |
a09598 |
}
|