Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: src/IBusChewingEngine.gob

Issue 2899003: Add signal handlers to ibus-chewing to listen for config changes. (Closed) Base URL: ssh://gitrw.chromium.org/ibus-chewing.git
Patch Set: Code Review fixes Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IBusChewingEngine-keys.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 #endif /* IBUS_1_1 */ 135 #endif /* IBUS_1_1 */
136 136
137 #define G_DEBUG_MSG(level, msg, args...) if (level<=ibus_chewing_verbose) g_debu g(msg, ##args) 137 #define G_DEBUG_MSG(level, msg, args...) if (level<=ibus_chewing_verbose) g_debu g(msg, ##args)
138 %} 138 %}
139 139
140 %privateheader{ 140 %privateheader{
141 gboolean ibus_chewing_engine_process_key_event(IBusEngine *engine, 141 gboolean ibus_chewing_engine_process_key_event(IBusEngine *engine,
142 guint keyval, guint modifiers); 142 guint keyval, guint modifiers);
143 void ibus_chewing_engine_candidate_clicked(IBusEngine *engine, guint index, 143 void ibus_chewing_engine_candidate_clicked(IBusEngine *engine, guint index,
144 guint button, guint state); 144 guint button, guint state);
145 void ibus_config_value_changed(IBusConfig *config, const gchar *section,
146 const gchar *name, GValue *value, gpointer userData);
145 147
146 #ifndef IBUS_1_1 148 #ifndef IBUS_1_1
147 gboolean ibus_chewing_engine_process_key_event_1_2(IBusEngine *engine, 149 gboolean ibus_chewing_engine_process_key_event_1_2(IBusEngine *engine,
148 guint keyval_ignore, guint keycode, guint modifiers); 150 guint keyval_ignore, guint keycode, guint modifiers);
149 151
150 #endif /* IBUS_1_1 */ 152 #endif /* IBUS_1_1 */
151 %} 153 %}
152 154
153 %{ 155 %{
154 extern gboolean ibus_chewing_verbose; 156 extern gboolean ibus_chewing_verbose;
155 //extern IBusConfig *iConfig; 157 extern IBusConfig *iConfig;
156 158
157 #define IBUS_CHEWING_MAIN 159 #define IBUS_CHEWING_MAIN
158 #include "IBusChewingEngine-def.c" 160 #include "IBusChewingEngine-def.c"
159 161
160 #ifndef IBUS_1_3 162 #ifndef IBUS_1_3
161 IBusKeymap *ibus_keymap_get(gchar *keymap_name){ 163 IBusKeymap *ibus_keymap_get(gchar *keymap_name){
162 #ifdef IBUS_1_1 164 #ifdef IBUS_1_1
163 return NULL; 165 return NULL;
164 #endif /* IBUS_1_1 */ 166 #endif /* IBUS_1_1 */
165 #ifdef IBUS_1_2 167 #ifdef IBUS_1_2
(...skipping 21 matching lines...) Expand all
187 189
188 private guint statusFlags=0; 190 private guint statusFlags=0;
189 191
190 /* For easy symbol input work around */ 192 /* For easy symbol input work around */
191 private ChewingInputStyle inputStyle; 193 private ChewingInputStyle inputStyle;
192 194
193 protected IBusLookupTable *table=NULL 195 protected IBusLookupTable *table=NULL
194 destroywith ibus_lookup_table_clear; 196 destroywith ibus_lookup_table_clear;
195 protected guint tableCursor=0; 197 protected guint tableCursor=0;
196 protected gboolean tableVisible=FALSE; 198 protected gboolean tableVisible=FALSE;
199 protected gulong handler_id = 0;
197 200
198 public IBusProperty *chieng_prop={ 201 public IBusProperty *chieng_prop={
199 g_object_ref_sink ( 202 g_object_ref_sink (
200 ibus_property_new("chewing_chieng_prop",PROP_TYPE_NORMAL, 203 ibus_property_new("chewing_chieng_prop",PROP_TYPE_NORMAL,
201 SELF_GET_CLASS(self)->chieng_prop_label_chi, 204 SELF_GET_CLASS(self)->chieng_prop_label_chi,
202 NULL, NULL, TRUE, TRUE, 205 NULL, NULL, TRUE, TRUE,
203 PROP_STATE_UNCHECKED, NULL)) 206 PROP_STATE_UNCHECKED, NULL))
204 } 207 }
205 destroywith g_object_unref; 208 destroywith g_object_unref;
206 209
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 271
269 class_init(klass){ 272 class_init(klass){
270 #ifdef IBUS_1_1 273 #ifdef IBUS_1_1
271 ibus_engine_class->process_key_event = ibus_chewing_engine_process_key_e vent; 274 ibus_engine_class->process_key_event = ibus_chewing_engine_process_key_e vent;
272 #else 275 #else
273 ibus_engine_class->process_key_event = ibus_chewing_engine_process_key_e vent_1_2; 276 ibus_engine_class->process_key_event = ibus_chewing_engine_process_key_e vent_1_2;
274 #endif /* IBUS_1_1 */ 277 #endif /* IBUS_1_1 */
275 ibus_engine_class->candidate_clicked = ibus_chewing_engine_candidate_cli cked; 278 ibus_engine_class->candidate_clicked = ibus_chewing_engine_candidate_cli cked;
276 } 279 }
277 280
281 override (G:Object) void
282 finalize (G:Object *gobject){
283 Self *self=SELF(gobject);
284 G_DEBUG_MSG(1,"[I1] finalize()");
285 if (self->config && self->handler_id) {
286 g_signal_handler_disconnect(self->config, self->handler_id);
287 }
288 }
289
278 private void load_setting(self){ 290 private void load_setting(self){
279 #define BUFFER_SIZE_LOCAL 200 291 #define BUFFER_SIZE_LOCAL 200
280 G_DEBUG_MSG(3,"[I3] load_setting()"); 292 G_DEBUG_MSG(3,"[I3] load_setting()");
281 int i; 293 int i;
282 //gchar buf[BUFFER_SIZE_LOCAL]; 294 //gchar buf[BUFFER_SIZE_LOCAL];
283 PropertyContext context = {NULL, self}; 295 PropertyContext context = {NULL, self};
284 296
285 for (i=0; propSpecs[i].valueType!=G_TYPE_INVALID;i++){ 297 for (i=0; propSpecs[i].valueType!=G_TYPE_INVALID;i++){
286 GValue gValue={0}; 298 GValue gValue={0};
287 299
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 } 775 }
764 ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT) ; 776 ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT) ;
765 chewing_handle_Default(self->context, keys[index]); 777 chewing_handle_Default(self->context, keys[index]);
766 chewing_free(keys); 778 chewing_free(keys);
767 self_update(self); 779 self_update(self);
768 } else { 780 } else {
769 G_DEBUG_MSG(3,"[I3] handle_cadidate_clicked() ... Wrong mode: %u", s elf->inputMode); 781 G_DEBUG_MSG(3,"[I3] handle_cadidate_clicked() ... Wrong mode: %u", s elf->inputMode);
770 } 782 }
771 } 783 }
772 784
785 protected void handle_config_value_changed(self, const gchar *section, const gchar *name, GValue *value){
786 int i;
787 PropertyContext context = {NULL, self};
788 G_DEBUG_MSG(4,"[I4] handle_config_value_changed(), section=%s, name=%s" ,section,name);
789 // Filter out config values that don't apply to chewing.
790 if (strcmp(section, "engine/Chewing")) {
791 return;
792 }
793
794 // Search through the property definitions to see if we use this value.
795 for (i=0; propSpecs[i].valueType!=G_TYPE_INVALID;i++){
796 if (0 == strcmp(propSpecs[i].key, name)){
797 // Call the assignment function associated with the config value .
798 propSpecs[i].setFunc(&context, value);
799 return;
800 }
801 }
802 }
803
773 protected int current_num_candidate(self){ 804 protected int current_num_candidate(self){
774 if (chewing_cand_TotalChoice(self->context) >= 805 if (chewing_cand_TotalChoice(self->context) >=
775 (chewing_cand_CurrentPage(self->context)+1) * chewing_cand_ChoicePer Page(self->context)) { 806 (chewing_cand_CurrentPage(self->context)+1) * chewing_cand_ChoicePer Page(self->context)) {
776 return chewing_cand_ChoicePerPage(self->context); 807 return chewing_cand_ChoicePerPage(self->context);
777 } else { 808 } else {
778 return chewing_cand_TotalChoice(self->context) % chewing_cand_Choice PerPage(self->context); 809 return chewing_cand_TotalChoice(self->context) % chewing_cand_Choice PerPage(self->context);
779 } 810 }
780 } 811 }
781 812
782 protected void cursor_prev(self){ 813 protected void cursor_prev(self){
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 self_update(self); 996 self_update(self);
966 } 997 }
967 } 998 }
968 999
969 override (IBus:Engine) void 1000 override (IBus:Engine) void
970 enable(IBus:Engine *engine){ 1001 enable(IBus:Engine *engine){
971 G_DEBUG_MSG(2,"[I2] enable()"); 1002 G_DEBUG_MSG(2,"[I2] enable()");
972 Self *self=SELF(engine); 1003 Self *self=SELF(engine);
973 1004
974 if (!self->config){ 1005 if (!self->config){
975 1006 » self->config=iConfig;
976 /* connections_list is not avail in init, so we put it here */
977 » GList *connections_list=ibus_service_get_connections(IBUS_SERVICE(e ngine));
978 » g_assert(connections_list);
979 » g_assert(connections_list->data);
980 » IBusConnection *iConnection=(IBusConnection *) connections_list->dat a;
981 » self->config=ibus_config_new(iConnection);
982 self_load_setting(self); 1007 self_load_setting(self);
983 } 1008 }
1009 if (!self->handler_id) {
1010 // Watch the ibus config service for config changes. If one of chew ing's values
1011 // changes, the local state needs to be updated to match.
1012 self->handler_id = g_signal_connect(self->config, "value-changed",
1013 G_CALLBACK(ibus_config_value_changed), self);
1014 }
1015 G_DEBUG_MSG(2,"[I2] enable() config = %x handler_id = %d", self->config, self->handler_id);
984 self_refresh_property_list(self); 1016 self_refresh_property_list(self);
985 self->inputMode=CHEWING_INPUT_MODE_SELECTING_DONE; 1017 self->inputMode=CHEWING_INPUT_MODE_SELECTING_DONE;
986 ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_ENABLED); 1018 ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_ENABLED);
987 } 1019 }
988 1020
989 override (IBus:Engine) void 1021 override (IBus:Engine) void
990 disable(IBus:Engine *engine){ 1022 disable(IBus:Engine *engine){
991 G_DEBUG_MSG(2,"[I2] disable()"); 1023 G_DEBUG_MSG(2,"[I2] disable()");
992 Self *self=SELF(engine); 1024 Self *self=SELF(engine);
993 self_force_commit(self); 1025 self_force_commit(self);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 IBusProperty *prop=self_get_iBusProperty(self, prop_name); 1112 IBusProperty *prop=self_get_iBusProperty(self, prop_name);
1081 ibus_property_set_visible(prop,FALSE); 1113 ibus_property_set_visible(prop,FALSE);
1082 ibus_engine_update_property(engine,prop); 1114 ibus_engine_update_property(engine,prop);
1083 } 1115 }
1084 } 1116 }
1085 1117
1086 %{ 1118 %{
1087 #include "IBusChewingEngine-keys.c" 1119 #include "IBusChewingEngine-keys.c"
1088 %} 1120 %}
1089 1121
OLDNEW
« no previous file with comments | « no previous file | src/IBusChewingEngine-keys.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698