1
2 /*
3 * Ump - Unnamed Math Program
4 * Copyright (c) 2004-2005 by Mattias Hultgren <mattias_hultgren@tele2.se>
5 *
6 * See main.cpp
7 */
8
9 #include <stdio.h>
10 #include <gtk/gtk.h>
11 #include "ump_aboutwin.h"
12 #include "main.h"
13
14 GtkWidget *aboutwin = 0;
15
16
17
aboutwin_show(GtkWindow * parent)18 void aboutwin_show(GtkWindow *parent)
19 {
20 GtkWidget *notebook,*vbox,*label1,*label2;
21 char str[200];
22
23 if(aboutwin == 0)
24 {
25 aboutwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
26
27 gtk_window_set_title( GTK_WINDOW(aboutwin), _("About Ump - Unnamed Math Program") );
28 g_signal_connect_swapped( GTK_OBJECT(aboutwin), "delete-event", G_CALLBACK(aboutwin_close),
29 NULL );
30
31 vbox = gtk_vbox_new( FALSE, 0 );
32
33
34 snprintf( str, 200, "%s %s", PRG_NAME,PRG_VERSION );
35 label1 = gtk_label_new(str);
36 gtk_misc_set_alignment( GTK_MISC(label1), 0.0f, 0.5f );
37 gtk_box_pack_start( GTK_BOX(vbox), label1, TRUE, TRUE, 2 );
38
39 notebook = gtk_notebook_new();
40
41 /* Page 'About' starts */
42 snprintf( str, 200, "\n%s - %s\n\nCopyright (c) %s Mattias Hultgren\n",PRG_NAME,
43 _("a math program"), PRG_DATE );
44
45 label1 = gtk_label_new( str );
46 gtk_misc_set_alignment(GTK_MISC(label1), 0.5f, 0.5f);
47 gtk_misc_set_padding(GTK_MISC(label1), 2, 2);
48
49 label2 = gtk_label_new( _("About") );
50 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),label1,label2);
51 /* Page 'About' ends */
52
53 /* Page 'Written by' starts */
54 label1 = gtk_label_new( "Mattias Hultgren" );
55 gtk_misc_set_alignment(GTK_MISC(label1), 0.0f, 0.0f);
56 gtk_misc_set_padding(GTK_MISC(label1), 2, 2);
57
58 label2 = gtk_label_new( _("Written by") );
59 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),label1,label2);
60 /* Page 'Written by' ends */
61
62 /* Page 'Translated by' starts */
63 {
64 const char *trans;
65 if((trans = translation.get_key_c_str("ABOUT_TRANSLATERS")) == 0)
66 trans = "(Untranslated)";
67 label1 = gtk_label_new( trans );
68 }
69 gtk_misc_set_alignment(GTK_MISC(label1), 0.0f, 0.0f);
70 gtk_misc_set_padding(GTK_MISC(label1), 2, 2);
71
72 label2 = gtk_label_new( _("Translated by") );
73 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),label1,label2);
74 /* Page 'Translated by' ends */
75
76
77 /* Page 'License' starts */
78 {
79 const char *trans;
80 if((trans = translation.get_key_c_str("ABOUT_LICENSE_DESC")) == 0)
81 trans = "This program is distibuted under the terms of GNU GPL v2.\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software Foundation,\nInc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
82 label1 = gtk_label_new( trans );
83 }
84 gtk_misc_set_alignment(GTK_MISC(label1), 0.0f, 0.0f);
85 gtk_misc_set_padding(GTK_MISC(label1), 2, 2);
86
87 label2 = gtk_label_new( _("License") );
88 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),label1,label2);
89 /* Page 'License' ends */
90
91
92 gtk_box_pack_start(GTK_BOX(vbox),notebook,TRUE,TRUE,2);
93 gtk_container_set_border_width(GTK_CONTAINER(notebook), 3);
94
95 {
96 GtkWidget *box,*button;
97 box = gtk_hbox_new(FALSE,2);
98
99 {
100 GtkWidget *tmpimg,*tmpbox,*tmplabel;
101 tmpimg = gtk_image_new_from_stock( GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON );
102
103 tmplabel = gtk_label_new_with_mnemonic(button_close);
104
105 tmpbox = gtk_hbox_new(FALSE,0);
106 gtk_box_pack_start(GTK_BOX(tmpbox),tmpimg,FALSE,FALSE,2);
107 gtk_box_pack_start(GTK_BOX(tmpbox),tmplabel,FALSE,FALSE,2);
108 button = gtk_button_new();
109 gtk_container_add(GTK_CONTAINER(button),tmpbox);
110 }
111 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(aboutwin_close), NULL);
112
113 gtk_box_pack_end(GTK_BOX(box),button,FALSE,FALSE,2);
114
115 gtk_box_pack_start(GTK_BOX(vbox),box,FALSE,FALSE,2);
116 }
117
118 gtk_container_add(GTK_CONTAINER(aboutwin),vbox);
119
120 gtk_window_set_modal(GTK_WINDOW(aboutwin), TRUE);
121 gtk_window_set_transient_for(GTK_WINDOW(aboutwin), parent);
122
123 gtk_widget_show_all(aboutwin);
124 }
125 else
126 gtk_window_present(GTK_WINDOW(aboutwin));
127 }
128
129
aboutwin_close(void)130 void aboutwin_close(void)
131 {
132 gtk_widget_destroy(aboutwin);
133 aboutwin = 0;
134 }
135