File: entry.c

package info (click to toggle)
imhangul 0.9.13-8
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,164 kB
  • ctags: 858
  • sloc: ansic: 16,930; sh: 8,472; python: 225; makefile: 50
file content (166 lines) | stat: -rw-r--r-- 4,794 bytes parent folder | download | duplicates (3)
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
/* example program for imhangul input test */
/* if you run this program, use ./test.sh instead of run this directly. */

#include <gtk/gtk.h>

void
on_status_window_clicked (GtkWidget *window) 
{
    static gboolean value = TRUE;
    GdkScreen *screen;
    GtkSettings *settings;

    screen = gdk_drawable_get_screen (window->window);
    settings = gtk_settings_get_for_screen (screen);

    g_object_set (settings,
	    	  "gtk-im-hangul-status-window", value,
		  NULL);
    g_print ("gtk-im-hangul-status-window: %d\n", value);
    value = !value;
}

void
on_use_capslock_clicked (GtkWidget *window) 
{
    static gboolean value = TRUE;
    GdkScreen *screen;
    GtkSettings *settings;

    screen = gdk_drawable_get_screen (window->window);
    settings = gtk_settings_get_for_screen (screen);

    g_object_set (settings,
	    	  "gtk-im-hangul-use-capslock", value,
		  NULL);
    g_print ("gtk-im-hangul-use-capslock: %d\n", value);
    value = !value;
}

void
on_use_dvorak_clicked (GtkWidget *window) 
{
    static gboolean value = TRUE;
    GdkScreen *screen;
    GtkSettings *settings;

    screen = gdk_drawable_get_screen (window->window);
    settings = gtk_settings_get_for_screen (screen);

    g_object_set (settings,
	    	  "gtk-im-hangul-use-dvorak", value,
		  NULL);
    g_print ("gtk-im-hangul-use-dvorak: %d\n", value);
    value = !value;
}

void
on_preedit_style_clicked (GtkWidget *window) 
{
    static gint value = 0;
    GdkScreen *screen;
    GtkSettings *settings;

    screen = gdk_drawable_get_screen (window->window);
    settings = gtk_settings_get_for_screen (screen);

    g_object_set (settings,
	    	  "gtk-im-hangul-preedit-style", value,
		  NULL);
    g_print ("gtk-im-hangul-preedit-style: %d\n", value);
    value++;
    if (value > 4)
	value = 0;
}

void
on_quit_clicked (GtkWidget *window)
{
    gtk_widget_destroy (window);
    gtk_main_quit();
}

void
on_popup_new_window(GtkWidget *widget)
{
	GtkWidget *window;
    GtkWidget *entry;

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    entry = gtk_entry_new ();
    gtk_container_add (GTK_CONTAINER (window), entry);
	gtk_widget_show_all(window);
}

void
on_destroy (GtkWidget *window, gpointer data)
{
    gtk_main_quit();
}

int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *entry;
    GtkWidget *button;

    gtk_init (&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK(on_destroy), NULL);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);

    entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
    entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
    entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
    entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
    entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
    entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);

    button = gtk_button_new_with_label ("Popup new window");
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
		              G_CALLBACK(on_popup_new_window), window);

    button = gtk_button_new_with_label ("gtk-im-hangul-status-window");
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
		              G_CALLBACK(on_status_window_clicked), window);

    button = gtk_button_new_with_label ("gtk-im-hangul-user-capslock");
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
		              G_CALLBACK(on_use_capslock_clicked), window);

    button = gtk_button_new_with_label ("gtk-im-hangul-use-dvorak");
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
		              G_CALLBACK(on_use_dvorak_clicked), window);

    button = gtk_button_new_with_label ("gtk-im-hangul-preedit-style");
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
		              G_CALLBACK(on_preedit_style_clicked), window);

    button = gtk_button_new_with_label ("quit");
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
    g_signal_connect_swapped (G_OBJECT (button), "clicked",
		              G_CALLBACK(on_quit_clicked), window);

    gtk_widget_show_all(window);

    gtk_main ();

    return 0;
}

/* vim: set sw=4 : */