gimpinkoptions-gui.c 20.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "tools-types.h"

27 28
#include "config/gimpconfig-params.h"

29 30 31 32
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimptoolinfo.h"

33 34
#include "widgets/gimppropwidgets.h"

35
#include "gimpinkoptions.h"
36
#include "gimpinktool-blob.h"
37
#include "gimppaintoptions-gui.h"
38

39
#include "gimp-intl.h"
40 41


42 43 44 45
enum
{
  PROP_0,
  PROP_SIZE,
46 47
  PROP_TILT_ANGLE,
  PROP_SIZE_SENSITIVITY,
48 49 50 51 52 53 54 55
  PROP_VEL_SENSITIVITY,
  PROP_TILT_SENSITIVITY,
  PROP_BLOB_TYPE,
  PROP_BLOB_ASPECT,
  PROP_BLOB_ANGLE
};


56 57 58
static void   gimp_ink_options_init       (GimpInkOptions      *options);
static void   gimp_ink_options_class_init (GimpInkOptionsClass *options_class);

59 60 61 62 63 64 65 66
static void   gimp_ink_options_set_property (GObject         *object,
                                             guint            property_id,
                                             const GValue    *value,
                                             GParamSpec      *pspec);
static void   gimp_ink_options_get_property (GObject         *object,
                                             guint            property_id,
                                             GValue          *value,
                                             GParamSpec      *pspec);
67

68 69
static GtkWidget * brush_widget_new         (GimpInkOptions  *options);
static GtkWidget * blob_button_new          (GimpInkBlobType  blob_type);
70

71 72 73 74

static GimpPaintOptionsClass *parent_class = NULL;


75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
GType
gimp_ink_options_get_type (void)
{
  static GType type = 0;

  if (! type)
    {
      static const GTypeInfo info =
      {
        sizeof (GimpInkOptionsClass),
	(GBaseInitFunc) NULL,
	(GBaseFinalizeFunc) NULL,
	(GClassInitFunc) gimp_ink_options_class_init,
	NULL,           /* class_finalize */
	NULL,           /* class_data     */
	sizeof (GimpInkOptions),
	0,              /* n_preallocs    */
	(GInstanceInitFunc) gimp_ink_options_init,
      };

      type = g_type_register_static (GIMP_TYPE_PAINT_OPTIONS,
                                     "GimpInkOptions",
                                     &info, 0);
    }

  return type;
}

103
static void
104 105
gimp_ink_options_class_init (GimpInkOptionsClass *klass)
{
106
  GObjectClass *object_class;
107

108
  object_class = G_OBJECT_CLASS (klass);
109 110 111 112 113 114

  parent_class = g_type_class_peek_parent (klass);

  object_class->set_property = gimp_ink_options_set_property;
  object_class->get_property = gimp_ink_options_get_property;

115 116 117 118
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SIZE,
                                   "size", NULL,
                                   0.0, 20.0, 4.4,
                                   0);
119 120 121 122 123 124 125
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TILT_ANGLE,
                                   "tilt-angle", NULL,
                                   -90.0, 90.0, 0.0,
                                   0);

  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SIZE_SENSITIVITY,
                                   "size-sensitivity", NULL,
126 127 128 129 130 131 132 133 134 135
                                   0.0, 1.0, 1.0,
                                   0);
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_VEL_SENSITIVITY,
                                   "vel-sensitivity", NULL,
                                   0.0, 1.0, 0.8,
                                   0);
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_TILT_SENSITIVITY,
                                   "tilt-sensitivity", NULL,
                                   0.0, 1.0, 0.4,
                                   0);
136

137 138 139 140 141 142 143 144 145 146 147 148 149
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BLOB_TYPE,
                                 "blob-type", NULL,
                                 GIMP_TYPE_INK_BLOB_TYPE,
                                 GIMP_INK_BLOB_TYPE_ELLIPSE,
                                 0);
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BLOB_ASPECT,
                                   "blob-aspect", NULL,
                                   1.0, 10.0, 1.0,
                                   0);
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BLOB_ANGLE,
                                   "blob-angle", NULL,
                                   -90.0, 90.0, 0.0,
                                   0);
150 151 152 153 154 155 156
}

static void
gimp_ink_options_init (GimpInkOptions *options)
{
}

