]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Rename 'percent_done' to 'fraction_done'
authorDaniel van Vugt <daniel.van.vugt@canonical.com>
Tue, 21 Apr 2020 05:38:21 +0000 (13:38 +0800)
committerDaniel van Vugt <daniel.van.vugt@canonical.com>
Tue, 21 Apr 2020 05:38:21 +0000 (13:38 +0800)
Because they are not percentages but fractional values in the range [0,1]

14 files changed:
src/libply-splash-core/ply-boot-splash-plugin.h
src/libply-splash-core/ply-text-progress-bar.c
src/libply-splash-core/ply-text-progress-bar.h
src/libply-splash-core/ply-text-step-bar.c
src/libply-splash-core/ply-text-step-bar.h
src/libply-splash-graphics/ply-progress-animation.c
src/libply-splash-graphics/ply-progress-animation.h
src/libply-splash-graphics/ply-progress-bar.c
src/libply-splash-graphics/ply-progress-bar.h
src/plugins/splash/script/plugin.c
src/plugins/splash/space-flares/plugin.c
src/plugins/splash/text/plugin.c
src/plugins/splash/tribar/plugin.c
src/plugins/splash/two-step/plugin.c

index 227147fa91b0b317bb75d3f6417b737f0b5e9ca3..c80770c4152e8c20d91f74bc34bc10113842dc3b 100644 (file)
@@ -78,7 +78,7 @@ typedef struct
                                size_t                    size);
         void (*on_boot_progress)(ply_boot_splash_plugin_t *plugin,
                                  double                    duration,
-                                 double                    percent_done);
+                                 double                    fraction_done);
         void (*on_root_mounted)(ply_boot_splash_plugin_t *plugin);
         void (*hide_splash_screen)(ply_boot_splash_plugin_t *plugin,
                                    ply_event_loop_t         *loop);
index dc275137e9abe2b7a5c379f8f661f38630ff8fd6..a7175c889c316b76329d2d0a32c19f49b2acb96b 100644 (file)
@@ -67,7 +67,7 @@ struct _ply_text_progress_bar
         int                 number_of_rows;
         int                 number_of_columns;
 
-        double              percent_done;
+        double              fraction_done;
         uint32_t            is_hidden : 1;
 };
 
@@ -186,9 +186,9 @@ ply_text_progress_bar_draw (ply_text_progress_bar_t *progress_bar)
                                               progress_bar->column,
                                               progress_bar->row);
 
-        brown_fraction = -(progress_bar->percent_done * progress_bar->percent_done) + 2 * progress_bar->percent_done;
-        blue_fraction = progress_bar->percent_done;
-        white_fraction = progress_bar->percent_done * progress_bar->percent_done;
+        brown_fraction = -(progress_bar->fraction_done * progress_bar->fraction_done) + 2 * progress_bar->fraction_done;
+        blue_fraction = progress_bar->fraction_done;
+        white_fraction = progress_bar->fraction_done * progress_bar->fraction_done;
 
         for (i = 0; i < width; i++) {
                 double f;
@@ -262,16 +262,16 @@ ply_text_progress_bar_hide (ply_text_progress_bar_t *progress_bar)
 }
 
 void
-ply_text_progress_bar_set_percent_done (ply_text_progress_bar_t *progress_bar,
-                                        double                   percent_done)
+ply_text_progress_bar_set_fraction_done (ply_text_progress_bar_t *progress_bar,
+                                         double                   fraction_done)
 {
-        progress_bar->percent_done = percent_done;
+        progress_bar->fraction_done = fraction_done;
 }
 
 double
-ply_text_progress_bar_get_percent_done (ply_text_progress_bar_t *progress_bar)
+ply_text_progress_bar_get_fraction_done (ply_text_progress_bar_t *progress_bar)
 {
-        return progress_bar->percent_done;
+        return progress_bar->fraction_done;
 }
 
 int
index 10a127d9f7a7545a703b9818083e2ad0001c5353..fe6e6667c74256f325e7013cb1623d0dea62df53 100644 (file)
@@ -42,10 +42,10 @@ void ply_text_progress_bar_show (ply_text_progress_bar_t *progress_bar,
                                  ply_text_display_t      *display);
 void ply_text_progress_bar_hide (ply_text_progress_bar_t *progress_bar);
 
