void load_config (const ConfigPointer& config)
{
    //Don't parse null configurations
    if (!config)
	return;

    //Read option 1: burmese_numerals
    String str = config->read(String(SCIM_CONFIG_IMENGINE_WAITZAR_BURMESE_NUMERALS), String(__burmese_numerals_config_string[0]));
    __config_burmese_numerals = __burmese_numerals_config_vals[0];
    for (int i=0; i<__burmese_numerals_config_opts; i++) {
        if (str == __burmese_numerals_config_string[i])
            __config_burmese_numerals = __burmese_numerals_config_vals[i];
    }

    //Read option 2: default_encoding
    str = config->read(String(SCIM_CONFIG_IMENGINE_WAITZAR_DEFAULT_ENCODING), String(__default_encoding_config_string[0]));
    __config_default_encoding = __default_encoding_config_vals[0];
    for (int i=0; i<__default_encoding_config_opts; i++) {
        if (str == __default_encoding_config_string[i])
            __config_default_encoding = __default_encoding_config_vals[i];
    }

    //Reset the radio buttons
    setup_widget_value ();
}
Ejemplo n.º 2
0
void
HangulFactory::reload_config(const ConfigPointer &config)
{
    if (config.null())
	return;

    m_show_candidate_comment = config->read(String(SCIM_CONFIG_SHOW_CANDIDATE_COMMENT),
					    m_show_candidate_comment);

    m_keyboard_layout = config->read(String(SCIM_CONFIG_LAYOUT), String("2"));

    m_use_ascii_mode = config->read(String(SCIM_CONFIG_USE_ASCII_MODE),
				    false);
    m_commit_by_word = config->read(String(SCIM_CONFIG_COMMIT_BY_WORD),
				    false);
    m_hanja_mode = config->read(String(SCIM_CONFIG_HANJA_MODE),
				    false);

    String str;
    str = config->read(String(SCIM_CONFIG_HANGUL_KEY),
		       String("Hangul,Shift+space"));
    scim_string_to_key_list(m_hangul_keys, str);

    str = config->read(String (SCIM_CONFIG_HANJA_KEY),
		       String ("Hangul_Hanja,F9"));
    scim_string_to_key_list(m_hanja_keys, str);

    str = config->read(String (SCIM_CONFIG_HANJA_MODE_KEY),
		       String (""));
    scim_string_to_key_list(m_hanja_mode_keys, str);

    m_lookup_table_vertical = config->read(String(SCIM_CONFIG_PANEL_LOOKUP_TABLE_VERTICAL),
					   false);
}
Ejemplo n.º 3
0
void ScimBridgeAgentImpl::slot_reload_config (const ConfigPointer &config)
{
    scim_bridge_pdebugln (8, "slot_reload_config ()");

    scim_frontend_hotkey_matcher.load_hotkeys (scim_config);
    scim_imengine_hotkey_matcher.load_hotkeys (scim_config);
    
    KeyEvent key;
    scim_string_to_key (key,
        config->read (String (SCIM_CONFIG_HOTKEYS_FRONTEND_VALID_KEY_MASK),
                      String ("Shift+Control+Alt+Lock")));

    int key_mask = (key.mask > 0) ? key.mask : 0xFFFF;
    key_mask |= SCIM_KEY_ReleaseMask;
    // Special treatment for two backslash keys on jp106 keyboard.
    key_mask |= SCIM_KEY_QuirkKanaRoMask;
    
    valid_key_mask = key_mask;

    ScimBridgeAgentIMContext::set_enabled_by_default (scim_config->read (String (SCIM_CONFIG_FRONTEND_IM_OPENED_BY_DEFAULT), ScimBridgeAgentIMContext::is_enabled_by_default ()));
    ScimBridgeAgentIMContext::set_imengine_shared (scim_config->read (String (SCIM_CONFIG_FRONTEND_SHARED_INPUT_METHOD), ScimBridgeAgentIMContext::is_imengine_shared ()));
    ScimBridgeAgentIMContext::set_on_the_spot_enabled (scim_config->read (String (SCIM_CONFIG_FRONTEND_ON_THE_SPOT), ScimBridgeAgentIMContext::is_on_the_spot_enabled ()));

    // Get keyboard layout setting
    // Flush the global config first, in order to load the new configs from disk.
    scim_global_config_flush ();

    scim_keyboard_layout = scim_get_default_keyboard_layout ();

    // Hot key name, hot key config key.
    // ! Update hotkey_list_length according to updated list length.
    int hotkey_list_length = 6;
    String hotkey_list[][2] = {
        { "Toggle on/off - ", "/Hotkeys/FrontEnd/Trigger" },
        { "Turn on - ", "/Hotkeys/FrontEnd/On" },
        { "Turn off - ", "/Hotkeys/FrontEnd/Off" },
        { "Next input method - ", "/Hotkeys/FrontEnd/NextFactory" },
        { "Previous input method - ", "/Hotkeys/FrontEnd/PreviousFactory" },
        { "Show input method menu - ", "/Hotkeys/FrontEnd/ShowFactoryMenu" }
    };
                           
    // Undefined hot keys are hidden from help window.
    String help_hotkeys = "\nGlobal Hotkeys:";
    for ( int i = 0; i < hotkey_list_length; i++ ) {
        String tmp_hotkeys = scim_config->read (String (hotkey_list[i][1]), String (""));
        if ( tmp_hotkeys != "" )
            help_hotkeys += "\n" + hotkey_list[i][0] + "<" + tmp_hotkeys + ">";
    }
    ScimBridgeAgentIMContext::set_help_hotkeys (help_hotkeys);
}
Ejemplo n.º 4
0
static void
load_config (const ConfigPointer &config)
{
    if (!config.null ()) {
    //    __config_use_kana =
    //        config->read (String (SCIM_CONFIG_IMENGINE_ANTHY_USE_KANA),
    //                      __config_use_kana);
        __config_server =
            config->read (String (SCIM_CONFIG_WNN_SERVER),
                          __config_server);
        __config_wnn_rc =
            config->read (String (SCIM_CONFIG_WNN_RC),
                          __config_wnn_rc);
        __config_servertype =
            config->read (String (SCIM_CONFIG_WNN_SERVERTYPE),
                          __config_servertype);
        __config_preeditor =
            config->read (String (SCIM_CONFIG_WNN_DEFAULT_PREEDITOR),
                          __config_preeditor);
        __config_alp =
            config->read (String (SCIM_CONFIG_WNN_ALP),
                          __config_alp);
        __config_numkeyselect =
            config->read (String (SCIM_CONFIG_WNN_NUMKEY_SELECT),
                          __config_numkeyselect);
        __config_autoconversion =
            config->read (String (SCIM_CONFIG_WNN_AUTO_CONVERSION),
                          __config_autoconversion);
        __config_yosoku =
            config->read (String (SCIM_CONFIG_WNN_YOSOKU),
                          __config_yosoku);
        __config_romkan_table =
            config->read (String (SCIM_CONFIG_WNN_ROMKAN_TABLE_FILE),
                          __config_romkan_table);

        for (unsigned int j = 0; j < __key_conf_pages_num; j++) {
            for (unsigned int i = 0; __key_conf_pages[j].data[i].key; ++ i) {
                __key_conf_pages[j].data[i].data =
                    config->read (String (__key_conf_pages[j].data[i].key),
                                  __key_conf_pages[j].data[i].data);
            }
        }

        setup_widget_value ();

        __have_changed = false;
    }
}
Ejemplo n.º 5
0
void
romaji_page_load_config (const ConfigPointer &config)
{
    __config_romaji_theme_file
        = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_THEME_FILE),
                        String (SCIM_ANTHY_CONFIG_ROMAJI_THEME_FILE_DEFAULT));
    setup_romaji_page ();
}
Ejemplo n.º 6
0
void
ArrayFactory::reload_config(const ConfigPointer &config)
{
    if (config.null())
        return;

    String str;
    str = config->read(String(SCIM_CONFIG_IMENGINE_ARRAY_ENCHKEY),
                    String(""));
    scim_string_to_key_list(m_ench_key, str);

    str = config->read(String(SCIM_CONFIG_IMENGINE_ARRAY_HFKEY),
                    String("Shift+space"));
    scim_string_to_key_list(m_full_half_key, str);

    m_show_special = config->read(String(SCIM_CONFIG_IMENGINE_ARRAY_SHOW_SPECIAL),
                    false);

    m_special_code_only = config->read(String(SCIM_CONFIG_IMENGINE_ARRAY_SPECIAL_CODE_ONLY),
                    false);
}
Ejemplo n.º 7
0
void
FrontEndHotkeyMatcher::load_hotkeys (const ConfigPointer &config)
{
    clear ();

    if (config.null () || !config->valid ()) return;

    KeyEventList keys;

    // Load the least important hotkeys first.
    for (int i = SCIM_FRONTEND_HOTKEY_SHOW_FACTORY_MENU; i >= SCIM_FRONTEND_HOTKEY_TRIGGER; --i) {
        if (scim_string_to_key_list (keys, config->read (String (__scim_frontend_hotkey_config_paths [i]), String (__scim_frontend_hotkey_defaults [i]))))
            m_impl->m_matcher.add_hotkeys (keys, i);
    }
}
Ejemplo n.º 8
0
void
IMEngineHotkeyMatcher::load_hotkeys (const ConfigPointer &config)
{
    clear ();

    if (config.null () || !config->valid ()) return;

    std::vector <String> uuids;

    scim_split_string_list (uuids, config->read (String (SCIM_CONFIG_HOTKEYS_IMENGINE_LIST), String ("")));

    std::sort (uuids.begin (), uuids.end ());
    uuids.erase (std::unique (uuids.begin (), uuids.end ()), uuids.end ());

    if (uuids.size ()) {
        KeyEventList keys;
        for (std::vector <String>::iterator uit = uuids.begin (); uit != uuids.end (); ++uit) {
            if (scim_string_to_key_list (keys, config->read (String (SCIM_CONFIG_HOTKEYS_IMENGINE "/") + *uit, String ("")))) {
                m_impl->m_matcher.add_hotkeys (keys, (int) m_impl->m_uuids.size ());
                m_impl->m_uuids.push_back (*uit);
            }
        }
    }
}
Ejemplo n.º 9
0
/**
 * @brief Get keyboard ISE
 *
 * @param ise_uuid The keyboard ISE uuid.
 * @param ise_name The keyboard ISE name.
 */
