diff options
-rw-r--r-- | src/lib/ecore_imf/Ecore_IMF.h | 43 | ||||
-rw-r--r-- | src/lib/ecore_imf/ecore_imf_context.c | 63 | ||||
-rw-r--r-- | src/lib/ecore_imf/ecore_imf_private.h | 1 |
3 files changed, 106 insertions, 1 deletions
diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h index 92c1bc6eac..0fc821da2f 100644 --- a/src/lib/ecore_imf/Ecore_IMF.h +++ b/src/lib/ecore_imf/Ecore_IMF.h | |||
@@ -1987,6 +1987,49 @@ EAPI void ecore_imf_context_mime_type_accept_set(Ecore_I | |||
1987 | */ | 1987 | */ |
1988 | EAPI void ecore_imf_context_input_panel_position_set(Ecore_IMF_Context *ctx, int x, int y); | 1988 | EAPI void ecore_imf_context_input_panel_position_set(Ecore_IMF_Context *ctx, int x, int y); |
1989 | 1989 | ||
1990 | /** | ||
1991 | * @ingroup Ecore_IMF_Context_Group | ||
1992 | * @brief Sets the prediction hint data at the specified key | ||
1993 | * | ||
1994 | * @since 1.21.0 | ||
1995 | * | ||
1996 | * @param[in] ctx An #Ecore_IMF_Context | ||
1997 | * @param key The key of the prediction hint | ||
1998 | * @param data The data to replace | ||
1999 | * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise | ||
2000 | * | ||
2001 | * This function modifies the data of @p key with @p data in the hash associated @p | ||
2002 | * ctx. If no entry is found, @p data is added to the hash associated @p ctx with the | ||
2003 | * key @p key. On success this function returns EINA_TRUE, | ||
2004 | * otherwise it returns @c EINA_FALSE. | ||
2005 | */ | ||
2006 | EAPI Eina_Bool ecore_imf_context_prediction_hint_hash_set(Ecore_IMF_Context *ctx, const char *key, const char *value); | ||
2007 | |||
2008 | /** | ||
2009 | * @ingroup Ecore_IMF_Context_Group | ||
2010 | * @brief Removes the prediction hint data identified by a key | ||
2011 | * | ||
2012 | * @since 1.21.0 | ||
2013 | * | ||
2014 | * @param[in] ctx An #Ecore_IMF_Context | ||
2015 | * @param key The key of the prediction hint | ||
2016 | * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise | ||
2017 | * | ||
2018 | * This function removes the entry identified by @p key from the hash associated @p ctx. | ||
2019 | */ | ||
2020 | EAPI Eina_Bool ecore_imf_context_prediction_hint_hash_del(Ecore_IMF_Context *ctx, const char *key); | ||
2021 | |||
2022 | /** | ||
2023 | * @ingroup Ecore_IMF_Context_Group | ||
2024 | * @brief Gets the hash table of prediction hint data | ||
2025 | * | ||
2026 | * @since 1.21.0 | ||
2027 | * | ||
2028 | * @param[in] ctx An #Ecore_IMF_Context | ||
2029 | * @return The prediction hint hash table | ||
2030 | */ | ||
2031 | EAPI const Eina_Hash *ecore_imf_context_prediction_hint_hash_get(Ecore_IMF_Context *ctx); | ||
2032 | |||
1990 | /* The following entry points must be exported by each input method module | 2033 | /* The following entry points must be exported by each input method module |
1991 | */ | 2034 | */ |
1992 | 2035 | ||
diff --git a/src/lib/ecore_imf/ecore_imf_context.c b/src/lib/ecore_imf/ecore_imf_context.c index 1b34e0c01f..a04708fa8d 100644 --- a/src/lib/ecore_imf/ecore_imf_context.c +++ b/src/lib/ecore_imf/ecore_imf_context.c | |||
@@ -224,6 +224,9 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx) | |||
224 | free(fn); | 224 | free(fn); |
225 | } | 225 | } |
226 | 226 | ||
227 | if (ctx->prediction_hint_hash) | ||
228 | eina_hash_free(ctx->prediction_hint_hash); | ||
229 | |||
227 | ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE); | 230 | ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE); |
228 | free(ctx); | 231 | free(ctx); |
229 | } | 232 | } |
@@ -1460,4 +1463,62 @@ ecore_imf_context_input_panel_position_set(Ecore_IMF_Context *ctx, int x, int y) | |||
1460 | 1463 | ||
1461 | if (ctx->klass->input_panel_position_set) | 1464 | if (ctx->klass->input_panel_position_set) |
1462 | ctx->klass->input_panel_position_set(ctx, x, y); | 1465 | ctx->klass->input_panel_position_set(ctx, x, y); |
1463 | } \ No newline at end of file | 1466 | } |
1467 | |||
1468 | static void | ||
1469 | _prediction_hint_hash_free_cb(void *data) | ||
1470 | { | ||
1471 | free(data); | ||
1472 | } | ||
1473 | |||
1474 | EAPI Eina_Bool | ||
1475 | ecore_imf_context_prediction_hint_hash_set(Ecore_IMF_Context *ctx, const char *key, const char *value) | ||
1476 | { | ||
1477 | if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) | ||
1478 | { | ||
1479 | ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, | ||
1480 | "ecore_imf_context_prediction_hint_hash_set"); | ||
1481 | return EINA_FALSE; | ||
1482 | } | ||
1483 | |||
1484 | if (!ctx->prediction_hint_hash) | ||
1485 | ctx->prediction_hint_hash = eina_hash_string_superfast_new(_prediction_hint_hash_free_cb); | ||
1486 | |||
1487 | if (!ctx->prediction_hint_hash) | ||
1488 | return EINA_FALSE; | ||
1489 | |||
1490 | char *old_value = eina_hash_set(ctx->prediction_hint_hash, key, value ? strdup(value) : strdup("")); | ||
1491 | if (old_value) | ||
1492 | free(old_value); | ||
1493 | |||
1494 | return EINA_TRUE; | ||
1495 | } | ||
1496 | |||
1497 | EAPI Eina_Bool | ||
1498 | ecore_imf_context_prediction_hint_hash_del(Ecore_IMF_Context *ctx, const char *key) | ||
1499 | { | ||
1500 | if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) | ||
1501 | { | ||
1502 | ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, | ||
1503 | "ecore_imf_context_prediction_hint_hash_del"); | ||
1504 | return EINA_FALSE; | ||
1505 | } | ||
1506 | |||
1507 | if (!ctx->prediction_hint_hash) | ||
1508 | return EINA_FALSE; | ||
1509 | |||
1510 | return eina_hash_del(ctx->prediction_hint_hash, key, NULL); | ||
1511 | } | ||
1512 | |||
1513 | EAPI const Eina_Hash * | ||
1514 | ecore_imf_context_prediction_hint_hash_get(Ecore_IMF_Context *ctx) | ||
1515 | { | ||
1516 | if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) | ||
1517 | { | ||
1518 | ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, | ||
1519 | "ecore_imf_context_prediction_hint_hash_get"); | ||
1520 | return NULL; | ||
1521 | } | ||
1522 | |||
1523 | return ctx->prediction_hint_hash; | ||
1524 | } | ||
diff --git a/src/lib/ecore_imf/ecore_imf_private.h b/src/lib/ecore_imf/ecore_imf_private.h index 611db426e7..22d2942109 100644 --- a/src/lib/ecore_imf/ecore_imf_private.h +++ b/src/lib/ecore_imf/ecore_imf_private.h | |||
@@ -60,6 +60,7 @@ struct _Ecore_IMF_Context | |||
60 | int input_panel_layout_variation; | 60 | int input_panel_layout_variation; |
61 | Eina_Bool (*retrieve_selection_func)(void *data, Ecore_IMF_Context *ctx, char **text); | 61 | Eina_Bool (*retrieve_selection_func)(void *data, Ecore_IMF_Context *ctx, char **text); |
62 | void *retrieve_selection_data; | 62 | void *retrieve_selection_data; |
63 | Eina_Hash *prediction_hint_hash; | ||
63 | Eina_Bool allow_prediction : 1; | 64 | Eina_Bool allow_prediction : 1; |
64 | Eina_Bool input_panel_enabled : 1; | 65 | Eina_Bool input_panel_enabled : 1; |
65 | Eina_Bool input_panel_return_key_disabled : 1; | 66 | Eina_Bool input_panel_return_key_disabled : 1; |