gtktexttag.c 74.9 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 "gtkmain.h"
52 53 54
#include "gtktexttag.h"
#include "gtktexttypes.h"
#include "gtktexttagtable.h"
55
#include "gtkintl.h"
56
#include "gtkmarshalers.h"
57
#include "gtkprivate.h"
58
#include "gtkalias.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
  PROP_PARAGRAPH_BACKGROUND,
  PROP_PARAGRAPH_BACKGROUND_GDK,
109 110 111

  /* Behavior args */
  PROP_ACCUMULATIVE_MARGIN,
112
  
113
  /* Whether-a-style-arg-is-set args */
114 115 116 117 118 119 120 121 122 123
  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
124
  PROP_SCALE_SET,
125 126 127 128 129
  PROP_PIXELS_ABOVE_LINES_SET,
  PROP_PIXELS_BELOW_LINES_SET,
  PROP_PIXELS_INSIDE_WRAP_SET,
  PROP_EDITABLE_SET,
  PROP_WRAP_MODE_SET,
130
  PROP_JUSTIFICATION_SET,
131 132 133 134 135 136
  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
137
  PROP_BACKGROUND_FULL_HEIGHT_SET,
138 139 140
  PROP_LANGUAGE_SET,
  PROP_TABS_SET,
  PROP_INVISIBLE_SET,
141
  PROP_PARAGRAPH_BACKGROUND_SET,
142

143 144
  LAST_ARG
};
145 146 147 148
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
149
                                       GParamSpec      *pspec);
150 151 152
static void gtk_text_tag_get_property (GObject         *object,
                                       guint            prop_id,
                                       GValue          *value,
Tim Janik's avatar
Tim Janik committed
153
                                       GParamSpec      *pspec);
154

155 156
static guint signals[LAST_SIGNAL] = { 0 };

Matthias Clasen's avatar
Matthias Clasen committed
157
G_DEFINE_TYPE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT)
158 159 160 161

