]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Simplify plugin interface by dropping attach_to_event_loop
authorRay Strode <rstrode@redhat.com>
Wed, 21 May 2008 12:57:59 +0000 (08:57 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 21 May 2008 12:57:59 +0000 (08:57 -0400)
Now we just pass the loop in directly to show and hide,
which makes its lifecycle more clear.

src/ply-boot-splash-plugin.h
src/ply-boot-splash.c
src/splash-plugins/details/details.c
src/splash-plugins/fedora-fade-in/fedora-fade-in.c
src/splash-plugins/text/text.c

index 890b709cc7ceb88b09fc6731be7af89e436a95e6..a93d07fcd438c55834a8a19fb44c0cd91c7f4671 100644 (file)
@@ -38,6 +38,7 @@ typedef struct
   void (* destroy_plugin) (ply_boot_splash_plugin_t *plugin);
 
   bool (* show_splash_screen) (ply_boot_splash_plugin_t *plugin,
+                               ply_event_loop_t         *loop,
                                ply_window_t             *window,
                                ply_buffer_t             *boot_buffer);
   void (* update_status) (ply_boot_splash_plugin_t *plugin,
@@ -46,9 +47,8 @@ typedef struct
                            const char               *output,
                            size_t                    size);
   void (* hide_splash_screen) (ply_boot_splash_plugin_t *plugin,
+                               ply_event_loop_t         *loop,
                                ply_window_t             *window);
-  void (* attach_to_event_loop) (ply_boot_splash_plugin_t *plugin,
-                                 ply_event_loop_t         *loop);
 
   char * (* ask_for_password) (ply_boot_splash_plugin_t *plugin);
   void (* on_keyboard_input) (ply_boot_splash_plugin_t *plugin,
index 9d59d5d1ce2740f1b36d96d67ece4d495f3c2289..c24ca64c1c6088cca36475aab56177b2749537e2 100644 (file)
@@ -176,12 +176,7 @@ ply_boot_splash_show (ply_boot_splash_t *splash)
 
   assert (splash->plugin_interface != NULL);
   assert (splash->plugin != NULL);
-  assert (splash->plugin_interface->attach_to_event_loop != NULL);
   assert (splash->plugin_interface->show_splash_screen != NULL);
-
-  splash->plugin_interface->attach_to_event_loop (splash->plugin,
-                                                  splash->loop);
-
   assert (splash->window != NULL);
 
   ply_window_set_keyboard_input_handler (splash->window,
@@ -190,6 +185,7 @@ 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->loop,
                                                      splash->window,
                                                      splash->boot_buffer))
     {
@@ -259,6 +255,7 @@ ply_boot_splash_hide (ply_boot_splash_t *splash)
   assert (splash->plugin_interface->hide_splash_screen != NULL);
 
   splash->plugin_interface->hide_splash_screen (splash->plugin,
+                                                splash->loop,
                                                 splash->window);
 
   ply_window_set_keyboard_input_handler (splash->window, NULL, NULL);
index 6eca872ab4c1a9fc1fc6c5e3f3fe3f8de265a1f6..30c9bf915f86401f9afa3299c09b90ca51070c8e 100644 (file)
@@ -78,8 +78,17 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
   free (plugin);
 }
 
+static void
+detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
+{
+  plugin->loop = NULL;
+
+  ply_trace ("detaching from event loop");
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
+                    ply_event_loop_t         *loop,
                     ply_window_t             *window,
                     ply_buffer_t             *boot_buffer)
 {
@@ -87,6 +96,12 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   assert (plugin != NULL);
 
+  plugin->loop = loop;
+
+  ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
+                                 detach_from_event_loop,
+                                 plugin);
+
   size = ply_buffer_get_size (boot_buffer);
 
   if (size > 0)
@@ -115,16 +130,9 @@ on_boot_output (ply_boot_splash_plugin_t *plugin,
     write (STDOUT_FILENO, output, size);
 }
 
-static void
-detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
-{
-  plugin->loop = NULL;
-
-  ply_trace ("detaching from event loop");
-}
-
 void
 hide_splash_screen (ply_boot_splash_plugin_t *plugin,
+                    ply_event_loop_t         *loop,
                     ply_window_t             *window)
 {
   assert (plugin != NULL);
@@ -138,19 +146,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
   detach_from_event_loop (plugin);
 }
 
-void
-attach_to_event_loop (ply_boot_splash_plugin_t *plugin,
-                      ply_event_loop_t         *loop)
-{
-  ply_trace ("attaching to event loop");
-
-  plugin->loop = loop;
-
-  ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
-                                 detach_from_event_loop,
-                                 plugin);
-}
-
 char *
 ask_for_password (ply_boot_splash_plugin_t *plugin)
 {
@@ -196,7 +191,6 @@ ply_boot_splash_plugin_get_interface (void)
       .update_status = update_status,
       .on_boot_output = on_boot_output,
       .hide_splash_screen = hide_splash_screen,
-      .attach_to_event_loop = attach_to_event_loop,
       .ask_for_password = ask_for_password,
       .on_keyboard_input = on_keyboard_input
     };
