gtktexttag.c 69.7 KB
Newer Older
1
/* gtktexttag.c - text tag object
2
 *
3 4 5 6 7 8 9 10 11
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 2000      Red Hat, Inc.
 * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
 *
 * This software is copyrighted by the Regents of the University of
 * California, Sun Microsystems, Inc., and other parties.  The
 * following terms apply to all files associated with the software
 * unless explicitly disclaimed in individual files.
12
 *
13 14 15 16 17 18 19 20 21
 * The authors hereby grant permission to use, copy, modify,
 * distribute, and license this software and its documentation for any
 * purpose, provided that existing copyright notices are retained in
 * all copies and that this notice is included verbatim in any
 * distributions. No written agreement, license, or royalty fee is
 * required for any of the authorized uses.  Modifications to this
 * software may be copyrighted by their authors and need not follow
 * the licensing terms described here, provided that the new terms are
 * clearly indicated on the first page of each file where they apply.
22
 *
23 24 25 26 27
 * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
 * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
 * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
 * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
 * NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
 * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * GOVERNMENT USE: If you are acquiring this software on behalf of the
 * U.S. government, the Government shall have only "Restricted Rights"
 * in the software and related documentation as defined in the Federal
 * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
 * are acquiring the software on behalf of the Department of Defense,
 * the software shall be classified as "Commercial Computer Software"
 * and the Government shall have only "Restricted Rights" as defined
 * in Clause 252.227-7013 (c) (1) of DFARs.  Notwithstanding the
 * foregoing, the authors grant the U.S. Government and others acting
 * in its behalf permission to use and distribute the software in
 * accordance with the terms specified in this license.
47
 *
48 49
 */

50
#include <config.h>
51
#include "gtkalias.h"
52
#include "gtkmain.h"
53 54 55
#include "gtktexttag.h"
#include "gtktexttypes.h"
#include "gtktexttagtable.h"
56
#include "gtkmain.h"
57
#include "gtkintl.h"
58
#include "gtkmarshalers.h"
59 60

#include <stdlib.h>
61
#include <string.h>
62 63 64 65 66 67 68

enum {
  EVENT,
  LAST_SIGNAL
};

enum {
69
  PROP_0,
70
  /* Construct args */
71
  PROP_NAME,
72 73

  /* Style args */
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
  PROP_BACKGROUND,
  PROP_FOREGROUND,
  PROP_BACKGROUND_GDK,
  PROP_FOREGROUND_GDK,
  PROP_BACKGROUND_STIPPLE,
  PROP_FOREGROUND_STIPPLE,
  PROP_FONT,
  PROP_FONT_DESC,
  PROP_FAMILY,
  PROP_STYLE,
  PROP_VARIANT,
  PROP_WEIGHT,
  PROP_STRETCH,
  PROP_SIZE,
  PROP_SIZE_POINTS,
Havoc Pennington's avatar
Havoc Pennington committed
89
  PROP_SCALE,
90 91 92 93 94
  PROP_PIXELS_ABOVE_LINES,
  PROP_PIXELS_BELOW_LINES,
  PROP_PIXELS_INSIDE_WRAP,
  PROP_EDITABLE,
  PROP_WRAP_MODE,
95
  PROP_JUSTIFICATION,
96 97 98 99 100 101 102
  PROP_DIRECTION,
  PROP_LEFT_MARGIN,
  PROP_INDENT,
  PROP_STRIKETHROUGH,
  PROP_RIGHT_MARGIN,
  PROP_UNDERLINE,
  PROP_RISE,
Soeren Sandmann's avatar
Soeren Sandmann committed
103
  PROP_BACKGROUND_FULL_HEIGHT,
104 105 106
  PROP_LANGUAGE,
  PROP_TABS,
  PROP_INVISIBLE,
107
  
108
  /* Whether-a-style-arg-is-set args */
109 110 111 112 113 114 115 116 117 118
  PROP_BACKGROUND_SET,
  PROP_FOREGROUND_SET,
  PROP_BACKGROUND_STIPPLE_SET,
  PROP_FOREGROUND_STIPPLE_SET,
  PROP_FAMILY_SET,
  PROP_STYLE_SET,
  PROP_VARIANT_SET,
  PROP_WEIGHT_SET,
  PROP_STRETCH_SET,
  PROP_SIZE_SET,
Havoc Pennington's avatar
Havoc Pennington committed
119
  PROP_SCALE_SET,
120 121 122 123 124
  PROP_PIXELS_ABOVE_LINES_SET,
  PROP_PIXELS_BELOW_LINES_SET,
  PROP_PIXELS_INSIDE_WRAP_SET,
  PROP_EDITABLE_SET,
  PROP_WRAP_MODE_SET,
125
  PROP_JUSTIFICATION_SET,
126 127 128 129 130 131
  PROP_LEFT_MARGIN_SET,
  PROP_INDENT_SET,
  PROP_STRIKETHROUGH_SET,
  PROP_RIGHT_MARGIN_SET,
  PROP_UNDERLINE_SET,
  PROP_RISE_SET,
Soeren Sandmann's avatar
Soeren Sandmann committed
132
  PROP_BACKGROUND_FULL_HEIGHT_SET,
133 134 135
  PROP_LANGUAGE_SET,
  PROP_TABS_SET,
  PROP_INVISIBLE_SET,
136

137 138
  LAST_ARG
};
139 140 141 142 143 144
static void gtk_text_tag_init         (GtkTextTag      *text_tag);
static void gtk_text_tag_class_init   (GtkTextTagClass *klass);
static void gtk_text_tag_finalize     (GObject         *object);
static void gtk_text_tag_set_property (GObject         *object,
                                       guint            prop_id,
                                       const GValue    *value,
Tim Janik's avatar
Tim Janik committed
145
                                       GParamSpec      *pspec);
