~ubuntu-branches/ubuntu/trusty/libxfce4ui/trusty

« back to all changes in this revision

Viewing changes to libxfce4ui/xfce-heading.c

  • Committer: Package Import Robot
  • Author(s): Yves-Alexis Perez
  • Date: 2013-05-21 21:32:57 UTC
  • mfrom: (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130521213257-q5nqhxkutb9ze4ld
Tags: 4.10.0-2
* Upload to unstable.
* debian/rules:
  - enable all hardening flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id$ */
2
 
/*-
 
1
/*
3
2
 * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
4
3
 *
5
4
 * This library is free software; you can redistribute it and/or
13
12
 * Library General Public License for more details.
14
13
 *
15
14
 * You should have received a copy of the GNU Library General Public
16
 
 * License along with this library; if not, write to the
17
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 
 * Boston, MA 02111-1307, USA.
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
17
 * MA 02110-1301 USA
19
18
 */
20
19
 
21
20
#ifdef HAVE_CONFIG_H
39
38
#define XFCE_HEADING_SPACING    12
40
39
#define XFCE_HEADING_ICON_SIZE  48
41
40
 
42
 
#define XFCE_HEADING_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFCE_TYPE_HEADING, XfceHeadingPrivate))
43
 
 
44
 
 
45
 
 
46
 
/* Property identifiers */
47
 
enum
48
 
{
49
 
  PROP_0,
50
 
  PROP_ICON,
51
 
  PROP_ICON_NAME,
52
 
  PROP_SUBTITLE,
53
 
  PROP_TITLE,
54
 
};
55
 
 
56
 
 
57
41
 
58
42
static void         _xfce_heading_finalize       (GObject          *object);
59
 
static void         _xfce_heading_get_property   (GObject          *object,
60
 
                                                 guint             prop_id,
61
 
                                                 GValue           *value,
62
 
                                                 GParamSpec       *pspec);
63
 
static void         _xfce_heading_set_property   (GObject          *object,
64
 
                                                 guint             prop_id,
65
 
                                                 const GValue     *value,
66
 
                                                 GParamSpec       *pspec);
67
43
static void         _xfce_heading_realize        (GtkWidget        *widget);
68
44
static void         _xfce_heading_size_request   (GtkWidget        *widget,
69
 
                                                 GtkRequisition   *requisition);
 
45
                                                  GtkRequisition   *requisition);
70
46
static void         _xfce_heading_style_set      (GtkWidget        *widget,
71
 
                                                 GtkStyle         *previous_style);
 
47
                                                  GtkStyle         *previous_style);
72
48
static gboolean     _xfce_heading_expose_event   (GtkWidget        *widget,
73
 
                                                 GdkEventExpose   *event);
 
49
                                                  GdkEventExpose   *event);
74
50
static AtkObject   *_xfce_heading_get_accessible (GtkWidget        *widget);
75
51
static PangoLayout *_xfce_heading_make_layout    (XfceHeading      *heading);
76
52
static GdkPixbuf   *_xfce_heading_make_pixbuf    (XfceHeading      *heading);
77
 
static GdkPixbuf   *_xfce_heading_get_icon       (XfceHeading      *heading);
78
 
static const gchar *_xfce_heading_get_icon_name  (XfceHeading      *heading);
79
 
static const gchar *_xfce_heading_get_subtitle   (XfceHeading      *heading);
80
 
static const gchar *_xfce_heading_get_title      (XfceHeading      *heading);
81
 
 
82
 
 
83
 
 
84
 
struct _XfceHeadingPrivate
85
 
