~ubuntu-branches/ubuntu/trusty/thunar-volman/trusty-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
/* $Id: xfce-heading.c 2340 2007-01-11 23:11:32Z benny $ */
/*-
 * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif

#include "xfce-heading.h"



#define XFCE_HEADING_BORDER      6
#define XFCE_HEADING_SPACING    12
#define XFCE_HEADING_ICON_SIZE  48

#define XFCE_HEADING_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFCE_TYPE_HEADING, XfceHeadingPrivate))



/* Property identifiers */
enum
{
  PROP_0,
  PROP_ICON,
  PROP_ICON_NAME,
  PROP_SUBTITLE,
  PROP_TITLE,
};



static void         xfce_heading_class_init     (XfceHeadingClass *klass);
static void         xfce_heading_init           (XfceHeading      *heading);
static void         xfce_heading_finalize       (GObject          *object);
static void         xfce_heading_get_property   (GObject          *object,
                                                 guint             prop_id,
                                                 GValue           *value,
                                                 GParamSpec       *pspec);
static void         xfce_heading_set_property   (GObject          *object,
                                                 guint             prop_id,
                                                 const GValue     *value,
                                                 GParamSpec       *pspec);
static void         xfce_heading_realize        (GtkWidget        *widget);
static void         xfce_heading_size_request   (GtkWidget        *widget,
                                                 GtkRequisition   *requisition);
static void         xfce_heading_style_set      (GtkWidget        *widget,
                                                 GtkStyle         *previous_style);
static gboolean     xfce_heading_expose_event   (GtkWidget        *widget,
                                                 GdkEventExpose   *event);
static AtkObject   *xfce_heading_get_accessible (GtkWidget        *widget);
static PangoLayout *xfce_heading_make_layout    (XfceHeading      *heading);
static GdkPixbuf   *xfce_heading_make_pixbuf    (XfceHeading      *heading);



struct _XfceHeadingPrivate
{
  GdkPixbuf *icon;
  gchar     *icon_name;
  gchar     *subtitle;
  gchar     *title;
};



G_DEFINE_TYPE (XfceHeading, xfce_heading, GTK_TYPE_WIDGET);



static void
xfce_heading_class_init (XfceHeadingClass *klass)
{
  GtkWidgetClass *gtkwidget_class;
  GObjectClass   *gobject_class;

  /* add our private data to the class */
  g_type_class_add_private (klass, sizeof (XfceHeadingPrivate));

  gobject_class = G_OBJECT_CLASS (klass);
  gobject_class->finalize = xfce_heading_finalize;
  gobject_class->get_property = xfce_heading_get_property;
  gobject_class->set_property = xfce_heading_set_property;

  gtkwidget_class = GTK_WIDGET_CLASS (klass);
  gtkwidget_class->realize = xfce_heading_realize;
  gtkwidget_class->size_request = xfce_heading_size_request;
  gtkwidget_class->style_set = xfce_heading_style_set;
  gtkwidget_class->expose_event = xfce_heading_expose_event;
  gtkwidget_class->get_accessible = xfce_heading_get_accessible;

  /**
   * XfceHeading:icon:
   *
   * The #GdkPixbuf to display as icon, or %NULL to use the
   * "icon-name" property.
   *
   * Since: 4.4.0
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_ICON,
                                   g_param_spec_object ("icon",
                                                        "icon",
                                                        "icon",
                                                        GDK_TYPE_PIXBUF,
                                                        G_PARAM_READWRITE));

  /**
   * XfceHeading:icon-name:
   *
   * If the "icon" property value is %NULL this is the name of
   * the icon to display instead (looked up using the icon theme).
   * If this property is also %NULL or the specified icon does not
   * exist in the selected icon theme, no icon will be displayed.
   *
   * Since: 4.4.0
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_ICON_NAME,
                                   g_param_spec_string ("icon-name",
                                                        "icon-name",
                                                        "icon-name",
                                                        NULL,
                                                        G_PARAM_READWRITE));

  /**
   * XfceHeading:subtitle:
   *
   * The sub title that should be displayed below the
   * title. May be %NULL or the empty string to display
   * only the title.
   *
   * Since: 4.4.0
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_SUBTITLE,
                                   g_param_spec_string ("subtitle",
                                                        "subtitle",
                                                        "subtitle",
                                                        NULL,
                                                        G_PARAM_READWRITE));

  /**
   * XfceHeading:title:
   *
   * The title text to display in the heading.
   *
   * Since: 4.4.0
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_TITLE,
                                   g_param_spec_string ("title",
                                                        "title",
                                                        "title",
                                                        NULL,
                                                        G_PARAM_READWRITE));
}



static void
xfce_heading_init (XfceHeading *heading)
{
  /* setup the private data */
  heading->priv = XFCE_HEADING_GET_PRIVATE (heading);

  /* setup the widget parameters */
  GTK_WIDGET_UNSET_FLAGS (heading, GTK_NO_WINDOW);
}



