File: about.cpp

package info (click to toggle)
gcin 2.9.4%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,796 kB
  • sloc: cpp: 34,326; ansic: 9,319; makefile: 658; sh: 556
file content (162 lines) | stat: -rw-r--r-- 4,909 bytes parent folder | download | duplicates (5)
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
#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 FURL_ANDROID "http://hyperrate.com/dir.php?eid=255"

#define LOG_URL "http://hyperrate.com/gcin-source/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"
#define IE_URL "http://hyperrate.com/thread.php?tid=22898#22898"

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), "關於 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 && 0
   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",
                "前往 gcin 討論區",
                "gcin也有 Windows版",
                "gcin改變記錄",
                "推薦使用26鍵的注音鍵盤",
                "使用詞音輸入標點符號",
                "如何新增詞",
                "如何手動斷詞"

          );
   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
static struct {
		char *label_str;
		char *url;
	} lab_url[] = {
#if UNIX
		{"討論區", FURL_LINUX },
        {"gcin也有 Windows版", FURL_WIN32},
#else
		{"討論區", FURL_WIN32 },
		{"gcin也有 Linux版", FURL_LINUX},
#endif
		{"gcin也有 Android版", FURL_ANDROID},
		{"gcin改變記錄", LOG_URL},
		{"推薦使用26鍵的注音鍵盤", ET26_URL},
		{"使用詞音輸入標點符號", PUNC_URL},
		{"如何新增詞", ADD_PHRASE_URL},
		{"如何手動斷詞", SPLIT_PHRASE_URL},
#if WIN32
		{"IE內使用gcin", IE_URL},
#endif
		{NULL}
	};

	int i;
	for(i=0; lab_url[i].url; i++) {
       GtkWidget *button = gtk_button_new_with_label(lab_url[i].label_str);
       gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
       g_signal_connect (G_OBJECT (button), "clicked",
		      G_CALLBACK (callback_url), lab_url[i].url);
	}
#endif


#if UNIX
    image = gtk_image_new_from_file (SYS_ICON_DIR"/hicolor/64x64/apps/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);

    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 ("關閉");
    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;
}