1 /*! ========================================================================
4 ** $Id: about.cpp,v 1.2 2005/01/13 21:11:16 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
33 #include <ETL/stringf>
35 #include <gtkmm/image.h>
36 #include <gdkmm/pixbufloader.h>
37 #include <gtkmm/button.h>
38 #include <gtkmm/label.h>
39 #include <gtkmm/fixed.h>
41 #include <synfig/general.h>
50 using namespace studio;
52 /* === M A C R O S ========================================================= */
55 #define VERSION "unknown"
56 #define PACKAGE "synfigstudio"
62 # define IMAGE_DIR "share\\pixmaps"
67 # define IMAGE_DIR "/usr/local/share/pixmaps"
71 # define IMAGE_EXT "png"
74 /* === G L O B A L S ======================================================= */
75 extern const guint gtk_major_version;
76 extern const guint gtk_minor_version;
77 extern const guint gtk_micro_version;
78 extern const guint gtk_binary_age;
79 extern const guint gtk_interface_age;
81 /* === P R O C E D U R E S ================================================= */
83 class studio::AboutProgress : public synfig::ProgressCallback
89 AboutProgress(About &about):about(about) { }
91 virtual bool task(const std::string &task)
95 about.tasklabel->set_label(task);
96 about.tasklabel->show();
103 while(studio::App::events_pending())studio::App::iteration(false);
107 virtual bool error(const std::string &task)
111 about.tasklabel->set_label(_("ERROR:")+task);
112 about.tasklabel->show();
119 while(studio::App::events_pending())studio::App::iteration(false);
123 virtual bool warning(const std::string &task)
127 about.tasklabel->set_label(_("WARNING:")+task);
128 about.tasklabel->show();
135 while(studio::App::events_pending())studio::App::iteration(false);
139 virtual bool amount_complete(int current, int total)
141 if(about.progressbar)
143 about.progressbar->set_fraction((float)current/(float)total);
144 about.progressbar->show();
147 cerr<<current<<'/'<<total<<endl;
149 while(studio::App::events_pending())studio::App::iteration(false);
152 }; // END of class AboutProgress
154 /* === M E T H O D S ======================================================= */
157 Gtk::Window(Gtk::WINDOW_POPUP),
158 can_self_destruct(true)
160 int image_w=300,image_h=350;
162 std::string imagepath;
164 imagepath=App::get_base_path()+ETL_DIRECTORY_SEPERATOR+IMAGE_DIR;
168 imagepath+=ETL_DIRECTORY_SEPERATOR;
172 Gtk::Image *Logo = manage(new class Gtk::Image());
173 Logo->set(imagepath+"about_dialog."IMAGE_EXT);
174 Logo->set_size_request(image_w,image_h);
175 Logo->set_alignment(0.5,0.5);
176 Logo->set_padding(0,0);
178 // Create the Copyright Label
179 Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SYNFIG_COPYRIGHT));
180 CopyrightLabel->set_size_request(image_w,24);
181 CopyrightLabel->set_alignment(0.5,0.5);
182 CopyrightLabel->set_padding(0,0);
183 CopyrightLabel->set_justify(Gtk::JUSTIFY_CENTER);
184 CopyrightLabel->set_line_wrap(false);
186 // Create the Version information label
187 Gtk::Label *VersionLabel = manage(new class Gtk::Label("Version"));
188 VersionLabel->set_size_request(image_w,80);
189 VersionLabel->set_flags(Gtk::CAN_FOCUS);
190 VersionLabel->set_alignment(0.5,0.5);
191 VersionLabel->set_padding(0,0);
192 VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
193 VersionLabel->set_line_wrap(false);
195 // Set the version label to contain the correct information
197 ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
198 ver+="Using SYNFIG ";
199 ver+=synfig::get_version();
201 ver+=strprintf(" and GNU G++ %d.%d.%d",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
204 ver+=strprintf("\nGtk+ %d.%d.%d",gtk_major_version,gtk_minor_version,gtk_micro_version);
207 ver+="\nDEBUG BUILD";
209 VersionLabel->set_text(ver);
211 // Create the image that will be used on the close button
212 Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
213 image2->set_alignment(0.5,0.5);
214 image2->set_padding(0,0);
216 // Create the close button, and attach the image to it
217 CloseButton = manage(new class Gtk::Button());
218 CloseButton->set_size_request(24,24);
219 CloseButton->set_flags(Gtk::CAN_FOCUS);
220 _tooltips.set_tip(*CloseButton, "Close", "");
221 CloseButton->set_relief(Gtk::RELIEF_NONE);
222 CloseButton->add(*image2);
224 // Create the progress bar
225 progressbar = manage(new class Gtk::ProgressBar());
226 progressbar->set_size_request(image_w,24);
228 // Create the current task label
229 tasklabel = manage(new class Gtk::Label());
230 tasklabel->set_size_request(image_w,24);
231 tasklabel->set_use_underline(false);
233 // Create the Gtk::Fixed container and put all of the widgets into it
234 Gtk::Fixed *fixed1 = manage(new class Gtk::Fixed());
235 fixed1->put(*Logo, 0, 0);
236 fixed1->put(*CopyrightLabel, 0, image_h-25);
237 fixed1->put(*CloseButton, image_w-24, 0);
238 fixed1->put(*VersionLabel, 0, image_h-90);
239 fixed1->put(*progressbar, 0, image_h+24);
240 fixed1->put(*tasklabel, 0, image_h);
242 // Set up the parameters for this pop-up window
243 set_title("Synfig Studio "VERSION);
245 property_window_position().set_value(Gtk::WIN_POS_CENTER);
246 set_resizable(false);
249 // show everything off
251 CopyrightLabel->show();
254 VersionLabel->show();
257 // Connect relevant signals
258 CloseButton->signal_clicked().connect(sigc::mem_fun(*this, &About::close));
260 cb=new AboutProgress(*this);
271 if(can_self_destruct)
276 About::set_can_self_destruct(bool x)
285 synfig::ProgressCallback *
286 About::get_callback()