const gchar *name,
GValue *value,
IBusError **error);
+static gboolean ibus_config_gconf_unset (IBusConfigService *config,
+ const gchar *section,
+ const gchar *name,
+ IBusError **error);
static GConfValue *_to_gconf_value (const GValue *value);
static void _from_gconf_value (GValue *value,
IBUS_OBJECT_CLASS (object_class)->destroy = (IBusObjectDestroyFunc) ibus_config_gconf_destroy;
IBUS_CONFIG_SERVICE_CLASS (object_class)->set_value = ibus_config_gconf_set_value;
IBUS_CONFIG_SERVICE_CLASS (object_class)->get_value = ibus_config_gconf_get_value;
+ IBUS_CONFIG_SERVICE_CLASS (object_class)->unset = ibus_config_gconf_unset;
}
static void
gconf_value_free (gv);
return TRUE;
}
+static gboolean
+ibus_config_gconf_unset (IBusConfigService *config,
+ const gchar *section,
+ const gchar *name,
+ IBusError **error)
+{
+ gchar *key;
+ GError *gerror = NULL;
+
+ key = g_strdup_printf (GCONF_PREFIX"/%s/%s", section, name);
+
+ gconf_client_unset (((IBusConfigGConf *)config)->client, key, &gerror);
+ g_free (key);
+
+ if (gerror != NULL) {
+ if (error) {
+ *error = ibus_error_new_from_text (DBUS_ERROR_FAILED, gerror->message);
+ g_error_free (gerror);
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+}
IBusConfigGConf *
ibus_config_gconf_new (IBusConnection *connection)
def set_value(self, section, name, value):
pass
+ def unset(self, section, name):
+ pass
+
def value_changed(self, section, name, value):
self.__proxy.ValueChanged(section, name, value)
def SetValue(self, section, name, value):
return self.__config.set_value(section, name, value)
+ def Unset(self, section, name):
+ return self.__config.unset(section, name)
+
def Destroy(self):
self.__config.destroy()
def set_list(self, section, name, value, signature):
return self.set_value(section, name, dbus.Array(value, signature=signature))
+ def unset(self, section, name):
+ try:
+ return self.__config.Unset(section, name)
+ except:
+ return
g_assert (retval);
return TRUE;
}
+
+gboolean
+ibus_config_unset (IBusConfig *config,
+ const gchar *section,
+ const gchar *name)
+{
+ g_assert (IBUS_IS_CONFIG (config));
+ g_assert (section != NULL);
+ g_assert (name != NULL);
+
+ gboolean retval;
+
+ retval = ibus_proxy_call ((IBusProxy *) config,
+ "Unset",
+ G_TYPE_STRING, §ion,
+ G_TYPE_STRING, &name,
+ G_TYPE_INVALID);
+ g_assert (retval);
+ return TRUE;
+}
const gchar *section,
const gchar *name,
const GValue *value);
+
+/**
+ * ibus_config_unset:
+ * @config: An IBusConfig
+ * @section: Section name of the configuration option.
+ * @name: Name of the configure option its self.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Remove an entry of a configuration option.
+ * @see_also: ibus_config_get_value.
+ */
+gboolean ibus_config_unset (IBusConfig *config,
+ const gchar *section,
+ const gchar *name);
G_END_DECLS
#endif
const gchar *name,
GValue *value,
IBusError **error);
+static gboolean ibus_config_service_unset (IBusConfigService *config,
+ const gchar *section,
+ const gchar *name,
+ IBusError **error);
static IBusServiceClass *parent_class = NULL;
klass->set_value = ibus_config_service_set_value;
klass->get_value = ibus_config_service_get_value;
+ klass->unset = ibus_config_service_unset;
/* install properties */
/**
g_value_unset (&value);
}
}
+ else if (ibus_message_is_method_call (message, IBUS_INTERFACE_CONFIG, "Unset")) {
+ gchar *section;
+ gchar *name;
+ IBusError *error = NULL;
+ gboolean retval;
+
+ retval = ibus_message_get_args (message,
+ &error,
+ G_TYPE_STRING, §ion,
+ G_TYPE_STRING, &name,
+ G_TYPE_INVALID);
+ if (!retval) {
+ reply = ibus_message_new_error_printf (message,
+ DBUS_ERROR_INVALID_ARGS,
+ "Can not parse arguments 1 of Unset");
+ ibus_error_free (error);
+ }
+ else if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->unset (config, section, name, &error)) {
+ reply = ibus_message_new_error (message,
+ error->name,
+ error->message);
+ ibus_error_free (error);
+ }
+ else {
+ reply = ibus_message_new_method_return (message);
+ }
+ }
if (reply) {
ibus_connection_send (connection, reply);
return FALSE;
}
+static gboolean
+ibus_config_service_unset (IBusConfigService *config,
+ const gchar *section,
+ const gchar *name,
+ IBusError **error)
+{
+ if (error) {
+ *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED,
+ "Can not unset [%s, %s]",
+ section, name);
+ }
+ return FALSE;
+}
+
void
ibus_config_service_value_changed (IBusConfigService *config,
const gchar *section,
* <para>Get value of a configuration option.
* </para>
* </listitem>
+ * <listitem>
+ * <para>gboolean unset(IBusConfigService *config, const gchar *section, const gchar *name,
+ * IBusError **error)
+ * </para>
+ * <variablelist>
+ * <varlistentry>
+ * <term>config:</term>
+ * <listitem>A configure service</listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>section:</term>
+ * <listitem>Section name of the configuration option.</listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>name:</term>
+ * <listitem>Name of the configuration option.</listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>error:</term>
+ * <listitem>Error outputs here.</listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>Returns:</term>
+ * <listitem>TRUE if succeed; FALSE otherwise.</listitem>
+ * </varlistentry>
+ * </variablelist>
+ * <para>Remove an entry to a configuration option.
+ * </para>
+ * </listitem>
* </itemizedlist>
*/
#ifndef __IBUS_CONFIG_SERVICE_H_
const gchar *name,
GValue *value,
IBusError **error);
+ gboolean (* unset) (IBusConfigService *config,
+ const gchar *section,
+ const gchar *name,
+ IBusError **error);
/*< private >*/
/* padding */