Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ src/ibus-chewing-lookup-table.c
src/ibus-chewing-preedit.c
src/ibus-chewing-util.c
src/main.c
src/maker-dialog-util.c
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
add_library(common STATIC
ibus-chewing-lookup-table.c
maker-dialog-util.c

ibus-chewing-lookup-table.h
maker-dialog-util.h
ibus-chewing-engine.h
)
target_link_libraries(common PUBLIC
Expand Down
44 changes: 22 additions & 22 deletions src/ibus-chewing-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
* USA.
*/
#include "ibus-chewing-engine.h"
#include "ibus-chewing-preedit.h"
#include "ibus-chewing-engine-private.h"
#include "ibus-chewing-lookup-table.h"
#include "ibus-chewing-preedit.h"
#include "ibus-chewing-util.h"
#include "maker-dialog-util.h"
#include "ibus-chewing-engine-private.h"
#include <chewing.h>
#include <glib.h>
#include <glib/gi18n.h>
Expand Down Expand Up @@ -569,7 +568,7 @@ void ibus_chewing_engine_refresh_property(IBusChewingEngine *self,
#ifndef UNIT_TEST
IBUS_CHEWING_LOG(DEBUG, "refresh_property(%s) status=%x", prop_name, self->statusFlags);

if (STRING_EQUALS(prop_name, "InputMode")) {
if (g_strcmp0(prop_name, "InputMode") == 0) {

ibus_property_set_label(self->InputMode,
ibus_chewing_pre_edit_get_chi_eng_mode(self->icPreEdit)
Expand All @@ -585,7 +584,7 @@ void ibus_chewing_engine_refresh_property(IBusChewingEngine *self,

ibus_engine_update_property(IBUS_ENGINE(self), self->InputMode);

} else if (STRING_EQUALS(prop_name, "AlnumSize")) {
} else if (g_strcmp0(prop_name, "AlnumSize") == 0) {

ibus_property_set_label(self->AlnumSize, chewing_get_ShapeMode(self->icPreEdit->context)
? self->AlnumSize_label_full
Expand All @@ -601,7 +600,7 @@ void ibus_chewing_engine_refresh_property(IBusChewingEngine *self,
if (self->statusFlags & ENGINE_FLAG_PROPERTIES_REGISTERED)
ibus_engine_update_property(IBUS_ENGINE(self), self->AlnumSize);

} else if (STRING_EQUALS(prop_name, "setup_prop")) {
} else if (g_strcmp0(prop_name, "setup_prop") == 0) {
#if IBUS_CHECK_VERSION(1, 5, 0)
ibus_property_set_symbol(self->setup_prop, self->setup_prop_symbol);
#endif
Expand Down Expand Up @@ -650,11 +649,11 @@ static IBusProperty *ibus_chewing_engine_get_ibus_property_by_name(IBusChewingEn
g_return_val_if_fail(self != NULL, (IBusProperty *)0);
g_return_val_if_fail(IBUS_IS_CHEWING_ENGINE(self), (IBusProperty *)0);
{
if (STRING_EQUALS(prop_name, "InputMode")) {
if (g_strcmp0(prop_name, "InputMode") == 0) {
return self->InputMode;
} else if (STRING_EQUALS(prop_name, "AlnumSize")) {
} else if (g_strcmp0(prop_name, "AlnumSize") == 0) {
return self->AlnumSize;
} else if (STRING_EQUALS(prop_name, "setup_prop")) {
} else if (g_strcmp0(prop_name, "setup_prop") == 0) {
return self->setup_prop;
}
IBUS_CHEWING_LOG(MSG, "get_ibus_property_by_name(%s): NULL is returned", prop_name);
Expand Down Expand Up @@ -848,8 +847,8 @@ static void parent_update_pre_edit_text_with_mode([[maybe_unused]] IBusEngine *i
IBusText *iText, guint cursor_pos,
gboolean visible, IBusPreeditFocusMode mode) {
#ifdef UNIT_TEST
printf("# * parent_update_pre_edit_text_with_mode(-, %s, %u, %x, %x)\n", iText->text, cursor_pos,
visible, mode);
printf("# * parent_update_pre_edit_text_with_mode(-, %s, %u, %x, %x)\n", iText->text,
cursor_pos, visible, mode);
#else
ibus_engine_update_preedit_text_with_mode(iEngine, iText, cursor_pos, visible, mode);
#endif
Expand All @@ -858,7 +857,8 @@ static void parent_update_pre_edit_text_with_mode([[maybe_unused]] IBusEngine *i
static void parent_update_auxiliary_text([[maybe_unused]] IBusEngine *iEngine, IBusText *iText,
gboolean visible) {
#ifdef UNIT_TEST
printf("# * parent_update_auxiliary_text(-, %s, %x)\n", (iText) ? iText->text : "NULL", visible);
printf("# * parent_update_auxiliary_text(-, %s, %x)\n", (iText) ? iText->text : "NULL",
visible);
#else
if (!visible || ibus_text_is_empty(iText)) {
ibus_engine_hide_auxiliary_text(iEngine);
Expand Down Expand Up @@ -1017,7 +1017,7 @@ void commit_text(IBusChewingEngine *self) {
gboolean ibus_chewing_engine_process_key_event(IBusEngine *engine, KSym keySym, guint keycode,
KeyModifiers unmaskedMod) {
IBUS_CHEWING_LOG(MSG, "******** process_key_event(-,%x(%s),%x,%x) %s", keySym,
key_sym_get_name(keySym), keycode, unmaskedMod,
ibus_keyval_name(keySym), keycode, unmaskedMod,
modifiers_to_string(unmaskedMod));

IBusChewingEngine *self = IBUS_CHEWING_ENGINE(engine);
Expand Down Expand Up @@ -1081,17 +1081,17 @@ void ibus_chewing_engine_property_activate(IBusEngine *engine, const gchar *prop
IBUS_CHEWING_LOG(INFO, "property_activate(-, %s, %u)", prop_name, prop_state);
IBusChewingEngine *self = IBUS_CHEWING_ENGINE(engine);

if (STRING_EQUALS(prop_name, "InputMode")) {
if (g_strcmp0(prop_name, "InputMode") == 0) {
/* Toggle Chinese <-> English */
ibus_chewing_pre_edit_toggle_chi_eng_mode(self->icPreEdit);
IBUS_CHEWING_LOG(INFO, "property_activate chinese=%d", is_chinese_mode(self));
ibus_chewing_engine_refresh_property(self, prop_name);
} else if (STRING_EQUALS(prop_name, "AlnumSize")) {
} else if (g_strcmp0(prop_name, "AlnumSize") == 0) {
/* Toggle Full <-> Half */
ibus_chewing_pre_edit_toggle_full_half_mode(self->icPreEdit);
IBUS_CHEWING_LOG(INFO, "property_activate fullwidth=%d", is_fullwidth_mode(self));
ibus_chewing_engine_refresh_property(self, prop_name);
} else if (STRING_EQUALS(prop_name, "setup_prop")) {
} else if (g_strcmp0(prop_name, "setup_prop") == 0) {
/* open preferences window */
char *argv[] = {QUOTE_ME(LIBEXEC_DIR) "/ibus-setup-chewing", NULL};
g_spawn_async(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL);
Expand All @@ -1103,16 +1103,16 @@ void ibus_chewing_engine_property_activate(IBusEngine *engine, const gchar *prop

char ibus_chewing_engine_get_default_english_case(IBusChewingEngine *self) {
char *prop = self->prop_default_english_case;
return STRING_EQUALS(prop, "lowercase") ? 'l' : STRING_EQUALS(prop, "uppercase") ? 'u' : 'n';
return g_strcmp0(prop, "lowercase") == 0 ? 'l' : g_strcmp0(prop, "uppercase") == 0 ? 'u' : 'n';
}

char ibus_chewing_engine_get_chinese_english_toggle_key(IBusChewingEngine *self) {
char *prop = self->prop_chi_eng_mode_toggle;
return STRING_EQUALS(prop, "caps_lock") ? 'c'
: STRING_EQUALS(prop, "shift") ? 's'
: STRING_EQUALS(prop, "shift_l") ? 'l'
: STRING_EQUALS(prop, "shift_r") ? 'r'
: 'n';
return g_strcmp0(prop, "caps_lock") == 0 ? 'c'
: g_strcmp0(prop, "shift") == 0 ? 's'
: g_strcmp0(prop, "shift_l") == 0 ? 'l'
: g_strcmp0(prop, "shift_r") == 0 ? 'r'
: 'n';
return 'n';
}

Expand Down
2 changes: 1 addition & 1 deletion src/ibus-chewing-lookup-table.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ibus-chewing-lookup-table.h"
#include "ibus-chewing-util.h"
#include "maker-dialog-util.h"
#include <ctype.h>

IBusLookupTable *ibus_chewing_lookup_table_new(ChewingContext *context) {
guint size = 10;
Expand Down
6 changes: 2 additions & 4 deletions src/ibus-chewing-lookup-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@

IBusLookupTable *ibus_chewing_lookup_table_new(ChewingContext *context);

void ibus_chewing_lookup_table_resize(IBusLookupTable *iTable,
ChewingContext *context);
void ibus_chewing_lookup_table_resize(IBusLookupTable *iTable, ChewingContext *context);

guint ibus_chewing_lookup_table_update(IBusLookupTable *iTable,
ChewingContext *context);
guint ibus_chewing_lookup_table_update(IBusLookupTable *iTable, ChewingContext *context);

#endif /* _IBUS_CHEWING_LOOKUP_TABLE_H_ */
2 changes: 1 addition & 1 deletion src/ibus-chewing-preedit-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

#define handle_log(funcName) \
IBUS_CHEWING_LOG(INFO, "* self_handle_%s(-,%x(%s),%x(%s))", funcName, kSym, \
key_sym_get_name(kSym), unmaskedMod, modifiers_to_string(unmaskedMod));
ibus_keyval_name(kSym), unmaskedMod, modifiers_to_string(unmaskedMod));

KSym self_key_sym_fix(IBusChewingPreEdit *self, KSym kSym, KeyModifiers unmaskedMod);

Expand Down
11 changes: 6 additions & 5 deletions src/ibus-chewing-preedit.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "ibus-chewing-engine.h"
#include "ibus-chewing-preedit.h"
#include "ibus-chewing-engine.h"
#include "ibus-chewing-lookup-table.h"
#include "ibus-chewing-util.h"
#include "maker-dialog-util.h"
#include "ibus-chewing-preedit-private.h"
#include "ibus-chewing-util.h"
#include "ibus.h"
#include <chewing.h>
#include <ctype.h>
#include <glib.h>

/**************************************
Expand Down Expand Up @@ -258,7 +259,7 @@ EventResponse self_handle_key_sym_default(IBusChewingPreEdit *self, KSym kSym,
KSym fixedKSym = self_key_sym_fix(self, kSym, unmaskedMod);

IBUS_CHEWING_LOG(DEBUG, "* self_handle_key_sym_default(): new kSym %x(%s), %x(%s)", fixedKSym,
key_sym_get_name(fixedKSym), unmaskedMod, modifiers_to_string(unmaskedMod));
ibus_keyval_name(fixedKSym), unmaskedMod, modifiers_to_string(unmaskedMod));
gint ret = chewing_handle_Default(self->context, fixedKSym);

/* Handle quick commit */
Expand Down Expand Up @@ -770,7 +771,7 @@ gboolean is_shift_toggle(KSym keyLast, KSym kSym, KeyModifiers unmaskedMod) {
gboolean ibus_chewing_pre_edit_process_key(IBusChewingPreEdit *self, KSym kSym,
KeyModifiers unmaskedMod) {
IBUS_CHEWING_LOG(INFO, "***** ibus_chewing_pre_edit_process_key(-,%x(%s),%x(%s))", kSym,
key_sym_get_name(kSym), unmaskedMod, modifiers_to_string(unmaskedMod));
ibus_keyval_name(kSym), unmaskedMod, modifiers_to_string(unmaskedMod));
process_key_debug("Before response");

/* Find corresponding rule */
Expand Down
33 changes: 13 additions & 20 deletions src/ibus-chewing-preedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ guint ibus_chewing_pre_edit_word_length(IBusChewingPreEdit *self);

guint ibus_chewing_pre_edit_word_limit(IBusChewingPreEdit *self);

#define ibus_chewing_pre_edit_is_empty(self) \
(ibus_chewing_pre_edit_length(self) == 0)
#define ibus_chewing_pre_edit_is_empty(self) (ibus_chewing_pre_edit_length(self) == 0)

#define ibus_chewing_pre_edit_is_full(self) \
#define ibus_chewing_pre_edit_is_full(self) \
(self->wordLen >= ibus_chewing_pre_edit_word_limit(self))

#define ibus_chewing_pre_edit_is_outgoing_empty(self) (self->outgoing->len == 0)
Expand All @@ -129,8 +128,7 @@ gchar *ibus_chewing_pre_edit_get_outgoing(IBusChewingPreEdit *self);

#define ibus_chewing_pre_edit_has_flag(self, f) mkdg_has_flag(self->flags, f)
#define ibus_chewing_pre_edit_set_flag(self, f) mkdg_set_flag(self->flags, f)
#define ibus_chewing_pre_edit_clear_flag(self, f) \
mkdg_clear_flag(self->flags, f)
#define ibus_chewing_pre_edit_clear_flag(self, f) mkdg_clear_flag(self->flags, f)

void ibus_chewing_pre_edit_force_commit(IBusChewingPreEdit *self);
void ibus_chewing_pre_edit_clear(IBusChewingPreEdit *self);
Expand All @@ -141,17 +139,13 @@ void ibus_chewing_pre_edit_clear_outgoing(IBusChewingPreEdit *self);
gboolean ibus_chewing_pre_edit_get_chi_eng_mode(IBusChewingPreEdit *self);
gboolean ibus_chewing_pre_edit_get_full_half_mode(IBusChewingPreEdit *self);

void ibus_chewing_pre_edit_set_chi_eng_mode(IBusChewingPreEdit *self,
gboolean chineseMode);
void ibus_chewing_pre_edit_set_full_half_mode(IBusChewingPreEdit *self,
gboolean fullShapeMode);
void ibus_chewing_pre_edit_set_chi_eng_mode(IBusChewingPreEdit *self, gboolean chineseMode);
void ibus_chewing_pre_edit_set_full_half_mode(IBusChewingPreEdit *self, gboolean fullShapeMode);

#define ibus_chewing_pre_edit_toggle_chi_eng_mode(self) \
ibus_chewing_pre_edit_set_chi_eng_mode( \
self, !ibus_chewing_pre_edit_get_chi_eng_mode(self))
#define ibus_chewing_pre_edit_toggle_full_half_mode(self) \
ibus_chewing_pre_edit_set_full_half_mode( \
self, !ibus_chewing_pre_edit_get_full_half_mode(self))
#define ibus_chewing_pre_edit_toggle_chi_eng_mode(self) \
ibus_chewing_pre_edit_set_chi_eng_mode(self, !ibus_chewing_pre_edit_get_chi_eng_mode(self))
#define ibus_chewing_pre_edit_toggle_full_half_mode(self) \
ibus_chewing_pre_edit_set_full_half_mode(self, !ibus_chewing_pre_edit_get_full_half_mode(self))

gboolean ibus_chewing_pre_edit_process_key(IBusChewingPreEdit *self, KSym kSym,
KeyModifiers unmaskedMod);
Expand All @@ -161,8 +155,7 @@ gboolean ibus_chewing_pre_edit_process_key(IBusChewingPreEdit *self, KSym kSym,
*
* Convert keycode to key_sym.
*/
KSym ibus_chewing_pre_edit_key_code_to_key_sym(IBusChewingPreEdit *self,
KSym keySym, guint keyCode,
KSym ibus_chewing_pre_edit_key_code_to_key_sym(IBusChewingPreEdit *self, KSym keySym, guint keyCode,
KeyModifiers unmaskedMod);

/**
Expand All @@ -175,9 +168,9 @@ gchar *ibus_chewing_pre_edit_get_bopomofo_string(IBusChewingPreEdit *self);

typedef enum {
EVENT_RESPONSE_PROCESS = 0, /* Event process by IM */
EVENT_RESPONSE_ABSORB, /* Event throw away by IM (e.g. Release event) */
EVENT_RESPONSE_IGNORE, /* Event that should be passed to application, but
not process by IM */
EVENT_RESPONSE_ABSORB, /* Event throw away by IM (e.g. Release event) */
EVENT_RESPONSE_IGNORE, /* Event that should be passed to application, but
not process by IM */
EVENT_RESPONSE_UNDECIDED,
} EventResponse;

Expand Down
Loading