Example #1
0
static void cb_fast_phonetic_kbd_switch(GtkCheckMenuItem *checkmenuitem, gpointer dat)
{
  char bak[128], cur[128];
  get_hime_conf_fstr(PHONETIC_KEYBOARD, cur, "");
  get_hime_conf_fstr(PHONETIC_KEYBOARD_BAK, bak, "");

  save_hime_conf_str(PHONETIC_KEYBOARD, bak);
  save_hime_conf_str(PHONETIC_KEYBOARD_BAK, cur);
  load_setttings();
  load_tab_pho_file();
  update_win_kbm_inited();
}
Example #2
0
int get_hime_conf_int(char *name, int default_value)
{
  char tt[32];
  char default_value_str[MAX_HIME_STR];

  sprintf(default_value_str, "%d", default_value);
  get_hime_conf_fstr(name, tt, default_value_str);

  return atoi(tt);
}
Example #3
0
gboolean is_pinyin_kbm()
{
  char kbm_str[32];

  get_hime_conf_fstr(PHONETIC_KEYBOARD, kbm_str, "zo-asdf");
#if 1
  b_pinyin = strstr(kbm_str, "pinyin") != NULL;
#else
  b_pinyin = 1;
#endif

  if (b_pinyin)
    load_pin_juyin();
  return b_pinyin;
}
Example #4
0
void save_kbm_conf()
{
  if (kbm_widget == NULL)
  {
    fprintf(stderr, "save_kbm_conf: kbm_widget is NULL!\n");
    return;
  }

  int idx = gtk_combo_box_get_active (GTK_COMBO_BOX (opt_kbm_opts));

  int idx_selkeys = gtk_combo_box_get_active (GTK_COMBO_BOX (opt_selkeys));

  pho_candicate_col_N = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_pho_candicate_col_N));

  if (pho_candicate_col_N > strlen(selkeys[idx_selkeys].kstr))
    pho_candicate_col_N = strlen(selkeys[idx_selkeys].kstr);

  dbg("pho_candicate_col_N %d\n", pho_candicate_col_N);

  char tt[128];
  sprintf(tt, "%s %s %d %d", kbm_sel[idx].kbm, selkeys[idx_selkeys].kstr, pho_candicate_col_N, selkeys[idx_selkeys].RL);

  char phokbm_name[128];
  get_hime_conf_fstr(PHONETIC_KEYBOARD, phokbm_name, "");

  if (strcmp(phokbm_name, tt)) {
    save_hime_conf_str(PHONETIC_KEYBOARD_BAK, phokbm_name);
  }
  save_hime_conf_str(PHONETIC_KEYBOARD, tt);

  save_tsin_eng_pho_key();

  save_hime_conf_int(TSIN_SPACE_OPT,
                     tsin_space_options[new_select_idx_tsin_space_opt].key);

  save_hime_conf_int(TSIN_PHRASE_PRE_SELECT,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_phrase_pre_select)));

  save_hime_conf_int(PHONETIC_CHAR_DYNAMIC_SEQUENCE,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_phonetic_char_dynamic_sequence)));
  save_hime_conf_int(PHO_HIDE_ROW2,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_pho_hide_row2)));

  save_hime_conf_int(PHO_IN_ROW1,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_pho_in_row1)));

  save_hime_conf_int(PHONETIC_HUGE_TAB,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_phonetic_huge_tab)));

  save_hime_conf_int(TSIN_TONE_CHAR_INPUT,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_tone_char_input)));

  save_hime_conf_int(TSIN_USE_PHO_NEAR,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_use_pho_near)));


  save_hime_conf_int(TSIN_TAB_PHRASE_END,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_tab_phrase_end)));


  save_hime_conf_int(TSIN_TAIL_SELECT_KEY,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_tail_select_key)));

  save_hime_conf_int(TSIN_BUFFER_EDITING_MODE,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_buffer_editing_mode)));

  tsin_buffer_size = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_tsin_buffer_size));
  save_hime_conf_int(TSIN_BUFFER_SIZE, tsin_buffer_size);

#if 0
  gchar *cstr;
  cstr = gtk_color_selection_palette_to_string(&tsin_phrase_line_gcolor, 1);
  dbg("color %s\n", cstr);
  save_hime_conf_str(TSIN_PHRASE_LINE_COLOR, cstr);
  g_free(cstr);
