GCIN_module_callback_functions *init_GCIN_module_callback_functions(char *sofile) { #if UNIX void *handle; char *error; dbg("dlopen %s\n", sofile); if (!(handle = dlopen(sofile, RTLD_LAZY))) { if ((error = dlerror()) != NULL) box_warn(error); return NULL; } #else HMODULE handle = LoadLibraryA(sofile); if (!handle) { box_warn("LoadLibraryA %s error %s", sofile, sys_err_strA()); return NULL; } #define dlsym GetProcAddress #endif GCIN_module_callback_functions st; *(void **) (&st.module_init_win) = dlsym(handle, "module_init_win"); if (!st.module_init_win) p_err("module_init_win() not found in %s", sofile); *(void **) (&st.module_get_win_geom) = dlsym(handle, "module_get_win_geom"); *(void **) (&st.module_reset) = dlsym(handle, "module_reset"); *(void **) (&st.module_get_preedit) = dlsym(handle, "module_get_preedit"); *(void **) (&st.module_feedkey) = dlsym(handle, "module_feedkey"); *(void **) (&st.module_feedkey_release) = dlsym(handle, "module_feedkey_release"); *(void **) (&st.module_move_win) = dlsym(handle, "module_move_win"); *(void **) (&st.module_change_font_size) = dlsym(handle, "module_change_font_size"); *(void **) (&st.module_show_win) = dlsym(handle, "module_show_win"); *(void **) (&st.module_hide_win) = dlsym(handle, "module_hide_win"); *(void **) (&st.module_win_visible) = dlsym(handle, "module_win_visible"); *(void **) (&st.module_flush_input) = dlsym(handle, "module_flush_input"); *(void **) (&st.module_setup_window_create) = dlsym(handle, "module_setup_window_create"); return tmemdup(&st, GCIN_module_callback_functions, 1); }
void create_win_save_phrase(WSP_S *wsp, int wspN) { #if WIN32 if (test_mode) return; #endif if (!wspN) return; SAVE_SESS *sess = tzmalloc(SAVE_SESS, 1); GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip(GTK_WINDOW(main_window), FALSE); sess->win = main_window; gtk_window_set_default_size(GTK_WINDOW (main_window), 20, 10); gtk_window_set_title(GTK_WINDOW(main_window), _(_L("加片語到詞庫"))); #if 0 g_signal_connect (G_OBJECT (main_window), "delete_event", G_CALLBACK (delete_event), sess); #endif GtkWidget *vbox = gtk_vbox_new (FALSE, 0); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox), GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (main_window), vbox); char tt[512]; tt[0] = 0; wsp_str(wsp, wspN, tt); gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new(tt), FALSE, FALSE, 0); int i; for(i=0; i<wspN; i++) { if (ph_key_sz==2) strcat(tt, phokey_to_str(wsp[i].key)); strcat(tt, " "); } if (tt[0]) gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new(tt), FALSE, FALSE, 0); sess->mywsp = tmemdup(wsp, WSP_S, wspN); sess->mywspN = wspN; GtkWidget *hbox_cancel_ok = gtk_hbox_new (FALSE, 10); gtk_box_pack_start (GTK_BOX (vbox), hbox_cancel_ok , FALSE, FALSE, 5); GtkWidget *button_ok = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_ok, TRUE, TRUE, 5); GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_box_pack_start (GTK_BOX (hbox_cancel_ok), button_cancel, TRUE, TRUE, 0); sess->label_countdown = gtk_label_new(NULL); gtk_box_pack_start (GTK_BOX (vbox), sess->label_countdown, FALSE, FALSE, 5); #if 1 #if WIN32 set_no_focus(main_window); #endif gtk_widget_realize(main_window); #if UNIX set_no_focus(main_window); #else win32_init_win(main_window); #endif #endif // dbg("mmmmmmmmmmmmm\n"); GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT); gtk_widget_grab_default (button_ok); #if 1 // dbg("main_window %x\n", main_window); g_signal_connect (G_OBJECT (button_cancel), "clicked", G_CALLBACK (close_win_save_phrase), sess); g_signal_connect (G_OBJECT (button_ok), "clicked", G_CALLBACK (cb_ok), sess); #endif gtk_window_present(GTK_WINDOW(main_window)); gtk_window_set_keep_above(GTK_WINDOW(main_window), TRUE); // gtk_window_set_modal(GTK_WINDOW(main_window), TRUE); sess->countdown = 3; disp_countdown(sess); sess->countdown_handle = g_timeout_add(1000, timeout_countdown, sess); gtk_widget_show_all(main_window); }