[gimp] plug-ins: add back wireframe mode using cairo



commit 5bd9de23b88dad65cdec1fa8d6698590875dd25a
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Sat Feb 19 19:49:34 2011 +0100

    plug-ins: add back wireframe mode using cairo

 plug-ins/map-object/map-object-main.c    |    3 +-
 plug-ins/map-object/map-object-main.h    |    1 +
 plug-ins/map-object/map-object-preview.c |  467 +++++++++++++++++++++++++++++-
 plug-ins/map-object/map-object-preview.h |    7 +
 plug-ins/map-object/map-object-ui.c      |   32 ++-
 5 files changed, 496 insertions(+), 14 deletions(-)
---
diff --git a/plug-ins/map-object/map-object-main.c b/plug-ins/map-object/map-object-main.c
index ff0a491..c5e6d5d 100644
--- a/plug-ins/map-object/map-object-main.c
+++ b/plug-ins/map-object/map-object-main.c
@@ -81,7 +81,8 @@ set_default_settings (void)
   mapvals.create_new_layer       = FALSE;
   mapvals.transparent_background = FALSE;
   mapvals.tiled                  = FALSE;
-  mapvals.livepreview            = TRUE;
+  mapvals.livepreview            = FALSE;
+  mapvals.showgrid               = TRUE;
 
   mapvals.lightsource.intensity = 1.0;
   gimp_rgba_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0, 1.0);
diff --git a/plug-ins/map-object/map-object-main.h b/plug-ins/map-object/map-object-main.h
index 6c78c8c..2757002 100644
--- a/plug-ins/map-object/map-object-main.h
+++ b/plug-ins/map-object/map-object-main.h
@@ -65,6 +65,7 @@ typedef struct
   gint transparent_background;
   gint tiled;
   gint livepreview;
+  gint showgrid;
   gint showcaps;
 
   gdouble zoom;
diff --git a/plug-ins/map-object/map-object-preview.c b/plug-ins/map-object/map-object-preview.c
index 92dcad0..2358785 100644
--- a/plug-ins/map-object/map-object-preview.c
+++ b/plug-ins/map-object/map-object-preview.c
@@ -18,8 +18,7 @@
 
 
 gdouble mat[3][4];
-
-gint       lightx, lighty;
+gint    lightx, lighty;
 
 /* Protos */
 /* ====== */
@@ -32,6 +31,34 @@ static void compute_preview         (gint x,
                                      gint ph);
 static void draw_light_marker       (gint xpos,
 				     gint ypos);
+static void draw_line               (cairo_t    *cr,
+				     gint        startx,
+				     gint        starty,
+				     gint        pw,
+				     gint        ph,
+				     gdouble     cx1,
+				     gdouble     cy1,
+				     gdouble     cx2,
+				     gdouble     cy2,
+				     GimpVector3 a,
+				     GimpVector3 b);
+
+static void draw_wireframe_plane    (gint        startx,
+				     gint        starty,
+				     gint        pw,
+				     gint        ph);
+static void draw_wireframe_sphere   (gint        startx,
+				     gint        starty,
+				     gint        pw,
+				     gint        ph);
+static void draw_wireframe_box      (gint        startx,
+				     gint        starty,
+				     gint        pw,
+				     gint        ph);
+static void draw_wireframe_cylinder (gint        startx,
+				     gint        starty,
+				     gint        pw,
+				     gint        ph);
 
 /**************************************************************/
 /* Computes a preview of the rectangle starting at (x,y) with */
@@ -298,9 +325,445 @@ preview_expose (GtkWidget      *widget,
 
   cairo_paint (cr);
 
+  if (mapvals.showgrid)
+    draw_preview_wireframe ();
   draw_lights (startx, starty, pw, ph);
 
   cairo_destroy (cr);
 
   return FALSE;
 }
