summaryrefslogtreecommitdiff
path: root/gtk/deprecated/gtkaction.c
blob: e0b1367f5acb1f2efeabd0606f55aeb9da28d77c (plain)
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
775
776
777
778
779
780
781
782
783
784
785
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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
/*
 * GTK - The GIMP Toolkit
 * Copyright (C) 1998, 1999 Red Hat, Inc.
 * All rights reserved.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

/*
 * Author: James Henstridge <james@daa.com.au>
 *
 * Modified by the GTK+ Team and others 2003.  See the AUTHORS
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

/**
 * SECTION:gtkaction
 * @Short_description: A deprecated action which can be triggered by a menu or toolbar item
 * @Title: GtkAction
 * @See_also: #GtkActionGroup, #GtkUIManager, #GtkActivatable
 *
 * > In GTK+ 3.10, GtkAction has been deprecated. Use #GAction
 * > instead, and associate actions with #GtkActionable widgets. Use
 * > #GMenuModel for creating menus with gtk_menu_new_from_model().
 *
 * Actions represent operations that the user can be perform, along with
 * some information how it should be presented in the interface. Each action
 * provides methods to create icons, menu items and toolbar items
 * representing itself.
 *
 * As well as the callback that is called when the action gets activated,
 * the following also gets associated with the action:
 *
 * - a name (not translated, for path lookup)
 *
 * - a label (translated, for display)
 *
 * - an accelerator
 *
 * - whether label indicates a stock id
 *
 * - a tooltip (optional, translated)
 *
 * - a toolbar label (optional, shorter than label)
 *
 *
 * The action will also have some state information:
 *
 * - visible (shown/hidden)
 *
 * - sensitive (enabled/disabled)
 *
 * Apart from regular actions, there are [toggle actions][GtkToggleAction],
 * which can be toggled between two states and
 * [radio actions][GtkRadioAction], of which only one in a group
 * can be in the “active” state. Other actions can be implemented as #GtkAction
 * subclasses.
 *
 * Each action can have one or more proxy widgets. To act as an action proxy,
 * widget needs to implement #GtkActivatable interface. Proxies mirror the state
 * of the action and should change when the action's state changes. Properties
 * that are always mirrored by proxies are #GtkAction:sensitive and
 * #GtkAction:visible. #GtkAction:gicon, #GtkAction:icon-name, #GtkAction:label,
 * #GtkAction:short-label and #GtkAction:stock-id properties are only mirorred
 * if proxy widget has #GtkActivatable:use-action-appearance property set to
 * %TRUE.
 *
 * When the proxy is activated, it should activate its action.
 */

#include "config.h"

#define GDK_DISABLE_DEPRECATION_WARNINGS

#include "gtkaction.h"
#include "gtkactiongroup.h"
#include "gtkaccellabel.h"
#include "gtkbutton.h"
#include "gtkiconfactory.h"
#include "gtkimage.h"
#include "gtkimagemenuitem.h"
#include "gtkintl.h"
#include "gtklabel.h"
#include "gtkmarshalers.h"
#include "gtkmenuitem.h"
#include "gtkstock.h"
#include "gtktearoffmenuitem.h"
#include "gtktoolbutton.h"
#include "gtktoolbar.h"
#include "gtkprivate.h"
#include "gtkbuildable.h"
#include "gtkactivatable.h"


struct _GtkActionPrivate 
{
  const gchar *name; /* interned */
  gchar *label;
  gchar *short_label;
  gchar *tooltip;
  gchar *stock_id; /* stock icon */
  gchar *icon_name; /* themed icon */
  GIcon *gicon;

  guint sensitive          : 1;
  guint visible            : 1;
  guint label_set          : 1; /* these two used so we can set label */
  guint short_label_set    : 1; /* based on stock id */
  guint visible_horizontal : 1;
  guint visible_vertical   : 1;
  guint is_important       : 1;
  guint hide_if_empty      : 1;
  guint visible_overflown  : 1;
  guint always_show_image  : 1;
  guint recursion_guard    : 1;
  guint activate_blocked   : 1;

  /* accelerator */
  guint          accel_count;
  GtkAccelGroup *accel_group;
  GClosure      *accel_closure;
  GQuark         accel_quark;

  GtkActionGroup *action_group;

  /* list of proxy widgets */
  GSList *proxies;
};

enum 
{
  ACTIVATE,
  LAST_SIGNAL
};

enum 
{
  PROP_0,
  PROP_NAME,
  PROP_LABEL,
  PROP_SHORT_LABEL,
  PROP_TOOLTIP,
  PROP_STOCK_ID,
  PROP_ICON_NAME,
  PROP_GICON,
  PROP_VISIBLE_HORIZONTAL,
  PROP_VISIBLE_VERTICAL,
  PROP_VISIBLE_OVERFLOWN,
  PROP_IS_IMPORTANT,
  PROP_HIDE_IF_EMPTY,
  PROP_SENSITIVE,
  PROP_VISIBLE,
  PROP_ACTION_GROUP,
  PROP_ALWAYS_SHOW_IMAGE
};

/* GtkBuildable */
static void gtk_action_buildable_init             (GtkBuildableIface *iface);
static void gtk_action_buildable_set_name         (GtkBuildable *buildable,
						   const gchar  *name);
static const gchar* gtk_action_buildable_get_name (GtkBuildable *buildable);

G_DEFINE_TYPE_WITH_CODE (GtkAction, gtk_action, G_TYPE_OBJECT,
                         G_ADD_PRIVATE (GtkAction)
			 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
						gtk_action_buildable_init))

static void gtk_action_finalize     (GObject *object);
static void gtk_action_set_property (GObject         *object,
				     guint            prop_id,
				     const GValue    *value,
				     GParamSpec      *pspec);
static void gtk_action_get_property (GObject         *object,
				     guint            prop_id,
				     GValue          *value,
				     GParamSpec      *pspec);
static void gtk_action_set_action_group (GtkAction	*action,
					 GtkActionGroup *action_group);

static GtkWidget *create_menu_item    (GtkAction *action);
static GtkWidget *create_tool_item    (GtkAction *action);
static void       connect_proxy       (GtkAction *action,
				       GtkWidget *proxy);
static void       disconnect_proxy    (GtkAction *action,
				       GtkWidget *proxy);
 
static void       closure_accel_activate (GClosure     *closure,
					  GValue       *return_value,
					  guint         n_param_values,
					  const GValue *param_values,
					  gpointer      invocation_hint,
					  gpointer      marshal_data);

static guint         action_signals[LAST_SIGNAL] = { 0 };