{
 
53
 
 
54
 
 
55
 
 
56
struct _XfceHeadingClass
 
57
{
 
58
  /*< private >*/
 
59
  GtkWidgetClass __parent__;
 
60
};
 
61
 
 
62
struct _XfceHeading
 
63
{
 
64
  /*< private >*/
 
65
  GtkWidget  __parent__;
 
66
 
86
67
  GdkPixbuf *icon;
87
68
  gchar     *icon_name;
88
69
  gchar     *subtitle;
101
82
  GtkWidgetClass *gtkwidget_class;
102
83
  GObjectClass   *gobject_class;
103
84
 
104
 
  /* add our private data to the class */
105
 
  g_type_class_add_private (klass, sizeof (XfceHeadingPrivate));
106
 
 
107
85
  gobject_class = G_OBJECT_CLASS (klass);
108
86
  gobject_class->finalize = _xfce_heading_finalize;
109
 
  gobject_class->get_property = _xfce_heading_get_property;
110
 
  gobject_class->set_property = _xfce_heading_set_property;
111
87
 
112
88
  gtkwidget_class = GTK_WIDGET_CLASS (klass);
113
89
  gtkwidget_class->realize = _xfce_heading_realize;
115
91
  gtkwidget_class->style_set = _xfce_heading_style_set;
116
92
  gtkwidget_class->expose_event = _xfce_heading_expose_event;
117
93
  gtkwidget_class->get_accessible = _xfce_heading_get_accessible;
118
 
 
119
 
  /**
120
 
   * XfceHeading:icon:
121
 
   *
122
 
   * The #GdkPixbuf to display as icon, or %NULL to use the
123
 
   * "icon-name" property.
124
 
   *
125
 
   * Since: 4.4.0
126
 
   **/
127
 
  g_object_class_install_property (gobject_class,
128
 
                                   PROP_ICON,
129
 
                                   g_param_spec_object ("icon",
130
 
                                                        "icon",
131
 
                                                        "icon",
132
 
                                                        GDK_TYPE_PIXBUF,
133
 
                                                        G_PARAM_READWRITE
134
 
                                                        | G_PARAM_STATIC_STRINGS));
135
 
 
136
 
  /**
137
 
   * XfceHeading:icon-name:
138
 
   *
139
 
   * If the "icon" property value is %NULL this is the name of
140
 
   * the icon to display instead (looked up using the icon theme).
141
 
   * If this property is also %NULL or the specified icon does not
142
 
   * exist in the selected icon theme, no icon will be displayed.
143
 
   *
144
 
   * Since: 4.4.0
145
 
   **/
146
 
  g_object_class_install_property (gobject_class,
147
 
                                   PROP_ICON_NAME,
148
 
                                   g_param_spec_string ("icon-name",
149
 
                                                        "icon-name",
150
 
                                                        "icon-name",
151
 
                                                        NULL,
152
 
                                                        G_PARAM_READWRITE
153
 
                                                        | G_PARAM_STATIC_STRINGS));
154
 
 
155
 
  /**
156
 
   * XfceHeading:subtitle:
157
 
   *
158
 
   * The sub title that should be displayed below the
159
 
   * title. May be %NULL or the empty string to display
160
 
   * only the title.
161
 
   *
162
 
   * Since: 4.4.0
163
 
   **/
164
 
  g_object_class_install_property (gobject_class,
165
 
                                   PROP_SUBTITLE,
166
 
                                   g_param_spec_string ("subtitle",
167
 
                                                        "subtitle",
168
 
                                                        "subtitle",
169
 
                                                        NULL,
170
 
                                                        G_PARAM_READWRITE
171
 
                                                        | G_PARAM_STATIC_STRINGS));
172
 
 
173
 
  /**
174
 
   * XfceHeading:title:
175
 
   *
176
 
   * The title text to display in the heading.
177
 
   *
178
 
   * Since: 4.4.0
179
 
   **/
180
 
  g_object_class_install_property (gobject_class,
181
 
                                   PROP_TITLE,
182
 
                                   g_param_spec_string ("title",
183
 
                                                        "title",
184
 
                                                        "title",
185
 
                                                        NULL,
186
 
                                                        G_PARAM_READWRITE
187
 
                                                        | G_PARAM_STATIC_STRINGS));
188
94
}
189
95
 
190
96
 
192
98
static void
193
99
_xfce_heading_init (XfceHeading *heading)
194
100
{
195
 
  /* setup the private data */
196
 
  heading->priv = XFCE_HEADING_GET_PRIVATE (heading);
197
 
 
198
101
  /* setup the widget parameters */
199
102
  GTK_WIDGET_UNSET_FLAGS (heading, GTK_NO_WINDOW);
200
103
}
207
110
  XfceHeading *heading = XFCE_HEADING (object);
208
111
 
209
112
  /* release the private data */
210
 
  if (G_UNLIKELY (heading->priv->icon != NULL))
211
 
    g_object_unref (G_OBJECT (heading->priv->icon));
 
113
  if (G_UNLIKELY (heading->icon != NULL))
 
114
    g_object_unref (G_OBJECT (heading->icon));
212
115
 
213
 
  g_free (heading->priv->icon_name);
214
 
  g_free (heading->priv->subtitle);
215
 
  g_free (heading->priv->title);
 
116
  g_free (heading->icon_name);
 
117
  g_free (heading->subtitle);
 
118
  g_free (heading->title);
216
119
 
217
120
  (*G_OBJECT_CLASS (_xfce_heading_parent_class)->finalize) (object);
218
121
}
220
123
 