static void
gtk_text_tag_class_init (GtkTextTagClass *klass)
{
162
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
163

164 165 166 167
  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;
168

169
  /* Construct */
170 171 172
  g_object_class_install_property (object_class,
                                   PROP_NAME,
                                   g_param_spec_string ("name",
173 174
                                                        P_("Tag name"),
                                                        P_("Name used to refer to the text tag. NULL for anonymous tags"),
175
                                                        NULL,
176
                                                        GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
177 178

  /* Style args */
179 180 181 182

  g_object_class_install_property (object_class,
                                   PROP_BACKGROUND,
                                   g_param_spec_string ("background",
183 184
                                                        P_("Background color name"),
                                                        P_("Background color as a string"),
185
                                                        NULL,
186
                                                        GTK_PARAM_WRITABLE));
187 188 189

  g_object_class_install_property (object_class,
                                   PROP_BACKGROUND_GDK,
Matthias Clasen's avatar
x  
Matthias Clasen committed
190
                                   g_param_spec_boxed ("background-gdk",
191 192
                                                       P_("Background color"),
                                                       P_("Background color as a (possibly unallocated) GdkColor"),
193
                                                       GDK_TYPE_COLOR,
194
                                                       GTK_PARAM_READWRITE));
195 196

  g_object_class_install_property (object_class,
Soeren Sandmann's avatar
Soeren Sandmann committed
197
                                   PROP_BACKGROUND_FULL_HEIGHT,
Matthias Clasen's avatar
x  
Matthias Clasen committed
198
                                   g_param_spec_boolean ("background-full-height",
199 200
                                                         P_("Background full height"),
                                                         P_("Whether the background color fills the entire line height or only the height of the tagged characters"),
201
                                                         FALSE,
202
                                                         GTK_PARAM_READWRITE));
203

204
  
205 206
  g_object_class_install_property (object_class,
                                   PROP_BACKGROUND_STIPPLE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
207
                                   g_param_spec_object ("background-stipple",
208 209
                                                        P_("Background stipple mask"),
                                                        P_("Bitmap to use as a mask when drawing the text background"),
210
                                                        GDK_TYPE_PIXMAP,
211
                                                        GTK_PARAM_READWRITE));  
212 213 214 215 216


  g_object_class_install_property (object_class,
                                   PROP_FOREGROUND,
                                   g_param_spec_string ("foreground",
217 218
                                                        P_("Foreground color name"),
                                                        P_("Foreground color as a string"),
219
                                                        NULL,
220
                                                        GTK_PARAM_WRITABLE));
221 222 223

  g_object_class_install_property (object_class,
                                   PROP_FOREGROUND_GDK,
Matthias Clasen's avatar
x  
Matthias Clasen committed
224
                                   g_param_spec_boxed ("foreground-gdk",
225 226
                                                       P_("Foreground color"),
                                                       P_("Foreground color as a (possibly unallocated) GdkColor"),
227
                                                       GDK_TYPE_COLOR,
228
                                                       GTK_PARAM_READWRITE));
229

230
  
231 232
  g_object_class_install_property (object_class,
                                   PROP_FOREGROUND_STIPPLE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
233
                                   g_param_spec_object ("foreground-stipple",
234 235
                                                        P_("Foreground stipple mask"),
                                                        P_("Bitmap to use as a mask when drawing the text foreground"),
236
                                                        GDK_TYPE_PIXMAP,
237
                                                        GTK_PARAM_READWRITE));  
238 239 240 241
  
  g_object_class_install_property (object_class,
                                   PROP_DIRECTION,
                                   g_param_spec_enum ("direction",
242 243
                                                      P_("Text direction"),
                                                      P_("Text direction, e.g. right-to-left or left-to-right"),
244
                                                      GTK_TYPE_TEXT_DIRECTION,
245
                                                      GTK_TEXT_DIR_NONE,
246
                                                      GTK_PARAM_READWRITE));
247 248 249 250

  g_object_class_install_property (object_class,
                                   PROP_EDITABLE,
                                   g_param_spec_boolean ("editable",
251 252
                                                         P_("Editable"),
                                                         P_("Whether the text can be modified by the user"),
253
                                                         TRUE,
254
                                                         GTK_PARAM_READWRITE));
255

256 257 258 259 260 261 262 263
  /**
   * GtkTextTag:font:
   *
   * Font description as string, e.g. \"Sans Italic 12\". 
   *
   * Note that the initial value of this property depends on
   * the internals of #PangoFontDescription.
   */
264 265 266
  g_object_class_install_property (object_class,
                                   PROP_FONT,
                                   g_param_spec_string ("font",
267 268
                                                        P_("Font"),
                                                        P_("Font description as a string, e.g. \"Sans Italic 12\""),
269
                                                        NULL,
270
                                                        GTK_PARAM_READWRITE));
271 272 273

  g_object_class_install_property (object_class,
                                   PROP_FONT_DESC,
Matthias Clasen's avatar
x  
Matthias Clasen committed
274
                                   g_param_spec_boxed ("font-desc",
275 276
                                                       P_("Font"),
                                                       P_("Font description as a PangoFontDescription struct"),
277
                                                       PANGO_TYPE_FONT_DESCRIPTION,
278
                                                       GTK_PARAM_READWRITE));
279 280 281 282
  
  g_object_class_install_property (object_class,
                                   PROP_FAMILY,
                                   g_param_spec_string ("family",
283 284
                                                        P_("Font family"),
                                                        P_("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
285
                                                        NULL,
286
                                                        GTK_PARAM_READWRITE));
287 288 289 290

  g_object_class_install_property (object_class,
                                   PROP_STYLE,
                                   g_param_spec_enum ("style",
291 292
                                                      P_("Font style"),
                                                      P_("Font style as a PangoStyle, e.g. PANGO_STYLE_ITALIC"),
293 294
                                                      PANGO_TYPE_STYLE,
                                                      PANGO_STYLE_NORMAL,
295
                                                      GTK_PARAM_READWRITE));
296 297 298 299

  g_object_class_install_property (object_class,
                                   PROP_VARIANT,
                                   g_param_spec_enum ("variant",
300 301
                                                     P_("Font variant"),
                                                     P_("Font variant as a PangoVariant, e.g. PANGO_VARIANT_SMALL_CAPS"),
302 303
                                                      PANGO_TYPE_VARIANT,
                                                      PANGO_VARIANT_NORMAL,
304
                                                      GTK_PARAM_READWRITE));
305 306 307 308
  
  g_object_class_install_property (object_class,
                                   PROP_WEIGHT,
                                   g_param_spec_int ("weight",
309 310
                                                     P_("Font weight"),
                                                     P_("Font weight as an integer, see predefined values in PangoWeight; for example, PANGO_WEIGHT_BOLD"),
311 312 313
                                                     0,
                                                     G_MAXINT,
                                                     PANGO_WEIGHT_NORMAL,
314
                                                     GTK_PARAM_READWRITE));
315 316 317 318 319
  

  g_object_class_install_property (object_class,
                                   PROP_STRETCH,
                                   g_param_spec_enum ("stretch",
320 321
                                                      P_("Font stretch"),
                                                      P_("Font stretch as a PangoStretch, e.g. PANGO_STRETCH_CONDENSED"),
322 323
                                                      PANGO_TYPE_STRETCH,
                                                      PANGO_STRETCH_NORMAL,
324
                                                      GTK_PARAM_READWRITE));
325 326 327 328
  
  g_object_class_install_property (object_class,
                                   PROP_SIZE,
                                   g_param_spec_int ("size",
329 330
                                                     P_("Font size"),
                                                     P_("Font size in Pango units"),
331 332 333
                                                     0,
                                                     G_MAXINT,
                                                     0,
334
                                                     GTK_PARAM_READWRITE));
335

Havoc Pennington's avatar
Havoc Pennington committed
336 337 338
  g_object_class_install_property (object_class,
                                   PROP_SCALE,
                                   g_param_spec_double ("scale",
339 340
                                                        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
341 342 343
                                                        0.0,
                                                        G_MAXDOUBLE,
                                                        1.0,
344
                                                        GTK_PARAM_READWRITE));
Havoc Pennington's avatar
Havoc Pennington committed
345
  
346 347
  g_object_class_install_property (object_class,
                                   PROP_SIZE_POINTS,
Matthias Clasen's avatar
x  
Matthias Clasen committed
348
                                   g_param_spec_double ("size-points",
349 350
                                                        P_("Font points"),
                                                        P_("Font size in points"),
351 352 353
                                                        0.0,
                                                        G_MAXDOUBLE,
                                                        0.0,
354
                                                        GTK_PARAM_READWRITE));  
355 356

  g_object_class_install_property (object_class,
357 358
                                   PROP_JUSTIFICATION,
                                   g_param_spec_enum ("justification",
359 360
                                                      P_("Justification"),
                                                      P_("Left, right, or center justification"),
361 362
                                                      GTK_TYPE_JUSTIFICATION,
                                                      GTK_JUSTIFY_LEFT,
363
                                                      GTK_PARAM_READWRITE));
364 365 366 367 368 369 370 371 372 373 374

  /**
   * GtkTextTag:language:
   *
   * 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.
   *
   * Note that the initial value of this property depends on the current
   * locale, see also gtk_get_default_language().
   */
375 376 377
  g_object_class_install_property (object_class,
                                   PROP_LANGUAGE,
                                   g_param_spec_string ("language",
378
                                                        P_("Language"),
379
                                                        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."),
380
                                                        NULL,
381
                                                        GTK_PARAM_READWRITE));  
382 383 384

  g_object_class_install_property (object_class,
                                   PROP_LEFT_MARGIN,
Matthias Clasen's avatar
x  
Matthias Clasen committed
385
                                   g_param_spec_int ("left-margin",
386 387
                                                     P_("Left margin"),
                                                     P_("Width of the left margin in pixels"),
388 389 390
                                                     0,
                                                     G_MAXINT,
                                                     0,
391
                                                     GTK_PARAM_READWRITE));
392 393 394

  g_object_class_install_property (object_class,
                                   PROP_RIGHT_MARGIN,
Matthias Clasen's avatar
x  
Matthias Clasen committed
395
                                   g_param_spec_int ("right-margin",
396 397
                                                     P_("Right margin"),
                                                     P_("Width of the right margin in pixels"),
398 399 400
                                                     0,
                                                     G_MAXINT,
                                                     0,
401
                                                     GTK_PARAM_READWRITE));
402 403 404 405 406

  
  g_object_class_install_property (object_class,
                                   PROP_INDENT,
                                   g_param_spec_int ("indent",
407 408
                                                     P_("Indent"),
                                                     P_("Amount to indent the paragraph, in pixels"),
409
                                                     G_MININT,
410 411
                                                     G_MAXINT,
                                                     0,
412
                                                     GTK_PARAM_READWRITE));
413 414 415 416 417

  
  g_object_class_install_property (object_class,
                                   PROP_RISE,
                                   g_param_spec_int ("rise",
418
                                                     P_("Rise"),
419
                                                     P_("Offset of text above the baseline (below the baseline if rise is negative) in Pango units"),
420
						     G_MININT,
421 422
                                                     G_MAXINT,
                                                     0,
423
                                                     GTK_PARAM_READWRITE));
424 425 426

  g_object_class_install_property (object_class,
                                   PROP_PIXELS_ABOVE_LINES,
Matthias Clasen's avatar
x  
Matthias Clasen committed
427
                                   g_param_spec_int ("pixels-above-lines",
428 429
                                                     P_("Pixels above lines"),
                                                     P_("Pixels of blank space above paragraphs"),
430 431 432
                                                     0,
                                                     G_MAXINT,
                                                     0,
433
                                                     GTK_PARAM_READWRITE));
434 435 436
  
  g_object_class_install_property (object_class,
                                   PROP_PIXELS_BELOW_LINES,
Matthias Clasen's avatar
x  
Matthias Clasen committed
437
                                   g_param_spec_int ("pixels-below-lines",
438 439
                                                     P_("Pixels below lines"),
                                                     P_("Pixels of blank space below paragraphs"),
440 441 442
                                                     0,
                                                     G_MAXINT,
                                                     0,
443
                                                     GTK_PARAM_READWRITE));
444 445 446

  g_object_class_install_property (object_class,
                                   PROP_PIXELS_INSIDE_WRAP,
Matthias Clasen's avatar
x  
Matthias Clasen committed
447
                                   g_param_spec_int ("pixels-inside-wrap",
448 449
                                                     P_("Pixels inside wrap"),
                                                     P_("Pixels of blank space between wrapped lines in a paragraph"),
450 451 452
                                                     0,
                                                     G_MAXINT,
                                                     0,
453
                                                     GTK_PARAM_READWRITE));
454 455 456 457

  g_object_class_install_property (object_class,
                                   PROP_STRIKETHROUGH,
                                   g_param_spec_boolean ("strikethrough",
458 459
                                                         P_("Strikethrough"),
                                                         P_("Whether to strike through the text"),
460
                                                         FALSE,
461
                                                         GTK_PARAM_READWRITE));
462 463 464 465
  
  g_object_class_install_property (object_class,
                                   PROP_UNDERLINE,
                                   g_param_spec_enum ("underline",
466 467
                                                      P_("Underline"),
                                                      P_("Style of underline for this text"),
468 469
                                                      PANGO_TYPE_UNDERLINE,
                                                      PANGO_UNDERLINE_NONE,
470
                                                      GTK_PARAM_READWRITE));
471 472 473
  
  g_object_class_install_property (object_class,
                                   PROP_WRAP_MODE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
474
                                   g_param_spec_enum ("wrap-mode",
475 476
                                                     P_("Wrap mode"),
                                                     P_("Whether to wrap lines never, at word boundaries, or at character boundaries"),
477
                                                      GTK_TYPE_WRAP_MODE,
478
                                                      GTK_WRAP_NONE,
479
                                                      GTK_PARAM_READWRITE));
480 481 482 483 484
  

  g_object_class_install_property (object_class,
                                   PROP_TABS,
                                   g_param_spec_boxed ("tabs",
485 486
                                                       P_("Tabs"),
                                                       P_("Custom tabs for this text"),
487
                                                       PANGO_TYPE_TAB_ARRAY,
488
                                                       GTK_PARAM_READWRITE));
489
  
490 491 492 493 494 495 496 497 498 499 500
  /**
   * GtkTextTag:invisible:
   *
   * Whether this text is hidden.
   *
   * Note that there may still be problems with the support for invisible 
   * text, in particular when navigating programmatically inside a buffer
   * containing invisible segments. 
   *
   * Since: 2.8
   */
501 502 503
  g_object_class_install_property (object_class,
                                   PROP_INVISIBLE,
                                   g_param_spec_boolean ("invisible",
504
                                                         P_("Invisible"),
505
                                                         P_("Whether this text is hidden."),
506
                                                         FALSE,
507
                                                         GTK_PARAM_READWRITE));
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
  /**
   * GtkTextTag:paragraph-background:
   *
   * The paragraph background color as a string.
   *
   * Since: 2.8
   */
  g_object_class_install_property (object_class,
                                   PROP_PARAGRAPH_BACKGROUND,
                                   g_param_spec_string ("paragraph-background",
                                                        P_("Paragraph background color name"),
                                                        P_("Paragraph background color as a string"),
                                                        NULL,
                                                        GTK_PARAM_WRITABLE));

  /**
   * GtkTextTag:paragraph-background-gdk:
   *
   * The paragraph background color as a as a (possibly unallocated) 
   * #GdkColor.
   *
   * Since: 2.8
   */
  g_object_class_install_property (object_class,
                                   PROP_PARAGRAPH_BACKGROUND_GDK,
                                   g_param_spec_boxed ("paragraph-background-gdk",
                                                       P_("Paragraph background color"),
                                                       P_("Paragraph background color as a (possibly unallocated) GdkColor"),
                                                       GDK_TYPE_COLOR,
                                                       GTK_PARAM_READWRITE));

540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
  /**
   * GtkTextTag:accumulative-margin:
   *
   * Whether the margins accumulate or override each other.
   *
   * When set to %TRUE the margins of this tag are added to the margins 
   * of any other non-accumulative margins present. When set to %FALSE 
   * the margins override one another (the default).
   *
   * Since: 2.12
   */
  g_object_class_install_property (object_class,
                                   PROP_ACCUMULATIVE_MARGIN,
                                   g_param_spec_boolean ("accumulative-margin",
                                                         P_("Margin Accumulates"),
                                                         P_("Whether left and right margins accumulate."),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE));

559 560
  /* Style props are set or not */

561
#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
562

Matthias Clasen's avatar
x  
Matthias Clasen committed
563
  ADD_SET_PROP ("background-set", PROP_BACKGROUND_SET,
564 565
                P_("Background set"),
                P_("Whether this tag affects the background color"));
566
  
Matthias Clasen's avatar
x  
Matthias Clasen committed
567
  ADD_SET_PROP ("background-full-height-set", PROP_BACKGROUND_FULL_HEIGHT_SET,
568 569
                P_("Background full height set"),
                P_("Whether this tag affects background height"));
570

Matthias Clasen's avatar
x  
Matthias Clasen committed
571
  ADD_SET_PROP ("background-stipple-set", PROP_BACKGROUND_STIPPLE_SET,
572 573
                P_("Background stipple set"),
                P_("Whether this tag affects the background stipple"));  
574

Matthias Clasen's avatar
x  
Matthias Clasen committed
575
  ADD_SET_PROP ("foreground-set", PROP_FOREGROUND_SET,
576 577
                P_("Foreground set"),
                P_("Whether this tag affects the foreground color"));
578

Matthias Clasen's avatar
x  
Matthias Clasen committed
579
  ADD_SET_PROP ("foreground-stipple-set", PROP_FOREGROUND_STIPPLE_SET,
580 581
                P_("Foreground stipple set"),
                P_("Whether this tag affects the foreground stipple"));
582
  
Matthias Clasen's avatar
x  
Matthias Clasen committed
583
  ADD_SET_PROP ("editable-set", PROP_EDITABLE_SET,
584 585
                P_("Editability set"),
                P_("Whether this tag affects text editability"));
586

Matthias Clasen's avatar
x  
Matthias Clasen committed
587
  ADD_SET_PROP ("family-set", PROP_FAMILY_SET,
588 589
                P_("Font family set"),
                P_("Whether this tag affects the font family"));  
590

Matthias Clasen's avatar
x  
Matthias Clasen committed
591
  ADD_SET_PROP ("style-set", PROP_STYLE_SET,
592 593
                P_("Font style set"),
                P_("Whether this tag affects the font style"));
594

Matthias Clasen's avatar
x  
Matthias Clasen committed
595
  ADD_SET_PROP ("variant-set", PROP_VARIANT_SET,
596 597
                P_("Font variant set"),
                P_("Whether this tag affects the font variant"));
598

Matthias Clasen's avatar
x  
Matthias Clasen committed
599
  ADD_SET_PROP ("weight-set", PROP_WEIGHT_SET,
600 601
                P_("Font weight set"),
                P_("Whether this tag affects the font weight"));
602

Matthias Clasen's avatar
x  
Matthias Clasen committed
603
  ADD_SET_PROP ("stretch-set", PROP_STRETCH_SET,
604 605
                P_("Font stretch set"),
                P_("Whether this tag affects the font stretch"));
606

Matthias Clasen's avatar
x  
Matthias Clasen committed
607
  ADD_SET_PROP ("size-set", PROP_SIZE_SET,
608 609
                P_("Font size set"),
                P_("Whether this tag affects the font size"));
610

Matthias Clasen's avatar
x  
Matthias Clasen committed
611
  ADD_SET_PROP ("scale-set", PROP_SCALE_SET,
612 613
                P_("Font scale set"),
                P_("Whether this tag scales the font size by a factor"));
Havoc Pennington's avatar
Havoc Pennington committed
614
  
Matthias Clasen's avatar
x  
Matthias Clasen committed
615
  ADD_SET_PROP ("justification-set", PROP_JUSTIFICATION_SET,
616 617
                P_("Justification set"),
                P_("Whether this tag affects paragraph justification"));
Havoc Pennington's avatar
Havoc Pennington committed
618
  
Matthias Clasen's avatar
x  
Matthias Clasen committed
619
  ADD_SET_PROP ("language-set", PROP_LANGUAGE_SET,
620 621
                P_("Language set"),
                P_("Whether this tag affects the language the text is rendered as"));
622

Matthias Clasen's avatar
x  
Matthias Clasen committed
623
  ADD_SET_PROP ("left-margin-set", PROP_LEFT_MARGIN_SET,
624 625
                P_("Left margin set"),
                P_("Whether this tag affects the left margin"));
626

Matthias Clasen's avatar
x  
Matthias Clasen committed
627
  ADD_SET_PROP ("indent-set", PROP_INDENT_SET,
628 629
                P_("Indent set"),
                P_("Whether this tag affects indentation"));
630

Matthias Clasen's avatar
x  
Matthias Clasen committed
631
  ADD_SET_PROP ("rise-set", PROP_RISE_SET,
632 633
                P_("Rise set"),
                P_("Whether this tag affects the rise"));
634

Matthias Clasen's avatar
x  
Matthias Clasen committed
635
  ADD_SET_PROP ("pixels-above-lines-set", PROP_PIXELS_ABOVE_LINES_SET,
636 637
                P_("Pixels above lines set"),
                P_("Whether this tag affects the number of pixels above lines"));
638

Matthias Clasen's avatar
x  
Matthias Clasen committed
639
  ADD_SET_PROP ("pixels-below-lines-set", PROP_PIXELS_BELOW_LINES_SET,
640 641
                P_("Pixels below lines set"),
                P_("Whether this tag affects the number of pixels above lines"));
642

Matthias Clasen's avatar
x  
Matthias Clasen committed
643
  ADD_SET_PROP ("pixels-inside-wrap-set", PROP_PIXELS_INSIDE_WRAP_SET,
644 645
                P_("Pixels inside wrap set"),
                P_("Whether this tag affects the number of pixels between wrapped lines"));
646

Matthias Clasen's avatar
x  
Matthias Clasen committed
647
  ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET,
648 649
                P_("Strikethrough set"),
                P_("Whether this tag affects strikethrough"));
650
  
Matthias Clasen's avatar
x  
Matthias Clasen committed
651
  ADD_SET_PROP ("right-margin-set", PROP_RIGHT_MARGIN_SET,
652 653
                P_("Right margin set"),
                P_("Whether this tag affects the right margin"));
654

Matthias Clasen's avatar
x  
Matthias Clasen committed
655
  ADD_SET_PROP ("underline-set", PROP_UNDERLINE_SET,
656 657
                P_("Underline set"),
                P_("Whether this tag affects underlining"));
658

Matthias Clasen's avatar
x  
Matthias Clasen committed
659
  ADD_SET_PROP ("wrap-mode-set", PROP_WRAP_MODE_SET,
660 661
                P_("Wrap mode set"),
                P_("Whether this tag affects line wrap mode"));
662

Matthias Clasen's avatar
x  
Matthias Clasen committed
663
  ADD_SET_PROP ("tabs-set", PROP_TABS_SET,
664 665
                P_("Tabs set"),
                P_("Whether this tag affects tabs"));
666

Matthias Clasen's avatar
x  
Matthias Clasen committed
667
  ADD_SET_PROP ("invisible-set", PROP_INVISIBLE_SET,
668 669
                P_("Invisible set"),
                P_("Whether this tag affects text visibility"));
670

671 672 673
  ADD_SET_PROP ("paragraph-background-set", PROP_PARAGRAPH_BACKGROUND_SET,
                P_("Paragraph background set"),
                P_("Whether this tag affects the paragraph background color"));
674 675 676 677 678 679 680 681 682 683 684 685 686 687

  /**
   * GtkTextTag::event:
   * @tag: the #GtkTextTag on which the signal is emitted
   * @object: the object the event was fired from (typically a #GtkTextView)
   * @event: the event which triggered the signal
   * @iter: a #GtkTextIter pointing at the location the event occured
   *
   * The ::event signal is emitted when an event occurs on a region of the
   * buffer marked with this tag.
   *
   * Returns: %TRUE to stop other handlers from being invoked for the
   * event. %FALSE to propagate the event further.
   */
688
  signals[EVENT] =
689
    g_signal_new (I_("event"),
690 691
                  G_OBJECT_CLASS_TYPE (object_class),
                  G_SIGNAL_RUN_LAST,
Manish Singh's avatar
Manish Singh committed
692
                  G_STRUCT_OFFSET (GtkTextTagClass, event),
693
                  _gtk_boolean_handled_accumulator, NULL,
694
                  _gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXED,
695 696 697
                  G_TYPE_BOOLEAN,
                  3,
                  G_TYPE_OBJECT,
698
                  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
699
                  GTK_TYPE_TEXT_ITER);
700 701
}

702
static void
703
gtk_text_tag_init (GtkTextTag *text_tag)
704
{
705
  text_tag->values = gtk_text_attributes_new ();
706 707
}

708 709 710 711 712 713 714 715 716
/**
 * 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
 **/
717 718 719 720 721
GtkTextTag*
gtk_text_tag_new (const gchar *name)
{
  GtkTextTag *tag;

Manish Singh's avatar
Manish Singh committed
722
  tag = g_object_new (GTK_TYPE_TEXT_TAG, "name", name, NULL);
723 724 725 726 727

  return tag;
}

static void
728
gtk_text_tag_finalize (GObject *object)
729
{
730
  GtkTextTag *text_tag;
731

732
  text_tag = GTK_TEXT_TAG (object);
733

734
  g_assert (!text_tag->values->realized);
735

736 737
  if (text_tag->table)
    gtk_text_tag_table_remove (text_tag->table, text_tag);
738

739
  g_assert (text_tag->table == NULL);
740

741 742
  gtk_text_attributes_unref (text_tag->values);
  text_tag->values = NULL;
743
  
744 745
  g_free (text_tag->name);
  text_tag->name = NULL;
746

Matthias Clasen's avatar
Matthias Clasen committed
747
  (* G_OBJECT_CLASS (gtk_text_tag_parent_class)->finalize) (object);
748 749 750
}

static void
751
set_bg_color (GtkTextTag *tag, GdkColor *color)
752 753 754
{
  if (color)
    {
Havoc Pennington's avatar
Havoc Pennington committed
755 756 757
      if (!tag->bg_color_set)
        {
          tag->bg_color_set = TRUE;
758
          g_object_notify (G_OBJECT (tag), "background-set");
Havoc Pennington's avatar
Havoc Pennington committed
759 760
        }
      
761 762 763 764
      tag->values->appearance.bg_color = *color;
    }
  else
    {
Havoc Pennington's avatar
Havoc Pennington committed
765 766 767
      if (tag->bg_color_set)
        {
          tag->bg_color_set = FALSE;
768
          g_object_notify (G_OBJECT (tag), "background-set");
Havoc Pennington's avatar
Havoc Pennington committed
769
        }
770 771 772 773
    }
}

static void
774
set_fg_color (GtkTextTag *tag, GdkColor *color)
775 776 777
{
  if (color)
    {
Havoc Pennington's avatar
Havoc Pennington committed
778 779 780
      if (!tag->fg_color_set)
        {
          tag->fg_color_set = TRUE;
781
          g_object_notify (G_OBJECT (tag), "foreground-set");
Havoc Pennington's avatar
Havoc Pennington committed
782
        }
783 784 785 786
      tag->values->appearance.fg_color = *color;
    }
  else
    {
Havoc Pennington's avatar
Havoc Pennington committed
787 788 789
      if (tag->fg_color_set)
        {
          tag->fg_color_set = FALSE;
790
          g_object_notify (G_OBJECT (tag), "foreground-set");
Havoc Pennington's avatar
Havoc Pennington committed
791
        }
792 793 794
    }
}

795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
static void
set_pg_bg_color (GtkTextTag *tag, GdkColor *color)
{
  if (color)
    {
      if (!tag->pg_bg_color_set)
        {
          tag->pg_bg_color_set = TRUE;
          g_object_notify (G_OBJECT (tag), "paragraph-background-set");
        }
      else
	gdk_color_free (tag->values->pg_bg_color);

      tag->values->pg_bg_color = gdk_color_copy (color);
    }
  else
    {
      if (tag->pg_bg_color_set)
        {
          tag->pg_bg_color_set = FALSE;
          g_object_notify (G_OBJECT (tag), "paragraph-background-set");
	  gdk_color_free (tag->values->pg_bg_color);
        }

      tag->values->pg_bg_color = NULL;
    }
}

823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
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;
}

845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884
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;
}