static void
gtk_action_class_init (GtkActionClass *klass)
{
  GObjectClass *gobject_class;

  gobject_class = G_OBJECT_CLASS (klass);

  gobject_class->finalize     = gtk_action_finalize;
  gobject_class->set_property = gtk_action_set_property;
  gobject_class->get_property = gtk_action_get_property;

  klass->activate = NULL;

  klass->create_menu_item  = create_menu_item;
  klass->create_tool_item  = create_tool_item;
  klass->create_menu       = NULL;
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
  klass->menu_item_type    = GTK_TYPE_IMAGE_MENU_ITEM;
  G_GNUC_END_IGNORE_DEPRECATIONS;
  klass->toolbar_item_type = GTK_TYPE_TOOL_BUTTON;
  klass->connect_proxy    = connect_proxy;
  klass->disconnect_proxy = disconnect_proxy;

  /**
   * GtkAction:name:
   *
   * A unique name for the action.
   *
   * Deprecated: 3.10: Use #GAction:name instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_NAME,
				   g_param_spec_string ("name",
							P_("Name"),
							P_("A unique name for the action."),
							NULL,
							GTK_PARAM_READWRITE | 
							G_PARAM_CONSTRUCT_ONLY));

  /**
   * GtkAction:label:
   *
   * The label used for menu items and buttons that activate
   * this action. If the label is %NULL, GTK+ uses the stock 
   * label specified via the stock-id property.
   *
   * This is an appearance property and thus only applies if 
   * #GtkActivatable:use-action-appearance is %TRUE.
   *
   * Deprecated: 3.10: Use the "label" attribute on #GMenuItem instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_LABEL,
				   g_param_spec_string ("label",
							P_("Label"),
							P_("The label used for menu items and buttons "
							   "that activate this action."),
							NULL,
							GTK_PARAM_READWRITE));

  /**
   * GtkAction:short-label:
   *
   * A shorter label that may be used on toolbar buttons.
   *
   * This is an appearance property and thus only applies if 
   * #GtkActivatable:use-action-appearance is %TRUE.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_SHORT_LABEL,
				   g_param_spec_string ("short-label",
							P_("Short label"),
							P_("A shorter label that may be used on toolbar buttons."),
							NULL,
							GTK_PARAM_READWRITE));


  /**
   * GtkAction:tooltip:
   *
   * A tooltip for this action.
   *
   * Deprecated: 3.10: Use gtk_widget_set_tooltip_text() instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_TOOLTIP,
				   g_param_spec_string ("tooltip",
							P_("Tooltip"),
							P_("A tooltip for this action."),
							NULL,
							GTK_PARAM_READWRITE));

  /**
   * GtkAction:stock-id:
   *
   * The stock icon displayed in widgets representing this action.
   *
   * This is an appearance property and thus only applies if 
   * #GtkActivatable:use-action-appearance is %TRUE.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_STOCK_ID,
				   g_param_spec_string ("stock-id",
							P_("Stock Icon"),
							P_("The stock icon displayed in widgets representing "
							   "this action."),
							NULL,
							GTK_PARAM_READWRITE));
  /**
   * GtkAction:gicon:
   *
   * The #GIcon displayed in the #GtkAction.
   *
   * Note that the stock icon is preferred, if the #GtkAction:stock-id 
   * property holds the id of an existing stock icon.
   *
   * This is an appearance property and thus only applies if 
   * #GtkActivatable:use-action-appearance is %TRUE.
   *
   * Since: 2.16
   *
   * Deprecated: 3.10: Use the "icon" attribute on a #GMenuItem instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_GICON,
				   g_param_spec_object ("gicon",
							P_("GIcon"),
							P_("The GIcon being displayed"),
							G_TYPE_ICON,
 							GTK_PARAM_READWRITE));							
  /**
   * GtkAction:icon-name:
   *
   * The name of the icon from the icon theme. 
   * 
   * Note that the stock icon is preferred, if the #GtkAction:stock-id 
   * property holds the id of an existing stock icon, and the #GIcon is
   * preferred if the #GtkAction:gicon property is set. 
   *
   * This is an appearance property and thus only applies if 
   * #GtkActivatable:use-action-appearance is %TRUE.
   *
   * Since: 2.10
   *
   * Deprecated: 3.10: Use the "icon" attribute on a #GMenuItem instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_ICON_NAME,
				   g_param_spec_string ("icon-name",
							P_("Icon Name"),
							P_("The name of the icon from the icon theme"),
							NULL,
 							GTK_PARAM_READWRITE));

  /**
   * GtkAction:visible-horizontal:
   *
   * Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_VISIBLE_HORIZONTAL,
				   g_param_spec_boolean ("visible-horizontal",
							 P_("Visible when horizontal"),
							 P_("Whether the toolbar item is visible when the toolbar "
							    "is in a horizontal orientation."),
							 TRUE,
							 GTK_PARAM_READWRITE));
  /**
   * GtkAction:visible-overflown:
   *
   * When %TRUE, toolitem proxies for this action are represented in the 
   * toolbar overflow menu.
   *
   * Since: 2.6
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_VISIBLE_OVERFLOWN,
				   g_param_spec_boolean ("visible-overflown",
							 P_("Visible when overflown"),
							 P_("When TRUE, toolitem proxies for this action "
							    "are represented in the toolbar overflow menu."),
							 TRUE,
							 GTK_PARAM_READWRITE));

  /**
   * GtkAction:visible-vertical:
   *
   * Whether the toolbar item is visible when the toolbar is in a vertical orientation.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_VISIBLE_VERTICAL,
				   g_param_spec_boolean ("visible-vertical",
							 P_("Visible when vertical"),
							 P_("Whether the toolbar item is visible when the toolbar "
							    "is in a vertical orientation."),
							 TRUE,
							 GTK_PARAM_READWRITE));
  /**
   * GtkAction:is-important:
   *
   * Whether the action is considered important. When TRUE, toolitem
   * proxies for this action show text in GTK_TOOLBAR_BOTH_HORIZ mode.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_IS_IMPORTANT,
				   g_param_spec_boolean ("is-important",
							 P_("Is important"),
							 P_("Whether the action is considered important. "
							    "When TRUE, toolitem proxies for this action "
							    "show text in GTK_TOOLBAR_BOTH_HORIZ mode."),
							 FALSE,
							 GTK_PARAM_READWRITE));
  /**
   * GtkAction:hide-if-empty:
   *
   * When TRUE, empty menu proxies for this action are hidden.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_HIDE_IF_EMPTY,
				   g_param_spec_boolean ("hide-if-empty",
							 P_("Hide if empty"),
							 P_("When TRUE, empty menu proxies for this action are hidden."),
							 TRUE,
							 GTK_PARAM_READWRITE));
  /**
   * GtkAction:sensitive:
   *
   * Whether the action is enabled.
   *
   * Deprecated: 3.10: Use #GAction:enabled and #GSimpleAction:enabled
   * instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_SENSITIVE,
				   g_param_spec_boolean ("sensitive",
							 P_("Sensitive"),
							 P_("Whether the action is enabled."),
							 TRUE,
							 GTK_PARAM_READWRITE));
  /**
   * GtkAction:visible:
   *
   * Whether the action is visible.
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   */
  g_object_class_install_property (gobject_class,
				   PROP_VISIBLE,
				   g_param_spec_boolean ("visible",
							 P_("Visible"),
							 P_("Whether the action is visible."),
							 TRUE,
							 GTK_PARAM_READWRITE));
  /**
   * GtkAction:action-group:
   *
   * The GtkActionGroup this GtkAction is associated with, or NULL
   * (for internal use).
   *
   * Deprecated: 3.10: Lookup the #GAction using g_action_map_lookup_action()
   * instead
   */
  g_object_class_install_property (gobject_class,
				   PROP_ACTION_GROUP,
				   g_param_spec_object ("action-group",
							 P_("Action Group"),
							 P_("The GtkActionGroup this GtkAction is associated with, or NULL (for internal use)."),
							 GTK_TYPE_ACTION_GROUP,
							 GTK_PARAM_READWRITE));

  /**
   * GtkAction:always-show-image:
   *
   * If %TRUE, the action's menu item proxies will ignore the #GtkSettings:gtk-menu-images 
   * setting and always show their image, if available.
   *
   * Use this property if the menu item would be useless or hard to use
   * without their image. 
   *
   * Since: 2.20
   *
   * Deprecated: 3.10: There is no corresponding replacement when using
   * #GAction
   **/
  g_object_class_install_property (gobject_class,
                                   PROP_ALWAYS_SHOW_IMAGE,
                                   g_param_spec_boolean ("always-show-image",
                                                         P_("Always show image"),
                                                         P_("Whether the image will always be shown"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));

  /**
   * GtkAction::activate:
   * @action: the #GtkAction
   *
   * The "activate" signal is emitted when the action is activated.
   *
   * Since: 2.4
   *
   * Deprecated: 3.10: Use #GSimpleAction::activate instead
   */
  action_signals[ACTIVATE] =
    g_signal_new (I_("activate"),
		  G_OBJECT_CLASS_TYPE (klass),
		  G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
		  G_STRUCT_OFFSET (GtkActionClass, activate),  NULL, NULL,
		  g_cclosure_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
}


static void
gtk_action_init (GtkAction *action)
{
  action->private_data = gtk_action_get_instance_private (action);

  action->private_data->name = NULL;
  action->private_data->label = NULL;
  action->private_data->short_label = NULL;
  action->private_data->tooltip = NULL;
  action->private_data->stock_id = NULL;
  action->private_data->icon_name = NULL;
  action->private_data->visible_horizontal = TRUE;
  action->private_data->visible_vertical   = TRUE;
  action->private_data->visible_overflown  = TRUE;
  action->private_data->is_important = FALSE;
  action->private_data->hide_if_empty = TRUE;
  action->private_data->always_show_image = FALSE;
  action->private_data->activate_blocked = FALSE;

  action->private_data->sensitive = TRUE;
  action->private_data->visible = TRUE;

  action->private_data->label_set = FALSE;
  action->private_data->short_label_set = FALSE;

  action->private_data->accel_count = 0;
  action->private_data->accel_group = NULL;
  action->private_data->accel_quark = 0;
  action->private_data->accel_closure = 
    g_closure_new_object (sizeof (GClosure), G_OBJECT (action));
  g_closure_set_marshal (action->private_data->accel_closure, 
			 closure_accel_activate);
  g_closure_ref (action->private_data->accel_closure);
  g_closure_sink (action->private_data->accel_closure);

  action->private_data->action_group = NULL;

  action->private_data->proxies = NULL;
  action->private_data->gicon = NULL;  
}

static void
gtk_action_buildable_init (GtkBuildableIface *iface)
{
  iface->set_name = gtk_action_buildable_set_name;
  iface->get_name = gtk_action_buildable_get_name;
}

static void
gtk_action_buildable_set_name (GtkBuildable *buildable,
			       const gchar  *name)
{
  GtkAction *action = GTK_ACTION (buildable);

  action->private_data->name = g_intern_string (name);
}

static const gchar *
gtk_action_buildable_get_name (GtkBuildable *buildable)
{
  GtkAction *action = GTK_ACTION (buildable);

  return action->private_data->name;
}

/**
 * gtk_action_new:
 * @name: A unique name for the action
 * @label: (allow-none): the label displayed in menu items and on buttons,
 *         or %NULL
 * @tooltip: (allow-none): a tooltip for the action, or %NULL
 * @stock_id: (allow-none): the stock icon to display in widgets representing
 *            the action, or %NULL
 *
 * Creates a new #GtkAction object. To add the action to a
 * #GtkActionGroup and set the accelerator for the action,
 * call gtk_action_group_add_action_with_accel().
 * See <xref linkend="XML-UI"/> for information on allowed action
 * names.
 *
 * Return value: a new #GtkAction
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction instead, associating it to a widget with
 * #GtkActionable or creating a #GtkMenu with gtk_menu_new_from_model()
 */
GtkAction *
gtk_action_new (const gchar *name,
		const gchar *label,
		const gchar *tooltip,
		const gchar *stock_id)
{
  g_return_val_if_fail (name != NULL, NULL);

  return g_object_new (GTK_TYPE_ACTION,
                       "name", name,
		       "label", label,
		       "tooltip", tooltip,
		       "stock-id", stock_id,
		       NULL);
}

static void
gtk_action_finalize (GObject *object)
{
  GtkAction *action;
  action = GTK_ACTION (object);

  g_free (action->private_data->label);
  g_free (action->private_data->short_label);
  g_free (action->private_data->tooltip);
  g_free (action->private_data->stock_id);
  g_free (action->private_data->icon_name);
  
  if (action->private_data->gicon)
    g_object_unref (action->private_data->gicon);

  g_closure_unref (action->private_data->accel_closure);
  if (action->private_data->accel_group)
    g_object_unref (action->private_data->accel_group);

  G_OBJECT_CLASS (gtk_action_parent_class)->finalize (object);  
}

static void
gtk_action_set_property (GObject         *object,
			 guint            prop_id,
			 const GValue    *value,
			 GParamSpec      *pspec)
{
  GtkAction *action;
  
  action = GTK_ACTION (object);

  switch (prop_id)
    {
    case PROP_NAME:
      action->private_data->name = g_intern_string (g_value_get_string (value));
      break;
    case PROP_LABEL:
      gtk_action_set_label (action, g_value_get_string (value));
      break;
    case PROP_SHORT_LABEL:
      gtk_action_set_short_label (action, g_value_get_string (value));
      break;
    case PROP_TOOLTIP:
      gtk_action_set_tooltip (action, g_value_get_string (value));
      break;
    case PROP_STOCK_ID:
      gtk_action_set_stock_id (action, g_value_get_string (value));
      break;
    case PROP_GICON:
      gtk_action_set_gicon (action, g_value_get_object (value));
      break;
    case PROP_ICON_NAME:
      gtk_action_set_icon_name (action, g_value_get_string (value));
      break;
    case PROP_VISIBLE_HORIZONTAL:
      gtk_action_set_visible_horizontal (action, g_value_get_boolean (value));
      break;
    case PROP_VISIBLE_VERTICAL:
      gtk_action_set_visible_vertical (action, g_value_get_boolean (value));
      break;
    case PROP_VISIBLE_OVERFLOWN:
      action->private_data->visible_overflown = g_value_get_boolean (value);
      break;
    case PROP_IS_IMPORTANT:
      gtk_action_set_is_important (action, g_value_get_boolean (value));
      break;
    case PROP_HIDE_IF_EMPTY:
      action->private_data->hide_if_empty = g_value_get_boolean (value);
      break;
    case PROP_SENSITIVE:
      gtk_action_set_sensitive (action, g_value_get_boolean (value));
      break;
    case PROP_VISIBLE:
      gtk_action_set_visible (action, g_value_get_boolean (value));
      break;
    case PROP_ACTION_GROUP:
      gtk_action_set_action_group (action, g_value_get_object (value));
      break;
    case PROP_ALWAYS_SHOW_IMAGE:
      gtk_action_set_always_show_image (action, g_value_get_boolean (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
gtk_action_get_property (GObject    *object,
			 guint       prop_id,
			 GValue     *value,
			 GParamSpec *pspec)
{
  GtkAction *action;

  action = GTK_ACTION (object);

  switch (prop_id)
    {
    case PROP_NAME:
      g_value_set_static_string (value, action->private_data->name);
      break;
    case PROP_LABEL:
      g_value_set_string (value, action->private_data->label);
      break;
    case PROP_SHORT_LABEL:
      g_value_set_string (value, action->private_data->short_label);
      break;
    case PROP_TOOLTIP:
      g_value_set_string (value, action->private_data->tooltip);
      break;
    case PROP_STOCK_ID:
      g_value_set_string (value, action->private_data->stock_id);
      break;
    case PROP_ICON_NAME:
      g_value_set_string (value, action->private_data->icon_name);
      break;
    case PROP_GICON:
      g_value_set_object (value, action->private_data->gicon);
      break;
    case PROP_VISIBLE_HORIZONTAL:
      g_value_set_boolean (value, action->private_data->visible_horizontal);
      break;
    case PROP_VISIBLE_VERTICAL:
      g_value_set_boolean (value, action->private_data->visible_vertical);
      break;
    case PROP_VISIBLE_OVERFLOWN:
      g_value_set_boolean (value, action->private_data->visible_overflown);
      break;
    case PROP_IS_IMPORTANT:
      g_value_set_boolean (value, action->private_data->is_important);
      break;
    case PROP_HIDE_IF_EMPTY:
      g_value_set_boolean (value, action->private_data->hide_if_empty);
      break;
    case PROP_SENSITIVE:
      g_value_set_boolean (value, action->private_data->sensitive);
      break;
    case PROP_VISIBLE:
      g_value_set_boolean (value, action->private_data->visible);
      break;
    case PROP_ACTION_GROUP:
      g_value_set_object (value, action->private_data->action_group);
      break;
    case PROP_ALWAYS_SHOW_IMAGE:
      g_value_set_boolean (value, action->private_data->always_show_image);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static GtkWidget *
create_menu_item (GtkAction *action)
{
  GType menu_item_type;

  menu_item_type = GTK_ACTION_GET_CLASS (action)->menu_item_type;

  return g_object_new (menu_item_type, NULL);
}

static GtkWidget *
create_tool_item (GtkAction *action)
{
  GType toolbar_item_type;

  toolbar_item_type = GTK_ACTION_GET_CLASS (action)->toolbar_item_type;

  return g_object_new (toolbar_item_type, NULL);
}

static void
remove_proxy (GtkAction *action,
	      GtkWidget *proxy)
{
  g_object_unref (proxy);
  action->private_data->proxies = g_slist_remove (action->private_data->proxies, proxy);
}

static void
connect_proxy (GtkAction *action,
	       GtkWidget *proxy)
{
  action->private_data->proxies = g_slist_prepend (action->private_data->proxies, proxy);

  g_object_ref_sink (proxy);

  if (action->private_data->action_group)
    _gtk_action_group_emit_connect_proxy (action->private_data->action_group, action, proxy);

}

static void
disconnect_proxy (GtkAction *action,
		  GtkWidget *proxy)
{
  remove_proxy (action, proxy);

  if (action->private_data->action_group)
    _gtk_action_group_emit_disconnect_proxy (action->private_data->action_group, action, proxy);
}

/**
 * _gtk_action_sync_menu_visible:
 * @action: (allow-none): a #GtkAction, or %NULL to determine the action from @proxy
 * @proxy: a proxy menu item
 * @empty: whether the submenu attached to @proxy is empty
 * 
 * Updates the visibility of @proxy from the visibility of @action
 * according to the following rules:

 * - if @action is invisible, @proxy is too
 *
 * - if @empty is %TRUE, hide @proxy unless the “hide-if-empty”
 *   property of @action indicates otherwise
 *
 * This function is used in the implementation of #GtkUIManager.
 *
 * Deprecated: 3.10
 **/
void
_gtk_action_sync_menu_visible (GtkAction *action,
			       GtkWidget *proxy,
			       gboolean   empty)
{
  gboolean visible = TRUE;
  gboolean hide_if_empty = TRUE;

  g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
  g_return_if_fail (action == NULL || GTK_IS_ACTION (action));

  if (action == NULL)
    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));

  if (action)
    {
      /* a GtkMenu for a <popup/> doesn't have to have an action */
      visible = gtk_action_is_visible (action);
      hide_if_empty = action->private_data->hide_if_empty;
    }

  if (visible && !(empty && hide_if_empty))
    gtk_widget_show (proxy);
  else
    gtk_widget_hide (proxy);
}

void
_gtk_action_emit_activate (GtkAction *action)
{
  GtkActionGroup *group = action->private_data->action_group;

  if (group != NULL)
    {
      g_object_ref (action);
      g_object_ref (group);
      _gtk_action_group_emit_pre_activate (group, action);
    }

  g_signal_emit (action, action_signals[ACTIVATE], 0);

  if (group != NULL)
    {
      _gtk_action_group_emit_post_activate (group, action);
      g_object_unref (group);
      g_object_unref (action);
    }
}

/**
 * gtk_action_activate:
 * @action: the action object
 *
 * Emits the “activate” signal on the specified action, if it isn't
 * insensitive. This gets called by the proxy widgets when they get 
 * activated.
 *
 * It can also be used to manually activate an action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use g_action_group_activate_action() on a #GAction instead
 */
void
gtk_action_activate (GtkAction *action)
{
  g_return_if_fail (GTK_IS_ACTION (action));
  
  if (action->private_data->activate_blocked)
    return;

  if (gtk_action_is_sensitive (action))
    _gtk_action_emit_activate (action);
}

/**
 * gtk_action_block_activate:
 * @action: a #GtkAction
 *
 * Disable activation signals from the action 
 *
 * This is needed when updating the state of your proxy
 * #GtkActivatable widget could result in calling gtk_action_activate(),
 * this is a convenience function to avoid recursing in those
 * cases (updating toggle state for instance).
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use g_simple_action_set_enabled() to disable the
 * #GSimpleAction instead
 */
void
gtk_action_block_activate (GtkAction *action)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  action->private_data->activate_blocked = TRUE;
}

/**
 * gtk_action_unblock_activate:
 * @action: a #GtkAction
 *
 * Reenable activation signals from the action 
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use g_simple_action_set_enabled() to enable the
 * #GSimpleAction instead
 */
void
gtk_action_unblock_activate (GtkAction *action)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  action->private_data->activate_blocked = FALSE;
}

/**
 * gtk_action_create_icon:
 * @action: the action object
 * @icon_size: (type int): the size of the icon that should be created.
 *
 * This function is intended for use by action implementations to
 * create icons displayed in the proxy widgets.
 *
 * Returns: (transfer none): a widget that displays the icon for this action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use g_menu_item_set_icon() to set an icon on a #GMenuItem,
 * or gtk_container_add() to add a #GtkImage to a #GtkButton
 */
GtkWidget *
gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size)
{
  GtkWidget *widget = NULL;

  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

  if (action->private_data->stock_id &&
      gtk_icon_factory_lookup_default (action->private_data->stock_id))
    widget = gtk_image_new_from_stock (action->private_data->stock_id, icon_size);
  else if (action->private_data->gicon)
    widget = gtk_image_new_from_gicon (action->private_data->gicon, icon_size);
  else if (action->private_data->icon_name)
    widget = gtk_image_new_from_icon_name (action->private_data->icon_name, icon_size);

  G_GNUC_END_IGNORE_DEPRECATIONS;

  return widget;
}

/**
 * gtk_action_create_menu_item:
 * @action: the action object
 *
 * Creates a menu item widget that proxies for the given action.
 *
 * Returns: (transfer none): a menu item connected to the action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use g_menu_item_new() and associate it with a #GAction
 * instead.
 */
GtkWidget *
gtk_action_create_menu_item (GtkAction *action)
{
  GtkWidget *menu_item;

  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  menu_item = GTK_ACTION_GET_CLASS (action)->create_menu_item (action);

  gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (menu_item), TRUE);
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_item), action);

  return menu_item;
}

