Release 0.61.08
[synfig.git] / synfig-studio / tags / stable / src / gtkmm / about.cpp
index 819ed63..656a871 100644 (file)
@@ -1,18 +1,23 @@
-/*! ========================================================================
-** Sinfg
-** Template File
-** $Id: about.cpp,v 1.2 2005/01/13 21:11:16 darco Exp $
+/* === S Y N F I G ========================================================= */
+/*!    \file about.cpp
+**     \brief writeme
 **
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+**     $Id$
 **
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
 **
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
 **
 ** === N O T E S ===========================================================
 **
@@ -38,7 +43,7 @@
 #include <gtkmm/label.h>
 #include <gtkmm/fixed.h>
 
-#include <sinfg/general.h>
+#include <synfig/general.h>
 
 #include "about.h"
 #include "app.h"
@@ -53,7 +58,7 @@ using namespace studio;
 
 #ifndef VERSION
 #define VERSION        "unknown"
-#define PACKAGE        "sinfgstudio"
+#define PACKAGE        "synfigstudio"
 #endif
 
 #ifdef WIN32
@@ -80,14 +85,14 @@ extern      const guint gtk_interface_age;
 
 /* === P R O C E D U R E S ================================================= */
 
-class studio::AboutProgress : public sinfg::ProgressCallback
+class studio::AboutProgress : public synfig::ProgressCallback
 {
        About &about;
-       
+
 public:
 
        AboutProgress(About &about):about(about) { }
-       
+
        virtual bool task(const std::string &task)
        {
                if(about.tasklabel)
@@ -154,34 +159,61 @@ public:
 /* === M E T H O D S ======================================================= */
 
 About::About():
-       Gtk::Window(Gtk::WINDOW_POPUP),
+       Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP),
        can_self_destruct(true)
 {
        int image_w=300,image_h=350;
 
        std::string imagepath;
 #ifdef WIN32
-       imagepath=App::get_base_path()+ETL_DIRECTORY_SEPERATOR+IMAGE_DIR;
+       imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
 #else
        imagepath=IMAGE_DIR;
 #endif
-       imagepath+=ETL_DIRECTORY_SEPERATOR;
-       
-       
+       char* synfig_root=getenv("SYNFIG_ROOT");
+       if(synfig_root) {
+               imagepath=synfig_root;
+               imagepath+=ETL_DIRECTORY_SEPARATOR;
+
+               imagepath+="share/pixmaps";
+       }
+       imagepath+=ETL_DIRECTORY_SEPARATOR;
+
+
        // Create the Logo
        Gtk::Image *Logo = manage(new class Gtk::Image());
        Logo->set(imagepath+"about_dialog."IMAGE_EXT);
        Logo->set_size_request(image_w,image_h);
        Logo->set_alignment(0.5,0.5);
        Logo->set_padding(0,0);
-       
+
        // Create the Copyright Label
-       Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SINFG_COPYRIGHT));
+       Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SYNFIG_COPYRIGHT));
        CopyrightLabel->set_size_request(image_w,24);
        CopyrightLabel->set_alignment(0.5,0.5);
        CopyrightLabel->set_padding(0,0);
        CopyrightLabel->set_justify(Gtk::JUSTIFY_CENTER);
        CopyrightLabel->set_line_wrap(false);
+       CopyrightLabel->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("black"));
+
+       /* Scale the text to fit */
+       int width = 0;
+       int height = 0;
+       float size=11;
+       Glib::RefPtr<Pango::Layout> l = CopyrightLabel->get_layout();
+       Pango::FontDescription fd = Pango::FontDescription("Sans, 11");
+       l->set_font_description(fd);
+       l->set_justify(Pango::ALIGN_CENTER);
+       fd.set_size(int(size*Pango::SCALE));
+       l->set_font_description(fd);
+       l->get_pixel_size(width,height);
+       while( width >= image_w-6 ){
+               size-=0.5;
+               fd.set_size((int)(size*Pango::SCALE));
+               l->set_font_description(fd);
+               l->get_pixel_size(width,height);
+       }
+       CopyrightLabel->modify_font(fd);
 
        // Create the Version information label
        Gtk::Label *VersionLabel = manage(new class Gtk::Label("Version"));
@@ -191,12 +223,13 @@ About::About():
        VersionLabel->set_padding(0,0);
        VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
        VersionLabel->set_line_wrap(false);
-       
+       VersionLabel->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("black"));
+
        // Set the version label to contain the correct information
        string ver;
        ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
-       ver+="Using SINFG ";
-       ver+=sinfg::get_version();
+       ver+="Using Synfig ";
+       ver+=synfig::get_version();
        #ifdef __GNUC__
                ver+=strprintf(" and GNU G++ %d.%d.%d",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
        #endif
@@ -208,11 +241,30 @@ About::About():
        #endif
        VersionLabel->set_text(ver);
 
+       /* Scale the text to fit */
+       width = 0;
+       height = 0;
+       size=11;
+       l = VersionLabel->get_layout();
+       fd = Pango::FontDescription("Sans, 11");
+       l->set_font_description(fd);
+       l->set_justify(Pango::ALIGN_CENTER);
+       fd.set_size(int(size*Pango::SCALE));
+       l->set_font_description(fd);
+       l->get_pixel_size(width,height);
+       while( width >= image_w-6 ){
+               size-=0.5;
+               fd.set_size((int)(size*Pango::SCALE));
+               l->set_font_description(fd);
+               l->get_pixel_size(width,height);
+       }
+       VersionLabel->modify_font(fd);
+
        // Create the image that will be used on the close button
        Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
        image2->set_alignment(0.5,0.5);
        image2->set_padding(0,0);
-       
+
        // Create the close button, and attach the image to it
        CloseButton = manage(new class Gtk::Button());
        CloseButton->set_size_request(24,24);
@@ -229,7 +281,7 @@ About::About():
        tasklabel = manage(new class Gtk::Label());
        tasklabel->set_size_request(image_w,24);
        tasklabel->set_use_underline(false);
-       
+
        // Create the Gtk::Fixed container and put all of the widgets into it
        Gtk::Fixed *fixed1 = manage(new class Gtk::Fixed());
        fixed1->put(*Logo, 0, 0);
@@ -240,7 +292,7 @@ About::About():
        fixed1->put(*tasklabel, 0, image_h);
 
        // Set up the parameters for this pop-up window
-       set_title("Sinfg Studio "VERSION);
+       set_title("Synfig Studio "VERSION);
        set_modal(false);
        property_window_position().set_value(Gtk::WIN_POS_CENTER);
        set_resizable(false);
@@ -279,10 +331,10 @@ About::set_can_self_destruct(bool x)
        if(x==true)
                CloseButton->show();
        else
-               CloseButton->hide();            
+               CloseButton->hide();
 }
 
-sinfg::ProgressCallback *
+synfig::ProgressCallback *
 About::get_callback()
 {
        return cb;