static void
xfce_heading_finalize (GObject *object)
{
  XfceHeading *heading = XFCE_HEADING (object);

  /* release the private data */
  if (G_UNLIKELY (heading->priv->icon != NULL))
    g_object_unref (G_OBJECT (heading->priv->icon));
  g_free (heading->priv->icon_name);
  g_free (heading->priv->subtitle);
  g_free (heading->priv->title);

  (*G_OBJECT_CLASS (xfce_heading_parent_class)->finalize) (object);
}



static void
xfce_heading_get_property (GObject    *object,
                           guint       prop_id,
                           GValue     *value,
                           GParamSpec *pspec)
{
  XfceHeading *heading = XFCE_HEADING (object);

  switch (prop_id)
    {
    case PROP_ICON:
      g_value_set_object (value, xfce_heading_get_icon (heading));
      break;

    case PROP_ICON_NAME:
      g_value_set_string (value, xfce_heading_get_icon_name (heading));
      break;

    case PROP_SUBTITLE:
      g_value_set_string (value, xfce_heading_get_subtitle (heading));
      break;

    case PROP_TITLE:
      g_value_set_string (value, xfce_heading_get_title (heading));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}



static void
xfce_heading_set_property (GObject      *object,
                           guint         prop_id,
                           const GValue *value,
                           GParamSpec   *pspec)
{
  XfceHeading *heading = XFCE_HEADING (object);

  switch (prop_id)
    {
    case PROP_ICON:
      xfce_heading_set_icon (heading, g_value_get_object (value));
      break;

    case PROP_ICON_NAME:
      xfce_heading_set_icon_name (heading, g_value_get_string (value));
      break;

    case PROP_SUBTITLE:
      xfce_heading_set_subtitle (heading, g_value_get_string (value));
      break;

    case PROP_TITLE:
      xfce_heading_set_title (heading, g_value_get_string (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}



static void
xfce_heading_realize (GtkWidget *widget)
{
  GdkWindowAttr attributes;

  /* mark the widget as realized */
  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);

  /* setup the window attributes */
  attributes.x = widget->allocation.x;
  attributes.y = widget->allocation.y;
  attributes.width = widget->allocation.width;
  attributes.height = widget->allocation.height;
  attributes.wclass = GDK_INPUT_OUTPUT;
  attributes.window_type = GDK_WINDOW_CHILD;
  attributes.visual = gtk_widget_get_visual (widget);
  attributes.colormap = gtk_widget_get_colormap (widget);
  attributes.event_mask = gtk_widget_get_events (widget)
                        | GDK_EXPOSURE_MASK;

  /* allocate the widget window */
  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes,
                                   GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP);
  gdk_window_set_user_data (widget->window, widget);

  /* connect the style to the window */
  widget->style = gtk_style_attach (widget->style, widget->window);

  /* set background color (using the base color) */
  gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
}



static void
xfce_heading_size_request (GtkWidget      *widget,
                           GtkRequisition *requisition)
{
  XfceHeading *heading = XFCE_HEADING (widget);
  PangoLayout *layout;
  GdkPixbuf   *pixbuf;
  gint         layout_width;
  gint         layout_height;
  gint         pixbuf_width = 0;
  gint         pixbuf_height = 0;

  /* determine the dimensions of the title text */
  layout = xfce_heading_make_layout (heading);
  pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
  g_object_unref (G_OBJECT (layout));

  /* determine the dimensions of the pixbuf */
  pixbuf = xfce_heading_make_pixbuf (heading);
  if (G_LIKELY (pixbuf != NULL))
    {
      pixbuf_width = gdk_pixbuf_get_width (pixbuf);
      pixbuf_height = gdk_pixbuf_get_height (pixbuf);
      g_object_unref (G_OBJECT (pixbuf));
    }

  /* determine the base dimensions */
  requisition->width = layout_width + pixbuf_width + ((pixbuf_width > 0) ? XFCE_HEADING_SPACING : 0);
  requisition->height = MAX (XFCE_HEADING_ICON_SIZE, MAX (pixbuf_height, layout_height));

  /* add border size */
  requisition->width += 2 * XFCE_HEADING_BORDER;
  requisition->height += 2 * XFCE_HEADING_BORDER;
}



static void
xfce_heading_style_set (GtkWidget *widget,
                        GtkStyle  *previous_style)
{
  /* check if we're already realized */
  if (GTK_WIDGET_REALIZED (widget))
    {
      /* set background color (using the base color) */
      gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
    }
}



static gboolean
xfce_heading_expose_event (GtkWidget      *widget,
                           GdkEventExpose *event)
{
  XfceHeading *heading = XFCE_HEADING (widget);
  PangoLayout *layout;
  GdkPixbuf   *pixbuf;
  gboolean     rtl;
  gint         width;
  gint         height;
  gint         x;
  gint         y;

  /* check if we should render from right to left */
  rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);

  /* determine the initial horizontal position */
  x = (rtl ? widget->allocation.width - XFCE_HEADING_BORDER : XFCE_HEADING_BORDER);

  /* check if we have a pixbuf to render */
  pixbuf = xfce_heading_make_pixbuf (heading);
  if (G_LIKELY (pixbuf != NULL))
    {
      /* determine the pixbuf dimensions */
      width = gdk_pixbuf_get_width (pixbuf);
      height = gdk_pixbuf_get_height (pixbuf);

      /* determine the vertical position */
      y = (widget->allocation.height - height) / 2;

      /* render the pixbuf */
      gdk_draw_pixbuf (widget->window, widget->style->black_gc, pixbuf, 0, 0,
                       (rtl ? x - width : x), y, width, height,
                       GDK_RGB_DITHER_NORMAL, 0, 0);

      /* release the pixbuf */
      g_object_unref (G_OBJECT (pixbuf));

      /* advance the horizontal position */
      x += (rtl ? -1 : 1) * (width + XFCE_HEADING_SPACING);
    }

  /* generate the title layout */
  layout = xfce_heading_make_layout (heading);
  pango_layout_get_pixel_size (layout, &width, &height);

  /* determine the vertical position */
  y = (widget->allocation.height - height) / 2;

  /* render the title */
  gtk_paint_layout (widget->style, widget->window, GTK_WIDGET_STATE (widget), TRUE, &event->area,
                    widget, "heading", (rtl ? x - width : x), y, layout);

  /* release the layout */
  g_object_unref (G_OBJECT (layout));

  return FALSE;
}



static AtkObject*
xfce_heading_get_accessible (GtkWidget *widget)
{
  AtkObject *object;

  object = (*GTK_WIDGET_CLASS (xfce_heading_parent_class)->get_accessible) (widget);
  atk_object_set_role (object, ATK_ROLE_HEADER);

  return object;
}



static PangoLayout*
xfce_heading_make_layout (XfceHeading *heading)
{
  PangoAttribute *attribute;
  PangoAttrList  *attr_list;
  PangoLayout    *layout;
  GString        *text;
  gint            title_length = 0;

  /* generate the full text */
  text = g_string_sized_new (128);
  if (G_LIKELY (heading->priv->title != NULL))
    {
      /* add the main title */
      title_length = strlen (heading->priv->title);
      g_string_append (text, heading->priv->title);
    }
  if (heading->priv->subtitle != NULL && *heading->priv->subtitle != '\0')
    {
      /* add an empty line between the title and the subtitle */
      if (G_LIKELY (heading->priv->title != NULL))
        g_string_append (text, "\n");

      /* add the subtitle */
      g_string_append (text, heading->priv->subtitle);
    }

  /* allocate and setup a new layout from the widget's context */
  layout = gtk_widget_create_pango_layout (GTK_WIDGET (heading), text->str);

  /* allocate an attribute list (large bold title) */
  attr_list = pango_attr_list_new ();
  attribute = pango_attr_scale_new (PANGO_SCALE_LARGE); /* large title */
  attribute->start_index = 0;
  attribute->end_index = title_length;
  pango_attr_list_insert (attr_list, attribute);
  attribute = pango_attr_weight_new (PANGO_WEIGHT_BOLD); /* bold title */
  attribute->start_index = 0;
  attribute->end_index = title_length;
  pango_attr_list_insert (attr_list, attribute);
  pango_layout_set_attributes (layout, attr_list);
  pango_attr_list_unref (attr_list);

  /* cleanup */
  g_string_free (text, TRUE);

  return layout;
}


  
static GdkPixbuf*
xfce_heading_make_pixbuf (XfceHeading *heading)
{
  GtkIconTheme *icon_theme;
  GdkPixbuf    *pixbuf = NULL;
  GdkScreen    *screen;

  if (G_UNLIKELY (heading->priv->icon != NULL))
    {
      /* just use the specified icon */
      pixbuf = g_object_ref (G_OBJECT (heading->priv->icon));
    }
  else if (G_LIKELY (heading->priv->icon_name != NULL))
    {
      /* determine the icon theme for the current screen */
      screen = gtk_widget_get_screen (GTK_WIDGET (heading));
      icon_theme = gtk_icon_theme_get_for_screen (screen);

      /* try to load the icon from the icon theme */
      pixbuf = gtk_icon_theme_load_icon (icon_theme, heading->priv->icon_name,
                                         XFCE_HEADING_ICON_SIZE,
                                         GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
    }

  return pixbuf;
}



/**
 * xfce_heading_new:
 *
 * Allocates a new #XfceHeading instance.
 *
 * Return value: the newly allocated #XfceHeading.
 *
 * Since: 4.4.0
 **/
GtkWidget*
xfce_heading_new (void)
{
  return g_object_new (XFCE_TYPE_HEADING, NULL);
}



/**
 * xfce_heading_get_icon:
 * @heading : a #XfceHeading.
 *
 * Returns the #GdkPixbuf that was set as icon for
 * @heading or %NULL if no icon is set. The returned
 * #GdkPixbuf object is owned by @heading.
 *
 * Return value: the icon for @heading, or %NULL.
 *
 * Since: 4.4.0
 **/
GdkPixbuf*
xfce_heading_get_icon (XfceHeading *heading)
{
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
  return heading->priv->icon;
}



/**
 * xfce_heading_set_icon:
 * @heading : a #XfceHeading.
 * @icon    : the new icon or %NULL.
 *
 * If @icon is not %NULL, @heading will display the new @icon
 * aside the title. Else, if @icon is %NULL no icon is displayed
 * unless an icon name was set with xfce_heading_set_icon_name().
 *
 * Since: 4.4.0
 **/
void
xfce_heading_set_icon (XfceHeading *heading,
                       GdkPixbuf   *icon)
{
  g_return_if_fail (XFCE_IS_HEADING (heading));
  g_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));

  /* check if we have a new icon */
  if (G_LIKELY (heading->priv->icon != icon))
    {
      /* disconnect from the previous icon */
      if (G_LIKELY (heading->priv->icon != NULL))
        g_object_unref (G_OBJECT (heading->priv->icon));

      /* activate the new icon */
      heading->priv->icon = icon;

      /* connect to the new icon */
      if (G_LIKELY (icon != NULL))
        g_object_ref (G_OBJECT (icon));

      /* schedule a resize */
      gtk_widget_queue_resize (GTK_WIDGET (heading));

      /* notify listeners */
      g_object_notify (G_OBJECT (heading), "icon");
    }
}