/**
 * gtk_action_create_tool_item:
 * @action: the action object
 *
 * Creates a toolbar item widget that proxies for the given action.
 *
 * Returns: (transfer none): a toolbar item connected to the action.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use a #GtkToolItem and associate it with a #GAction using
 * gtk_actionable_set_action_name() instead
 */
GtkWidget *
gtk_action_create_tool_item (GtkAction *action)
{
  GtkWidget *button;

  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  button = GTK_ACTION_GET_CLASS (action)->create_tool_item (action);

  gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (button), TRUE);
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);

  return button;
}

void
_gtk_action_add_to_proxy_list (GtkAction     *action,
			       GtkWidget     *proxy)
{
  g_return_if_fail (GTK_IS_ACTION (action));
  g_return_if_fail (GTK_IS_WIDGET (proxy));
 
  GTK_ACTION_GET_CLASS (action)->connect_proxy (action, proxy);
}

void
_gtk_action_remove_from_proxy_list (GtkAction     *action,
				    GtkWidget     *proxy)
{
  g_return_if_fail (GTK_IS_ACTION (action));
  g_return_if_fail (GTK_IS_WIDGET (proxy));

  GTK_ACTION_GET_CLASS (action)->disconnect_proxy (action, proxy);
}

/**
 * gtk_action_get_proxies:
 * @action: the action object
 * 
 * Returns the proxy widgets for an action.
 * See also gtk_activatable_get_related_action().
 *
 * Return value: (element-type GtkWidget) (transfer none): a #GSList of proxy widgets. The list is owned by GTK+
 * and must not be modified.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10
 **/
