Exemplo n.º 1
0
        /// <summary/>
        public DummyInputBusController()
        {
            m_connection = IBusConnectionFactory.Create();

            if (m_connection == null)
            {
                return;
            }

            m_ibus         = new IBusDotNet.InputBusWrapper(m_connection);
            m_inputContext = m_ibus.InputBus.CreateInputContext("UnitTest");
            m_inputContext.SetCapabilities(Capabilities.Focus | Capabilities.PreeditText);
        }
Exemplo n.º 2
0
        /// <summary>Get Ibus keyboard at given index</summary>
        public string GetKeyboardName(int index)
        {
            if (Connection == null)
            {
                return(String.Empty);
            }
            var ibusWrapper = new IBusDotNet.InputBusWrapper(Connection);

            object[]       engines    = ibusWrapper.InputBus.ListActiveEngines();
            IBusEngineDesc engineDesc = IBusEngineDesc.GetEngineDesc(engines[index]);

            return(FormatKeyboardIdentifier(engineDesc));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Wrap an ibus with protection incase DBus connection is dropped.
 /// </summary>
 protected void ProtectedIBusInvoke(Action action)
 {
     try
     {
         action();
     }
     catch (NDesk.DBus.DBusConectionErrorException error)
     {
         m_ibus         = null;
         m_inputContext = null;
         NotifyUserOfIBusConnectionDropped();
     }
     catch (System.NullReferenceException)
     {
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Send a KeyEvent to ibus.
        /// </summary>
        public bool ProcessKeyEvent(uint keyval, uint keycode, uint state)
        {
            if (m_inputContext == null)
            {
                return(false);
            }

            try
            {
                return(m_inputContext.ProcessKeyEvent(keyval, keycode, state));
            }
            catch (NDesk.DBus.DBusConectionErrorException error)
            {
                m_ibus         = null;
                m_inputContext = null;
                NotifyUserOfIBusConnectionDropped();
                return(false);
            }
        }
Exemplo n.º 5
0
        public void CanGetEngineDesc()
        {
            Connection = IBusConnectionFactory.Create();
            if (Connection == null)
            {
                Assert.Ignore("Can't run this test without ibus running.");
                return;
            }

            var ibusWrapper = new IBusDotNet.InputBusWrapper(Connection);

            object[] engines = ibusWrapper.InputBus.ListActiveEngines();
            if (engines.Length == 0)
            {
                Assert.Ignore("Can't run this test without any ibus keyboards installed.");
                return;
            }

            Assert.IsNotNull(IBusEngineDesc.GetEngineDesc(engines[0]));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create a Connection to Ibus. If successfull Connected property is true.
        /// </summary>
        public IBusCommunicator()
        {
            m_connection = IBusConnectionFactory.Create();

            if (m_connection == null)
            {
                return;
            }

            // Prevent hanging on exit issues caused by missing dispose calls, or strange interaction
            // between ComObjects and managed object.
            Application.ThreadExit += (sender, args) =>
            {
                if (m_connection != null)
                {
                    m_connection.Dispose();
                }
            };

            m_ibus = new IBusDotNet.InputBusWrapper(m_connection);
        }