Blame src/ibusconfig.h

Packit Service 1d8f1c
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
Packit Service 1d8f1c
/* vim:set et sts=4: */
Packit Service 1d8f1c
/* ibus - The Input Bus
Packit Service 1d8f1c
 * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
Packit Service 1d8f1c
 * Copyright (C) 2008-2013 Red Hat, Inc.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * This library is free software; you can redistribute it and/or
Packit Service 1d8f1c
 * modify it under the terms of the GNU Lesser General Public
Packit Service 1d8f1c
 * License as published by the Free Software Foundation; either
Packit Service 1d8f1c
 * version 2.1 of the License, or (at your option) any later version.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * This library is distributed in the hope that it will be useful,
Packit Service 1d8f1c
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 1d8f1c
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 1d8f1c
 * Lesser General Public License for more details.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * You should have received a copy of the GNU Lesser General Public
Packit Service 1d8f1c
 * License along with this library; if not, write to the Free Software
Packit Service 1d8f1c
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
Packit Service 1d8f1c
 * USA
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
Packit Service 1d8f1c
#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
Packit Service 1d8f1c
#error "Only <ibus.h> can be included directly"
Packit Service 1d8f1c
#endif
Packit Service 1d8f1c
Packit Service 1d8f1c
#ifndef __IBUS_CONFIG_H_
Packit Service 1d8f1c
#define __IBUS_CONFIG_H_
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * SECTION: ibusconfig
Packit Service 1d8f1c
 * @title: IBusConfig
Packit Service 1d8f1c
 * @short_description: IBus engine configuration module.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * An IBusConfig provides engine configuration methods
Packit Service 1d8f1c
 * such as get and set the configure settings to configuration file.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Currently, IBusConfig supports gconf.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
Packit Service 1d8f1c
#include "ibusproxy.h"
Packit Service 1d8f1c
Packit Service 1d8f1c
/*
Packit Service 1d8f1c
 * Type macros.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
Packit Service 1d8f1c
/* define GOBJECT macros */
Packit Service 1d8f1c
#define IBUS_TYPE_CONFIG             \
Packit Service 1d8f1c
    (ibus_config_get_type ())
Packit Service 1d8f1c
#define IBUS_CONFIG(obj)             \
Packit Service 1d8f1c
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_CONFIG, IBusConfig))
Packit Service 1d8f1c
#define IBUS_CONFIG_CLASS(klass)     \
Packit Service 1d8f1c
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_CONFIG, IBusConfigClass))
Packit Service 1d8f1c
#define IBUS_IS_CONFIG(obj)          \
Packit Service 1d8f1c
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_CONFIG))
Packit Service 1d8f1c
#define IBUS_IS_CONFIG_CLASS(klass)  \
Packit Service 1d8f1c
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_CONFIG))
Packit Service 1d8f1c
#define IBUS_CONFIG_GET_CLASS(obj)   \
Packit Service 1d8f1c
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_CONFIG, IBusConfigClass))
Packit Service 1d8f1c
Packit Service 1d8f1c
G_BEGIN_DECLS
Packit Service 1d8f1c
Packit Service 1d8f1c
typedef struct _IBusConfig IBusConfig;
Packit Service 1d8f1c
typedef struct _IBusConfigClass IBusConfigClass;
Packit Service 1d8f1c
typedef struct _IBusConfigPrivate IBusConfigPrivate;
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * IBusConfig:
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * An opaque data type representing an IBusConfig.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
struct _IBusConfig {
Packit Service 1d8f1c
    /*< private >*/
Packit Service 1d8f1c
    IBusProxy parent;
Packit Service 1d8f1c
    IBusConfigPrivate *priv;
Packit Service 1d8f1c
Packit Service 1d8f1c
    /* instance members */
Packit Service 1d8f1c
};
Packit Service 1d8f1c
Packit Service 1d8f1c
struct _IBusConfigClass {
Packit Service 1d8f1c
    /*< private >*/
Packit Service 1d8f1c
    IBusProxyClass parent;
Packit Service 1d8f1c
Packit Service 1d8f1c
    /* class members */
Packit Service 1d8f1c
};
Packit Service 1d8f1c
Packit Service 1d8f1c
GType            ibus_config_get_type       (void);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_new:
Packit Service 1d8f1c
 * @connection: A #GDBusConnection.
Packit Service 1d8f1c
 * @cancellable: A #GCancellable or %NULL.
Packit Service 1d8f1c
 * @error: Return location for error or %NULL.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Create a new #IBusConfig from existing #GDBusConnection.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: A newly allocated #IBusConfig corresponding to @connection.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
IBusConfig      *ibus_config_new            (GDBusConnection    *connection,
Packit Service 1d8f1c
                                             GCancellable       *cancellable,
Packit Service 1d8f1c
                                             GError            **error);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_new_async:
Packit Service 1d8f1c
 * @connection: An #GDBusConnection.
Packit Service 1d8f1c
 * @cancellable: A #GCancellable or %NULL.
Packit Service 1d8f1c
 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
Packit Service 1d8f1c
 *      The callback should not be %NULL.
