gtklabel.c 184 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Elliot Lee's avatar
Elliot Lee committed
2 3 4
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Owen Taylor's avatar
Owen Taylor committed
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
Owen Taylor's avatar
Owen Taylor committed
15 16
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Elliot Lee's avatar
Elliot Lee committed
17
 */
18 19

/*
20
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
21 22
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
23
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
24 25
 */

26
#include "config.h"
27

28
#include <math.h>
Elliot Lee's avatar
Elliot Lee committed
29
#include <string.h>
30

Elliot Lee's avatar
Elliot Lee committed
31
#include "gtklabel.h"
32
#include "gtkaccellabel.h"
33
#include "gtkdnd.h"
34
#include "gtkmain.h"
35
#include "gtkmarshalers.h"
36
#include "gtkwindow.h"
37
#include "gdk/gdkkeysyms.h"
38
#include "gtkclipboard.h"
39
#include "gtkimagemenuitem.h"
40
#include "gtkintl.h"
41
#include "gtkseparatormenuitem.h"
42
#include "gtktextutil.h"
43 44
#include "gtkmenuitem.h"
#include "gtknotebook.h"
45
#include "gtkstock.h"
46
#include "gtkbindings.h"
47
#include "gtkbuildable.h"
Matthias Clasen's avatar
Matthias Clasen committed
48 49 50
#include "gtkimage.h"
#include "gtkshow.h"
#include "gtktooltip.h"
51
#include "gtksizerequest.h"
52
#include "gtkprivate.h"
53

54

55
struct _GtkLabelPriv
56
{
57 58 59 60 61 62 63
  GtkLabelSelectionInfo *select_info;
  GtkWidget *mnemonic_widget;
  GtkWindow *mnemonic_window;

  PangoAttrList *attrs;
  PangoAttrList *effective_attrs;
  PangoLayout   *layout;
64 65

  gboolean mnemonics_visible;
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

  gchar   *label;
  gchar   *text;

  guint    jtype            : 2;
  guint    wrap             : 1;
  guint    use_underline    : 1;
  guint    use_markup       : 1;
  guint    ellipsize        : 3;
  guint    single_line_mode : 1;
  guint    have_transform   : 1;
  guint    in_click         : 1;
  guint    wrap_mode        : 3;
  guint    pattern_set      : 1;
  guint    track_links      : 1;

  guint    mnemonic_keyval;

  gint     wrap_width;
  gint     width_chars;
  gint     max_width_chars;
87 88

  gdouble  angle;
89
};
Matthias Clasen's avatar
Matthias Clasen committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129

/* Notes about the handling of links:
 *
 * Links share the GtkLabelSelectionInfo struct with selectable labels.
 * There are some new fields for links. The links field contains the list
 * of GtkLabelLink structs that describe the links which are embedded in
 * the label. The active_link field points to the link under the mouse
 * pointer. For keyboard navigation, the 'focus' link is determined by
 * finding the link which contains the selection_anchor position.
 * The link_clicked field is used with button press and release events
 * to ensure that pressing inside a link and releasing outside of it
 * does not activate the link.
 *
 * Links are rendered with the link-color/visited-link-color colors
 * that are determined by the style and with an underline. When the mouse
 * pointer is over a link, the pointer is changed to indicate the link,
 * and the background behind the link is rendered with the base[PRELIGHT]
 * color. While a button is pressed over a link, the background is rendered
 * with the base[ACTIVE] color.
 *
 * Labels with links accept keyboard focus, and it is possible to move
 * the focus between the embedded links using Tab/Shift-Tab. The focus
 * is indicated by a focus rectangle that is drawn around the link text.
 * Pressing Enter activates the focussed link, and there is a suitable
 * context menu for links that can be opened with the Menu key. Pressing
 * Control-C copies the link URI to the clipboard.
 *
 * In selectable labels with links, link functionality is only available
 * when the selection is empty.
 */
typedef struct
{
  gchar *uri;
  gchar *title;     /* the title attribute, used as tooltip */
  gboolean visited; /* get set when the link is activated; this flag
                     * gets preserved over later set_markup() calls
                     */
  gint start;       /* position of the link in the PangoLayout */
  gint end;
} GtkLabelLink;
130

131 132 133 134 135
struct _GtkLabelSelectionInfo
{
  GdkWindow *window;
  gint selection_anchor;
  gint selection_end;
136
  GtkWidget *popup_menu;
Matthias Clasen's avatar
Matthias Clasen committed
137 138 139 140

  GList *links;
  GtkLabelLink *active_link;

141 142 143
  gint drag_start_x;
  gint drag_start_y;

Matthias Clasen's avatar
Matthias Clasen committed
144
  guint in_drag      : 1;
145
  guint select_words : 1;
Matthias Clasen's avatar
Matthias Clasen committed
146 147
  guint selectable   : 1;
  guint link_clicked : 1;
148
};
Elliot Lee's avatar
Elliot Lee committed
149

150 151 152 153
enum {
  MOVE_CURSOR,
  COPY_CLIPBOARD,
  POPULATE_POPUP,
Matthias Clasen's avatar
Matthias Clasen committed
154
  ACTIVATE_LINK,
155
  ACTIVATE_CURRENT_LINK,
156 157
  LAST_SIGNAL
};
158

