1 /**********************************************************************
2  *
3  *   FreeDoko a Doppelkopf-Game
4  *
5  *   Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders
6  *
7  *   This program is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU General Public License as
9  *   published by the Free Software Foundation; either version 2 of
10  *   the License, or (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *   You can find this license in the file 'gpl.txt'.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  *   MA  02111-1307  USA
22  *
23  *  Contact:
24  *    Diether Knof dknof@posteo.de
25  *
26  *********************************************************************/
27 
28 #include "constants.h"
29 
30 #ifdef USE_UI_GTKMM
31 
32 #include "about.h"
33 
34 #include "ui.h"
35 #include "help.h"
36 
37 #include <gtkmm/image.h>
38 #include <gtkmm/scrolledwindow.h>
39 #include <gtkmm/textview.h>
40 
41 namespace UI_GTKMM_NS {
42 
43 /** constructor
44  **
45  ** @param    parent   the parent object
46  **/
About(Base * const parent)47 About::About(Base* const parent) :
48   Base(parent),
49   StickyDialog("FreeDoko – " + _("Window::about"), false)
50 {
51   this->ui->add_window(*this);
52   this->signal_realize().connect(sigc::mem_fun(*this, &About::init));
53 } // About::About(Base* parent)
54 
55 /** destructor
56  **/
57 About::~About()
58   = default;
59 
60 /** create all subelements
61  **/
62 void
init()63 About::init()
64 {
65   this->set_icon(this->ui->icon);
66 
67   this->set_skip_taskbar_hint();
68 
69   this->text = Gtk::manage(new Gtk::TextView());
70   this->text->get_buffer()->set_text(_("Version: %s",
71                                        static_cast<string>(*::version))
72                                      + "\n\n"
73                                        + _("About::about"));
74 
75   add_close_button(*this);
76 
77   this->set_default_size((this->ui->logo->get_width() * 3) / 2,
78                          (this->ui->logo->get_height() * 5) / 2);
79 #ifdef POSTPONED
80   this->get_window()->set_decorations(Gdk::DECOR_BORDER
81                                       | Gdk::DECOR_RESIZEH
82                                       | Gdk::DECOR_TITLE
83                                       | Gdk::DECOR_MENU);
84 #endif
85 
86   { // the image
87     auto image = Gtk::manage(new Gtk::Image(parent->ui->logo));
88     this->get_content_area()->pack_start(*image, Gtk::PACK_SHRINK);
89   } // the image
90   { // the text
91     auto text_window = Gtk::manage(new Gtk::ScrolledWindow());
92     text_window->add(*this->text);
93     text_window->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
94     this->text->set_editable(false);
95     this->text->set_wrap_mode(Gtk::WRAP_WORD);
96     this->text->set_cursor_visible(false);
97 
98     this->get_content_area()->pack_start(*text_window);
99   } // the text
100   { // the 'visit homepage' button
101     auto homepage_button = Gtk::manage(new Gtk::Button(_("visit homepage") + " "));
102     homepage_button->set_image_from_icon_name("applications-internet");
103     homepage_button->set_always_show_image();
104     homepage_button->signal_clicked().connect(sigc::mem_fun(*this->ui->help,
105                                                             &Help::show_homepage));
106     homepage_button->set_halign(Gtk::ALIGN_CENTER);
107 
108     this->get_content_area()->pack_end(*homepage_button, Gtk::PACK_SHRINK);
109   } // the 'visit homepage' button
110 
111   this->show_all_children();
112 } // void About::init()
113 
114 } // namespace UI_GTKMM_NS
115 
116 #endif // #ifdef USE_UI_GTKMM
117