885 886 887 888 889
static void
notify_set_changed (GObject       *object,
		    PangoFontMask  changed_mask)
{
  if (changed_mask & PANGO_FONT_MASK_FAMILY)
890
    g_object_notify (object, "family-set");
891
  if (changed_mask & PANGO_FONT_MASK_STYLE)
892
    g_object_notify (object, "style-set");
893
  if (changed_mask & PANGO_FONT_MASK_VARIANT)
894
    g_object_notify (object, "variant-set");
895
  if (changed_mask & PANGO_FONT_MASK_WEIGHT)
896
    g_object_notify (object, "weight-set");
897
  if (changed_mask & PANGO_FONT_MASK_STRETCH)
898
    g_object_notify (object, "stretch-set");
899
  if (changed_mask & PANGO_FONT_MASK_SIZE)
900
    g_object_notify (object, "size-set");
901 902
}

903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920
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");
}

921 922 923 924
static void
set_font_description (GtkTextTag           *text_tag,
                      PangoFontDescription *font_desc)
{
925 926 927 928 929 930 931 932 933 934 935
  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);
936
  else
937 938 939 940 941 942 943 944 945 946 947 948 949
    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);

950
  g_object_notify (object, "font-desc");
951 952 953 954 955 956 957 958 959 960 961 962 963
  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
