Version handling in main window title, About window (now with tabs, including the license) and in PP3 files

This commit is contained in:
Hombre
2011-02-08 01:25:40 +01:00
parent 84945ee826
commit aac9c13b9f
16 changed files with 856 additions and 610 deletions

View File

@@ -18,6 +18,7 @@
*/
#include <splash.h>
#include <multilangmgr.h>
#include <glib/gstdio.h>
#include <safegtk.h>
extern Glib::ustring argv0;
@@ -44,26 +45,131 @@ void SplashImage::on_realize () {
bool SplashImage::on_expose_event (GdkEventExpose* event) {
Glib::RefPtr<Gdk::Window> window = get_window();
Glib::RefPtr<Gdk::Window> window = get_window();
pixbuf->render_to_drawable (window, gc_, 0, 0, 0, 0, pixbuf->get_width(), pixbuf->get_height(), Gdk::RGB_DITHER_NONE, 0, 0);
Cairo::FontOptions cfo;
cfo.set_antialias (Cairo::ANTIALIAS_SUBPIXEL);
Glib::RefPtr<Pango::Context> context = get_pango_context () ;
Glib::RefPtr<Pango::Context> context = get_pango_context ();
context->set_cairo_font_options (cfo);
Pango::FontDescription fontd = context->get_font_description ();
fontd.set_weight (Pango::WEIGHT_SEMIBOLD);
fontd.set_size (12*Pango::SCALE);
fontd.set_weight (Pango::WEIGHT_LIGHT);
fontd.set_absolute_size (12*Pango::SCALE);
context->set_font_description (fontd);
Gdk::Color *textColor = new Gdk::Color();
textColor->set_rgb(0, 0, 0);
gc_->set_foreground(*textColor);
version = create_pango_layout (versionString);
int w, h;
version = create_pango_layout (versionString);
version->get_pixel_size (w, h);
window->draw_layout(gc_, pixbuf->get_width() - w - 28, 44-h, version);
window->draw_layout(gc_, pixbuf->get_width() - w - 4, pixbuf->get_height() - h - 4, version);
return true;
}
Splash::Splash () {
set_title (M("GENERAL_ABOUT"));
set_border_width (4);
Gtk::Notebook* nb = Gtk::manage (new Gtk::Notebook ());
get_vbox()->pack_start (*nb);
// Tab 1: the image
splashImage = new SplashImage ();
nb->append_page (*splashImage, M("ABOUT_TAB_SPLASH"));
splashImage->show ();
// Tab 2: the informations about the current version
std::string buildFileName = Glib::build_filename (argv0, "AboutThisBuild.txt");
if ( Glib::file_test(buildFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = g_fopen (buildFileName.c_str(), "rt");
if (f != NULL) {
char* buffer = new char[1024];
std::ostringstream ostr;
while (fgets (buffer, 1024, f))
ostr << buffer;
delete [] buffer;
fclose (f);
Glib::RefPtr<Gtk::TextBuffer> textBuffer = Gtk::TextBuffer::create();
textBuffer->set_text((Glib::ustring)(ostr.str()));
Gtk::ScrolledWindow *buildSW = Gtk::manage (new Gtk::ScrolledWindow());
Gtk::TextView *buildTV = Gtk::manage (new Gtk::TextView (textBuffer));
buildTV->set_editable(false);
buildSW->add(*buildTV);
nb->append_page (*buildSW, M("ABOUT_TAB_BUILD"));
}
}
// Tab 3: the credits
#if defined _WIN32 || defined __APPLE__
std::string creditsFileName = Glib::build_filename (argv0, "AUTHORS.txt");
#else
std::string creditsFileName = Glib::build_filename (argv0, "share/doc/AUTHORS.txt");
#endif
if ( Glib::file_test(creditsFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = g_fopen (creditsFileName.c_str(), "rt");
if (f != NULL) {
char* buffer = new char[1024];
std::ostringstream ostr;
while (fgets (buffer, 1024, f))
ostr << buffer;
delete [] buffer;
fclose (f);
Glib::RefPtr<Gtk::TextBuffer> textBuffer = Gtk::TextBuffer::create();
textBuffer->set_text((Glib::ustring)(ostr.str()));
Gtk::ScrolledWindow *creditsSW = Gtk::manage (new Gtk::ScrolledWindow());
Gtk::TextView *creditsTV = Gtk::manage (new Gtk::TextView (textBuffer));
creditsTV->set_editable(false);
creditsSW->add(*creditsTV);
nb->append_page (*creditsSW, M("ABOUT_TAB_CREDITS"));
}
}
// Tab 4: the license
#if defined _WIN32 || defined __APPLE__
std::string licenseFileName = Glib::build_filename (argv0, "LICENSE.txt");
#else
std::string licenseFileName = Glib::build_filename (argv0, "share/doc/LICENSE.txt");
#endif
if ( Glib::file_test(licenseFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = g_fopen (licenseFileName.c_str(), "rt");
if (f != NULL) {
char* buffer = new char[1024];
std::ostringstream ostr;
while (fgets (buffer, 1024, f))
ostr << buffer;
delete [] buffer;
fclose (f);
Glib::RefPtr<Gtk::TextBuffer> textBuffer = Gtk::TextBuffer::create();
textBuffer->set_text((Glib::ustring)(ostr.str()));
Gtk::ScrolledWindow *licenseSW = Gtk::manage (new Gtk::ScrolledWindow());
Gtk::TextView *creditsTV = Gtk::manage (new Gtk::TextView (textBuffer));
creditsTV->set_editable(false);
licenseSW->add(*creditsTV);
nb->append_page (*licenseSW, M("ABOUT_TAB_LICENSE"));
}
}
set_position (Gtk::WIN_POS_CENTER);
//add_events(Gdk::BUTTON_RELEASE_MASK);
set_resizable (true);
nb->set_current_page (0);
show_all_children ();
set_modal (true);
set_keep_above (true);
}
Splash::Splash (int maxtime) {
set_title (M("GENERAL_ABOUT"));
@@ -71,7 +177,6 @@ Splash::Splash (int maxtime) {
splashImage = new SplashImage ();
// add (*splashImage);
get_vbox()->pack_start (*splashImage);
set_has_separator (false);
splashImage->show ();
if (maxtime>0)