Exemple #1
0
static void fcitx_input_method_g_properties_changed(
    GDBusProxy *proxy, GVariant *changed_properties,
    const gchar *const *invalidated_properties) {
    FcitxInputMethod *user = FCITX_INPUT_METHOD(proxy);
    GVariantIter *iter;
    const gchar *key;

    if (changed_properties != NULL) {
        g_variant_get(changed_properties, "a{sv}", &iter);
        while (g_variant_iter_next(iter, "{&sv}", &key, NULL)) {
            if (g_strcmp0(key, "IMList") == 0)
                g_signal_emit(user, signals[IMLIST_CHANGED_SIGNAL], 0);
            else if (g_strcmp0(key, "CurrentIM") == 0)
                g_object_notify_by_pspec(G_OBJECT(user),
                                         properties[PROP_CURRENT_IM]);
        }
        g_variant_iter_free(iter);
    }

    if (invalidated_properties != NULL) {
        const gchar *const *item = invalidated_properties;
        while (*item) {
            if (g_strcmp0(*item, "IMList") == 0)
                g_signal_emit(user, signals[IMLIST_CHANGED_SIGNAL], 0);
            else if (g_strcmp0(*item, "CurrentIM") == 0)
                g_object_notify_by_pspec(G_OBJECT(user),
                                         properties[PROP_CURRENT_IM]);
            item++;
        }
    }
}
Exemple #2
0
static void
fcitx_input_method_finalize(GObject *object)
{
    G_GNUC_UNUSED FcitxInputMethod *im = FCITX_INPUT_METHOD(object);

    if (G_OBJECT_CLASS(fcitx_input_method_parent_class)->finalize != NULL)
        G_OBJECT_CLASS(fcitx_input_method_parent_class)->finalize(object);
}
Exemple #3
0
static void fcitx_input_method_get_property(GObject *object, guint property_id,
                                            GValue *value, GParamSpec *pspec) {
    FcitxInputMethod *proxy = FCITX_INPUT_METHOD(object);

    switch (property_id) {
    case PROP_CURRENT_IM:
        g_value_take_string(value, fcitx_input_method_get_current_im(proxy));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
    }
}
Exemple #4
0
/**
 * fcitx_input_method_new:
 * @bus_type: #GBusType
 * @flags:  #GDBusProxyFlags
 * @display_number: display_number
 * @cancellable: A #GCancellable or %NULL
 * @error: Error or %NULL
 *
 * New a #fcitxInputMethod.
 *
 * Returns: A newly allocated #FcitxInputMethod.
 */
FCITX_EXPORT_API
FcitxInputMethod *fcitx_input_method_new(GBusType bus_type,
                                         GDBusProxyFlags flags,
                                         gint display_number,
                                         GCancellable *cancellable,
                                         GError **error) {
    gchar servicename[64];
    sprintf(servicename, "%s-%d", FCITX_DBUS_SERVICE, display_number);

    char *name = servicename;
    FcitxInputMethod *im = g_initable_new(
        FCITX_TYPE_INPUT_METHOD, cancellable, error, "g-flags", flags, "g-name",
        name, "g-bus-type", bus_type, "g-object-path", FCITX_IM_DBUS_PATH,
        "g-interface-name", FCITX_IM_DBUS_INTERFACE, NULL);
    return FCITX_INPUT_METHOD(im);
}
Exemple #5
0
static void fcitx_input_method_set_property(GObject *object, guint property_id,
                                            const GValue *value,
                                            GParamSpec *pspec) {
    FcitxInputMethod *proxy = FCITX_INPUT_METHOD(object);
    gchar *current_im;

    switch (property_id) {
    case PROP_CURRENT_IM:
        current_im = g_value_dup_string(value);
        if (current_im && current_im[0]) {
            fcitx_input_method_set_current_im(proxy, current_im);
        }
        g_free(current_im);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
    }
}