]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Factor handler registration code out into separate functions in plugins
authorRay Strode <rstrode@redhat.com>
Mon, 9 Mar 2009 16:16:10 +0000 (12:16 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 9 Mar 2009 16:28:25 +0000 (12:28 -0400)
This will make it easier to unregister the handlers from both
hide and destroy

src/plugins/splash/fade-in/plugin.c
src/plugins/splash/glow/plugin.c
src/plugins/splash/pulser/plugin.c
src/plugins/splash/solar/plugin.c
src/plugins/splash/spinfinity/plugin.c
src/plugins/splash/text/plugin.c

index 71411d50c055cac23a32d0bd98629cbe063d57c3..598bc08ad511e33397cb3f1ef83b200d419f81aa 100644 (file)
@@ -156,6 +156,9 @@ free_stars (ply_boot_splash_plugin_t *plugin)
   plugin->stars = NULL;
 }
 
+static void add_handlers (ply_boot_splash_plugin_t *plugin);
+static void remove_handlers (ply_boot_splash_plugin_t *plugin);
+
 static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
 
 void
@@ -440,6 +443,39 @@ on_erase (ply_boot_splash_plugin_t *plugin,
                                        PLYMOUTH_BACKGROUND_END_COLOR);
 }
 
+static void
+add_handlers (ply_boot_splash_plugin_t *plugin)
+{
+  ply_window_add_keyboard_input_handler (plugin->window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_add_backspace_handler (plugin->window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_add_enter_handler (plugin->window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
+  ply_window_set_draw_handler (plugin->window,
+                               (ply_window_draw_handler_t)
+                               on_draw, plugin);
+
+  ply_window_set_erase_handler (plugin->window,
+                               (ply_window_erase_handler_t)
+                               on_erase, plugin);
+}
+
+static void
+remove_handlers (ply_boot_splash_plugin_t *plugin)
+{
+
+  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
+  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
+  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
+  ply_window_set_draw_handler (plugin->window, NULL, NULL);
+  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+}
+
 void
 add_window (ply_boot_splash_plugin_t *plugin,
             ply_window_t             *window)
@@ -462,23 +498,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   assert (plugin != NULL);
   assert (plugin->logo_image != NULL);
 
-  ply_window_add_keyboard_input_handler (plugin->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, plugin);
-  ply_window_add_backspace_handler (plugin->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, plugin);
-  ply_window_add_enter_handler (plugin->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, plugin);
-
-  ply_window_set_draw_handler (plugin->window,
-                               (ply_window_draw_handler_t)
-                               on_draw, plugin);
-
-  ply_window_set_erase_handler (plugin->window,
-                               (ply_window_erase_handler_t)
-                               on_erase, plugin);
+  add_handlers (plugin);
 
   plugin->loop = loop;
 
@@ -605,11 +625,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
-  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
-  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
-  ply_window_set_draw_handler (plugin->window, NULL, NULL);
-  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+  remove_handlers (plugin);
 
   if (plugin->loop != NULL)
     {
index 113ec869092d8cfe2aa2f4f4fa638a25106ccb15..c81c9215d1e31f84bede406536bfb531d8f1b420 100644 (file)
@@ -94,6 +94,9 @@ struct _ply_boot_splash_plugin
   uint32_t is_animating : 1;
 };
 
+static void add_handlers (ply_boot_splash_plugin_t *plugin);
+static void remove_handlers (ply_boot_splash_plugin_t *plugin);
+
 static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
 ply_boot_splash_plugin_t *
 create_plugin (void)
@@ -317,6 +320,39 @@ on_erase (ply_boot_splash_plugin_t *plugin,
                                        PLYMOUTH_BACKGROUND_END_COLOR);
 }
 
+static void
+add_handlers (ply_boot_splash_plugin_t *plugin)
+{
+  ply_window_add_keyboard_input_handler (plugin->window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_add_backspace_handler (plugin->window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_add_enter_handler (plugin->window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
+  ply_window_set_draw_handler (plugin->window,
+                               (ply_window_draw_handler_t)
+                               on_draw, plugin);
+
+  ply_window_set_erase_handler (plugin->window,
+                               (ply_window_erase_handler_t)
+                               on_erase, plugin);
+}
+
+static void
+remove_handlers (ply_boot_splash_plugin_t *plugin)
+{
+
+  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
+  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
+  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
+  ply_window_set_draw_handler (plugin->window, NULL, NULL);
+  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+}
+
 void
 add_window (ply_boot_splash_plugin_t *plugin,
             ply_window_t             *window)
@@ -338,23 +374,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  ply_window_add_keyboard_input_handler (plugin->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, plugin);
-  ply_window_add_backspace_handler (plugin->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, plugin);
-  ply_window_add_enter_handler (plugin->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, plugin);
-
-  ply_window_set_draw_handler (plugin->window,
-                               (ply_window_draw_handler_t)
-                               on_draw, plugin);
-
-  ply_window_set_erase_handler (plugin->window,
-                               (ply_window_erase_handler_t)
-                               on_erase, plugin);
+  add_handlers (plugin);
 
   plugin->loop = loop;
 
@@ -451,12 +471,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-
-  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
-  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
-  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
-  ply_window_set_draw_handler (plugin->window, NULL, NULL);
-  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+  remove_handlers (plugin);
 
   if (plugin->loop != NULL)
     {
index 82a25c18cf03314adbed6ad65697e81a842124e2..122139eded04114fc46fadb58117b0132180c3f7 100644 (file)
@@ -70,6 +70,8 @@ struct _ply_boot_splash_plugin
 };
 void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
                          ply_event_loop_t         *loop);
+static void add_handlers (ply_boot_splash_plugin_t *plugin);
+static void remove_handlers (ply_boot_splash_plugin_t *plugin);
 
 ply_boot_splash_plugin_t *
 create_plugin (void)
@@ -203,6 +205,37 @@ on_erase (ply_boot_splash_plugin_t *plugin,
   ply_window_clear_screen (plugin->window);
 }
 
+static void
+add_handlers (ply_boot_splash_plugin_t *plugin)
+{
+  ply_window_add_keyboard_input_handler (plugin->window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_add_backspace_handler (plugin->window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_add_enter_handler (plugin->window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+  ply_window_set_draw_handler (plugin->window,
+                               (ply_window_draw_handler_t)
+                                on_draw, plugin);
+  ply_window_set_erase_handler (plugin->window,
+                                (ply_window_erase_handler_t)
+                                on_erase, plugin);
+}
+
+static void
+remove_handlers (ply_boot_splash_plugin_t *plugin)
+{
+
+  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
+  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
+  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
+  ply_window_set_draw_handler (plugin->window, NULL, NULL);
+  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+}
+
 void
 add_window (ply_boot_splash_plugin_t *plugin,
             ply_window_t             *window)
@@ -224,24 +257,9 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
+  add_handlers (plugin);
   ply_show_new_kernel_messages (false);
 
-  ply_window_add_keyboard_input_handler (plugin->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, plugin);
-  ply_window_add_backspace_handler (plugin->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, plugin);
-  ply_window_add_enter_handler (plugin->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, plugin);
-  ply_window_set_draw_handler (plugin->window,
-                               (ply_window_draw_handler_t)
-                                on_draw, plugin);
-  ply_window_set_erase_handler (plugin->window,
-                                (ply_window_erase_handler_t)
-                                on_erase, plugin);
-
   plugin->loop = loop;
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
                                  detach_from_event_loop,
@@ -282,11 +300,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   if (plugin->window != NULL)
     {
-      ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
-      ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
-      ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
-      ply_window_set_draw_handler (plugin->window, NULL, NULL);
-      ply_window_set_erase_handler (plugin->window, NULL, NULL);
+      remove_handlers (plugin);
 
       ply_window_set_background_color (plugin->window, PLY_WINDOW_COLOR_DEFAULT);
       ply_window_clear_screen (plugin->window);
index 1c3b6a5da20ba593c746d31b5a806fb9fe72691d..d80d97f9cd3d6a5633fb5c8a6abf457f15870ef3 100644 (file)
@@ -200,6 +200,9 @@ struct _ply_boot_splash_plugin
   uint32_t is_animating : 1;
 };
 
+static void add_handlers (ply_boot_splash_plugin_t *plugin);
+static void remove_handlers (ply_boot_splash_plugin_t *plugin);
+
 static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
 
 
@@ -1108,6 +1111,39 @@ on_erase (ply_boot_splash_plugin_t *plugin,
                                                      ply_image_get_data (plugin->logo_image));
 }
 
+static void
+add_handlers (ply_boot_splash_plugin_t *plugin)
+{
+  ply_window_add_keyboard_input_handler (plugin->window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_add_backspace_handler (plugin->window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_add_enter_handler (plugin->window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
+  ply_window_set_draw_handler (plugin->window,
+                               (ply_window_draw_handler_t)
+                               on_draw, plugin);
+
+  ply_window_set_erase_handler (plugin->window,
+                               (ply_window_erase_handler_t)
+                               on_erase, plugin);
+}
+
+static void
+remove_handlers (ply_boot_splash_plugin_t *plugin)
+{
+
+  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
+  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
+  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
+  ply_window_set_draw_handler (plugin->window, NULL, NULL);
+  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+}
+
 void
 add_window (ply_boot_splash_plugin_t *plugin,
             ply_window_t             *window)
@@ -1338,23 +1374,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   assert (plugin != NULL);
   assert (plugin->logo_image != NULL);
 
-  ply_window_add_keyboard_input_handler (plugin->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, plugin);
-  ply_window_add_backspace_handler (plugin->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, plugin);
-  ply_window_add_enter_handler (plugin->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, plugin);
-
-  ply_window_set_draw_handler (plugin->window,
-                               (ply_window_draw_handler_t)
-                               on_draw, plugin);
-
-  ply_window_set_erase_handler (plugin->window,
-                               (ply_window_erase_handler_t)
-                               on_erase, plugin);
+  add_handlers (plugin);
 
   plugin->loop = loop;
 
@@ -1436,11 +1456,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
-  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
-  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
-  ply_window_set_draw_handler (plugin->window, NULL, NULL);
-  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+  remove_handlers (plugin);
 
   if (plugin->loop != NULL)
     {
index ebf0bb73d153e0ccb8dde179ef3468dd25be2aa5..07460f1b48b9d65f082286fe342d68a61879e1ed 100644 (file)
@@ -95,6 +95,9 @@ struct _ply_boot_splash_plugin
   uint32_t is_animating : 1;
 };
 
+static void add_handlers (ply_boot_splash_plugin_t *plugin);
+static void remove_handlers (ply_boot_splash_plugin_t *plugin);
+
 static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
 ply_boot_splash_plugin_t *
 create_plugin (void)
@@ -332,6 +335,39 @@ on_erase (ply_boot_splash_plugin_t *plugin,
                                        PLYMOUTH_BACKGROUND_END_COLOR);
 }
 
+static void
+add_handlers (ply_boot_splash_plugin_t *plugin)
+{
+  ply_window_add_keyboard_input_handler (plugin->window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_add_backspace_handler (plugin->window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_add_enter_handler (plugin->window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+
+  ply_window_set_draw_handler (plugin->window,
+                               (ply_window_draw_handler_t)
+                               on_draw, plugin);
+
+  ply_window_set_erase_handler (plugin->window,
+                               (ply_window_erase_handler_t)
+                               on_erase, plugin);
+}
+
+static void
+remove_handlers (ply_boot_splash_plugin_t *plugin)
+{
+
+  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
+  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
+  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
+  ply_window_set_draw_handler (plugin->window, NULL, NULL);
+  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+}
+
 void
 add_window (ply_boot_splash_plugin_t *plugin,
             ply_window_t             *window)
@@ -354,23 +390,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   assert (plugin != NULL);
   assert (plugin->logo_image != NULL);
 
-  ply_window_add_keyboard_input_handler (plugin->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, plugin);
-  ply_window_add_backspace_handler (plugin->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, plugin);
-  ply_window_add_enter_handler (plugin->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, plugin);
-
-  ply_window_set_draw_handler (plugin->window,
-                               (ply_window_draw_handler_t)
-                               on_draw, plugin);
-
-  ply_window_set_erase_handler (plugin->window,
-                               (ply_window_erase_handler_t)
-                               on_erase, plugin);
+  add_handlers (plugin);
 
   plugin->loop = loop;
 
@@ -450,12 +470,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-
-  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
-  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
-  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
-  ply_window_set_draw_handler (plugin->window, NULL, NULL);
-  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+  remove_handlers (plugin);
 
   if (plugin->loop != NULL)
     {
index e87cece7dacb27d19a177b2798ab786bdda1f0e3..bbc5a3b7b0f455461923f8f90851adb57fb7ee81 100644 (file)
@@ -74,6 +74,9 @@ struct _ply_boot_splash_plugin
 void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
                          ply_event_loop_t         *loop);
 
+static void add_handlers (ply_boot_splash_plugin_t *plugin);
+static void remove_handlers (ply_boot_splash_plugin_t *plugin);
+
 ply_boot_splash_plugin_t *
 create_plugin (void)
 {
@@ -234,6 +237,38 @@ on_erase (ply_boot_splash_plugin_t *plugin,
   ply_window_clear_screen (plugin->window);
 }
 
+static void
+add_handlers (ply_boot_splash_plugin_t *plugin)
+{
+  ply_window_add_keyboard_input_handler (plugin->window,
+                                         (ply_window_keyboard_input_handler_t)
+                                         on_keyboard_input, plugin);
+  ply_window_add_backspace_handler (plugin->window,
+                                    (ply_window_backspace_handler_t)
+                                    on_backspace, plugin);
+  ply_window_add_enter_handler (plugin->window,
+                                (ply_window_enter_handler_t)
+                                on_enter, plugin);
+  ply_window_set_draw_handler (plugin->window,
+                               (ply_window_draw_handler_t)
+                                on_draw, plugin);
+  ply_window_set_erase_handler (plugin->window,
+                                (ply_window_erase_handler_t)
+                                on_erase, plugin);
+}
+
+static void
+remove_handlers (ply_boot_splash_plugin_t *plugin)
+{
+
+  ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
+  ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
+  ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
+  ply_window_set_draw_handler (plugin->window, NULL, NULL);
+  ply_window_set_erase_handler (plugin->window, NULL, NULL);
+
+}
+
 void
 add_window (ply_boot_splash_plugin_t *plugin,
             ply_window_t             *window)
@@ -255,21 +290,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
 
-  ply_window_add_keyboard_input_handler (plugin->window,
-                                         (ply_window_keyboard_input_handler_t)
-                                         on_keyboard_input, plugin);
-  ply_window_add_backspace_handler (plugin->window,
-                                    (ply_window_backspace_handler_t)
-                                    on_backspace, plugin);
-  ply_window_add_enter_handler (plugin->window,
-                                (ply_window_enter_handler_t)
-                                on_enter, plugin);
-  ply_window_set_draw_handler (plugin->window,
-                               (ply_window_draw_handler_t)
-                                on_draw, plugin);
-  ply_window_set_erase_handler (plugin->window,
-                                (ply_window_erase_handler_t)
-                                on_erase, plugin);
+  add_handlers (plugin);
 
   ply_window_hide_text_cursor (plugin->window);
   ply_window_set_text_cursor_position (plugin->window, 0, 0);
@@ -331,11 +352,7 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
 
   if (plugin->window != NULL)
     {
-      ply_window_remove_keyboard_input_handler (plugin->window, (ply_window_keyboard_input_handler_t) on_keyboard_input);
-      ply_window_remove_backspace_handler (plugin->window, (ply_window_backspace_handler_t) on_backspace);
-      ply_window_remove_enter_handler (plugin->window, (ply_window_enter_handler_t) on_enter);
-      ply_window_set_draw_handler (plugin->window, NULL, NULL);
-      ply_window_set_erase_handler (plugin->window, NULL, NULL);
+      remove_handlers (plugin);
 
       ply_window_set_background_color (plugin->window, PLY_WINDOW_COLOR_DEFAULT);
       ply_window_clear_screen (plugin->window);