159
enum {
160 161 162 163 164 165 166 167
  PROP_0,
  PROP_LABEL,
  PROP_ATTRIBUTES,
  PROP_USE_MARKUP,
  PROP_USE_UNDERLINE,
  PROP_JUSTIFY,
  PROP_PATTERN,
  PROP_WRAP,
168
  PROP_WRAP_MODE,
169
  PROP_SELECTABLE,
170
  PROP_MNEMONIC_KEYVAL,
171 172
  PROP_MNEMONIC_WIDGET,
  PROP_CURSOR_POSITION,
173
  PROP_SELECTION_BOUND,
174
  PROP_ELLIPSIZE,
175
  PROP_WIDTH_CHARS,
176
  PROP_SINGLE_LINE_MODE,
177
  PROP_ANGLE,
178 179
  PROP_MAX_WIDTH_CHARS,
  PROP_TRACK_VISITED_LINKS
180 181
};

182 183 184
/* When rotating ellipsizable text we want the natural size to request 
 * more to ensure the label wont ever ellipsize in an allocation of full natural size.
 * */
185
#define ROTATION_ELLIPSIZE_PADDING 2
186

187 188
static guint signals[LAST_SIGNAL] = { 0 };

Matthias Clasen's avatar
Matthias Clasen committed
189 190 191
static const GdkColor default_link_color = { 0, 0, 0, 0xeeee };
static const GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };

192 193 194
static void gtk_label_set_property      (GObject          *object,
					 guint             prop_id,
					 const GValue     *value,
195
					 GParamSpec       *pspec);
196 197 198
static void gtk_label_get_property      (GObject          *object,
					 guint             prop_id,
					 GValue           *value,
199
					 GParamSpec       *pspec);
200
static void gtk_label_destroy           (GtkObject        *object);
201
static void gtk_label_finalize          (GObject          *object);
202 203
static void gtk_label_size_allocate     (GtkWidget        *widget,
                                         GtkAllocation    *allocation);
Havoc Pennington's avatar
Havoc Pennington committed
204 205
static void gtk_label_state_changed     (GtkWidget        *widget,
                                         GtkStateType      state);
206 207 208 209 210 211
static void gtk_label_style_set         (GtkWidget        *widget,
					 GtkStyle         *previous_style);
static void gtk_label_direction_changed (GtkWidget        *widget,
					 GtkTextDirection  previous_dir);
static gint gtk_label_expose            (GtkWidget        *widget,
					 GdkEventExpose   *event);
Matthias Clasen's avatar
Matthias Clasen committed
212 213
static gboolean gtk_label_focus         (GtkWidget         *widget,
                                         GtkDirectionType   direction);
Elliot Lee's avatar
Elliot Lee committed
214

215 216 217 218
static void gtk_label_realize           (GtkWidget        *widget);
static void gtk_label_unrealize         (GtkWidget        *widget);
static void gtk_label_map               (GtkWidget        *widget);
static void gtk_label_unmap             (GtkWidget        *widget);
Federico Mena Quintero's avatar
Federico Mena Quintero committed
219 220 221 222 223 224 225

static gboolean gtk_label_button_press      (GtkWidget        *widget,
					     GdkEventButton   *event);
static gboolean gtk_label_button_release    (GtkWidget        *widget,
					     GdkEventButton   *event);
static gboolean gtk_label_motion            (GtkWidget        *widget,
					     GdkEventMotion   *event);
Matthias Clasen's avatar
Matthias Clasen committed
226 227 228
static gboolean gtk_label_leave_notify      (GtkWidget        *widget,
                                             GdkEventCrossing *event);

229
static void     gtk_label_grab_focus        (GtkWidget        *widget);
230

Matthias Clasen's avatar
Matthias Clasen committed
231 232 233 234 235
static gboolean gtk_label_query_tooltip     (GtkWidget        *widget,
                                             gint              x,
                                             gint              y,
                                             gboolean          keyboard_tip,
                                             GtkTooltip       *tooltip);
236 237 238 239 240 241 242 243 244 245 246 247 248 249

static void gtk_label_set_text_internal          (GtkLabel      *label,
						  gchar         *str);
static void gtk_label_set_label_internal         (GtkLabel      *label,
						  gchar         *str);
static void gtk_label_set_use_markup_internal    (GtkLabel      *label,
						  gboolean       val);
static void gtk_label_set_use_underline_internal (GtkLabel      *label,
						  gboolean       val);
static void gtk_label_set_attributes_internal    (GtkLabel      *label,
						  PangoAttrList *attrs);
static void gtk_label_set_uline_text_internal    (GtkLabel      *label,
						  const gchar   *str);
static void gtk_label_set_pattern_internal       (GtkLabel      *label,
250 251
				                  const gchar   *pattern,
                                                  gboolean       is_mnemonic);
Matthias Clasen's avatar
Matthias Clasen committed
252
static void gtk_label_set_markup_internal        (GtkLabel      *label,
253 254 255
						  const gchar   *str,
						  gboolean       with_uline);
static void gtk_label_recalculate                (GtkLabel      *label);
256 257
static void gtk_label_hierarchy_changed          (GtkWidget     *widget,
						  GtkWidget     *old_toplevel);
258 259
static void gtk_label_screen_changed             (GtkWidget     *widget,
						  GdkScreen     *old_screen);
Matthias Clasen's avatar
Matthias Clasen committed
260
static gboolean gtk_label_popup_menu             (GtkWidget     *widget);
261

262 263
static void gtk_label_create_window       (GtkLabel *label);
static void gtk_label_destroy_window      (GtkLabel *label);
Matthias Clasen's avatar
Matthias Clasen committed
264 265 266
static void gtk_label_ensure_select_info  (GtkLabel *label);
static void gtk_label_clear_select_info   (GtkLabel *label);
static void gtk_label_update_cursor       (GtkLabel *label);
267
static void gtk_label_clear_layout        (GtkLabel *label);
268
static void gtk_label_ensure_layout       (GtkLabel *label, gboolean guess_wrap_width);
269
static void gtk_label_invalidate_wrap_width (GtkLabel *label);
270 271 272 273
static void gtk_label_select_region_index (GtkLabel *label,
                                           gint      anchor_index,
                                           gint      end_index);