void isf_get_keyboard_ise (String &ise_uuid, String &ise_name, const ConfigPointer &config)
{
    String language = String ("~other");
    String uuid     = config->read (String (SCIM_CONFIG_DEFAULT_IMENGINE_FACTORY) + String ("/") + language, String ("d75857a5-4148-4745-89e2-1da7ddaf7999"));
    if (ise_uuid.length () > 0)
        uuid = ise_uuid;
    for (unsigned int i = 0; i < _uuids.size (); i++) {
        if (uuid == _uuids[i]) {
            ise_name = _names[i];
            ise_uuid = uuid;
            return;
        }
    }
    ise_name = String ("");
    ise_uuid = String ("");
}
Ejemplo n.º 10
0
// implementation of Array
ArrayFactory::ArrayFactory (const ConfigPointer &config) 
    : m_status_property (SCIM_PROP_STATUS, "English/Chinese Input"),
      m_letter_property (SCIM_PROP_LETTER, "Full/Half Letter"),
      m_use_phrases(config->read(
                  String(SCIM_CONFIG_IMENGINE_ARRAY_USE_PHRASES), false))
{
    m_config = config;

    SCIM_DEBUG_IMENGINE(2) << "Start loading scim-array module\n";

    SCIM_DEBUG_IMENGINE(2) << "scim-array: start loading array30.cin from " << SCIM_ARRAY_MAIN_CIN_TABLE << "\n";
    arrayCins[0] = new ArrayCIN((char*)SCIM_ARRAY_MAIN_CIN_TABLE);

    SCIM_DEBUG_IMENGINE(2) << "scim-array: start loading array-shortcode.cin from " << SCIM_ARRAY_SHORT_CODE_CIN_TABLE << "\n";
    arrayCins[1] = new ArrayCIN((char*)SCIM_ARRAY_SHORT_CODE_CIN_TABLE);

    SCIM_DEBUG_IMENGINE(2) << "scim-array: start loading array-special.cin from " << SCIM_ARRAY_SPECIAL_CIN_TABLE << "\n";
    arrayCins[2] = new ArrayCIN((char*)SCIM_ARRAY_SPECIAL_CIN_TABLE, true);

    SCIM_DEBUG_IMENGINE(2) << "scim-array: start loading array-phrases.cin from " << SCIM_ARRAY_PHRASE_CIN_TABLE << "\n";
    if (m_use_phrases)
    {
        arrayCins[3] = new ArrayCIN((char*)SCIM_ARRAY_PHRASE_CIN_TABLE, false, false);
        load_user_phrases();
    }
    else
        arrayCins[3] = NULL;


    m_status_property.set_tip(_("The status of the current input method. Click to change it."));
    m_letter_property.set_tip(_("The input mode of the letters. Click to toggle between half and full."));

    reload_config(config);

    m_reload_signal_connection = m_config->signal_connect_reload(slot(this, &ArrayFactory::reload_config));
}
void load_config( const ConfigPointer &config )
{
	if (!config.null ()) {
		__config_add_phrase_forward =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_ADD_PHRASE_FORWARD ),
				__config_add_phrase_forward );

		__config_phrase_choice_rearward =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_PHRASE_CHOICE_REARWARD ),
				__config_phrase_choice_rearward );

		__config_auto_shift_cursor =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_AUTO_SHIFT_CURSOR ),
				__config_auto_shift_cursor );

		__config_esc_clean_all_buffer =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_ESC_CLEAN_ALL_BUFFER ),
				__config_esc_clean_all_buffer );

		__config_space_as_selection =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_SPACE_AS_SELECTION ),
				__config_space_as_selection );

		__config_kb_type_data = 
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_USER_KB_TYPE ),
				__config_kb_type_data);

		__config_selKey_type_data =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_USER_SELECTION_KEYS ),
					__config_selKey_type_data);

		__config_selKey_num_data =
			config->read( String( SCIM_CHEWING_SELECTION_KEYS_NUM ),
					__config_selKey_num_data);

		__config_chieng_mode_data =
			config->read( String( SCIM_CONFIG_IMENGINE_CHEWING_CHI_ENG_MODE ),
					__config_chieng_mode_data);


		for (int i = 0; __config_keyboards[ i ].key; ++ i) {
			__config_keyboards[ i ].data =
				config->read( String( __config_keyboards [ i ].key ),
						__config_keyboards[ i ].data);
		}

		for (unsigned int i = 0;
		     i < (sizeof(config_color_common) / sizeof((config_color_common)[0])); i++) {
			ColorConfigData &entry = config_color_common[i];
			entry.bg_value = config->read (String (entry.bg_key), entry.bg_value);
		}

		setup_widget_value ();

		__have_changed = false;
	}
}
Ejemplo n.º 12
0
static Evas_Object *isf_setting_main_view_tizen(ug_data * ugd)
{
   String tmpStr = _config->read(SCIM_CONFIG_DEFAULT_HELPER_ISE,String("b70bf6cc-ff77-47dc-a137-60acc32d1e0c"));
   snprintf (_active_ise_name, sizeof (_active_ise_name), "%s", (uuid_to_name(tmpStr)).c_str());
   snprintf (ise_bak, sizeof (ise_bak), "%s", _active_ise_name);
   LOGD("Default ISE Name : %s", ise_bak);

    ugd->naviframe = _create_naviframe_layout (ugd->layout_main);
    char *navi_btn_l_lable = NULL;
    char *navi_btn_r_lable = NULL;
    service_get_extra_data(ugd->data, "navi_btn_left",&navi_btn_l_lable);
    service_get_extra_data(ugd->data, "navi_btn_right",&navi_btn_r_lable);
    if (sw_radio_grp != NULL)
    {
        evas_object_del(sw_radio_grp);
        sw_radio_grp = NULL;
    }

    Evas_Object *genlist = elm_genlist_add(ugd->naviframe);
    elm_object_style_set(genlist, "dialogue");
    evas_object_show(genlist);

    Elm_Object_Item *nf_it;
    Evas_Object *cbar = elm_toolbar_add (ugd->naviframe);
    elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
    if (cbar == NULL) return NULL;

    if (navi_btn_l_lable!= NULL) {
        elm_toolbar_item_append(cbar, NULL, navi_btn_l_lable, sw_keyboard_selection_view_back_cb, ugd);
        elm_toolbar_item_append(cbar, NULL, navi_btn_r_lable, sw_keyboard_selection_view_set_cb, ugd);

        nf_it = elm_naviframe_item_push(ugd->naviframe, T_("Keyboard"), NULL, NULL, genlist, NULL);
        elm_object_item_part_content_set(nf_it, "controlbar", cbar);
    }
    else {
        elm_toolbar_item_append(cbar, NULL, navi_btn_r_lable, sw_keyboard_selection_view_set_cb, ugd);
        nf_it = elm_naviframe_item_push(ugd->naviframe, T_("Keyboard"), NULL, NULL, genlist, NULL);
        elm_object_item_part_content_set(nf_it, "controlbar", cbar);
    }

    if (navi_btn_l_lable!= NULL)
        free(navi_btn_l_lable);
    if (navi_btn_r_lable!= NULL)
        free(navi_btn_r_lable);
    unsigned int i = 0;

    sw_iselist.clear();
    std::vector<String> selected_langs, all_langs;

    isf_get_all_languages (all_langs);
    isf_get_helper_names_in_languages (all_langs, sw_iselist);
    std::sort (sw_iselist.begin (), sw_iselist.end ());

    if (sw_iselist.size () > 0) {
        // Set item class for dialogue group seperator
        itcSeparator.item_style = "dialogue/separator/21/with_line";
        itcSeparator.func.text_get = NULL;
        itcSeparator.func.content_get = NULL;
        itcSeparator.func.state_get = NULL;
        itcSeparator.func.del = NULL;

        //separator
        Elm_Object_Item *item;
        item = elm_genlist_item_append(
                    genlist,                // genlist object
                    &itcSeparator,          // item class
                    NULL,                   // data
                    NULL,
                    ELM_GENLIST_ITEM_NONE,
                    NULL,
                    NULL);
        elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
    }

    for (i = 0; i < sw_iselist.size (); i++) {
        if (strcmp (_active_ise_name, sw_iselist[i].c_str ()) == 0) {
            mark = i;
            break;
        }
    }

    //set item class for 1text.1icon(text+radiobutton)
    itc1.item_style = "dialogue/1text.1icon.2";
    itc1.func.text_get = _gl_label_get;
    itc1.func.content_get = _gl_icon_get;
    itc1.func.state_get = _gl_state_get;
    itc1.func.del = _gl_del;
    for (i = 0;i < sw_iselist.size();i++) {
        elm_genlist_item_append(genlist, &itc1,
                    (void *)(i), NULL, ELM_GENLIST_ITEM_NONE, _gl_sel,
                    (void *)(i));
    }

    return ugd->naviframe;
}
    void
