Пример #1
0
static void
_ibus_input_ctx_commit_text(void *data, const Eldbus_Message *msg)
{
   Eldbus_Message_Iter *iter = NULL;
   struct wkb_ibus_text *txt;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "v", &iter))
     {
        ERR("Error reading message arguments");
        return;
     }

   txt = wkb_ibus_text_from_message_iter(iter);
   DBG("Commit text: '%s'", txt->text);
   wl_input_method_context_commit_string(wkb_ibus->input_ctx->wl_ctx,
                                         wkb_ibus->input_ctx->serial,
                                         txt->text);
   wkb_ibus_text_free(txt);
}
Пример #2
0
static void
_ibus_input_ctx_update_preedit_text(void *data, const Eldbus_Message *msg)
{
   Eldbus_Message_Iter *iter = NULL;
   unsigned int cursor;
   struct wkb_ibus_text *txt;
   Eina_Bool visible;

   _check_message_errors(msg);

   if (!eldbus_message_arguments_get(msg, "vub", &iter, &cursor, &visible))
     {
        ERR("Error reading message arguments");
        return;
     }

   if (wkb_ibus->input_ctx->preedit)
     {
        free(wkb_ibus->input_ctx->preedit);
        wkb_ibus->input_ctx->preedit = NULL;
     }

   txt = wkb_ibus_text_from_message_iter(iter);
   DBG("Preedit text: '%s', Cursor: '%d'", txt->text, cursor);
   wkb_ibus->input_ctx->preedit = strdup(txt->text);
   wkb_ibus->input_ctx->cursor = cursor;

   if (!visible)
     {
        _set_preedit_text("");
        return;
     }

   wl_input_method_context_preedit_cursor(wkb_ibus->input_ctx->wl_ctx, cursor);
   _set_preedit_text(wkb_ibus->input_ctx->preedit);
}
Пример #3
0
struct wkb_ibus_property *
wkb_ibus_property_from_message_iter(Eldbus_Message_Iter *iter)
{
   struct wkb_ibus_serializable ignore = { 0 };
   struct wkb_ibus_property *prop = calloc(1, sizeof(*prop));
   Eldbus_Message_Iter *iter_prop, *label, *symbol, *tooltip, *sub_props;

   EINA_SAFETY_ON_NULL_RETURN_VAL(prop, NULL);

   DBG("Message iter signature '%s'", eldbus_message_iter_signature_get(iter));

   eldbus_message_iter_arguments_get(iter, "(sa{sv}suvsvbbuvv)", &iter_prop);
   if (!eldbus_message_iter_arguments_get(iter_prop, "sa{sv}suvsvbbuvv",
                                          &ignore.text, &ignore.dict,
                                          &prop->key, &prop->type,
                                          &label, &prop->icon, &tooltip,
                                          &prop->sensitive, &prop->visible,
                                          &prop->state, &sub_props, &symbol))
     {
        ERR("Error deserializing IBusProperty");
        free(prop);
        prop = NULL;
        goto end;
     }

   DBG("Property :");
   DBG("\tKey.............: '%s'", prop->key);
   DBG("\tType............: '%d'", prop->type);
   DBG("\tLabel...........: '%p'", label);
   DBG("\tIcon............: '%s'", prop->icon);
   DBG("\tTooltip.........: '%p'", tooltip);
   DBG("\tSensitive.......: '%d'", prop->sensitive);
   DBG("\tVisible.........: '%d'", prop->visible);
   DBG("\tState...........: '%d'", prop->state);
   DBG("\tSub Properties..: '%p'", sub_props);
   DBG("\tSymbol..........: '%p'", symbol);

   if (!label)
     {
        INF("Property has no label");
        goto symbol;
     }

   if (!(prop->label = wkb_ibus_text_from_message_iter(label)))
     {
        wkb_ibus_property_free(prop);
        prop = NULL;
        goto end;
     }

symbol:
   if (!symbol)
     {
        INF("Property has no symbol");
        goto tooltip;
     }

   if (!(prop->symbol = wkb_ibus_text_from_message_iter(symbol)))
     {
        wkb_ibus_property_free(prop);
        prop = NULL;
        goto end;
     }

tooltip:
   if (!tooltip)
     {
        INF("Property has no tooltip");
        goto sub_props;
     }

   if (!(prop->tooltip = wkb_ibus_text_from_message_iter(tooltip)))
     {
        wkb_ibus_property_free(prop);
        prop = NULL;
        goto end;
     }

sub_props:
   if (!sub_props)
     {
        INF("Property has no sub properties");
        goto end;
     }

   prop->sub_properties = wkb_ibus_properties_from_message_iter(sub_props);

end:
   return prop;
}
Пример #4
0
struct wkb_ibus_lookup_table *
wkb_ibus_lookup_table_from_message_iter(Eldbus_Message_Iter *iter)
{
   struct wkb_ibus_serializable ignore = { 0 };
   struct wkb_ibus_lookup_table *table = calloc(1, sizeof(*table));
   struct wkb_ibus_text *text = NULL;
   Eldbus_Message_Iter *iter_table, *candidates, *labels, *t;

   EINA_SAFETY_ON_NULL_RETURN_VAL(table, NULL);

   DBG("Message iter signature '%s'", eldbus_message_iter_signature_get(iter));

   eldbus_message_iter_arguments_get(iter, "(sa{sv}uubbiavav)", &iter_table);
   if (!eldbus_message_iter_arguments_get(iter_table, "sa{sv}uubbiavav",
                                          &ignore.text, &ignore.dict,
                                          &table->page_size, &table->cursor_pos,
                                          &table->cursor_visible, &table->round,
                                          &table->orientation, &candidates,
                                          &labels))
     {
        ERR("Error deserializing IBusLookupTable");
        free(table);
        table = NULL;
        goto end;
     }

   DBG("Lookup table:");
   DBG("\tPage size.......: '%d'", table->page_size);
   DBG("\tCursor position.: '%d'", table->cursor_pos);
   DBG("\tCursor visible..: '%d'", table->cursor_visible);
   DBG("\tRound...........: '%d'", table->round);
   DBG("\tOrientation.....: '%d'", table->orientation);
   DBG("\tCandidates......: '%p'", candidates);
   DBG("\tLabels..........: '%p'", labels);

   if (!candidates)
     {
        INF("Lookup table has no candidates");
        goto labels;
     }

   while (eldbus_message_iter_get_and_next(candidates, 'v', &t))
     {
        if (!(text = wkb_ibus_text_from_message_iter(t)))
          {
             wkb_ibus_lookup_table_free(table);
             table = NULL;
             goto end;
          }

        if (!table->candidates)
           table->candidates = eina_array_new(10);

        DBG("Appending new candidate %s", text->text);
        eina_array_push(table->candidates, text);
     }

labels:
   if (!labels)
     {
        INF("Lookup table has no labels");
        goto end;
     }

   while (eldbus_message_iter_get_and_next(labels, 'v', &t))
     {
        if (!(text = wkb_ibus_text_from_message_iter(t)))
          {
             wkb_ibus_lookup_table_free(table);
             table = NULL;
             goto end;
          }

        if (!table->labels)
           table->labels = eina_array_new(10);

        DBG("Appending new label %s", text->text);
        eina_array_push(table->labels, text);
     }

end:
   return table;
}