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
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
|
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include "config.h"
#include "hdy-action-row.h"
#include <glib/gi18n-lib.h>
/**
* SECTION:hdy-action-row
* @short_description: A #GtkListBox row used to present actions.
* @Title: HdyActionRow
*
* The #HdyActionRow widget can have a title, a subtitle and an icon. The row
* can receive additional widgets at its end, or prefix widgets at its start.
*
* It is convenient to present a preference and its related actions.
*
* #HdyActionRow is unactivatable by default, giving it an activatable widget
* will automatically make it activatable, but unsetting it won't change the
* row's activatability.
*
* # HdyActionRow as GtkBuildable
*
* The GtkWindow implementation of the GtkBuildable interface supports setting a
* child at its end by omitting the “type” attribute of a <child> element.
*
* It also supports setting a child as a prefix widget by specifying “prefix” as
* the “type” attribute of a <child> element.
*
* # CSS nodes
*
* #HdyActionRow has a main CSS node with name row.
*
* It contains the subnode box.header for its main horizontal box, and box.title
* for the vertical box containing the title and subtitle labels.
*
* It contains subnodes label.title and label.subtitle representing respectively
* the title label and subtitle label.
*
* Since: 0.0.6
*/
typedef struct
{
GtkBox *header;
GtkImage *image;
GtkBox *prefixes;
GtkLabel *subtitle;
GtkBox *suffixes;
GtkLabel *title;
GtkBox *title_box;
GtkWidget *previous_parent;
gboolean use_underline;
GtkWidget *activatable_widget;
} HdyActionRowPrivate;
static void hdy_action_row_buildable_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_WITH_CODE (HdyActionRow, hdy_action_row, HDY_TYPE_PREFERENCES_ROW,
G_ADD_PRIVATE (HdyActionRow)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
hdy_action_row_buildable_init))
static GtkBuildableIface *parent_buildable_iface;
enum {
PROP_0,
PROP_ICON_NAME,
PROP_ACTIVATABLE_WIDGET,
PROP_SUBTITLE,
PROP_USE_UNDERLINE,
LAST_PROP,
};
static GParamSpec *props[LAST_PROP];
enum {
SIGNAL_ACTIVATED,
SIGNAL_LAST_SIGNAL,
};
static guint signals[SIGNAL_LAST_SIGNAL];
static void
row_activated_cb (HdyActionRow *self,
GtkListBoxRow *row)
{
/* No need to use GTK_LIST_BOX_ROW() for a pointer comparison. */
if ((GtkListBoxRow *) self == row)
hdy_action_row_activate (self);
}
static void
parent_cb (HdyActionRow *self)
{
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (self));
if (priv->previous_parent != NULL) {
g_signal_handlers_disconnect_by_func (priv->previous_parent, G_CALLBACK (row_activated_cb), self);
priv->previous_parent = NULL;
}
if (parent == NULL || !GTK_IS_LIST_BOX (parent))
return;
priv->previous_parent = parent;
g_signal_connect_swapped (parent, "row-activated", G_CALLBACK (row_activated_cb), self);
}
static void
update_subtitle_visibility (HdyActionRow *self)
{
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
gtk_widget_set_visible (GTK_WIDGET (priv->subtitle),
gtk_label_get_text (priv->subtitle) != NULL &&
g_strcmp0 (gtk_label_get_text (priv->subtitle), "") != 0);
}
static void
hdy_action_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
HdyActionRow *self = HDY_ACTION_ROW (object);
switch (prop_id) {
case PROP_ICON_NAME:
g_value_set_string (value, hdy_action_row_get_icon_name (self));
break;
case PROP_ACTIVATABLE_WIDGET:
g_value_set_object (value, (GObject *) hdy_action_row_get_activatable_widget (self));
break;
case PROP_SUBTITLE:
g_value_set_string (value, hdy_action_row_get_subtitle (self));
break;
case PROP_USE_UNDERLINE:
g_value_set_boolean (value, hdy_action_row_get_use_underline (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
hdy_action_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
HdyActionRow *self = HDY_ACTION_ROW (object);
switch (prop_id) {
case PROP_ICON_NAME:
hdy_action_row_set_icon_name (self, g_value_get_string (value));
break;
case PROP_ACTIVATABLE_WIDGET:
hdy_action_row_set_activatable_widget (self, (GtkWidget*) g_value_get_object (value));
break;
case PROP_SUBTITLE:
hdy_action_row_set_subtitle (self, g_value_get_string (value));
break;
case PROP_USE_UNDERLINE:
hdy_action_row_set_use_underline (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
hdy_action_row_dispose (GObject *object)
{
HdyActionRow *self = HDY_ACTION_ROW (object);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
if (priv->previous_parent != NULL) {
g_signal_handlers_disconnect_by_func (priv->previous_parent, G_CALLBACK (row_activated_cb), self);
priv->previous_parent = NULL;
}
G_OBJECT_CLASS (hdy_action_row_parent_class)->dispose (object);
}
static void
hdy_action_row_show_all (GtkWidget *widget)
{
HdyActionRow *self = HDY_ACTION_ROW (widget);
HdyActionRowPrivate *priv;
g_return_if_fail (HDY_IS_ACTION_ROW (self));
priv = hdy_action_row_get_instance_private (self);
gtk_container_foreach (GTK_CONTAINER (priv->prefixes),
(GtkCallback) gtk_widget_show_all,
NULL);
gtk_container_foreach (GTK_CONTAINER (priv->suffixes),
(GtkCallback) gtk_widget_show_all,
NULL);
GTK_WIDGET_CLASS (hdy_action_row_parent_class)->show_all (widget);
}
static void
hdy_action_row_destroy (GtkWidget *widget)
{
HdyActionRow *self = HDY_ACTION_ROW (widget);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
if (priv->header) {
gtk_widget_destroy (GTK_WIDGET (priv->header));
priv->header = NULL;
}
hdy_action_row_set_activatable_widget (self, NULL);
priv->prefixes = NULL;
priv->suffixes = NULL;
GTK_WIDGET_CLASS (hdy_action_row_parent_class)->destroy (widget);
}
static void
hdy_action_row_add (GtkContainer *container,
GtkWidget *child)
{
HdyActionRow *self = HDY_ACTION_ROW (container);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
/* When constructing the widget, we want the box to be added as the child of
* the GtkListBoxRow, as an implementation detail.
*/
if (priv->header == NULL)
GTK_CONTAINER_CLASS (hdy_action_row_parent_class)->add (container, child);
else {
gtk_container_add (GTK_CONTAINER (priv->suffixes), child);
gtk_widget_show (GTK_WIDGET (priv->suffixes));
}
}
static void
hdy_action_row_remove (GtkContainer *container,
GtkWidget *child)
{
HdyActionRow *self = HDY_ACTION_ROW (container);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
if (child == GTK_WIDGET (priv->header))
GTK_CONTAINER_CLASS (hdy_action_row_parent_class)->remove (container, child);
else if (gtk_widget_get_parent (child) == GTK_WIDGET (priv->prefixes))
gtk_container_remove (GTK_CONTAINER (priv->prefixes), child);
else
gtk_container_remove (GTK_CONTAINER (priv->suffixes), child);
}
typedef struct {
HdyActionRow *row;
GtkCallback callback;
gpointer callback_data;
} ForallData;
static void
for_non_internal_child (GtkWidget *widget,
gpointer callback_data)
{
ForallData *data = callback_data;
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (data->row);
if (widget != (GtkWidget *) priv->image &&
widget != (GtkWidget *) priv->prefixes &&
widget != (GtkWidget *) priv->suffixes &&
widget != (GtkWidget *) priv->title_box)
data->callback (widget, data->callback_data);
}
static void
hdy_action_row_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data)
{
HdyActionRow *self = HDY_ACTION_ROW (container);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
ForallData data;
if (include_internals) {
GTK_CONTAINER_CLASS (hdy_action_row_parent_class)->forall (GTK_CONTAINER (self), include_internals, callback, callback_data);
return;
}
data.row = self;
data.callback = callback;
data.callback_data = callback_data;
if (priv->prefixes)
GTK_CONTAINER_GET_CLASS (priv->prefixes)->forall (GTK_CONTAINER (priv->prefixes), include_internals, for_non_internal_child, &data);
if (priv->suffixes)
GTK_CONTAINER_GET_CLASS (priv->suffixes)->forall (GTK_CONTAINER (priv->suffixes), include_internals, for_non_internal_child, &data);
if (priv->header)
GTK_CONTAINER_GET_CLASS (priv->header)->forall (GTK_CONTAINER (priv->header), include_internals, for_non_internal_child, &data);
}
static void
hdy_action_row_activate_real (HdyActionRow *self)
{
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
if (priv->activatable_widget)
gtk_widget_mnemonic_activate (priv->activatable_widget, FALSE);
g_signal_emit (self, signals[SIGNAL_ACTIVATED], 0);
}
static void
hdy_action_row_class_init (HdyActionRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->get_property = hdy_action_row_get_property;
object_class->set_property = hdy_action_row_set_property;
object_class->dispose = hdy_action_row_dispose;
widget_class->destroy = hdy_action_row_destroy;
widget_class->show_all = hdy_action_row_show_all;
container_class->add = hdy_action_row_add;
container_class->remove = hdy_action_row_remove;
container_class->forall = hdy_action_row_forall;
klass->activate = hdy_action_row_activate_real;
/**
* HdyActionRow:icon-name:
*
* The icon name for this row.
*
* Since: 0.0.6
*/
props[PROP_ICON_NAME] =
g_param_spec_string ("icon-name",
_("Icon name"),
_("Icon name"),
"",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* HdyActionRow:activatable-widget:
*
* The activatable widget for this row.
*
* Since: 0.0.7
*/
props[PROP_ACTIVATABLE_WIDGET] =
g_param_spec_object ("activatable-widget",
_("Activatable widget"),
_("The widget to be activated when the row is activated"),
GTK_TYPE_WIDGET,
G_PARAM_READWRITE);
/**
* HdyActionRow:subtitle:
*
* The subtitle for this row.
*
* Since: 0.0.6
*/
props[PROP_SUBTITLE] =
g_param_spec_string ("subtitle",
_("Subtitle"),
_("Subtitle"),
"",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* HdyActionRow:use-underline:
*
* Whether an embedded underline in the text of the title and subtitle labels
* indicates a mnemonic.
*
* Since: 0.0.6
*/
props[PROP_USE_UNDERLINE] =
g_param_spec_boolean ("use-underline",
_("Use underline"),
_("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"),
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, LAST_PROP, props);
/**
* HdyActionRow::activated:
* @self: The #HdyActionRow instance
*
* This signal is emitted after the row has been activated.
*
* Since: 1.0
*/
signals[SIGNAL_ACTIVATED] =
g_signal_new ("activated",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
0);
gtk_widget_class_set_template_from_resource (widget_class,
"/sm/puri/handy/ui/hdy-action-row.ui");
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, header);
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, image);
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, prefixes);
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, subtitle);
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, suffixes);
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, title);
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, title_box);
}
static gboolean
string_is_not_empty (GBinding *binding,
const GValue *from_value,
GValue *to_value,
gpointer user_data)
{
const gchar *string = g_value_get_string (from_value);
g_value_set_boolean (to_value, string != NULL && g_strcmp0 (string, "") != 0);
return TRUE;
}
static void
hdy_action_row_init (HdyActionRow *self)
{
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
g_object_bind_property_full (self, "title", priv->title, "visible", G_BINDING_SYNC_CREATE,
string_is_not_empty, NULL, NULL, NULL);
update_subtitle_visibility (self);
g_signal_connect (self, "notify::parent", G_CALLBACK (parent_cb), NULL);
}
static void
hdy_action_row_buildable_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *type)
{
HdyActionRow *self = HDY_ACTION_ROW (buildable);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
if (priv->header == NULL || !type)
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (child));
else if (type && strcmp (type, "prefix") == 0)
hdy_action_row_add_prefix (self, GTK_WIDGET (child));
else
GTK_BUILDER_WARN_INVALID_CHILD_TYPE (self, type);
}
static void
hdy_action_row_buildable_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->add_child = hdy_action_row_buildable_add_child;
}
/**
* hdy_action_row_new:
*
* Creates a new #HdyActionRow.
*
* Returns: a new #HdyActionRow
*
* Since: 0.0.6
*/
GtkWidget *
hdy_action_row_new (void)
{
return g_object_new (HDY_TYPE_ACTION_ROW, NULL);
}
/**
* hdy_action_row_get_subtitle:
* @self: a #HdyActionRow
*
* Gets the subtitle for @self.
*
* Returns: (transfer none) (nullable): the subtitle for @self, or %NULL.
*
* Since: 0.0.6
*/
const gchar *
hdy_action_row_get_subtitle (HdyActionRow *self)
{
HdyActionRowPrivate *priv;
g_return_val_if_fail (HDY_IS_ACTION_ROW (self), NULL);
priv = hdy_action_row_get_instance_private (self);
return gtk_label_get_text (priv->subtitle);
}
/**
* hdy_action_row_set_subtitle:
* @self: a #HdyActionRow
* @subtitle: (nullable): the subtitle
*
* Sets the subtitle for @self.
*
* Since: 0.0.6
*/
void
hdy_action_row_set_subtitle (HdyActionRow *self,
const gchar *subtitle)
{
HdyActionRowPrivate *priv;
g_return_if_fail (HDY_IS_ACTION_ROW (self));
priv = hdy_action_row_get_instance_private (self);
if (g_strcmp0 (gtk_label_get_text (priv->subtitle), subtitle) == 0)
return;
gtk_label_set_text (priv->subtitle, subtitle);
gtk_widget_set_visible (GTK_WIDGET (priv->subtitle),
subtitle != NULL && g_strcmp0 (subtitle, "") != 0);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SUBTITLE]);
}
/**
* hdy_action_row_get_icon_name:
* @self: a #HdyActionRow
*
* Gets the icon name for @self.
*
* Returns: the icon name for @self.
*
* Since: 0.0.6
*/
const gchar *
hdy_action_row_get_icon_name (HdyActionRow *self)
{
HdyActionRowPrivate *priv;
const gchar *icon_name;
g_return_val_if_fail (HDY_IS_ACTION_ROW (self), NULL);
priv = hdy_action_row_get_instance_private (self);
gtk_image_get_icon_name (priv->image, &icon_name, NULL);
return icon_name;
}
/**
* hdy_action_row_set_icon_name:
* @self: a #HdyActionRow
* @icon_name: the icon name
*
* Sets the icon name for @self.
*
* Since: 0.0.6
*/
void
hdy_action_row_set_icon_name (HdyActionRow *self,
const gchar *icon_name)
{
HdyActionRowPrivate *priv;
const gchar *old_icon_name;
g_return_if_fail (HDY_IS_ACTION_ROW (self));
priv = hdy_action_row_get_instance_private (self);
gtk_image_get_icon_name (priv->image, &old_icon_name, NULL);
if (g_strcmp0 (old_icon_name, icon_name) == 0)
return;
gtk_image_set_from_icon_name (priv->image, icon_name, GTK_ICON_SIZE_INVALID);
gtk_widget_set_visible (GTK_WIDGET (priv->image),
icon_name != NULL && g_strcmp0 (icon_name, "") != 0);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ICON_NAME]);
}
/**
* hdy_action_row_get_activatable_widget:
* @self: a #HdyActionRow
*
* Gets the widget activated when @self is activated.
*
* Returns: (nullable) (transfer none): the widget activated when @self is
* activated, or %NULL if none has been set.
*
* Since: 0.0.7
*/
GtkWidget *
hdy_action_row_get_activatable_widget (HdyActionRow *self)
{
HdyActionRowPrivate *priv;
g_return_val_if_fail (HDY_IS_ACTION_ROW (self), NULL);
priv = hdy_action_row_get_instance_private (self);
return priv->activatable_widget;
}
static void
activatable_widget_weak_notify (gpointer data,
GObject *where_the_object_was)
{
HdyActionRow *self = HDY_ACTION_ROW (data);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
priv->activatable_widget = NULL;
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVATABLE_WIDGET]);
}
/**
* hdy_action_row_set_activatable_widget:
* @self: a #HdyActionRow
* @widget: (nullable): the target #GtkWidget, or %NULL to unset
*
* Sets the widget to activate when @self is activated, either by clicking
* on it, by calling hdy_action_row_activate(), or via mnemonics in the title or
* the subtitle. See the “use_underline” property to enable mnemonics.
*
* The target widget will be activated by emitting the
* GtkWidget::mnemonic-activate signal on it.
*
* Since: 0.0.7
*/
void
hdy_action_row_set_activatable_widget (HdyActionRow *self,
GtkWidget *widget)
{
HdyActionRowPrivate *priv;
g_return_if_fail (HDY_IS_ACTION_ROW (self));
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
priv = hdy_action_row_get_instance_private (self);
if (priv->activatable_widget == widget)
return;
if (priv->activatable_widget)
g_object_weak_unref (G_OBJECT (priv->activatable_widget),
activatable_widget_weak_notify,
self);
priv->activatable_widget = widget;
if (priv->activatable_widget != NULL) {
g_object_weak_ref (G_OBJECT (priv->activatable_widget),
activatable_widget_weak_notify,
self);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (self), TRUE);
}
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACTIVATABLE_WIDGET]);
}
/**
* hdy_action_row_get_use_underline:
* @self: a #HdyActionRow
*
* Gets whether an embedded underline in the text of the title and subtitle
* labels indicates a mnemonic. See hdy_action_row_set_use_underline().
*
* Returns: %TRUE if an embedded underline in the title and subtitle labels
* indicates the mnemonic accelerator keys.
*
* Since: 0.0.6
*/
gboolean
hdy_action_row_get_use_underline (HdyActionRow *self)
{
HdyActionRowPrivate *priv;
g_return_val_if_fail (HDY_IS_ACTION_ROW (self), FALSE);
priv = hdy_action_row_get_instance_private (self);
return priv->use_underline;
}
/**
* hdy_action_row_set_use_underline:
* @self: a #HdyActionRow
* @use_underline: %TRUE if underlines in the text indicate mnemonics
*
* If true, an underline in the text of the title and subtitle labels indicates
* the next character should be used for the mnemonic accelerator key.
*
* Since: 0.0.6
*/
void
hdy_action_row_set_use_underline (HdyActionRow *self,
gboolean use_underline)
{
HdyActionRowPrivate *priv;
g_return_if_fail (HDY_IS_ACTION_ROW (self));
priv = hdy_action_row_get_instance_private (self);
if (priv->use_underline == !!use_underline)
return;
priv->use_underline = !!use_underline;
hdy_preferences_row_set_use_underline (HDY_PREFERENCES_ROW (self), priv->use_underline);
gtk_label_set_use_underline (priv->title, priv->use_underline);
gtk_label_set_use_underline (priv->subtitle, priv->use_underline);
gtk_label_set_mnemonic_widget (priv->title, GTK_WIDGET (self));
gtk_label_set_mnemonic_widget (priv->subtitle, GTK_WIDGET (self));
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_USE_UNDERLINE]);
}
/**
* hdy_action_row_add_prefix:
* @self: a #HdyActionRow
* @widget: the prefix widget
*
* Adds a prefix widget to @self.
*
* Since: 0.0.6
*/
void
hdy_action_row_add_prefix (HdyActionRow *self,
GtkWidget *widget)
{
HdyActionRowPrivate *priv;
g_return_if_fail (HDY_IS_ACTION_ROW (self));
g_return_if_fail (GTK_IS_WIDGET (self));
priv = hdy_action_row_get_instance_private (self);
gtk_box_pack_start (priv->prefixes, widget, FALSE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (priv->prefixes));
}
void
hdy_action_row_activate (HdyActionRow *self)
{
g_return_if_fail (HDY_IS_ACTION_ROW (self));
HDY_ACTION_ROW_GET_CLASS (self)->activate (self);
}
|