964
    {
965
      g_object_notify (object, "size");
966
      g_object_notify (object, "size-points");
967
    }
968 969 970 971 972 973 974 975 976 977 978

  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 ();
979 980
}

981
static void
982 983 984
gtk_text_tag_set_property (GObject      *object,
                           guint         prop_id,
                           const GValue *value,
Tim Janik's avatar
Tim Janik committed
985
                           GParamSpec   *pspec)
986
{
987
  GtkTextTag *text_tag;
988
  gboolean size_changed = FALSE;
989

990
  text_tag = GTK_TEXT_TAG (object);
991

992
  g_return_if_fail (!text_tag->values->realized);
993

994
  switch (prop_id)
995
    {
996
    case PROP_NAME:
997
      g_return_if_fail (text_tag->name == NULL);
998
      text_tag->name = g_strdup (g_value_get_string (value));
999 1000
      break;

1001
    case PROP_BACKGROUND:
1002 1003 1004
      {
        GdkColor color;

1005
        if (gdk_color_parse (g_value_get_string (value), &color))
1006
          set_bg_color (text_tag, &color);
1007
        else
1008
          g_warning ("Don't know color `%s'", g_value_get_string (value));
1009

1010
        g_object_notify (object, "background-gdk");
1011 1012 1013
      }
      break;

1014
    case PROP_FOREGROUND:
1015 1016 1017
      {
        GdkColor color;

1018
        if (gdk_color_parse (g_value_get_string (value), &color))
1019
          set_fg_color (text_tag, &color);
1020
        else
1021
          g_warning ("Don't know color `%s'", g_value_get_string (value));
1022

1023
        g_object_notify (object, "foreground-gdk");
1024 1025
      }
      break;
1026

1027
    case PROP_BACKGROUND_GDK:
1028
      {
Tim Janik's avatar
Tim Janik committed
1029 1030
        GdkColor *color = g_value_get_boxed (value);

1031
        set_bg_color (text_tag, color);
1032 1033 1034
      }
      break;

1035
    case PROP_FOREGROUND_GDK:
1036
      {
Tim Janik's avatar
Tim Janik committed
1037 1038
        GdkColor *color = g_value_get_boxed (value);

1039
        set_fg_color (text_tag, color);
1040 1041 1042
      }
      break;

1043
    case PROP_BACKGROUND_STIPPLE:
1044
      {
1045
        GdkBitmap *bitmap = g_value_get_object (value);
1046

1047
        text_tag->bg_stipple_set = TRUE;
1048
        g_object_notify (object, "background-stipple-set");
Havoc Pennington's avatar
Havoc Pennington committed
1049
        
1050
        if (text_tag->values->appearance.bg_stipple != bitmap)
1051 1052
          {
            if (bitmap != NULL)
Manish Singh's avatar
Manish Singh committed
1053
              g_object_ref (bitmap);
1054

1055
            if (text_tag->values->appearance.bg_stipple)
Manish Singh's avatar
Manish Singh committed
1056
              g_object_unref (text_tag->values->appearance.bg_stipple);
1057

1058
            text_tag->values->appearance.bg_stipple = bitmap;
1059 1060 1061 1062
          }
      }
      break;

1063
    case PROP_FOREGROUND_STIPPLE:
1064
      {
1065
        GdkBitmap *bitmap = g_value_get_object (value);
1066

1067
        text_tag->fg_stipple_set = TRUE;
1068
        g_object_notify (object, "foreground-stipple-set");
1069

1070
        if (text_tag->values->appearance.fg_stipple != bitmap)
1071 1072
          {
            if (bitmap != NULL)
Manish Singh's avatar
Manish Singh committed
1073
              g_object_ref (bitmap);
1074

1075
            if (text_tag->values->appearance.fg_stipple)
Manish Singh's avatar
Manish Singh committed
1076
              g_object_unref (text_tag->values->appearance.fg_stipple);
1077

1078
            text_tag->values->appearance.fg_stipple = bitmap;
1079 1080 1081 1082
          }
      }
      break;

1083
    case PROP_FONT:
1084 1085 1086 1087
      {
        PangoFontDescription *font_desc = NULL;
        const gchar *name;

1088
        name = g_value_get_string (value);
1089 1090

        if (name)
1091 1092
          font_desc = pango_font_description_from_string (name);

1093
        set_font_description (text_tag, font_desc);
1094 1095
	if (font_desc)
	  pango_font_description_free (font_desc);
1096
        
1097 1098 1099 1100
        size_changed = TRUE;
      }
      break;

1101
    case PROP_FONT_DESC:
1102 1103 1104
      {
        PangoFontDescription *font_desc;

Tim Janik's avatar
Tim Janik committed
1105
        font_desc = g_value_get_boxed (value);
1106

1107
        set_font_description (text_tag, font_desc);
1108 1109 1110 1111 1112

        size_changed = TRUE;
      }
      break;

1113 1114 1115 1116 1117 1118
    case PROP_FAMILY:
    case PROP_STYLE:
    case PROP_VARIANT:
    case PROP_WEIGHT:
    case PROP_STRETCH:
    case PROP_SIZE:
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141
    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,
1142
					       g_value_get_int (value));
1143 1144 1145 1146 1147 1148 1149 1150
	    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));
