1
/* Copyright (C) 2011 Edward Der-Hua Liu, Hsin-Chu, Taiwan
3
* This library is free software; you can redistribute it and/or
4
* modify it under the terms of the GNU Lesser General Public
5
* License as published by the Free Software Foundation; either
6
* version 2.1 of the License, or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "im-client/hime-im-client-attr.h"
23
#include "hime-module.h"
24
#include "hime-module-cb.h"
27
extern HIME_module_main_functions gmf;
28
extern int current_intcode;
29
void module_show_win();
31
static GtkWidget *button_int;
32
static GtkWidget *labels_int[MAX_INTCODE];
40
static int int_selN = sizeof(int_sel)/sizeof(int_sel[0]);
42
static GtkWidget *opt_int_opts;
44
static void minimize_win()
46
gtk_window_resize(GTK_WINDOW(gwin_int), 1, 1);
49
static void adj_intcode_buttons()
53
if (current_intcode==INTCODE_UTF32) {
54
for(i=4;i < MAX_INTCODE; i++)
55
gtk_widget_show(labels_int[i]);
57
for(i=4;i < MAX_INTCODE; i++)
58
gtk_widget_hide(labels_int[i]);
65
static void cb_select( GtkWidget *widget, gpointer data)
67
current_intcode = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
68
adj_intcode_buttons();
71
static GtkWidget *create_int_opts()
74
GtkWidget *hbox = gtk_hbox_new (FALSE, 1);
76
opt_int_opts = gtk_combo_box_new_text ();
77
gtk_box_pack_start (GTK_BOX (hbox), opt_int_opts, FALSE, FALSE, 0);
80
for(i=0; i < int_selN; i++) {
81
gtk_combo_box_append_text (GTK_COMBO_BOX_TEXT (opt_int_opts), int_sel[i].name);
84
gtk_combo_box_set_active (GTK_COMBO_BOX (opt_int_opts), current_intcode);
85
g_signal_connect (G_OBJECT (opt_int_opts), "changed", G_CALLBACK (cb_select), NULL);
91
void disp_int(int index, char *intcode)
93
gtk_label_set_text(GTK_LABEL(labels_int[index]), intcode);
96
static unich_t full_space[] = " ";
98
void clear_int_code(int index)
100
gtk_label_set_text(GTK_LABEL(labels_int[index]), _(full_space));
104
void clear_int_code_all()
108
for(i=0; i < MAX_INTCODE; i++)
112
void module_hide_win()
116
gtk_widget_hide(gwin_int);
117
dbg("hide_win_int\n");
120
extern gboolean force_show;
121
extern int intcode_cin;
123
void module_move_win(int x, int y)
128
// dbg("move_win_int %d %d\n",x,y);
130
gtk_window_get_size(GTK_WINDOW(gwin_int), gmf.mf_win_xl, gmf.mf_win_yl);
132
if (x + *gmf.mf_win_xl > *gmf.mf_dpy_xl)
133
x = *gmf.mf_dpy_xl - *gmf.mf_win_xl;
137
if (y + *gmf.mf_win_yl > *gmf.mf_dpy_yl)
138
y = *gmf.mf_dpy_yl - *gmf.mf_win_yl;
142
*gmf.mf_win_x = x; *gmf.mf_win_y = y;
143
gtk_window_move(GTK_WINDOW(gwin_int), x, y);
147
void create_win_intcode()
154
gwin_int = gtk_window_new (GTK_WINDOW_TOPLEVEL);
155
gtk_window_set_has_resize_grip(GTK_WINDOW(gwin_int), FALSE);
157
// gtk_window_set_default_size(GTK_WINDOW (gwin_int), 1, 1);
158
gtk_container_set_border_width (GTK_CONTAINER (gwin_int), 0);
161
GtkWidget *frame = gtk_frame_new(NULL);
162
gtk_container_set_border_width (GTK_CONTAINER (frame), 0);
163
gtk_container_add (GTK_CONTAINER(gwin_int), frame);
166
GtkWidget *hbox_top = gtk_hbox_new (FALSE, 0);
167
gtk_container_add (GTK_CONTAINER (frame), hbox_top);
169
GtkWidget *button_intcode = gtk_button_new_with_label(_("內碼"));
170
g_signal_connect_swapped (GTK_OBJECT (button_intcode), "button_press_event",
171
G_CALLBACK (gmf.mf_inmd_switch_popup_handler), NULL);
172
gtk_box_pack_start (GTK_BOX (hbox_top), button_intcode, FALSE, FALSE, 0);
174
button_int = gtk_button_new();
175
gtk_container_set_border_width (GTK_CONTAINER (button_int), 0);
176
gtk_box_pack_start (GTK_BOX (hbox_top), button_int, FALSE, FALSE, 0);
177
GtkWidget *hbox_int = gtk_hbox_new (FALSE, 0);
178
gtk_container_add (GTK_CONTAINER (button_int), hbox_int);
181
for(i=0; i < MAX_INTCODE;i ++) {
182
GtkWidget *label = gtk_label_new(_(full_space));
183
labels_int[i] = label;
184
gtk_box_pack_start (GTK_BOX (hbox_int), label, FALSE, FALSE, 0);
185
gmf.mf_set_label_font_size(label, *gmf.mf_hime_font_size);
188
GtkWidget *intsel = create_int_opts();
189
gtk_box_pack_start (GTK_BOX (hbox_top), intsel, FALSE, FALSE, 0);
191
gtk_widget_show_all (gwin_int);
193
gtk_widget_realize (gwin_int);
194
set_no_focus(gwin_int);
196
adj_intcode_buttons();
199
// dbg("create %x\n",gwin_int);
202
void module_show_win()
205
create_win_intcode();
210
if (hime_pop_up_win && !intcode_cin && !force_show)
214
if (!GTK_WIDGET_VISIBLE(gwin_int)) {
215
gtk_widget_show(gwin_int);
218
// dbg("show_win_int %x\n", gwin_int);
219
gtk_widget_show(gwin_int);
220
module_move_win(*gmf.mf_win_x, *gmf.mf_win_y);
221
gtk_window_present(GTK_WINDOW(gwin_int));
225
void module_win_geom()
229
gtk_window_get_position(GTK_WINDOW(gwin_int), gmf.mf_win_x, gmf.mf_win_y);
231
gmf.mf_get_win_size(gwin_int, gmf.mf_win_xl, gmf.mf_win_yl);
235
int module_win_visible()
237
return GTK_WIDGET_VISIBLE(gwin_int);
241
void module_change_font_size()