-void ply_text_progress_bar_set_percent_done (ply_text_progress_bar_t *progress_bar,
-                                             double                   percent_done);
+void ply_text_progress_bar_set_fraction_done (ply_text_progress_bar_t *progress_bar,
+                                              double                   fraction_done);
 
-double ply_text_progress_bar_get_percent_done (ply_text_progress_bar_t *progress_bar);
+double ply_text_progress_bar_get_fraction_done (ply_text_progress_bar_t *progress_bar);
 
 int ply_text_progress_bar_get_number_of_rows (ply_text_progress_bar_t *progress_bar);
 int ply_text_progress_bar_get_number_of_columns (ply_text_progress_bar_t *progress_bar);
index 568b9a216d88c83013fb1e1de2f248c171b5b15c..f54fc56f0f65f27e5dd702c0bb53175b1c93c9ed 100644 (file)
@@ -37,7 +37,7 @@ struct _ply_text_step_bar
         int                 number_of_rows;
         int                 number_of_columns;
 
-        double              percent_done;
+        double              fraction_done;
         uint32_t            is_hidden : 1;
 };
 
@@ -81,7 +81,7 @@ ply_text_step_bar_draw (ply_text_step_bar_t *step_bar)
                                               step_bar->column,
                                               step_bar->row);
 
-        cur = step_bar->percent_done * step_bar->number_of_columns;
+        cur = step_bar->fraction_done * step_bar->number_of_columns;
         for (i = 0; i < step_bar->number_of_columns; i++) {
                 if (i == cur)
                         ply_text_display_set_foreground_color (step_bar->display,
@@ -132,16 +132,16 @@ ply_text_step_bar_hide (ply_text_step_bar_t *step_bar)
 }
 
 void
-ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar,
-                                    double               percent_done)
+ply_text_step_bar_set_fraction_done (ply_text_step_bar_t *step_bar,
+                                     double               fraction_done)
 {
-        step_bar->percent_done = percent_done;
+        step_bar->fraction_done = fraction_done;
 }
 
 double
-ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar)
+ply_text_step_bar_get_fraction_done (ply_text_step_bar_t *step_bar)
 {
-        return step_bar->percent_done;
+        return step_bar->fraction_done;
 }
 
 int
index e5dce91fd10c6c403f427cdfab122ee78d485c3d..f0aa4a6c96628144146a1ac8506af0c83293b520 100644 (file)
@@ -36,10 +36,10 @@ void ply_text_step_bar_show (ply_text_step_bar_t *step_bar,
                              ply_text_display_t  *display);
 void ply_text_step_bar_hide (ply_text_step_bar_t *step_bar);
 
-void ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar,
-                                         double               percent_done);
+void ply_text_step_bar_set_fraction_done (ply_text_step_bar_t *step_bar,
+                                          double               fraction_done);
 
-double ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar);
+double ply_text_step_bar_get_fraction_done (ply_text_step_bar_t *step_bar);
 
 int ply_text_step_bar_get_number_of_rows (ply_text_step_bar_t *step_bar);
 int ply_text_step_bar_get_number_of_columns (ply_text_step_bar_t *step_bar);
index bcbca3fcd44e0d30d1f7d5e50d21e516df014687..aebc7f6f84012baa27652c9628a11ca51d5e4987 100644 (file)
@@ -62,7 +62,7 @@ struct _ply_progress_animation
         ply_rectangle_t                     area;
         ply_rectangle_t                     frame_area;
 
-        double                              percent_done;
+        double                              fraction_done;
         int                                 previous_frame_number;
 
         double                              transition_start_time;
