g_variant_new ("(v)", ibus_serializable_serialize ((IBusSerializable *)desc)));
}
else {
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "Input context does not have engine.");
+ g_dbus_method_invocation_return_error (
+ invocation,
+ IBUS_ERROR,
+ IBUS_ERROR_NO_ENGINE,
+ "Input context does not have engine.");
}
}
ibusservice.c \
ibusfactory.c \
ibusengine.c \
+ ibuserror.c \
ibustext.c \
ibuskeymap.c \
ibusattribute.c \
ibusservice.h \
ibusfactory.h \
ibusengine.h \
+ ibuserror.h \
ibustext.h \
ibuskeymap.h \
ibusattribute.h \
#include <ibusservice.h>
#include <ibusfactory.h>
#include <ibusengine.h>
+#include <ibuserror.h>
#include <ibusproperty.h>
#include <ibusproplist.h>
#include <ibuslookuptable.h>
--- /dev/null
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/* vim:set et sts=4: */
+/* ibus - The Input Bus
+ * Copyright (C) 2011 Peng Huang <shawn.p.huang@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "ibuserror.h"
+
+#include <gio/gio.h>
+#include "ibustypes.h"
+
+static const GDBusErrorEntry ibus_error_entries[] =
+{
+ { IBUS_ERROR_NO_ENGINE, "org.freedesktop.IBus.Error.NoEngine" },
+};
+
+GQuark
+ibus_error_quark (void)
+{
+ static volatile gsize quark_volatile = 0;
+ g_dbus_error_register_error_domain ("ibus-error-quark",
+ &quark_volatile,
+ ibus_error_entries,
+ G_N_ELEMENTS (ibus_error_entries));
+ return (GQuark) quark_volatile;
+}
--- /dev/null
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/* vim:set et sts=4: */
+/* ibus - The Input Bus
+ * Copyright (C) 2011 Peng Huang <shawn.p.huang@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
+#error "Only <ibus.h> can be included directly"
+#endif
+
+/**
+ * SECTION: ibusshare
+ * @short_description: Shared utility functions and definition.
+ * @stability: Stable
+ *
+ * This file defines some utility functions and definition
+ * which are shared among ibus component and services.
+ */
+
+#ifndef __IBUS_ERROR_H_
+#define __IBUS_ERROR_H_
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define IBUS_ERROR ibus_error_quark()
+GQuark ibus_error_quark (void);
+
+G_END_DECLS
+#endif
#include "ibusattribute.h"
#include "ibuslookuptable.h"
#include "ibusproplist.h"
+#include "ibuserror.h"
#define IBUS_INPUT_CONTEXT_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), IBUS_TYPE_INPUT_CONTEXT, IBusInputContextPrivate))
ibus_input_context_get_engine (IBusInputContext *context)
{
g_assert (IBUS_IS_INPUT_CONTEXT (context));
- GVariant *result;
+ GVariant *result = NULL;
GError *error = NULL;
result = g_dbus_proxy_call_sync ((GDBusProxy *) context,
"GetEngine", /* method_name */
NULL, /* cancellable */
&error /* error */
);
-
if (result == NULL) {
- g_warning ("%s.GetEngine: %s", IBUS_INTERFACE_INPUT_CONTEXT, error->message);
+ if (g_error_matches (error, IBUS_ERROR, IBUS_ERROR_NO_ENGINE)) {
+ g_debug ("%s.GetEngine: %s",
+ IBUS_INTERFACE_INPUT_CONTEXT,
+ error->message);
+ }
+ else {
+ g_warning ("%s.GetEngine: %s",
+ IBUS_INTERFACE_INPUT_CONTEXT,
+ error->message);
+ }
g_error_free (error);
return NULL;
}
ibus_init (void)
{
g_type_init ();
+ IBUS_ERROR;
IBUS_TYPE_TEXT;
IBUS_TYPE_ATTRIBUTE;
IBUS_TYPE_ATTR_LIST;
} IBusBusRequestNameReply;
/**
+ * IBusError:
+ * @IBUS_ERROR_NO_ENGINE:
+ * There is no engine associated with input context.
+ */
+typedef enum {
+ IBUS_ERROR_NO_ENGINE,
+} IBusError;
+
+/**
* IBusRectangle:
* @x: x coordinate.
* @y: y coordinate.
--- /dev/null
+#!/usr/bin/env python
+# vim:set et sts=4 sw=4:
+#
+# ibus - The Input Bus
+#
+# Copyright (c) 2011 Peng Huang <shawn.p.huang@gmail.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
+
+import glib
+import gio
+from gi.repository import IBus
+IBus.init()
+main = glib.MainLoop()
+bus = IBus.Bus()
+ic = bus.create_input_context("ibus-test")
+ic.get_engine()
+ic.get_engine()
+ic.get_engine()
+ic.get_engine()