int module_init_win (GCIN_module_main_functions *pFuncs) { GtkWidget *pErrDialog = NULL; int nIdx; int nSegSize = 0; if (!pFuncs) return FALSE; g_gcinModMainFuncs = *pFuncs; g_gcinModMainFuncs.mf_set_tsin_pho_mode (); g_gcinModMainFuncs.mf_set_win1_cb ((cb_selec_by_idx_t)select_idx, prev_page, next_page); if (g_pWinChewing) return TRUE; if (!chewing_initialize ()) { pErrDialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "chewing init failed"); gtk_dialog_run (GTK_DIALOG (pErrDialog)); gtk_widget_destroy (pErrDialog); return FALSE; } g_pWinChewing = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip (GTK_WINDOW (g_pWinChewing), FALSE); gtk_window_set_resizable(GTK_WINDOW(g_pWinChewing), FALSE); gtk_window_set_default_size (GTK_WINDOW (g_pWinChewing), 32, 12); gtk_widget_realize (g_pWinChewing); g_gcinModMainFuncs.mf_set_no_focus (g_pWinChewing); g_pEvBoxChewing = gtk_event_box_new (); gtk_event_box_set_visible_window (GTK_EVENT_BOX(g_pEvBoxChewing), FALSE); if (!g_pEvBoxChewing) return FALSE; gtk_container_add (GTK_CONTAINER (g_pWinChewing), g_pEvBoxChewing); g_pHBoxChewing = gtk_hbox_new (FALSE, 0); if (!g_pHBoxChewing) return FALSE; gtk_container_add (GTK_CONTAINER (g_pEvBoxChewing), g_pHBoxChewing); // TODO: not sure if we need the mouse CB or not... // if we add the CB here, then it seems that we have to use gdk // it seems not so important...? do it later //g_signal_connect (G_OBJECT (g_pEvBoxChewing), "button-press-event", // G_CALLBACK (mouse_button_callback), NULL); if (!g_pSeg) { nSegSize = sizeof (SEG) * MAX_SEG_NUM; g_pSeg = malloc (nSegSize); memset (g_pSeg, 0, nSegSize); } for (nIdx = 0; nIdx < MAX_SEG_NUM; nIdx++) { g_pSeg[nIdx].label = gtk_label_new (NULL); gtk_widget_show (g_pSeg[nIdx].label); gtk_box_pack_start (GTK_BOX (g_pHBoxChewing), g_pSeg[nIdx].label, FALSE, FALSE, 0); } if (!g_gcinModMainFuncs.mf_phkbm->selkeyN) g_gcinModMainFuncs.mf_load_tab_pho_file(); gtk_widget_show_all (g_pWinChewing); g_gcinModMainFuncs.mf_init_tsin_selection_win (); module_change_font_size (); module_hide_win (); return TRUE; }
int module_init_win(GCIN_module_main_functions *funcs) { gmf = *funcs; // dbg("module_init_win\n"); gmf.mf_set_tsin_pho_mode(); gmf.mf_set_win1_cb((cb_selec_by_idx_t)select_idx, prev_page, next_page); if (win_anthy) return TRUE; if (anthy_init() == -1) { gmf.mf_box_warn("anthy_init() failed. Anthy not installed or incompatible anthy.so ?"); return FALSE; } ac = anthy_create_context(); if (!ac) { gmf.mf_box_warn("anthy_create_context error"); return FALSE; } anthy_context_set_encoding(ac, ANTHY_UTF8_ENCODING); win_anthy = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip(GTK_WINDOW(win_anthy), FALSE); gtk_window_set_resizable(GTK_WINDOW(win_anthy), FALSE); gtk_window_set_default_size(GTK_WINDOW (win_anthy), 40, 50); gtk_widget_realize (win_anthy); gmf.mf_set_no_focus(win_anthy); event_box_anthy = gtk_event_box_new(); gtk_event_box_set_visible_window (GTK_EVENT_BOX(event_box_anthy), FALSE); gtk_container_add(GTK_CONTAINER(win_anthy), event_box_anthy); GtkWidget *hbox_top = gtk_hbox_new (FALSE, 0); gtk_container_add(GTK_CONTAINER(event_box_anthy), hbox_top); g_signal_connect(G_OBJECT(event_box_anthy),"button-press-event", G_CALLBACK(mouse_button_callback), NULL); if (!seg) { int n=sizeof(SEG)*MAX_SEG_N; seg=malloc(n); bzero(seg, n); } int i; for(i=0; i < MAX_SEG_N; i++) { seg[i].label = gtk_label_new(NULL); gtk_widget_show(seg[i].label); gtk_box_pack_start (GTK_BOX (hbox_top), seg[i].label, FALSE, FALSE, 0); } gtk_widget_show_all(win_anthy); gmf.mf_init_tsin_selection_win(); module_change_font_size(); if (!gmf.mf_phkbm->selkeyN) gmf.mf_load_tab_pho_file(); module_hide_win(); return TRUE; }