Create a buffer to hold boot messages and pass that buffer to plugin show functions

This commit is contained in:
Ray Strode 2008-05-19 22:54:46 -04:00
parent b08048505b
commit 038d5d6dd3
7 changed files with 33 additions and 9 deletions

View file

@ -49,6 +49,7 @@ typedef struct
ply_window_t *window;
ply_boot_splash_t *boot_splash;
ply_terminal_session_t *session;
ply_buffer_t *boot_buffer;
int original_root_dir_fd;
} state_t;
@ -192,7 +193,7 @@ start_boot_splash (state_t *state,
ply_trace ("Loading boot splash plugin '%s'",
module_path);
splash = ply_boot_splash_new (module_path, state->window);
splash = ply_boot_splash_new (module_path, state->window, state->boot_buffer);
ply_trace ("attaching plugin to event loop");
ply_boot_splash_attach_to_event_loop (splash, state->loop);
@ -227,6 +228,9 @@ spawn_session (state_t *state,
ply_trace ("attaching terminal session to event loop");
ply_terminal_session_attach_to_event_loop (session, state->loop);
ply_trace ("buffering terminal session for replay if user presses escape");
ply_terminal_session_set_output_buffer (session, state->boot_buffer);
ply_trace ("running '%s'", argv[0]);
if (!ply_terminal_session_run (session, flags,
(ply_terminal_session_begin_handler_t)
@ -236,6 +240,8 @@ spawn_session (state_t *state,
{
ply_save_errno ();
ply_terminal_session_free (session);
ply_buffer_free (state->boot_buffer);
state->boot_buffer = NULL;
ply_restore_errno ();
return NULL;
}
@ -455,6 +461,8 @@ main (int argc,
return EX_OSERR;
}
state.boot_buffer = ply_buffer_new ();
state.session = spawn_session (&state, argv + 1);
if (state.session == NULL)
@ -504,6 +512,8 @@ main (int argc,
ply_trace ("freeing terminal session");
ply_terminal_session_free (state.session);
ply_buffer_free (state.boot_buffer);
ply_trace ("freeing event loop");
ply_event_loop_free (state.loop);

View file

@ -28,6 +28,7 @@
#include "ply-event-loop.h"
#include "ply-window.h"
#include "ply-buffer.h"
typedef struct _ply_boot_splash_plugin ply_boot_splash_plugin_t;
@ -37,7 +38,8 @@ typedef struct
void (* destroy_plugin) (ply_boot_splash_plugin_t *plugin);
bool (* show_splash_screen) (ply_boot_splash_plugin_t *plugin,
ply_window_t *window);
ply_window_t *window,
ply_buffer_t *boot_buffer);
void (* update_status) (ply_boot_splash_plugin_t *plugin,
const char *status);
void (* hide_splash_screen) (ply_boot_splash_plugin_t *plugin,

View file

@ -45,6 +45,7 @@ struct _ply_boot_splash
const ply_boot_splash_plugin_interface_t *plugin_interface;
ply_boot_splash_plugin_t *plugin;
ply_window_t *window;
ply_buffer_t *boot_buffer;
char *module_name;
char *status;
@ -57,7 +58,8 @@ typedef const ply_boot_splash_plugin_interface_t *
ply_boot_splash_t *
ply_boot_splash_new (const char *module_name,
ply_window_t *window)
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
ply_boot_splash_t *splash;
@ -70,6 +72,7 @@ ply_boot_splash_new (const char *module_name,
splash->is_shown = false;
splash->window = window;
splash->boot_buffer = boot_buffer;
return splash;
}
@ -187,7 +190,8 @@ ply_boot_splash_show (ply_boot_splash_t *splash)
ply_trace ("showing splash screen\n");
if (!splash->plugin_interface->show_splash_screen (splash->plugin,
splash->window))
splash->window,
splash->boot_buffer))
{
ply_save_errno ();
@ -304,6 +308,7 @@ main (int argc,
ply_event_loop_t *loop;
ply_boot_splash_t *splash;
ply_window_t *window;
ply_buffer_t *buffer;
int exit_code;
const char *module_name;
@ -327,7 +332,8 @@ main (int argc,
ply_window_attach_to_event_loop (window, loop);
ply_window_set_escape_handler (window, (ply_window_escape_handler_t)on_quit, loop);
splash = ply_boot_splash_new (module_name, window);
buffer = ply_buffer_new ();
splash = ply_boot_splash_new (module_name, window, buffer);
ply_boot_splash_attach_to_event_loop (splash, loop);
if (!ply_boot_splash_show (splash))
@ -343,6 +349,7 @@ main (int argc,
splash);
exit_code = ply_event_loop_run (loop);
ply_boot_splash_free (splash);
ply_buffer_free (buffer);
return exit_code;
}

View file

@ -28,12 +28,14 @@
#include "ply-event-loop.h"
#include "ply-window.h"
#include "ply-buffer.h"
typedef struct _ply_boot_splash ply_boot_splash_t;
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_boot_splash_t *ply_boot_splash_new (const char *module_name,
ply_window_t *window);
ply_window_t *window,
ply_buffer_t *boot_buffer);
void ply_boot_splash_free (ply_boot_splash_t *splash);
bool ply_boot_splash_show (ply_boot_splash_t *splash);
void ply_boot_splash_update_status (ply_boot_splash_t *splash,

View file

@ -80,7 +80,8 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
assert (plugin != NULL);

View file

@ -321,7 +321,8 @@ on_interrupt (ply_boot_splash_plugin_t *plugin)
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
assert (plugin != NULL);
assert (plugin->logo_image != NULL);

View file

@ -96,7 +96,8 @@ open_console (ply_boot_splash_plugin_t *plugin)
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
assert (plugin != NULL);