Ejemplo n.º 1
0
Archivo: main.c Proyecto: Abioy/ibus
static void
_context_update_preedit_text_cb (IBusInputContext *context,
                                 IBusText         *text,
                                 gint              cursor_pos,
                                 gboolean          visible,
                                 X11IC            *x11ic)
{
    g_assert (IBUS_IS_INPUT_CONTEXT (context));
    g_assert (IBUS_IS_TEXT (text));
    g_assert (x11ic);

    if (x11ic->preedit_string) {
        g_free(x11ic->preedit_string);
    }
    x11ic->preedit_string = g_strdup(text->text);

    if (x11ic->preedit_attrs) {
        g_object_unref (x11ic->preedit_attrs);
    }

    g_object_ref(text->attrs);
    x11ic->preedit_attrs = text->attrs;

    x11ic->preedit_cursor = cursor_pos;
    x11ic->preedit_visible = visible;

    _update_preedit (x11ic);
}
Ejemplo n.º 2
0
void
ibus_text_append_attribute (IBusText *text,
                            guint     type,
                            guint     value,
                            guint     start_index,
                            gint      end_index)
{
    g_assert (IBUS_IS_TEXT (text));

    IBusAttribute *attr;

    if (end_index < 0) {
        end_index  += g_utf8_strlen(text->text, -1) + 1;
    }

    if (end_index <= 0) {
        return;
    }

    if (text->attrs == NULL) {
        text->attrs = ibus_attr_list_new ();
    }

    attr = ibus_attribute_new (type, value, start_index, end_index);
    ibus_attr_list_append (text->attrs, attr);
    g_object_unref (attr);
}
Ejemplo n.º 3
0
static gboolean
ibus_text_copy (IBusText       *dest,
                const IBusText *src)
{
    gboolean retval;

    retval = parent_class->copy ((IBusSerializable *)dest,
                                 (IBusSerializable *)src);
    g_return_val_if_fail (retval, FALSE);

    g_return_val_if_fail (IBUS_IS_TEXT (dest), FALSE);
    g_return_val_if_fail (IBUS_IS_TEXT (src), FALSE);

    dest->text = g_strdup (src->text);
    dest->is_static = FALSE;
    if (src->attrs)
        dest->attrs = (IBusAttrList *)ibus_serializable_copy ((IBusSerializable *)src->attrs);

    return TRUE;
}
Ejemplo n.º 4
0
void
ibus_property_set_label (IBusProperty *prop,
                         IBusText     *label)
{
    g_assert (IBUS_IS_PROPERTY (prop));
    g_return_if_fail (label == NULL || IBUS_IS_TEXT (label));

    if (prop->label) {
        g_object_unref (prop->label);
    }

    if (label == NULL) {
        prop->label = ibus_text_new_from_static_string ("");
    }
    else {
        prop->label = g_object_ref_sink (label);
    }
}
Ejemplo n.º 5
0
void
ibus_property_set_tooltip (IBusProperty *prop,
                           IBusText     *tooltip)
{
    g_assert (IBUS_IS_PROPERTY (prop));
    g_assert (tooltip == NULL || IBUS_IS_TEXT (tooltip));

    if (prop->tooltip) {
        g_object_unref (prop->tooltip);
    }

    if (tooltip == NULL) {
        prop->tooltip = ibus_text_new_from_static_string ("");
        g_object_ref_sink (prop->tooltip);
    }
    else {
        prop->tooltip = tooltip;
        g_object_ref_sink (prop->tooltip);
    }
}
Ejemplo n.º 6
0
Archivo: main.c Proyecto: Abioy/ibus
static void
_context_commit_text_cb (IBusInputContext *context,
                         IBusText         *text,
                         X11IC            *x11ic)
{
    g_assert (IBUS_IS_INPUT_CONTEXT (context));
    g_assert (IBUS_IS_TEXT (text));
    g_assert (x11ic != NULL);

    XTextProperty tp;
    IMCommitStruct cms = {0};

    Xutf8TextListToTextProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
        (gchar **)&(text->text), 1, XCompoundTextStyle, &tp);

    cms.major_code = XIM_COMMIT;
    cms.icid = x11ic->icid;
    cms.connect_id = x11ic->connect_id;
    cms.flag = XimLookupChars;
    cms.commit_string = (gchar *)tp.value;
    IMCommitString (_xims, (XPointer) & cms);

    XFree (tp.value);
}