@@ -88,7 +88,7 @@ ply_progress_animation_new (const char *image_dir,
         progress_animation->frames_prefix = strdup (frames_prefix);
         progress_animation->image_dir = strdup (image_dir);
         progress_animation->is_hidden = true;
-        progress_animation->percent_done = 0.0;
+        progress_animation->fraction_done = 0.0;
         progress_animation->area.x = 0;
         progress_animation->area.y = 0;
         progress_animation->area.width = 0;
@@ -216,7 +216,7 @@ ply_progress_animation_draw (ply_progress_animation_t *progress_animation)
         if (number_of_frames == 0)
                 return;
 
-        frame_number = progress_animation->percent_done * (number_of_frames - 1);
+        frame_number = progress_animation->fraction_done * (number_of_frames - 1);
 
         if (progress_animation->previous_frame_number != frame_number &&
             progress_animation->transition != PLY_PROGRESS_ANIMATION_TRANSITION_NONE &&
@@ -456,17 +456,17 @@ ply_progress_animation_get_height (ply_progress_animation_t *progress_animation)
 }
 
 void
-ply_progress_animation_set_percent_done (ply_progress_animation_t *progress_animation,
-                                         double                    percent_done)
+ply_progress_animation_set_fraction_done (ply_progress_animation_t *progress_animation,
+                                          double                    fraction_done)
 {
-        progress_animation->percent_done = percent_done;
+        progress_animation->fraction_done = fraction_done;
         ply_progress_animation_draw (progress_animation);
 }
 
 double
-ply_progress_animation_get_percent_done (ply_progress_animation_t *progress_animation)
+ply_progress_animation_get_fraction_done (ply_progress_animation_t *progress_animation)
 {
-        return progress_animation->percent_done;
+        return progress_animation->fraction_done;
 }
 
 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
index d10c5172826421f9f206210fde3868caf303eafc..aefe7c9b5c353e9bae55677dd69acc1a3067c052 100644 (file)
@@ -64,9 +64,9 @@ bool ply_progress_animation_is_hidden (ply_progress_animation_t *progress_animat
 long ply_progress_animation_get_width (ply_progress_animation_t *progress_animation);
 long ply_progress_animation_get_height (ply_progress_animation_t *progress_animation);
 
-void ply_progress_animation_set_percent_done (ply_progress_animation_t *progress_animation,
-                                              double                    percent_done);
-double ply_progress_animation_get_percent_done (ply_progress_animation_t *progress_animation);
+void ply_progress_animation_set_fraction_done (ply_progress_animation_t *progress_animation,
+                                               double                    fraction_done);
+double ply_progress_animation_get_fraction_done (ply_progress_animation_t *progress_animation);
 
 #endif
 
index 369255af2f4fca72b12aa24ca8c2b9f3014e870e..5938dd6a790729f3818ca36c23a56c64a5913ae2 100644 (file)
@@ -58,7 +58,7 @@ struct _ply_progress_bar
 
         uint32_t             fg_color;
         uint32_t             bg_color;
-        double               percent_done;
+        double               fraction_done;
 
         uint32_t             is_hidden : 1;
 };
@@ -73,7 +73,7 @@ ply_progress_bar_new (void)
         progress_bar->is_hidden = true;
         progress_bar->fg_color = 0xffffffff; /* Solid white */
         progress_bar->bg_color = 0x01000000; /* Transparent */
-        progress_bar->percent_done = 0.0;
+        progress_bar->fraction_done = 0.0;
 
         return progress_bar;
 }
@@ -105,7 +105,7 @@ ply_progress_bar_draw_area (ply_progress_bar_t *progress_bar,
          */
 
         fill_area = progress_bar->area;
-        fill_area.width = progress_bar->area.width * progress_bar->percent_done;
+        fill_area.width = progress_bar->area.width * progress_bar->fraction_done;
         ply_pixel_buffer_fill_with_hex_color (buffer, &fill_area, progress_bar->fg_color);
 
         fill_area.x = fill_area.x + fill_area.width;
@@ -179,17 +179,17 @@ ply_progress_bar_get_height (ply_progress_bar_t *progress_bar)
 }
 
 void
-ply_progress_bar_set_percent_done (ply_progress_bar_t *progress_bar,
-                                   double              percent_done)
+ply_progress_bar_set_fraction_done (ply_progress_bar_t *progress_bar,
+                                    double              fraction_done)
 {
-        progress_bar->percent_done = percent_done;
+        progress_bar->fraction_done = fraction_done;
         ply_progress_bar_draw (progress_bar);
 }
 
 double
-ply_progress_bar_get_percent_done (ply_progress_bar_t *progress_bar)
+ply_progress_bar_get_fraction_done (ply_progress_bar_t *progress_bar)
 {
-        return progress_bar->percent_done;
+        return progress_bar->fraction_done;
 }
 
 void
