This code is ripped from gtk-sharp, and just provides a convenient way to invoke some code on the glib mainloop.
Exemple #1
0
        internal void Dispose()
        {
            //FIXME: find a better way to see if we have been already disposed
            if (!mainLoop.IsRunning)
            {
#if DEBUG
                //we prefer to crash, in order to fix ASAP the buggy clown that did this
                throw new ObjectDisposedException("You shouldn't call dispose more than once");
#else
                return;                // probably already disposed
#endif
            }
            AutoResetEvent sync = GLibHacks.Invoke(delegate(object sender, EventArgs args) {
                ShutdownAtkBridge();
                Atk.Util.GetRootHandler = null;
                mainLoop.Quit();
            });
            sync.WaitOne();
            sync.Close();
            sync = null;
        }
Exemple #2
0
        public void ApplicationStarts()
        {
            if (mainLoop != null && mainLoop.IsRunning)
            {
                Log.Warn("AutomationBridge: Received init event, but already running;  ignoring.");
                return;
            }

            CheckMainLoop();
            AutoResetEvent sync = GLibHacks.Invoke(delegate(object sender, EventArgs args) {
                Environment.SetEnvironmentVariable(ATK_BRIDGE_ENVVAR_NAME, null);
                LaunchAtkBridge();
                Environment.SetEnvironmentVariable(GAIL_ENVVAR_NAME, null);
            });

            sync.WaitOne();
            sync.Close();
            sync = null;

            Environment.SetEnvironmentVariable(GTK_MODULES_ENVVAR_NAME, gtk_modules_envvar_content);
        }
Exemple #3
0
 public bool HandleKey(Atk.KeyEventStruct evnt)
 {
     if (KeyListenerList.Count == 0)
     {
         return(false);
     }
     foreach (KeyValuePair <uint, KeyListenerInfo> kvp in KeyListenerList)
     {
         int            result = 0;
         AutoResetEvent sync   = GLibHacks.Invoke(delegate(object sender, EventArgs args) {
             result = kvp.Value.listener(evnt);
         });
         sync.WaitOne();
         sync.Close();
         sync = null;
         if (result != 0)
         {
             return(true);
         }
     }
     return(false);
 }