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_SEPERATOR+IMAGE_DIR;
172 char* synfig_root=getenv("SYNFIG_ROOT");
174 imagepath=synfig_root;
175 imagepath+=ETL_DIRECTORY_SEPERATOR;
177 imagepath+="share/pixmaps";
179 imagepath+=ETL_DIRECTORY_SEPERATOR;
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);
197 // Create the Version information label
198 Gtk::Label *VersionLabel = manage(new class Gtk::Label("Version"));
199 VersionLabel->set_size_request(image_w,80);
200 VersionLabel->set_flags(Gtk::CAN_FOCUS);
201 VersionLabel->set_alignment(0.5,0.5);
202 VersionLabel->set_padding(0,0);
203 VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
204 VersionLabel->set_line_wrap(false);
206 // Set the version label to contain the correct information
208 ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
209 ver+="Using Synfig ";
210 ver+=synfig::get_version();
212 ver+=strprintf(" and GNU G++ %d.%d.%d",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
215 ver+=strprintf("\nGtk+ %d.%d.%d",gtk_major_version,gtk_minor_version,gtk_micro_version);
218 ver+="\nDEBUG BUILD";
220 VersionLabel->set_text(ver);
222 // Create the image that will be used on the close button
223 Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
224 image2->set_alignment(0.5,0.5);
225 image2->set_padding(0,0);
227 // Create the close button, and attach the image to it
228 CloseButton = manage(new class Gtk::Button());
229 CloseButton->set_size_request(24,24);
230 CloseButton->set_flags(Gtk::CAN_FOCUS);
231 _tooltips.set_tip(*CloseButton, "Close", "");
232 CloseButton->set_relief(Gtk::RELIEF_NONE);
233 CloseButton->add(*image2);
235 // Create the progress bar
236 progressbar = manage(new class Gtk::ProgressBar());
237 progressbar->set_size_request(image_w,24);
239 // Create the current task label
240 tasklabel = manage(new class Gtk::Label());
241 tasklabel->set_size_request(image_w,24);
242 tasklabel->set_use_underline(false);
244 // Create the Gtk::Fixed container and put all of the widgets into it
245 Gtk::Fixed *fixed1 = manage(new class Gtk::Fixed());
246 fixed1->put(*Logo, 0, 0);
247 fixed1->put(*CopyrightLabel, 0, image_h-25);
248 fixed1->put(*CloseButton, image_w-24, 0);
249 fixed1->put(*VersionLabel, 0, image_h-90);
250 fixed1->put(*progressbar, 0, image_h+24);
251 fixed1->put(*tasklabel, 0, image_h);
253 // Set up the parameters for this pop-up window
254 set_title("Synfig Studio "VERSION);
256 property_window_position().set_value(Gtk::WIN_POS_CENTER);
257 set_resizable(false);
260 // show everything off
262 CopyrightLabel->show();
265 VersionLabel->show();
268 // Connect relevant signals
269 CloseButton->signal_clicked().connect(sigc::mem_fun(*this, &About::close));
271 cb=new AboutProgress(*this);
282 if(can_self_destruct)
287 About::set_can_self_destruct(bool x)
296 synfig::ProgressCallback *
297 About::get_callback()