GSList*
gtk_action_get_proxies (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->proxies;
}

/**
 * gtk_action_get_name:
 * @action: the action object
 * 
 * Returns the name of the action.
 * 
 * Return value: the name of the action. The string belongs to GTK+ and should not
 *   be freed.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use g_action_get_name() on a #GAction instead
 **/
const gchar *
gtk_action_get_name (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->name;
}

/**
 * gtk_action_is_sensitive:
 * @action: the action object
 * 
 * Returns whether the action is effectively sensitive.
 *
 * Return value: %TRUE if the action and its associated action group 
 * are both sensitive.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use g_action_get_enabled() on a #GAction
 * instead
 **/
gboolean
gtk_action_is_sensitive (GtkAction *action)
{
  GtkActionPrivate *priv;
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  priv = action->private_data;
  return priv->sensitive &&
    (priv->action_group == NULL ||
     gtk_action_group_get_sensitive (priv->action_group));
}

/**
 * gtk_action_get_sensitive:
 * @action: the action object
 * 
 * Returns whether the action itself is sensitive. Note that this doesn't 
 * necessarily mean effective sensitivity. See gtk_action_is_sensitive() 
 * for that.
 *
 * Return value: %TRUE if the action itself is sensitive.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use g_action_get_enabled() on a #GAction
 * instead
 **/
