[pinpoint] pinpoint: Remove all those weird warning about opening "./NULL"



commit 1067ddf72c85c32d9eb6212b2a2c6a3a74d5d694
Author: Damien Lespiau <damien lespiau intel com>
Date:   Tue Oct 25 19:03:22 2011 +0100

    pinpoint: Remove all those weird warning about opening "./NULL"
    
    It was because "NULL" was the default bg which was treated as an image
    file. The Clutter code was relying on that failing to create an empty
    texture as the backround.
    
    Like, really?
    
    Just handle the NONE background explictely by create a dummy rectangle
    of the same color then the stage. This is a way to keep the invariant of
    always having a valid ClutterActor as the background.

 pinpoint.c   |    2 +-
 pp-cairo.c   |    2 +-
 pp-clutter.c |   19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/pinpoint.c b/pinpoint.c
index 3c0323e..9adf699 100644
--- a/pinpoint.c
+++ b/pinpoint.c
@@ -61,7 +61,7 @@ static EnumDescription PPTextAlign_desc[] =
 static PinPointPoint pin_default_point = {
   .stage_color = "black",
 
-  .bg = "NULL",
+  .bg = NULL,
   .bg_type = PP_BG_NONE,
   .bg_scale = PP_BG_FIT,
 
diff --git a/pp-cairo.c b/pp-cairo.c
index a673674..53ea355 100644
--- a/pp-cairo.c
+++ b/pp-cairo.c
@@ -288,7 +288,7 @@ _cairo_render_background (CairoRenderer *renderer,
   char       *full_path = NULL;
   const char *file;
 
-  if (point == NULL)
+  if (point == NULL || point->bg == NULL)
     {
       cairo_set_source_rgb (renderer->ctx, 0,0,0);
       cairo_paint (renderer->ctx);
diff --git a/pp-clutter.c b/pp-clutter.c
index 08ed901..27e2b49 100644
--- a/pp-clutter.c
+++ b/pp-clutter.c
@@ -1067,6 +1067,25 @@ clutter_renderer_make_point (PinPointRenderer *pp_renderer,
                                            NULL);
       }
       break;
+    case PP_BG_NONE:
+      {
+        ClutterColor black = {0, 0, 0, 255};
+
+        ret = clutter_color_from_string (&color, point->stage_color);
+        if (ret)
+          data->background = g_object_new (CLUTTER_TYPE_RECTANGLE,
+                                           "color",  &color,
+                                           "width",  100.0,
+                                           "height", 100.0,
+                                           NULL);
+        else
+          data->background = g_object_new (CLUTTER_TYPE_RECTANGLE,
+                                           "color",  &black,
+                                           "width",  100.0,
+                                           "height", 100.0,
+                                           NULL);
+      }
+      break;
     case PP_BG_IMAGE:
       data->background = _clutter_get_texture (renderer, file);
       ret = TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]