+
+/**************************/
+/* Draw preview wireframe */
+/**************************/
+
+void
+draw_preview_wireframe (void)
+{
+  gint      startx, starty, pw, ph;
+
+  pw     = PREVIEW_WIDTH  * mapvals.zoom;
+  ph     = PREVIEW_HEIGHT * mapvals.zoom;
+  startx = (PREVIEW_WIDTH  - pw) / 2;
+  starty = (PREVIEW_HEIGHT - ph) / 2;
+
+  draw_wireframe (startx, starty, pw, ph);
+}
+
+/****************************/
+/* Draw a wireframe preview */
+/****************************/
+
+void
+draw_wireframe (gint startx,
+		gint starty,
+		gint pw,
+		gint ph)
+{
+  switch (mapvals.maptype)
+    {
+    case MAP_PLANE:
+      draw_wireframe_plane (startx, starty, pw, ph);
+      break;
+    case MAP_SPHERE:
+      draw_wireframe_sphere (startx, starty, pw, ph);
+      break;
+    case MAP_BOX:
+      draw_wireframe_box (startx, starty, pw, ph);
+      break;
+    case MAP_CYLINDER:
+      draw_wireframe_cylinder (startx, starty, pw, ph);
+      break;
+    }
+}
+
+static void
+draw_wireframe_plane (gint startx,
+		      gint starty,
+		      gint pw,
+		      gint ph)
+{
+  GimpVector3 v1, v2, a, b, c, d, dir1, dir2;
+  gint        cnt;
+  gdouble     x1, y1, x2, y2, cx1, cy1, cx2, cy2, fac;
+  cairo_t    *cr;
+
+  cr = gdk_cairo_create (gtk_widget_get_window (previewarea));
+
+  cairo_rectangle (cr, startx, starty, pw, ph);
+  cairo_clip (cr);
+
+  /* Find rotated box corners */
+  /* ======================== */
+
+  gimp_vector3_set (&v1, 0.5, 0.0, 0.0);
+  gimp_vector3_set (&v2, 0.0, 0.5, 0.0);
+
+  gimp_vector3_rotate (&v1,
+		       gimp_deg_to_rad (mapvals.alpha),
+		       gimp_deg_to_rad (mapvals.beta),
+		       gimp_deg_to_rad (mapvals.gamma));
+
+  gimp_vector3_rotate (&v2,
+		       gimp_deg_to_rad (mapvals.alpha),
+		       gimp_deg_to_rad (mapvals.beta),
+		       gimp_deg_to_rad (mapvals.gamma));
+
+  dir1 = v1; gimp_vector3_normalize (&dir1);
+  dir2 = v2; gimp_vector3_normalize (&dir2);
+
+  fac = 1.0 / (gdouble) WIRESIZE;
+
+  gimp_vector3_mul (&dir1, fac);
+  gimp_vector3_mul (&dir2, fac);
+
+  gimp_vector3_add (&a, &mapvals.position, &v1);
+  gimp_vector3_sub (&b, &a, &v2);
+  gimp_vector3_add (&a, &a, &v2);
+  gimp_vector3_sub (&d, &mapvals.position, &v1);
+  gimp_vector3_sub (&d, &d, &v2);
+
+  c = b;
+
+  cx1 = (gdouble) startx;
+  cy1 = (gdouble) starty;
+  cx2 = cx1 + (gdouble) pw;
+  cy2 = cy1 + (gdouble) ph;
+
+  for (cnt = 0; cnt <= WIRESIZE; cnt++)
+    {
+      gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			    &x1, &y1, &mapvals.viewpoint, &a);
+      gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			    &x2, &y2, &mapvals.viewpoint, &b);
+
+      cairo_move_to (cr, RINT (x1), RINT (y1));
+      cairo_line_to (cr, RINT (x2), RINT (y2));
+
+      gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			    &x1, &y1, &mapvals.viewpoint, &c);
+      gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			    &x2, &y2, &mapvals.viewpoint, &d);
+
+      cairo_move_to (cr, RINT (x1), RINT (y1));
+      cairo_line_to (cr, RINT (x2), RINT (y2));
+
+      gimp_vector3_sub (&a, &a, &dir1);
+      gimp_vector3_sub (&b, &b, &dir1);
+      gimp_vector3_add (&c, &c, &dir2);
+      gimp_vector3_add (&d, &d, &dir2);
+    }
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_stroke_preserve (cr);
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+  cairo_stroke (cr);
+
+  cairo_destroy (cr);
+}
+
+static void
+draw_wireframe_sphere (gint startx,
+		       gint starty,
+		       gint pw,
+		       gint ph)
+{
+  GimpVector3 p[2 * (WIRESIZE + 5)];
+  gint        cnt, cnt2;
+  gdouble     x1, y1, x2, y2, twopifac, cx1, cy1, cx2, cy2;
+  cairo_t    *cr;
+
+  cr = gdk_cairo_create (gtk_widget_get_window (previewarea));
+
+  cairo_rectangle (cr, startx, starty, pw, ph);
+  cairo_clip (cr);
+
+  /* Compute wireframe points */
+  /* ======================== */
+
+  twopifac = (2.0 * G_PI) / WIRESIZE;
+
+  for (cnt = 0; cnt < WIRESIZE; cnt++)
+    {
+      p[cnt].x = mapvals.radius * cos ((gdouble) cnt * twopifac);
+      p[cnt].y = 0.0;
+      p[cnt].z = mapvals.radius * sin ((gdouble) cnt * twopifac);
+      gimp_vector3_rotate (&p[cnt],
+			   gimp_deg_to_rad (mapvals.alpha),
+			   gimp_deg_to_rad (mapvals.beta),
+			   gimp_deg_to_rad (mapvals.gamma));
+      gimp_vector3_add (&p[cnt], &p[cnt], &mapvals.position);
+    }
+
+  p[cnt] = p[0];
+
+  for (cnt = WIRESIZE + 1; cnt < 2 * WIRESIZE + 1; cnt++)
+    {
+      p[cnt].x = mapvals.radius * cos ((gdouble) (cnt-(WIRESIZE+1))*twopifac);
+      p[cnt].y = mapvals.radius * sin ((gdouble) (cnt-(WIRESIZE+1))*twopifac);
+      p[cnt].z = 0.0;
+      gimp_vector3_rotate (&p[cnt],
+			   gimp_deg_to_rad (mapvals.alpha),
+			   gimp_deg_to_rad (mapvals.beta),
+			   gimp_deg_to_rad (mapvals.gamma));
+      gimp_vector3_add (&p[cnt], &p[cnt], &mapvals.position);
+    }
+
+  p[cnt] = p[WIRESIZE+1];
+  cnt++;
+  cnt2 = cnt;
+
+  /* Find rotated axis */
+  /* ================= */
+
+  gimp_vector3_set (&p[cnt], 0.0, -0.35, 0.0);
+  gimp_vector3_rotate (&p[cnt],
+		       gimp_deg_to_rad (mapvals.alpha),
+		       gimp_deg_to_rad (mapvals.beta),
+		       gimp_deg_to_rad (mapvals.gamma));
+  p[cnt+1] = mapvals.position;
+
+  gimp_vector3_set (&p[cnt+2], 0.0, 0.0, -0.35);
+  gimp_vector3_rotate (&p[cnt+2],
+		       gimp_deg_to_rad (mapvals.alpha),
+		       gimp_deg_to_rad (mapvals.beta),
+		       gimp_deg_to_rad (mapvals.gamma));
+  p[cnt+3] = mapvals.position;
+
+  p[cnt + 4] = p[cnt];
+  gimp_vector3_mul (&p[cnt + 4], -1.0);
+  p[cnt + 5] = p[cnt + 1];
+
+  gimp_vector3_add (&p[cnt],     &p[cnt],     &mapvals.position);
+  gimp_vector3_add (&p[cnt + 2], &p[cnt + 2], &mapvals.position);
+  gimp_vector3_add (&p[cnt + 4], &p[cnt + 4], &mapvals.position);
+
+  /* Draw the circles (equator and zero meridian) */
+  /* ============================================ */
+
+  cx1 = (gdouble) startx;
+  cy1 = (gdouble) starty;
+  cx2 = cx1 + (gdouble) pw;
+  cy2 = cy1 + (gdouble) ph;
+
+  for (cnt = 0; cnt < cnt2 - 1; cnt++)
+    {
+      if (p[cnt].z > mapvals.position.z && p[cnt + 1].z > mapvals.position.z)
+        {
+          gimp_vector_3d_to_2d (startx, starty, pw, ph,
+				&x1, &y1, &mapvals.viewpoint, &p[cnt]);
+          gimp_vector_3d_to_2d (startx, starty, pw, ph,
+				&x2, &y2, &mapvals.viewpoint, &p[cnt + 1]);
+
+          cairo_move_to (cr, (gint) (x1 + 0.5), (gint) (y1 + 0.5));
+          cairo_line_to (cr, (gint) (x2 + 0.5), (gint) (y2 + 0.5));
+        }
+    }
+
+  /* Draw the axis (pole to pole and center to zero meridian) */
+  /* ======================================================== */
+
+  for (cnt = 0; cnt < 3; cnt++)
+    {
+      gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			    &x1, &y1, &mapvals.viewpoint, &p[cnt2]);
+      gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			    &x2, &y2, &mapvals.viewpoint, &p[cnt2 + 1]);
+
+      cairo_move_to (cr, RINT (x1), RINT (y1));
+      cairo_line_to (cr, RINT (x2), RINT (y2));
+
+      cnt2 += 2;
+    }
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_stroke_preserve (cr);
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+  cairo_stroke (cr);
+
+  cairo_destroy (cr);
+}
+
+static void
+draw_line (cairo_t    *cr,
+	   gint        startx,
+	   gint        starty,
+	   gint        pw,
+	   gint        ph,
+	   gdouble     cx1,
+	   gdouble     cy1,
+	   gdouble     cx2,
+	   gdouble     cy2,
+	   GimpVector3 a,
+	   GimpVector3 b)
+{
+  gdouble x1, y1, x2, y2;
+
+  gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			&x1, &y1, &mapvals.viewpoint, &a);
+  gimp_vector_3d_to_2d (startx, starty, pw, ph,
+			&x2, &y2, &mapvals.viewpoint, &b);
+
+  cairo_move_to (cr, RINT (x1), RINT (y1));
+  cairo_line_to (cr, RINT (x2), RINT (y2));
+}
+
+static void
+draw_wireframe_box (gint startx,
+		    gint starty,
+		    gint pw,
+		    gint ph)
+{
+  GimpVector3 p[8], tmp, scale;
+  gint        i;
+  gdouble     cx1, cy1, cx2, cy2;
+  cairo_t    *cr;
+
+  cr = gdk_cairo_create (gtk_widget_get_window (previewarea));
+
+  cairo_rectangle (cr, startx, starty, pw, ph);
+  cairo_clip (cr);
+
+  /* Compute wireframe points */
+  /* ======================== */
+
+  init_compute ();
+
+  scale = mapvals.scale;
+  gimp_vector3_mul (&scale, 0.5);
+
+  gimp_vector3_set (&p[0], -scale.x, -scale.y, scale.z);
+  gimp_vector3_set (&p[1],  scale.x, -scale.y, scale.z);
+  gimp_vector3_set (&p[2],  scale.x,  scale.y, scale.z);
+  gimp_vector3_set (&p[3], -scale.x,  scale.y, scale.z);
+
+  gimp_vector3_set (&p[4], -scale.x, -scale.y, -scale.z);
+  gimp_vector3_set (&p[5],  scale.x, -scale.y, -scale.z);
+  gimp_vector3_set (&p[6],  scale.x,  scale.y, -scale.z);
+  gimp_vector3_set (&p[7], -scale.x,  scale.y, -scale.z);
+
+  /* Rotate and translate points */
+  /* =========================== */
+
+  for (i = 0; i < 8; i++)
+    {
+      vecmulmat (&tmp, &p[i], rotmat);
+      gimp_vector3_add (&p[i], &tmp, &mapvals.position);
+    }
+
+  /* Draw the box */
+  /* ============ */
+
+  cx1 = (gdouble) startx;
+  cy1 = (gdouble) starty;
+  cx2 = cx1 + (gdouble) pw;
+  cy2 = cy1 + (gdouble) ph;
+
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[0],p[1]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[1],p[2]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[2],p[3]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[3],p[0]);
+
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[4],p[5]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[5],p[6]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[6],p[7]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[7],p[4]);
+
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[0],p[4]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[1],p[5]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[2],p[6]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[3],p[7]);
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_stroke_preserve (cr);
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+  cairo_stroke (cr);
+
+  cairo_destroy (cr);
+}
+
+static void
+draw_wireframe_cylinder (gint startx,
+			 gint starty,
+			 gint pw,
+			 gint ph)
+{
+  GimpVector3 p[2*8], a, axis, scale;
+  gint        i;
+  gdouble     cx1, cy1, cx2, cy2;
+  gfloat      m[16], l, angle;
+  cairo_t    *cr;
+
+  cr = gdk_cairo_create (gtk_widget_get_window (previewarea));
+
+  cairo_rectangle (cr, startx, starty, pw, ph);
+  cairo_clip (cr);
+
+  /* Compute wireframe points */
+  /* ======================== */
+
+  init_compute ();
+
+  scale = mapvals.scale;
+  gimp_vector3_mul (&scale, 0.5);
+
+  l = mapvals.cylinder_length / 2.0;
+  angle = 0;
+
+  gimp_vector3_set (&axis, 0.0, 1.0, 0.0);
+
+  for (i = 0; i < 8; i++)
+    {
+      rotatemat (angle, &axis, m);
+
+      gimp_vector3_set (&a, mapvals.cylinder_radius, 0.0, 0.0);
+
+      vecmulmat (&p[i], &a, m);
+
+      p[i+8] = p[i];
+
+      p[i].y   += l;
+      p[i+8].y -= l;
+
+      angle += 360.0 / 8.0;
+    }
+
+  /* Rotate and translate points */
+  /* =========================== */
+
+  for (i = 0; i < 16; i++)
+    {
+      vecmulmat (&a, &p[i], rotmat);
+      gimp_vector3_add (&p[i], &a, &mapvals.position);
+    }
+
+  /* Draw the box */
+  /* ============ */
+
+  cx1 = (gdouble) startx;
+  cy1 = (gdouble) starty;
+  cx2 = cx1 + (gdouble) pw;
+  cy2 = cy1 + (gdouble) ph;
+
+  for (i = 0; i < 7; i++)
+    {
+      draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[i],p[i+1]);
+      draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[i+8],p[i+9]);
+      draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[i],p[i+8]);
+    }
+
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[7],p[0]);
+  draw_line (cr, startx,starty,pw,ph, cx1,cy1,cx2,cy2, p[15],p[8]);
+
+  cairo_set_line_width (cr, 3.0);
+  cairo_stroke_preserve (cr);
+  cairo_set_line_width (cr, 1.0);
+  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+  cairo_stroke (cr);
+
+  cairo_destroy (cr);
+}
diff --git a/plug-ins/map-object/map-object-preview.h b/plug-ins/map-object/map-object-preview.h
index bd2b20c..bbcfb77 100644
--- a/plug-ins/map-object/map-object-preview.h
+++ b/plug-ins/map-object/map-object-preview.h
@@ -4,6 +4,8 @@
 #define PREVIEW_WIDTH 200
 #define PREVIEW_HEIGHT 200
 