gboolean
gtk_action_get_sensitive (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  return action->private_data->sensitive;
}

/**
 * gtk_action_set_sensitive:
 * @action: the action object
 * @sensitive: %TRUE to make the action sensitive
 * 
 * Sets the :sensitive property of the action to @sensitive. Note that 
 * this doesn't necessarily mean effective sensitivity. See 
 * gtk_action_is_sensitive() 
 * for that.
 *
 * Since: 2.6
 *
 * Deprecated: 3.10: Use g_simple_action_set_enabled() on a #GSimpleAction
 * instead
 **/
void
gtk_action_set_sensitive (GtkAction *action,
			  gboolean   sensitive)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  sensitive = sensitive != FALSE;
  
  if (action->private_data->sensitive != sensitive)
    {
      action->private_data->sensitive = sensitive;

      g_object_notify (G_OBJECT (action), "sensitive");
    }
}

/**
 * gtk_action_is_visible:
 * @action: the action object
 * 
 * Returns whether the action is effectively visible.
 *
 * Return value: %TRUE if the action and its associated action group 
 * are both visible.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the state of
 * #GtkActionable widgets directly
 **/
gboolean
gtk_action_is_visible (GtkAction *action)
{
  GtkActionPrivate *priv;
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  priv = action->private_data;
  return priv->visible &&
    (priv->action_group == NULL ||
     gtk_action_group_get_visible (priv->action_group));
}

