static gboolean single = FALSE;
static gboolean xim = FALSE;
static gboolean replace = FALSE;
+static gboolean restart = FALSE;
static gchar *panel = "default";
static gchar *config = "default";
static gchar *desktop = "gnome";
{ "monitor-timeout", 'j', 0, G_OPTION_ARG_INT, &g_monitor_timeout, "timeout of poll changes of engines in seconds. 0 to disable it. ", "timeout [default is 0]" },
#endif
{ "mem-profile", 'm', 0, G_OPTION_ARG_NONE, &g_mempro, "enable memory profile, send SIGUSR2 to print out the memory profile.", NULL },
+ { "restart", 'r', 0, G_OPTION_ARG_NONE, &restart, "restart panel and config processes when they die.", NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &g_verbose, "verbose.", NULL },
{ NULL },
};
if (g_strcmp0 (config, "default") == 0) {
IBusComponent *component;
component = bus_registry_lookup_component_by_name (BUS_DEFAULT_REGISTRY, IBUS_SERVICE_CONFIG);
+ if (component) {
+ ibus_component_set_restart (component, restart);
+ }
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) {
+ ibus_component_set_restart (component, restart);
+ }
if (component == NULL || !ibus_component_start (component, g_verbose)) {
g_printerr ("Can not execute default panel program\n");
exit (-1);
/* IBusComponentPriv */
struct _IBusComponentPrivate {
- gpointer pad;
+ // TRUE if the component started in the verbose mode.
+ gboolean verbose;
+ // TRUE if the component needs to be restarted when it dies.
+ gboolean restart;
};
typedef struct _IBusComponentPrivate IBusComponentPrivate;
#define IBUS_COMPONENT_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), BUS_TYPE_COMPONENT, IBusComponentPrivate))
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), IBUS_TYPE_COMPONENT, IBusComponentPrivate))
// static guint _signals[LAST_SIGNAL] = { 0 };
IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass);
IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass);
+ g_type_class_add_private (klass, sizeof (IBusComponentPrivate));
+
object_class->destroy = (IBusObjectDestroyFunc) ibus_component_destroy;
serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_component_serialize;
component->observed_paths = NULL;
component->pid = 0;
component->child_source_id = 0;
+
+ IBusComponentPrivate * priv = IBUS_COMPONENT_GET_PRIVATE (component);
+ priv->verbose = FALSE;
+ priv->restart = FALSE;
}
static void
g_spawn_close_pid (pid);
component->pid = 0;
component->child_source_id = 0;
+
+ IBusComponentPrivate *priv = IBUS_COMPONENT_GET_PRIVATE (component);
+ if (priv->restart) {
+ g_debug ("==== Restarting %s", component->exec);
+ ibus_component_start (component, priv->verbose);
+ }
}
gboolean
if (component->pid != 0)
return TRUE;
+ IBusComponentPrivate *priv = IBUS_COMPONENT_GET_PRIVATE (component);
+ priv->verbose = verbose;
+
gint argc;
gchar **argv;
gboolean retval;
component = (IBusComponent *)g_object_get_data ((GObject *)engine, "component");
return component;
}
+
+void
+ibus_component_set_restart (IBusComponent *component, gboolean restart)
+{
+ g_assert (IBUS_IS_COMPONENT (component));
+
+ IBusComponentPrivate *priv = IBUS_COMPONENT_GET_PRIVATE (component);
+ priv->restart = restart;
+}
/**
* ibus_component_start:
* @component: An IBusComponent.
- * @verbose: if redirect the child output to /dev/null
+ * @verbose: if FALSE, redirect the child output to /dev/null
* @returns: TRUE if the component is started; FALSE otherwise.
*
* Whether the IBusComponent is started.
*/
IBusComponent *ibus_component_get_from_engine (IBusEngineDesc *engine);
+/**
+ * ibus_component_set_restart:
+ * @component: An IBusComponent.
+ * @restart: if TRUE, the component will be restartd when it dies.
+ *
+ * Set whether the component needs to be restarted when it dies.
+ */
+void ibus_component_set_restart (IBusComponent *component,
+ gboolean restart);
+
+
G_END_DECLS
#endif