From fceb77c9dffd6644944bfd26e77ace64aba3f96f Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 26 Oct 2015 13:20:18 -0400 Subject: [PATCH 1/2] two-step: don't tank in updates mode when there's no progress animations Right now we try to use the progress animation in updates mode, even if there's not one. This commit makes the progress animation truely optional. --- src/plugins/splash/two-step/plugin.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 541a108..ceca101 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -180,66 +180,73 @@ view_free (view_t *view) } static bool view_load (view_t *view) { ply_trace ("loading entry"); if (!ply_entry_load (view->entry)) return false; ply_trace ("loading animation"); if (!ply_animation_load (view->end_animation)) { ply_trace ("Default animation wouldn't load, " "falling back to old naming scheme"); /* fallback to throbber- for compatibility */ ply_animation_free (view->end_animation); view->end_animation = ply_animation_new (view->plugin->animation_dir, "throbber-"); if (!ply_animation_load (view->end_animation)) { ply_trace ("old naming scheme didn't work either"); return false; } ply_throbber_free (view->throbber); view->throbber = NULL; } - ply_trace ("loading progress animation"); - if (!ply_progress_animation_load (view->progress_animation)) + if (view->progress_animation != NULL) + { + ply_trace ("loading progress animation"); + if (!ply_progress_animation_load (view->progress_animation)) + { + ply_trace ("optional progress animation wouldn't load"); + ply_progress_animation_free (view->progress_animation); + view->progress_animation = NULL; + } + } + else { - ply_trace ("optional progress animation wouldn't load"); - ply_progress_animation_free (view->progress_animation); - view->progress_animation = NULL; + ply_trace ("this theme has no progress animation\n"); } if (view->throbber != NULL) { ply_trace ("loading throbber"); if (!ply_throbber_load (view->throbber)) { ply_trace ("optional throbber was not loaded"); ply_throbber_free (view->throbber); view->throbber = NULL; } } else { ply_trace ("this theme has no throbber\n"); } return true; } static bool load_views (ply_boot_splash_plugin_t *plugin) { ply_list_node_t *node; bool view_loaded; view_loaded = false; node = ply_list_get_first_node (plugin->views); while (node != NULL) @@ -1249,62 +1256,63 @@ show_message (ply_boot_splash_plugin_t *plugin, view = ply_list_node_get_data (node); next_node = ply_list_get_next_node (plugin->views, node); ply_label_set_text (view->message_label, message); ply_label_show (view->message_label, view->display, 10, 10); ply_pixel_display_draw_area (view->display, 10, 10, ply_label_get_width (view->message_label), ply_label_get_height(view->message_label)); node = next_node; } } static void system_update (ply_boot_splash_plugin_t *plugin, int progress) { ply_list_node_t *node; if (plugin->mode != PLY_BOOT_SPLASH_MODE_UPDATES) return; node = ply_list_get_first_node (plugin->views); while (node != NULL) { ply_list_node_t *next_node; view_t *view; view = ply_list_node_get_data (node); next_node = ply_list_get_next_node (plugin->views, node); - ply_progress_animation_set_percent_done (view->progress_animation, - (double) progress / 100.f); + if (view->progress_animation != NULL) + ply_progress_animation_set_percent_done (view->progress_animation, + (double) progress / 100.f); node = next_node; } } static void display_normal (ply_boot_splash_plugin_t *plugin) { pause_views (plugin); if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL) hide_prompt (plugin); plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL; start_progress_animation (plugin); redraw_views (plugin); unpause_views (plugin); } static void display_password (ply_boot_splash_plugin_t *plugin, const char *prompt, int bullets) { pause_views (plugin); if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL) stop_animation (plugin, NULL); plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY; show_password_prompt (plugin, prompt, bullets); redraw_views (plugin); unpause_views (plugin); -- 2.5.0 From 5de88b84ee949aaa80fafbf9e794bc2b9eddb6a6 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 26 Oct 2015 13:28:33 -0400 Subject: [PATCH 2/2] script: only support one message at a time That's the other themes do, and callers expect it. --- themes/script/script.script | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/themes/script/script.script b/themes/script/script.script index 7ea9d5e..25a2f2b 100644 --- a/themes/script/script.script +++ b/themes/script/script.script @@ -125,55 +125,47 @@ progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); progress_bar.original_image = Image("progress_bar.png"); progress_bar.sprite = Sprite(); progress_bar.x = Window.GetX() + Window.GetWidth() / 2 - progress_bar.original_image.GetWidth() / 2; progress_bar.y = Window.GetY() + Window.GetHeight() / 2 * 1.5 - progress_box.image.GetHeight() / 2 + (progress_box.image.GetHeight() - progress_bar.original_image.GetHeight()) / 2; progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); fun progress_callback (duration, progress) { if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) { progress_bar.image = progress_bar.original_image.Scale(progress_bar.original_image.GetWidth(progress_bar.original_image) * progress, progress_bar.original_image.GetHeight()); progress_bar.sprite.SetImage (progress_bar.image); } } Plymouth.SetBootProgressFunction(progress_callback); #----------------------------------------- Quit -------------------------------- fun quit_callback () { logo.sprite.SetOpacity (1); } Plymouth.SetQuitFunction(quit_callback); #----------------------------------------- Message -------------------------------- -message_sprites = []; -message_sprite_count = 0; -message_sprite_y = 10; +message_sprite = Sprite(); +message_sprite.SetPosition(10, 10, 10000); fun display_message_callback (text) { my_image = Image.Text(text, 1, 1, 1); - message_sprites[message_sprite_count] = Sprite(my_image); - message_sprites[message_sprite_count].SetPosition(10, message_sprite_y, 10000); - message_sprites[message_sprite_count].text = text; - message_sprite_count++; - message_sprite_y += my_image.GetHeight(); + message_sprite.SetImage(my_image); } fun hide_message_callback (text) { - for (i = 0; i < message_sprite_count; i++) - { - if (message_sprites[i].text == text) - message_sprites[i] = NULL; - } + message_sprite = Sprite(); + message_sprite.SetPosition(10, 10, 10000); } Plymouth.SetDisplayMessageFunction (display_message_callback); Plymouth.SetHideMessageFunction (hide_message_callback); -- 2.5.0