/**
 * gtk_action_get_visible:
 * @action: the action object
 * 
 * Returns whether the action itself is visible. Note that this doesn't 
 * necessarily mean effective visibility. See gtk_action_is_sensitive() 
 * for that.
 *
 * Return value: %TRUE if the action itself is visible.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the state of
 * #GtkActionable widgets directly
 **/
gboolean
gtk_action_get_visible (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  return action->private_data->visible;
}

/**
 * gtk_action_set_visible:
 * @action: the action object
 * @visible: %TRUE to make the action visible
 * 
 * Sets the :visible property of the action to @visible. Note that 
 * this doesn't necessarily mean effective visibility. See 
 * gtk_action_is_visible() 
 * for that.
 *
 * Since: 2.6
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the state of
 * #GtkActionable widgets directly
 **/
void
gtk_action_set_visible (GtkAction *action,
			gboolean   visible)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  visible = visible != FALSE;
  
  if (action->private_data->visible != visible)
    {
      action->private_data->visible = visible;

      g_object_notify (G_OBJECT (action), "visible");
    }
}
/**
 * gtk_action_set_is_important:
 * @action: the action object
 * @is_important: %TRUE to make the action important
 *
 * Sets whether the action is important, this attribute is used
 * primarily by toolbar items to decide whether to show a label
 * or not.
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor whether
 * labels are shown directly
 */
void 
gtk_action_set_is_important (GtkAction *action,
			     gboolean   is_important)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  is_important = is_important != FALSE;
  
  if (action->private_data->is_important != is_important)
    {
      action->private_data->is_important = is_important;
      
      g_object_notify (G_OBJECT (action), "is-important");
    }  
}

/**
 * gtk_action_get_is_important:
 * @action: a #GtkAction
 *
 * Checks whether @action is important or not
 * 
 * Returns: whether @action is important
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor whether
 * labels are shown directly
 */
gboolean 
gtk_action_get_is_important (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  return action->private_data->is_important;
}

/**
 * gtk_action_set_always_show_image:
 * @action: a #GtkAction
 * @always_show: %TRUE if menuitem proxies should always show their image
 *
 * Sets whether @action<!-- -->'s menu item proxies will ignore the
 * #GtkSettings:gtk-menu-images setting and always show their image, if available.
 *
 * Use this if the menu item would be useless or hard to use
 * without their image.
 *
 * Since: 2.20
 *
 * Deprecated: 3.10: Use g_menu_item_set_icon() on a #GMenuItem instead, if the
 * item should have an image
 */
void
gtk_action_set_always_show_image (GtkAction *action,
                                  gboolean   always_show)
{
  GtkActionPrivate *priv;

  g_return_if_fail (GTK_IS_ACTION (action));

  priv = action->private_data;

  always_show = always_show != FALSE;
  
  if (priv->always_show_image != always_show)
    {
      priv->always_show_image = always_show;

      g_object_notify (G_OBJECT (action), "always-show-image");
    }
}

/**
 * gtk_action_get_always_show_image:
 * @action: a #GtkAction
 *
 * Returns whether @action<!-- -->'s menu item proxies will always
 * show their image, if available.
 *
 * Returns: %TRUE if the menu item proxies will always show their image
 *
 * Since: 2.20
 *
 * Deprecated: 3.10: Use g_menu_item_get_attribute_value() on a #GMenuItem
 * instead
 */
gboolean
gtk_action_get_always_show_image  (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  return action->private_data->always_show_image;
}

/**
 * gtk_action_set_label:
 * @action: a #GtkAction
 * @label: the label text to set
 *
 * Sets the label of @action.
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and set a label on a menu item with
 * g_menu_item_set_label(). For #GtkActionable widgets, use the widget-specific
 * API to set a label
 */
void 
gtk_action_set_label (GtkAction	  *action,
		      const gchar *label)
{
  gchar *tmp;
  
  g_return_if_fail (GTK_IS_ACTION (action));
  
  tmp = action->private_data->label;
  action->private_data->label = g_strdup (label);
  g_free (tmp);
  action->private_data->label_set = (action->private_data->label != NULL);
  /* if label is unset, then use the label from the stock item */
  if (!action->private_data->label_set && action->private_data->stock_id)
    {
      GtkStockItem stock_item;

      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

      if (gtk_stock_lookup (action->private_data->stock_id, &stock_item))
	action->private_data->label = g_strdup (stock_item.label);

      G_GNUC_END_IGNORE_DEPRECATIONS;
    }

  g_object_notify (G_OBJECT (action), "label");
  
  /* if short_label is unset, set short_label=label */
  if (!action->private_data->short_label_set)
    {
      gtk_action_set_short_label (action, action->private_data->label);
      action->private_data->short_label_set = FALSE;
    }
}

/**
 * gtk_action_get_label:
 * @action: a #GtkAction
 *
 * Gets the label text of @action.
 *
 * Returns: the label text
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and get a label from a menu item
 * with g_menu_item_get_attribute_value(). For #GtkActionable widgets, use the
 * widget-specific API to get a label
 */
const gchar *
gtk_action_get_label (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->label;
}

/**
 * gtk_action_set_short_label:
 * @action: a #GtkAction
 * @short_label: the label text to set
 *
 * Sets a shorter label text on @action.
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, which has no equivalent of short
 * labels
 */