/**
 * xfce_heading_get_icon_name:
 * @heading : a #XfceHeading.
 *
 * Returns the icon name previously set by a call to
 * xfce_heading_set_icon_name() or %NULL if no icon name
 * is set for @heading.
 *
 * Return value: the icon name for @heading, or %NULL.
 *
 * Since: 4.4.0
 **/
G_CONST_RETURN gchar*
xfce_heading_get_icon_name (XfceHeading *heading)
{
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
  return heading->priv->icon_name;
}



/**
 * xfce_heading_set_icon_name:
 * @heading   : a #XfceHeading.
 * @icon_name : the new icon name, or %NULL.
 *
 * If @icon_name is not %NULL and the "icon" property is set to
 * %NULL, see xfce_heading_set_icon(), the @heading will display
 * the name icon identified by the @icon_name.
 *
 * Since: 4.4.0
 **/
void
xfce_heading_set_icon_name (XfceHeading *heading,
                            const gchar *icon_name)
{
  g_return_if_fail (XFCE_IS_HEADING (heading));

  /* release the previous icon name */
  g_free (heading->priv->icon_name);

  /* activate the new icon name */
  heading->priv->icon_name = g_strdup (icon_name);

  /* schedule a resize */
  gtk_widget_queue_resize (GTK_WIDGET (heading));

  /* notify listeners */
  g_object_notify (G_OBJECT (heading), "icon-name");
}