Packit Service 1d8f1c
 * @user_data: The data to pass to callback.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * New an #IBusConfig asynchronously.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
void             ibus_config_new_async      (GDBusConnection    *connection,
Packit Service 1d8f1c
                                             GCancellable       *cancellable,
Packit Service 1d8f1c
                                             GAsyncReadyCallback callback,
Packit Service 1d8f1c
                                             gpointer            user_data);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_new_async_finish:
Packit Service 1d8f1c
 * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback pass to
Packit Service 1d8f1c
 *      ibus_config_new_async().
Packit Service 1d8f1c
 * @error: Return location for error or %NULL.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Finishes an operation started with ibus_config_new_async().
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: A newly allocated #IBusConfig.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
IBusConfig      *ibus_config_new_async_finish
Packit Service 1d8f1c
                                            (GAsyncResult       *res,
Packit Service 1d8f1c
                                             GError            **error);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_get_value:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 * @name: Name of the configure option.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Get the value of a configuration option synchronously.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * GConf stores configure options in a tree-like structure,
Packit Service 1d8f1c
 * and the IBus related setting is at /desktop/ibus,
Packit Service 1d8f1c
 * thus, @section here is a path from there,
Packit Service 1d8f1c
 * while @name is the key of that configuration option.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * ibus-chewing, for example, stores its setting in /desktop/ibus/engine/Chewing,
Packit Service 1d8f1c
 * so the section name for it is "engine/Chewing".
Packit Service 1d8f1c
 * See also: ibus_config_set_value().
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: A #GVariant or %NULL. Free with g_variant_unref().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
GVariant        *ibus_config_get_value      (IBusConfig         *config,
Packit Service 1d8f1c
                                             const gchar        *section,
Packit Service 1d8f1c
                                             const gchar        *name);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_get_value_async:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 * @name: Name of the configure option.
Packit Service 1d8f1c
 * @timeout_ms: The timeout in milliseconds or -1 to use the default timeout.
Packit Service 1d8f1c
 * @cancellable: A #GCancellable or %NULL.
Packit Service 1d8f1c
 * @callback: Callback function to invoke when the return value is ready.
Packit Service 1d8f1c
 * @user_data: The data to pass to callback.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Get the value of a configuration option asynchronously.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_get_value().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
void             ibus_config_get_value_async (IBusConfig         *config,
Packit Service 1d8f1c
                                              const gchar        *section,
Packit Service 1d8f1c
                                              const gchar        *name,
Packit Service 1d8f1c
                                              gint                timeout_ms,
Packit Service 1d8f1c
                                              GCancellable       *cancellable,
Packit Service 1d8f1c
                                              GAsyncReadyCallback callback,
Packit Service 1d8f1c
                                              gpointer            user_data);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_get_value_async_finish:
Packit Service 1d8f1c
 * @config: A #IBusConfig.
Packit Service 1d8f1c
 * @result: A #GAsyncResult.
Packit Service 1d8f1c
 * @error: Return location for error or %NULL.
Packit Service 1d8f1c
 * 
Packit Service 1d8f1c
 * Finish get value of a configuration option.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: A #GVariant or %NULL if error is set. Free with g_variant_unref().
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_get_value_async().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
GVariant        *ibus_config_get_value_async_finish
Packit Service 1d8f1c
                                            (IBusConfig         *config,
Packit Service 1d8f1c
                                             GAsyncResult       *result,
Packit Service 1d8f1c
                                             GError            **error);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_get_values:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Get all values in a section synchronously.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: A #GVariant or %NULL. Free with g_variant_unref().
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_set_value().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
GVariant        *ibus_config_get_values     (IBusConfig         *config,
Packit Service 1d8f1c
                                             const gchar        *section);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_get_values_async:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 * @timeout_ms: The timeout in milliseconds or -1 to use the default timeout.
Packit Service 1d8f1c
 * @cancellable: A #GCancellable or %NULL.
Packit Service 1d8f1c
 * @callback: Callback function to invoke when the return value is ready.
Packit Service 1d8f1c
 * @user_data: The data to pass to callback.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Get all values in a section asynchronously.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_get_values().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
void             ibus_config_get_values_async(IBusConfig         *config,
Packit Service 1d8f1c
                                              const gchar        *section,
Packit Service 1d8f1c
                                              gint                timeout_ms,
Packit Service 1d8f1c
                                              GCancellable       *cancellable,
Packit Service 1d8f1c
                                              GAsyncReadyCallback callback,
Packit Service 1d8f1c
                                              gpointer            user_data);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_get_values_async_finish:
Packit Service 1d8f1c
 * @config: A #IBusConfig.
Packit Service 1d8f1c
 * @result: A #GAsyncResult.
Packit Service 1d8f1c
 * @error: Return location for error or %NULL.
Packit Service 1d8f1c
 * 
Packit Service 1d8f1c
 * Finish get values in a section.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: A #GVariant or %NULL if error is set. Free with g_variant_unref().
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_get_values_async().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
GVariant        *ibus_config_get_values_async_finish
Packit Service 1d8f1c
                                            (IBusConfig         *config,
Packit Service 1d8f1c
                                             GAsyncResult       *result,
Packit Service 1d8f1c
                                             GError            **error);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_set_value:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 * @name: Name of the configure option its self.
