static IBusServiceClass *parent_class = NULL;
+extern gboolean g_verbose;
+
GType
bus_ibus_impl_get_type (void)
{
component = ibus_component_get_from_engine ((IBusEngineDesc *) ibus->engine_list->data);
if (component && !ibus_component_is_running (component)) {
- ibus_component_start (component);
+ ibus_component_start (component, g_verbose);
}
}
}
IBusComponent *comp;
BusFactoryProxy *factory;
BusEngineProxy *engine;
+ GTimeVal t1, t2;
factory = bus_factory_proxy_get_from_engine (engine_desc);
g_assert (comp);
if (!ibus_component_is_running (comp)) {
- ibus_component_start (comp);
+ ibus_component_start (comp, g_verbose);
gint time = 0;
- while (time < G_USEC_PER_SEC * 3) {
+ g_get_current_time (&t1);
+ while (1) {
if (g_main_context_pending (NULL)) {
g_main_context_iteration (NULL, FALSE);
+ factory = bus_factory_proxy_get_from_engine (engine_desc);
+ if (factory != NULL) {
+ break;
+ }
}
- else {
- g_usleep (50 * 1000);
- time += 50 * 1000;
- }
- factory = bus_factory_proxy_get_from_engine (engine_desc);
- if (factory != NULL) {
+ g_get_current_time (&t2);
+ if (t2.tv_sec - t1.tv_sec >= 5)
break;
- }
}
}
- factory = bus_factory_proxy_get_from_engine (engine_desc);
+ else {
+ factory = bus_factory_proxy_get_from_engine (engine_desc);
+ }
}
if (factory == NULL) {
static gchar *desktop = "gnome";
static gchar *address = "";
gboolean g_rescan = FALSE;
-static gboolean verbose = FALSE;
+gboolean g_verbose = FALSE;
static const GOptionEntry entries[] =
{
{ "address", 'a', 0, G_OPTION_ARG_STRING, &address, "specify the address of ibus daemon.", "address" },
{ "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, "if there is an old ibus-daemon is running, it will be replaced.", NULL },
{ "re-scan", 't', 0, G_OPTION_ARG_NONE, &g_rescan, "force to re-scan components, and re-create registry cache.", NULL },
- { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "verbose.", NULL },
+ { "verbose", 'v', 0, G_OPTION_ARG_NONE, &g_verbose, "verbose.", NULL },
{ NULL },
};
const gchar *message,
gpointer user_data)
{
- if (verbose) {
+ if (g_verbose) {
g_log_default_handler (log_domain, log_level, message, user_data);
}
}
if (g_strcmp0 (config, "default") == 0) {
IBusComponent *component;
component = bus_registry_lookup_component_by_name (BUS_DEFAULT_REGISTRY, IBUS_SERVICE_CONFIG);
- if (component == NULL || !ibus_component_start (component)) {
+ if (component == NULL || !ibus_component_start (component, g_verbose)) {
g_printerr ("Can not execute default config program\n");
exit (-1);
}
if (g_strcmp0 (panel, "default") == 0) {
IBusComponent *component;
component = bus_registry_lookup_component_by_name (BUS_DEFAULT_REGISTRY, IBUS_SERVICE_PANEL);
- if (component == NULL || !ibus_component_start (component)) {
+ if (component == NULL || !ibus_component_start (component, g_verbose)) {
g_printerr ("Can not execute default panel program\n");
exit (-1);
}
}
gboolean
-ibus_component_start (IBusComponent *component)
+ibus_component_start (IBusComponent *component, gboolean verbose)
{
g_assert (IBUS_IS_COMPONENT (component));
gchar **argv;
gboolean retval;
GError *error;
+ GSpawnFlags flags;
error = NULL;
if (!g_shell_parse_argv (component->exec, &argc, &argv, &error)) {
}
error = NULL;
+ flags = G_SPAWN_DO_NOT_REAP_CHILD;
+ if (!verbose) {
+ flags |= G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL;
+ }
retval = g_spawn_async (NULL, argv, NULL,
- G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+ flags,
NULL, NULL,
&(component->pid), &error);
g_strfreev (argv)