static void cb_popup(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) { // dbg("cb_popup\n"); switch (button) { #if UNIX case 1: toggle_im_enabled(); break; case 2: kbm_toggle(); break; #endif case 3: // dbg("tray_menu %x\n", tray_menu); if (!tray_menu) tray_menu = create_tray_menu(mitems_main); #if 0 gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, gtk_status_icon_position_menu, status_icon, button, activate_time); #else gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, NULL, NULL, button, activate_time); #endif break; } }
gboolean tray_button_press_event_cb (GtkStatusIcon *status_icon, GdkEventButton * event, gpointer userdata) { switch (event->button) { case 1: if (event->state & GDK_SHIFT_MASK) inmd_switch_popup_handler(NULL, (GdkEvent *)event); else toggle_im_enabled(); break; case 2: #if 0 inmd_switch_popup_handler(NULL, (GdkEvent *)event); #else kbm_toggle(); dbg("win_kbm_on %d\n", win_kbm_on); update_item_active_all(); #endif break; case 3: if (!tray_menu) tray_menu = create_tray_menu(mitems); gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, gtk_status_icon_position_menu, tray_icon, event->button, event->time); break; } return TRUE; }
static void cb_activate_state(GtkStatusIcon *status_icon, gpointer user_data) { // dbg("cb_activate\n"); if (gcin_tray_hf_win_kbm) { kbm_toggle(); update_item_active_all(); } else toggle_half_full_char_sub(); }
void message_cb(char *message) { void sim_output(); // FIXME void trad_output(); // FIXME // dbg("message '%s'\n", message); /* TODO: rewrite the mess with case() ? */ if (!strcmp(message, CHANGE_FONT_SIZE)) { change_font_size(); } else if (!strcmp(message, GB_OUTPUT_TOGGLE)) { cb_trad_sim_toggle(); #if TRAY_ENABLED update_item_active_all(); #endif } else if (!strcmp(message, SIM_OUTPUT_TOGGLE)) { sim_output(); #if TRAY_ENABLED disp_tray_icon(); update_item_active_all(); #endif } else if (!strcmp(message, TRAD_OUTPUT_TOGGLE)) { trad_output(); #if TRAY_ENABLED disp_tray_icon(); update_item_active_all(); #endif } else if (!strcmp(message, KBM_TOGGLE)) { kbm_toggle(); } else if (strstr(message, "#hime_message")) { execute_message(message); } else #if TRAY_ENABLED if (!strcmp(message, UPDATE_TRAY)) { disp_tray_icon(); } else #endif if (!strcmp(message, RELOAD_TSIN_DB)) { reload_tsin_db(); } else if (!strcmp(message, HIME_EXIT_MESSAGE)) { do_exit(); } else reload_data(); }
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_gcin_conf_fstr(PHONETIC_KEYBOARD, cur, ""); get_gcin_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"); }