221
124
 
222
125
static void
223
 
_xfce_heading_get_property (GObject    *object,
224
 
                           guint       prop_id,
225
 
                           GValue     *value,
226
 
                           GParamSpec *pspec)
227
 
{
228
 
  XfceHeading *heading = XFCE_HEADING (object);
229
 
 
230
 
  switch (prop_id)
231
 
    {
232
 
    case PROP_ICON:
233
 
      g_value_set_object (value, _xfce_heading_get_icon (heading));
234
 
      break;
235
 
 
236
 
    case PROP_ICON_NAME:
237
 
      g_value_set_string (value, _xfce_heading_get_icon_name (heading));
238
 
      break;
239
 
 
240
 
    case PROP_SUBTITLE:
241
 
      g_value_set_string (value, _xfce_heading_get_subtitle (heading));
242
 
      break;
243
 
 
244
 
    case PROP_TITLE:
245
 
      g_value_set_string (value, _xfce_heading_get_title (heading));
246
 
      break;
247
 
 
248
 
    default:
249
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
250
 
      break;
251
 
    }
252
 
}
253
 
 
254
 
 
255
 
 
256
 
static void
257
 
_xfce_heading_set_property (GObject      *object,
258
 
                           guint         prop_id,
259
 
                           const GValue *value,
260
 
                           GParamSpec   *pspec)
261
 
{
262
 
  XfceHeading *heading = XFCE_HEADING (object);
263
 
 
264
 
  switch (prop_id)
265
 
    {
266
 
    case PROP_ICON:
267
 
      _xfce_heading_set_icon (heading, g_value_get_object (value));
268
 
      break;
269
 
 
270
 
    case PROP_ICON_NAME:
271
 
      _xfce_heading_set_icon_name (heading, g_value_get_string (value));
272
 
      break;
273
 
 
274
 
    case PROP_SUBTITLE:
275
 
      _xfce_heading_set_subtitle (heading, g_value_get_string (value));
276
 
      break;
277
 
 
278
 
    case PROP_TITLE:
279
 
      _xfce_heading_set_title (heading, g_value_get_string (value));
280
 
      break;
281
 
 
282
 
    default:
283
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
284
 
      break;
285
 
    }
286
 
}
287
 
 
288
 
 
289
 
 
290
 
static void
291
126
_xfce_heading_realize (GtkWidget *widget)
292
127
{
293
128
  GdkWindowAttr attributes;
323
158
 
324
159
static void
325
160
_xfce_heading_size_request (GtkWidget      *widget,
326
 
                           GtkRequisition *requisition)
 
161
                            GtkRequisition *requisition)
327
162
{
328
163
  XfceHeading *heading = XFCE_HEADING (widget);
329
164
  PangoLayout *layout;
360
195
 
361
196
static void
362
197
_xfce_heading_style_set (GtkWidget *widget,
363
 
                        GtkStyle  *previous_style)
 
198
                         GtkStyle  *previous_style)
364
199
{
365
200
  /* check if we're already realized */
366
201
  if (GTK_WIDGET_REALIZED (widget))
374
209
 
375
210
static gboolean
376
211
_xfce_heading_expose_event (GtkWidget      *widget,
377
 
                           GdkEventExpose *event)
 
212
                            GdkEventExpose *event)
