1 /* === S Y N F I G ========================================================= */
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
10 ** Copyright (c) 2008 Paul Wise
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 ** === N O T E S ===========================================================
25 ** ========================================================================= */
27 /* === H E A D E R S ======================================================= */
39 #include <ETL/stringf>
41 #include <gtkmm/image.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/frame.h>
44 #include <gtkmm/fixed.h>
46 #include <synfig/general.h>
57 using namespace studio;
59 /* === M A C R O S ========================================================= */
62 #define VERSION "unknown"
63 #define PACKAGE "synfigstudio"
69 # define IMAGE_DIR "share\\pixmaps"
74 # define IMAGE_DIR "/usr/local/share/pixmaps"
78 # define IMAGE_EXT "png"
81 #define NUMBER_OF_SPLASH_SCREEN 2
83 /* === G L O B A L S ======================================================= */
85 /* === P R O C E D U R E S ================================================= */
87 class studio::SplashProgress : public synfig::ProgressCallback
93 SplashProgress(Splash &splash):splash(splash) { }
95 virtual bool task(const std::string &task)
99 splash.tasklabel->set_label(task);
100 splash.tasklabel->show();
107 while(studio::App::events_pending())studio::App::iteration(false);
111 virtual bool error(const std::string &task)
115 splash.tasklabel->set_label(_("ERROR:")+task);
116 splash.tasklabel->show();
123 while(studio::App::events_pending())studio::App::iteration(false);
127 virtual bool warning(const std::string &task)
131 splash.tasklabel->set_label(_("WARNING:")+task);
132 splash.tasklabel->show();
139 while(studio::App::events_pending())studio::App::iteration(false);
143 virtual bool amount_complete(int current, int total)
145 if(splash.progressbar)
147 splash.progressbar->set_fraction((float)current/(float)total);
148 splash.progressbar->show();
151 cerr<<current<<'/'<<total<<endl;
153 while(studio::App::events_pending())studio::App::iteration(false);
156 }; // END of class SplashProgress
158 /* === M E T H O D S ======================================================= */
161 Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP)
163 std::string imagepath;
165 imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
169 char* synfig_root=getenv("SYNFIG_ROOT");
171 imagepath=synfig_root;
172 imagepath+=ETL_DIRECTORY_SEPARATOR;
174 imagepath+=ETL_DIRECTORY_SEPARATOR;
175 imagepath+="pixmaps";
176 imagepath+=ETL_DIRECTORY_SEPARATOR;
177 imagepath+="synfigstudio";
179 imagepath+=ETL_DIRECTORY_SEPARATOR;
181 // Create the splash image
182 Gtk::Image* splash_image = manage(new class Gtk::Image());
184 const float ran = rand()/float(RAND_MAX);
185 int number =1+int(ran*(NUMBER_OF_SPLASH_SCREEN));
186 splash_image->set(imagepath+"splash_screen"+strprintf("%d",number)+"."IMAGE_EXT);
187 splash_image->set_alignment(0.5,0.5);
188 splash_image->set_padding(0,0);
190 // Get the image size
191 int image_w = 350; int image_h = 0;
192 Glib::RefPtr<Gdk::Pixbuf> pixbuf = splash_image->get_pixbuf();
194 image_w = pixbuf->get_width();
195 image_h = pixbuf->get_height();
198 // Create the progress bar
199 progressbar = manage(new class Gtk::ProgressBar());
200 progressbar->set_size_request(image_w,24);
202 // Create the current task label
203 tasklabel = manage(new class Gtk::Label());
204 tasklabel->set_size_request(image_w,24);
205 tasklabel->set_use_underline(false);
207 // Create the Gtk::Fixed container and put all of the widgets into it
208 Gtk::Fixed* fixed = manage(new class Gtk::Fixed());
209 if( pixbuf ) fixed->put(*splash_image, 0, 0);
210 fixed->put(*progressbar, 0, image_h+24);
211 fixed->put(*tasklabel, 0, image_h);
213 // Create shadow around the outside of the window
214 Gtk::Frame* frame = manage(new class Gtk::Frame());
215 frame->set_shadow_type(Gtk::SHADOW_OUT);
218 // Set up the parameters for this pop-up window
219 set_title("Synfig Studio "VERSION);
221 property_window_position().set_value(Gtk::WIN_POS_CENTER);
222 set_resizable(false);
223 set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
224 set_auto_startup_notification(false);
226 set_icon_from_file(imagepath+"synfig_icon."+IMAGE_EXT);
228 synfig::warning("Unable to open "+imagepath+"synfig_icon."+IMAGE_EXT);
232 // show everything off
233 if( pixbuf ) splash_image->show();
237 // Once the splash is shown, we want startup stuff to continue as normal
238 signal_map().connect(sigc::mem_fun(*this, &Splash::enable_startup_notification));
240 cb=new SplashProgress(*this);
248 synfig::ProgressCallback *
249 Splash::get_callback()
255 Splash::enable_startup_notification(){
256 set_auto_startup_notification(true);