Packit Service 1d8f1c
 * @value: A #GVariant that holds the value. If the value is floating, the
Packit Service 1d8f1c
 * function takes ownership of it.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Set the value of a configuration option synchronously.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: %TRUE if succeed; %FALSE otherwise.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_get_value().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
gboolean         ibus_config_set_value      (IBusConfig         *config,
Packit Service 1d8f1c
                                             const gchar        *section,
Packit Service 1d8f1c
                                             const gchar        *name,
Packit Service 1d8f1c
                                             GVariant           *value);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_set_value_async:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 * @name: Name of the configure option.
Packit Service 1d8f1c
 * @value: A #GVariant that holds the value. If the value is floating, the
Packit Service 1d8f1c
 * function takes ownership of it.
Packit Service 1d8f1c
 * @timeout_ms: The timeout in milliseconds or -1 to use the default timeout.
Packit Service 1d8f1c
 * @cancellable: A #GCancellable or %NULL.
Packit Service 1d8f1c
 * @callback: Callback function to invoke when the return value is ready.
Packit Service 1d8f1c
 * @user_data: The data to pass to callback.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Set the value of a configuration option asynchronously.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_set_value().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
void             ibus_config_set_value_async (IBusConfig         *config,
Packit Service 1d8f1c
                                              const gchar        *section,
Packit Service 1d8f1c
                                              const gchar        *name,
Packit Service 1d8f1c
                                              GVariant           *value,
Packit Service 1d8f1c
                                              gint                timeout_ms,
Packit Service 1d8f1c
                                              GCancellable       *cancellable,
Packit Service 1d8f1c
                                              GAsyncReadyCallback callback,
Packit Service 1d8f1c
                                              gpointer            user_data);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_set_value_async_finish:
Packit Service 1d8f1c
 * @config: A #IBusConfig.
Packit Service 1d8f1c
 * @result: A #GAsyncResult.
Packit Service 1d8f1c
 * @error: Return location for error or %NULL.
Packit Service 1d8f1c
 * 
Packit Service 1d8f1c
 * Finish set value of a configuration option.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: %TRUE or %FALSE if error is set.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_set_value_async().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
gboolean         ibus_config_set_value_async_finish
Packit Service 1d8f1c
                                            (IBusConfig         *config,
Packit Service 1d8f1c
                                             GAsyncResult       *result,
Packit Service 1d8f1c
                                             GError            **error);
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_unset:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: Section name of the configuration option.
Packit Service 1d8f1c
 * @name: Name of the configure option its self.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Remove an entry of a configuration option.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: %TRUE if succeed; %FALSE otherwise.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_get_value().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
gboolean         ibus_config_unset      (IBusConfig         *config,
Packit Service 1d8f1c
                                         const gchar        *section,
Packit Service 1d8f1c
                                         const gchar        *name);
Packit Service 1d8f1c
Packit Service 1d8f1c
/* FIXME add an asynchronous version of unset */
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_watch:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: (allow-none): Section name of the configuration option.
Packit Service 1d8f1c
 * @name: (allow-none): Name of the configure option its self.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Subscribe to the configuration option change notification.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Until this function is called, every change will be notified to the
Packit Service 1d8f1c
 * client through #IBusConfig::value-changed signal.  Clients should
Packit Service 1d8f1c
 * call ibus_config_watch() with the sections they are interested in,
Packit Service 1d8f1c
 * to reduce the number of D-Bus messages.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: %TRUE if succeed; %FALSE otherwise.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_unwatch().
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
gboolean         ibus_config_watch      (IBusConfig         *config,
Packit Service 1d8f1c
                                         const gchar        *section,
Packit Service 1d8f1c
                                         const gchar        *name);
Packit Service 1d8f1c
Packit Service 1d8f1c
/* FIXME add an asynchronous version of watch */
Packit Service 1d8f1c
Packit Service 1d8f1c
/**
Packit Service 1d8f1c
 * ibus_config_unwatch:
Packit Service 1d8f1c
 * @config: An #IBusConfig
Packit Service 1d8f1c
 * @section: (allow-none): Section name of the configuration option.
Packit Service 1d8f1c
 * @name: (allow-none): Name of the configure option its self.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Unsubscribe from the configuration option change notification.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * Returns: %TRUE if succeed; %FALSE otherwise.
Packit Service 1d8f1c
 *
Packit Service 1d8f1c
 * See also: ibus_config_watch.
Packit Service 1d8f1c
 */
Packit Service 1d8f1c
gboolean         ibus_config_unwatch    (IBusConfig         *config,
Packit Service 1d8f1c
                                         const gchar        *section,
Packit Service 1d8f1c
                                         const gchar        *name);
Packit Service 1d8f1c
Packit Service 1d8f1c
/* FIXME add an asynchronous version of unwatch */
Packit Service 1d8f1c
Packit Service 1d8f1c
G_END_DECLS
Packit Service 1d8f1c
#endif
Packit Service 1d8f1c