~pkg-ime/ibus/debian-ibus

« back to all changes in this revision

Viewing changes to bus/ibusimpl.c

  • Committer: Asias He
  • Date: 2010-12-05 07:43:51 UTC
  • mfrom: (41.1.42 upstream)
  • Revision ID: asias.hejun@gmail.com-20101205074351-r53b8l45l483cchg
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
812
812
    return reply;
813
813
}
814
814
 
 
815
 
 
816
static gboolean
 
817
_timeout_cb (gpointer data)
 
818
{
 
819
    return TRUE;
 
820
}
 
821
 
815
822
static BusFactoryProxy *
816
823
_get_factory_proxy(IBusEngineDesc *engine_desc)
817
824
{
818
 
    BusFactoryProxy *factory;
819
 
    GTimeVal t1, t2;
820
 
    g_get_current_time (&t1);
821
 
    while (1) {
822
 
        if (g_main_context_pending (NULL)) {
823
 
            g_main_context_iteration (NULL, FALSE);
 
825
    BusFactoryProxy *factory = NULL;
 
826
 
 
827
    /* Add a timeout to wake up g_main_context_iteration in every 0.5 second,
 
828
     * and then to check the factory assocated with the engine_desc */
 
829
    guint timeout_id = g_timeout_add (500, _timeout_cb, NULL);
 
830
 
 
831
    GTimer *timer = g_timer_new ();
 
832
 
 
833
    /* Leave the loop, if it spends more than 5 seconds */
 
834
    while (g_timer_elapsed (timer, NULL) <= 5.0) {
 
835
        if (g_main_context_iteration (NULL, TRUE)) {
824
836
            factory = bus_factory_proxy_get_from_engine (engine_desc);
825
837
            if (factory != NULL) {
826
 
                return factory;
 
838
                break;
827
839
            }
828
840
        }
829
 
        g_get_current_time (&t2);
830
 
        if (t2.tv_sec - t1.tv_sec >= 5)
831
 
            break;
832
841
    }
833
 
    return NULL;
 
842
 
 
843
    g_source_remove (timeout_id);
 
844
    g_timer_destroy (timer);
 
845
 
 
846
    return factory;
834
847
}
835
848
 
836
849
static BusEngineProxy *