1151
	    g_object_notify (object, "size-points");
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
	    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));
1162
	g_object_notify (object, "font-desc");
1163
	g_object_notify (object, "font");
1164 1165

	break;
1166 1167
      }
      
Havoc Pennington's avatar
Havoc Pennington committed
1168 1169 1170
    case PROP_SCALE:
      text_tag->values->font_scale = g_value_get_double (value);
      text_tag->scale_set = TRUE;
1171
      g_object_notify (object, "scale-set");
1172 1173 1174
      size_changed = TRUE;
      break;
      
1175
    case PROP_PIXELS_ABOVE_LINES:
1176
      text_tag->pixels_above_lines_set = TRUE;
1177
      text_tag->values->pixels_above_lines = g_value_get_int (value);
1178
      g_object_notify (object, "pixels-above-lines-set");
1179 1180 1181
      size_changed = TRUE;
      break;

1182
    case PROP_PIXELS_BELOW_LINES:
1183
      text_tag->pixels_below_lines_set = TRUE;
1184
      text_tag->values->pixels_below_lines = g_value_get_int (value);
1185
      g_object_notify (object, "pixels-below-lines-set");
1186 1187 1188
      size_changed = TRUE;
      break;

1189
    case PROP_PIXELS_INSIDE_WRAP:
