static void calculate_status_win() { if (!property_list) { status_bar_win.w = 0; return; } unsigned i, w = 0; for (i = 0; ; i++) { IBusProperty *prop = ibus_prop_list_get(property_list, i); if (!prop) break; w += text_width(prop->label->text); } status_bar_win.x = cursor_x; status_bar_win.y = get_cursor_y() + 2 * WIN_INTERVAL + GAP; status_bar_win.w = FW(w + property_list->properties->len) + 2 * MARGIN; status_bar_win.h = WIN_HEIGHT; if (status_bar_win.x + status_bar_win.w > SW) { if (status_bar_win.w > SW) status_bar_win.x = 0; else status_bar_win.x = SW - status_bar_win.w; } }
static void draw_status_bar() { set_im_window(StatusBarWin, status_bar_win); if (!status_bar_win.w) return; draw_margin(status_bar_win, COLOR_BG); unsigned i, x = status_bar_win.x + MARGIN, y = status_bar_win.y + MARGIN; for (i = 0; ; i++) { IBusProperty *prop = ibus_prop_list_get(property_list, i); if (!prop) break; draw_text(x, y, COLOR_FG, COLOR_BG, prop->label->text, strlen(prop->label->text)); x += FW(text_width(prop->label->text)); char space = ' '; draw_text(x, y, COLOR_FG, COLOR_BG, &space, 1); x += FW(1); } }
static void ibus_unikey_engine_property_activate(IBusEngine* engine, const gchar* prop_name, guint prop_state) { IBusProperty* prop; IBusText* label; guint i, j; unikey = (IBusUnikeyEngine*)engine; // input method active if (strncmp(prop_name, CONFIG_INPUTMETHOD, strlen(CONFIG_INPUTMETHOD)) == 0) { for (i=0; i<NUM_INPUTMETHOD; i++) { if (strcmp(prop_name + strlen(CONFIG_INPUTMETHOD)+1, Unikey_IMNames[i]) == 0) { unikey->im = Unikey_IM[i]; // update label for (j=0; j<unikey->prop_list->properties->len; j++) { prop = ibus_prop_list_get(unikey->prop_list, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_INPUTMETHOD) == 0) { label = ibus_text_new_from_static_string(Unikey_IMNames[i]); ibus_property_set_label(prop, label); break; } } // end update label // update property state for (j=0; j<unikey->menu_im->properties->len; j++) { prop = ibus_prop_list_get(unikey->menu_im, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), prop_name)==0) ibus_property_set_state(prop, PROP_STATE_CHECKED); else ibus_property_set_state(prop, PROP_STATE_UNCHECKED); } // end update property state break; } } } // end input method active // output charset active else if (strncmp(prop_name, CONFIG_OUTPUTCHARSET, strlen(CONFIG_OUTPUTCHARSET)) == 0) { for (i=0; i<NUM_OUTPUTCHARSET; i++) { if (strcmp(prop_name+strlen(CONFIG_OUTPUTCHARSET)+1, Unikey_OCNames[i]) == 0) { unikey->oc = Unikey_OC[i]; // update label for (j=0; j<unikey->prop_list->properties->len; j++) { prop = ibus_prop_list_get(unikey->prop_list, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_OUTPUTCHARSET)==0) { label = ibus_text_new_from_static_string(Unikey_OCNames[i]); ibus_property_set_label(prop, label); break; } } // end update label // update property state for (j=0; j<unikey->menu_oc->properties->len; j++) { prop = ibus_prop_list_get(unikey->menu_oc, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), prop_name) == 0) ibus_property_set_state(prop, PROP_STATE_CHECKED); else ibus_property_set_state(prop, PROP_STATE_UNCHECKED); } // end update property state break; } } } // end output charset active // spellcheck active else if (strcmp(prop_name, CONFIG_SPELLCHECK) == 0) { unikey->ukopt.spellCheckEnabled = !unikey->ukopt.spellCheckEnabled; // update state for (j = 0; j < unikey->menu_opt->properties->len ; j++) { prop = ibus_prop_list_get(unikey->menu_opt, j); if (prop == NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_SPELLCHECK) == 0) { ibus_property_set_state(prop, (unikey->ukopt.spellCheckEnabled == 1)? PROP_STATE_CHECKED:PROP_STATE_UNCHECKED); break; } } // end update state } // end spellcheck active // MacroEnabled active else if (strcmp(prop_name, CONFIG_MACROENABLED) == 0) { unikey->ukopt.macroEnabled = !unikey->ukopt.macroEnabled; // update state for (j = 0; j < unikey->menu_opt->properties->len ; j++) { prop = ibus_prop_list_get(unikey->menu_opt, j); if (prop == NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_MACROENABLED) == 0) { ibus_property_set_state(prop, (unikey->ukopt.macroEnabled == 1)? PROP_STATE_CHECKED:PROP_STATE_UNCHECKED); break; } } // end update state } // end MacroEnabled active // MouseCapture active else if (strcmp(prop_name, CONFIG_MOUSECAPTURE) == 0) { unikey->mouse_capture = !unikey->mouse_capture; // update state for (j = 0; j < unikey->menu_opt->properties->len ; j++) { prop = ibus_prop_list_get(unikey->menu_opt, j); if (prop == NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_MOUSECAPTURE) == 0) { ibus_property_set_state(prop, (unikey->mouse_capture == 1)? PROP_STATE_CHECKED:PROP_STATE_UNCHECKED); break; } } // end update state } // end MouseCapture active // if Run setup else if (strcmp(prop_name, "RunSetupGUI") == 0) { system(LIBEXECDIR "/ibus-setup-unikey &"); } // END Run setup ibus_unikey_engine_reset(engine); UnikeySetInputMethod(unikey->im); UnikeySetOutputCharset(unikey->oc); UnikeySetOptions(&unikey->ukopt); }