274 275 276 277
static gboolean gtk_label_mnemonic_activate (GtkWidget         *widget,
					     gboolean           group_cycling);
static void     gtk_label_setup_mnemonic    (GtkLabel          *label,
					     guint              last_key);
278 279 280 281 282 283
static void     gtk_label_drag_data_get     (GtkWidget         *widget,
					     GdkDragContext    *context,
					     GtkSelectionData  *selection_data,
					     guint              info,
					     guint              time);

284 285 286 287 288 289 290 291 292 293 294 295 296 297
static void     gtk_label_buildable_interface_init     (GtkBuildableIface *iface);
static gboolean gtk_label_buildable_custom_tag_start   (GtkBuildable     *buildable,
							GtkBuilder       *builder,
							GObject          *child,
							const gchar      *tagname,
							GMarkupParser    *parser,
							gpointer         *data);

static void     gtk_label_buildable_custom_finished    (GtkBuildable     *buildable,
							GtkBuilder       *builder,
							GObject          *child,
							const gchar      *tagname,
							gpointer          user_data);

298

299
static void connect_mnemonics_visible_notify    (GtkLabel   *label);
300 301 302 303
static gboolean      separate_uline_pattern     (const gchar  *str,
                                                 guint        *accel_key,
                                                 gchar       **new_str,
                                                 gchar       **pattern);
304 305


Matthias Clasen's avatar
Matthias Clasen committed
306
/* For selectable labels: */
307 308 309 310 311 312 313 314 315 316 317 318
static void gtk_label_move_cursor        (GtkLabel        *label,
					  GtkMovementStep  step,
					  gint             count,
					  gboolean         extend_selection);
static void gtk_label_copy_clipboard     (GtkLabel        *label);
static void gtk_label_select_all         (GtkLabel        *label);
static void gtk_label_do_popup           (GtkLabel        *label,
					  GdkEventButton  *event);
static gint gtk_label_move_forward_word  (GtkLabel        *label,
					  gint             start);
static gint gtk_label_move_backward_word (GtkLabel        *label,
					  gint             start);
319

Matthias Clasen's avatar
Matthias Clasen committed
320 321 322
/* For links: */
static void          gtk_label_rescan_links     (GtkLabel  *label);
static void          gtk_label_clear_links      (GtkLabel  *label);
323 324 325
static gboolean      gtk_label_activate_link    (GtkLabel    *label,
                                                 const gchar *uri);
static void          gtk_label_activate_current_link (GtkLabel *label);
Matthias Clasen's avatar
Matthias Clasen committed
326 327 328 329
static GtkLabelLink *gtk_label_get_current_link (GtkLabel  *label);
static void          gtk_label_get_link_colors  (GtkWidget  *widget,
                                                 GdkColor  **link_color,
                                                 GdkColor  **visited_link_color);
330 331
static void          emit_activate_link         (GtkLabel     *label,
                                                 GtkLabelLink *link);
Matthias Clasen's avatar
Matthias Clasen committed
332

333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
static void               gtk_label_size_request_init     (GtkSizeRequestIface *iface);
static GtkSizeRequestMode gtk_label_get_request_mode      (GtkSizeRequest      *widget);
static void               gtk_label_get_width             (GtkSizeRequest      *widget,
							   gint                *minimum_size,
							   gint                *natural_size);
static void               gtk_label_get_height            (GtkSizeRequest      *widget,
							   gint                *minimum_size,
							   gint                *natural_size);
static void               gtk_label_get_width_for_height  (GtkSizeRequest      *widget,
							   gint                 height,
							   gint                *minimum_width,
							   gint                *natural_width);
static void               gtk_label_get_height_for_width  (GtkSizeRequest      *widget,
							   gint                 width,
							   gint                *minimum_height,
							   gint                *natural_height);
349

350 351 352 353
static GtkBuildableIface *buildable_parent_iface = NULL;

G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_MISC,
			 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
354
						gtk_label_buildable_interface_init)
355 356
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
                                                gtk_label_size_request_init));
Elliot Lee's avatar
Elliot Lee committed
357

358 359 360 361 362 363 364 365 366 367
static void
add_move_binding (GtkBindingSet  *binding_set,
		  guint           keyval,
		  guint           modmask,
		  GtkMovementStep step,
		  gint            count)
{
  g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
  
  gtk_binding_entry_add_signal (binding_set, keyval, modmask,
368
				"move-cursor", 3,
Manish Singh's avatar
Manish Singh committed
369
				G_TYPE_ENUM, step,
370
				G_TYPE_INT, count,
Manish Singh's avatar
Manish Singh committed
371
				G_TYPE_BOOLEAN, FALSE);
372 373 374

  /* Selection-extending version */
  gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
375
				"move-cursor", 3,
Manish Singh's avatar
Manish Singh committed
376
				G_TYPE_ENUM, step,
377
				G_TYPE_INT, count,
Manish Singh's avatar
Manish Singh committed
378
				G_TYPE_BOOLEAN, TRUE);
379 380
}

