-
Notifications
You must be signed in to change notification settings - Fork 3
/
about.cpp
166 lines (123 loc) · 5.77 KB
/
about.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "gcin.h"
#include "gcin-version.h"
static GtkWidget *about_window;
/* Our usual callback function */
static void callback_close( GtkWidget *widget, gpointer data )
{
gtk_widget_destroy(about_window);
about_window = NULL;
}
void align_with_ui_window(GtkWidget *win);
int html_browser(char *fname);
#define FURL_WIN32 "http://hyperrate.com/dir.php?eid=215"
#define FURL_LINUX "http://hyperrate.com/dir.php?eid=67"
#define LOG_URL "http://www.csie.nctu.edu.tw/~cp76/gcin/download/Changelog.html"
#define ET26_URL "http://hyperrate.com/thread.php?tid=22661"
#define PUNC_URL "http://hyperrate.com/thread.php?tid=19444#19444"
#define ADD_PHRASE_URL "http://hyperrate.com/thread.php?tid=23991#23991"
#define SPLIT_PHRASE_URL "http://hyperrate.com/thread.php?tid=26361"
static void callback_url( GtkWidget *widget, gpointer data)
{
#if WIN32
ShellExecuteA(NULL, "open", (char *)data, NULL, NULL, SW_SHOWNORMAL);
#else
html_browser(data);
#endif
}
void sys_icon_fname(char *iconame, char fname[]);
void create_about_window()
{
if (about_window) {
gtk_window_present(GTK_WINDOW(about_window));
return;
}
GtkWidget *vbox = gtk_vbox_new(FALSE,3);
GtkWidget *hbox;
/* Create a new about_window */
about_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(about_window), GTK_WIN_POS_CENTER);
gtk_window_set_has_resize_grip(GTK_WINDOW(about_window), FALSE);
gtk_window_set_title (GTK_WINDOW (about_window), _(_L("關於 gcin")));
g_signal_connect (G_OBJECT (about_window), "destroy",
G_CALLBACK (callback_close), NULL);
g_signal_connect (G_OBJECT (about_window), "delete_event",
G_CALLBACK (callback_close), NULL);
/* Sets the border width of the about_window. */
gtk_container_set_border_width (GTK_CONTAINER (about_window), 10);
GtkWidget *label_version;
GtkWidget *image;
/* Create box for image and label */
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
GtkWidget *separator = gtk_hseparator_new ();
gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 3);
// this doesn't work on win32
#if GTK_CHECK_VERSION(2,18,9) && UNIX && 1
char tmp[1024];
sprintf(tmp, "<a href='"FURL_LINUX"'>%s</a>\n"
"<a href='"FURL_WIN32"'>%s</a>\n"
"<a href='"LOG_URL"'>%s</a>\n"
"<a href='"ET26_URL"'>%s</a>\n"
"<a href='"PUNC_URL"'>%s</a>\n"
"<a href='"ADD_PHRASE_URL"'>%s</a>\n"
"<a href='"SPLIT_PHRASE_URL"'>%s</a>\n",
_(_L("前往 gcin 討論區")),
_(_L("gcin也有 Windows版")),
_(_L("gcin改變記錄")),
_(_L("推薦使用26鍵的注音鍵盤")),
_(_L("使用詞音輸入標點符號")),
_(_L("如何新增詞")),
_(_L("如何手動斷詞"))
);
GtkWidget *label = gtk_label_new(tmp);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
#else
GtkWidget *button_forum = gtk_button_new_with_label(_(_L("討論區")));
gtk_box_pack_start(GTK_BOX(vbox), button_forum, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_forum), "clicked",
G_CALLBACK (callback_url), FURL_WIN32);
GtkWidget *button_linux = gtk_button_new_with_label(_(_L("gcin也有 Linux版")));
gtk_box_pack_start(GTK_BOX(vbox), button_linux, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_linux), "clicked",
G_CALLBACK (callback_url), FURL_LINUX);
GtkWidget *button_changelog = gtk_button_new_with_label(_(_L("gcin改變記錄")));
gtk_box_pack_start(GTK_BOX(vbox), button_changelog, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_changelog), "clicked",
G_CALLBACK (callback_url), LOG_URL);
GtkWidget *button_et26 = gtk_button_new_with_label(_(_L("推薦使用26鍵的注音鍵盤")));
gtk_box_pack_start(GTK_BOX(vbox), button_et26, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_et26), "clicked",
G_CALLBACK (callback_url), ET26_URL);
GtkWidget *button_punc = gtk_button_new_with_label(_(_L("使用詞音輸入標點符號")));
gtk_box_pack_start(GTK_BOX(vbox), button_punc, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_punc), "clicked",
G_CALLBACK (callback_url), PUNC_URL);
GtkWidget *button_add_phrase = gtk_button_new_with_label(_(_L("如何新增詞")));
gtk_box_pack_start(GTK_BOX(vbox), button_add_phrase, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_add_phrase), "clicked",
G_CALLBACK (callback_url), ADD_PHRASE_URL);
GtkWidget *button_split_phrase = gtk_button_new_with_label(_(_L("如何手動斷詞")));
gtk_box_pack_start(GTK_BOX(vbox), button_split_phrase, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (button_split_phrase), "clicked",
G_CALLBACK (callback_url), SPLIT_PHRASE_URL);
#endif
#if UNIX
image = gtk_image_new_from_file (SYS_ICON_DIR"/gcin.png");
#else
char gcin_png[128];
sys_icon_fname("gcin.png", gcin_png);
image = gtk_image_new_from_file (gcin_png);
#endif
label_version = gtk_label_new ("version " GCIN_VERSION " " __DATE__);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 3);
gtk_box_pack_start (GTK_BOX (hbox), label_version, FALSE, FALSE, 3);
gtk_container_add (GTK_CONTAINER (about_window), vbox);
GtkWidget *button = gtk_button_new_with_label (_(_L("關閉")));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 3);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (callback_close), (gpointer) "cool button");
gtk_widget_show_all (about_window);
return;
}