示例#1
0
void get_key_str(void *key, int idx, char *out_str)
{
    char t[128];
    char *phostr;

    if (is_gtab) {
        int tlen;
        u_int64_t key64;
        if (ph_key_sz == 4) {
            u_int32_t key32;
            cp_ph_key(key, idx, &key32);
            key64 = key32;
        } else
            cp_ph_key(key, idx, &key64);
        gtab_key2name(pinmd, key64, t, &tlen);
        phostr = t;
    } else {
        phokey_t k;
        cp_ph_key(key, idx, &k);
        phostr = b_pinyin?
                 phokey2pinyin(k):phokey_to_str(k);
    }

    strcpy(out_str, phostr);
}
示例#2
0
GtkWidget *create_pho_sel_area()
{
  hbox_pho_sel = gtk_hbox_new (FALSE, 0);

  int i;

  for(i=0; i < bigphoN; i++) {
    bigpho[i].opt_menu = gtk_combo_box_new_text ();
    gtk_box_pack_start (GTK_BOX (hbox_pho_sel), bigpho[i].opt_menu, FALSE, FALSE, 0);

    int j;
    for(j=0; j < bigpho[i].phokeysN; j++) {
      char t[128];
      char *phostr;

      if (is_gtab) {
        int tlen;
        u_int64_t key64;
        if (ph_key_sz == 4) {
          u_int32_t key32;
          cp_ph_key(bigpho[i].phokeys,j, &key32);
          key64 = key32;
        } else
          cp_ph_key(bigpho[i].phokeys,j, &key64);

        gtab_key2name(pinmd, key64, t, &tlen);
//        dbg("%d,%d] %s\n", i,j, t);
        phostr = t;
      } else {
        phokey_t k;
        cp_ph_key(bigpho[i].phokeys, j, &k);
        phostr = b_pinyin?
        phokey2pinyin(k):phokey_to_str(k);
      }

      gtk_combo_box_append_text (GTK_COMBO_BOX_TEXT (bigpho[i].opt_menu), phostr);
    }

    gtk_combo_box_set_active (GTK_COMBO_BOX(bigpho[i].opt_menu), 0);
  }


  GtkWidget *button_ok = gtk_button_new_with_label("OK to add");
  gtk_box_pack_start (GTK_BOX (hbox_pho_sel), button_ok, FALSE, FALSE, 20);
  g_signal_connect (G_OBJECT (button_ok), "clicked",
     G_CALLBACK (cb_button_ok), NULL);

  GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  gtk_box_pack_start (GTK_BOX (hbox_pho_sel), button_cancel, FALSE, FALSE, 20);
  g_signal_connect (G_OBJECT (button_cancel), "clicked",
     G_CALLBACK (cb_button_cancel), NULL);


  return hbox_pho_sel;
}
示例#3
0
static void cb_button_ok(GtkButton *button, gpointer user_data)
{
    u_int64_t pharr8[MAX_PHRASE_LEN];

    int i;
    for(i=0; i < bigphoN; i++) {
        int idx = gtk_combo_box_get_active(GTK_COMBO_BOX(bigpho[i].opt_menu));
        void *dest = get_ph_key_ptr(pharr8, i);

        cp_ph_key(bigpho[i].phokeys, idx, dest);
    }

    save_phrase_to_db(pharr8, current_str, bigphoN, 0);

    destroy_pho_sel_area();
}
示例#4
0
static void cb_button_ok(GtkButton *button, gpointer user_data)
{
  u_int64_t pharr8[MAX_PHRASE_LEN];

  int i;
  for(i=0; i < bigphoN; i++) {
    int idx = gtk_combo_box_get_active(GTK_COMBO_BOX(bigpho[i].opt_menu));
    void *dest = get_ph_key_ptr(pharr8, i);

    cp_ph_key(bigpho[i].phokeys, idx, dest);
  }

  save_phrase_to_db(pharr8, current_str, bigphoN, 0);

  destroy_pho_sel_area();

  GtkTextMark *selebound =  gtk_text_buffer_get_selection_bound(buffer);
  gtk_text_mark_set_visible(selebound, FALSE);

  cb_button_parse(NULL, NULL);

}