#endif


  save_omni_config();
  /* caleb- does found where "reload kbm" is used.
   * caleb- think the send_hime_message() here does nothing.
   */
  send_hime_message(GDK_DISPLAY(), "reload kbm");
}
Example #5
0
static void cb_popup_state(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data)
{
  switch (button) {

    case 1:
#if UNIX
      toggle_im_enabled();
      break;
    case 2:
#endif
      kbm_toggle();
      break;
    case 3:
    {
      char bak[512], cur[512];
      get_hime_conf_fstr(PHONETIC_KEYBOARD, cur, "");
      get_hime_conf_fstr(PHONETIC_KEYBOARD_BAK, bak, "");
      if (bak[0] && strcmp(bak, cur)) {
        char kbm[512];

        strcpy(kbm, bak);
        char *p=strchr(kbm, ' ');

        if (p) {
          *(p++)=0;
          int i;
          for(i=0;kbm_sel[i].name;i++)
            if (!strcmp(kbm_sel[i].kbm, kbm)) {
              break;
            }

          if (kbm_sel[i].kbm) {
            unich_t tt[128];
            if (mitems_state[0].name)
              free(mitems_state[0].name);
#if UNIX
            sprintf(tt, "注音換 %s %s", kbm_sel[i].name, p);
            mitems_state[0].name = strdup(tt);
#else
            swprintf(tt, L"注音換 %s %S", kbm_sel[i].name, p);
            mitems_state[0].name = wcsdup(tt);
#endif
          }
        }

//        dbg("hhhhhhhhhhhh %x\n", tray_menu_state);
        if (tray_menu_state) {
          gtk_widget_destroy(tray_menu_state);
          tray_menu_state = NULL;
        }
      }

      if (!tray_menu_state)
        tray_menu_state = create_tray_menu(mitems_state);

      gtk_menu_popup(GTK_MENU(tray_menu_state), NULL, NULL, NULL, NULL, button, activate_time);
      break;
    }
  }

//  dbg("zzzzzzzzzzzzz\n");
}
Example #6
0
static gboolean cb_ok( GtkWidget *widget,
                                   GdkEvent  *event,
                                   gpointer   data )
{
  int idx = gtk_combo_box_get_active (GTK_COMBO_BOX (opt_kbm_opts));

  int idx_selkeys = gtk_combo_box_get_active (GTK_COMBO_BOX (opt_selkeys));

  pho_candicate_col_N = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_pho_candicate_col_N));

  if (pho_candicate_col_N > strlen(selkeys[idx_selkeys].kstr))
    pho_candicate_col_N = strlen(selkeys[idx_selkeys].kstr);

  dbg("pho_candicate_col_N %d\n", pho_candicate_col_N);

  char tt[128];
  sprintf(tt, "%s %s %d %d", kbm_sel[idx].kbm, selkeys[idx_selkeys].kstr, pho_candicate_col_N, selkeys[idx_selkeys].RL);

  char phokbm_name[128];
  get_hime_conf_fstr(PHONETIC_KEYBOARD, phokbm_name, "");

  if (strcmp(phokbm_name, tt)) {
    save_hime_conf_str(PHONETIC_KEYBOARD_BAK, phokbm_name);
  }
  save_hime_conf_str(PHONETIC_KEYBOARD, tt);

  save_tsin_eng_pho_key();

  save_hime_conf_int(TSIN_SPACE_OPT,
                     tsin_space_options[new_select_idx_tsin_space_opt].key);

  save_hime_conf_int(TSIN_PHRASE_PRE_SELECT,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_phrase_pre_select)));

  save_hime_conf_int(PHONETIC_CHAR_DYNAMIC_SEQUENCE,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_phonetic_char_dynamic_sequence)));
  save_hime_conf_int(PHO_HIDE_ROW2,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_pho_hide_row2)));

  save_hime_conf_int(PHO_IN_ROW1,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_pho_in_row1)));

  save_hime_conf_int(PHONETIC_HUGE_TAB,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_phonetic_huge_tab)));

  save_hime_conf_int(TSIN_TONE_CHAR_INPUT,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_tone_char_input)));

  save_hime_conf_int(TSIN_USE_PHO_NEAR,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_use_pho_near)));


  save_hime_conf_int(TSIN_TAB_PHRASE_END,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_tab_phrase_end)));


  save_hime_conf_int(TSIN_TAIL_SELECT_KEY,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_tail_select_key)));

  save_hime_conf_int(TSIN_BUFFER_EDITING_MODE,
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button_tsin_buffer_editing_mode)));

  tsin_buffer_size = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_tsin_buffer_size));
  save_hime_conf_int(TSIN_BUFFER_SIZE, tsin_buffer_size);

  gchar *cstr;
#if 0
  cstr = gtk_color_selection_palette_to_string(&tsin_phrase_line_gcolor, 1);
  dbg("color %s\n", cstr);
  save_hime_conf_str(TSIN_PHRASE_LINE_COLOR, cstr);
  g_free(cstr);
#endif


  cstr = gtk_color_selection_palette_to_string(&tsin_cursor_gcolor, 1);
  dbg("color %s\n", cstr);
  save_hime_conf_str(TSIN_CURSOR_COLOR, cstr);
  g_free(cstr);

  send_hime_message(
#if UNIX
	  GDK_DISPLAY(),
#endif
	  "reload kbm");

  gtk_widget_destroy(hime_kbm_window); hime_kbm_window = NULL;

  return TRUE;
}