load_config (const ConfigPointer &config)
{
    if (!config.null ()) {
        __config_toolbar_auto_snap =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_AUTO_SNAP),
                    __config_toolbar_auto_snap);
        __config_toolbar_hide_timeout =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_HIDE_TIMEOUT),
                    __config_toolbar_hide_timeout);
        __config_toolbar_show_factory_icon =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_SHOW_FACTORY_ICON),
                    __config_toolbar_show_factory_icon);
        __config_toolbar_show_factory_name =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_SHOW_FACTORY_NAME),
                    __config_toolbar_show_factory_name);
        __config_toolbar_show_menu_icon =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_SHOW_MENU_ICON),
                    __config_toolbar_show_menu_icon);
        __config_toolbar_show_help_icon =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_SHOW_HELP_ICON),
                    __config_toolbar_show_help_icon);
        __config_toolbar_show_property_label =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_TOOLBAR_SHOW_PROPERTY_LABEL),
                    __config_toolbar_show_property_label);
        __config_font =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_FONT),
                    __config_font);
        __config_vkb_program = 
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_VKB_PROGRAM),
                    __config_vkb_program);
        __config_vkb_parameters = 
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_VKB_PARAMETERS),
                    __config_vkb_parameters);
        __config_vkb_window_width = 
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_VKB_WIDTH),
                    __config_vkb_window_width);
        __config_vkb_window_height = 
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_VKB_HEIGHT),
                    __config_vkb_window_height);
        __config_vkb_dockpanel = 
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_DOCK_PANEL),
                    __config_vkb_dockpanel);
        __config_vkb_panel_extend = 
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_PANEL_EXTEND),
                    __config_vkb_panel_extend);
        __config_vkb_enable =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_ENABLE_VKB),
                    __config_vkb_enable);
        __config_vkb_panel_normal_text_color =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_PANEL_NORMAL_TEXT_COLOR),
                    __config_vkb_panel_normal_text_color);
        __config_vkb_panel_normal_bg_color =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_PANEL_NORMAL_BG_COLOR),
                    __config_vkb_panel_normal_bg_color);
        __config_vkb_panel_active_text_color =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_PANEL_ACTIVE_TEXT_COLOR),
                    __config_vkb_panel_active_text_color);
        __config_vkb_panel_active_bg_color =
            config->read (String (SCIM_CONFIG_PANEL_VKB_GTK_PANEL_ACTIVE_BG_COLOR),
                    __config_vkb_panel_active_bg_color);
        setup_widget_value ();

        __have_changed = false;
    }
}
Ejemplo n.º 14
0
void ScimConsoleImpl::slot_reload_config (const ConfigPointer &config)
{
    scim_frontend_hotkey_matcher.load_hotkeys (scim_config);
    scim_imengine_hotkey_matcher.load_hotkeys (scim_config);

    panel_hotkey_matcher.clear ();
    vector<String> strings;
    KeyEventList hotkeys;

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Menu", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_F2));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Menu));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_MENU);

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Cancel", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Escape));
        hotkeys.push_back (KeyEvent (SCIM_KEY_BackSpace));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Delete));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_CANCEL);

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/OK", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Return));
        hotkeys.push_back (KeyEvent (SCIM_KEY_space));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_OK);

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Previous", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Left));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Up));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_PREVIOUS);
    
    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Next", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Right));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Down));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_NEXT);

    // Get keyboard layout setting
    // Flush the global config first, in order to load the new configs from disk.
    scim_global_config_flush ();

    scim_keyboard_layout = scim_get_default_keyboard_layout ();
}
Ejemplo n.º 15
0
int main (int argc, char *argv [])
{
    static ConfigModule  config_module;

    ConfigPointer        config;
    std::vector<String>  config_list;
    String               def_config;
    String               key;
    String               value;
    String               display;

    DataType             type = DATA_TYPE_STRING;
    Command              cmd = DO_NOTHING;
    bool                 reload = false;
    bool                 global = false;

    int                  i;

    char *p =  getenv ("DISPLAY");
    if (p) display = String (p);

    //get modules list
    scim_get_config_module_list (config_list);

    //Use simple Config module as default if available.
    if (config_list.size ()) {
        def_config = scim_global_config_read (SCIM_GLOBAL_CONFIG_DEFAULT_CONFIG_MODULE, String ("simple"));
        if (std::find (config_list.begin (),
                       config_list.end (),
                       def_config) == config_list.end ())
            def_config = config_list [0];
    } else {
        cerr << "No config module found.\n";
        return -1;
    }

    // parse command options
    i = 0;
    while (i<argc) {
        if (++i >= argc) break;

        if (String ("-h") == argv [i] ||
                String ("--help") == argv [i]) {
            cout << "Usage: " << argv [0] << " <option>...\n\n"
                 << "The options are:\n"
                 << "  -g, --get key        Get the value of this key.\n"
                 << "  -s, --set key=value  Set the value of this key.\n"
                 << "  -d, --del key        Delete the key and its data\n"
                 << "                       from user config file.\n"
                 << "  -t, --type type      The key value type, valid types are:\n"
                 << "                       string, int, double, bool, string-list,\n"
                 << "                       int-list. The default type is string.\n"
                 << "  -c, --config name    Use specified Config module,\n"
                 << "                       use simple module by default.\n"
                 << "                       Use \"global\" instead of a real config module name,\n"
                 << "                       if you want to access the global configuration file.\n"
                 << "                       (Normally they are /etc/scim/global and ~/.scim/global).\n"
                 << "  --reload             Force the running scim to reload configuration.\n"
                 << "  --display display    The display which scim Panel is running on,\n"
                 << "                       it's only useful when --reload is used.\n"
                 << "  -h, --help           Show this help.\n";
            return 0;
        }

        if (String ("-g") == argv [i] ||
                String ("--get") == argv [i]) {
            if (++i >= argc) {
                cerr << "No argument for option " << argv [i-1] << endl;
                return -1;
            }
            if (cmd != DO_NOTHING) {
                cerr << "You can only do one thing at the same time!\n";
                return -1;
            }
            key = String (argv [i]);
            cmd = GET_DATA;
            continue;
        }

        if (String ("-s") == argv [i] ||
                String ("--set") == argv [i]) {
            if (++i >= argc) {
                cerr << "No argument for option " << argv [i-1] << endl;
                return -1;
            }
            if (cmd != DO_NOTHING) {
                cerr << "You can only do one thing at the same time!\n";
                return -1;
            }

            String str (argv [i]);
            str = trim_blank (str);

            key = get_param_portion (str);
            value = get_value_portion (str);

            if (!key.length ()) {
                cerr << "Bad argument for option " << argv [i-1] << endl;
                return -1;
            }

            cmd = SET_DATA;
            continue;
        }

        if (String ("-d") == argv [i] ||
                String ("--del") == argv [i]) {
            if (++i >= argc) {
                cerr << "No argument for option " << argv [i-1] << endl;
                return -1;
            }
            if (cmd != DO_NOTHING) {
                cerr << "You can only do one thing at the same time!\n";
                return -1;
            }

            key = String (argv [i]);
            cmd = DEL_KEY;
            continue;
        }

        if (String ("-t") == argv [i] ||
                String ("--type") == argv [i]) {
            if (++i >= argc) {
                cerr << "No argument for option " << argv [i-1] << endl;
                return -1;
            }
            if (String (argv [i]) == "string")
                type = DATA_TYPE_STRING;
            else if (String (argv [i]) == "int")
                type = DATA_TYPE_INT;
            else if (String (argv [i]) == "double")
                type = DATA_TYPE_DOUBLE;
            else if (String (argv [i]) == "bool")
                type = DATA_TYPE_BOOL;
            else if (String (argv [i]) == "string-list")
                type = DATA_TYPE_STRING_LIST;
            else if (String (argv [i]) == "int-list")
                type = DATA_TYPE_STRING_LIST;
            else {
                cerr << "Bad argument for option " << argv [i-1] << endl;
                return -1;
            }
            continue;
        }

        if (String ("-c") == argv [i] ||
                String ("--config") == argv [i]) {
            if (++i >= argc) {
                cerr << "No argument for option " << argv [i-1] << endl;
                return -1;
            }
            def_config = String (argv [i]);
            continue;
        }

        if (String ("--display") == argv [i]) {
            if (++i >= argc) {
                cerr << "No argument for option " << argv [i-1] << endl;
                return -1;
            }
            display = String (argv [i]);
            continue;
        }

        if (String ("--reload") == argv [i]) {
            reload = true;
            continue;
        }

        cerr << "Unknown option " << argv [i] << endl;
        return -1;
    }

    if ((cmd == DO_NOTHING || !key.length ()) && reload == false) {
        cerr << "What do you want to do?\n";
        return -1;
    }

    if (cmd != DO_NOTHING) {
        if (def_config == "global") {
            global = true;
        } else {
            if (!config_module.load (def_config)) {
                cerr << "Failed to load config module " << def_config << endl;
                return -1;
            }

            config = config_module.create_config ();

            if (config.null ()) {
                cerr << "Failed to create config object.\n";
                return -1;
            }
        }
    }

    // Get data
    if (cmd == GET_DATA) {
        bool ok = false;
        if (type == DATA_TYPE_STRING) {
            if (global) {
                value = scim_global_config_read (key, String (""));
                ok = (scim_global_config_read (key, String ("Invalid")) == value);
            } else {
                ok = config->read (key, &value);
            }
            if (ok) cout << value << endl;
        } else if (type == DATA_TYPE_INT) {
            int intval;
            if (global) {
                intval = scim_global_config_read (key, (int) 0);
                ok = (scim_global_config_read (key, (int) 0) == intval);
            } else {
                ok = config->read (key, &intval);
            }
            if (ok) cout << intval << endl;
        } else if (type == DATA_TYPE_DOUBLE) {
            double doubleval;
            if (global) {
                doubleval = scim_global_config_read (key, (double) 0);
                ok = (scim_global_config_read (key, (double) 1) == doubleval);
            } else {
                ok = config->read (key, &doubleval);
            }
            if (ok) cout << doubleval << endl;
        } else if (type == DATA_TYPE_BOOL) {
            bool boolval;
            if (global) {
                boolval = scim_global_config_read (key, (bool) false);
                ok = (scim_global_config_read (key, (bool) true) == boolval);
            } else {
                ok = config->read (key, &boolval);
            }
            if (ok) cout << (boolval ? "true" : "false") << endl;
        } else if (type == DATA_TYPE_STRING_LIST) {
            std::vector <String> strlistval;
            if (global) {
                strlistval = scim_global_config_read (key, strlistval);
                ok = (strlistval.size () > 0);
            } else {
                ok = config->read (key, &strlistval);
            }
            if (ok) cout << scim_combine_string_list (strlistval, ',') << endl;
        } else if (type == DATA_TYPE_INT_LIST) {
            std::vector <int> intlistval;
            if (global) {
                intlistval = scim_global_config_read (key, intlistval);
                ok = (intlistval.size () > 0);
            } else {
                ok = config->read (key, &intlistval);
            }

            if (ok) {
                for (size_t i = 0; i<intlistval.size (); ++i) {
                    cout << intlistval [i];
                    if (i < intlistval.size () - 1)
                        cout << ",";
                }
                cout << endl;
            }
        }

        if (!ok) {
            cerr << "Failed to get key value.\n";
            return -1;
        }
    }

    // Set data
    else if (cmd == SET_DATA) {
        bool ok = true;
        if (type != DATA_TYPE_STRING && !value.length ()) {
            ok = false;
        } else if (type == DATA_TYPE_STRING) {
            if (global) {
                scim_global_config_write (key, value);
            } else {
                ok = config->write (key, value);
            }
        } else if (type == DATA_TYPE_INT) {
            int intval = strtol (value.c_str (), 0, 10);
            if (global) {
                scim_global_config_write (key, intval);
            } else {
                ok = config->write (key, intval);
            }
        } else if (type == DATA_TYPE_DOUBLE) {
            double doubleval = strtod (value.c_str (), 0);
            if (global) {
                scim_global_config_write (key, doubleval);
            } else {
                ok = config->write (key, doubleval);
            }
        } else if (type == DATA_TYPE_BOOL) {
            bool boolval = false;
            if (value == "true" || value == "True" || value == "TRUE" || value == "1")
                boolval = true;

            if (global) {
                scim_global_config_write (key, boolval);
            } else {
                ok = config->write (key, boolval);
            }
        } else if (type == DATA_TYPE_STRING_LIST) {
            std::vector <String> strlistval;
            scim_split_string_list (strlistval, value, ',');

            if (global) {
                scim_global_config_write (key, strlistval);
            } else {
                ok = config->write (key, strlistval);
            }
        } else if (type == DATA_TYPE_INT_LIST) {
            std::vector <int> intlistval;
            std::vector <String> strlist;
            scim_split_string_list (strlist, value, ',');
            for (size_t i = 0; i<strlist.size (); ++i)
                intlistval.push_back (strtol (strlist[i].c_str (), 0, 10));

            if (global) {
                scim_global_config_write (key, intlistval);
            } else {
                ok = config->write (key, intlistval);
            }
        }

        if (global)
            ok = scim_global_config_flush ();

        if (!ok) {
            cerr << "Failed to set key value.\n";
            return -1;
        } else {
            cout << "Set data success.\n";
            if (!global) config->flush ();
        }
    }

    // Delete key
    else if (cmd == DEL_KEY) {
        bool ok = false;

        if (global) {
            scim_global_config_reset (key);
            ok = scim_global_config_flush ();
        } else {
            ok = config->erase (key);
        }

        if (ok) {
            cout << "Delete key success.\n";
            if (!global) config->flush ();
        } else {
            cerr << "Failed to delete the key.\n";
            return -1;
        }
    }

    if (reload) {
        HelperInfo   helper_info ("41b79480-c5d2-4929-9456-11d519c26b87", "scim-config-agent", "", "", SCIM_HELPER_STAND_ALONE);
        HelperAgent  helper_agent;

        int          id;

        id = helper_agent.open_connection (helper_info, display);

        if (id < 0) {
            cerr << "Unable to open the connection to scim Panel.\n";
            return -1;
        }

        helper_agent.reload_config ();

        cout << "Configuration reload request has been sent to the running scim.\n";

        helper_agent.close_connection ();
    }

    return 0;
}
Ejemplo n.º 16
0
void
SKKFactory::reload_config (const ConfigPointer &config)
{
    if (config) {
        String str;
        std::vector<String> sysdicts_default;

        scim_split_string_list (sysdicts_default,
                                String (SCIM_SKK_CONFIG_SYSDICT_DEFAULT));
        m_sysdicts = config->read(String(SCIM_SKK_CONFIG_SYSDICT),
                                  sysdicts_default);
        if (m_sysdicts.size() > 0) {
            for (std::vector<String>::const_iterator it = m_sysdicts.begin();
                    it != m_sysdicts.end(); it++) {
                scim_skkdict->add_sysdict(*it);
            }
        } else {
            scim_skkdict->add_sysdict(String(SCIM_SKK_CONFIG_SYSDICT_DEFAULT));
        }
        m_userdictname = config->read(String(SCIM_SKK_CONFIG_USERDICT),
                                      String(SCIM_SKK_CONFIG_USERDICT_DEFAULT));
        scim_skkdict->set_userdict(m_userdictname, scim_skkhistory);
        candvec_size =
            config->read(String(SCIM_SKK_CONFIG_CANDVEC_SIZE),
                         SCIM_SKK_CONFIG_CANDVEC_SIZE_DEFAULT);
        annot_view =
            config->read(String(SCIM_SKK_CONFIG_ANNOT_VIEW),
                         SCIM_SKK_CONFIG_ANNOT_VIEW_DEFAULT);
        str = config->read(String(SCIM_SKK_CONFIG_ANNOT_POS),
                           String(SCIM_SKK_CONFIG_ANNOT_POS_DEFAULT));
        if (islower(str[0])) str[0] = toupper(str[0]);
        annot_pos = (str == String("Inline"));
        str = config->read(String(SCIM_SKK_CONFIG_ANNOT_TARGET),
                           String(SCIM_SKK_CONFIG_ANNOT_TARGET_DEFAULT));
        annot_target = (str == String("all"));

        annot_highlight =
            config->read(String(SCIM_SKK_CONFIG_ANNOT_HIGHLIGHT),
                         SCIM_SKK_CONFIG_ANNOT_HIGHLIGHT_DEFAULT);
        str = config->read(String(SCIM_SKK_CONFIG_ANNOT_BGCOLOR),
                           String(SCIM_SKK_CONFIG_ANNOT_BGCOLOR_DEFAULT));
        annot_bgcolor = strtol(str.c_str() + 1, (char**)NULL, 16);

        ignore_return =
            config->read(String(SCIM_SKK_CONFIG_IGNORE_RETURN),
                         SCIM_SKK_CONFIG_IGNORE_RETURN_DEFAULT);

        str = config->read(String(SCIM_SKK_CONFIG_STYLE_FILENAME), String());
        key2kana.clear_rules();
        {
            /* read style files */
            StyleFile sfile;
            static const String romaji = "RomajiTable/FundamentalTable";
            static const String kana   = "KanaTable/FundamentalTable";
            if (sfile.load(str.c_str())) {
                if (!sfile.get_key2kana_table(key2kana, romaji)) {
                    sfile.get_key2kana_table(key2kana, kana);
                }
            } else {
                /* default settings */
                key2kana.set_rules(romakana_table);
            }
        }

        str = config->read(String(SCIM_SKK_CONFIG_KAKUTEI_KEY),
                           String(SCIM_SKK_CONFIG_KAKUTEI_KEY_DEFAULT));
        m_keybind.set_kakutei_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_KATAKANA_KEY),
                           String(SCIM_SKK_CONFIG_KATAKANA_KEY_DEFAULT));
        m_keybind.set_katakana_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_HALF_KATAKANA_KEY),
                           String(SCIM_SKK_CONFIG_HALF_KATAKANA_KEY_DEFAULT));
        m_keybind.set_half_katakana_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_ASCII_KEY),
                           String(SCIM_SKK_CONFIG_ASCII_KEY_DEFAULT));
        m_keybind.set_ascii_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_WIDE_ASCII_KEY),
                           String(SCIM_SKK_CONFIG_WIDE_ASCII_KEY_DEFAULT));
        m_keybind.set_wide_ascii_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_CONVERT_KEY),
                           String(SCIM_SKK_CONFIG_CONVERT_KEY_DEFAULT));
        m_keybind.set_convert_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_START_PREEDIT_KEY),
                           String(SCIM_SKK_CONFIG_START_PREEDIT_KEY_DEFAULT));
        m_keybind.set_start_preedit_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_CANCEL_KEY),
                           String(SCIM_SKK_CONFIG_CANCEL_KEY_DEFAULT));
        m_keybind.set_cancel_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_ASCII_CONVERT_KEY),
                           String(SCIM_SKK_CONFIG_ASCII_CONVERT_KEY_DEFAULT));
        m_keybind.set_ascii_convert_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_PREVCAND_KEY),
                           String(SCIM_SKK_CONFIG_PREVCAND_KEY_DEFAULT));
        m_keybind.set_prevcand_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_BACKSPACE_KEY),
                           String(SCIM_SKK_CONFIG_BACKSPACE_KEY_DEFAULT));
        m_keybind.set_backspace_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_DELETE_KEY),
                           String(SCIM_SKK_CONFIG_DELETE_KEY_DEFAULT));
        m_keybind.set_delete_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_FORWARD_KEY),
                           String(SCIM_SKK_CONFIG_FORWARD_KEY_DEFAULT));
        m_keybind.set_forward_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_BACKWARD_KEY),
                           String(SCIM_SKK_CONFIG_BACKWARD_KEY_DEFAULT));
        m_keybind.set_backward_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_HOME_KEY),
                           String(SCIM_SKK_CONFIG_HOME_KEY_DEFAULT));
        m_keybind.set_home_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_END_KEY),
                           String(SCIM_SKK_CONFIG_END_KEY_DEFAULT));
        m_keybind.set_end_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_UPCASE_KEY),
                           String(SCIM_SKK_CONFIG_UPCASE_KEY_DEFAULT));
        m_keybind.set_upcase_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_COMPLETION_KEY),
                           String(SCIM_SKK_CONFIG_COMPLETION_KEY_DEFAULT));
        m_keybind.set_completion_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_COMPLETION_BACK_KEY),
                           String(SCIM_SKK_CONFIG_COMPLETION_BACK_KEY_DEFAULT));
        m_keybind.set_completion_back_keys(str);
        str = config->read(String(SCIM_SKK_CONFIG_SELECTION_STYLE),
                           String(SCIM_SKK_CONFIG_SELECTION_STYLE_DEFAULT));
        m_keybind.set_selection_style(str);
    }
}
Ejemplo n.º 17
0
void
load_config (const ConfigPointer &config)
{
    if (!config.null ()) {
        __config_toolbar_always_hidden =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_ALWAYS_HIDDEN),
                          __config_toolbar_always_hidden);
        __config_toolbar_always_show =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_ALWAYS_SHOW),
                          __config_toolbar_always_show);
        __config_toolbar_auto_snap =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_AUTO_SNAP),
                          __config_toolbar_auto_snap);
        __config_toolbar_hide_timeout =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_HIDE_TIMEOUT),
                          __config_toolbar_hide_timeout);
        __config_toolbar_show_factory_icon =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_SHOW_FACTORY_ICON),
                          __config_toolbar_show_factory_icon);
        __config_toolbar_show_factory_name =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_SHOW_FACTORY_NAME),
                          __config_toolbar_show_factory_name);
        __config_toolbar_show_stick_icon =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_SHOW_STICK_ICON),
                          __config_toolbar_show_stick_icon);
        __config_toolbar_show_menu_icon =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_SHOW_MENU_ICON),
                          __config_toolbar_show_menu_icon);
        __config_toolbar_show_help_icon =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_SHOW_HELP_ICON),
                          __config_toolbar_show_help_icon);
        __config_toolbar_show_property_label =
            config->read (String (SCIM_CONFIG_PANEL_GTK_TOOLBAR_SHOW_PROPERTY_LABEL),
                          __config_toolbar_show_property_label);
        __config_lookup_table_embedded =
            config->read (String (SCIM_CONFIG_PANEL_GTK_LOOKUP_TABLE_EMBEDDED),
                          __config_lookup_table_embedded);
        __config_lookup_table_vertical =
            config->read (String (SCIM_CONFIG_PANEL_GTK_LOOKUP_TABLE_VERTICAL),
                          __config_lookup_table_vertical);
        __config_default_sticked =
            config->read (String (SCIM_CONFIG_PANEL_GTK_DEFAULT_STICKED),
                          __config_default_sticked);
        __config_show_tray_icon =
            config->read (String (SCIM_CONFIG_PANEL_GTK_SHOW_TRAY_ICON),
                          __config_show_tray_icon);
        __config_font =
            config->read (String (SCIM_CONFIG_PANEL_GTK_FONT),
                          __config_font);

        setup_widget_value ();

        __have_changed = false;
    }
}