146 147 148
static void gtk_text_tag_get_property (GObject         *object,
                                       guint            prop_id,
                                       GValue          *value,
Tim Janik's avatar
Tim Janik committed
149
                                       GParamSpec      *pspec);
150 151

static GObjectClass *parent_class = NULL;
152 153
static guint signals[LAST_SIGNAL] = { 0 };

154
GType
155 156
gtk_text_tag_get_type (void)
{
157
  static GType our_type = 0;
158 159 160

  if (our_type == 0)
    {
161
      static const GTypeInfo our_info =
162 163
      {
        sizeof (GtkTextTagClass),
164 165 166 167 168 169 170 171
        (GBaseInitFunc) NULL,
        (GBaseFinalizeFunc) NULL,
        (GClassInitFunc) gtk_text_tag_class_init,
        NULL,           /* class_finalize */
        NULL,           /* class_data */
        sizeof (GtkTextTag),
        0,              /* n_preallocs */
        (GInstanceInitFunc) gtk_text_tag_init
172 173
      };

Manish Singh's avatar
Manish Singh committed
174 175
      our_type = g_type_register_static (G_TYPE_OBJECT, "GtkTextTag",
                                         &our_info, 0);
176
    }
177 178 179 180 181 182 183

  return our_type;
}

static void
gtk_text_tag_class_init (GtkTextTagClass *klass)
{
184
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
185

186
  parent_class = g_type_class_peek_parent (klass);
187

188 189 190 191
  object_class->set_property = gtk_text_tag_set_property;
  object_class->get_property = gtk_text_tag_get_property;
  
  object_class->finalize = gtk_text_tag_finalize;
192

193
  /* Construct */
194 195 196
  g_object_class_install_property (object_class,
                                   PROP_NAME,
                                   g_param_spec_string ("name",
197 198
                                                        P_("Tag name"),
                                                        P_("Name used to refer to the text tag. NULL for anonymous tags"),
199 200
                                                        NULL,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
201 202

  /* Style args */
203 204 205 206

  g_object_class_install_property (object_class,
                                   PROP_BACKGROUND,
                                   g_param_spec_string ("background",
207 208
                                                        P_("Background color name"),
                                                        P_("Background color as a string"),
209 210 211 212 213 214
                                                        NULL,
                                                        G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_BACKGROUND_GDK,
                                   g_param_spec_boxed ("background_gdk",
215 216
                                                       P_("Background color"),
                                                       P_("Background color as a (possibly unallocated) GdkColor"),
217
                                                       GDK_TYPE_COLOR,
218 219 220
                                                       G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
Soeren Sandmann's avatar
Soeren Sandmann committed
221
                                   PROP_BACKGROUND_FULL_HEIGHT,
222
                                   g_param_spec_boolean ("background_full_height",
223 224
                                                         P_("Background full height"),
                                                         P_("Whether the background color fills the entire line height or only the height of the tagged characters"),
225 226 227
                                                         FALSE,
                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));

228
  
229 230 231
  g_object_class_install_property (object_class,
                                   PROP_BACKGROUND_STIPPLE,
                                   g_param_spec_object ("background_stipple",
232 233
                                                        P_("Background stipple mask"),
                                                        P_("Bitmap to use as a mask when drawing the text background"),
234 235 236 237 238 239 240
                                                        GDK_TYPE_PIXMAP,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));  


  g_object_class_install_property (object_class,
                                   PROP_FOREGROUND,
                                   g_param_spec_string ("foreground",
241 242
                                                        P_("Foreground color name"),
                                                        P_("Foreground color as a string"),
243 244 245 246 247 248
                                                        NULL,
                                                        G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_FOREGROUND_GDK,
                                   g_param_spec_boxed ("foreground_gdk",
249 250
                                                       P_("Foreground color"),
                                                       P_("Foreground color as a (possibly unallocated) GdkColor"),
251
                                                       GDK_TYPE_COLOR,
252 253
                                                       G_PARAM_READABLE | G_PARAM_WRITABLE));

254
  
255 256 257
  g_object_class_install_property (object_class,
                                   PROP_FOREGROUND_STIPPLE,
                                   g_param_spec_object ("foreground_stipple",
258 259
                                                        P_("Foreground stipple mask"),
                                                        P_("Bitmap to use as a mask when drawing the text foreground"),
260 261 262 263 264 265
                                                        GDK_TYPE_PIXMAP,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));  
  
  g_object_class_install_property (object_class,
                                   PROP_DIRECTION,
                                   g_param_spec_enum ("direction",
266 267
                                                      P_("Text direction"),
                                                      P_("Text direction, e.g. right-to-left or left-to-right"),
268 269 270 271 272 273 274
                                                      GTK_TYPE_TEXT_DIRECTION,
                                                      GTK_TEXT_DIR_LTR,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_EDITABLE,
                                   g_param_spec_boolean ("editable",
275 276
                                                         P_("Editable"),
                                                         P_("Whether the text can be modified by the user"),
277 278 279 280 281 282
                                                         TRUE,
                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_FONT,
                                   g_param_spec_string ("font",
283 284
                                                        P_("Font"),
                                                        P_("Font description as a string, e.g. \"Sans Italic 12\""),
285 286 287 288 289 290
                                                        NULL,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_FONT_DESC,
                                   g_param_spec_boxed ("font_desc",
291 292
                                                       P_("Font"),
                                                       P_("Font description as a PangoFontDescription struct"),
293
                                                       PANGO_TYPE_FONT_DESCRIPTION,
294 295 296 297 298 299
                                                       G_PARAM_READABLE | G_PARAM_WRITABLE));

  
  g_object_class_install_property (object_class,
                                   PROP_FAMILY,
                                   g_param_spec_string ("family",
300 301
                                                        P_("Font family"),
                                                        P_("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
302 303 304 305 306 307
                                                        NULL,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_STYLE,
                                   g_param_spec_enum ("style",
308 309
                                                      P_("Font style"),
                                                      P_("Font style as a PangoStyle, e.g. PANGO_STYLE_ITALIC"),
310 311 312 313 314 315 316
                                                      PANGO_TYPE_STYLE,
                                                      PANGO_STYLE_NORMAL,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_VARIANT,
                                   g_param_spec_enum ("variant",
317 318
                                                     P_("Font variant"),
                                                     P_("Font variant as a PangoVariant, e.g. PANGO_VARIANT_SMALL_CAPS"),
319 320 321 322 323 324 325
                                                      PANGO_TYPE_VARIANT,
                                                      PANGO_VARIANT_NORMAL,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_WEIGHT,
                                   g_param_spec_int ("weight",
326 327
                                                     P_("Font weight"),
                                                     P_("Font weight as an integer, see predefined values in PangoWeight; for example, PANGO_WEIGHT_BOLD"),
328 329 330 331 332 333 334 335 336
                                                     0,
                                                     G_MAXINT,
                                                     PANGO_WEIGHT_NORMAL,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));
  

  g_object_class_install_property (object_class,
                                   PROP_STRETCH,
                                   g_param_spec_enum ("stretch",
337 338
                                                      P_("Font stretch"),
                                                      P_("Font stretch as a PangoStretch, e.g. PANGO_STRETCH_CONDENSED"),
339 340 341 342 343 344 345
                                                      PANGO_TYPE_STRETCH,
                                                      PANGO_STRETCH_NORMAL,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_SIZE,
                                   g_param_spec_int ("size",
346 347
                                                     P_("Font size"),
                                                     P_("Font size in Pango units"),
348 349 350 351 352
                                                     0,
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

Havoc Pennington's avatar
Havoc Pennington committed
353 354 355
  g_object_class_install_property (object_class,
                                   PROP_SCALE,
                                   g_param_spec_double ("scale",
356 357
                                                        P_("Font scale"),
                                                        P_("Font size as a scale factor relative to the default font size. This properly adapts to theme changes etc. so is recommended. Pango predefines some scales such as PANGO_SCALE_X_LARGE"),
Havoc Pennington's avatar
Havoc Pennington committed
358 359 360 361 362
                                                        0.0,
                                                        G_MAXDOUBLE,
                                                        1.0,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
  
363 364 365
  g_object_class_install_property (object_class,
                                   PROP_SIZE_POINTS,
                                   g_param_spec_double ("size_points",
366 367
                                                        P_("Font points"),
                                                        P_("Font size in points"),
368 369 370 371 372 373
                                                        0.0,
                                                        G_MAXDOUBLE,
                                                        0.0,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));  

  g_object_class_install_property (object_class,
374 375
                                   PROP_JUSTIFICATION,
                                   g_param_spec_enum ("justification",
376 377
                                                      P_("Justification"),
                                                      P_("Left, right, or center justification"),
378 379 380 381 382 383 384
                                                      GTK_TYPE_JUSTIFICATION,
                                                      GTK_JUSTIFY_LEFT,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_LANGUAGE,
                                   g_param_spec_string ("language",
385
                                                        P_("Language"),
386
                                                        P_("The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If not set, an appropriate default will be used."),
387 388 389 390 391 392
                                                        NULL,
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));  

  g_object_class_install_property (object_class,
                                   PROP_LEFT_MARGIN,
                                   g_param_spec_int ("left_margin",
393 394
                                                     P_("Left margin"),
                                                     P_("Width of the left margin in pixels"),
395 396 397 398 399 400 401 402
                                                     0,
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_RIGHT_MARGIN,
                                   g_param_spec_int ("right_margin",
403 404
                                                     P_("Right margin"),
                                                     P_("Width of the right margin in pixels"),
405 406 407 408 409 410 411 412 413
                                                     0,
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

  
  g_object_class_install_property (object_class,
                                   PROP_INDENT,
                                   g_param_spec_int ("indent",
414 415
                                                     P_("Indent"),
                                                     P_("Amount to indent the paragraph, in pixels"),
416
                                                     G_MININT,
417 418 419 420 421 422 423 424
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

  
  g_object_class_install_property (object_class,
                                   PROP_RISE,
                                   g_param_spec_int ("rise",
425 426
                                                     P_("Rise"),
                                                     P_("Offset of text above the baseline (below the baseline if rise is negative) in pixels"),
427
						     G_MININT,
428 429 430 431 432 433 434
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_PIXELS_ABOVE_LINES,
                                   g_param_spec_int ("pixels_above_lines",
435 436
                                                     P_("Pixels above lines"),
                                                     P_("Pixels of blank space above paragraphs"),
437 438 439 440 441 442 443 444
                                                     0,
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_PIXELS_BELOW_LINES,
                                   g_param_spec_int ("pixels_below_lines",
445 446
                                                     P_("Pixels below lines"),
                                                     P_("Pixels of blank space below paragraphs"),
447 448 449 450 451 452 453 454
                                                     0,
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_PIXELS_INSIDE_WRAP,
                                   g_param_spec_int ("pixels_inside_wrap",
455 456
                                                     P_("Pixels inside wrap"),
                                                     P_("Pixels of blank space between wrapped lines in a paragraph"),
457 458 459 460 461 462 463 464
                                                     0,
                                                     G_MAXINT,
                                                     0,
                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));

  g_object_class_install_property (object_class,
                                   PROP_STRIKETHROUGH,
                                   g_param_spec_boolean ("strikethrough",
465 466
                                                         P_("Strikethrough"),
                                                         P_("Whether to strike through the text"),
467 468 469 470 471 472
                                                         FALSE,
                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_UNDERLINE,
                                   g_param_spec_enum ("underline",
473 474
                                                      P_("Underline"),
                                                      P_("Style of underline for this text"),
475 476 477 478 479 480 481
                                                      PANGO_TYPE_UNDERLINE,
                                                      PANGO_UNDERLINE_NONE,
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_WRAP_MODE,
                                   g_param_spec_enum ("wrap_mode",
482 483
                                                     P_("Wrap mode"),
                                                     P_("Whether to wrap lines never, at word boundaries, or at character boundaries"),
484
                                                      GTK_TYPE_WRAP_MODE,
485
                                                      GTK_WRAP_NONE,
486 487 488 489 490 491
                                                      G_PARAM_READABLE | G_PARAM_WRITABLE));
  

  g_object_class_install_property (object_class,
                                   PROP_TABS,
                                   g_param_spec_boxed ("tabs",
492 493
                                                       P_("Tabs"),
                                                       P_("Custom tabs for this text"),
494
                                                       PANGO_TYPE_TAB_ARRAY,
495 496 497 498 499
                                                       G_PARAM_READABLE | G_PARAM_WRITABLE));
  
  g_object_class_install_property (object_class,
                                   PROP_INVISIBLE,
                                   g_param_spec_boolean ("invisible",
500 501
                                                         P_("Invisible"),
                                                         P_("Whether this text is hidden. Not implemented in GTK 2.0"),
502 503 504 505 506 507 508 509
                                                         FALSE,
                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));

  /* Style props are set or not */

#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))

  ADD_SET_PROP ("background_set", PROP_BACKGROUND_SET,
510 511
                P_("Background set"),
                P_("Whether this tag affects the background color"));
512
  
Soeren Sandmann's avatar
Soeren Sandmann committed
513
  ADD_SET_PROP ("background_full_height_set", PROP_BACKGROUND_FULL_HEIGHT_SET,
514 515
                P_("Background full height set"),
                P_("Whether this tag affects background height"));
516 517

  ADD_SET_PROP ("background_stipple_set", PROP_BACKGROUND_STIPPLE_SET,
518 519
                P_("Background stipple set"),
                P_("Whether this tag affects the background stipple"));  
520 521

  ADD_SET_PROP ("foreground_set", PROP_FOREGROUND_SET,
522 523
                P_("Foreground set"),
                P_("Whether this tag affects the foreground color"));
524 525

  ADD_SET_PROP ("foreground_stipple_set", PROP_FOREGROUND_STIPPLE_SET,
526 527
                P_("Foreground stipple set"),
                P_("Whether this tag affects the foreground stipple"));
528 529
  
  ADD_SET_PROP ("editable_set", PROP_EDITABLE_SET,
530 531
                P_("Editability set"),
                P_("Whether this tag affects text editability"));
532 533

  ADD_SET_PROP ("family_set", PROP_FAMILY_SET,
534 535
                P_("Font family set"),
                P_("Whether this tag affects the font family"));  
536 537

  ADD_SET_PROP ("style_set", PROP_STYLE_SET,
538 539
                P_("Font style set"),
                P_("Whether this tag affects the font style"));
540 541

  ADD_SET_PROP ("variant_set", PROP_VARIANT_SET,
542 543
                P_("Font variant set"),
                P_("Whether this tag affects the font variant"));
544 545

  ADD_SET_PROP ("weight_set", PROP_WEIGHT_SET,
546 547
                P_("Font weight set"),
                P_("Whether this tag affects the font weight"));
548 549

  ADD_SET_PROP ("stretch_set", PROP_STRETCH_SET,
550 551
                P_("Font stretch set"),
                P_("Whether this tag affects the font stretch"));
552 553

  ADD_SET_PROP ("size_set", PROP_SIZE_SET,
554 555
                P_("Font size set"),
                P_("Whether this tag affects the font size"));
556

Havoc Pennington's avatar
Havoc Pennington committed
557
  ADD_SET_PROP ("scale_set", PROP_SCALE_SET,
558 559
                P_("Font scale set"),
                P_("Whether this tag scales the font size by a factor"));
Havoc Pennington's avatar
Havoc Pennington committed
560
  
561
  ADD_SET_PROP ("justification_set", PROP_JUSTIFICATION_SET,
562 563
                P_("Justification set"),
                P_("Whether this tag affects paragraph justification"));
Havoc Pennington's avatar
Havoc Pennington committed
564
  
565
  ADD_SET_PROP ("language_set", PROP_LANGUAGE_SET,
566 567
                P_("Language set"),
                P_("Whether this tag affects the language the text is rendered as"));
568 569

  ADD_SET_PROP ("left_margin_set", PROP_LEFT_MARGIN_SET,
570 571
                P_("Left margin set"),
                P_("Whether this tag affects the left margin"));
572 573

  ADD_SET_PROP ("indent_set", PROP_INDENT_SET,
574 575
                P_("Indent set"),
                P_("Whether this tag affects indentation"));
576 577

  ADD_SET_PROP ("rise_set", PROP_RISE_SET,
578 579
                P_("Rise set"),
                P_("Whether this tag affects the rise"));
580 581

  ADD_SET_PROP ("pixels_above_lines_set", PROP_PIXELS_ABOVE_LINES_SET,
582 583
                P_("Pixels above lines set"),
                P_("Whether this tag affects the number of pixels above lines"));
584 585

  ADD_SET_PROP ("pixels_below_lines_set", PROP_PIXELS_BELOW_LINES_SET,
586 587
                P_("Pixels below lines set"),
                P_("Whether this tag affects the number of pixels above lines"));
588 589

  ADD_SET_PROP ("pixels_inside_wrap_set", PROP_PIXELS_INSIDE_WRAP_SET,
590 591
                P_("Pixels inside wrap set"),
                P_("Whether this tag affects the number of pixels between wrapped lines"));
592 593

  ADD_SET_PROP ("strikethrough_set", PROP_STRIKETHROUGH_SET,
594 595
                P_("Strikethrough set"),
                P_("Whether this tag affects strikethrough"));
596 597
  
  ADD_SET_PROP ("right_margin_set", PROP_RIGHT_MARGIN_SET,
598 599
                P_("Right margin set"),
                P_("Whether this tag affects the right margin"));
600 601

  ADD_SET_PROP ("underline_set", PROP_UNDERLINE_SET,
602 603
                P_("Underline set"),
                P_("Whether this tag affects underlining"));
604 605

  ADD_SET_PROP ("wrap_mode_set", PROP_WRAP_MODE_SET,
606 607
                P_("Wrap mode set"),
                P_("Whether this tag affects line wrap mode"));
608 609

  ADD_SET_PROP ("tabs_set", PROP_TABS_SET,
610 611
                P_("Tabs set"),
                P_("Whether this tag affects tabs"));
612 613

  ADD_SET_PROP ("invisible_set", PROP_INVISIBLE_SET,
614 615
                P_("Invisible set"),
                P_("Whether this tag affects text visibility"));
616

617
  signals[EVENT] =
618 619 620
    g_signal_new ("event",
                  G_OBJECT_CLASS_TYPE (object_class),
                  G_SIGNAL_RUN_LAST,
Manish Singh's avatar
Manish Singh committed
621
                  G_STRUCT_OFFSET (GtkTextTagClass, event),
622
                  _gtk_boolean_handled_accumulator, NULL,
623
                  _gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXED,
624 625 626
                  G_TYPE_BOOLEAN,
                  3,
                  G_TYPE_OBJECT,
Hans Breuer's avatar
Hans Breuer committed
627
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
628
                  GTK_TYPE_TEXT_ITER);
629 630
}

631
static void
632
gtk_text_tag_init (GtkTextTag *text_tag)
633 634 635
{
  /* 0 is basically a fine way to initialize everything in the
     entire struct */
636 637
  
  text_tag->values = gtk_text_attributes_new ();
638 639
}

640 641 642 643 644 645 646 647 648
/**
 * gtk_text_tag_new:
 * @name: tag name, or %NULL
 * 
 * Creates a #GtkTextTag. Configure the tag using object arguments,
 * i.e. using g_object_set().
 * 
 * Return value: a new #GtkTextTag
 **/
649 650 651 652 653
GtkTextTag*
gtk_text_tag_new (const gchar *name)
{
  GtkTextTag *tag;

Manish Singh's avatar
Manish Singh committed
654
  tag = g_object_new (GTK_TYPE_TEXT_TAG, "name", name, NULL);
655 656 657 658 659

  return tag;
}

static void
660
gtk_text_tag_finalize (GObject *object)
661
{
662
  GtkTextTag *text_tag;
663

664
  text_tag = GTK_TEXT_TAG (object);
665

666
  g_assert (!text_tag->values->realized);
667

668 669
  if (text_tag->table)
    gtk_text_tag_table_remove (text_tag->table, text_tag);
670

671
  g_assert (text_tag->table == NULL);
672

673 674
  gtk_text_attributes_unref (text_tag->values);
  text_tag->values = NULL;
675
  
676 677
  g_free (text_tag->name);
  text_tag->name = NULL;
678

679
  (* G_OBJECT_CLASS (parent_class)->finalize) (object);
680 681 682
}

static void
683
set_bg_color (GtkTextTag *tag, GdkColor *color)
684 685 686
{
  if (color)
    {
Havoc Pennington's avatar
Havoc Pennington committed
687 688 689
      if (!tag->bg_color_set)
        {
          tag->bg_color_set = TRUE;
690
          g_object_notify (G_OBJECT (tag), "background_set");
Havoc Pennington's avatar
Havoc Pennington committed
691 692
        }
      
693 694 695 696
      tag->values->appearance.bg_color = *color;
    }
  else
    {
Havoc Pennington's avatar
Havoc Pennington committed
697 698 699
      if (tag->bg_color_set)
        {
          tag->bg_color_set = FALSE;
700
          g_object_notify (G_OBJECT (tag), "background_set");
Havoc Pennington's avatar
Havoc Pennington committed
701
        }
702 703 704 705
    }
}

static void
706
set_fg_color (GtkTextTag *tag, GdkColor *color)
707 708 709
{
  if (color)
    {
Havoc Pennington's avatar
Havoc Pennington committed
710 711 712
      if (!tag->fg_color_set)
        {
          tag->fg_color_set = TRUE;
713
          g_object_notify (G_OBJECT (tag), "foreground_set");
Havoc Pennington's avatar
Havoc Pennington committed
714
        }
715 716 717 718
      tag->values->appearance.fg_color = *color;
    }
  else
    {
Havoc Pennington's avatar
Havoc Pennington committed
719 720 721
      if (tag->fg_color_set)
        {
          tag->fg_color_set = FALSE;
722
          g_object_notify (G_OBJECT (tag), "foreground_set");
Havoc Pennington's avatar
Havoc Pennington committed
723
        }
724 725 726
    }
}

727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
static PangoFontMask
get_property_font_set_mask (guint prop_id)
{
  switch (prop_id)
    {
    case PROP_FAMILY_SET:
      return PANGO_FONT_MASK_FAMILY;
    case PROP_STYLE_SET:
      return PANGO_FONT_MASK_STYLE;
    case PROP_VARIANT_SET:
      return PANGO_FONT_MASK_VARIANT;
    case PROP_WEIGHT_SET:
      return PANGO_FONT_MASK_WEIGHT;
    case PROP_STRETCH_SET:
      return PANGO_FONT_MASK_STRETCH;
    case PROP_SIZE_SET:
      return PANGO_FONT_MASK_SIZE;
    }

  return 0;
}

749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788
static PangoFontMask
set_font_desc_fields (PangoFontDescription *desc,
		      PangoFontMask         to_set)
{
  PangoFontMask changed_mask = 0;
  
  if (to_set & PANGO_FONT_MASK_FAMILY)
    {
      const char *family = pango_font_description_get_family (desc);
      if (!family)
	{
	  family = "sans";
	  changed_mask |= PANGO_FONT_MASK_FAMILY;
	}

      pango_font_description_set_family (desc, family);
    }
  if (to_set & PANGO_FONT_MASK_STYLE)
    pango_font_description_set_style (desc, pango_font_description_get_style (desc));
  if (to_set & PANGO_FONT_MASK_VARIANT)
    pango_font_description_set_variant (desc, pango_font_description_get_variant (desc));
  if (to_set & PANGO_FONT_MASK_WEIGHT)
    pango_font_description_set_weight (desc, pango_font_description_get_weight (desc));
  if (to_set & PANGO_FONT_MASK_STRETCH)
    pango_font_description_set_stretch (desc, pango_font_description_get_stretch (desc));
  if (to_set & PANGO_FONT_MASK_SIZE)
    {
      gint size = pango_font_description_get_size (desc);
      if (size <= 0)
	{
	  size = 10 * PANGO_SCALE;
	  changed_mask |= PANGO_FONT_MASK_SIZE;
	}
      
      pango_font_description_set_size (desc, size);
    }

  return changed_mask;
}

789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
static void
notify_set_changed (GObject       *object,
		    PangoFontMask  changed_mask)
{
  if (changed_mask & PANGO_FONT_MASK_FAMILY)
    g_object_notify (object, "family_set");
  if (changed_mask & PANGO_FONT_MASK_STYLE)
    g_object_notify (object, "style_set");
  if (changed_mask & PANGO_FONT_MASK_VARIANT)
    g_object_notify (object, "variant_set");
  if (changed_mask & PANGO_FONT_MASK_WEIGHT)
    g_object_notify (object, "weight_set");
  if (changed_mask & PANGO_FONT_MASK_STRETCH)
    g_object_notify (object, "stretch_set");
  if (changed_mask & PANGO_FONT_MASK_SIZE)
    g_object_notify (object, "size_set");
}

807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
static void
notify_fields_changed (GObject       *object,
		       PangoFontMask  changed_mask)
{
  if (changed_mask & PANGO_FONT_MASK_FAMILY)
    g_object_notify (object, "family");
  if (changed_mask & PANGO_FONT_MASK_STYLE)
    g_object_notify (object, "style");
  if (changed_mask & PANGO_FONT_MASK_VARIANT)
    g_object_notify (object, "variant");
  if (changed_mask & PANGO_FONT_MASK_WEIGHT)
    g_object_notify (object, "weight");
  if (changed_mask & PANGO_FONT_MASK_STRETCH)
    g_object_notify (object, "stretch");
  if (changed_mask & PANGO_FONT_MASK_SIZE)
    g_object_notify (object, "size");
}

825 826 827 828
static void
set_font_description (GtkTextTag           *text_tag,
                      PangoFontDescription *font_desc)
{
829 830 831 832 833 834 835 836 837 838 839
  GObject *object = G_OBJECT (text_tag);
  PangoFontDescription *new_font_desc;
  PangoFontMask old_mask, new_mask, changed_mask, set_changed_mask;
  
  if (font_desc)
    new_font_desc = pango_font_description_copy (font_desc);
  else
    new_font_desc = pango_font_description_new ();

  if (text_tag->values->font)
    old_mask = pango_font_description_get_set_fields (text_tag->values->font);
840
  else
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
    old_mask = 0;
  
  new_mask = pango_font_description_get_set_fields (new_font_desc);

  changed_mask = old_mask | new_mask;
  set_changed_mask = old_mask ^ new_mask;

  if (text_tag->values->font)
    pango_font_description_free (text_tag->values->font);
  text_tag->values->font = new_font_desc;
  
  g_object_freeze_notify (object);

  g_object_notify (object, "font_desc");
  g_object_notify (object, "font");
  
  if (changed_mask & PANGO_FONT_MASK_FAMILY)
    g_object_notify (object, "family");
  if (changed_mask & PANGO_FONT_MASK_STYLE)
    g_object_notify (object, "style");
  if (changed_mask & PANGO_FONT_MASK_VARIANT)
    g_object_notify (object, "variant");
  if (changed_mask & PANGO_FONT_MASK_WEIGHT)
    g_object_notify (object, "weight");
  if (changed_mask & PANGO_FONT_MASK_STRETCH)
    g_object_notify (object, "stretch");
  if (changed_mask & PANGO_FONT_MASK_SIZE)
Havoc Pennington's avatar
Havoc Pennington committed
868
    {
869 870
      g_object_notify (object, "size");
      g_object_notify (object, "size_points");
871
    }
872 873 874 875 876 877 878 879 880 881 882

  notify_set_changed (object, set_changed_mask);
  
  g_object_thaw_notify (object);
}

static void
gtk_text_tag_ensure_font (GtkTextTag *text_tag)
{
  if (!text_tag->values->font)
    text_tag->values->font = pango_font_description_new ();
883 884
}

885
static void
886 887 888
gtk_text_tag_set_property (GObject      *object,
                           guint         prop_id,
                           const GValue *value,
Tim Janik's avatar
Tim Janik committed
889
                           GParamSpec   *pspec)
890
{
891
  GtkTextTag *text_tag;
892
  gboolean size_changed = FALSE;
893

894
  text_tag = GTK_TEXT_TAG (object);
895

896
  g_return_if_fail (!text_tag->values->realized);
897

898
  switch (prop_id)
899
    {
900
    case PROP_NAME:
901
      g_return_if_fail (text_tag->name == NULL);
902
      text_tag->name = g_strdup (g_value_get_string (value));
903 904
      break;

905
    case PROP_BACKGROUND:
906 907 908
      {
        GdkColor color;

909
        if (gdk_color_parse (g_value_get_string (value), &color))
910
          set_bg_color (text_tag, &color);
911
        else
912
          g_warning ("Don't know color `%s'", g_value_get_string (value));
Havoc Pennington's avatar
Havoc Pennington committed
913

914
        g_object_notify (object, "background_gdk");
915 916 917
      }
      break;

918
    case PROP_FOREGROUND:
919 920 921
      {
        GdkColor color;

922
        if (gdk_color_parse (g_value_get_string (value), &color))
923
          set_fg_color (text_tag, &color);
924
        else
925
          g_warning ("Don't know color `%s'", g_value_get_string (value));
Havoc Pennington's avatar
Havoc Pennington committed
926

927
        g_object_notify (object, "foreground_gdk");
928 929
      }
      break;
930

931
    case PROP_BACKGROUND_GDK:
932
      {
Tim Janik's avatar
Tim Janik committed
933 934
        GdkColor *color = g_value_get_boxed (value);

935
        set_bg_color (text_tag, color);
936 937 938
      }
      break;

939
    case PROP_FOREGROUND_GDK:
940
      {
Tim Janik's avatar
Tim Janik committed
941 942
        GdkColor *color = g_value_get_boxed (value);

943
        set_fg_color (text_tag, color);
944 945 946
      }
      break;

947
    case PROP_BACKGROUND_STIPPLE:
948
      {
949
        GdkBitmap *bitmap = g_value_get_object (value);
950

951
        text_tag->bg_stipple_set = TRUE;
952
        g_object_notify (object, "background_stipple_set");
Havoc Pennington's avatar
Havoc Pennington committed
953
        
954
        if (text_tag->values->appearance.bg_stipple != bitmap)
955 956
          {
            if (bitmap != NULL)
Manish Singh's avatar
Manish Singh committed
957
              g_object_ref (bitmap);
958

959
            if (text_tag->values->appearance.bg_stipple)
Manish Singh's avatar
Manish Singh committed
960
              g_object_unref (text_tag->values->appearance.bg_stipple);
961

962
            text_tag->values->appearance.bg_stipple = bitmap;
963 964 965 966
          }
      }
      break;

967
    case PROP_FOREGROUND_STIPPLE:
968
      {
969
        GdkBitmap *bitmap = g_value_get_object (value);
970

971
        text_tag->fg_stipple_set = TRUE;
972
        g_object_notify (object, "foreground_stipple_set");
973

974
        if (text_tag->values->appearance.fg_stipple != bitmap)
975 976
          {
            if (bitmap != NULL)
Manish Singh's avatar
Manish Singh committed
977
              g_object_ref (bitmap);
978

979
            if (text_tag->values->appearance.fg_stipple)
Manish Singh's avatar
Manish Singh committed
980
              g_object_unref (text_tag->values->appearance.fg_stipple);
981

982
            text_tag->values->appearance.fg_stipple = bitmap;
983 984 985 986
          }
      }
      break;

987
    case PROP_FONT:
988 989 990 991
      {
        PangoFontDescription *font_desc = NULL;
        const gchar *name;

992
        name = g_value_get_string (value);
993 994

        if (name)
995 996
          font_desc = pango_font_description_from_string (name);

997
        set_font_description (text_tag, font_desc);
998 999
	if (font_desc)
	  pango_font_description_free (font_desc);
1000
        
1001 1002 1003 1004
        size_changed = TRUE;
      }
      break;

1005
    case PROP_FONT_DESC:
1006 1007 1008
      {
        PangoFontDescription *font_desc;

Tim Janik's avatar
Tim Janik committed
1009
        font_desc = g_value_get_boxed (value);
1010

1011
        set_font_description (text_tag, font_desc);
1012 1013 1014 1015 1016

        size_changed = TRUE;
      }
      break;

1017 1018 1019 1020 1021 1022
    case PROP_FAMILY:
    case PROP_STYLE:
    case PROP_VARIANT:
    case PROP_WEIGHT:
    case PROP_STRETCH:
    case PROP_SIZE:
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045
    case PROP_SIZE_POINTS:
      {
	PangoFontMask old_set_mask;

	gtk_text_tag_ensure_font (text_tag);
	old_set_mask = pango_font_description_get_set_fields (text_tag->values->font);
 
	switch (prop_id)
	  {
	  case PROP_FAMILY:
	    pango_font_description_set_family (text_tag->values->font,
					       g_value_get_string (value));
	    break;
	  case PROP_STYLE:
	    pango_font_description_set_style (text_tag->values->font,
					      g_value_get_enum (value));
	    break;
	  case PROP_VARIANT:
	    pango_font_description_set_variant (text_tag->values->font,
						g_value_get_enum (value));
	    break;
	  case PROP_WEIGHT:
	    pango_font_description_set_weight (text_tag->values->font,
1046
					       g_value_get_int (value));
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
	    break;
	  case PROP_STRETCH:
	    pango_font_description_set_stretch (text_tag->values->font,
						g_value_get_enum (value));
	    break;
	  case PROP_SIZE:
	    pango_font_description_set_size (text_tag->values->font,
					     g_value_get_int (value));
	    g_object_notify (object, "size_points");
	    break;
	  case PROP_SIZE_POINTS:
	    pango_font_description_set_size (text_tag->values->font,
					     g_value_get_double (value) * PANGO_SCALE);
	    g_object_notify (object, "size");
	    break;
	  }

	size_changed = TRUE;
	notify_set_changed (object, old_set_mask & pango_font_description_get_set_fields (text_tag->values->font));
	g_object_notify (object, "font_desc");
	g_object_notify (object, "font");
1068 1069

	break;
1070 1071
      }
      
Havoc Pennington's avatar
Havoc Pennington committed
1072 1073 1074
    case PROP_SCALE:
      text_tag->values->font_scale = g_value_get_double (value);
      text_tag->scale_set = TRUE;
1075
      g_object_notify (object, "scale_set");
1076 1077 1078
      size_changed = TRUE;
      break;
      
1079
    case PROP_PIXELS_ABOVE_LINES:
1080
      text_tag->pixels_above_lines_set = TRUE;
1081
      text_tag->values->pixels_above_lines = g_value_get_int (value);
1082
      g_object_notify (object, "pixels_above_lines_set");
1083 1084 1085
      size_changed = TRUE;
      break;

1086
    case PROP_PIXELS_BELOW_LINES:
1087
      text_tag->pixels_below_lines_set = TRUE;
1088
      text_tag->values->pixels_below_lines = g_value_get_int (value);
1089
      g_object_notify (object, "pixels_below_lines_set");
1090 1091 1092
      size_changed = TRUE;
      break;

1093
    case PROP_PIXELS_INSIDE_WRAP:
1094
      text_tag->pixels_inside_wrap_set = TRUE;
1095
      text_tag->values->pixels_inside_wrap = g_value_get_int (value);
1096
      g_object_notify (object, "pixels_inside_wrap_set");
1097 1098 1099
      size_changed = TRUE;
      break;

1100
    case PROP_EDITABLE:
1101
      text_tag->editable_set = TRUE;
1102
      text_tag->values->editable = g_value_get_boolean (value);
1103
      g_object_notify (object, "editable_set");
1104 1105
      break;

1106
    case PROP_WRAP_MODE:
1107
      text_tag->wrap_mode_set = TRUE;
1108
      text_tag->values->wrap_mode = g_value_get_enum (value);
1109
      g_object_notify (object, "wrap_mode_set");
1110 1111 1112
      size_changed = TRUE;
      break;

1113 1114 1115
    case PROP_JUSTIFICATION:
      text_tag->justification_set = TRUE;
      text_tag->values->justification = g_value_get_enum (value);
1116
      g_object_notify (object, "justification_set");
1117 1118 1119
      size_changed = TRUE;
      break;

1120 1121
    case PROP_DIRECTION:
      text_tag->values->direction = g_value_get_enum (value);
1122 1123
      break;

1124
    case PROP_LEFT_MARGIN:
1125
      text_tag->left_margin_set = TRUE;
1126
      text_tag->values->left_margin = g_value_get_int (value);
1127
      g_object_notify (object, "left_margin_set");
1128 1129 1130
      size_changed = TRUE;
      break;

1131
    case PROP_INDENT:
1132
      text_tag->indent_set = TRUE;
1133
      text_tag->values->indent = g_value_get_int (value);
1134
      g_object_notify (object, "indent_set");
1135 1136 1137
      size_changed = TRUE;
      break;

1138
    case PROP_STRIKETHROUGH:
1139
      text_tag->strikethrough_set = TRUE;
1140
      text_tag->values->appearance.strikethrough = g_value_get_boolean (value);
1141
      g_object_notify (object, "strikethrough_set");
1142
      break;
1143

1144
    case PROP_RIGHT_MARGIN:
1145
      text_tag->right_margin_set = TRUE;
1146
      text_tag->values->right_margin = g_value_get_int (value);
1147
      g_object_notify (object, "right_margin_set");
1148 1149
      size_changed = TRUE;
      break;
1150

1151
    case PROP_UNDERLINE:
1152
      text_tag->underline_set = TRUE;
1153
      text_tag->values->appearance.underline = g_value_get_enum (value);
1154
      g_object_notify (object, "underline_set");
1155
      break;
1156

1157
    case PROP_RISE:
1158
      text_tag->rise_set = TRUE;
1159
      text_tag->values->appearance.rise = g_value_get_int (value);
1160
      g_object_notify (object, "rise_set");
Havoc Pennington's avatar
Havoc Pennington committed
1161
      size_changed = TRUE;      
1162 1163
      break;