[Splashy-devel] 1/6 Make simple interface for splashy_video.h

Tim Dijkstra newsuser at famdijkstra.org
Sat Aug 12 21:36:15 UTC 2006


Remove show_progress from the argument list of the video_* functions.
That argument just goes along for the ride so in the end change_splash
knows about it. A flag local to splashy_video.c seems better. 


Index: splashy_video.c
===================================================================
--- splashy_video.c	(revision 136)
+++ splashy_video.c	(working copy)
@@ -64,6 +64,7 @@
 static guint _last_x = 0;
 
 static gboolean draw_progressbar_forward = TRUE;
+static gboolean show_progressbar = FALSE;
 
 /*
  * helper functions 
@@ -214,6 +215,13 @@
         gint divider_w, divider_h;
         guint rectangle_red, rectangle_green, rectangle_blue, rectangle_alpha;
 
+
+	/* We set a flag here now that change_splash can see to know
+	 * if it has to redraw the progress bar.
+	 */
+
+	show_progressbar = TRUE;
+	
         const gchar *draw_progress =
                 xml_parser_get_text ("/splashy/progressbar/border/enable");
         gboolean draw_progress_border = (draw_progress
@@ -802,7 +810,7 @@
 
 void
 video_change_splash (splashy_video_t * video,
-                     const gchar * newimage, gboolean show_progress)
+                     const gchar * newimage)
 {
         video->dfb->CreateImageProvider (video->dfb, newimage,
                                          &video->provider);
@@ -811,7 +819,7 @@
         /*
          * restore progressbar 
          */
-        if (show_progress == TRUE)
+        if (show_progressbar == TRUE)
         {
                 video_draw_progressbar (video, &video->progressbar);
                 if (_last_progress >= 0)
@@ -970,7 +978,7 @@
  */
 
 void
-video_clear_offscreen (splashy_video_t * video, gboolean show_progress)
+video_clear_offscreen (splashy_video_t * video)
 {
         gint red, green, blue, alpha;
         if (video->textbox == NULL)
@@ -995,7 +1003,7 @@
         /*
          * copy the "clean" surface from our primary surface to offscreen 
          */
-        video_change_splash (video, _current_background, show_progress);
+        video_change_splash (video, _current_background);
 
         /*
          * now we need to flip these surfaces so that the background tint
@@ -1028,7 +1036,7 @@
 * @return
 */
 void
-video_start_text_area (splashy_video_t * video, gboolean show_progress)
+video_start_text_area (splashy_video_t * video)
 {
         gint divider_w, divider_h;
         gint screen_width, screen_height;
@@ -1098,7 +1106,7 @@
         /*
          * clear the offscreen surface and set the drawing flags
          */
-        video_clear_offscreen (video, show_progress);
+        video_clear_offscreen (video);
 
         /*
          * Get the text colour (no alpha) 
@@ -1147,8 +1155,7 @@
  * @return
  */
 void
-video_printline (splashy_video_t * video, gchar * string,
-                 gboolean show_progress)
+video_printline (splashy_video_t * video, gchar * string)
 {
         if (video->textbox == NULL)
                 return;
@@ -1160,7 +1167,7 @@
          */
         if (last_text_y_position > 0)
         {
-                video_clear_offscreen (video, show_progress);
+                video_clear_offscreen (video);
                 last_text_y_position = 0;
         }
 
@@ -1188,8 +1195,7 @@
  * @return
  */
 void
-video_printline_s (splashy_video_t * video, gchar * string,
-                   gboolean show_progress)
+video_printline_s (splashy_video_t * video, gchar * string)
 {
         if (video->textbox == NULL)
                 return;
@@ -1206,7 +1212,7 @@
             (video->textbox->area.h -
              abs (video->textbox->fontdesc.height * 2)))
         {
-                video_clear_offscreen (video, show_progress);
+                video_clear_offscreen (video);
                 last_text_y_position = 0;
         }
         /*
Index: splashy_functions.c
===================================================================
--- splashy_functions.c	(revision 136)
+++ splashy_functions.c	(working copy)
@@ -78,7 +78,6 @@
 static gint arg_progress = 0;   /* value to be sent to last_progress from
                                  * FIFO. @see keyevent_loop() */
 
-static gboolean _show_progress = FALSE;
 static splashy_video_t video;
 
 static gboolean exiting = FALSE;        /* threads should read this before
@@ -221,14 +220,14 @@
 gint
 cmd_print (void **args)
 {
-        video_printline (&video, args[0], _show_progress);
+        video_printline (&video, args[0]);
         return 0;
 }
 
 gint
 cmd_print_clear (void **args)
 {
-        video_printline (&video, "", _show_progress);
+        video_printline (&video, "");
         return 0;
 }
 
@@ -265,7 +264,7 @@
          * TODO change background to current image 
          */
         /*
-         * video_printline (&video, "", _show_progress); 
+         * video_printline (&video, ""); 
          */
         return 0;
 }
@@ -498,7 +497,7 @@
                 background =
                         _splashy_theme_image_path
                         (SPL_DEFAULT_THEME, "/splashy/background/errorimg");
-        video_change_splash (&video, background, _show_progress);
+        video_change_splash (&video, background);
 
         /*
          * safe for future reference 
@@ -718,8 +717,7 @@
                                                 video_printline_s (&video,
                                                                    (char *)
                                                                    buf_str->
-                                                                   str,
-                                                                   _show_progress);
+                                                                   str);
 
                                         sched_yield ();
 
@@ -834,8 +832,7 @@
                                  * progressbar filled 
                                  */
                                 video_change_splash (&video,
-                                                     _current_background,
-                                                     _show_progress);
+                                                     _current_background);
                                 sched_yield ();
                                 nanosleep (&_sleep, NULL);
                         }
@@ -1007,8 +1004,7 @@
                                                 F2_toggle_pressed = TRUE;
                                                 show_textbox_area = TRUE;
                                                 /* now show the box */
-                                                video_printline_s (&video,
-                                                                "",_show_progress);
+                                                video_printline_s (&video,"");
                                         }
                                         else
                                         {
@@ -1021,8 +1017,7 @@
                                                  * we need to re-draw the screen
                                                  */
                                                 video_change_splash (&video,
-                                                                     _current_background,
-                                                                     _show_progress);
+                                                                     _current_background);
                                         }
                                 }
                         }