/**
 * xfce_heading_get_subtitle:
 * @heading : a #XfceHeading.
 *
 * Returns the sub title displayed below the
 * main title of the @heading, or %NULL if
 * no subtitle is set.
 *
 * Return value: the subtitle of @heading, or %NULL.
 *
 * Since: 4.4.0
 **/
G_CONST_RETURN gchar*
xfce_heading_get_subtitle (XfceHeading *heading)
{
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
  return heading->priv->subtitle;
}



/**
 * xfce_heading_set_subtitle:
 * @heading  : a #XfceHeading.
 * @subtitle : the new subtitle for @heading, or %NULL.
 *
 * If @subtitle is not %NULL and not the empty string, it
 * will be displayed by @heading below the main title.
 *
 * Since: 4.4.0
 **/
void
xfce_heading_set_subtitle (XfceHeading *heading,
                           const gchar *subtitle)
{
  g_return_if_fail (XFCE_IS_HEADING (heading));
  g_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));

  /* release the previous subtitle */
  g_free (heading->priv->subtitle);

  /* activate the new subtitle */
  heading->priv->subtitle = g_strdup (subtitle);

  /* schedule a resize */
  gtk_widget_queue_resize (GTK_WIDGET (heading));

  /* notify listeners */
  g_object_notify (G_OBJECT (heading), "subtitle");
}



/**
 * xfce_heading_get_title:
 * @heading : a #XfceHeading.
 *
 * Returns the title displayed by the @heading.
 *
 * Return value: the title displayed by the @heading.
 *
 * Since: 4.4.0
 **/
G_CONST_RETURN gchar*
xfce_heading_get_title (XfceHeading *heading)
{
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
  return heading->priv->title;
}



/**
 * xfce_heading_set_title:
 * @heading : a #XfceHeading.
 * @title   : the new title for the @heading.
 *
 * Sets the title displayed by the @heading to the
 * specified @title.
 *
 * Since: 4.4.0
 **/
void
xfce_heading_set_title (XfceHeading *heading,
                        const gchar *title)
{
  g_return_if_fail (XFCE_IS_HEADING (heading));
  g_return_if_fail (title == NULL || g_utf8_validate (title, -1, NULL));

  /* release the previous title */
  g_free (heading->priv->title);

  /* activate the new title */
  heading->priv->title = g_strdup (title);

  /* schedule a resize */
  gtk_widget_queue_resize (GTK_WIDGET (heading));

  /* notify listeners */
  g_object_notify (G_OBJECT (heading), "title");
}