index 55f5a4809701fe028e8f18f62dc9c126b6e6121d..e7dbf57b3638df7d3a07d2f05810551d6d3674fb 100644 (file)
@@ -56,9 +56,9 @@ bool ply_progress_bar_is_hidden (ply_progress_bar_t *bar);
 long ply_progress_bar_get_width (ply_progress_bar_t *bar);
 long ply_progress_bar_get_height (ply_progress_bar_t *bar);
 
-void ply_progress_bar_set_percent_done (ply_progress_bar_t *bar,
-                                        double              percent_done);
-double ply_progress_bar_get_percent_done (ply_progress_bar_t *bar);
+void ply_progress_bar_set_fraction_done (ply_progress_bar_t *bar,
+                                         double              fraction_done);
+double ply_progress_bar_get_fraction_done (ply_progress_bar_t *bar);
 
 void ply_progress_bar_set_colors (ply_progress_bar_t *bar,
                                   uint32_t            fg_color,
index 8be19f1e730f2c1e2dc453e6714314ada684ff1c..492f4937dfb1b7b61da2e361f6d19fabe3385034 100644 (file)
@@ -237,12 +237,12 @@ on_timeout (ply_boot_splash_plugin_t *plugin)
 static void
 on_boot_progress (ply_boot_splash_plugin_t *plugin,
                   double                    duration,
-                  double                    percent_done)
+                  double                    fraction_done)
 {
         script_lib_plymouth_on_boot_progress (plugin->script_state,
                                               plugin->script_plymouth_lib,
                                               duration,
-                                              percent_done);
+                                              fraction_done);
 }
 
 static bool
index 1b28268fdb5fa91a834d602fb55bc0f68482b107..b362b47038bc10f6d19d9b1cdfca2091978e3c98 100644 (file)
@@ -1149,11 +1149,11 @@ on_timeout (ply_boot_splash_plugin_t *plugin)
 static void
 on_boot_progress (ply_boot_splash_plugin_t *plugin,
                   double                    duration,
-                  double                    percent_done)
+                  double                    fraction_done)
 {
         if (plugin->progress_target < 0)
-                plugin->progress = percent_done;
-        plugin->progress_target = percent_done;
+                plugin->progress = fraction_done;
+        plugin->progress_target = fraction_done;
 }
 
 static void
index 7298f5a30cf047c44fcb87c4e04c2fe4502815dd..7805b9e8b6055f6efcf058549f440580c6584c80 100644 (file)
@@ -536,16 +536,16 @@ update_status (ply_boot_splash_plugin_t *plugin,
 static void
 on_boot_progress (ply_boot_splash_plugin_t *plugin,
                   double                    duration,
-                  double                    percent_done)
+                  double                    fraction_done)
 {
         ply_list_node_t *node;
         double total_duration;
 
-        total_duration = duration / percent_done;
+        total_duration = duration / fraction_done;
 
         /* Fun made-up smoothing function to make the growth asymptotic:
          * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */
-        percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done);
+        fraction_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - fraction_done);
 
         node = ply_list_get_first_node (plugin->views);
 
@@ -556,7 +556,7 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
                 view = ply_list_node_get_data (node);
                 next_node = ply_list_get_next_node (plugin->views, node);
 
-                ply_text_step_bar_set_percent_done (view->step_bar, percent_done);
+                ply_text_step_bar_set_fraction_done (view->step_bar, fraction_done);
 
                 if (plugin->is_animating)
                         ply_text_step_bar_draw (view->step_bar);
index bbf5d4721c9bfeb4fc415ac78684dbc07638b8a4..1778822a5b0963ad4b74576f7709f83b93e887d7 100644 (file)
@@ -542,16 +542,16 @@ update_status (ply_boot_splash_plugin_t *plugin,
 static void
 on_boot_progress (ply_boot_splash_plugin_t *plugin,
                   double                    duration,
-                  double                    percent_done)
+                  double                    fraction_done)
 {
         ply_list_node_t *node;
         double total_duration;
 
-        total_duration = duration / percent_done;
+        total_duration = duration / fraction_done;
 
         /* Fun made-up smoothing function to make the growth asymptotic:
          * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */
-        percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done);
+        fraction_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - fraction_done);
 
         node = ply_list_get_first_node (plugin->views);
 