381
static void
Elliot Lee's avatar
Elliot Lee committed
382 383
gtk_label_class_init (GtkLabelClass *class)
{
384
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
385 386
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
387
  GtkBindingSet *binding_set;
388

389 390
  gobject_class->set_property = gtk_label_set_property;
  gobject_class->get_property = gtk_label_get_property;
391
  gobject_class->finalize = gtk_label_finalize;
392 393

  object_class->destroy = gtk_label_destroy;
Matthias Clasen's avatar
Matthias Clasen committed
394

395
  widget_class->size_allocate = gtk_label_size_allocate;
Havoc Pennington's avatar
Havoc Pennington committed
396
  widget_class->state_changed = gtk_label_state_changed;
397
  widget_class->style_set = gtk_label_style_set;
Matthias Clasen's avatar
Matthias Clasen committed
398
  widget_class->query_tooltip = gtk_label_query_tooltip;
399
  widget_class->direction_changed = gtk_label_direction_changed;
Elliot Lee's avatar
Elliot Lee committed
400
  widget_class->expose_event = gtk_label_expose;
401 402 403 404 405 406 407
  widget_class->realize = gtk_label_realize;
  widget_class->unrealize = gtk_label_unrealize;
  widget_class->map = gtk_label_map;
  widget_class->unmap = gtk_label_unmap;
  widget_class->button_press_event = gtk_label_button_press;
  widget_class->button_release_event = gtk_label_button_release;
  widget_class->motion_notify_event = gtk_label_motion;
Matthias Clasen's avatar
Matthias Clasen committed
408
  widget_class->leave_notify_event = gtk_label_leave_notify;
409
  widget_class->hierarchy_changed = gtk_label_hierarchy_changed;
410
  widget_class->screen_changed = gtk_label_screen_changed;
411
  widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
412
  widget_class->drag_data_get = gtk_label_drag_data_get;
413
  widget_class->grab_focus = gtk_label_grab_focus;
Matthias Clasen's avatar
Matthias Clasen committed
414 415
  widget_class->popup_menu = gtk_label_popup_menu;
  widget_class->focus = gtk_label_focus;
416 417 418

  class->move_cursor = gtk_label_move_cursor;
  class->copy_clipboard = gtk_label_copy_clipboard;
Matthias Clasen's avatar
Matthias Clasen committed
419 420
  class->activate_link = gtk_label_activate_link;

Matthias Clasen's avatar
Matthias Clasen committed
421 422 423 424 425 426 427 428 429 430 431 432 433 434
  /**
   * GtkLabel::move-cursor:
   * @entry: the object which received the signal
   * @step: the granularity of the move, as a #GtkMovementStep
   * @count: the number of @step units to move
   * @extend_selection: %TRUE if the move should extend the selection
   *
   * The ::move-cursor signal is a
   * <link linkend="keybinding-signals">keybinding signal</link>
   * which gets emitted when the user initiates a cursor movement.
   * If the cursor is not visible in @entry, this signal causes
   * the viewport to be moved instead.
   *
   * Applications should not connect to it, but may emit it with
435
   * g_signal_emit_by_name() if they need to control the cursor
Matthias Clasen's avatar
Matthias Clasen committed
436 437 438 439 440 441 442 443 444 445 446 447
   * programmatically.
   *
   * The default bindings for this signal come in two variants,
   * the variant with the Shift modifier extends the selection,
   * the variant without the Shift modifer does not.
   * There are too many key combinations to list them all here.
   * <itemizedlist>
   * <listitem>Arrow keys move by individual characters/lines</listitem>
   * <listitem>Ctrl-arrow key combinations move by words/paragraphs</listitem>
   * <listitem>Home/End keys move to the ends of the buffer</listitem>
   * </itemizedlist>
   */
448
  signals[MOVE_CURSOR] = 
449
    g_signal_new (I_("move-cursor"),
Manish Singh's avatar
Manish Singh committed
450 451 452 453 454 455 456 457 458
		  G_OBJECT_CLASS_TYPE (gobject_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkLabelClass, move_cursor),
		  NULL, NULL,
		  _gtk_marshal_VOID__ENUM_INT_BOOLEAN,
		  G_TYPE_NONE, 3,
		  GTK_TYPE_MOVEMENT_STEP,
		  G_TYPE_INT,
		  G_TYPE_BOOLEAN);
Matthias Clasen's avatar
Matthias Clasen committed
459 460 461 462 463 464 465 466 467 468 469

   /**
   * GtkLabel::copy-clipboard:
   * @label: the object which received the signal
   *
   * The ::copy-clipboard signal is a
   * <link linkend="keybinding-signals">keybinding signal</link>
   * which gets emitted to copy the selection to the clipboard.
   *
   * The default binding for this signal is Ctrl-c.
   */ 
470
  signals[COPY_CLIPBOARD] =
471
    g_signal_new (I_("copy-clipboard"),
Manish Singh's avatar
Manish Singh committed
472 473 474 475 476 477
		  G_OBJECT_CLASS_TYPE (gobject_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkLabelClass, copy_clipboard),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
478
  
Matthias Clasen's avatar
Matthias Clasen committed
479 480 481 482 483 484 485 486 487 488 489 490
  /**
   * GtkLabel::populate-popup:
   * @label: The label on which the signal is emitted
   * @menu: the menu that is being populated
   *
   * The ::populate-popup signal gets emitted before showing the
   * context menu of the label. Note that only selectable labels
   * have context menus.
   *
   * If you need to add items to the context menu, connect
   * to this signal and append your menuitems to the @menu.
   */
491
  signals[POPULATE_POPUP] =
492
    g_signal_new (I_("populate-popup"),
Manish Singh's avatar
Manish Singh committed
493 494 495 496 497 498 499 500
		  G_OBJECT_CLASS_TYPE (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkLabelClass, populate_popup),
		  NULL, NULL,
		  _gtk_marshal_VOID__OBJECT,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_MENU);

Matthias Clasen's avatar
Matthias Clasen committed
501
    /**
502 503
     * GtkLabel::activate-current-link:
     * @label: The label on which the signal was emitted
Matthias Clasen's avatar
Matthias Clasen committed
504
     *
505
     * A <link linkend="keybinding-signals">keybinding signal</link>
Matthias Clasen's avatar
Matthias Clasen committed
506 507 508 509 510 511 512
     * which gets emitted when the user activates a link in the label.
     *
     * Applications may also emit the signal with g_signal_emit_by_name()
     * if they need to control activation of URIs programmatically.
     *
     * The default bindings for this signal are all forms of the Enter key.
     *
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
     * Since: 2.18
     */
    signals[ACTIVATE_CURRENT_LINK] =
      g_signal_new_class_handler ("activate-current-link",
                                  G_TYPE_FROM_CLASS (object_class),
                                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                                  G_CALLBACK (gtk_label_activate_current_link),
                                  NULL, NULL,
                                  _gtk_marshal_VOID__VOID,
                                  G_TYPE_NONE, 0);

    /**
     * GtkLabel::activate-link:
     * @label: The label on which the signal was emitted
     * @uri: the URI that is activated
     *
     * The signal which gets emitted to activate a URI.
     * Applications may connect to it to override the default behaviour,
     * which is to call gtk_show_uri().
     *
Matthias Clasen's avatar
Matthias Clasen committed
533 534 535 536 537 538 539
     * Returns: %TRUE if the link has been activated
     *
     * Since: 2.18
     */
    signals[ACTIVATE_LINK] =
      g_signal_new ("activate-link",
                    G_TYPE_FROM_CLASS (object_class),
540
                    G_SIGNAL_RUN_LAST,
Matthias Clasen's avatar
Matthias Clasen committed
541 542
                    G_STRUCT_OFFSET (GtkLabelClass, activate_link),
                    _gtk_boolean_handled_accumulator, NULL,
543 544
                    _gtk_marshal_BOOLEAN__STRING,
                    G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
Matthias Clasen's avatar
Matthias Clasen committed
545

Manish Singh's avatar
Manish Singh committed
546
  g_object_class_install_property (gobject_class,
547 548
                                   PROP_LABEL,
                                   g_param_spec_string ("label",
549 550
                                                        P_("Label"),
                                                        P_("The text of the label"),
551
                                                        "",
552
                                                        GTK_PARAM_READWRITE));
553 554 555
  g_object_class_install_property (gobject_class,
				   PROP_ATTRIBUTES,
				   g_param_spec_boxed ("attributes",
556 557
						       P_("Attributes"),
						       P_("A list of style attributes to apply to the text of the label"),
558
						       PANGO_TYPE_ATTR_LIST,
559
						       GTK_PARAM_READWRITE));
560 561
  g_object_class_install_property (gobject_class,
                                   PROP_USE_MARKUP,
Matthias Clasen's avatar
x  
Matthias Clasen committed
562
                                   g_param_spec_boolean ("use-markup",
563 564
							 P_("Use markup"),
							 P_("The text of the label includes XML markup. See pango_parse_markup()"),
565
                                                        FALSE,
566
                                                        GTK_PARAM_READWRITE));
567 568
  g_object_class_install_property (gobject_class,
                                   PROP_USE_UNDERLINE,
Matthias Clasen's avatar
x  
Matthias Clasen committed
569
                                   g_param_spec_boolean ("use-underline",
570 571
							 P_("Use underline"),
							 P_("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
572
                                                        FALSE,
573
                                                        GTK_PARAM_READWRITE));
574 575 576 577

  g_object_class_install_property (gobject_class,
				   PROP_JUSTIFY,
                                   g_param_spec_enum ("justify",
578 579
                                                      P_("Justification"),
                                                      P_("The alignment of the lines in the text of the label relative to each other. This does NOT affect the alignment of the label within its allocation. See GtkMisc::xalign for that"),
580 581
						      GTK_TYPE_JUSTIFICATION,
						      GTK_JUSTIFY_LEFT,
582
                                                      GTK_PARAM_READWRITE));
583 584 585 586

  g_object_class_install_property (gobject_class,
                                   PROP_PATTERN,
                                   g_param_spec_string ("pattern",
587 588
                                                        P_("Pattern"),
                                                        P_("A string with _ characters in positions correspond to characters in the text to underline"),
589
                                                        NULL,
590
                                                        GTK_PARAM_WRITABLE));
591 592 593 594

  g_object_class_install_property (gobject_class,
                                   PROP_WRAP,
                                   g_param_spec_boolean ("wrap",
595 596
                                                        P_("Line wrap"),
                                                        P_("If set, wrap lines if the text becomes too wide"),
597
                                                        FALSE,
598
                                                        GTK_PARAM_READWRITE));
599 600 601
  /**
   * GtkLabel:wrap-mode:
   *
602 603 604
   * If line wrapping is on (see the #GtkLabel:wrap property) this controls 
   * how the line wrapping is done. The default is %PANGO_WRAP_WORD, which 
   * means wrap on word boundaries.
605 606 607 608 609 610 611 612 613 614 615
   *
   * Since: 2.10
   */
  g_object_class_install_property (gobject_class,
                                   PROP_WRAP_MODE,
                                   g_param_spec_enum ("wrap-mode",
						      P_("Line wrap mode"),
						      P_("If wrap is set, controls how linewrapping is done"),
						      PANGO_TYPE_WRAP_MODE,
						      PANGO_WRAP_WORD,
						      GTK_PARAM_READWRITE));
616 617 618
  g_object_class_install_property (gobject_class,
                                   PROP_SELECTABLE,
                                   g_param_spec_boolean ("selectable",
619 620
                                                        P_("Selectable"),
                                                        P_("Whether the label text can be selected with the mouse"),
621
                                                        FALSE,
622
                                                        GTK_PARAM_READWRITE));
623
  g_object_class_install_property (gobject_class,
624
                                   PROP_MNEMONIC_KEYVAL,
Matthias Clasen's avatar
x  
Matthias Clasen committed
625
                                   g_param_spec_uint ("mnemonic-keyval",
626 627
						      P_("Mnemonic key"),
						      P_("The mnemonic accelerator key for this label"),
628 629 630
						      0,
						      G_MAXUINT,
						      GDK_VoidSymbol,
631
						      GTK_PARAM_READABLE));
632 633
  g_object_class_install_property (gobject_class,
                                   PROP_MNEMONIC_WIDGET,
Matthias Clasen's avatar
x  
Matthias Clasen committed
634
                                   g_param_spec_object ("mnemonic-widget",
635 636
							P_("Mnemonic widget"),
							P_("The widget to be activated when the label's mnemonic "
Soren Sandmann's avatar
Soren Sandmann committed
637
							  "key is pressed"),
638
							GTK_TYPE_WIDGET,
639
							GTK_PARAM_READWRITE));
640

641 642
  g_object_class_install_property (gobject_class,
                                   PROP_CURSOR_POSITION,
Matthias Clasen's avatar
x  
Matthias Clasen committed
643
                                   g_param_spec_int ("cursor-position",
644 645
                                                     P_("Cursor Position"),
                                                     P_("The current position of the insertion cursor in chars"),
646 647 648
                                                     0,
                                                     G_MAXINT,
                                                     0,
649
                                                     GTK_PARAM_READABLE));
650 651 652
  
  g_object_class_install_property (gobject_class,
                                   PROP_SELECTION_BOUND,
Matthias Clasen's avatar
x  
Matthias Clasen committed
653
                                   g_param_spec_int ("selection-bound",
654 655
                                                     P_("Selection Bound"),
                                                     P_("The position of the opposite end of the selection from the cursor in chars"),
656 657 658
                                                     0,
                                                     G_MAXINT,
                                                     0,
659
                                                     GTK_PARAM_READABLE));
660
  
661 662 663
  /**
   * GtkLabel:ellipsize:
   *
664 665 666
   * The preferred place to ellipsize the string, if the label does 
   * not have enough room to display the entire string, specified as a 
   * #PangoEllisizeMode. 
667
   *
668 669 670 671 672 673 674
   * Note that setting this property to a value other than 
   * %PANGO_ELLIPSIZE_NONE has the side-effect that the label requests 
   * only enough space to display the ellipsis "...". In particular, this 
   * means that ellipsizing labels do not work well in notebook tabs, unless 
   * the tab's #GtkNotebook:tab-expand property is set to %TRUE. Other ways
   * to set a label's width are gtk_widget_set_size_request() and
   * gtk_label_set_width_chars().
675 676 677
   *
   * Since: 2.6
   */
678 679 680 681
  g_object_class_install_property (gobject_class,
				   PROP_ELLIPSIZE,
                                   g_param_spec_enum ("ellipsize",
                                                      P_("Ellipsize"),
682
                                                      P_("The preferred place to ellipsize the string, if the label does not have enough room to display the entire string"),
683 684
						      PANGO_TYPE_ELLIPSIZE_MODE,
						      PANGO_ELLIPSIZE_NONE,
685
                                                      GTK_PARAM_READWRITE));
686 687 688

  /**
   * GtkLabel:width-chars:
689
   *
690
   * The desired width of the label, in characters. If this property is set to
691 692 693 694 695
   * -1, the width will be calculated automatically.
   *
   * See the section on <link linkend="label-text-layout">text layout</link>
   * for details of how #GtkLabel:width-chars and #GtkLabel:max-width-chars
   * determine the width of ellipsized and wrapped labels.
696
   *
697 698 699 700
   * Since: 2.6
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_WIDTH_CHARS,
Matthias Clasen's avatar
x  
Matthias Clasen committed
701
                                   g_param_spec_int ("width-chars",
Matthias Clasen's avatar
Matthias Clasen committed
702
                                                     P_("Width In Characters"),
703 704 705 706
                                                     P_("The desired width of the label, in characters"),
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
707
                                                     GTK_PARAM_READWRITE));
708
  
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
  /**
   * GtkLabel:single-line-mode:
   * 
   * Whether the label is in single line mode. In single line mode,
   * the height of the label does not depend on the actual text, it
   * is always set to ascent + descent of the font. This can be an
   * advantage in situations where resizing the label because of text 
   * changes would be distracting, e.g. in a statusbar.
   *
   * Since: 2.6
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_SINGLE_LINE_MODE,
                                   g_param_spec_boolean ("single-line-mode",
                                                        P_("Single Line Mode"),
                                                        P_("Whether the label is in single line mode"),
                                                        FALSE,
726
                                                        GTK_PARAM_READWRITE));
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745

  /**
   * GtkLabel:angle:
   * 
   * The angle that the baseline of the label makes with the horizontal,
   * in degrees, measured counterclockwise. An angle of 90 reads from
   * from bottom to top, an angle of 270, from top to bottom. Ignored
   * if the label is selectable, wrapped, or ellipsized.
   *
   * Since: 2.6
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_ANGLE,
                                   g_param_spec_double ("angle",
							P_("Angle"),
							P_("Angle at which the label is rotated"),
							0.0,
							360.0,
							0.0, 
746
							GTK_PARAM_READWRITE));
747
  
748 749 750
  /**
   * GtkLabel:max-width-chars:
   * 
751
   * The desired maximum width of the label, in characters. If this property 
752 753 754 755 756 757
   * is set to -1, the width will be calculated automatically.
   *
   * See the section on <link linkend="label-text-layout">text layout</link>
   * for details of how #GtkLabel:width-chars and #GtkLabel:max-width-chars
   * determine the width of ellipsized and wrapped labels.
   *
758 759 760 761
   * Since: 2.6
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_MAX_WIDTH_CHARS,
Matthias Clasen's avatar
x  
Matthias Clasen committed
762
                                   g_param_spec_int ("max-width-chars",
763 764
                                                     P_("Maximum Width In Characters"),
                                                     P_("The desired maximum width of the label, in characters"),
765 766 767
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
768
                                                     GTK_PARAM_READWRITE));
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785

  /**
   * GtkLabel:track-visited-links:
   *
   * Set this property to %TRUE to make the label track which links
   * have been clicked. It will then apply the ::visited-link-color
   * color, instead of ::link-color.
   *
   * Since: 2.18
   */
  g_object_class_install_property (gobject_class,
                                   PROP_TRACK_VISITED_LINKS,
                                   g_param_spec_boolean ("track-visited-links",
                                                         P_("Track visited links"),
                                                         P_("Whether visited links should be tracked"),
                                                         TRUE,
                                                         GTK_PARAM_READWRITE));
786 787 788 789 790 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
  /*
   * Key bindings
   */

  binding_set = gtk_binding_set_by_class (class);

  /* Moving the insertion point */
  add_move_binding (binding_set, GDK_Right, 0,
		    GTK_MOVEMENT_VISUAL_POSITIONS, 1);
  
  add_move_binding (binding_set, GDK_Left, 0,
		    GTK_MOVEMENT_VISUAL_POSITIONS, -1);

  add_move_binding (binding_set, GDK_KP_Right, 0,
		    GTK_MOVEMENT_VISUAL_POSITIONS, 1);
  
  add_move_binding (binding_set, GDK_KP_Left, 0,
		    GTK_MOVEMENT_VISUAL_POSITIONS, -1);
  
  add_move_binding (binding_set, GDK_f, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
  
  add_move_binding (binding_set, GDK_b, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
  
  add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_WORDS, 1);

  add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_WORDS, -1);

  add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_WORDS, 1);

  add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_WORDS, -1);

823 824
  /* select all */
  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK,
825
				"move-cursor", 3,
826 827 828 829 830
				G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
				G_TYPE_INT, -1,
				G_TYPE_BOOLEAN, FALSE);

  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK,
831
				"move-cursor", 3,
832 833 834 835 836
				G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
				G_TYPE_INT, 1,
				G_TYPE_BOOLEAN, TRUE);

  gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK,
