2 Copyright (C) 2003 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <sys/types.h>
29 #include <gtk--/label.h>
30 #include <gtk--/text.h>
31 #include <gtk--/scrolledwindow.h>
32 #include <gtk--/notebook.h>
34 #include <ardour/ardour.h>
35 #include <ardour/version.h>
40 #include <gtkmmext/gtk_ui.h>
41 #include <gtkmmext/doi.h>
44 #include "rgb_macros.h"
45 #include "ardour_ui.h"
52 using namespace ARDOUR;
54 #ifdef WITH_PAYMENT_OPTIONS
57 static const gchar * paypal_xpm[] = {
92 "1'111111111111111111111111111111111111111111111111111111111%_#",
93 "%333333333333333333333333333333333333333333333333333333333333.",
94 "%444444444444444444444444444444444444444444444444444444444444:",
95 "_4333333!!!!!!33333333333333333333!!!!!!33333333333!%%%%1334[:",
96 "_444444@+}}}}+>)44444444444444444,:}}}}}.^(44444444@}..+.44($:",
97 "_433333^:&&&&)_}_33///33333333333&+)&&&'~+./3///333^.(;#]33($:",
98 "_444444>_444444'}_>...#%####~,]##..444444=+#]...>1;#_4;.144($:",
99 "_43333!+'4,>#=4(:+_%%%]}}#~#}_+~~:]44_>&44#}_%%%_+>:14=}@33($:",
100 "_44444*+$4&--)4(+%44444%-)4=--'4{+14,}-~44##44444&}}*4)+444($:",
101 "_433331:;4):_;4*}_]:.$4*-~4{}>44#-=4@.#{4;+>_:.&4,++;4_#333($:",
102 "_44444_#444444=.-.%&*,41-#4(:@4'-:(44444(_-:^&*,4*}#44.%444($:",
103 "_43333:%4;@@'~+-%44*&44]-.;;'4,:-#44*@&%:-];4{'(4)-%4{+&333($:",
104 "_4444{}@4*}}+>#:;4^-#4;.>+,444_+:^4(:}+.]}=4'-+(4_-&4&+{444($:",
105 "_4333'+(41:*=3'.44*)(4=+)+*44@}%+@4=}&=/@}{4{1{44:+,4^.3333($:",
106 "_4444~>,,]#444*})(;**,':*}'4;._@}=,%:444(+~(;{&,*}.,,>~4444($:",
107 "_4333>}}}}^3333~}::}}}}>].;4^+=~}}}}]3333'}+:}}}}}}}}}'3333($:",
108 "_4444$@@@@(44444$))@*@*^}$4=}14=@@@@{44444=))&*@@@@@@@;4444($:",
109 "_433333333333333333333=+:%%.>/33333333333333333333333333333($:",
110 "_4444444444444444444441....>=444444444444444444444444444444($:",
111 "_4333333333333333333333333333333333333333333333333333333333($:",
112 "_4444444444444444444444444444444444444444444444444444444444($:",
113 "_4333333333333333333333333333333333333333333333333333333333($:",
114 "_4444442222444222442444242444244222242444242222244222244444($:",
115 "_4333332333232333233232332232233233332233233323332333333333($:",
116 "_4444442222442222244424442424244222442424244424444222444444($:",
117 "_4333332333332333233323332333233233332332233323333333233333($:",
118 "_4444442444442444244424442444244222242444244424442222444444($:",
119 "_433333333333333333333333333333333333333333333333333333333344:",
120 "#4([[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=&:",
121 ".=&<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<1|",
122 "::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"};
126 stoppit (GdkEventButton* ev, Gtk::Notebook* notebook)
128 gtk_signal_emit_stop_by_name (GTK_OBJECT(notebook->gtkobj()),
129 "button_release_event");
133 static const char* author_names[] = {
134 N_("Marcus Andersson"),
143 N_("Gerard van Dongen"),
144 N_("Thomas Charbonnel"),
145 N_("Nick Mainsbridge"),
147 N_("Sampo Savolainen"),
155 static const char* translators[] = {
156 N_("French:\n\tAlain Fréhel <alain.frehel@free.fr>"),
157 N_("German:\n\tKarsten Petersen <kapet@kapet.de>"),
158 N_("Italian:\n\tFilippo Pappalardo <filippo@email.it>"),
159 N_("Portuguese:\n\tRui Nuno Capela <rncbc@rncbc.org>"),
160 N_("Brazilian Portuguese:\n\tAlexander da Franca Fernandes <alexander@nautae.eti.br>\
161 \n\tChris Ross <chris@tebibyte.org>"),
162 N_("Spanish:\n\t Alex Krohn <alexkrohn@fastmail.fm>"),
163 N_("Russian:\n\t Igor Blinov <pitstop@nm.ru>"),
168 About::About (ARDOUR_UI * ui)
169 : Window (GTK_WINDOW_TOPLEVEL), _ui (ui)
170 #ifdef WITH_PAYMENT_OPTIONS
171 , paypal_pixmap (paypal_xpm)
174 using namespace Notebook_Helpers;
180 Gtk::Label* small_label = manage (new Label (_(
181 "Copyright (C) 1999-2005 Paul Davis\n"
182 "Ardour comes with ABSOLUTELY NO WARRANTY\n"
183 "This is free software, and you are welcome to redistribute it\n"
184 "under certain conditions; see the file COPYING for details.\n")));
186 Gtk::Label* version_label =
188 (compose(_("Ardour: %1\n(built with ardour/gtk %2.%3.%4 libardour: %5.%6.%7)"),
190 gtk_ardour_major_version,
191 gtk_ardour_minor_version,
192 gtk_ardour_micro_version,
193 libardour_major_version,
194 libardour_minor_version,
195 libardour_micro_version)));
197 Notebook* notebook = manage (new Notebook);
199 ScrolledWindow* author_scroller = manage (new ScrolledWindow);
200 Text* author_text = manage (new Text);
202 author_text->set_editable (false);
203 author_text->set_name (X_("AboutText"));
206 "Primary author:\n\t\
208 Major developers:\n\t\
213 for (int32_t n = 0; author_names[n] != 0; ++n) {
214 str += _(author_names[n]);
218 author_text->insert (str);
220 author_scroller->add (*author_text);
221 author_scroller->set_usize (-1, 75);
222 author_scroller->set_policy (GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
224 ScrolledWindow* translator_scroller = manage (new ScrolledWindow);
225 Text* translator_text = manage (new Text);
227 translator_text->set_editable (false);
228 translator_text->set_name (X_("AboutText"));
232 for (int32_t n = 0; translators[n] != 0; ++n) {
233 str += _(translators[n]);
237 translator_text->insert (str);
239 translator_scroller->add (*translator_text);
240 translator_scroller->set_usize (-1, 75);
241 translator_scroller->set_policy (GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
243 Label* author_tab_label = manage (new Label (_("Authors")));
244 Label* translator_tab_label = manage (new Label (_("Translators")));
246 notebook->pages().push_back (TabElem (*author_scroller, *author_tab_label));
247 notebook->pages().push_back (TabElem (*translator_scroller, *translator_tab_label));
249 notebook->set_name ("AboutNoteBook");
250 notebook->button_release_event.connect_after (bind (slot (stoppit), notebook));
256 set_name ("AboutWindow");
257 set_title ("ardour: about");
258 set_wmclass ("ardour_about", "Ardour");
260 vbox.set_border_width (5);
261 vbox.set_spacing (5);
263 if (load_logo_size ()) {
264 logo_area.set_usize (logo_width, logo_height);
267 vbox.pack_start (logo_area, false, false);
268 logo_area.expose_event.connect (slot (*this, &About::logo_area_expose));
270 expose_event.connect (slot (*this, &About::logo_area_expose));
273 small_label->set_name ("AboutWindowSmallLabel");
274 version_label->set_name("AboutWindowSmallLabel");
276 first_label.set_name ("AboutWindowLabel");
277 third_label.set_name ("AboutWindowPDLabel");
278 second_label.set_name ("AboutWindowLabel");
280 subvbox.pack_start (*small_label, false, false);
281 subvbox.pack_start (*version_label, false, false);
282 subvbox.pack_start (*notebook, true, true);
284 #ifdef WITH_PAYMENT_OPTIONS
285 paypal_button.add (paypal_pixmap);
287 HBox *payment_box = manage (new HBox);
288 payment_box->pack_start (paypal_button, true, false);
290 subvbox.pack_start (*payment_box, false, false);
293 delete_event.connect (bind (slot (just_hide_it), static_cast<Gtk::Window*> (this)));
296 add_events (GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);
298 set_position (GTK_WIN_POS_CENTER);
303 /* wait for the first logo expose event to complete so that
304 we know we are fully drawn.
308 gtk_main_iteration ();
317 About::show_sub (bool yn)
320 vbox.pack_start (subvbox, true, true);
323 vbox.remove (subvbox);
329 About::button_release_event_impl (GdkEventButton* ev)
333 if (!_ui->shown ()) {
334 /* show it immediately */
342 About::realize_impl ()
344 Window::realize_impl ();
345 get_window().set_decorations (GdkWMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
346 // get_window().set_decorations (GdkWMDecoration (0));
350 About::load_logo_size ()
354 string path = find_data_file ("splash.ppm");
356 if (path.length() == 0) {
360 if ((fp = fopen (path.c_str(), "rb")) == 0) {
361 error << compose (_("cannot open splash image file \"%1\""), path) << endmsg;
365 fgets (buf, sizeof (buf), fp);
366 if (strcmp (buf, "P6\n") != 0) {
371 fgets (buf, sizeof (buf), fp);
372 fgets (buf, sizeof (buf), fp);
373 sscanf (buf, "%d %d", &logo_width, &logo_height);
379 About::load_logo (Gtk::Window& window)
389 path = find_data_file ("splash.ppm");
391 if (path.length() == 0) {
395 if ((fp = fopen (path.c_str(), "rb")) == 0) {
399 fgets (buf, sizeof (buf), fp);
400 if (strcmp (buf, "P6\n") != 0) {
405 fgets (buf, sizeof (buf), fp);
406 fgets (buf, sizeof (buf), fp);
407 sscanf (buf, "%d %d", &logo_width, &logo_height);
409 fgets (buf, sizeof (buf), fp);
410 if (strcmp (buf, "255\n") != 0) {
415 Gtk::Preview preview (GTK_PREVIEW_COLOR);
417 preview.size (logo_width, logo_height);
418 pixelrow = new guchar[logo_width * 3];
420 for (i = 0; i < logo_height; i++) {
421 count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp);
422 if (count != (logo_width * 3))
428 preview.draw_row (pixelrow, 0, i, logo_width);
433 logo_pixmap = gdk_pixmap_new (GTK_WIDGET(window.gtkobj())->window, logo_width, logo_height,
434 gtk_preview_get_visual()->depth);
435 gc = gdk_gc_new (logo_pixmap);
436 gtk_preview_put (preview.gtkobj(), logo_pixmap, gc, 0, 0, 0, 0, logo_width, logo_height);
446 About::logo_area_expose (GdkEventExpose* ev)
453 logo_area.get_window().draw_pixmap (logo_area.get_style()->get_black_gc(),
454 Gdk_Pixmap (logo_pixmap),
456 ((logo_area.width() - logo_width) / 2),
457 ((logo_area.height() - logo_height) / 2),
458 logo_width, logo_height);
465 #ifdef WITH_PAYMENT_OPTIONS
467 About::goto_paypal ()
469 char buf[PATH_MAX+16];
471 char *docfile = "foo";
478 if ((grandchild = fork()) == 0) {
484 snprintf (buf, sizeof(buf), "openurl(%s)", docfile);
488 execvp ("mozilla", argv);
489 error << "could not start mozilla" << endmsg;
493 waitpid (grandchild, &status, 0);