378
213
{
379
214
  XfceHeading *heading = XFCE_HEADING (widget);
380
215
  PangoLayout *layout;
422
257
  y = (widget->allocation.height - height) / 2;
423
258
 
424
259
  /* render the title */
425
 
  gtk_paint_layout (widget->style, widget->window, GTK_WIDGET_STATE (widget), TRUE, &event->area,
 
260
  gtk_paint_layout (widget->style, widget->window,
 
261
                    GTK_WIDGET_STATE (widget), TRUE, &event->area,
426
262
                    widget, "heading", (rtl ? x - width : x), y, layout);
427
263
 
428
264
  /* release the layout */
457
293
 
458
294
  /* generate the full text */
459
295
  text = g_string_sized_new (128);
460
 
  if (G_LIKELY (heading->priv->title != NULL))
 
296
  if (G_LIKELY (heading->title != NULL))
461
297
    {
462
298
      /* add the main title */
463
 
      title_length = strlen (heading->priv->title);
464
 
      g_string_append (text, heading->priv->title);
 
299
      title_length = strlen (heading->title);
 
300
      g_string_append (text, heading->title);
465
301
    }
466
 
  if (heading->priv->subtitle != NULL && *heading->priv->subtitle != '\0')
 
302
  if (heading->subtitle != NULL && *heading->subtitle != '\0')
467
303
    {
468
304
      /* add an empty line between the title and the subtitle */
469
 
      if (G_LIKELY (heading->priv->title != NULL))
 
305
      if (G_LIKELY (heading->title != NULL))
470
306
        g_string_append (text, "\n");
471
307
 
472
308
      /* add the subtitle */
473
 
      g_string_append (text, heading->priv->subtitle);
 
309
      g_string_append (text, heading->subtitle);
474
310
    }
475
311
 
476
312
  /* allocate and setup a new layout from the widget's context */
503
339
  GtkIconTheme *icon_theme;
504
340
  GdkPixbuf    *pixbuf = NULL;
505
341
  GdkScreen    *screen;
 
342
  GdkPixbuf    *scaled;
506
343
 
507
 
  if (G_UNLIKELY (heading->priv->icon != NULL))
 
344
  if (G_UNLIKELY (heading->icon != NULL))
508
345
    {
509
346
      /* just use the specified icon */
510
 
      pixbuf = g_object_ref (G_OBJECT (heading->priv->icon));
 
347
      pixbuf = g_object_ref (G_OBJECT (heading->icon));
511
348
    }
512
 
  else if (G_LIKELY (heading->priv->icon_name != NULL))
 
349
  else if (G_LIKELY (heading->icon_name != NULL))
513
350
    {
514
351
      /* determine the icon theme for the current screen */
515
352
      screen = gtk_widget_get_screen (GTK_WIDGET (heading));
516
353
      icon_theme = gtk_icon_theme_get_for_screen (screen);
517
354
 
518
355
      /* try to load the icon from the icon theme */
519
 
      pixbuf = gtk_icon_theme_load_icon (icon_theme, heading->priv->icon_name,
 
356
      pixbuf = gtk_icon_theme_load_icon (icon_theme, heading->icon_name,
520
357
                                         XFCE_HEADING_ICON_SIZE,
521
358
                                         GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
 
359
 
 
360
      if (pixbuf != NULL
 
361
          && (gdk_pixbuf_get_height (pixbuf) > XFCE_HEADING_ICON_SIZE
 
362
              || gdk_pixbuf_get_width (pixbuf) > XFCE_HEADING_ICON_SIZE))
 
363
        {
 
364
          /* this doesn't happen often, so be stupid
 
365
           * and assume icons are always squared */
 
366
          scaled = gdk_pixbuf_scale_simple (pixbuf,
 
367
                                            XFCE_HEADING_ICON_SIZE,
 
368
                                            XFCE_HEADING_ICON_SIZE,
 
369
                                            GDK_INTERP_BILINEAR);
 
370
          g_object_unref (pixbuf);
 
371
          pixbuf = scaled;
 
372
        }
 
373
 
 
374
      /* cache the icon, this does not take theme changes in account,
 
375
       * but because of the only use in the titled dialog, this works
 
376
       * fine, since the window properties are emitted on icon changes */
 
377
      if (heading->icon == NULL
 
378
          && pixbuf != NULL)
 
379
        heading->icon = g_object_ref (pixbuf);
522
380
    }
523
381
 
524
382
  return pixbuf;
527
385
 
528
386
 
529
387
/**
530
 
 * _xfce_heading_new:
531
 
 *
532
 
 * Allocates a new #XfceHeading instance.
533
 
 *
534
 
 * Return value: the newly allocated #XfceHeading.
535
 
 **/
536
 
GtkWidget*
537
 
_xfce_heading_new (void)
538
 
{
539
 
  return g_object_new (XFCE_TYPE_HEADING, NULL);
540
 
}
541
 
 
542
 
 
543
 
 
544
 
/**
545
 
 * _xfce_heading_get_icon:
546
 
 * @heading : a #XfceHeading.
547
 
 *
548
 
 * Returns the #GdkPixbuf that was set as icon for
549
 
 * @heading or %NULL if no icon is set. The returned
550
 
 * #GdkPixbuf object is owned by @heading.
551
 
 *
552
 
 * Return value: the icon for @heading, or %NULL.
553
 
 **/
554
 
static GdkPixbuf*
555
 
_xfce_heading_get_icon (XfceHeading *heading)
556
 
{
557
 
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
558
 
  return heading->priv->icon;
559
 
}
560
 
 
561
 
 
562
 
 
563
 
/**
564
388
 * _xfce_heading_set_icon:
565
389
 * @heading : a #XfceHeading.
566
390
 * @icon    : the new icon or %NULL.
573
397
_xfce_heading_set_icon (XfceHeading *heading,
574
398
                        GdkPixbuf   *icon)
575
399
{
576
 
  g_return_if_fail (XFCE_IS_HEADING (heading));
577
 
  g_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));
 
400
  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
 
401
  _libxfce4ui_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));
578
402
 
579
403
  /* check if we have a new icon */
580
 
  if (G_LIKELY (heading->priv->icon != icon))
 
404
  if (G_LIKELY (heading->icon != icon))
581
405
    {
582
406
      /* disconnect from the previous icon */
583
 
      if (G_LIKELY (heading->priv->icon != NULL))
584
 
        g_object_unref (G_OBJECT (heading->priv->icon));
585
 
 
586
 
      /* activate the new icon */
587
 
      heading->priv->icon = icon;
588
 
 
589
 
      /* connect to the new icon */
590
 
      if (G_LIKELY (icon != NULL))
591
 
        g_object_ref (G_OBJECT (icon));
592
 
 
593
 
      /* schedule a resize */
 
407
      if (G_LIKELY (heading->icon != NULL))
 
408
        g_object_unref (G_OBJECT (heading->icon));
 
409
 
 
410
      if (icon != NULL)
 
411
        {
 
412
          if (gdk_pixbuf_get_height (icon) > XFCE_HEADING_ICON_SIZE
 
413
              || gdk_pixbuf_get_width (icon) > XFCE_HEADING_ICON_SIZE)
 
414
            {
 
415
              /* this doesn't happen often, so be stupid
 
416
               * and assume icons are always squared */
 
417
              heading->icon = gdk_pixbuf_scale_simple (icon,
 
418
                                                       XFCE_HEADING_ICON_SIZE,
 
419
                                                       XFCE_HEADING_ICON_SIZE,
 
420
                                                       GDK_INTERP_BILINEAR);
 
421
            }
 
422
          else
 
423
            {
 
424
              heading->icon = g_object_ref (icon);
 
425
            }
 
426
        }
 
427
      else
 
428
        {
 
429
          heading->icon = NULL;
 
430
        }
 
431
 
594
432
      gtk_widget_queue_resize (GTK_WIDGET (heading));
595
 
 
596
 
      /* notify listeners */
597
 
      g_object_notify (G_OBJECT (heading), "icon");
598
433
    }
599
434
}
600
435
 
601
436
 
602
437
 
603
438
/**
604
 
 * _xfce_heading_get_icon_name:
605
 
 * @heading : a #XfceHeading.
606
 
 *
607
 
 * Returns the icon name previously set by a call to
608
 
 * _xfce_heading_set_icon_name() or %NULL if no icon name
609
 
 * is set for @heading.
610
 
 *
611
 
 * Return value: the icon name for @heading, or %NULL.
612
 
 **/
613
 
static const gchar*
614
 
_xfce_heading_get_icon_name (XfceHeading *heading)
615
 
{
616
 
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
617
 
  return heading->priv->icon_name;
618
 
}
619
 
 
620
 
 
621
 
 
622
 
/**
623
439
 * _xfce_heading_set_icon_name:
624
440
 * @heading   : a #XfceHeading.
625
441
 * @icon_name : the new icon name, or %NULL.
632
448
_xfce_heading_set_icon_name (XfceHeading *heading,
633
449
                             const gchar *icon_name)
634
450
{
635
 
  g_return_if_fail (XFCE_IS_HEADING (heading));
636
 
 
637
 
  /* release the previous icon name */
638
 
  g_free (heading->priv->icon_name);
 
451
  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
639
452
 
640
453
  /* activate the new icon name */
641
 
  heading->priv->icon_name = g_strdup (icon_name);
 
454
  g_free (heading->icon_name);
 
455
  heading->icon_name = g_strdup (icon_name);
642
456
 
643
 
  /* schedule a resize */
644
457
  gtk_widget_queue_resize (GTK_WIDGET (heading));
645
 
 
646
 
  /* notify listeners */
647
 
  g_object_notify (G_OBJECT (heading), "icon-name");
648
 
}
649
 
 
650
 
 
651
 
 
652
 
/**
653
 
 * _xfce_heading_get_subtitle:
654
 
 * @heading : a #XfceHeading.
655
 
 *
656
 
 * Returns the sub title displayed below the
657
 
 * main title of the @heading, or %NULL if
658
 
 * no subtitle is set.
659
 
 *
660
 
 * Return value: the subtitle of @heading, or %NULL.
661
 
 **/
662
 
static const gchar*
663
 
_xfce_heading_get_subtitle (XfceHeading *heading)
664
 
{
665
 
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
666
 
  return heading->priv->subtitle;
667
458
}
668
459
 
669
460
 
680
471
_xfce_heading_set_subtitle (XfceHeading *heading,
681
472
                            const gchar *subtitle)
682
473
{
683
 
  g_return_if_fail (XFCE_IS_HEADING (heading));
684
 
  g_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));
685
 
 
686
 
  /* release the previous subtitle */
687
 
  g_free (heading->priv->subtitle);
 
474
  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
 
475
  _libxfce4ui_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));