@@ -1048,11 +1043,10 @@
  * wrappers: splashy_child_start() and splashy_child_stop()
  * @see splashy_child_start() and @see splashy_child_stop()
  * @param seq sequence command to execute: "boot" or "shutdown"
- * @param show_progress whether we should display a progress bar
  * @return
  */
 gint
-_splashy_child (const gchar * seq, gboolean show_progress)
+_splashy_child (const gchar * seq)
 {
         gint i;                 /* general purpose counter */
         gint thr_id_c, thr_id_d;        /* thread ID for the newly * created
@@ -1070,6 +1064,8 @@
 
         const gchar *background = NULL;
         gboolean _preview = FALSE;
+	
+        gboolean show_progress = FALSE;
 
         /*
          * handle exit signals
@@ -1102,6 +1098,14 @@
                         background =
                                 _splashy_theme_image_path (SPL_DEFAULT_THEME,
                                                            "/splashy/background/boot");
+
+                show_progress =
+                        (g_ascii_strncasecmp (
+                                xml_parser_get_text ("/splashy/progressbaronboot"),
+                                "yes", 3
+                                ) ==
+                         0) ? TRUE : FALSE;
+			
         }
         else if (g_ascii_strncasecmp (seq, "shutdown", 8) == 0)
         {
@@ -1112,6 +1116,14 @@
                         background =
                                 _splashy_theme_image_path (SPL_DEFAULT_THEME,
                                                            "/splashy/background/shutdown");
+
+                show_progress =
+                        (g_ascii_strncasecmp (
+                                xml_parser_get_text ("/splashy/progressbaronshutdown"),
+                                "yes", 3
+                                ) ==
+                         0) ? TRUE : FALSE;
+
         }
         else if (g_ascii_strncasecmp (seq, "test", 4) == 0
                  || g_ascii_strncasecmp (seq, "preview", 7) == 0)
@@ -1134,6 +1146,14 @@
                         background =
                                 _splashy_theme_image_path (SPL_DEFAULT_THEME,
                                                            "/splashy/background/boot");
+
+                show_progress =
+                        (g_ascii_strncasecmp (
+                                xml_parser_get_text ("/splashy/progressbaronboot"),
+                                "yes", 3
+                                ) ==
+                        0) ? TRUE : FALSE;
+
         }
         else
         {
@@ -1185,7 +1205,7 @@
          * Note that this won't actually show the text area until we print
          * to it. @see verbose_text_loop() and the create thread below
          */
-        video_start_text_area (&video, show_progress);
+        video_start_text_area (&video);
 
         /*
          * setup our main input: keyboard 
@@ -1254,18 +1274,13 @@
 splashy_child_start ()
 {
         DEBUG_PRINT ("Entering splashy_child_start %s", "");
-        const gchar *show_progress =
-                xml_parser_get_text ("/splashy/progressbaronboot");
-        _show_progress =
-                (g_ascii_strncasecmp (show_progress, "yes", 3) ==
-                 0) ? TRUE : FALSE;
 
         /*
          * TODO make this configurable from config.xml for e/a theme 
          */
         video_set_progressbar_forward (TRUE);
 
-        gint ret = _splashy_child ("boot", _show_progress);
+        gint ret = _splashy_child ("boot");
         if (ret < 0)
                 ERROR_PRINT ("Could not start Splashy. %d\n", ret);
         DEBUG_PRINT ("Exiting splashy_child_start %d", ret);
@@ -1278,18 +1293,12 @@
 void
 splashy_child_stop ()
 {
-        const gchar *show_progress =
-                xml_parser_get_text ("/splashy/progressbaronshutdown");
-        _show_progress =
-                (g_ascii_strncasecmp (show_progress, "yes", 3) ==
-                 0) ? TRUE : FALSE;
-
         /*
          * TODO make this configurable from config.xml for e/a theme 
          */
         video_set_progressbar_forward (FALSE);
 
-        gint ret = _splashy_child ("shutdown", _show_progress);
+        gint ret = _splashy_child ("shutdown");
         if (ret < 0)
                 g_print ("ERROR: Main process exited with %d\n", ret);
         splashy_child_exit ();
@@ -1302,12 +1311,7 @@
 splashy_child_test ()
 {
         DEBUG_PRINT ("Entering splashy_child_test %s", "");
-        const gchar *show_progress =
-                xml_parser_get_text ("/splashy/progressbaronboot");
-        _show_progress =
-                (g_ascii_strncasecmp (show_progress, "yes", 3) ==
-                 0) ? TRUE : FALSE;
-        gint ret = _splashy_child ("test", _show_progress);
+        gint ret = _splashy_child ("test");
         if (ret < 0)
                 ERROR_PRINT ("Could not start Splashy on test mode. %d\n",
                              ret);
Index: splashy_video.h
===================================================================
--- splashy_video.h	(revision 136)
+++ splashy_video.h	(working copy)
@@ -73,27 +73,26 @@
 gint video_update_progressbar (splashy_video_t * video,
                                DFBRectangle * progressbar, gint perc);
 void video_start_splash (splashy_video_t * video, const gchar * background);
-void video_change_splash (splashy_video_t * video, const gchar * newimage, gboolean show_progress);
-void video_start_text_area (splashy_video_t * video, gboolean show_progress);
+void video_change_splash (splashy_video_t * video, const gchar * newimage);
+void video_start_text_area (splashy_video_t * video);
 void video_set_mode (splashy_video_t * video);
 void video_allow_vt_switching ();
 /*
  * allows to print a single message to the center of the textbox area
  * reseting the old one
  */
-void video_printline (splashy_video_t * video, gchar * string, gboolean show_progress);
+void video_printline (splashy_video_t * video, gchar * string);
 /*
  * allows to print a message appended to the end of the textbox area
  * keeping the old one
  */
-void video_printline_s (splashy_video_t * video, gchar * string, gboolean show_progress);
+void video_printline_s (splashy_video_t * video, gchar * string);
 /* 
  * write data to our textbox the right way. it uses video_printline_s() to do
  * the actual writing. @see verbose_text_loop() in splashy_functions.c
  */
 void video_writelog (splashy_video_t * video, unsigned char *ptr, 
-                gint len, char *ringbuf, char *outptr, char *endptr, 
-                gboolean show_progress);
+                gint len, char *ringbuf, char *outptr, char *endptr);
 
 void video_fade_in (splashy_video_t * video);
 void video_fade_out (splashy_video_t * video);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/splashy-devel/attachments/20060812/e9cf43e2/signature-0001.pgp


More information about the Splashy-devel mailing list