index eb014f3d6128339e2761d7dca455ec389d05f3aa..820a56caecde15706396f7c5dc3eb9570652b9a2 100644 (file)
@@ -321,8 +321,17 @@ on_interrupt (ply_boot_splash_plugin_t *plugin)
   stop_animation (plugin);
 }
 
+static void
+detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
+{
+  plugin->loop = NULL;
+
+  ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
+                    ply_event_loop_t         *loop,
                     ply_window_t             *window,
                     ply_buffer_t             *boot_buffer)
 {
@@ -330,6 +339,11 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   assert (plugin->logo_image != NULL);
   assert (plugin->frame_buffer != NULL);
 
+  plugin->loop = loop;
+  ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
+                                 detach_from_event_loop,
+                                 plugin);
+
   ply_trace ("loading logo image");
   if (!ply_image_load (plugin->logo_image))
     return false;
@@ -441,16 +455,9 @@ update_status (ply_boot_splash_plugin_t *plugin,
   add_star (plugin);
 }
 
-static void
-detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
-{
-  plugin->loop = NULL;
-
-  ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
-}
-
 void
 hide_splash_screen (ply_boot_splash_plugin_t *plugin,
+                    ply_event_loop_t         *loop,
                     ply_window_t             *window)
 {
   assert (plugin != NULL);
@@ -468,17 +475,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
   ply_frame_buffer_close (plugin->frame_buffer);
 }
 
-void
-attach_to_event_loop (ply_boot_splash_plugin_t *plugin,
-                      ply_event_loop_t         *loop)
-{
-  plugin->loop = loop;
-
-  ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) 
-                                 detach_from_event_loop,
-                                 plugin); 
-}
-
 void
 on_keyboard_input (ply_boot_splash_plugin_t *plugin,
                    const char               *keyboard_input)
@@ -495,7 +491,6 @@ ply_boot_splash_plugin_get_interface (void)
       .show_splash_screen = show_splash_screen,
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
-      .attach_to_event_loop = attach_to_event_loop,
       .on_keyboard_input = on_keyboard_input
     };
 
index 6ae750aa5dd208dc18584d1669adc25befff1f0c..d65c0be4c4766e100f32f579d9e7d8021ed8f50f 100644 (file)
@@ -94,13 +94,27 @@ open_console (ply_boot_splash_plugin_t *plugin)
   return true;
 }
 
+static void
+detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
+{
+  plugin->loop = NULL;
+
+  ply_trace ("detaching from event loop");
+}
+
 bool
 show_splash_screen (ply_boot_splash_plugin_t *plugin,
+                    ply_event_loop_t         *loop,
                     ply_window_t             *window,
                     ply_buffer_t             *boot_buffer)
 {
   assert (plugin != NULL);
 
+  plugin->loop = loop;
+  ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
+                                 detach_from_event_loop,
+                                 plugin);
+
   ply_trace ("opening console");
   if (!open_console (plugin))
     return false;
@@ -118,16 +132,9 @@ update_status (ply_boot_splash_plugin_t *plugin,
   write (plugin->console_fd, ".", 1);
 }
 
-static void
-detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
-{
-  plugin->loop = NULL;
-
-  ply_trace ("detaching from event loop");
-}
-
 void
 hide_splash_screen (ply_boot_splash_plugin_t *plugin,
+                    ply_event_loop_t         *loop,
                     ply_window_t             *window)
 {
   assert (plugin != NULL);
@@ -144,18 +151,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
     }
 }
 
-void
-attach_to_event_loop (ply_boot_splash_plugin_t *plugin,
-                      ply_event_loop_t         *loop)
-{
-  plugin->loop = loop;
-
-  ply_trace ("attaching to event loop");
-  ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
-                                 detach_from_event_loop,
-                                 plugin);
-}
-
 char *
 ask_for_password (ply_boot_splash_plugin_t *plugin)
 {
@@ -200,7 +195,6 @@ ply_boot_splash_plugin_get_interface (void)
       .show_splash_screen = show_splash_screen,
       .update_status = update_status,
       .hide_splash_screen = hide_splash_screen,
-      .attach_to_event_loop = attach_to_event_loop,
       .ask_for_password = ask_for_password,
       .on_keyboard_input = on_keyboard_input
     };