157 158 159 160 161 162
static void
gimp_ink_options_set_property (GObject      *object,
                               guint         property_id,
                               const GValue *value,
                               GParamSpec   *pspec)
{
163 164 165 166 167 168 169 170 171
  GimpInkOptions *options;

  options = GIMP_INK_OPTIONS (object);

  switch (property_id)
    {
    case PROP_SIZE:
      options->size = g_value_get_double (value);
      break;
172 173 174 175 176
    case PROP_TILT_ANGLE:
      options->tilt_angle = g_value_get_double (value);
      break;
    case PROP_SIZE_SENSITIVITY:
      options->size_sensitivity = g_value_get_double (value);
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
      break;
    case PROP_VEL_SENSITIVITY:
      options->vel_sensitivity = g_value_get_double (value);
      break;
    case PROP_TILT_SENSITIVITY:
      options->tilt_sensitivity = g_value_get_double (value);
      break;
    case PROP_BLOB_TYPE:
      options->blob_type = g_value_get_enum (value);
      break;
    case PROP_BLOB_ASPECT:
      options->blob_aspect = g_value_get_double (value);
      break;
    case PROP_BLOB_ANGLE:
      options->blob_angle = g_value_get_double (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
197 198 199 200 201 202 203 204
}

static void
gimp_ink_options_get_property (GObject    *object,
                               guint       property_id,
                               GValue     *value,
                               GParamSpec *pspec)
{
205 206 207 208 209 210 211 212 213
  GimpInkOptions *options;

  options = GIMP_INK_OPTIONS (object);

  switch (property_id)
    {
    case PROP_SIZE:
      g_value_set_double (value, options->size);
      break;
214 215 216 217 218
    case PROP_TILT_ANGLE:
      g_value_set_double (value, options->tilt_angle);
      break;
    case PROP_SIZE_SENSITIVITY:
      g_value_set_double (value, options->size_sensitivity);
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
      break;
    case PROP_VEL_SENSITIVITY:
      g_value_set_double (value, options->vel_sensitivity);
      break;
    case PROP_TILT_SENSITIVITY:
      g_value_set_double (value, options->tilt_sensitivity);
      break;
    case PROP_BLOB_TYPE:
      g_value_set_enum (value, options->blob_type);
      break;
    case PROP_BLOB_ASPECT:
      g_value_set_double (value, options->blob_aspect);
      break;
    case PROP_BLOB_ANGLE:
      g_value_set_double (value, options->blob_angle);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
239 240
}

241
GtkWidget *
242 243
gimp_ink_options_gui (GimpToolOptions *tool_options)
{
244 245 246
  GObject   *config;
  GtkWidget *table;
  GtkWidget *vbox;
247
  GtkWidget *brush_vbox;
248 249 250
  GtkWidget *hbox;
  GtkWidget *frame;
  GtkWidget *brush;
251

252
  config = G_OBJECT (tool_options);
253

254
  vbox = gimp_paint_options_gui (tool_options);
255 256 257 258 259 260 261 262 263 264 265 266 267

  /* adjust sliders */
  frame = gtk_frame_new (_("Adjustment"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (2, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  gtk_container_set_border_width (GTK_CONTAINER (table), 2);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  /*  size slider  */
268 269 270 271 272
  gimp_prop_scale_entry_new (config, "size",
                             GTK_TABLE (table), 0, 0,
                             _("Size:"),
                             1.0, 2.0, 1,
                             FALSE, 0.0, 0.0);
273 274

  /* angle adjust slider */
275 276 277 278 279
  gimp_prop_scale_entry_new (config, "tilt-angle",
                             GTK_TABLE (table), 0, 1,
                             _("Angle:"),
                             1.0, 10.0, 1,
                             FALSE, 0.0, 0.0);
280 281 282 283 284 285 286 287 288 289 290 291 292

  /* sens sliders */
  frame = gtk_frame_new (_("Sensitivity"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (3, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  gtk_container_set_border_width (GTK_CONTAINER (table), 2);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  /* size sens slider */
293
  gimp_prop_scale_entry_new (config, "size-sensitivity",
294 295 296 297
                             GTK_TABLE (table), 0, 0,
                             _("Size:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
298

299
  /* tilt sens slider */
300 301 302 303 304
  gimp_prop_scale_entry_new (config, "tilt-sensitivity",
                             GTK_TABLE (table), 0, 1,
                             _("Tilt:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
305 306

  /* velocity sens slider */
307 308 309 310 311
  gimp_prop_scale_entry_new (config, "vel-sensitivity",
                             GTK_TABLE (table), 0, 2,
                             _("Speed:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
312 313 314

  /*  bottom hbox */
  hbox = gtk_hbox_new (FALSE, 2);
315
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
316 317 318
  gtk_widget_show (hbox);

  /* Brush type radiobuttons */
319 320
  frame = gimp_prop_enum_radio_frame_new (config, "blob-type",
                                          _("Type"), 0, 0);
321 322 323
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

324
  {
325 326 327
    GList           *children;
    GList           *list;
    GimpInkBlobType  blob_type;
328

329 330
    children =
      gtk_container_get_children (GTK_CONTAINER (GTK_BIN (frame)->child));
331

332
    for (list = children, blob_type = GIMP_INK_BLOB_TYPE_ELLIPSE;
333
         list;
334
         list = g_list_next (list), blob_type++)
335 336
      {
        GtkWidget *radio;
337
        GtkWidget *blob;
338

339
        radio = GTK_WIDGET (list->data);
340

341
        gtk_container_remove (GTK_CONTAINER (radio), GTK_BIN (radio)->child);
342

343
        blob = blob_button_new (blob_type);
344 345 346
        gtk_container_add (GTK_CONTAINER (radio), blob);
        gtk_widget_show (blob);
      }
347

348 349
    g_list_free (children);
  }
350 351 352 353 354 355

  /* Brush shape widget */
  frame = gtk_frame_new (_("Shape"));
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

356 357 358 359
  brush_vbox = gtk_vbox_new (FALSE, 2);
  gtk_container_set_border_width (GTK_CONTAINER (brush_vbox), 2);
  gtk_container_add (GTK_CONTAINER (frame), brush_vbox);
  gtk_widget_show (brush_vbox);
360 361 362

  frame = gtk_aspect_frame_new (NULL, 0.0, 0.5, 1.0, FALSE);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
363
  gtk_box_pack_start (GTK_BOX (brush_vbox), frame, TRUE, TRUE, 0);
364
  gtk_widget_show (frame);
365

366 367 368
  brush = brush_widget_new (GIMP_INK_OPTIONS (tool_options));
  gtk_container_add (GTK_CONTAINER (frame), brush);
  gtk_widget_show (brush);
369 370

  return vbox;
371 372 373 374 375 376 377 378 379 380
}


/*  BrushWidget functions  */

typedef struct _BrushWidget BrushWidget;

struct _BrushWidget
{
  GtkWidget      *widget;
381
  gboolean        active;
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414

  /* EEK */
  GimpInkOptions *ink_options;
};

static void     brush_widget_notify         (GimpInkOptions *options,
                                             GParamSpec     *pspec,
                                             BrushWidget    *brush_widget);
static void     brush_widget_active_rect    (BrushWidget    *brush_widget,
                                             GtkWidget      *widget,
                                             GdkRectangle   *rect);
static void     brush_widget_realize        (GtkWidget      *widget);
static gboolean brush_widget_expose         (GtkWidget      *widget,
                                             GdkEventExpose *event,
                                             BrushWidget    *brush_widget);
static gboolean brush_widget_button_press   (GtkWidget      *widget,
                                             GdkEventButton *event,
                                             BrushWidget    *brush_widget);
static gboolean brush_widget_button_release (GtkWidget      *widget,
                                             GdkEventButton *event,
                                             BrushWidget    *brush_widget);
static gboolean brush_widget_motion_notify  (GtkWidget      *widget,
                                             GdkEventMotion *event,
                                             BrushWidget    *brush_widget);

static void     paint_blob                  (GdkDrawable    *drawable,
                                             GdkGC          *gc,
                                             Blob           *blob);

static GtkWidget *
brush_widget_new (GimpInkOptions *options)
{
  BrushWidget *brush_w;
415 416

  brush_w = g_new (BrushWidget, 1);
417
  brush_w->widget      = gtk_drawing_area_new ();
418
  brush_w->active      = FALSE;
419 420
  brush_w->ink_options = options;

421 422 423 424 425 426 427
  gtk_widget_set_size_request (brush_w->widget, 60, 60);
  gtk_widget_set_events (brush_w->widget,
			 GDK_BUTTON_PRESS_MASK   |
                         GDK_BUTTON_RELEASE_MASK |
			 GDK_POINTER_MOTION_MASK |
                         GDK_EXPOSURE_MASK);

428
  g_signal_connect (options, "notify",
429
                    G_CALLBACK (brush_widget_notify),
430
                    brush_w);
431

432
  g_signal_connect (brush_w->widget, "button_press_event",
433
		    G_CALLBACK (brush_widget_button_press),
434
		    brush_w);
435
  g_signal_connect (brush_w->widget, "button_release_event",
436
		    G_CALLBACK (brush_widget_button_release),
437
		    brush_w);
438
  g_signal_connect (brush_w->widget, "motion_notify_event",
439
		    G_CALLBACK (brush_widget_motion_notify),
440
		    brush_w);
441
  g_signal_connect (brush_w->widget, "expose_event",
442
		    G_CALLBACK (brush_widget_expose),
443
		    brush_w);
444
  g_signal_connect (brush_w->widget, "realize",
445
		    G_CALLBACK (brush_widget_realize),
446
		    brush_w);
447

448 449 450 451
  g_object_weak_ref (G_OBJECT (brush_w->widget),
                     (GWeakNotify) g_free, brush_w);

  return brush_w->widget;
452
}
453

454
static void
455 456 457
brush_widget_notify (GimpInkOptions *options,
                     GParamSpec     *pspec,
                     BrushWidget    *brush_w)
458 459 460 461 462 463 464 465 466 467 468 469
{
  switch (pspec->param_id)
    {
    case PROP_BLOB_TYPE:
    case PROP_BLOB_ASPECT:
    case PROP_BLOB_ANGLE:
      gtk_widget_queue_draw (brush_w->widget);
      break;

    default:
      break;
    }
470 471 472
}

static void
473 474 475
brush_widget_active_rect (BrushWidget  *brush_widget,
			  GtkWidget    *widget,
			  GdkRectangle *rect)
476
{
477 478
  gint x,y;
  gint r;
479

480 481 482 483 484 485 486 487 488
  r = MIN (widget->allocation.width, widget->allocation.height) / 2;

  x = (widget->allocation.width / 2 +
       0.85 * r * brush_widget->ink_options->blob_aspect / 10.0 *
       cos (brush_widget->ink_options->blob_angle));

  y = (widget->allocation.height / 2 +
       0.85 * r * brush_widget->ink_options->blob_aspect / 10.0 *
       sin (brush_widget->ink_options->blob_angle));
489

490 491 492 493
  rect->x      = x - 5;
  rect->y      = y - 5;
  rect->width  = 10;
  rect->height = 10;
494 495 496
}

static void
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
brush_widget_realize (GtkWidget *widget)
{
  gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
}

static void
brush_widget_draw_brush (BrushWidget *brush_widget,
			 GtkWidget   *widget,
			 gdouble      xc,
			 gdouble      yc,
			 gdouble      radius)
{
  BlobFunc  function = blob_ellipse;
  Blob     *blob;

  switch (brush_widget->ink_options->blob_type)
    {
    case GIMP_INK_BLOB_TYPE_ELLIPSE:
      function = blob_ellipse;
      break;

    case GIMP_INK_BLOB_TYPE_SQUARE:
      function = blob_square;
      break;

    case GIMP_INK_BLOB_TYPE_DIAMOND:
      function = blob_diamond;
      break;
    }

  blob = (* function) (xc, yc,
                       radius * cos (brush_widget->ink_options->blob_angle),
                       radius * sin (brush_widget->ink_options->blob_angle),
                       (- (radius / brush_widget->ink_options->blob_aspect) *
                        sin (brush_widget->ink_options->blob_angle)),
                       ((radius / brush_widget->ink_options->blob_aspect) *
                        cos (brush_widget->ink_options->blob_angle)));
  paint_blob (widget->window, widget->style->fg_gc[widget->state], blob);
  g_free (blob);
}

static gboolean
brush_widget_expose (GtkWidget      *widget,
		     GdkEventExpose *event,
		     BrushWidget    *brush_widget)
542
{
543 544 545 546 547 548 549
  GdkRectangle rect;
  gint         r0;

  r0 = MIN (widget->allocation.width, widget->allocation.height) / 2;

  if (r0 < 2)
    return TRUE;
550

551 552 553 554 555 556 557 558
  brush_widget_draw_brush (brush_widget, widget,
			   widget->allocation.width  / 2,
			   widget->allocation.height / 2,
			   0.9 * r0);

  brush_widget_active_rect (brush_widget, widget, &rect);
  gdk_draw_rectangle (widget->window, widget->style->bg_gc[GTK_STATE_NORMAL],
		      TRUE,	/* filled */
559
		      rect.x, rect.y,
560 561 562 563 564 565
		      rect.width, rect.height);
  gtk_paint_shadow (widget->style, widget->window, widget->state,
                    GTK_SHADOW_OUT,
                    NULL, widget, NULL,
                    rect.x, rect.y,
                    rect.width, rect.height);
566

567 568
  return TRUE;
}
569

570 571 572 573 574 575 576 577 578 579 580 581
static gboolean
brush_widget_button_press (GtkWidget      *widget,
			   GdkEventButton *event,
			   BrushWidget    *brush_widget)
{
  GdkRectangle rect;

  brush_widget_active_rect (brush_widget, widget, &rect);

  if ((event->x >= rect.x) && (event->x-rect.x < rect.width) &&
      (event->y >= rect.y) && (event->y-rect.y < rect.height))
    {
582
      brush_widget->active = TRUE;
583 584 585 586 587 588 589 590 591 592
    }

  return TRUE;
}

static gboolean
brush_widget_button_release (GtkWidget      *widget,
			     GdkEventButton *event,
			     BrushWidget    *brush_widget)
{
593
  brush_widget->active = FALSE;
594 595 596 597 598 599 600 601 602

  return TRUE;
}

static gboolean
brush_widget_motion_notify (GtkWidget      *widget,
			    GdkEventMotion *event,
			    BrushWidget    *brush_widget)
{
603
  if (brush_widget->active)
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
    {
      gint x;
      gint y;
      gint rsquare;

      x = event->x - widget->allocation.width  / 2;
      y = event->y - widget->allocation.height / 2;

      rsquare = x*x + y*y;

      if (rsquare != 0)
	{
          gint    r0;
          gdouble angle;
          gdouble aspect;

	  r0 = MIN (widget->allocation.width, widget->allocation.height) / 2;

          angle  = atan2 (y, x);
          aspect = 10.0 * sqrt ((gdouble) rsquare / (r0 * r0)) / 0.85;

          aspect = CLAMP (aspect, 1.0, 10.0);

627
          g_object_set (brush_widget->ink_options,
628 629 630 631 632 633 634 635 636 637 638 639 640 641
                        "blob-angle",  angle,
                        "blob-aspect", aspect,
                        NULL);

	  gtk_widget_queue_draw (widget);
	}
    }

  return TRUE;
}


/*  blob button functions  */

642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
static gboolean   blob_button_expose (GtkWidget      *widget,
                                      GdkEventExpose *event,
                                      BlobFunc        function);

static GtkWidget *
blob_button_new (GimpInkBlobType blob_type)
{
  GtkWidget *blob;
  BlobFunc   function = blob_ellipse;

  switch (blob_type)
    {
    case GIMP_INK_BLOB_TYPE_ELLIPSE:
      function = blob_ellipse;
      break;

    case GIMP_INK_BLOB_TYPE_SQUARE:
      function = blob_square;
      break;

    case GIMP_INK_BLOB_TYPE_DIAMOND:
      function = blob_diamond;
      break;
    }

  blob = gtk_drawing_area_new ();
  gtk_widget_set_size_request (blob, 21, 21);

  g_signal_connect (blob, "expose_event",
                    G_CALLBACK (blob_button_expose),
                    function);

  return blob;
}

677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
static gboolean
blob_button_expose (GtkWidget      *widget,
                    GdkEventExpose *event,
                    BlobFunc        function)
{
  Blob *blob;

  blob = (* function) (widget->allocation.width  / 2,
                       widget->allocation.height / 2,
                       8, 0, 0, 8);
  paint_blob (widget->window, widget->style->fg_gc[widget->state], blob);
  g_free (blob);

  return TRUE;
}


/*  Draw a blob onto a drawable with the specified graphics context  */

static void
paint_blob (GdkDrawable *drawable,
	    GdkGC       *gc,
	    Blob        *blob)
{
  gint i;

  for (i = 0; i < blob->height; i++)
    if (blob->data[i].left <= blob->data[i].right)
      gdk_draw_line (drawable, gc,
                     blob->data[i].left,      i + blob->y,
                     blob->data[i].right + 1, i + blob->y);
708
}