837
				"move-cursor", 3,
838 839 840 841 842
				G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
				G_TYPE_INT, -1,
				G_TYPE_BOOLEAN, FALSE);

  gtk_binding_entry_add_signal (binding_set, GDK_slash, GDK_CONTROL_MASK,
843
				"move-cursor", 3,
844 845 846 847 848 849
				G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
				G_TYPE_INT, 1,
				G_TYPE_BOOLEAN, TRUE);

  /* unselect all */
  gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
850
				"move-cursor", 3,
851 852 853 854 855
				G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
				G_TYPE_INT, 0,
				G_TYPE_BOOLEAN, FALSE);

  gtk_binding_entry_add_signal (binding_set, GDK_backslash, GDK_CONTROL_MASK,
856
				"move-cursor", 3,
857 858 859
				G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
				G_TYPE_INT, 0,
				G_TYPE_BOOLEAN, FALSE);
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 885 886 887 888 889 890 891 892

  add_move_binding (binding_set, GDK_f, GDK_MOD1_MASK,
		    GTK_MOVEMENT_WORDS, 1);

  add_move_binding (binding_set, GDK_b, GDK_MOD1_MASK,
		    GTK_MOVEMENT_WORDS, -1);

  add_move_binding (binding_set, GDK_Home, 0,
		    GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);

  add_move_binding (binding_set, GDK_End, 0,
		    GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);

  add_move_binding (binding_set, GDK_KP_Home, 0,
		    GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);

  add_move_binding (binding_set, GDK_KP_End, 0,
		    GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
  
  add_move_binding (binding_set, GDK_Home, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_BUFFER_ENDS, -1);

  add_move_binding (binding_set, GDK_End, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_BUFFER_ENDS, 1);

  add_move_binding (binding_set, GDK_KP_Home, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_BUFFER_ENDS, -1);

  add_move_binding (binding_set, GDK_KP_End, GDK_CONTROL_MASK,
		    GTK_MOVEMENT_BUFFER_ENDS, 1);

  /* copy */
  gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK,
893
				"copy-clipboard", 0);