@@ -562,7 +562,7 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
                 view = ply_list_node_get_data (node);
                 next_node = ply_list_get_next_node (plugin->views, node);
 
-                ply_text_progress_bar_set_percent_done (view->progress_bar, percent_done);
+                ply_text_progress_bar_set_fraction_done (view->progress_bar, fraction_done);
 
                 if (plugin->is_animating)
                         ply_text_progress_bar_draw (view->progress_bar);
index 2d7ee162e3c9589d5c45a5ebab4256ec1ca0f7f8..2899b2254d7e135c443c7826d429498e3fd70436 100644 (file)
@@ -68,8 +68,8 @@
 #define FRAMES_PER_SECOND 30
 #endif
 
-#ifndef SHOW_ANIMATION_PERCENT
-#define SHOW_ANIMATION_PERCENT 0.9
+#ifndef SHOW_ANIMATION_FRACTION
+#define SHOW_ANIMATION_FRACTION 0.9
 #endif
 
 #define PROGRESS_BAR_WIDTH  400
@@ -1707,7 +1707,7 @@ on_animation_stopped (ply_boot_splash_plugin_t *plugin)
 
 static void
 update_progress_animation (ply_boot_splash_plugin_t *plugin,
-                           double                    percent_done)
+                           double                    fraction_done)
 {
         ply_list_node_t *node;
         view_t *view;
@@ -1718,13 +1718,13 @@ update_progress_animation (ply_boot_splash_plugin_t *plugin,
                 view = ply_list_node_get_data (node);
 
                 if (view->progress_animation != NULL)
-                        ply_progress_animation_set_percent_done (view->progress_animation,
-                                                                 percent_done);
+                        ply_progress_animation_set_fraction_done (view->progress_animation,
+                                                                  fraction_done);
 
-                ply_progress_bar_set_percent_done (view->progress_bar, percent_done);
+                ply_progress_bar_set_fraction_done (view->progress_bar, fraction_done);
                 if (!ply_progress_bar_is_hidden (view->progress_bar) &&
                     plugin->mode_settings[plugin->mode].progress_bar_show_percent_complete) {
-                        snprintf (buf, sizeof(buf), _("%d%% complete"), (int)(percent_done * 100));
+                        snprintf (buf, sizeof(buf), _("%d%% complete"), (int)(fraction_done * 100));
                         view_show_message (view, buf);
                 }
 
@@ -1735,7 +1735,7 @@ update_progress_animation (ply_boot_splash_plugin_t *plugin,
 static void
 on_boot_progress (ply_boot_splash_plugin_t *plugin,
                   double                    duration,
-                  double                    percent_done)
+                  double                    fraction_done)
 {
         if (plugin->mode == PLY_BOOT_SPLASH_MODE_UPDATES ||
             plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE ||
@@ -1753,7 +1753,7 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
          * become_idle gets called.
          */
         if (plugin->mode_settings[plugin->mode].use_end_animation &&
-            percent_done >= SHOW_ANIMATION_PERCENT) {
+            fraction_done >= SHOW_ANIMATION_FRACTION) {
                 if (plugin->stop_trigger == NULL) {
                         ply_trace ("boot progressed to end");
 
@@ -1767,21 +1767,21 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
         } else {
                 double total_duration;
 
-                percent_done *= (1 / SHOW_ANIMATION_PERCENT);
+                fraction_done *= (1 / SHOW_ANIMATION_FRACTION);
 
                 switch (plugin->progress_function) {
                 /* Fun made-up smoothing function to make the growth asymptotic:
                  * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */
                 case PROGRESS_FUNCTION_TYPE_WWOODS:
-                        total_duration = duration / percent_done;
-                        percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done);
+                        total_duration = duration / fraction_done;
+                        fraction_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - fraction_done);
                         break;
 
                 case PROGRESS_FUNCTION_TYPE_LINEAR:
                         break;
                 }
 
-                update_progress_animation (plugin, percent_done);
+                update_progress_animation (plugin, fraction_done);
         }
 }