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 /* === G L O B A L S ======================================================= */
83 /* === P R O C E D U R E S ================================================= */
85 class studio::SplashProgress : public synfig::ProgressCallback
91 SplashProgress(Splash &splash):splash(splash) { }
93 virtual bool task(const std::string &task)
97 splash.tasklabel->set_label(task);
98 splash.tasklabel->show();
105 while(studio::App::events_pending())studio::App::iteration(false);
109 virtual bool error(const std::string &task)
113 splash.tasklabel->set_label(_("ERROR:")+task);
114 splash.tasklabel->show();
121 while(studio::App::events_pending())studio::App::iteration(false);
125 virtual bool warning(const std::string &task)
129 splash.tasklabel->set_label(_("WARNING:")+task);
130 splash.tasklabel->show();
137 while(studio::App::events_pending())studio::App::iteration(false);
141 virtual bool amount_complete(int current, int total)
143 if(splash.progressbar)
145 splash.progressbar->set_fraction((float)current/(float)total);
146 splash.progressbar->show();
149 cerr<<current<<'/'<<total<<endl;
151 while(studio::App::events_pending())studio::App::iteration(false);
154 }; // END of class SplashProgress
156 /* === M E T H O D S ======================================================= */
159 Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP)
161 std::string imagepath;
163 imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
167 char* synfig_root=getenv("SYNFIG_ROOT");
169 imagepath=synfig_root;
170 imagepath+=ETL_DIRECTORY_SEPARATOR;
172 imagepath+=ETL_DIRECTORY_SEPARATOR;
173 imagepath+="pixmaps";
174 imagepath+=ETL_DIRECTORY_SEPARATOR;
175 imagepath+="synfigstudio";
177 imagepath+=ETL_DIRECTORY_SEPARATOR;
179 // Create the splash image
180 Gtk::Image* splash_image = manage(new class Gtk::Image());
181 splash_image->set(imagepath+"splash_screen."IMAGE_EXT);
182 splash_image->set_alignment(0.5,0.5);
183 splash_image->set_padding(0,0);
185 // Get the image size
186 int image_w = 350; int image_h = 0;
187 Glib::RefPtr<Gdk::Pixbuf> pixbuf = splash_image->get_pixbuf();
189 image_w = pixbuf->get_width();
190 image_h = pixbuf->get_height();
193 // Create the progress bar
194 progressbar = manage(new class Gtk::ProgressBar());
195 progressbar->set_size_request(image_w,24);
197 // Create the current task label
198 tasklabel = manage(new class Gtk::Label());
199 tasklabel->set_size_request(image_w,24);
200 tasklabel->set_use_underline(false);
202 // Create the Gtk::Fixed container and put all of the widgets into it
203 Gtk::Fixed* fixed = manage(new class Gtk::Fixed());
204 if( pixbuf ) fixed->put(*splash_image, 0, 0);
205 fixed->put(*progressbar, 0, image_h+24);
206 fixed->put(*tasklabel, 0, image_h);
208 // Create shadow around the outside of the window
209 Gtk::Frame* frame = manage(new class Gtk::Frame());
210 frame->set_shadow_type(Gtk::SHADOW_OUT);
213 // Set up the parameters for this pop-up window
214 set_title("Synfig Studio "VERSION);
216 property_window_position().set_value(Gtk::WIN_POS_CENTER);
217 set_resizable(false);
218 set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
219 set_auto_startup_notification(false);
221 set_icon_from_file(imagepath+"synfig_icon."+IMAGE_EXT);
223 synfig::warning("Unable to open "+imagepath+"synfig_icon."+IMAGE_EXT);
227 // show everything off
228 if( pixbuf ) splash_image->show();
232 // Once the splash is shown, we want startup stuff to continue as normal
233 signal_map().connect(sigc::mem_fun(*this, &Splash::enable_startup_notification));
235 cb=new SplashProgress(*this);
243 synfig::ProgressCallback *
244 Splash::get_callback()
250 Splash::enable_startup_notification(){
251 set_auto_startup_notification(true);