OLD | NEW |
1 requires 2.0.0 | 1 requires 2.0.0 |
2 | 2 |
3 %alltop{ | 3 %alltop{ |
4 /* | 4 /* |
5 * Copyright © 2009 Red Hat, Inc. All rights reserved. | 5 * Copyright © 2009 Red Hat, Inc. All rights reserved. |
6 * Copyright © 2009 Ding-Yi Chen <dchen at redhat.com> | 6 * Copyright © 2009 Ding-Yi Chen <dchen at redhat.com> |
7 * | 7 * |
8 * This file is part of the ibus-chewing Project. | 8 * This file is part of the ibus-chewing Project. |
9 * | 9 * |
10 * This program is free software; you can redistribute it and/or | 10 * This program is free software; you can redistribute it and/or |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 /** | 101 /** |
102 * EngineStatus: | 102 * EngineStatus: |
103 * @INITIALIZED: Engine is initialized. | 103 * @INITIALIZED: Engine is initialized. |
104 */ | 104 */ |
105 enum ENGINE_STATUS{ | 105 enum ENGINE_STATUS{ |
106 INITIALIZED= 0x1, | 106 INITIALIZED= 0x1, |
107 ENABLED= 0x2, | 107 ENABLED= 0x2, |
108 FOCUS_IN= 0x4, | 108 FOCUS_IN= 0x4, |
109 SHOW_CANDIDATE= 0x8, | 109 SHOW_CANDIDATE= 0x8, |
110 NEED_COMMIT= 0x10, | 110 NEED_COMMIT= 0x10, |
| 111 FORCE_COMMIT= 0x20, |
111 } Engine:Status; | 112 } Engine:Status; |
112 | 113 |
113 %h{ | 114 %h{ |
114 #include "maker-dialog.h" | 115 #include "maker-dialog.h" |
115 #define GCONF_KEY_PREFIX "/desktop/ibus/engine/Chewing/" | 116 #define GCONF_KEY_PREFIX "/desktop/ibus/engine/Chewing/" |
116 /* For easy symbol input work around */ | 117 /* For easy symbol input work around */ |
117 #define EASY_SYMBOL_INPUT_WORK_AROUND | 118 #define EASY_SYMBOL_INPUT_WORK_AROUND |
118 | 119 |
119 extern PropertySpec propSpecs[]; | 120 extern PropertySpec propSpecs[]; |
120 extern const gchar *page_labels[]; | 121 extern const gchar *page_labels[]; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 ibus_engine_show_lookup_table(IBUS_ENGINE(self)); | 433 ibus_engine_show_lookup_table(IBUS_ENGINE(self)); |
433 ibus_chewing_engine_set_status_flag(self,ENGINE_STATUS_SHOW_CANDIDAT
E); | 434 ibus_chewing_engine_set_status_flag(self,ENGINE_STATUS_SHOW_CANDIDAT
E); |
434 }else{ | 435 }else{ |
435 ibus_engine_hide_lookup_table(IBUS_ENGINE(self)); | 436 ibus_engine_hide_lookup_table(IBUS_ENGINE(self)); |
436 ibus_chewing_engine_clear_status_flag(self,ENGINE_STATUS_SHOW_CANDID
ATE); | 437 ibus_chewing_engine_clear_status_flag(self,ENGINE_STATUS_SHOW_CANDID
ATE); |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 private void update_lookup_table(self){ | 441 private void update_lookup_table(self){ |
441 if (!self->table){ | 442 if (!self->table){ |
442 » self->table=ibus_lookup_table_new(1,0,FALSE,TRUE); | 443 » self->table=ibus_lookup_table_new(1,0,TRUE,TRUE); |
443 g_object_ref_sink(self->table); | 444 g_object_ref_sink(self->table); |
444 } | 445 } |
445 ibus_lookup_table_clear(self->table); | 446 ibus_lookup_table_clear(self->table); |
446 int choicePerPage=chewing_cand_ChoicePerPage(self->context); | 447 int choicePerPage=chewing_cand_ChoicePerPage(self->context); |
447 int i=0; | 448 int i=0; |
448 char *candidate=NULL; | 449 char *candidate=NULL; |
449 IBusText *iText=NULL; | 450 IBusText *iText=NULL; |
450 | 451 |
451 G_DEBUG_MSG(4,"[I4] update_lookup_table() TotalChoice=%d CurrentPage=%d"
, | 452 G_DEBUG_MSG(4,"[I4] update_lookup_table() TotalChoice=%d CurrentPage=%d"
, |
452 chewing_cand_TotalChoice(self->context),chewing_cand_CurrentPage
(self->context)); | 453 chewing_cand_TotalChoice(self->context),chewing_cand_CurrentPage
(self->context)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 return iText; | 514 return iText; |
514 } | 515 } |
515 | 516 |
516 private void update_aux_string(self, IBusText *preeditIText){ | 517 private void update_aux_string(self, IBusText *preeditIText){ |
517 G_DEBUG_MSG(4,"[I4] update_aux_string() statusFlags=%x", self->_priv->st
atusFlags); | 518 G_DEBUG_MSG(4,"[I4] update_aux_string() statusFlags=%x", self->_priv->st
atusFlags); |
518 IBusText *iText=NULL; | 519 IBusText *iText=NULL; |
519 switch (self->_priv->inputStyle){ | 520 switch (self->_priv->inputStyle){ |
520 case CHEWING_INPUT_STYLE_IN_APPLICATION: | 521 case CHEWING_INPUT_STYLE_IN_APPLICATION: |
521 if (chewing_aux_Length(self->context)>0){ | 522 if (chewing_aux_Length(self->context)>0){ |
522 gchar *aux_string=chewing_aux_String(self->context); | 523 gchar *aux_string=chewing_aux_String(self->context); |
523 iText=ibus_text_new_from_string (aux_string); | |
524 iText=g_object_ref_sink(ibus_text_new_from_string (aux_strin
g)); | 524 iText=g_object_ref_sink(ibus_text_new_from_string (aux_strin
g)); |
525 ibus_engine_update_auxiliary_text(IBUS_ENGINE(self),iText,TR
UE); | 525 ibus_engine_update_auxiliary_text(IBUS_ENGINE(self),iText,TR
UE); |
526 g_object_unref (iText); | 526 g_object_unref (iText); |
527 ibus_engine_show_auxiliary_text(IBUS_ENGINE(self)); | 527 ibus_engine_show_auxiliary_text(IBUS_ENGINE(self)); |
528 g_free(aux_string); | 528 g_free(aux_string); |
529 }else{ | 529 }else{ |
530 ibus_engine_hide_auxiliary_text(IBUS_ENGINE(self)); | 530 ibus_engine_hide_auxiliary_text(IBUS_ENGINE(self)); |
531 } | 531 } |
532 break; | 532 break; |
533 case CHEWING_INPUT_STYLE_IN_CANDIDATE: | 533 case CHEWING_INPUT_STYLE_IN_CANDIDATE: |
(...skipping 14 matching lines...) Expand all Loading... |
548 break; | 548 break; |
549 } | 549 } |
550 G_DEBUG_MSG(5,"[I5] update_preedit(): return"); | 550 G_DEBUG_MSG(5,"[I5] update_preedit(): return"); |
551 } | 551 } |
552 | 552 |
553 protected gboolean update(self){ | 553 protected gboolean update(self){ |
554 G_DEBUG_MSG(3,"[I3] update() statusFlags=%x", self->_priv->statusFlags); | 554 G_DEBUG_MSG(3,"[I3] update() statusFlags=%x", self->_priv->statusFlags); |
555 self_determine_input_mode(self); | 555 self_determine_input_mode(self); |
556 gint chiSymbolCursor; | 556 gint chiSymbolCursor; |
557 glong zhuyin_item_written; | 557 glong zhuyin_item_written; |
| 558 self_commit(self); |
558 gchar *preeditBuf=self_make_preedit_string(self, &zhuyin_item_written); | 559 gchar *preeditBuf=self_make_preedit_string(self, &zhuyin_item_written); |
559 IBusText *iText=self_decorate_preedit(self, preeditBuf, &chiSymbolCursor
, zhuyin_item_written); | 560 IBusText *iText=self_decorate_preedit(self, preeditBuf, &chiSymbolCursor
, zhuyin_item_written); |
560 if (g_object_is_floating(iText)){ | 561 if (g_object_is_floating(iText)){ |
561 g_object_ref_sink(iText); | 562 g_object_ref_sink(iText); |
562 } | 563 } |
563 | 564 |
564 self_update_aux_string(self, iText); | 565 self_update_aux_string(self, iText); |
565 self_update_preedit(self, iText, chiSymbolCursor); | 566 self_update_preedit(self, iText, chiSymbolCursor); |
566 g_object_unref (iText); | 567 g_object_unref (iText); |
567 uint16 *phoneSeq=(chewing_get_phoneSeqLen(self->context)>0)? chewing_get
_phoneSeq(self->context): NULL; | 568 uint16 *phoneSeq=(chewing_get_phoneSeqLen(self->context)>0)? chewing_get
_phoneSeq(self->context): NULL; |
568 G_DEBUG_MSG(4,"[I4] update() inputMode=%d nPhoneSeq=%d statusFlags=%u", | 569 G_DEBUG_MSG(4,"[I4] update() inputMode=%d nPhoneSeq=%d statusFlags=%u", |
569 self->inputMode, | 570 self->inputMode, |
570 chewing_get_phoneSeqLen(self->context), | 571 chewing_get_phoneSeqLen(self->context), |
571 self->_priv->statusFlags); | 572 self->_priv->statusFlags); |
572 if (phoneSeq){ | 573 if (phoneSeq){ |
573 int i=0; | 574 int i=0; |
574 for(i=0;i<chewing_get_phoneSeqLen(self->context);i++){ | 575 for(i=0;i<chewing_get_phoneSeqLen(self->context);i++){ |
575 G_DEBUG_MSG(5,"[I5] update() phoneSeq[%d]=%x",i,phoneSeq[i]); | 576 G_DEBUG_MSG(5,"[I5] update() phoneSeq[%d]=%x",i,phoneSeq[i]); |
576 } | 577 } |
577 free(phoneSeq); | 578 free(phoneSeq); |
578 } | 579 } |
579 self_update_lookup_table(self); | 580 self_update_lookup_table(self); |
580 » self_commit(self); | 581 » //self_commit(self); |
581 gboolean ret=TRUE; | 582 gboolean ret=TRUE; |
582 | 583 |
583 if (chewing_keystroke_CheckAbsorb(self->context)){ | 584 if (chewing_keystroke_CheckAbsorb(self->context)){ |
584 ret=TRUE; | 585 ret=TRUE; |
585 }else if (chewing_keystroke_CheckIgnore(self->context)){ | 586 }else if (chewing_keystroke_CheckIgnore(self->context)){ |
586 ret=FALSE; | 587 ret=FALSE; |
587 } | 588 } |
588 G_DEBUG_MSG(4,"[I4] update() return %s",(ret)? "TRUE": "FALSE"); | 589 G_DEBUG_MSG(4,"[I4] update() return %s",(ret)? "TRUE": "FALSE"); |
589 return ret; | 590 return ret; |
590 } | 591 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 } | 786 } |
786 g_free(str_ptr); | 787 g_free(str_ptr); |
787 G_DEBUG_MSG(3, "[I3] determine_input_mode() return: zhuyin_latest=%s zh
uyin_tone=%d inputMode=%d", | 788 G_DEBUG_MSG(3, "[I3] determine_input_mode() return: zhuyin_latest=%s zh
uyin_tone=%d inputMode=%d", |
788 self->_priv->zhuyin_latest,zhuyin_tone,self->inputMode); | 789 self->_priv->zhuyin_latest,zhuyin_tone,self->inputMode); |
789 } | 790 } |
790 | 791 |
791 /* commit string */ | 792 /* commit string */ |
792 protected gboolean commit(self){ | 793 protected gboolean commit(self){ |
793 gint commit=chewing_commit_Check(self->context); | 794 gint commit=chewing_commit_Check(self->context); |
794 G_DEBUG_MSG(2,"[I2] commit() %s statusFlags=%x", (commit) ? "TRUE": "FAL
SE", self->_priv->statusFlags); | 795 G_DEBUG_MSG(2,"[I2] commit() %s statusFlags=%x", (commit) ? "TRUE": "FAL
SE", self->_priv->statusFlags); |
795 » if (commit && (self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT)){ | 796 » if ((self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT) && commit){ |
796 IBusText *iText=NULL; | 797 IBusText *iText=NULL; |
797 | 798 |
798 gchar *commit_string=chewing_commit_String(self->context); | 799 gchar *commit_string=chewing_commit_String(self->context); |
799 G_DEBUG_MSG(3,"[I3] commit() commit_string=%s", commit_string); | 800 G_DEBUG_MSG(3,"[I3] commit() commit_string=%s", commit_string); |
800 iText=g_object_ref_sink(ibus_text_new_from_string(commit_string)); | 801 iText=g_object_ref_sink(ibus_text_new_from_string(commit_string)); |
801 ibus_engine_commit_text(IBUS_ENGINE(self),iText); | 802 ibus_engine_commit_text(IBUS_ENGINE(self),iText); |
802 g_free(commit_string); | 803 g_free(commit_string); |
803 g_object_unref(iText); | 804 g_object_unref(iText); |
804 » ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_NEED_COMMI
T); | 805 » if (!chewing_buffer_Check(self->context)){ |
| 806 » » /* Buffer is clean */ |
| 807 » » ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_NEED_C
OMMIT | ENGINE_STATUS_FORCE_COMMIT ); |
| 808 » }else if (self->_priv->statusFlags & ENGINE_STATUS_FORCE_COMMIT){ |
| 809 » » /* Flush the buffer */ |
| 810 » » chewing_handle_Enter(self->context); |
| 811 » » commit_string=chewing_commit_String(self->context); |
| 812 » » iText=g_object_ref_sink(ibus_text_new_from_string(commit_string)
); |
| 813 » » ibus_engine_commit_text(IBUS_ENGINE(self),iText); |
| 814 » » g_free(commit_string); |
| 815 » » g_object_unref(iText); |
| 816 » » ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_FORCE_
COMMIT ); |
| 817 » } |
805 } | 818 } |
806 return commit; | 819 return commit; |
807 } | 820 } |
808 | 821 |
809 protected void force_commit(self){ | 822 protected void force_commit(self){ |
810 G_DEBUG_MSG(3,"[I3] force_commit() buffer=%d, commit=%d statusFlags=%x", | 823 G_DEBUG_MSG(3,"[I3] force_commit() buffer=%d, commit=%d statusFlags=%x", |
811 chewing_buffer_Check(self->context),chewing_commit_Check(self->c
ontext), self->_priv->statusFlags); | 824 chewing_buffer_Check(self->context),chewing_commit_Check(self->c
ontext), self->_priv->statusFlags); |
812 /* Remove the incomplete zhuyin symbol */ | 825 /* Remove the incomplete zhuyin symbol */ |
813 if (self->inputMode==CHEWING_INPUT_MODE_EDITING) | 826 if (self->inputMode==CHEWING_INPUT_MODE_EDITING) |
814 chewing_handle_Esc(self->context); | 827 chewing_handle_Esc(self->context); |
815 if (chewing_buffer_Check(self->context)){ | 828 if (chewing_buffer_Check(self->context)){ |
816 if (!chewing_commit_Check(self->context)){ | 829 if (!chewing_commit_Check(self->context)){ |
817 /* Close candidate window */ | 830 /* Close candidate window */ |
818 if (self->_priv->statusFlags & ENGINE_STATUS_SHOW_CANDIDATE){ | 831 if (self->_priv->statusFlags & ENGINE_STATUS_SHOW_CANDIDATE){ |
819 chewing_handle_Esc(self->context); | 832 chewing_handle_Esc(self->context); |
820 } | 833 } |
821 chewing_handle_Enter(self->context); | 834 chewing_handle_Enter(self->context); |
822 } | 835 } |
823 » ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT)
; | 836 » ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT
| ENGINE_STATUS_FORCE_COMMIT); |
824 self_update(self); | 837 self_update(self); |
825 } | 838 } |
826 } | 839 } |
827 | 840 |
828 /*============================================ | 841 /*============================================ |
829 * Overridden Parent (IBusEngine) methods | 842 * Overridden Parent (IBusEngine) methods |
830 */ | 843 */ |
831 override (IBus:Engine) void | 844 override (IBus:Engine) void |
832 reset(IBus:Engine *engine){ | 845 reset(IBus:Engine *engine){ |
833 G_DEBUG_MSG(1,"[I1] reset"); | 846 G_DEBUG_MSG(1,"[I1] reset"); |
834 Self *self=SELF(engine); | 847 Self *self=SELF(engine); |
| 848 if (self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT){ |
| 849 /* Force commit non-empty preedit buffer */ |
| 850 self_force_commit(self); |
| 851 } |
835 ibus_lookup_table_clear(self->table); | 852 ibus_lookup_table_clear(self->table); |
836 /* Save KBType type, becaue chewing_Reset() will reset it to default. | 853 /* Save KBType type, becaue chewing_Reset() will reset it to default. |
837 */ | 854 */ |
838 int kbType=chewing_get_KBType(self->context); | 855 int kbType=chewing_get_KBType(self->context); |
839 chewing_Reset(self->context); | 856 chewing_Reset(self->context); |
840 chewing_set_KBType(self->context,kbType); | 857 chewing_set_KBType(self->context,kbType); |
841 ibus_engine_hide_auxiliary_text(IBUS_ENGINE(engine)); | 858 ibus_engine_hide_auxiliary_text(IBUS_ENGINE(engine)); |
842 ibus_engine_hide_lookup_table(IBUS_ENGINE(self)); | 859 ibus_engine_hide_lookup_table(IBUS_ENGINE(self)); |
843 } | 860 } |
844 | 861 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 IBusProperty *prop=self_get_iBusProperty(self, prop_name); | 1002 IBusProperty *prop=self_get_iBusProperty(self, prop_name); |
986 ibus_property_set_visible(prop,FALSE); | 1003 ibus_property_set_visible(prop,FALSE); |
987 ibus_engine_update_property(engine,prop); | 1004 ibus_engine_update_property(engine,prop); |
988 } | 1005 } |
989 } | 1006 } |
990 | 1007 |
991 %{ | 1008 %{ |
992 #include "IBusChewingEngine-keys.c" | 1009 #include "IBusChewingEngine-keys.c" |
993 %} | 1010 %} |
994 | 1011 |
OLD | NEW |