1 /* === S Y N F I G ========================================================= */
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 ** === N O T E S ===========================================================
24 ** ========================================================================= */
26 /* === H E A D E R S ======================================================= */
38 #include <ETL/stringf>
40 #include <gtkmm/image.h>
41 #include <gdkmm/pixbufloader.h>
42 #include <gtkmm/button.h>
43 #include <gtkmm/label.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 ======================================================= */
82 extern const guint gtk_major_version;
83 extern const guint gtk_minor_version;
84 extern const guint gtk_micro_version;
85 extern const guint gtk_binary_age;
86 extern const guint gtk_interface_age;
88 /* === P R O C E D U R E S ================================================= */
90 class studio::SplashProgress : public synfig::ProgressCallback
96 SplashProgress(Splash &splash):splash(splash) { }
98 virtual bool task(const std::string &task)
102 splash.tasklabel->set_label(task);
103 splash.tasklabel->show();
110 while(studio::App::events_pending())studio::App::iteration(false);
114 virtual bool error(const std::string &task)
118 splash.tasklabel->set_label(_("ERROR:")+task);
119 splash.tasklabel->show();
126 while(studio::App::events_pending())studio::App::iteration(false);
130 virtual bool warning(const std::string &task)
134 splash.tasklabel->set_label(_("WARNING:")+task);
135 splash.tasklabel->show();
142 while(studio::App::events_pending())studio::App::iteration(false);
146 virtual bool amount_complete(int current, int total)
148 if(splash.progressbar)
150 splash.progressbar->set_fraction((float)current/(float)total);
151 splash.progressbar->show();
154 cerr<<current<<'/'<<total<<endl;
156 while(studio::App::events_pending())studio::App::iteration(false);
159 }; // END of class SplashProgress
161 /* === M E T H O D S ======================================================= */
164 Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP),
165 can_self_destruct(true)
167 int image_w=300,image_h=350;
169 std::string imagepath;
171 imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
175 char* synfig_root=getenv("SYNFIG_ROOT");
177 imagepath=synfig_root;
178 imagepath+=ETL_DIRECTORY_SEPARATOR;
180 imagepath+="share/pixmaps";
182 imagepath+=ETL_DIRECTORY_SEPARATOR;
186 Gtk::Image *Logo = manage(new class Gtk::Image());
187 Logo->set(imagepath+"splash_screen."IMAGE_EXT);
188 Logo->set_size_request(image_w,image_h);
189 Logo->set_alignment(0.5,0.5);
190 Logo->set_padding(0,0);
192 // Create the Copyright Label
193 Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SYNFIG_COPYRIGHT));
194 CopyrightLabel->set_size_request(image_w,24);
195 CopyrightLabel->set_alignment(0.5,0.5);
196 CopyrightLabel->set_padding(0,0);
197 CopyrightLabel->set_justify(Gtk::JUSTIFY_CENTER);
198 CopyrightLabel->set_line_wrap(false);
199 CopyrightLabel->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("black"));
201 /* Scale the text to fit */
205 Glib::RefPtr<Pango::Layout> l = CopyrightLabel->get_layout();
206 Pango::FontDescription fd = Pango::FontDescription("Sans, 11");
207 l->set_font_description(fd);
208 l->set_justify(Pango::ALIGN_CENTER);
209 fd.set_size(int(size*Pango::SCALE));
210 l->set_font_description(fd);
211 l->get_pixel_size(width,height);
212 while( width >= image_w-6 ){
214 fd.set_size((int)(size*Pango::SCALE));
215 l->set_font_description(fd);
216 l->get_pixel_size(width,height);
218 CopyrightLabel->modify_font(fd);
220 // Create the Version information label
221 Gtk::Label *VersionLabel = manage(new class Gtk::Label(_("Version")));
222 VersionLabel->set_size_request(image_w,80);
223 VersionLabel->set_flags(Gtk::CAN_FOCUS);
224 VersionLabel->set_alignment(0.5,0.5);
225 VersionLabel->set_padding(0,0);
226 VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
227 VersionLabel->set_line_wrap(false);
228 VersionLabel->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("black"));
230 // Set the version label to contain the correct information
232 ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
233 ver+="Using Synfig ";
234 ver+=synfig::get_version();
236 ver+=strprintf(" and GNU G++ %d.%d.%d",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
239 ver+=strprintf("\nGtk+ %d.%d.%d",gtk_major_version,gtk_minor_version,gtk_micro_version);
242 ver+="\nDEBUG BUILD";
244 VersionLabel->set_text(ver);
246 /* Scale the text to fit */
250 l = VersionLabel->get_layout();
251 fd = Pango::FontDescription("Sans, 11");
252 l->set_font_description(fd);
253 l->set_justify(Pango::ALIGN_CENTER);
254 fd.set_size(int(size*Pango::SCALE));
255 l->set_font_description(fd);
256 l->get_pixel_size(width,height);
257 while( width >= image_w-6 ){
259 fd.set_size((int)(size*Pango::SCALE));
260 l->set_font_description(fd);
261 l->get_pixel_size(width,height);
263 VersionLabel->modify_font(fd);
265 // Create the image that will be used on the close button
266 Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
267 image2->set_alignment(0.5,0.5);
268 image2->set_padding(0,0);
270 // Create the close button, and attach the image to it
271 CloseButton = manage(new class Gtk::Button());
272 CloseButton->set_size_request(24,24);
273 CloseButton->set_flags(Gtk::CAN_FOCUS);
274 _tooltips.set_tip(*CloseButton, _("Close"), "");
275 CloseButton->set_relief(Gtk::RELIEF_NONE);
276 CloseButton->add(*image2);
278 // Create the progress bar
279 progressbar = manage(new class Gtk::ProgressBar());
280 progressbar->set_size_request(image_w,24);
282 // Create the current task label
283 tasklabel = manage(new class Gtk::Label());
284 tasklabel->set_size_request(image_w,24);
285 tasklabel->set_use_underline(false);
287 // Create the Gtk::Fixed container and put all of the widgets into it
288 Gtk::Fixed *fixed1 = manage(new class Gtk::Fixed());
289 fixed1->put(*Logo, 0, 0);
290 fixed1->put(*CopyrightLabel, 0, image_h-25);
291 fixed1->put(*CloseButton, image_w-24, 0);
292 fixed1->put(*VersionLabel, 0, image_h-90);
293 fixed1->put(*progressbar, 0, image_h+24);
294 fixed1->put(*tasklabel, 0, image_h);
296 // Set up the parameters for this pop-up window
297 set_title("Synfig Studio "VERSION);
299 property_window_position().set_value(Gtk::WIN_POS_CENTER);
300 set_resizable(false);
303 // show everything off
305 CopyrightLabel->show();
308 VersionLabel->show();
311 // Connect relevant signals
312 CloseButton->signal_clicked().connect(sigc::mem_fun(*this, &Splash::close));
314 cb=new SplashProgress(*this);
325 if(can_self_destruct)
330 Splash::set_can_self_destruct(bool x)
339 synfig::ProgressCallback *
340 Splash::get_callback()