894

Matthias Clasen's avatar
Matthias Clasen committed
895
  gtk_binding_entry_add_signal (binding_set, GDK_Return, 0,
896
				"activate-current-link", 0);
Matthias Clasen's avatar
Matthias Clasen committed
897
  gtk_binding_entry_add_signal (binding_set, GDK_ISO_Enter, 0,
898
				"activate-current-link", 0);
Matthias Clasen's avatar
Matthias Clasen committed
899
  gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0,
900
				"activate-current-link", 0);
Matthias Clasen's avatar
Matthias Clasen committed
901

902 903 904 905 906 907
  gtk_settings_install_property (g_param_spec_boolean ("gtk-label-select-on-focus",
						       P_("Select on focus"),
						       P_("Whether to select the contents of a selectable label when it is focused"),
						       TRUE,
						       GTK_PARAM_READWRITE));

908
  g_type_class_add_private (class, sizeof (GtkLabelPriv));
Elliot Lee's avatar
Elliot Lee committed
909 910
}

911 912 913 914
static void 
gtk_label_set_property (GObject      *object,
			guint         prop_id,
			const GValue *value,
915
			GParamSpec   *pspec)
916
{
917
  GtkLabel *label = GTK_LABEL (object);
918

919
  switch (prop_id)
920
    {
921
    case PROP_LABEL:
922
      gtk_label_set_label (label, g_value_get_string (value));
923 924 925 926 927
      break;
    case PROP_ATTRIBUTES:
      gtk_label_set_attributes (label, g_value_get_boxed (value));
      break;
    case PROP_USE_MARKUP:
928
      gtk_label_set_use_markup (label, g_value_get_boolean (value));
929
      break;
930
    case PROP_USE_UNDERLINE:
931
      gtk_label_set_use_underline (label, g_value_get_boolean (value));
932
      break;
933 934
    case PROP_JUSTIFY:
      gtk_label_set_justify (label, g_value_get_enum (value));
935
      break;
936 937 938 939 940 941
    case PROP_PATTERN:
      gtk_label_set_pattern (label, g_value_get_string (value));
      break;
    case PROP_WRAP:
      gtk_label_set_line_wrap (label, g_value_get_boolean (value));
      break;	  
942 943 944
    case PROP_WRAP_MODE:
      gtk_label_set_line_wrap_mode (label, g_value_get_enum (value));
      break;	  
945 946
    case PROP_SELECTABLE:
      gtk_label_set_selectable (label, g_value_get_boolean (value));
947
      break;	  
948 949 950
    case PROP_MNEMONIC_WIDGET:
      gtk_label_set_mnemonic_widget (label, (GtkWidget*) g_value_get_object (value));
      break;
951 952 953
    case PROP_ELLIPSIZE:
      gtk_label_set_ellipsize (label, g_value_get_enum (value));
      break;
954 955 956
    case PROP_WIDTH_CHARS:
      gtk_label_set_width_chars (label, g_value_get_int (value));
      break;
957 958 959
    case PROP_SINGLE_LINE_MODE:
      gtk_label_set_single_line_mode (label, g_value_get_boolean (value));
      break;	  
960 961
    case PROP_ANGLE:
      gtk_label_set_angle (label, g_value_get_double (value));
962 963 964 965
      break;
    case PROP_MAX_WIDTH_CHARS:
      gtk_label_set_max_width_chars (label, g_value_get_int (value));
      break;
966 967 968
    case PROP_TRACK_VISITED_LINKS:
      gtk_label_set_track_visited_links (label, g_value_get_boolean (value));
      break;
Tim Janik's avatar
Tim Janik committed
969
    default:
970
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Tim Janik's avatar
Tim Janik committed
971
      break;
972 973 974
    }
}