1190
      text_tag->pixels_inside_wrap_set = TRUE;
1191
      text_tag->values->pixels_inside_wrap = g_value_get_int (value);
1192
      g_object_notify (object, "pixels-inside-wrap-set");
1193 1194 1195
      size_changed = TRUE;
      break;

1196
    case PROP_EDITABLE:
1197
      text_tag->editable_set = TRUE;
1198
      text_tag->values->editable = g_value_get_boolean (value);
1199
      g_object_notify (object, "editable-set");
1200 1201
      break;

1202
    case PROP_WRAP_MODE:
1203
      text_tag->wrap_mode_set = TRUE;
1204
      text_tag->values->wrap_mode = g_value_get_enum (value);
1205
      g_object_notify (object, "wrap-mode-set");
1206 1207 1208
      size_changed = TRUE;
      break;

1209 1210 1211
    case PROP_JUSTIFICATION:
      text_tag->justification_set = TRUE;
      text_tag->values->justification = g_value_get_enum (value);
1212
      g_object_notify (object, "justification-set");
1213 1214 1215
      size_changed = TRUE;
      break;

1216 1217
    case PROP_DIRECTION:
      text_tag->values->direction = g_value_get_enum (value);
1218 1219
      break;

1220
    case PROP_LEFT_MARGIN:
1221
      text_tag->left_margin_set = TRUE;
1222
      text_tag->values->left_margin = g_value_get_int (value);
1223
      g_object_notify (object, "left-margin-set");
1224 1225 1226
      size_changed = TRUE;
      break;

1227
    case PROP_INDENT:
1228
      text_tag->indent_set = TRUE;
1229
      text_tag->values->indent = g_value_get_int (value);
1230
      g_object_notify (object, "indent-set");
1231 1232 1233
      size_changed = TRUE;
      break;

1234
    case PROP_STRIKETHROUGH:
1235
      text_tag->strikethrough_set = TRUE;
1236
      text_tag->values->appearance.strikethrough = g_value_get_boolean (value);
1237
      g_object_notify (object, "strikethrough-set");
1238
      break;
1239