1 /*! ========================================================================
4 ** $Id: about.cpp,v 1.2 2005/01/13 21:11:16 darco Exp $
6 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** General Public License for more details.
18 ** === N O T E S ===========================================================
20 ** ========================================================================= */
22 /* === H E A D E R S ======================================================= */
34 #include <ETL/stringf>
36 #include <gtkmm/image.h>
37 #include <gdkmm/pixbufloader.h>
38 #include <gtkmm/button.h>
39 #include <gtkmm/label.h>
40 #include <gtkmm/fixed.h>
42 #include <synfig/general.h>
51 using namespace studio;
53 /* === M A C R O S ========================================================= */
56 #define VERSION "unknown"
57 #define PACKAGE "synfigstudio"
63 # define IMAGE_DIR "share\\pixmaps"
68 # define IMAGE_DIR "/usr/local/share/pixmaps"
72 # define IMAGE_EXT "png"
75 /* === G L O B A L S ======================================================= */
76 extern const guint gtk_major_version;
77 extern const guint gtk_minor_version;
78 extern const guint gtk_micro_version;
79 extern const guint gtk_binary_age;
80 extern const guint gtk_interface_age;
82 /* === P R O C E D U R E S ================================================= */
84 class studio::AboutProgress : public synfig::ProgressCallback
90 AboutProgress(About &about):about(about) { }
92 virtual bool task(const std::string &task)
96 about.tasklabel->set_label(task);
97 about.tasklabel->show();
104 while(studio::App::events_pending())studio::App::iteration(false);
108 virtual bool error(const std::string &task)
112 about.tasklabel->set_label(_("ERROR:")+task);
113 about.tasklabel->show();
120 while(studio::App::events_pending())studio::App::iteration(false);
124 virtual bool warning(const std::string &task)
128 about.tasklabel->set_label(_("WARNING:")+task);
129 about.tasklabel->show();
136 while(studio::App::events_pending())studio::App::iteration(false);
140 virtual bool amount_complete(int current, int total)
142 if(about.progressbar)
144 about.progressbar->set_fraction((float)current/(float)total);
145 about.progressbar->show();
148 cerr<<current<<'/'<<total<<endl;
150 while(studio::App::events_pending())studio::App::iteration(false);
153 }; // END of class AboutProgress
155 /* === M E T H O D S ======================================================= */
158 Gtk::Window(Gtk::WINDOW_POPUP),
159 can_self_destruct(true)
161 int image_w=300,image_h=350;
163 std::string imagepath;
165 imagepath=App::get_base_path()+ETL_DIRECTORY_SEPERATOR+IMAGE_DIR;
169 imagepath+=ETL_DIRECTORY_SEPERATOR;
173 Gtk::Image *Logo = manage(new class Gtk::Image());
174 Logo->set(imagepath+"about_dialog."IMAGE_EXT);
175 Logo->set_size_request(image_w,image_h);
176 Logo->set_alignment(0.5,0.5);
177 Logo->set_padding(0,0);
179 // Create the Copyright Label
180 Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SYNFIG_COPYRIGHT));
181 CopyrightLabel->set_size_request(image_w,24);
182 CopyrightLabel->set_alignment(0.5,0.5);
183 CopyrightLabel->set_padding(0,0);
184 CopyrightLabel->set_justify(Gtk::JUSTIFY_CENTER);
185 CopyrightLabel->set_line_wrap(false);
187 // Create the Version information label
188 Gtk::Label *VersionLabel = manage(new class Gtk::Label("Version"));
189 VersionLabel->set_size_request(image_w,80);
190 VersionLabel->set_flags(Gtk::CAN_FOCUS);
191 VersionLabel->set_alignment(0.5,0.5);
192 VersionLabel->set_padding(0,0);
193 VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
194 VersionLabel->set_line_wrap(false);
196 // Set the version label to contain the correct information
198 ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
199 ver+="Using SYNFIG ";
200 ver+=synfig::get_version();
202 ver+=strprintf(" and GNU G++ %d.%d.%d",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
205 ver+=strprintf("\nGtk+ %d.%d.%d",gtk_major_version,gtk_minor_version,gtk_micro_version);
208 ver+="\nDEBUG BUILD";
210 VersionLabel->set_text(ver);
212 // Create the image that will be used on the close button
213 Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
214 image2->set_alignment(0.5,0.5);
215 image2->set_padding(0,0);
217 // Create the close button, and attach the image to it
218 CloseButton = manage(new class Gtk::Button());
219 CloseButton->set_size_request(24,24);
220 CloseButton->set_flags(Gtk::CAN_FOCUS);
221 _tooltips.set_tip(*CloseButton, "Close", "");
222 CloseButton->set_relief(Gtk::RELIEF_NONE);
223 CloseButton->add(*image2);
225 // Create the progress bar
226 progressbar = manage(new class Gtk::ProgressBar());
227 progressbar->set_size_request(image_w,24);
229 // Create the current task label
230 tasklabel = manage(new class Gtk::Label());
231 tasklabel->set_size_request(image_w,24);
232 tasklabel->set_use_underline(false);
234 // Create the Gtk::Fixed container and put all of the widgets into it
235 Gtk::Fixed *fixed1 = manage(new class Gtk::Fixed());
236 fixed1->put(*Logo, 0, 0);
237 fixed1->put(*CopyrightLabel, 0, image_h-25);
238 fixed1->put(*CloseButton, image_w-24, 0);
239 fixed1->put(*VersionLabel, 0, image_h-90);
240 fixed1->put(*progressbar, 0, image_h+24);
241 fixed1->put(*tasklabel, 0, image_h);
243 // Set up the parameters for this pop-up window
244 set_title("Synfig Studio "VERSION);
246 property_window_position().set_value(Gtk::WIN_POS_CENTER);
247 set_resizable(false);
250 // show everything off
252 CopyrightLabel->show();
255 VersionLabel->show();
258 // Connect relevant signals
259 CloseButton->signal_clicked().connect(sigc::mem_fun(*this, &About::close));
261 cb=new AboutProgress(*this);
272 if(can_self_destruct)
277 About::set_can_self_destruct(bool x)
286 synfig::ProgressCallback *
287 About::get_callback()