void 
gtk_action_set_short_label (GtkAction   *action,
			    const gchar *short_label)
{
  gchar *tmp;

  g_return_if_fail (GTK_IS_ACTION (action));

  tmp = action->private_data->short_label;
  action->private_data->short_label = g_strdup (short_label);
  g_free (tmp);
  action->private_data->short_label_set = (action->private_data->short_label != NULL);
  /* if short_label is unset, then use the value of label */
  if (!action->private_data->short_label_set)
    action->private_data->short_label = g_strdup (action->private_data->label);

  g_object_notify (G_OBJECT (action), "short-label");
}

/**
 * gtk_action_get_short_label:
 * @action: a #GtkAction
 *
 * Gets the short label text of @action.
 *
 * Returns: the short label text.
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, which has no equivalent of short
 * labels
 */
const gchar *
gtk_action_get_short_label (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->short_label;
}

/**
 * gtk_action_set_visible_horizontal:
 * @action: a #GtkAction
 * @visible_horizontal: whether the action is visible horizontally
 *
 * Sets whether @action is visible when horizontal
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the
 * visibility of associated widgets and menu items directly
 */
void 
gtk_action_set_visible_horizontal (GtkAction *action,
				   gboolean   visible_horizontal)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  g_return_if_fail (GTK_IS_ACTION (action));

  visible_horizontal = visible_horizontal != FALSE;
  
  if (action->private_data->visible_horizontal != visible_horizontal)
    {
      action->private_data->visible_horizontal = visible_horizontal;
      
      g_object_notify (G_OBJECT (action), "visible-horizontal");
    }  
}

/**
 * gtk_action_get_visible_horizontal:
 * @action: a #GtkAction
 *
 * Checks whether @action is visible when horizontal
 * 
 * Returns: whether @action is visible when horizontal
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the
 * visibility of associated widgets and menu items directly
 */
gboolean 
gtk_action_get_visible_horizontal (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  return action->private_data->visible_horizontal;
}

/**
 * gtk_action_set_visible_vertical:
 * @action: a #GtkAction
 * @visible_vertical: whether the action is visible vertically
 *
 * Sets whether @action is visible when vertical 
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the
 * visibility of associated widgets and menu items directly
 */
void 
gtk_action_set_visible_vertical (GtkAction *action,
				 gboolean   visible_vertical)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  g_return_if_fail (GTK_IS_ACTION (action));

  visible_vertical = visible_vertical != FALSE;
  
  if (action->private_data->visible_vertical != visible_vertical)
    {
      action->private_data->visible_vertical = visible_vertical;
      
      g_object_notify (G_OBJECT (action), "visible-vertical");
    }  
}

/**
 * gtk_action_get_visible_vertical:
 * @action: a #GtkAction
 *
 * Checks whether @action is visible when horizontal
 * 
 * Returns: whether @action is visible when horizontal
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and control and monitor the
 * visibility of associated widgets and menu items directly
 */
gboolean 
gtk_action_get_visible_vertical (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);

  return action->private_data->visible_vertical;
}

/**
 * gtk_action_set_tooltip:
 * @action: a #GtkAction
 * @tooltip: the tooltip text
 *
 * Sets the tooltip text on @action
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and set tooltips on associated
 * #GtkActionable widgets with gtk_widget_set_tooltip_text()
 */
void 
gtk_action_set_tooltip (GtkAction   *action,
			const gchar *tooltip)
{
  gchar *tmp;

  g_return_if_fail (GTK_IS_ACTION (action));

  tmp = action->private_data->tooltip;
  action->private_data->tooltip = g_strdup (tooltip);
  g_free (tmp);

  g_object_notify (G_OBJECT (action), "tooltip");
}

/**
 * gtk_action_get_tooltip:
 * @action: a #GtkAction
 *
 * Gets the tooltip text of @action.
 *
 * Returns: the tooltip text
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and get tooltips from associated
 * #GtkActionable widgets with gtk_widget_get_tooltip_text()
 */
const gchar *
gtk_action_get_tooltip (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->tooltip;
}

/**
 * gtk_action_set_stock_id:
 * @action: a #GtkAction
 * @stock_id: the stock id
 *
 * Sets the stock id on @action
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, which has no equivalent of stock
 * items
 */
void 
gtk_action_set_stock_id (GtkAction   *action,
			 const gchar *stock_id)
{
  gchar *tmp;

  g_return_if_fail (GTK_IS_ACTION (action));

  g_return_if_fail (GTK_IS_ACTION (action));

  tmp = action->private_data->stock_id;
  action->private_data->stock_id = g_strdup (stock_id);
  g_free (tmp);

  g_object_notify (G_OBJECT (action), "stock-id");
  
  /* update label and short_label if appropriate */
  if (!action->private_data->label_set)
    {
      GtkStockItem stock_item;

      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

      if (action->private_data->stock_id &&
	  gtk_stock_lookup (action->private_data->stock_id, &stock_item))
	gtk_action_set_label (action, stock_item.label);
      else
	gtk_action_set_label (action, NULL);

      G_GNUC_END_IGNORE_DEPRECATIONS;

      action->private_data->label_set = FALSE;
    }
}

/**
 * gtk_action_get_stock_id:
 * @action: a #GtkAction
 *
 * Gets the stock id of @action.
 *
 * Returns: the stock id
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, which has no equivalent of stock
 * items
 */
const gchar *
gtk_action_get_stock_id (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->stock_id;
}

/**
 * gtk_action_set_icon_name:
 * @action: a #GtkAction
 * @icon_name: the icon name to set
 *
 * Sets the icon name on @action
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and g_menu_item_set_icon() to set an
 * icon on a #GMenuItem associated with a #GAction, or gtk_container_add() to
 * add a #GtkImage to a #GtkButton
 */
void 
gtk_action_set_icon_name (GtkAction   *action,
			  const gchar *icon_name)
{
  gchar *tmp;

  g_return_if_fail (GTK_IS_ACTION (action));

  tmp = action->private_data->icon_name;
  action->private_data->icon_name = g_strdup (icon_name);
  g_free (tmp);

  g_object_notify (G_OBJECT (action), "icon-name");
}

/**
 * gtk_action_get_icon_name:
 * @action: a #GtkAction
 *
 * Gets the icon name of @action.
 *
 * Returns: the icon name
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and
 * g_menu_item_get_attribute_value() to get an icon from a #GMenuItem
 * associated with a #GAction
 */
const gchar *
gtk_action_get_icon_name (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->icon_name;
}

/**
 * gtk_action_set_gicon:
 * @action: a #GtkAction
 * @icon: the #GIcon to set
 *
 * Sets the icon of @action.
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and g_menu_item_set_icon() to set an
 * icon on a #GMenuItem associated with a #GAction, or gtk_container_add() to
 * add a #GtkImage to a #GtkButton
 */