975 976 977 978
static void 
gtk_label_get_property (GObject     *object,
			guint        prop_id,
			GValue      *value,
979
			GParamSpec  *pspec)
980
{
981 982 983
  GtkLabel *label = GTK_LABEL (object);
  GtkLabelPriv *priv = label->priv;

984
  switch (prop_id)
985
    {
986
    case PROP_LABEL:
987
      g_value_set_string (value, priv->label);
988 989
      break;
    case PROP_ATTRIBUTES:
990
      g_value_set_boxed (value, priv->attrs);
991 992
      break;
    case PROP_USE_MARKUP:
993
      g_value_set_boolean (value, priv->use_markup);
994 995
      break;
    case PROP_USE_UNDERLINE:
996
      g_value_set_boolean (value, priv->use_underline);
997
      break;
998
    case PROP_JUSTIFY:
999
      g_value_set_enum (value, priv->jtype);
1000
      break;
1001
    case PROP_WRAP:
1002
      g_value_set_boolean (value, priv->wrap);
1003
      break;
1004
    case PROP_WRAP_MODE:
1005
      g_value_set_enum (value, priv->wrap_mode);
1006
      break;
1007 1008 1009
    case PROP_SELECTABLE:
      g_value_set_boolean (value, gtk_label_get_selectable (label));
      break;
1010
    case PROP_MNEMONIC_KEYVAL:
1011
      g_value_set_uint (value, priv->mnemonic_keyval);
1012
      break;
1013
    case PROP_MNEMONIC_WIDGET:
1014
      g_value_set_object (value, (GObject*) priv->mnemonic_widget);
1015
      break;
1016
    case PROP_CURSOR_POSITION:
1017
      if (priv->select_info && priv->select_info->selectable)
1018
	{
1019 1020
	  gint offset = g_utf8_pointer_to_offset (priv->text,
						  priv->text + priv->select_info->selection_end);
1021 1022 1023 1024 1025 1026
	  g_value_set_int (value, offset);
	}
      else
	g_value_set_int (value, 0);
      break;
    case PROP_SELECTION_BOUND:
1027
      if (priv->select_info && priv->select_info->selectable)
1028
	{
1029 1030
	  gint offset = g_utf8_pointer_to_offset (priv->text,
						  priv->text + priv->select_info->selection_anchor);
1031 1032 1033 1034 1035
	  g_value_set_int (value, offset);
	}
      else
	g_value_set_int (value, 0);
      break;
1036
    case PROP_ELLIPSIZE:
1037
      g_value_set_enum (value, priv->ellipsize);
1038
      break;
1039
    case PROP_WIDTH_CHARS:
1040
      g_value_set_int (value, gtk_label_get_width_chars (label));
1041
      break;
1042 1043 1044
    case PROP_SINGLE_LINE_MODE:
      g_value_set_boolean (value, gtk_label_get_single_line_mode (label));
      break;
1045 1046 1047
    case PROP_ANGLE:
      g_value_set_double (value, gtk_label_get_angle (label));
      break;
1048 1049 1050
    case PROP_MAX_WIDTH_CHARS:
      g_value_set_int (value, gtk_label_get_max_width_chars (label));
      break;
1051 1052 1053
    case PROP_TRACK_VISITED_LINKS:
      g_value_set_boolean (value, gtk_label_get_track_visited_links (label));
      break;
1054
    default: