Parent Directory | Revision Log
Date adjustment
1 | /* |
2 | * Copyright (C) 2009 Till Harbaum <till@harbaum.org>. |
3 | * |
4 | * This file is part of GPXView. |
5 | * |
6 | * GPXView 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 3 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * GPXView 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 GPXView. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | #include "gpxview.h" |
21 | |
22 | #ifndef FREMANTLE |
23 | #define LINK_COLOR "blue" |
24 | #else |
25 | #define LINK_COLOR "lightblue" |
26 | #endif |
27 | |
28 | #ifdef ENABLE_BROWSER_INTERFACE |
29 | static gboolean on_link_clicked(GtkWidget *widget, GdkEventButton *event, |
30 | gpointer user_data) { |
31 | |
32 | const char *str = |
33 | gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)))); |
34 | browser_url((appdata_t*)user_data, (char*)str); |
35 | return TRUE; |
36 | } |
37 | #endif |
38 | |
39 | static GtkWidget *link_new(appdata_t *appdata, const char *url) { |
40 | #ifdef ENABLE_BROWSER_INTERFACE |
41 | if(appdata) { |
42 | GtkWidget *label = gtk_label_new(""); |
43 | char *str = g_strdup_printf("<span color=\"" LINK_COLOR |
44 | "\"><u>%s</u></span>", url); |
45 | gtk_label_set_markup(GTK_LABEL(label), str); |
46 | g_free(str); |
47 | |
48 | GtkWidget *eventbox = gtk_event_box_new(); |
49 | gtk_container_add(GTK_CONTAINER(eventbox), label); |
50 | |
51 | g_signal_connect(eventbox, "button-press-event", |
52 | G_CALLBACK(on_link_clicked), appdata); |
53 | return eventbox; |
54 | } |
55 | #endif |
56 | GtkWidget *label = gtk_label_new(""); |
57 | char *str = g_strdup_printf("<span color=\"" LINK_COLOR "\">%s</span>", url); |
58 | gtk_label_set_markup(GTK_LABEL(label), str); |
59 | g_free(str); |
60 | return label; |
61 | } |
62 | |
63 | #ifdef ENABLE_BROWSER_INTERFACE |
64 | void on_paypal_button_clicked(GtkButton *button, appdata_t *appdata) { |
65 | // gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT); |
66 | browser_url(appdata, |
67 | "https://www.paypal.com/cgi-bin/webscr" |
68 | "?cmd=_s-xclick&hosted_button_id=7400558"); |
69 | } |
70 | #endif |
71 | |
72 | GtkWidget *label_big(char *str) { |
73 | GtkWidget *label = gtk_label_new(""); |
74 | char *markup = |
75 | g_markup_printf_escaped("<span size='x-large'>%s</span>", str); |
76 | gtk_label_set_markup(GTK_LABEL(label), markup); |
77 | g_free(markup); |
78 | return label; |
79 | } |
80 | |
81 | GtkWidget *label_xbig(char *str) { |
82 | GtkWidget *label = gtk_label_new(""); |
83 | char *markup = |
84 | g_markup_printf_escaped("<span size='xx-large'>%s</span>", str); |
85 | gtk_label_set_markup(GTK_LABEL(label), markup); |
86 | g_free(markup); |
87 | return label; |
88 | } |
89 | |
90 | GtkWidget *license_page_new(void) { |
91 | char *name = g_strdup(ICONPATH "COPYING"); |
92 | |
93 | GtkWidget *label = text_wrap(""); |
94 | |
95 | /* load license into buffer */ |
96 | FILE *file = fopen(name, "r"); |
97 | g_free(name); |
98 | |
99 | if(!file) { |
100 | /* loading from installation path failed, try to load */ |
101 | /* from local directory (for debugging) */ |
102 | name = g_strdup("./data/COPYING"); |
103 | file = fopen(name, "r"); |
104 | g_free(name); |
105 | } |
106 | |
107 | if(file) { |
108 | fseek(file, 0l, SEEK_END); |
109 | int flen = ftell(file); |
110 | fseek(file, 0l, SEEK_SET); |
111 | |
112 | char *buffer = g_malloc(flen+1); |
113 | if(fread(buffer, 1, flen, file) != flen) |
114 | text_set(label, _("Load error")); |
115 | else { |
116 | buffer[flen]=0; |
117 | text_set(label, buffer); |
118 | } |
119 | |
120 | fclose(file); |
121 | g_free(buffer); |
122 | } else |
123 | text_set(label, _("Load error")); |
124 | |
125 | #ifndef USE_PANNABLE_AREA |
126 | GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
127 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
128 | GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
129 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
130 | label); |
131 | gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(scrolled_window), |
132 | GTK_SHADOW_IN); |
133 | return scrolled_window; |
134 | #else |
135 | GtkWidget *pannable_area = hildon_pannable_area_new(); |
136 | hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area), |
137 | label); |
138 | return pannable_area; |
139 | #endif |
140 | } |
141 | |
142 | GtkWidget *copyright_page_new(appdata_t *appdata) { |
143 | GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
144 | |
145 | /* ------------------------ */ |
146 | GtkWidget *ivbox = gtk_vbox_new(FALSE, 0); |
147 | |
148 | GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
149 | GtkWidget *ihbox = gtk_hbox_new(FALSE, 20); |
150 | gtk_box_pack_start(GTK_BOX(ihbox), icon_get_widget(ICON_MISC, 5), |
151 | FALSE, FALSE, 0); |
152 | gtk_box_pack_start(GTK_BOX(ihbox), label_xbig("GPXView"), |
153 | FALSE, FALSE, 0); |
154 | |
155 | gtk_box_pack_start(GTK_BOX(hbox), ihbox, TRUE, FALSE, 0); |
156 | gtk_box_pack_start_defaults(GTK_BOX(ivbox), hbox); |
157 | |
158 | gtk_box_pack_start_defaults(GTK_BOX(ivbox), |
159 | label_big(_("Geocaching with Maemo"))); |
160 | |
161 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
162 | |
163 | /* ------------------------ */ |
164 | ivbox = gtk_vbox_new(FALSE, 0); |
165 | |
166 | gtk_box_pack_start(GTK_BOX(ivbox), |
167 | gtk_label_new("Version " VERSION), FALSE, FALSE, 0); |
168 | gtk_box_pack_start(GTK_BOX(ivbox), |
169 | gtk_label_new(__DATE__ " " __TIME__), FALSE, FALSE, 0); |
170 | |
171 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
172 | |
173 | /* ------------------------ */ |
174 | ivbox = gtk_vbox_new(FALSE, 0); |
175 | |
176 | gtk_box_pack_start(GTK_BOX(ivbox), |
177 | gtk_label_new(_("Copyright 2008-2010")), FALSE, FALSE, 0); |
178 | |
179 | gtk_box_pack_start(GTK_BOX(ivbox), |
180 | link_new(appdata, "http://gpxview.garage.maemo.org"), |
181 | FALSE, FALSE, 0); |
182 | |
183 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
184 | |
185 | return vbox; |
186 | } |
187 | |
188 | /* a label that is left aligned */ |
189 | GtkWidget *left_label(char *str) { |
190 | GtkWidget *widget = gtk_label_new(str); |
191 | gtk_misc_set_alignment(GTK_MISC(widget), 0.0f, 0.5f); |
192 | return widget; |
193 | } |
194 | |
195 | static void author_add(GtkWidget *box, char *str) { |
196 | gtk_box_pack_start(GTK_BOX(box), left_label(str), FALSE, FALSE, 0); |
197 | } |
198 | |
199 | GtkWidget *authors_page_new(void) { |
200 | GtkWidget *ivbox, *vbox = gtk_vbox_new(FALSE, 16); |
201 | |
202 | /* -------------------------------------------- */ |
203 | ivbox = gtk_vbox_new(FALSE, 0); |
204 | author_add(ivbox, _("Main developer:")); |
205 | author_add(ivbox, "Till Harbaum <till@harbaum.org>"); |
206 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
207 | |
208 | /* -------------------------------------------- */ |
209 | ivbox = gtk_vbox_new(FALSE, 0); |
210 | author_add(ivbox, _("Original map widget by:")); |
211 | author_add(ivbox, "John Stowers <john.stowers@gmail.com>"); |
212 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
213 | |
214 | /* -------------------------------------------- */ |
215 | ivbox = gtk_vbox_new(FALSE, 0); |
216 | author_add(ivbox, _("GCVote service provided by:")); |
217 | author_add(ivbox, "Guido Wegener <guido.wegener@gmx.de>"); |
218 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
219 | |
220 | /* -------------------------------------------- */ |
221 | ivbox = gtk_vbox_new(FALSE, 0); |
222 | author_add(ivbox, _("Additional translations by:")); |
223 | author_add(ivbox, "Marko Vertainen <marko.vertainen@iki.fi>"); |
224 | author_add(ivbox, "Sergei Ivanov <isn@vu.spb.ru>"); |
225 | author_add(ivbox, "Vitaly Petrov <vit.petrov@vu.spb.ru>"); |
226 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
227 | |
228 | /* -------------------------------------------- */ |
229 | ivbox = gtk_vbox_new(FALSE, 0); |
230 | author_add(ivbox, _("Testers:")); |
231 | author_add(ivbox, "Uwe Koch <asys3@yahoo.com>"); |
232 | author_add(ivbox, "Tanja Harbaum <tanja@harbaum.org>"); |
233 | gtk_box_pack_start(GTK_BOX(vbox), ivbox, TRUE, FALSE, 0); |
234 | |
235 | #ifndef USE_PANNABLE_AREA |
236 | GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
237 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
238 | GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
239 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
240 | vbox); |
241 | gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(scrolled_window), |
242 | GTK_SHADOW_IN); |
243 | return scrolled_window; |
244 | #else |
245 | GtkWidget *pannable_area = hildon_pannable_area_new(); |
246 | hildon_pannable_area_add_with_viewport(HILDON_PANNABLE_AREA(pannable_area), |
247 | vbox); |
248 | return pannable_area; |
249 | #endif |
250 | } |
251 | |
252 | GtkWidget *donate_page_new(appdata_t *appdata) { |
253 | GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
254 | |
255 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
256 | text_wrap(_("If you like GPXView and want to support its future development " |
257 | "please consider donating to the developer. You can either " |
258 | "donate via paypal to"))); |
259 | |
260 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
261 | link_new(NULL, "till@harbaum.org")); |
262 | |
263 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
264 | text_wrap(_("or you can just click the button below which will open " |
265 | "the appropriate web page in your browser."))); |
266 | |
267 | GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
268 | GtkWidget *button = gtk_button_new(); |
269 | gtk_button_set_image(GTK_BUTTON(button), |
270 | icon_get_widget(ICON_MISC, 3)); |
271 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
272 | g_signal_connect(button, "clicked", |
273 | G_CALLBACK(on_paypal_button_clicked), appdata); |
274 | gtk_box_pack_start(GTK_BOX(ihbox), button, TRUE, FALSE, 0); |
275 | gtk_box_pack_start_defaults(GTK_BOX(vbox), ihbox); |
276 | |
277 | return vbox; |
278 | } |
279 | |
280 | GtkWidget *bugs_page_new(appdata_t *appdata) { |
281 | GtkWidget *vbox = gtk_vbox_new(FALSE, 0); |
282 | |
283 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
284 | text_wrap(_("Please report bugs or feature requests via the GPXView " |
285 | "bug tracker. This bug tracker can directly be reached via " |
286 | "the following link:"))); |
287 | |
288 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
289 | link_new(appdata, "https://garage.maemo.org/tracker/?group_id=973")); |
290 | |
291 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
292 | text_wrap(_("You might also be interested in joining the mailing lists " |
293 | "or the forum:"))); |
294 | |
295 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
296 | link_new(appdata, "http://garage.maemo.org/projects/gpxview/")); |
297 | |
298 | gtk_box_pack_start_defaults(GTK_BOX(vbox), |
299 | text_wrap(_("Thank you for contributing!"))); |
300 | |
301 | return vbox; |
302 | } |
303 | |
304 | void about_box(appdata_t *appdata) { |
305 | GtkWidget *dialog = gtk_dialog_new_with_buttons(_("About GPXView"), |
306 | GTK_WINDOW(appdata->window), GTK_DIALOG_MODAL, |
307 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); |
308 | |
309 | #ifdef USE_MAEMO |
310 | gtk_window_set_default_size(GTK_WINDOW(dialog), 640, 480); |
311 | #else |
312 | gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 200); |
313 | #endif |
314 | |
315 | GtkWidget *notebook = notebook_new(); |
316 | |
317 | notebook_append_page(notebook, copyright_page_new(appdata), _("Copyright")); |
318 | notebook_append_page(notebook, license_page_new(), _("License")); |
319 | notebook_append_page(notebook, authors_page_new(), _("Authors")); |
320 | notebook_append_page(notebook, donate_page_new(appdata), _("Donate")); |
321 | notebook_append_page(notebook, bugs_page_new(appdata), _("Bugs")); |
322 | |
323 | gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(dialog))->vbox), |
324 | notebook); |
325 | |
326 | gtk_widget_show_all(dialog); |
327 | |
328 | gtk_dialog_run(GTK_DIALOG(dialog)); |
329 | gtk_widget_destroy(dialog); |
330 | } |