File: about.c

package info (click to toggle)
gcin 1.4.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,488 kB
  • ctags: 3,272
  • sloc: ansic: 25,634; makefile: 524; sh: 411; cpp: 231
file content (96 lines) | stat: -rw-r--r-- 2,800 bytes parent folder | download
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
#include "gcin.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;
}

extern GtkWidget *main_window;

void align_with_ui_window(GtkWidget *win)
{
    gint uix, uiy;

    gtk_window_get_position(GTK_WINDOW(main_window), &uix, &uiy);

    gtk_window_move(GTK_WINDOW(win), uix, uiy);
}


void align_with_ui_window(GtkWidget *win);

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_title (GTK_WINDOW (about_window), _("關於 gcin"));

    /* It's a good idea to do this for all windows. */
    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);

    align_with_ui_window(about_window);

    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);

    char tt[512];

#if 1
    GtkWidget *label_sf = gtk_label_new ("http://hyperrate.com/dir.php?eid=67\n");
    gtk_label_set_selectable(GTK_LABEL(label_sf), TRUE);
    gtk_box_pack_start(GTK_BOX(vbox), label_sf, FALSE, FALSE, 0);
#else
    GtkWidget *button_url = gtk_link_button_new_with_label("http://hyperrate.com/dir.php?eid=67", "forum");
    gtk_box_pack_start(GTK_BOX(vbox), button_url, FALSE, FALSE, 0);
#endif

    image = gtk_image_new_from_file (SYS_ICON_DIR"/gcin.png");

    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);

    /* Create a new button */
    GtkWidget *button = gtk_button_new_with_label (_("關閉"));
    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 3);
    /* Connect the "clicked" signal of the button to our callback */
    g_signal_connect (G_OBJECT (button), "clicked",
		      G_CALLBACK (callback_close), (gpointer) "cool button");

    gtk_widget_show_all (about_window);

    return;
}