5f286aef8b7be528b0b2e2eb45be9728b10a5941
[goodguy/history.git] / cinelerra-5.1 / cinelerra / aboutprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "aboutprefs.h"
23 #include "bcsignals.h"
24 #include "file.h"
25 #include "language.h"
26 #include "mwindow.h"
27 #include "theme.h"
28 #include "vframe.h"
29 #include "versioninfo.h"
30
31 #ifndef COMPILEDATE
32 #define COMPILEDATE "built: " __DATE__ " " __TIME__
33 #endif
34 const char *AboutPrefs::build_timestamp = COMPILEDATE;
35
36 AboutPrefs::AboutPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
37  : PreferencesDialog(mwindow, pwindow)
38 {
39 }
40
41 AboutPrefs::~AboutPrefs()
42 {
43         about.remove_all_objects();
44 }
45
46 void AboutPrefs::create_objects()
47 {
48         int x, y;
49
50
51         BC_Resources *resources = BC_WindowBase::get_resources();
52
53 //      add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x,
54 //              mwindow->theme->preferencestitle_y,
55 //              _("About"),
56 //              LARGEFONT,
57 //              resources->text_default));
58
59         x = mwindow->theme->preferencesoptions_x;
60         y = mwindow->theme->preferencesoptions_y +
61                 get_text_height(LARGEFONT);
62
63         set_font(LARGEFONT);
64         set_color(resources->text_default);
65         draw_text(x, y, PROGRAM_NAME " " CINELERRA_VERSION);
66         y += 2*get_text_height(MEDIUMFONT);
67
68         set_font(MEDIUMFONT);
69         draw_text(x, y, COPYRIGHTTEXT1
70 #if defined(COPYRIGHTTEXT2)
71         COPYRIGHTTEXT2
72 #endif
73         );
74         y += get_text_height(MEDIUMFONT) * 3;
75
76
77         const char *cfg_path = File::get_cindat_path();
78         char msg_path[BCTEXTLEN];
79         FILE *fp = 0;
80         if( BC_Resources::language[0] ) {
81                 snprintf(msg_path, sizeof(msg_path), "%s/msg/%s",
82                         cfg_path, BC_Resources::language);
83                 fp = fopen(msg_path, "r");
84         }
85         if( !fp ) {
86                 snprintf(msg_path, sizeof(msg_path), "%s/msg/txt",
87                         cfg_path);
88                 fp = fopen(msg_path, "r");
89         }
90         if( fp ) {
91                 set_font(LARGEFONT);
92                 draw_text(x, y, _("About:"));
93                 y += get_text_height(LARGEFONT);
94                 char msg[BCTEXTLEN];
95                 while( fgets(msg, sizeof(msg), fp) ) {
96                         int len = strlen(msg);
97                         if( len > 0 && msg[len-1] == '\n' ) msg[len-1] = 0;
98                         about.append(new BC_ListBoxItem(msg));
99                 }
100                 BC_ListBox *listbox;
101                 add_subwindow(listbox = new BC_ListBox(x, y, 450, 280,
102                         LISTBOX_TEXT, &about, 0, 0, 1));
103                 y += listbox->get_h() + get_text_height(LARGEFONT) + 10;
104         }
105         else
106                 y += 300 + get_text_height(LARGEFONT) + 10;
107
108         set_font(LARGEFONT);
109         set_color(resources->text_default);
110         draw_text(x, y, _("License:"));
111         y += get_text_height(LARGEFONT);
112         set_font(MEDIUMFONT);
113
114         char license3[BCTEXTLEN];
115         sprintf(license3, _(
116 "This program is free software; you can redistribute it and/or modify it under the terms\n"
117 "of the GNU General Public License as published by the Free Software Foundation; either version\n"
118 "2 of the License, or (at your option) any later version.\n"
119 "  This software uses libraries from the FFmpeg project under the LGPLv2.1.\n"
120 "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
121 "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n"
122 "PURPOSE.  See the GNU General Public License for more details.\n"));
123         draw_text(x, y, license3);
124         y += get_text_height(MEDIUMFONT, license3);
125
126         draw_text(x, y, build_timestamp);
127 #if defined(REPOMAINTXT)
128         y += get_text_height(MEDIUMFONT, build_timestamp);
129         draw_text(x, y, REPOMAINTXT);
130 #endif
131
132         x = get_w() - mwindow->theme->about_bg->get_w() - 10;
133         y = mwindow->theme->preferencesoptions_y;
134         BC_Pixmap *temp_pixmap = new BC_Pixmap(this,
135                 mwindow->theme->about_bg,
136                 PIXMAP_ALPHA);
137         draw_pixmap(temp_pixmap,
138                 x,
139                 y);
140
141         delete temp_pixmap;
142
143
144         x += mwindow->theme->about_bg->get_w() + 10;
145         y += get_text_height(LARGEFONT) * 2;
146
147
148         flash();
149         flush();
150 }
151
152