[dia] Initialize render_bounding_boxes from environment variable



commit 3d19600348761c8d6389d122889482d25217ed66
Author: Hans Breuer <hans breuer org>
Date:   Sun Nov 17 12:13:59 2013 +0100

    Initialize render_bounding_boxes from environment variable
    
    Remove one more global variable using DIAVAR, setting this from
    .dia/persistence wasn't that convenient anyway.

 app/preferences.c |    5 -----
 app/preferences.h |    2 --
 lib/arrows.c      |    2 +-
 lib/arrows.h      |    1 -
 lib/diagramdata.h |    1 -
 lib/diarenderer.h |    3 +++
 lib/layer.c       |   19 +++++++++++++++++--
 lib/libdia.def    |    3 ---
 8 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/app/preferences.c b/app/preferences.c
index beae100..047bcbc 100644
--- a/app/preferences.c
+++ b/app/preferences.c
@@ -244,9 +244,6 @@ DiaPrefData prefs_data[] =
   { "grid_w", PREF_UREAL, PREF_OFFSET(grid.w), &default_real_one, GRID_TAB, N_("Hex Size:") },
   /*  { "grid_solid", PREF_BOOLEAN, PREF_OFFSET(grid.solid), &default_true, 3, N_("Solid lines:") },  */
 
-  { "render_bounding_boxes", PREF_BOOLEAN,PREF_OFFSET(render_bounding_boxes),
-    &default_false,0,"render bounding boxes",NULL, TRUE},
-
   { "fixed_icon_size", PREF_BOOLEAN,PREF_OFFSET(fixed_icon_size),
     &default_true,0,"ensure fixed icon size",NULL, TRUE},
 
@@ -367,8 +364,6 @@ void
 prefs_init(void)
 {
   prefs_set_defaults();
-
-  render_bounding_boxes = prefs.render_bounding_boxes;
 }
 
 static void
diff --git a/app/preferences.h b/app/preferences.h
index e11aa00..53464f3 100644
--- a/app/preferences.h
+++ b/app/preferences.h
@@ -64,8 +64,6 @@ struct DiaPreferences {
     int solid;
   } pagebreak;
 
-  int render_bounding_boxes;
-
   int fixed_icon_size;
 
   int toolbox_on_top;
diff --git a/lib/arrows.c b/lib/arrows.c
index 8de39fe..e7207bb 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -2020,7 +2020,7 @@ arrow_draw(DiaRenderer *renderer, ArrowType type,
       break;
     }
   }
-  if ((type != ARROW_NONE) && (render_bounding_boxes) && (renderer->is_interactive)) {
+  if ((type != ARROW_NONE) && (render_bounding_boxes()) && (renderer->is_interactive)) {
     Arrow arrow = {type, length, width};
     Rectangle bbox = {0, };
     Point p1, p2;
diff --git a/lib/arrows.h b/lib/arrows.h
index 489342f..2a34bf8 100644
--- a/lib/arrows.h
+++ b/lib/arrows.h
@@ -19,7 +19,6 @@
 #define ARROWS_H
 
 #include "diatypes.h"
-#include "diavar.h"
 #include "geometry.h"
 #include "color.h"
 #include "dia_xml.h"
diff --git a/lib/diagramdata.h b/lib/diagramdata.h
index c2376b1..4578813 100644
--- a/lib/diagramdata.h
+++ b/lib/diagramdata.h
@@ -25,7 +25,6 @@
 #include "diatypes.h"
 #include "color.h"
 #include "geometry.h"
-#include "diavar.h"
 #include "paper.h"
 
 G_BEGIN_DECLS
diff --git a/lib/diarenderer.h b/lib/diarenderer.h
index 7ba9588..2cce06c 100644
--- a/lib/diarenderer.h
+++ b/lib/diarenderer.h
@@ -345,6 +345,9 @@ int  dia_renderer_get_height_pixels (DiaRenderer*);
 void bezier_render_fill   (DiaRenderer *renderer, BezPoint *pts, int total, Color *color);
 void bezier_render_stroke (DiaRenderer *renderer, BezPoint *pts, int total, Color *color);
 
+/*! \brief query DIA_RENDER_BOUNDING_BOXES */
+int render_bounding_boxes (void);
+
 G_END_DECLS
 
 #endif /* DIA_RENDERER_H */
diff --git a/lib/layer.c b/lib/layer.c
index e8057b0..9f63c5f 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -43,7 +43,22 @@ normal_render(DiaObject *obj, DiaRenderer *renderer,
 }
 
 
-int render_bounding_boxes = FALSE;
+/*!
+ * bounding box debug helper : environment variable DIA_RENDER_BOUNDING_BOXES
+ * set to !0 to see the calculated bounding boxes
+ */
+int
+render_bounding_boxes (void)
+{
+  static int rbb = FALSE;
+  static int once = TRUE;
+
+  if (once) {
+    rbb = g_getenv ("DIA_RENDER_BOUNDING_BOXES") != NULL;
+    once = FALSE;
+  }
+  return rbb;
+}
 
 /*!
  * \brief Render all components of a single layer.
@@ -76,7 +91,7 @@ layer_render(Layer *layer, DiaRenderer *renderer, Rectangle *update,
     obj = (DiaObject *) list->data;
 
     if (update==NULL || rectangle_intersects(update, &obj->bounding_box)) {
-      if ((render_bounding_boxes) && (renderer->is_interactive)) {
+      if ((render_bounding_boxes()) && (renderer->is_interactive)) {
        Point p1, p2;
        Color col;
        p1.x = obj->bounding_box.left;
diff --git a/lib/libdia.def b/lib/libdia.def
index 7894204..b50df4e 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -1,7 +1,4 @@
 EXPORTS
-; variables need to be exported by DIAVAR
- render_bounding_boxes
-
 ; exported functions
  apply_textattr_properties
  apply_textstr_properties


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