void
gtk_action_set_gicon (GtkAction *action,
                      GIcon     *icon)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  if (action->private_data->gicon)
    g_object_unref (action->private_data->gicon);

  action->private_data->gicon = icon;

  if (action->private_data->gicon)
    g_object_ref (action->private_data->gicon);

  g_object_notify (G_OBJECT (action), "gicon");
}

/**
 * gtk_action_get_gicon:
 * @action: a #GtkAction
 *
 * Gets the gicon of @action.
 *
 * Returns: (transfer none): The action's #GIcon if one is set.
 *
 * Since: 2.16
 *
 * Deprecated: 3.10: Use #GAction instead, and
 * g_menu_item_get_attribute_value() to get an icon from a #GMenuItem
 * associated with a #GAction
 */
GIcon *
gtk_action_get_gicon (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->gicon;
}

static void
closure_accel_activate (GClosure     *closure,
                        GValue       *return_value,
                        guint         n_param_values,
                        const GValue *param_values,
                        gpointer      invocation_hint,
                        gpointer      marshal_data)
{
  if (gtk_action_is_sensitive (GTK_ACTION (closure->data)))
    {
      _gtk_action_emit_activate (GTK_ACTION (closure->data));
      
      /* we handled the accelerator */
      g_value_set_boolean (return_value, TRUE);
    }
}

static void
gtk_action_set_action_group (GtkAction	    *action,
			     GtkActionGroup *action_group)
{
  if (action->private_data->action_group == NULL)
    g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
  else
    g_return_if_fail (action_group == NULL);

  action->private_data->action_group = action_group;
}

/**
 * gtk_action_set_accel_path:
 * @action: the action object
 * @accel_path: the accelerator path
 *
 * Sets the accel path for this action.  All proxy widgets associated
 * with the action will have this accel path, so that their
 * accelerators are consistent.
 *
 * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
 * pass a static string, you can save some memory by interning it first with 
 * g_intern_static_string().
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction and the accelerator path on an associated
 * #GtkMenu instead
 */
void
gtk_action_set_accel_path (GtkAction   *action, 
			   const gchar *accel_path)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  action->private_data->accel_quark = g_quark_from_string (accel_path);
}

/**
 * gtk_action_get_accel_path:
 * @action: the action object
 *
 * Returns the accel path for this action.  
 *
 * Since: 2.6
 *
 * Returns: the accel path for this action, or %NULL
 *   if none is set. The returned string is owned by GTK+ 
 *   and must not be freed or modified.
 *
 * Deprecated: 3.10: Use #GAction and the accelerator path on an associated
 * #GtkMenu instead
 */
const gchar *
gtk_action_get_accel_path (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  if (action->private_data->accel_quark)
    return g_quark_to_string (action->private_data->accel_quark);
  else
    return NULL;
}

/**
 * gtk_action_get_accel_closure:
 * @action: the action object
 *
 * Returns the accel closure for this action.
 *
 * Since: 2.8
 *
 * Returns: (transfer none): the accel closure for this action. The
 *          returned closure is owned by GTK+ and must not be unreffed
 *          or modified.
 *
 * Deprecated: 3.10: Use #GAction and #GtkMenu instead, which have no
 * equivalent for getting the accel closure
 */
GClosure *
gtk_action_get_accel_closure (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  return action->private_data->accel_closure;
}


/**
 * gtk_action_set_accel_group:
 * @action: the action object
 * @accel_group: (allow-none): a #GtkAccelGroup or %NULL
 *
 * Sets the #GtkAccelGroup in which the accelerator for this action
 * will be installed.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction and the accelerator group on an associated
 * #GtkMenu instead
 **/
void
gtk_action_set_accel_group (GtkAction     *action,
			    GtkAccelGroup *accel_group)
{
  g_return_if_fail (GTK_IS_ACTION (action));
  g_return_if_fail (accel_group == NULL || GTK_IS_ACCEL_GROUP (accel_group));
  
  if (accel_group)
    g_object_ref (accel_group);
  if (action->private_data->accel_group)
    g_object_unref (action->private_data->accel_group);

  action->private_data->accel_group = accel_group;
}

/**
 * gtk_action_connect_accelerator:
 * @action: a #GtkAction
 * 
 * Installs the accelerator for @action if @action has an
 * accel path and group. See gtk_action_set_accel_path() and 
 * gtk_action_set_accel_group()
 *
 * Since multiple proxies may independently trigger the installation
 * of the accelerator, the @action counts the number of times this
 * function has been called and doesn't remove the accelerator until
 * gtk_action_disconnect_accelerator() has been called as many times.
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction and the accelerator group on an associated
 * #GtkMenu instead
 **/
void 
gtk_action_connect_accelerator (GtkAction *action)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  if (!action->private_data->accel_quark ||
      !action->private_data->accel_group)
    return;

  if (action->private_data->accel_count == 0)
    {
      const gchar *accel_path = 
	g_quark_to_string (action->private_data->accel_quark);
      
      gtk_accel_group_connect_by_path (action->private_data->accel_group,
				       accel_path,
				       action->private_data->accel_closure);
    }

  action->private_data->accel_count++;
}

/**
 * gtk_action_disconnect_accelerator:
 * @action: a #GtkAction
 * 
 * Undoes the effect of one call to gtk_action_connect_accelerator().
 *
 * Since: 2.4
 *
 * Deprecated: 3.10: Use #GAction and the accelerator group on an associated
 * #GtkMenu instead
 **/
void 
gtk_action_disconnect_accelerator (GtkAction *action)
{
  g_return_if_fail (GTK_IS_ACTION (action));

  if (!action->private_data->accel_quark ||
      !action->private_data->accel_group)
    return;

  action->private_data->accel_count--;

  if (action->private_data->accel_count == 0)
    gtk_accel_group_disconnect (action->private_data->accel_group,
				action->private_data->accel_closure);
}

/**
 * gtk_action_create_menu:
 * @action: a #GtkAction
 *
 * If @action provides a #GtkMenu widget as a submenu for the menu
 * item or the toolbar item it creates, this function returns an
 * instance of that menu.
 *
 * Return value: (transfer none): the menu item provided by the
 *               action, or %NULL.
 *
 * Since: 2.12
 *
 * Deprecated: 3.10: Use #GAction and #GMenuModel instead, and create a
 * #GtkMenu with gtk_menu_new_from_model()
 */
GtkWidget *
gtk_action_create_menu (GtkAction *action)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  if (GTK_ACTION_GET_CLASS (action)->create_menu)
    return GTK_ACTION_GET_CLASS (action)->create_menu (action);

  return NULL;
}