1 /* === S Y N F I G ========================================================= */
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 ** === N O T E S ===========================================================
23 ** ========================================================================= */
25 /* === H E A D E R S ======================================================= */
37 #include <ETL/stringf>
39 #include <gtkmm/image.h>
40 #include <gdkmm/pixbufloader.h>
41 #include <gtkmm/button.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/fixed.h>
45 #include <synfig/general.h>
54 using namespace studio;
56 /* === M A C R O S ========================================================= */
59 #define VERSION "unknown"
60 #define PACKAGE "synfigstudio"
66 # define IMAGE_DIR "share\\pixmaps"
71 # define IMAGE_DIR "/usr/local/share/pixmaps"
75 # define IMAGE_EXT "png"
78 /* === G L O B A L S ======================================================= */
79 extern const guint gtk_major_version;
80 extern const guint gtk_minor_version;
81 extern const guint gtk_micro_version;
82 extern const guint gtk_binary_age;
83 extern const guint gtk_interface_age;
85 /* === P R O C E D U R E S ================================================= */
87 class studio::AboutProgress : public synfig::ProgressCallback
93 AboutProgress(About &about):about(about) { }
95 virtual bool task(const std::string &task)
99 about.tasklabel->set_label(task);
100 about.tasklabel->show();
107 while(studio::App::events_pending())studio::App::iteration(false);
111 virtual bool error(const std::string &task)
115 about.tasklabel->set_label(_("ERROR:")+task);
116 about.tasklabel->show();
123 while(studio::App::events_pending())studio::App::iteration(false);
127 virtual bool warning(const std::string &task)
131 about.tasklabel->set_label(_("WARNING:")+task);
132 about.tasklabel->show();
139 while(studio::App::events_pending())studio::App::iteration(false);
143 virtual bool amount_complete(int current, int total)
145 if(about.progressbar)
147 about.progressbar->set_fraction((float)current/(float)total);
148 about.progressbar->show();
151 cerr<<current<<'/'<<total<<endl;
153 while(studio::App::events_pending())studio::App::iteration(false);
156 }; // END of class AboutProgress
158 /* === M E T H O D S ======================================================= */
161 Gtk::Window(Gtk::WINDOW_POPUP),
162 can_self_destruct(true)
164 int image_w=300,image_h=350;
166 std::string imagepath;
168 imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
172 char* synfig_root=getenv("SYNFIG_ROOT");
174 imagepath=synfig_root;
175 imagepath+=ETL_DIRECTORY_SEPARATOR;
177 imagepath+="share/pixmaps";
179 imagepath+=ETL_DIRECTORY_SEPARATOR;
183 Gtk::Image *Logo = manage(new class Gtk::Image());
184 Logo->set(imagepath+"about_dialog."IMAGE_EXT);
185 Logo->set_size_request(image_w,image_h);
186 Logo->set_alignment(0.5,0.5);
187 Logo->set_padding(0,0);
189 // Create the Copyright Label
190 Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SYNFIG_COPYRIGHT));
191 CopyrightLabel->set_size_request(image_w,24);
192 CopyrightLabel->set_alignment(0.5,0.5);
193 CopyrightLabel->set_padding(0,0);
194 CopyrightLabel->set_justify(Gtk::JUSTIFY_CENTER);
195 CopyrightLabel->set_line_wrap(false);
196 CopyrightLabel->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("black"));
198 /* Scale the text to fit */
202 Glib::RefPtr<Pango::Layout> l = CopyrightLabel->get_layout();
203 Pango::FontDescription fd = Pango::FontDescription("Sans, 11");
204 l->set_font_description(fd);
205 l->set_justify(Pango::ALIGN_CENTER);
206 fd.set_size(int(size*Pango::SCALE));
207 l->set_font_description(fd);
208 l->get_pixel_size(width,height);
209 while( width >= image_w-6 ){
211 fd.set_size((int)(size*Pango::SCALE));
212 l->set_font_description(fd);
213 l->get_pixel_size(width,height);
215 CopyrightLabel->modify_font(fd);
217 // Create the Version information label
218 Gtk::Label *VersionLabel = manage(new class Gtk::Label("Version"));
219 VersionLabel->set_size_request(image_w,80);
220 VersionLabel->set_flags(Gtk::CAN_FOCUS);
221 VersionLabel->set_alignment(0.5,0.5);
222 VersionLabel->set_padding(0,0);
223 VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
224 VersionLabel->set_line_wrap(false);
225 VersionLabel->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("black"));
227 // Set the version label to contain the correct information
229 ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
230 ver+="Using Synfig ";
231 ver+=synfig::get_version();
233 ver+=strprintf(" and GNU G++ %d.%d.%d",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
236 ver+=strprintf("\nGtk+ %d.%d.%d",gtk_major_version,gtk_minor_version,gtk_micro_version);
239 ver+="\nDEBUG BUILD";
241 VersionLabel->set_text(ver);
243 /* Scale the text to fit */
247 l = VersionLabel->get_layout();
248 fd = Pango::FontDescription("Sans, 11");
249 l->set_font_description(fd);
250 l->set_justify(Pango::ALIGN_CENTER);
251 fd.set_size(int(size*Pango::SCALE));
252 l->set_font_description(fd);
253 l->get_pixel_size(width,height);
254 while( width >= image_w-6 ){
256 fd.set_size((int)(size*Pango::SCALE));
257 l->set_font_description(fd);
258 l->get_pixel_size(width,height);
260 VersionLabel->modify_font(fd);
262 // Create the image that will be used on the close button
263 Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
264 image2->set_alignment(0.5,0.5);
265 image2->set_padding(0,0);
267 // Create the close button, and attach the image to it
268 CloseButton = manage(new class Gtk::Button());
269 CloseButton->set_size_request(24,24);
270 CloseButton->set_flags(Gtk::CAN_FOCUS);
271 _tooltips.set_tip(*CloseButton, "Close", "");
272 CloseButton->set_relief(Gtk::RELIEF_NONE);
273 CloseButton->add(*image2);
275 // Create the progress bar
276 progressbar = manage(new class Gtk::ProgressBar());
277 progressbar->set_size_request(image_w,24);
279 // Create the current task label
280 tasklabel = manage(new class Gtk::Label());
281 tasklabel->set_size_request(image_w,24);
282 tasklabel->set_use_underline(false);
284 // Create the Gtk::Fixed container and put all of the widgets into it
285 Gtk::Fixed *fixed1 = manage(new class Gtk::Fixed());
286 fixed1->put(*Logo, 0, 0);
287 fixed1->put(*CopyrightLabel, 0, image_h-25);
288 fixed1->put(*CloseButton, image_w-24, 0);
289 fixed1->put(*VersionLabel, 0, image_h-90);
290 fixed1->put(*progressbar, 0, image_h+24);
291 fixed1->put(*tasklabel, 0, image_h);
293 // Set up the parameters for this pop-up window
294 set_title("Synfig Studio "VERSION);
296 property_window_position().set_value(Gtk::WIN_POS_CENTER);
297 set_resizable(false);
300 // show everything off
302 CopyrightLabel->show();
305 VersionLabel->show();
308 // Connect relevant signals
309 CloseButton->signal_clicked().connect(sigc::mem_fun(*this, &About::close));
311 cb=new AboutProgress(*this);
322 if(can_self_destruct)
327 About::set_can_self_destruct(bool x)
336 synfig::ProgressCallback *
337 About::get_callback()