int main(int argc, char **argv) { int i; gtk_init(&argc, &argv); load_setttings(); if (argc > 1) { p_err("Currently only support ~/.config/hime/pho.tab2"); } pho_load(); for(i=0; i < idxnum_pho; i++) { phokey_t key = idx_pho[i].key; int frm = idx_pho[i].start; int to = idx_pho[i+1].start; int j; for(j=frm; j < to; j++) { prph(key); char *str = pho_idx_str(j); dbg(" %s %d\n", str, ch_pho[j].count); } } return 0; }
int main(int argc, char **argv) { #if WIN32 init_TableDir(); #endif gtk_init (&argc, &argv); #if HIME_i18n_message bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif b_pinyin = is_pinyin_kbm(); pho_load(); mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip(GTK_WINDOW(mainwin), FALSE); gtk_window_set_default_size(GTK_WINDOW (mainwin), 640, 220); set_window_hime_icon(mainwin); GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GtkWidget *vbox_top = gtk_vbox_new (FALSE, 0); gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox_top), GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER(mainwin), vbox_top); GtkWidget *view = gtk_text_view_new (); gtk_widget_set_hexpand (view, TRUE); gtk_widget_set_vexpand (view, TRUE); gtk_container_add (GTK_CONTAINER(sw), view); gtk_box_pack_start (GTK_BOX (vbox_top), sw, TRUE, TRUE, 0); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); gtk_text_buffer_create_tag (buffer, "blue_background", "background", "blue", "foreground", "white", NULL); gtk_text_buffer_create_tag (buffer, "char_wrap", "wrap_mode", GTK_WRAP_CHAR, NULL); hbox_buttons = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_top), hbox_buttons, FALSE, FALSE, 0); GtkWidget *button_fetch = gtk_button_new_with_label(_(_L("自剪貼區更新"))); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_fetch, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_fetch), "clicked", G_CALLBACK (cb_button_fetch), NULL); GtkWidget *button_exit = gtk_button_new_from_stock(GTK_STOCK_QUIT); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_exit, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_exit), "clicked", G_CALLBACK (do_exit), NULL); g_signal_connect (G_OBJECT (mainwin), "delete_event", G_CALLBACK (do_exit), NULL); gtk_widget_show_all(mainwin); #if UNIX pclipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); #else pclipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); #endif req_clipboard(); gtk_main(); return 0; }
int main(int argc, char **argv) { #if WIN32 WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD(2, 2); err = WSAStartup(wVersionRequested, &wsaData); #endif dbg("%s\n", argv[0]); b_contrib = strstr(argv[0], "ts-contribute")!=NULL; if (b_contrib) dbg("b_contrib\n"); set_is_chs(); load_setttings(); init_TableDir(); b_pinyin = is_pinyin_kbm(); gtk_init (&argc, &argv); load_gtab_list(TRUE); char gcin_dir[512]; get_gcin_dir(gcin_dir); if (argc < 2) { #if UNIX chdir(gcin_dir); #else _chdir(gcin_dir); #endif } #if GCIN_i18n_message bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif get_gcin_user_fname(DOWNLOADED_PHRASES, downloaded_file_src); strcat(downloaded_file_src, ".src"); pinmd = &inmd[default_input_method]; if (pinmd->method_type == method_type_TSIN) { dbg("is tsin\n"); pho_load(); if (b_contrib) { load_tsin_contrib(); } else { if (argc > 1) load_tsin_db_ex(&tsin_hand, argv[1], FALSE, FALSE, FALSE); else load_tsin_db(); } ph_key_sz = 2; } else if (pinmd->filename) { if (b_contrib) p_err("Currently %s only supports tsin", argv[0]); dbg("gtab filename %s\n", pinmd->filename); init_gtab(default_input_method); is_gtab = TRUE; init_tsin_table_fname(pinmd, gtab_tsin_fname); load_tsin_db0(gtab_tsin_fname, TRUE); } else p_err("Your default input method %s doesn't use phrase database", pinmd->cname); dbg("ph_key_sz: %d\n", ph_key_sz); #if UNIX dpy = GDK_DISPLAY(); #endif load_ts_phrase(); mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(mainwin), GTK_WIN_POS_CENTER); g_signal_connect (G_OBJECT (mainwin), "key-press-event", G_CALLBACK (key_press_event), NULL); gtk_window_set_has_resize_grip(GTK_WINDOW(mainwin), FALSE); // gtk_window_set_default_size(GTK_WINDOW (mainwin), 640, 520); set_window_gcin_icon(mainwin); vbox_top = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER(mainwin), vbox_top); GtkWidget *hbox_page = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_top), hbox_page, TRUE, FALSE, 0); GtkWidget *align_page = gtk_alignment_new(0, 0, 1.0, 1.0); gtk_box_pack_start (GTK_BOX (hbox_page), align_page, TRUE, TRUE, 0); GtkWidget *vbox_page = gtk_vbox_new (TRUE, 0); gtk_container_add (GTK_CONTAINER(align_page), vbox_page); scroll_bar = gtk_vscrollbar_new( GTK_ADJUSTMENT(gtk_adjustment_new(tsN - PAGE_LEN,0, tsN, 1,PAGE_LEN,PAGE_LEN))); gtk_box_pack_start (GTK_BOX (hbox_page), scroll_bar, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(scroll_bar), "change-value", G_CALLBACK(cb_scroll_bar), NULL); int i; for(i=0; i<PAGE_LEN; i++) { GtkWidget *hbox; hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_page), hbox, TRUE, TRUE, 0); button_check[i] = gtk_check_button_new(); gtk_box_pack_start (GTK_BOX (hbox), button_check[i], FALSE, FALSE, 0); labels[i]=gtk_label_new(NULL); GtkWidget *align = gtk_alignment_new (0, 0, 0, 0); gtk_container_add(GTK_CONTAINER(align), labels[i]); gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0); } hbox_buttons = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_top), hbox_buttons, FALSE, FALSE, 0); GtkWidget *button_delete = b_contrib ? gtk_button_new_with_label(_(_L("私密詞不上載"))):gtk_button_new_from_stock (GTK_STOCK_DELETE); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_delete, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_delete), "clicked", G_CALLBACK (cb_button_delete), NULL); GtkWidget *button_find = gtk_button_new_from_stock (GTK_STOCK_FIND); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_find, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_find), "clicked", G_CALLBACK (cb_button_find), NULL); #if 0 GtkWidget *button_edit = gtk_button_new_from_stock (GTK_STOCK_EDIT); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_edit, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_edit), "clicked", G_CALLBACK (cb_button_edit), NULL); #endif GtkWidget *button_save = b_contrib ? gtk_button_new_with_label(_(_L("上載詞"))) :gtk_button_new_from_stock (GTK_STOCK_SAVE); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_save, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_save), "clicked", G_CALLBACK (cb_button_save), NULL); GtkWidget *button_quit = gtk_button_new_from_stock (GTK_STOCK_QUIT); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_quit, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_quit), "clicked", G_CALLBACK (do_exit), NULL); if (!b_contrib && !is_gtab) { GtkWidget *button_download = gtk_button_new_with_label(_(_L("下載共享詞庫"))); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_download, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_download), "clicked", G_CALLBACK (cb_button_download), NULL); } g_signal_connect (G_OBJECT (mainwin), "delete_event", G_CALLBACK (do_exit), NULL); gtk_widget_realize (mainwin); gtk_widget_show_all(mainwin); // load_ts_phrase(); disp_page(); #if 0 GdkWindow *gdkwin=gtk_widget_get_window(mainwin); gdk_window_set_events(gdkwin, GDK_BUTTON_PRESS_MASK|GDK_SCROLL_MASK| gdk_window_get_events(gdkwin)); #endif gtk_main(); return 0; }
int main(int argc, char **argv) { init_TableDir(); set_is_chs(); gtk_init (&argc, &argv); load_setttings(); load_gtab_list(TRUE); b_pinyin = is_pinyin_kbm(); #if GCIN_i18n_message bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif pinmd = &inmd[default_input_method]; if (pinmd->method_type == method_type_TSIN) { dbg("is tsin\n"); pho_load(); load_tsin_db(); ph_key_sz = 2; } else if (pinmd->filename) { dbg("gtab filename %s\n", pinmd->filename); init_gtab(default_input_method); is_gtab = TRUE; init_tsin_table_fname(pinmd, gtab_tsin_fname); load_tsin_db0(gtab_tsin_fname, TRUE); } else p_err("Your default input method %s doesn't use phrase database", pinmd->cname); dbg("ph_key_sz: %d\n", ph_key_sz); #if UNIX dpy = GDK_DISPLAY(); #endif mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_has_resize_grip(GTK_WINDOW(mainwin), FALSE); gtk_window_set_default_size(GTK_WINDOW (mainwin), 640, 520); set_window_gcin_icon(mainwin); GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GtkWidget *vbox_top = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER(mainwin), vbox_top); GtkWidget *view = gtk_text_view_new (); gtk_widget_set_hexpand (view, TRUE); gtk_widget_set_vexpand (view, TRUE); gtk_container_add (GTK_CONTAINER(sw), view); gtk_box_pack_start (GTK_BOX (vbox_top), sw, TRUE, TRUE, 0); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); #if UNIX char *text = _(_L("按滑鼠中鍵, 貼上你要 tslearn 學習的文章。")); #else char *text = _(_L("按 ctrl-V, 貼上你要 tslearn 學習的文章。")); #endif gtk_text_buffer_set_text (buffer, text, -1); gtk_text_buffer_create_tag (buffer, "blue_background", "background", "blue", "foreground", "white", NULL); gtk_text_buffer_create_tag (buffer, "char_wrap", "wrap_mode", GTK_WRAP_CHAR, NULL); hbox_buttons = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox_top), hbox_buttons, FALSE, FALSE, 0); GtkWidget *button_parse = gtk_button_new_with_label(_(_L("標示已知詞"))); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_parse, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_parse), "clicked", G_CALLBACK (cb_button_parse), NULL); GtkWidget *button_add = gtk_button_new_with_label(_(_L("新增詞"))); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_add, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (button_add), "clicked", G_CALLBACK (cb_button_add), NULL); GtkWidget *button_quit = gtk_button_new_from_stock (GTK_STOCK_QUIT); gtk_box_pack_start (GTK_BOX (hbox_buttons), button_quit, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (button_quit), "clicked", G_CALLBACK (do_exit), NULL); g_signal_connect (G_OBJECT (mainwin), "delete_event", G_CALLBACK (do_exit), NULL); all_wrap(); gtk_widget_show_all(mainwin); #if WIN32 gtk_window_present(GTK_WINDOW(mainwin)); #endif gtk_main(); return 0; }