688
476
 
689
477
  /* activate the new subtitle */
690
 
  heading->priv->subtitle = g_strdup (subtitle);
 
478
  g_free (heading->subtitle);
 
479
  heading->subtitle = g_strdup (subtitle);
691
480
 
692
 
  /* schedule a resize */
693
481
  gtk_widget_queue_resize (GTK_WIDGET (heading));
694
 
 
695
 
  /* notify listeners */
696
 
  g_object_notify (G_OBJECT (heading), "subtitle");
697
 
}
698
 
 
699
 
 
700
 
 
701
 
/**
702
 
 * _xfce_heading_get_title:
703
 
 * @heading : a #XfceHeading.
704
 
 *
705
 
 * Returns the title displayed by the @heading.
706
 
 *
707
 
 * Return value: the title displayed by the @heading.
708
 
 **/
709
 
static const gchar*
710
 
_xfce_heading_get_title (XfceHeading *heading)
711
 
{
712
 
  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
713
 
  return heading->priv->title;
714
482
}
715
483
 
716
484
 
727
495
_xfce_heading_set_title (XfceHeading *heading,
728
496
                         const gchar *title)
729
497
{
730
 
  g_return_if_fail (XFCE_IS_HEADING (heading));
731
 
  g_return_if_fail (title == NULL || g_utf8_validate (title, -1, NULL));
732
 
 
733
 
  /* release the previous title */
734
 
  g_free (heading->priv->title);
 
498
  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
 
499
  _libxfce4ui_return_if_fail (title == NULL || g_utf8_validate (title, -1, NULL));
735
500
 
736
501
  /* activate the new title */
737
 
  heading->priv->title = g_strdup (title);
 
502
  g_free (heading->title);
 
503
  heading->title = g_strdup (title);
738
504
 
739
 
  /* schedule a resize */
740
505
  gtk_widget_queue_resize (GTK_WIDGET (heading));
741
 
 
742
 
  /* notify listeners */
743
 
  g_object_notify (G_OBJECT (heading), "title");
744
506
}
745
507
 
746
508