]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
two-step: Add separate startup / shutdown animations
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 2 Mar 2015 22:53:25 +0000 (14:53 -0800)
committerRay Strode <rstrode@redhat.com>
Tue, 3 Mar 2015 00:20:44 +0000 (19:20 -0500)
In the case of Endless, we have a very fluid active bootup animation
that looks quite excellent for turning the computer on, but when turning
it off or restarting, it's sort of awkward to have the same animation
play. For our use case, we want to simply show our watermark.

src/plugins/splash/two-step/plugin.c

index 935d830d9a3f22bb074e7e0d63ef18533dff73e5..0899acee96b8e0916d13976a9190f9e2d82fed41 100644 (file)
@@ -156,8 +156,6 @@ view_new (ply_boot_splash_plugin_t *plugin,
         view->display = display;
 
         view->entry = ply_entry_new (plugin->animation_dir);
-        view->end_animation = ply_animation_new (plugin->animation_dir,
-                                                 "animation-");
         view->progress_animation = ply_progress_animation_new (plugin->animation_dir,
                                                                "progress-");
 
@@ -189,6 +187,57 @@ view_free (view_t *view)
         free (view);
 }
 
+static void
+view_load_end_animation (view_t *view)
+{
+        const char *animation_prefix;
+        ply_boot_splash_plugin_t *plugin;
+
+        ply_trace ("loading animation");
+
+        plugin = view->plugin;
+
+        switch (plugin->mode) {
+        case PLY_BOOT_SPLASH_MODE_BOOT_UP:
+        case PLY_BOOT_SPLASH_MODE_UPDATES:
+                animation_prefix = "startup-animation-";
+                break;
+        case PLY_BOOT_SPLASH_MODE_SHUTDOWN:
+                animation_prefix = "shutdown-animation-";
+                break;
+        }
+
+        ply_trace ("trying prefix: %s", animation_prefix);
+        view->end_animation = ply_animation_new (plugin->animation_dir,
+                                                 animation_prefix);
+
+        if (ply_animation_load (view->end_animation))
+                return;
+        ply_animation_free (view->end_animation);
+
+        ply_trace ("now trying more general prefix: animation-");
+        view->end_animation = ply_animation_new (plugin->animation_dir,
+                                                 "animation-");
+        if (ply_animation_load (view->end_animation))
+                return;
+        ply_animation_free (view->end_animation);
+
+        ply_trace ("now trying old compat prefix: throbber-");
+        view->end_animation = ply_animation_new (plugin->animation_dir,
+                                                 "throbber-");
+        if (ply_animation_load (view->end_animation)) {
+                /* files named throbber- are for end animation, so
+                 * there's no throbber */
+                ply_throbber_free (view->throbber);
+                view->throbber = NULL;
+                return;
+        }
+
+        ply_trace ("optional animation didn't load");
+        ply_animation_free (view->end_animation);
+        view->end_animation = NULL;
+}
+
 static bool
 view_load (view_t *view)
 {
@@ -216,24 +265,7 @@ view_load (view_t *view)
         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;
-        }
+        view_load_end_animation (view);
 
         ply_trace ("loading progress animation");
         if (!ply_progress_animation_load (view->progress_animation)) {