+#define WIRESIZE 16
+
 /* Externally visible variables */
 /* ============================ */
 
@@ -16,6 +18,11 @@ extern gint       lightx,lighty;
 void     compute_preview_image  (void);
 gboolean preview_expose         (GtkWidget      *widget,
                                  GdkEventExpose *eevent);
+void     draw_wireframe         (gint startx,
+                                 gint starty,
+                                 gint pw,
+                                 gint ph);
+void     draw_preview_wireframe (void);
 gint     check_light_hit        (gint            xpos,
                                  gint            ypos);
 void     update_light           (gint            xpos,
diff --git a/plug-ins/map-object/map-object-ui.c b/plug-ins/map-object/map-object-ui.c
index 10aebae..4c97a39 100644
--- a/plug-ins/map-object/map-object-ui.c
+++ b/plug-ins/map-object/map-object-ui.c
@@ -89,30 +89,30 @@ static void
 update_light_pos_entries (void)
 {
   g_signal_handlers_block_by_func (xadj,
-                                   gimp_double_adjustment_update,
+                                   double_adjustment_update,
                                    &mapvals.lightsource.position.x);
   gtk_adjustment_set_value (GTK_ADJUSTMENT (xadj),
 			    mapvals.lightsource.position.x);
   g_signal_handlers_unblock_by_func (xadj,
-                                     gimp_double_adjustment_update,
+                                     double_adjustment_update,
                                      &mapvals.lightsource.position.x);
 
   g_signal_handlers_block_by_func (yadj,
-                                   gimp_double_adjustment_update,
+                                   double_adjustment_update,
                                    &mapvals.lightsource.position.y);
   gtk_adjustment_set_value (GTK_ADJUSTMENT (yadj),
 			    mapvals.lightsource.position.y);
   g_signal_handlers_unblock_by_func (yadj,
-                                     gimp_double_adjustment_update,
+                                     double_adjustment_update,
                                      &mapvals.lightsource.position.y);
 
   g_signal_handlers_block_by_func (zadj,
-                                   gimp_double_adjustment_update,
+                                   double_adjustment_update,
                                    &mapvals.lightsource.position.z);
   gtk_adjustment_set_value (GTK_ADJUSTMENT (zadj),
 			    mapvals.lightsource.position.z);
   g_signal_handlers_unblock_by_func (zadj,
-                                     gimp_double_adjustment_update,
+                                     double_adjustment_update,
                                      &mapvals.lightsource.position.z);
 }
 
@@ -157,9 +157,10 @@ lightmenu_callback (GtkWidget *widget,
     }
 
   if (mapvals.livepreview)
-    compute_preview_image ();
-
-  gtk_widget_queue_draw (previewarea);
+    {
+      compute_preview_image ();
+      gtk_widget_queue_draw (previewarea);
+    }
 }
 
 /***************************************/
@@ -523,7 +524,7 @@ create_options_page (void)
 			      _("Antialiasing quality. Higher is better, "
 			       "but slower"), NULL);
   g_signal_connect (adj, "value-changed",
-                    G_CALLBACK (double_adjustment_update),
+                    G_CALLBACK (gimp_double_adjustment_update),
                     &mapvals.maxdepth);
 
   spinbutton = gimp_spin_button_new (&adj, mapvals.pixeltreshold,
@@ -1363,7 +1364,16 @@ main_dialog (GimpDrawable *drawable)
                     G_CALLBACK (zoomed_callback),
                     NULL);
 
-  toggle = gtk_check_button_new_with_mnemonic (_("Update previe_w live"));
+  toggle = gtk_check_button_new_with_mnemonic (_("Show _wireframe"));
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), mapvals.showgrid);
+  gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
+  gtk_widget_show (toggle);
+
+  g_signal_connect (toggle, "toggled",
+                    G_CALLBACK (toggle_update),
+                    &mapvals.showgrid);
+
+  toggle = gtk_check_button_new_with_mnemonic (_("Update preview _live"));
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), mapvals.livepreview);
   gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
   gtk_widget_show (toggle);



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