Compare commits
349 Commits
ebassi/ci-
...
keymap.win
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e06176ae44 | ||
|
|
e47ddfb107 | ||
|
|
499e4b4c50 | ||
|
|
fd52220b1b | ||
|
|
e9438224ab | ||
|
|
2120e9df88 | ||
|
|
ddd16dd312 | ||
|
|
7624f66fec | ||
|
|
dab11ea841 | ||
|
|
a3f3dc0f1c | ||
|
|
5d59447ccb | ||
|
|
e3c38e4143 | ||
|
|
e5ec4df702 | ||
|
|
dbdc909e19 | ||
|
|
c6ef1943e4 | ||
|
|
a3c9f8594a | ||
|
|
354f2b65fa | ||
|
|
b3657d5f2e | ||
|
|
82ca65956f | ||
|
|
c8c2106f3e | ||
|
|
8178dfb85a | ||
|
|
50e78198a8 | ||
|
|
ee04cbcfa8 | ||
|
|
fc312f7ffe | ||
|
|
e6e964c3f3 | ||
|
|
df5e796d99 | ||
|
|
d3239c953d | ||
|
|
fb9a3bf32b | ||
|
|
ace83a938d | ||
|
|
fb028f0fe7 | ||
|
|
8a13909bab | ||
|
|
4e745f06e9 | ||
|
|
14b65a3c4f | ||
|
|
64ad490bc1 | ||
|
|
d2d7a4bcab | ||
|
|
14cbd13ef2 | ||
|
|
efc314196d | ||
|
|
403a70ca89 | ||
|
|
44b36b6321 | ||
|
|
4bd829e3e1 | ||
|
|
38f74d8a23 | ||
|
|
2613c2ef9b | ||
|
|
5751cd662d | ||
|
|
4039b713c3 | ||
|
|
c3f8010b19 | ||
|
|
3e8a22ae8a | ||
|
|
c01f3be6e6 | ||
|
|
0cf372c814 | ||
|
|
ac20c9cd41 | ||
|
|
d74c2a74e5 | ||
|
|
b79637ac41 | ||
|
|
e135772119 | ||
|
|
3cf26b471b | ||
|
|
c630285692 | ||
|
|
5702b71037 | ||
|
|
a4e5f5ca50 | ||
|
|
b0b00d49d2 | ||
|
|
cb018ec047 | ||
|
|
168b21c77e | ||
|
|
2dcc641d5a | ||
|
|
c8432ae668 | ||
|
|
642ad4e06f | ||
|
|
924796b478 | ||
|
|
319d4c7e01 | ||
|
|
07c491f235 | ||
|
|
970f91ec24 | ||
|
|
48381bd4f6 | ||
|
|
1a12999431 | ||
|
|
90676540ec | ||
|
|
7db58d5f8d | ||
|
|
875452b476 | ||
|
|
1c4c5e3b80 | ||
|
|
af5e13b9a1 | ||
|
|
9b78bc4af7 | ||
|
|
1702a4c223 | ||
|
|
f0e35c8ed8 | ||
|
|
26150d8489 | ||
|
|
48dcbf4935 | ||
|
|
59dd7d8900 | ||
|
|
c279bdaa81 | ||
|
|
01d52a7292 | ||
|
|
2b38d14bf5 | ||
|
|
d35a21873e | ||
|
|
b23cae9643 | ||
|
|
505df337c2 | ||
|
|
117997da54 | ||
|
|
19052d4360 | ||
|
|
2dbaca2464 | ||
|
|
4b8134b19b | ||
|
|
588fe5b5c1 | ||
|
|
b8f44de48e | ||
|
|
49bdc4f0c2 | ||
|
|
a0ee25a21e | ||
|
|
d8192013f3 | ||
|
|
8ed1f51f7f | ||
|
|
03fec389f4 | ||
|
|
38c39e2aa1 | ||
|
|
6298fd1eef | ||
|
|
5a77994516 | ||
|
|
6142238237 | ||
|
|
3164f328b5 | ||
|
|
ce78d0c301 | ||
|
|
94305f248b | ||
|
|
3afd5d7a89 | ||
|
|
d2adbad408 | ||
|
|
2df382277d | ||
|
|
9f71bdd045 | ||
|
|
838d0924b9 | ||
|
|
1f8d593931 | ||
|
|
574a3a456d | ||
|
|
3617fbab42 | ||
|
|
29ccd13e15 | ||
|
|
de9c9efa6f | ||
|
|
eb809ba425 | ||
|
|
adf60fb3a1 | ||
|
|
a3fd46c516 | ||
|
|
0040667965 | ||
|
|
60e67a62e6 | ||
|
|
931f130377 | ||
|
|
524fbc35a7 | ||
|
|
51d35750f6 | ||
|
|
90fde9c939 | ||
|
|
5cbc55578f | ||
|
|
f90e7b9c56 | ||
|
|
d5b9489408 | ||
|
|
975d763db1 | ||
|
|
907fc30fac | ||
|
|
25d2efeabe | ||
|
|
3a119a3d3a | ||
|
|
8df883ed71 | ||
|
|
0c49f7349d | ||
|
|
08004d4eed | ||
|
|
6d7e56bed6 | ||
|
|
8e6701c9a6 | ||
|
|
6d5c512571 | ||
|
|
b94ea1b4f7 | ||
|
|
b2d6011679 | ||
|
|
c0aa1c8a49 | ||
|
|
5fe837483c | ||
|
|
4f15b988e7 | ||
|
|
6cd3bc7384 | ||
|
|
0faadef36f | ||
|
|
af6c3017fb | ||
|
|
8157abe591 | ||
|
|
61e08baec1 | ||
|
|
0493e89897 | ||
|
|
c783e9aa5f | ||
|
|
4661f15fab | ||
|
|
e51a98d184 | ||
|
|
b67eee5741 | ||
|
|
d9259fc958 | ||
|
|
65f748fc62 | ||
|
|
bed3616bf0 | ||
|
|
1605ca0140 | ||
|
|
8692f5d8e3 | ||
|
|
42e2c54922 | ||
|
|
291c61891a | ||
|
|
59e08c0dac | ||
|
|
a70c9c69a0 | ||
|
|
dffe6b87e4 | ||
|
|
28b7962bee | ||
|
|
64e131f285 | ||
|
|
a9f0f18c3a | ||
|
|
2e0822bed0 | ||
|
|
b0fb31fc96 | ||
|
|
163d32eea1 | ||
|
|
b7728a884b | ||
|
|
86b4b2eef2 | ||
|
|
09eda804f7 | ||
|
|
37d4932b31 | ||
|
|
0fddf73ddb | ||
|
|
f981ab7a9e | ||
|
|
677ea5f22d | ||
|
|
fce455ae0b | ||
|
|
e050a2661c | ||
|
|
a03581ce39 | ||
|
|
13b9b9b7d8 | ||
|
|
0a3b370805 | ||
|
|
313ba0280a | ||
|
|
adb7676fc1 | ||
|
|
8ffb398517 | ||
|
|
9a943e21d3 | ||
|
|
7c106578ed | ||
|
|
d1d9b92aee | ||
|
|
434b145ee0 | ||
|
|
2546b88661 | ||
|
|
bba6d604f0 | ||
|
|
274f9ad919 | ||
|
|
89a8c89663 | ||
|
|
e7b290debb | ||
|
|
46e754a17d | ||
|
|
b12992c1cb | ||
|
|
374a451eeb | ||
|
|
1e13acb206 | ||
|
|
5b2b2feb9f | ||
|
|
77af993181 | ||
|
|
c5ed5c5ff9 | ||
|
|
6b53a55dd7 | ||
|
|
83fbdcd5e6 | ||
|
|
cb8bf6540c | ||
|
|
fdb1fa4d08 | ||
|
|
10d7ccc8e0 | ||
|
|
b973f7f375 | ||
|
|
7671c1074b | ||
|
|
6ce2e19bbe | ||
|
|
3a08706e40 | ||
|
|
e5722fe9d2 | ||
|
|
700f957d9a | ||
|
|
9109dee072 | ||
|
|
b6a843a05b | ||
|
|
ff1fb4f10d | ||
|
|
1bf79a4dae | ||
|
|
85d4b86545 | ||
|
|
98e88b7b53 | ||
|
|
85702f8f5d | ||
|
|
d97cb851f1 | ||
|
|
6dcdb4a601 | ||
|
|
41ef1d87ef | ||
|
|
44728d09a9 | ||
|
|
b1664534af | ||
|
|
56e89e8d26 | ||
|
|
f6ebc06767 | ||
|
|
3db5e15bde | ||
|
|
a2291fb989 | ||
|
|
af97f19926 | ||
|
|
0dae1f48fd | ||
|
|
c7dbb8ef91 | ||
|
|
3a1e019e83 | ||
|
|
a923be95b3 | ||
|
|
a11ab6c995 | ||
|
|
1d802881eb | ||
|
|
6c796cf201 | ||
|
|
44c6619660 | ||
|
|
ef7499a31b | ||
|
|
ed571ae68a | ||
|
|
e2b3cbac23 | ||
|
|
ba290eb9b0 | ||
|
|
3805e1d507 | ||
|
|
daf3b3a3b4 | ||
|
|
800eb76a2d | ||
|
|
bcbc6159f4 | ||
|
|
5f8c6d2287 | ||
|
|
88eb3a9c34 | ||
|
|
3e43dda9d4 | ||
|
|
f96a1cfadd | ||
|
|
758bcd5343 | ||
|
|
2bfd4196fb | ||
|
|
1b7a99cb24 | ||
|
|
087c0078ca | ||
|
|
b9ae54c951 | ||
|
|
7ac6e25ffc | ||
|
|
d3089ebbc2 | ||
|
|
14a64c7372 | ||
|
|
ca9b06878d | ||
|
|
8f100269ad | ||
|
|
48bb9200d9 | ||
|
|
d7794bf608 | ||
|
|
3151906157 | ||
|
|
6153efd02a | ||
|
|
b5b8f42a0c | ||
|
|
043ffd38bc | ||
|
|
32b826e312 | ||
|
|
700ca3b946 | ||
|
|
e45dd771db | ||
|
|
698cbee1fb | ||
|
|
80756322cd | ||
|
|
f1e14c4858 | ||
|
|
8d46bd1d7c | ||
|
|
fbb08a30e2 | ||
|
|
81371e7c79 | ||
|
|
7702670d86 | ||
|
|
9e4316bf96 | ||
|
|
4ea2a6628f | ||
|
|
39dfdac771 | ||
|
|
b7fa00e22d | ||
|
|
3df0a333ad | ||
|
|
8880e3bd2e | ||
|
|
0b5b908a74 | ||
|
|
31a072497d | ||
|
|
cbb6828657 | ||
|
|
8e170217a1 | ||
|
|
36d4a8090f | ||
|
|
341244203f | ||
|
|
2023914186 | ||
|
|
ef9ec43469 | ||
|
|
67411701c6 | ||
|
|
e20a3339bf | ||
|
|
a8baee342c | ||
|
|
6a1cb3304b | ||
|
|
45400fe381 | ||
|
|
5504278b78 | ||
|
|
93481e6c2e | ||
|
|
b9e9898212 | ||
|
|
7c47b6907b | ||
|
|
b10d5ec8ff | ||
|
|
8dad615f04 | ||
|
|
23e086089d | ||
|
|
9317a9f35c | ||
|
|
22100089c3 | ||
|
|
074d54ef5a | ||
|
|
ddd1b0958d | ||
|
|
d77902365d | ||
|
|
d9b216e629 | ||
|
|
a7bd6b094a | ||
|
|
eeae1b1ea7 | ||
|
|
0a71dc1bed | ||
|
|
feb73a5ebb | ||
|
|
83d8ae2f30 | ||
|
|
51f5690ae3 | ||
|
|
e58e6a0fbe | ||
|
|
eb82b2a9ca | ||
|
|
dfc7d26275 | ||
|
|
77d1026c5a | ||
|
|
08ae513064 | ||
|
|
f52c86ae21 | ||
|
|
03745a489c | ||
|
|
63421b1876 | ||
|
|
80e0e3fe4f | ||
|
|
ef46fe0e8e | ||
|
|
7c7dabae8c | ||
|
|
9f9e7dffef | ||
|
|
94729b4880 | ||
|
|
3918dd4643 | ||
|
|
04a51837f7 | ||
|
|
75a0bef921 | ||
|
|
d50ebd947c | ||
|
|
8e4f8a45a9 | ||
|
|
3ad03b1706 | ||
|
|
dfe00c4ac4 | ||
|
|
5bb656af4c | ||
|
|
469b913cdf | ||
|
|
9c1c8a554a | ||
|
|
2359510b1f | ||
|
|
25a1c421b5 | ||
|
|
ef308e5f17 | ||
|
|
33f0809784 | ||
|
|
81ee273e98 | ||
|
|
f3fe1812aa | ||
|
|
be8246a6cb | ||
|
|
25d0fb4c76 | ||
|
|
98b66acbdd | ||
|
|
1976df1e54 | ||
|
|
39baf4fff4 | ||
|
|
a88e5a5f4e | ||
|
|
a39e519bed | ||
|
|
a4aa6d79ad | ||
|
|
ea3933b87a | ||
|
|
6ae9f7e7c3 | ||
|
|
efbbfb6547 |
76
NEWS
@@ -1,3 +1,79 @@
|
||||
Overview of Changes in master
|
||||
=============================
|
||||
|
||||
* GtkColumnView:
|
||||
- Improve column resizing
|
||||
- Make double-click reset column widths
|
||||
- Move header outside of scrollbars
|
||||
|
||||
* GtkSearchEntry:
|
||||
- Add an icon
|
||||
|
||||
* GtkDropDown:
|
||||
- Polish the appearance
|
||||
|
||||
* GtkColorChooser:
|
||||
- Accessibility improvements
|
||||
|
||||
* GtkPopoverMenu:
|
||||
- Add accessibility support
|
||||
- Allow custom items. This adds new API:
|
||||
gtk_popover_menu_add/remove_child
|
||||
gtk_popover_menu_bar_add/remove_child
|
||||
|
||||
* GtkTextView:
|
||||
- Fix rendering and positioning of anchored children
|
||||
|
||||
* Constraints:
|
||||
- Fix loading constraints from ui files
|
||||
|
||||
* Media support:
|
||||
- Use cubic instead of linear volume
|
||||
|
||||
* Accessibility:
|
||||
- Implement Component for all widgets
|
||||
- Implement Text and EditableText for all editables
|
||||
- Rework accessible name/description computation
|
||||
- Add documentation for app and widget developers
|
||||
- Handle HIDDEN state changes by adding/removing elements
|
||||
- Support setting accessibility attributes in ui files
|
||||
|
||||
* Introspection:
|
||||
- Add some missing annotations
|
||||
|
||||
* gdk:
|
||||
- Deliver events on flush
|
||||
- Drop the unused GdkPoint struct from the API
|
||||
|
||||
* Demos:
|
||||
- Add another constraints demo
|
||||
- Tweak various demos to improve consistency
|
||||
|
||||
* Tools:
|
||||
- Improve gtk4-builder-tool handling of various
|
||||
widgets when converting ui files from GTK 3
|
||||
|
||||
* Documentation:
|
||||
- Use GtkApplication in all examples
|
||||
- Improve and expand the widget gallery
|
||||
|
||||
* Testsuite:
|
||||
- Improve coverage of GDK
|
||||
- Improve coverage of gtk4-builder-tool
|
||||
|
||||
* Build:
|
||||
- Fix the build with cups 2.2.12
|
||||
- Make cloudprint support build without warnings
|
||||
|
||||
* OS X:
|
||||
- Fix various input issues
|
||||
- Make GtkGLArea work (with the cairo backend)
|
||||
|
||||
* Translation updates:
|
||||
German
|
||||
Polish
|
||||
|
||||
|
||||
Overview of Changes in 3.99.3
|
||||
=============================
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* always defined to indicate that i18n is enabled */
|
||||
#define ENABLE_NLS 1
|
||||
|
||||
/* Use structured logging */
|
||||
#define G_LOG_STRUCTURED 1
|
||||
|
||||
/* The prefix for our gettext translation domains. */
|
||||
#mesondefine GETTEXT_PACKAGE
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
/* Constraints/Simple
|
||||
/* Constraints/Simple Constraints
|
||||
* #Keywords: GtkLayoutManager
|
||||
*
|
||||
* GtkConstraintLayout provides a layout manager that uses relations
|
||||
* between widgets (also known as "constraints") to compute the position
|
||||
* between widgets (also known as “constraints”) to compute the position
|
||||
* and size of each child.
|
||||
*
|
||||
* In addition to child widgets, the constraints can involve spacer
|
||||
* objects (also known as “guides”). This example has a guide between
|
||||
* the two buttons in the top row.
|
||||
*
|
||||
* Try resizing the window to see how the constraints react to update
|
||||
* the layout.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -234,15 +241,12 @@ simple_grid_init (SimpleGrid *self)
|
||||
|
||||
self->button1 = gtk_button_new_with_label ("Child 1");
|
||||
gtk_widget_set_parent (self->button1, widget);
|
||||
gtk_widget_set_name (self->button1, "button1");
|
||||
|
||||
self->button2 = gtk_button_new_with_label ("Child 2");
|
||||
gtk_widget_set_parent (self->button2, widget);
|
||||
gtk_widget_set_name (self->button2, "button2");
|
||||
|
||||
self->button3 = gtk_button_new_with_label ("Child 3");
|
||||
gtk_widget_set_parent (self->button3, widget);
|
||||
gtk_widget_set_name (self->button3, "button3");
|
||||
|
||||
GtkLayoutManager *manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
||||
build_constraints (self, GTK_CONSTRAINT_LAYOUT (manager));
|
||||
@@ -259,7 +263,8 @@ do_constraints (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Simple Constraints");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
106
demos/gtk-demo/constraints.ui
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="title" translatable="yes">Constraints — Builder</property>
|
||||
<property name="default-width">260</property>
|
||||
<child>
|
||||
<object class="ConstraintsGrid">
|
||||
<property name="layout-manager">
|
||||
<object class="GtkConstraintLayout">
|
||||
<constraints>
|
||||
<guide name="space"
|
||||
min-width="10" min-height="10"
|
||||
nat-width="100" nat-height="10"
|
||||
max-width="200" max-height="20"
|
||||
strength="strong"/>
|
||||
<constraint target="button1" target-attribute="width"
|
||||
relation="le"
|
||||
constant="200"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="start"
|
||||
relation="eq"
|
||||
source="button1" source-attribute="start"
|
||||
constant="-8"
|
||||
strength="required"/>
|
||||
<constraint target="button1" target-attribute="width"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="width"
|
||||
strength="required"/>
|
||||
<constraint target="button1" target-attribute="end"
|
||||
relation="eq"
|
||||
source="space" source-attribute="start"
|
||||
strength="required"/>
|
||||
<constraint target="space" target-attribute="end"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="start"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="end"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="end"
|
||||
constant="8"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="start"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="start"
|
||||
constant="-8"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="end"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="end"
|
||||
constant="8"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="top"
|
||||
relation="eq"
|
||||
source="button1" source-attribute="top"
|
||||
constant="-8"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="top"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="top"
|
||||
constant="-8"
|
||||
strength="required"/>
|
||||
<constraint target="button1" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="top"
|
||||
constant="-12"
|
||||
strength="required"/>
|
||||
<constraint target="button2" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="top"
|
||||
constant="-12"
|
||||
strength="required"/>
|
||||
<constraint target="button3" target-attribute="height"
|
||||
relation="eq"
|
||||
source="button1" source-attribute="height"
|
||||
strength="required"/>
|
||||
<constraint target="button3" target-attribute="height"
|
||||
relation="eq"
|
||||
source="button2" source-attribute="height"
|
||||
strength="required"/>
|
||||
<constraint target="super" target-attribute="bottom"
|
||||
relation="eq"
|
||||
source="button3" source-attribute="bottom"
|
||||
constant="8"
|
||||
strength="required"/>
|
||||
</constraints>
|
||||
</object>
|
||||
</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">Child 1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label">Child 2</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button3">
|
||||
<property name="label">Child 3</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Constraints/Interactive
|
||||
/* Constraints/Interactive Constraints
|
||||
* #Keywords: GtkConstraintLayout
|
||||
*
|
||||
* Demonstrate how constraints can be updates during user interaction.
|
||||
* This example shows how constraints can be updated during user interaction.
|
||||
* The vertical edge between the buttons can be dragged with the mouse.
|
||||
*/
|
||||
|
||||
@@ -215,7 +215,8 @@ do_constraints2 (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Interactive Constraints");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
*
|
||||
* GtkConstraintLayout allows defining constraints using a
|
||||
* compact syntax called Visual Format Language, or VFL.
|
||||
*
|
||||
* A typical example of a VFL specification looks like this:
|
||||
*
|
||||
* H:|-[button1(==button2)]-12-[button2]-|
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
@@ -134,7 +138,8 @@ do_constraints3 (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Constraints — VFL");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
|
||||
72
demos/gtk-demo/constraints4.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Constraints/Builder
|
||||
*
|
||||
* GtkConstraintLayouts can be created in .ui files, and constraints can be
|
||||
* set up at that time as well, as this example demonstrates. It uses the
|
||||
* same setup as the “Simple” constraints demo.
|
||||
*/
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_DECLARE_FINAL_TYPE (ConstraintsGrid, constraints_grid, CONSTRAINTS, GRID, GtkWidget)
|
||||
|
||||
struct _ConstraintsGrid
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ConstraintsGrid, constraints_grid, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
constraints_grid_init (ConstraintsGrid *grid)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
constraints_grid_dispose (GObject *object)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (object);
|
||||
GtkWidget *child;
|
||||
|
||||
while ((child = gtk_widget_get_first_child (widget)))
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
G_OBJECT_CLASS (constraints_grid_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
constraints_grid_class_init (ConstraintsGridClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = constraints_grid_dispose;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_constraints4 (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
|
||||
g_type_ensure (constraints_grid_get_type ());
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/constraints4/constraints.ui");
|
||||
|
||||
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
return window;
|
||||
}
|
||||
@@ -18,6 +18,9 @@
|
||||
<file>demoimage.c</file>
|
||||
<file>demoimage.h</file>
|
||||
</gresource>
|
||||
<gresource prefix="/constraints4">
|
||||
<file>constraints.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/css_accordion">
|
||||
<file>css_accordion.css</file>
|
||||
<file>reset.css</file>
|
||||
@@ -226,9 +229,12 @@
|
||||
<file>revealer.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/images">
|
||||
<file>pixbufpaintable.h</file>
|
||||
<file>pixbufpaintable.c</file>
|
||||
<file>alphatest.png</file>
|
||||
<file>floppybuddy.gif</file>
|
||||
<file>gtk-logo.webm</file>
|
||||
<file alias="org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
|
||||
</gresource>
|
||||
<gresource prefix="/video-player">
|
||||
<file>bbb.png</file>
|
||||
@@ -242,6 +248,7 @@
|
||||
<file>constraints.c</file>
|
||||
<file>constraints2.c</file>
|
||||
<file>constraints3.c</file>
|
||||
<file>constraints4.c</file>
|
||||
<file>css_accordion.c</file>
|
||||
<file>css_basics.c</file>
|
||||
<file>css_blendmodes.c</file>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
</menu>
|
||||
<object class="GtkAboutDialog" id="aboutdialog1">
|
||||
<property name="program-name" translatable="yes">Builder demo</property>
|
||||
<property name="logo-icon-name" translatable="yes">gtk3-demo</property>
|
||||
<property name="logo-icon-name" translatable="yes">org.gtk.Demo4</property>
|
||||
<property name="modal">True</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="window1">
|
||||
|
||||
@@ -44,11 +44,23 @@ G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
|
||||
static void
|
||||
demo_tagged_entry_init (DemoTaggedEntry *entry)
|
||||
{
|
||||
GtkCssProvider *provider;
|
||||
|
||||
entry->text = gtk_text_new ();
|
||||
gtk_widget_set_hexpand (entry->text, TRUE);
|
||||
gtk_widget_set_vexpand (entry->text, TRUE);
|
||||
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
|
||||
gtk_editable_init_delegate (GTK_EDITABLE (entry));
|
||||
gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
|
||||
gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
|
||||
gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -116,6 +128,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, "entry");
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX);
|
||||
}
|
||||
|
||||
static GtkEditable *
|
||||
@@ -211,7 +224,6 @@ static void
|
||||
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
|
||||
@@ -221,13 +233,6 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
|
||||
gesture = gtk_gesture_click_new ();
|
||||
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -113,12 +113,9 @@ apply_transform (CanvasItem *item)
|
||||
y = gtk_widget_get_allocated_height (item->label) / 2.0;
|
||||
item->r = sqrt (x*x + y*y);
|
||||
|
||||
transform = gsk_transform_translate (
|
||||
gsk_transform_rotate (
|
||||
gsk_transform_translate (NULL,
|
||||
&(graphene_point_t) { item->r, item->r }),
|
||||
item->angle + item->delta),
|
||||
&(graphene_point_t) { - x, - y });
|
||||
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
|
||||
transform = gsk_transform_rotate (transform, item->angle + item->delta);
|
||||
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
|
||||
|
||||
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
@@ -325,9 +325,8 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
/*
|
||||
* Create the groups area
|
||||
*/
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Knockout groups</u>");
|
||||
label = gtk_label_new ("Knockout groups");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -344,9 +343,8 @@ do_drawingarea (GtkWidget *do_widget)
|
||||
* Create the scribble area
|
||||
*/
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Scribble area</u>");
|
||||
label = gtk_label_new ("Scribble area");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
|
||||
@@ -65,18 +65,22 @@ strings_setup_item_single_line (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box, *image, *title;
|
||||
GtkWidget *checkmark;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
|
||||
image = gtk_image_new ();
|
||||
title = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
|
||||
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
|
||||
|
||||
gtk_box_append (GTK_BOX (box), image);
|
||||
gtk_box_append (GTK_BOX (box), title);
|
||||
gtk_box_append (GTK_BOX (box), checkmark);
|
||||
|
||||
g_object_set_data (G_OBJECT (item), "title", title);
|
||||
g_object_set_data (G_OBJECT (item), "image", image);
|
||||
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
@@ -86,6 +90,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box, *box2, *image, *title, *description;
|
||||
GtkWidget *checkmark;
|
||||
|
||||
image = gtk_image_new ();
|
||||
title = gtk_label_new ("");
|
||||
@@ -93,6 +98,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
description = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
|
||||
gtk_widget_add_css_class (description, "dim-label");
|
||||
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
@@ -101,26 +107,48 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
gtk_box_append (GTK_BOX (box), box2);
|
||||
gtk_box_append (GTK_BOX (box2), title);
|
||||
gtk_box_append (GTK_BOX (box2), description);
|
||||
gtk_box_append (GTK_BOX (box), checkmark);
|
||||
|
||||
g_object_set_data (G_OBJECT (item), "title", title);
|
||||
g_object_set_data (G_OBJECT (item), "image", image);
|
||||
g_object_set_data (G_OBJECT (item), "description", description);
|
||||
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
|
||||
static void
|
||||
strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
selected_item_changed (GtkDropDown *dropdown,
|
||||
GParamSpec *pspec,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *checkmark;
|
||||
|
||||
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
|
||||
|
||||
if (gtk_drop_down_get_selected_item (dropdown) == gtk_list_item_get_item (item))
|
||||
gtk_widget_set_opacity (checkmark, 1.0);
|
||||
else
|
||||
gtk_widget_set_opacity (checkmark, 0.0);
|
||||
}
|
||||
|
||||
static void
|
||||
strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkDropDown *dropdown = data;
|
||||
GtkWidget *image, *title, *description;
|
||||
GtkWidget *checkmark;
|
||||
StringHolder *holder;
|
||||
GtkWidget *popup;
|
||||
|
||||
holder = gtk_list_item_get_item (item);
|
||||
|
||||
title = g_object_get_data (G_OBJECT (item), "title");
|
||||
image = g_object_get_data (G_OBJECT (item), "image");
|
||||
description = g_object_get_data (G_OBJECT (item), "description");
|
||||
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (title), holder->title);
|
||||
if (image)
|
||||
@@ -133,19 +161,43 @@ strings_bind_item (GtkSignalListItemFactory *factory,
|
||||
gtk_label_set_label (GTK_LABEL (description), holder->description);
|
||||
gtk_widget_set_visible (description , holder->description != NULL);
|
||||
}
|
||||
|
||||
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
|
||||
if (popup && gtk_widget_is_ancestor (popup, GTK_WIDGET (dropdown)))
|
||||
{
|
||||
gtk_widget_show (checkmark);
|
||||
g_signal_connect (dropdown, "notify::selected-item",
|
||||
G_CALLBACK (selected_item_changed), item);
|
||||
selected_item_changed (dropdown, NULL, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_hide (checkmark);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
strings_unbind_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item,
|
||||
gpointer data)
|
||||
{
|
||||
GtkDropDown *dropdown = data;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (dropdown, selected_item_changed, list_item);
|
||||
}
|
||||
|
||||
static GtkListItemFactory *
|
||||
strings_factory_new (gboolean full)
|
||||
strings_factory_new (gpointer data, gboolean full)
|
||||
{
|
||||
GtkListItemFactory *factory;
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
if (full)
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), NULL);
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), data);
|
||||
else
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), NULL);
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), data);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), data);
|
||||
g_signal_connect (factory, "unbind", G_CALLBACK (strings_unbind_item), data);
|
||||
|
||||
return factory;
|
||||
}
|
||||
@@ -186,19 +238,22 @@ drop_down_new_from_strings (const char *const *titles,
|
||||
g_return_val_if_fail (descriptions == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)descriptions), NULL);
|
||||
|
||||
model = strings_model_new (titles, icons, descriptions);
|
||||
factory = strings_factory_new (FALSE);
|
||||
widget = g_object_new (GTK_TYPE_DROP_DOWN,
|
||||
"model", model,
|
||||
NULL);
|
||||
g_object_unref (model);
|
||||
|
||||
factory = strings_factory_new (widget, FALSE);
|
||||
if (icons != NULL || descriptions != NULL)
|
||||
list_factory = strings_factory_new (TRUE);
|
||||
list_factory = strings_factory_new (widget, TRUE);
|
||||
else
|
||||
list_factory = NULL;
|
||||
|
||||
widget = g_object_new (GTK_TYPE_DROP_DOWN,
|
||||
"model", model,
|
||||
"factory", factory,
|
||||
"list-factory", list_factory,
|
||||
NULL);
|
||||
g_object_set (widget,
|
||||
"factory", factory,
|
||||
"list-factory", list_factory,
|
||||
NULL);
|
||||
|
||||
g_object_unref (model);
|
||||
g_object_unref (factory);
|
||||
if (list_factory)
|
||||
g_object_unref (list_factory);
|
||||
|
||||
@@ -78,11 +78,11 @@ do_entry_completion (GtkWidget *do_widget)
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
|
||||
@@ -27,16 +27,16 @@ do_entry_undo (GtkWidget *do_widget)
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"Use Primary+z or Primary+Shift+z to undo or redo changes");
|
||||
"Use Control+z or Control+Shift+z to undo or redo changes");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
/* Create our entry */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Error states
|
||||
/* Error States
|
||||
*
|
||||
* GtkLabel and GtkEntry can indicate errors if you set the .error
|
||||
* style class on them.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<property name="modal">1</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="use-header-bar">1</property>
|
||||
<property name="title" translatable="yes">Settings</property>
|
||||
<property name="title" translatable="yes">Error States</property>
|
||||
<property name="hide-on-close">1</property>
|
||||
<child internal-child="content_area">
|
||||
<object class="GtkBox">
|
||||
|
||||
@@ -1068,7 +1068,6 @@ update_font_variations (void)
|
||||
unsigned int length;
|
||||
int i;
|
||||
|
||||
child = gtk_widget_get_first_child (variations_grid);
|
||||
while ((child = gtk_widget_get_first_child (variations_grid)))
|
||||
gtk_grid_remove (GTK_GRID (variations_grid), child);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Pango/Font rendering
|
||||
/* Pango/Font Rendering
|
||||
*
|
||||
* Demonstrates various aspects of font rendering.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* OpenGL/Transitions
|
||||
/* OpenGL/Transitions and Effects
|
||||
* #Keywords: OpenGL, shader, effect
|
||||
*
|
||||
* Create transitions between pages using a custom fragment shader.
|
||||
@@ -282,11 +282,12 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Transitions");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Transitions and Effects");
|
||||
headerbar = gtk_header_bar_new ();
|
||||
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
||||
gtk_widget_set_size_request (scale, 100, -1);
|
||||
gtk_widget_set_tooltip_text (scale, "Transition duration");
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <glib/gstdio.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "pixbufpaintable.h"
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GdkPixbufLoader *pixbuf_loader = NULL;
|
||||
@@ -56,6 +57,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), NULL);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
}
|
||||
|
||||
@@ -262,7 +264,7 @@ start_progressive_loading (GtkWidget *picture)
|
||||
* The timeout simply simulates a slow data source by inserting
|
||||
* pauses in the reading process.
|
||||
*/
|
||||
load_timeout = g_timeout_add (1500, progressive_timeout, picture);
|
||||
load_timeout = g_timeout_add (300, progressive_timeout, picture);
|
||||
g_source_set_name_by_id (load_timeout, "[gtk] progressive_timeout");
|
||||
}
|
||||
|
||||
@@ -345,9 +347,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Image loaded from a file</u>");
|
||||
label = gtk_label_new ("Image from a resource");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -355,7 +356,7 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
image = gtk_image_new_from_icon_name ("gtk3-demo");
|
||||
image = gtk_image_new_from_resource ("/images/org.gtk.Demo4.svg");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
|
||||
gtk_frame_set_child (GTK_FRAME (frame), image);
|
||||
@@ -363,9 +364,8 @@ do_images (GtkWidget *do_widget)
|
||||
|
||||
/* Animation */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Animation loaded from a file</u>");
|
||||
label = gtk_label_new ("Animation from a resource");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -373,15 +373,16 @@ do_images (GtkWidget *do_widget)
|
||||
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), frame);
|
||||
|
||||
picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");
|
||||
paintable = pixbuf_paintable_new_from_resource ("/images/floppybuddy.gif");
|
||||
picture = gtk_picture_new_for_paintable (paintable);
|
||||
g_object_unref (paintable);
|
||||
|
||||
gtk_frame_set_child (GTK_FRAME (frame), picture);
|
||||
|
||||
/* Symbolic icon */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Symbolic themed icon</u>");
|
||||
label = gtk_label_new ("Symbolic themed icon");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -400,9 +401,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Progressive image loading</u>");
|
||||
label = gtk_label_new ("Progressive image loading");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -414,6 +414,7 @@ do_images (GtkWidget *do_widget)
|
||||
* will create the pixbuf and fill it in.
|
||||
*/
|
||||
picture = gtk_picture_new ();
|
||||
gtk_picture_set_alternative_text (GTK_PICTURE (picture), "A slowly loading image");
|
||||
gtk_frame_set_child (GTK_FRAME (frame), picture);
|
||||
|
||||
start_progressive_loading (picture);
|
||||
@@ -422,9 +423,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Displaying video</u>");
|
||||
label = gtk_label_new ("Displaying video");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@@ -440,9 +440,8 @@ do_images (GtkWidget *do_widget)
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>GtkWidgetPaintable</u>");
|
||||
label = gtk_label_new ("GtkWidgetPaintable");
|
||||
gtk_widget_add_css_class (label, "heading");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
paintable = gtk_widget_paintable_new (do_widget);
|
||||
|
||||
@@ -34,7 +34,7 @@ do_layoutmanager (GtkWidget *parent)
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager—Transition");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transition");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ do_layoutmanager2 (GtkWidget *parent)
|
||||
int i;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager—Transformation");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transformation");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 620);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* List Box/Complex list
|
||||
/* List Box/Complex
|
||||
*
|
||||
* GtkListBox allows lists with complicated layouts, using
|
||||
* regular widgets supporting sorting and filtering.
|
||||
@@ -197,7 +197,7 @@ gtk_message_row_update (GtkMessageRow *row)
|
||||
|
||||
if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0)
|
||||
{
|
||||
gtk_image_set_from_icon_name (priv->avatar_image, "gtk3-demo");
|
||||
gtk_image_set_from_icon_name (priv->avatar_image, "org.gtk.Demo4");
|
||||
gtk_image_set_icon_size (priv->avatar_image, GTK_ICON_SIZE_LARGE);
|
||||
}
|
||||
else
|
||||
@@ -349,7 +349,7 @@ do_listbox (GtkWidget *do_widget)
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "List Box — Complex");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ demos = files([
|
||||
'constraints.c',
|
||||
'constraints2.c',
|
||||
'constraints3.c',
|
||||
'constraints4.c',
|
||||
'css_accordion.c',
|
||||
'css_basics.c',
|
||||
'css_blendmodes.c',
|
||||
@@ -118,7 +119,8 @@ extra_demo_sources = files(['main.c',
|
||||
'singular_value_decomposition.c',
|
||||
'four_point_transform.c',
|
||||
'demo2widget.c',
|
||||
'demo3widget.c'])
|
||||
'demo3widget.c',
|
||||
'pixbufpaintable.c'])
|
||||
|
||||
if harfbuzz_dep.found() and pangoft_dep.found()
|
||||
demos += files(['font_features.c', 'listview_ucd.c'])
|
||||
@@ -160,7 +162,7 @@ executable('gtk4-demo',
|
||||
c_args: gtkdemo_args + demo_cflags,
|
||||
dependencies: gtkdemo_deps,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
# gui_app: true,
|
||||
link_args: extra_demo_ldflags,
|
||||
install: true)
|
||||
|
||||
@@ -169,7 +171,7 @@ executable('gtk4-demo-application',
|
||||
c_args: gtkdemo_args + common_cflags,
|
||||
dependencies: gtkdemo_deps,
|
||||
include_directories: confinc,
|
||||
gui_app: true,
|
||||
# gui_app: true,
|
||||
link_args: extra_demo_ldflags,
|
||||
install: true)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Paintable/A simple paintable
|
||||
/* Paintable/Simple Paintable
|
||||
*
|
||||
* GdkPaintable is an interface used by GTK for drawings of any sort
|
||||
* that do not require layouting or positioning.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Paintable/An animated paintable
|
||||
/* Paintable/Animated Paintable
|
||||
*
|
||||
* GdkPaintable also allows paintables to change.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Paintable/A media stream
|
||||
/* Paintable/Media Stream
|
||||
*
|
||||
* GdkPaintable is also used by the GtkMediaStream class.
|
||||
*
|
||||
|
||||
@@ -3,100 +3,16 @@
|
||||
* The GtkPaned Widget divides its content area into two panes
|
||||
* with a divider in between that the user can adjust. A separate
|
||||
* child is placed into each pane. GtkPaned widgets can be split
|
||||
* horizontally or vertially.
|
||||
* horizontally or vertically. This test contains both a horizontal
|
||||
* and a vertical GtkPaned widget.
|
||||
*
|
||||
* There are a number of options that can be set for each pane.
|
||||
* This test contains both a horizontal and a vertical GtkPaned
|
||||
* widget, and allows you to adjust the options for each side of
|
||||
* each widget.
|
||||
* You can use the Inspector to adjust the options for each side
|
||||
* of each widget.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
toggle_resize (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkPaned *paned;
|
||||
|
||||
parent = gtk_widget_get_parent (child);
|
||||
paned = GTK_PANED (parent);
|
||||
|
||||
if (child == gtk_paned_get_start_child (paned))
|
||||
gtk_paned_set_resize_start_child (paned, !gtk_paned_get_resize_start_child (paned));
|
||||
else
|
||||
gtk_paned_set_resize_end_child (paned, !gtk_paned_get_resize_end_child (paned));
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_shrink (GtkWidget *widget,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkPaned *paned;
|
||||
|
||||
parent = gtk_widget_get_parent (child);
|
||||
paned = GTK_PANED (parent);
|
||||
|
||||
if (child == gtk_paned_get_start_child (paned))
|
||||
gtk_paned_set_shrink_start_child (paned, !gtk_paned_get_shrink_start_child (paned));
|
||||
else
|
||||
gtk_paned_set_shrink_end_child (paned, !gtk_paned_get_shrink_end_child (paned));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_pane_options (GtkPaned *paned,
|
||||
const char *frame_label,
|
||||
const char *label1,
|
||||
const char *label2)
|
||||
{
|
||||
GtkWidget *child1, *child2;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *check_button;
|
||||
|
||||
child1 = gtk_paned_get_start_child (paned);
|
||||
child2 = gtk_paned_get_end_child (paned);
|
||||
|
||||
frame = gtk_frame_new (frame_label);
|
||||
|
||||
table = gtk_grid_new ();
|
||||
gtk_frame_set_child (GTK_FRAME (frame), table);
|
||||
|
||||
label = gtk_label_new (label1);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child1);
|
||||
|
||||
label = gtk_label_new (label2);
|
||||
gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_resize), child2);
|
||||
|
||||
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
|
||||
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
|
||||
g_signal_connect (check_button, "toggled",
|
||||
G_CALLBACK (toggle_shrink), child2);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_panes (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -104,19 +20,19 @@ do_panes (GtkWidget *do_widget)
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hpaned;
|
||||
GtkWidget *vpaned;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *box;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 330, 250);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_widget_set_margin_start (vbox, 8);
|
||||
gtk_widget_set_margin_end (vbox, 8);
|
||||
@@ -132,41 +48,37 @@ do_panes (GtkWidget *do_widget)
|
||||
|
||||
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_paned_set_start_child (GTK_PANED (vpaned), hpaned);
|
||||
gtk_paned_set_shrink_start_child (GTK_PANED (vpaned), FALSE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 60, 60);
|
||||
gtk_paned_set_start_child (GTK_PANED (hpaned), box);
|
||||
label = gtk_label_new ("Hi there");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_start_child (GTK_PANED (hpaned), label);
|
||||
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Hi there");
|
||||
gtk_widget_set_margin_start (button, 4);
|
||||
gtk_widget_set_margin_end (button, 4);
|
||||
gtk_widget_set_margin_top (button, 4);
|
||||
gtk_widget_set_margin_bottom (button, 4);
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
label = gtk_label_new ("Hello");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_end_child (GTK_PANED (hpaned), label);
|
||||
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 80, 60);
|
||||
gtk_paned_set_end_child (GTK_PANED (hpaned), box);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_widget_set_size_request (box, 60, 80);
|
||||
gtk_paned_set_end_child (GTK_PANED (vpaned), box);
|
||||
|
||||
/* Now create toggle buttons to control sizing */
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
create_pane_options (GTK_PANED (hpaned),
|
||||
"Horizontal",
|
||||
"Left",
|
||||
"Right"));
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox),
|
||||
create_pane_options (GTK_PANED (vpaned),
|
||||
"Vertical",
|
||||
"Top",
|
||||
"Bottom"));
|
||||
label = gtk_label_new ("Goodbye");
|
||||
gtk_widget_set_margin_start (label, 4);
|
||||
gtk_widget_set_margin_end (label, 4);
|
||||
gtk_widget_set_margin_top (label, 4);
|
||||
gtk_widget_set_margin_bottom (label, 4);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_paned_set_end_child (GTK_PANED (vpaned), label);
|
||||
gtk_paned_set_shrink_end_child (GTK_PANED (vpaned), FALSE);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
187
demos/gtk-demo/pixbufpaintable.c
Normal file
@@ -0,0 +1,187 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "pixbufpaintable.h"
|
||||
|
||||
struct _PixbufPaintable {
|
||||
GObject parent_instance;
|
||||
|
||||
char *resource_path;
|
||||
GdkPixbufAnimation *anim;
|
||||
GdkPixbufAnimationIter *iter;
|
||||
|
||||
guint timeout;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_RESOURCE_PATH = 1,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
static void
|
||||
pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
|
||||
GTimeVal val;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
|
||||
g_get_current_time (&val);
|
||||
gdk_pixbuf_animation_iter_advance (self->iter, &val);
|
||||
pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (self->iter);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
|
||||
|
||||
g_object_unref (texture);
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
static int
|
||||
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
|
||||
|
||||
return gdk_pixbuf_animation_get_width (self->anim);
|
||||
}
|
||||
|
||||
static int
|
||||
pixbuf_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
|
||||
|
||||
return gdk_pixbuf_animation_get_height (self->anim);
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_init_interface (GdkPaintableInterface *iface)
|
||||
{
|
||||
iface->snapshot = pixbuf_paintable_snapshot;
|
||||
iface->get_intrinsic_width = pixbuf_paintable_get_intrinsic_width;
|
||||
iface->get_intrinsic_height = pixbuf_paintable_get_intrinsic_height;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE(PixbufPaintable, pixbuf_paintable, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
pixbuf_paintable_init_interface))
|
||||
|
||||
static void
|
||||
pixbuf_paintable_init (PixbufPaintable *paintable)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
delay_cb (gpointer data)
|
||||
{
|
||||
PixbufPaintable *self = data;
|
||||
int delay;
|
||||
|
||||
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
|
||||
self->timeout = g_timeout_add (delay, delay_cb, self);
|
||||
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_set_resource_path (PixbufPaintable *self,
|
||||
const char *resource_path)
|
||||
{
|
||||
int delay;
|
||||
|
||||
g_free (self->resource_path);
|
||||
self->resource_path = g_strdup (resource_path);
|
||||
|
||||
g_clear_object (&self->anim);
|
||||
self->anim = gdk_pixbuf_animation_new_from_resource (resource_path, NULL);
|
||||
g_clear_object (&self->iter);
|
||||
self->iter = gdk_pixbuf_animation_get_iter (self->anim, NULL);
|
||||
|
||||
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
|
||||
self->timeout = g_timeout_add (delay, delay_cb, self);
|
||||
|
||||
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
|
||||
|
||||
g_object_notify (G_OBJECT (self), "resource-path");
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RESOURCE_PATH:
|
||||
pixbuf_paintable_set_resource_path (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RESOURCE_PATH:
|
||||
g_value_set_string (value, self->resource_path);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_dispose (GObject *object)
|
||||
{
|
||||
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
|
||||
|
||||
g_clear_pointer (&self->resource_path, g_free);
|
||||
g_clear_object (&self->anim);
|
||||
g_clear_object (&self->iter);
|
||||
if (self->timeout)
|
||||
{
|
||||
g_source_remove (self->timeout);
|
||||
self->timeout = 0;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (pixbuf_paintable_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
pixbuf_paintable_class_init (PixbufPaintableClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->dispose = pixbuf_paintable_dispose;
|
||||
object_class->get_property = pixbuf_paintable_get_property;
|
||||
object_class->set_property = pixbuf_paintable_set_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_RESOURCE_PATH,
|
||||
g_param_spec_string ("resource-path", "Resource path", "Resource path",
|
||||
NULL, G_PARAM_READWRITE));
|
||||
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
pixbuf_paintable_new_from_resource (const char *path)
|
||||
{
|
||||
return g_object_new (PIXBUF_TYPE_PAINTABLE,
|
||||
"resource-path", path,
|
||||
NULL);
|
||||
}
|
||||
13
demos/gtk-demo/pixbufpaintable.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define PIXBUF_TYPE_PAINTABLE (pixbuf_paintable_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE(PixbufPaintable, pixbuf_paintable, PIXBUF, PAINTABLE, GObject)
|
||||
|
||||
GdkPaintable * pixbuf_paintable_new_from_resource (const char *path);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -110,17 +110,17 @@ set_search_by (GSimpleAction *action,
|
||||
if (g_str_equal (term, "name"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by name");
|
||||
gtk_entry_set_placeholder_text (entry, "name");
|
||||
gtk_entry_set_placeholder_text (entry, "Name…");
|
||||
}
|
||||
else if (g_str_equal (term, "description"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by description");
|
||||
gtk_entry_set_placeholder_text (entry, "description");
|
||||
gtk_entry_set_placeholder_text (entry, "Description…");
|
||||
}
|
||||
else if (g_str_equal (term, "filename"))
|
||||
{
|
||||
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by file name");
|
||||
gtk_entry_set_placeholder_text (entry, "file name");
|
||||
gtk_entry_set_placeholder_text (entry, "File name…");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ do_search_entry (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *find_button;
|
||||
GtkWidget *cancel_button;
|
||||
@@ -268,18 +267,14 @@ do_search_entry (GtkWidget *do_widget)
|
||||
|
||||
g_object_weak_ref (G_OBJECT (window), search_entry_destroyed, &window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
||||
gtk_widget_set_margin_start (vbox, 18);
|
||||
gtk_widget_set_margin_end (vbox, 18);
|
||||
gtk_widget_set_margin_top (vbox, 18);
|
||||
gtk_widget_set_margin_bottom (vbox, 18);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label), "Search entry demo");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
|
||||
/* Create our entry */
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* Entry/Delayed Search Entry
|
||||
/* Entry/Type to Search
|
||||
*
|
||||
* GtkSearchEntry provides an entry that is ready for search.
|
||||
*
|
||||
* Search entries have their "changed" signal delayed and should
|
||||
* be used when the searched operation is slow such as loads of
|
||||
* entries to search, or online searches.
|
||||
* Search entries have their "search-changed" signal delayed and
|
||||
* should be used when the search operation is slow, such as big
|
||||
* datasets to search, or online searches.
|
||||
*
|
||||
* GtkSearchBar allows have a hidden search entry that 'springs
|
||||
* into action' upon keyboard input.
|
||||
@@ -18,101 +18,69 @@ search_changed_cb (GtkSearchEntry *entry,
|
||||
{
|
||||
const char *text;
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
g_message ("search changed: %s", text);
|
||||
gtk_label_set_text (result_label, text ? text : "");
|
||||
}
|
||||
|
||||
static void
|
||||
changed_cb (GtkEditable *editable)
|
||||
{
|
||||
const char *text;
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (editable));
|
||||
g_message ("changed: %s", text);
|
||||
}
|
||||
|
||||
static void
|
||||
search_changed (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "search-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
next_match (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "next-match");
|
||||
}
|
||||
|
||||
static void
|
||||
previous_match (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "previous-match");
|
||||
}
|
||||
|
||||
static void
|
||||
stop_search (GtkSearchEntry *entry,
|
||||
GtkLabel *label)
|
||||
{
|
||||
gtk_label_set_text (label, "stop-search");
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_search_entry2 (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *container;
|
||||
GtkWidget *searchbar;
|
||||
GtkWidget *button;
|
||||
GtkWidget *header;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Type to Search");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
gtk_widget_set_size_request (window, 200, -1);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
entry = gtk_search_entry_new ();
|
||||
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (container), entry);
|
||||
gtk_widget_set_halign (entry, GTK_ALIGN_CENTER);
|
||||
searchbar = gtk_search_bar_new ();
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (searchbar), GTK_EDITABLE (entry));
|
||||
gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (searchbar), FALSE);
|
||||
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), container);
|
||||
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), entry);
|
||||
gtk_box_append (GTK_BOX (vbox), searchbar);
|
||||
|
||||
/* Hook the search bar to key presses */
|
||||
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
|
||||
|
||||
/* Help */
|
||||
label = gtk_label_new ("Start Typing to search");
|
||||
gtk_box_append (GTK_BOX (vbox), label);
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
|
||||
gtk_widget_set_margin_start (box, 18);
|
||||
gtk_widget_set_margin_end (box, 18);
|
||||
gtk_widget_set_margin_top (box, 18);
|
||||
gtk_widget_set_margin_bottom (box, 18);
|
||||
gtk_box_append (GTK_BOX (vbox), box);
|
||||
|
||||
/* Toggle button */
|
||||
button = gtk_toggle_button_new_with_label ("Search");
|
||||
button = gtk_toggle_button_new ();
|
||||
gtk_button_set_icon_name (GTK_BUTTON (button), "system-search-symbolic");
|
||||
g_object_bind_property (button, "active",
|
||||
searchbar, "search-mode-enabled",
|
||||
G_BINDING_BIDIRECTIONAL);
|
||||
gtk_box_append (GTK_BOX (vbox), button);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
|
||||
|
||||
/* Result */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
gtk_box_append (GTK_BOX (box), hbox);
|
||||
|
||||
label = gtk_label_new ("Result:");
|
||||
label = gtk_label_new ("Searching for:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_margin_start (label, 6);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
@@ -120,28 +88,6 @@ do_search_entry2 (GtkWidget *do_widget)
|
||||
|
||||
g_signal_connect (entry, "search-changed",
|
||||
G_CALLBACK (search_changed_cb), label);
|
||||
g_signal_connect (entry, "changed",
|
||||
G_CALLBACK (changed_cb), label);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
|
||||
label = gtk_label_new ("Signal:");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
gtk_widget_set_margin_start (label, 6);
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_box_append (GTK_BOX (hbox), label);
|
||||
|
||||
g_signal_connect (entry, "search-changed",
|
||||
G_CALLBACK (search_changed), label);
|
||||
g_signal_connect (entry, "next-match",
|
||||
G_CALLBACK (next_match), label);
|
||||
g_signal_connect (entry, "previous-match",
|
||||
G_CALLBACK (previous_match), label);
|
||||
g_signal_connect (entry, "stop-search",
|
||||
G_CALLBACK (stop_search), label);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -66,6 +66,7 @@ do_tagged_entry (GtkWidget *do_widget)
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tag {
|
||||
margin: 4px;
|
||||
margin: 4px 0px;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
background: lightskyblue;
|
||||
@@ -17,3 +17,7 @@ tag button {
|
||||
padding: 0;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
entry.tagged {
|
||||
border-spacing: 4px;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
</object>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="resizable">0</property>
|
||||
<property name="title">Themes</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<child type="start">
|
||||
|
||||
@@ -164,7 +164,7 @@ save_file (GFile *save_filename)
|
||||
NULL,
|
||||
&error);
|
||||
|
||||
if (error != NULL)
|
||||
if (error == NULL)
|
||||
{
|
||||
if (save_filename != filename)
|
||||
{
|
||||
|
||||
@@ -91,6 +91,16 @@ change_theme_state (GSimpleAction *action,
|
||||
|
||||
static GtkWidget *page_stack;
|
||||
|
||||
static void
|
||||
transition_speed_changed (GtkRange *range,
|
||||
gpointer data)
|
||||
{
|
||||
double value;
|
||||
|
||||
value = gtk_range_get_value (range);
|
||||
gtk_stack_set_transition_duration (GTK_STACK (page_stack), (int)value);
|
||||
}
|
||||
|
||||
static void
|
||||
change_transition_state (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
@@ -250,6 +260,8 @@ activate_about (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkApplication *app = user_data;
|
||||
GtkWindow *window;
|
||||
GtkWidget *button;
|
||||
const char *authors[] = {
|
||||
"Andrea Cimitan",
|
||||
"Cosimo Cecchi",
|
||||
@@ -267,6 +279,10 @@ activate_about (GSimpleAction *action,
|
||||
|
||||
s = g_string_new ("");
|
||||
|
||||
window = gtk_application_get_active_window (app);
|
||||
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
|
||||
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
|
||||
|
||||
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
|
||||
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
|
||||
if (os_name && os_version)
|
||||
@@ -292,6 +308,7 @@ activate_about (GSimpleAction *action,
|
||||
|
||||
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
||||
"transient-for", gtk_application_get_active_window (app),
|
||||
"modal", TRUE,
|
||||
"program-name", "GTK Widget Factory",
|
||||
"version", version,
|
||||
"copyright", "© 1997—2020 The GTK Team",
|
||||
@@ -315,6 +332,21 @@ activate_about (GSimpleAction *action,
|
||||
g_free (os_version);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_shortcuts_window (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkApplication *app = user_data;
|
||||
GtkWindow *window;
|
||||
GtkWidget *button;
|
||||
|
||||
window = gtk_application_get_active_window (app);
|
||||
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
|
||||
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
|
||||
gtk_widget_activate_action (GTK_WIDGET (window), "win.show-help-overlay", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_quit (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
@@ -2022,6 +2054,7 @@ activate (GApplication *app)
|
||||
"validate_more_details", (GCallback)validate_more_details,
|
||||
"mode_switch_state_set", (GCallback)mode_switch_state_set,
|
||||
"level_scale_value_changed", (GCallback)level_scale_value_changed,
|
||||
"transition_speed_changed", (GCallback)transition_speed_changed,
|
||||
NULL);
|
||||
gtk_builder_set_scope (builder, scope);
|
||||
g_object_unref (scope);
|
||||
@@ -2359,6 +2392,7 @@ main (int argc, char *argv[])
|
||||
GAction *action;
|
||||
static GActionEntry app_entries[] = {
|
||||
{ "about", activate_about, NULL, NULL, NULL },
|
||||
{ "shortcuts", activate_shortcuts_window, NULL, NULL, NULL },
|
||||
{ "quit", activate_quit, NULL, NULL, NULL },
|
||||
{ "inspector", activate_inspector, NULL, NULL, NULL },
|
||||
{ "main", NULL, "s", "'steak'", NULL },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="gear_menu">
|
||||
<menu id="gear_menu_model">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Get Busy</attribute>
|
||||
@@ -40,6 +40,9 @@
|
||||
<attribute name="label" translatable="yes">Transition Pages</attribute>
|
||||
<attribute name="action">win.transition</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="custom">transition-speed</attribute>
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
@@ -48,7 +51,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
<attribute name="action">app.shortcuts</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_About Widget Factory</attribute>
|
||||
@@ -444,7 +447,26 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="gear_menu_button">
|
||||
<property name="valign">center</property>
|
||||
<property name="menu-model">gear_menu</property>
|
||||
<property name="popover">
|
||||
<object class="GtkPopoverMenu" id="gear_menu">
|
||||
<property name="menu-model">gear_menu_model</property>
|
||||
<child type="transition-speed">
|
||||
<object class="GtkScale">
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment">
|
||||
<property name="lower">0</property>
|
||||
<property name="upper">1000</property>
|
||||
<property name="value">250</property>
|
||||
<property name="step-increment">50</property>
|
||||
<property name="page-increment">50</property>
|
||||
<property name="page-size">0</property>
|
||||
</object>
|
||||
</property>
|
||||
<signal name="value-changed" handler="transition_speed_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -3198,7 +3220,7 @@ bad things might happen.</property>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="halign">end</property>
|
||||
<property name="icon-name">emblem-system-symbolic</property>
|
||||
<property name="menu-model">gear_menu</property>
|
||||
<property name="menu-model">gear_menu_model</property>
|
||||
<property name="tooltip-text">This is a menu button</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
|
||||
@@ -16,14 +16,16 @@
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<reference id="reference">
|
||||
<chapter>
|
||||
<title>API Reference</title>
|
||||
<xi:include href="xml/general.xml" />
|
||||
<xi:include href="xml/gdkdisplaymanager.xml" />
|
||||
<xi:include href="xml/gdkdisplay.xml" />
|
||||
<xi:include href="xml/gdkseat.xml" />
|
||||
<xi:include href="xml/gdkdevice.xml" />
|
||||
<xi:include href="xml/gdkdevicepad.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkdevicepad.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkmonitor.xml" />
|
||||
<xi:include href="xml/regions.xml" />
|
||||
<xi:include href="xml/textures.xml" />
|
||||
@@ -32,16 +34,24 @@
|
||||
<xi:include href="xml/cursors.xml" />
|
||||
<xi:include href="xml/gdksurface.xml" />
|
||||
<xi:include href="xml/gdktoplevel.xml" />
|
||||
<xi:include href="xml/gdktoplevellayout.xml" />
|
||||
<xi:include href="xml/gdktoplevelsize.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdktoplevellayout.xml" />
|
||||
<xi:include href="xml/gdktoplevelsize.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkpopup.xml" />
|
||||
<xi:include href="xml/gdkpopuplayout.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkpopuplayout.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkframeclock.xml" />
|
||||
<xi:include href="xml/gdkframetimings.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkframetimings.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gdkdrawcontext.xml" />
|
||||
<xi:include href="xml/gdkglcontext.xml" />
|
||||
<xi:include href="xml/gdkvulkancontext.xml" />
|
||||
<xi:include href="xml/gdkcairocontext.xml" />
|
||||
<section>
|
||||
<xi:include href="xml/gdkglcontext.xml" />
|
||||
<xi:include href="xml/gdkvulkancontext.xml" />
|
||||
<xi:include href="xml/gdkcairocontext.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/events.xml" />
|
||||
<xi:include href="xml/keys.xml" />
|
||||
<xi:include href="xml/gdkclipboard.xml" />
|
||||
@@ -50,13 +60,16 @@
|
||||
<xi:include href="xml/gdkcontentprovider.xml" />
|
||||
<xi:include href="xml/gdkcontentserializer.xml" />
|
||||
<xi:include href="xml/gdkcontentdeserializer.xml" />
|
||||
<xi:include href="xml/gdkapplaunchcontext.xml" />
|
||||
<xi:include href="xml/pixbufs.xml" />
|
||||
<xi:include href="xml/pango_interaction.xml" />
|
||||
<xi:include href="xml/cairo_interaction.xml" />
|
||||
</chapter>
|
||||
<chapter>
|
||||
<title>GDK Platform Support</title>
|
||||
<xi:include href="xml/gdkapplaunchcontext.xml" />
|
||||
<xi:include href="xml/x_interaction.xml" />
|
||||
<xi:include href="xml/wayland_interaction.xml" />
|
||||
</reference>
|
||||
</chapter>
|
||||
|
||||
<index id="api-index-full">
|
||||
<title>Index of all symbols</title>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
</MACRO>
|
||||
|
||||
<MACRO>
|
||||
<NAME>GDK_WINDOWING_QUARTZ</NAME>
|
||||
#define GDK_WINDOWING_QUARTZ
|
||||
<NAME>GDK_WINDOWING_MACOS</NAME>
|
||||
#define GDK_WINDOWING_MACOS
|
||||
</MACRO>
|
||||
|
||||
<MACRO>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<SUBSECTION>
|
||||
GDK_WINDOWING_X11
|
||||
GDK_WINDOWING_WIN32
|
||||
GDK_WINDOWING_QUARTZ
|
||||
GDK_WINDOWING_MACOS
|
||||
GDK_WINDOWING_WAYLAND
|
||||
|
||||
<SUBSECTION>
|
||||
@@ -303,11 +303,8 @@ gdk_cairo_draw_from_gl
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<TITLE>Points, Rectangles and Regions</TITLE>
|
||||
<TITLE>Rectangles and Regions</TITLE>
|
||||
<FILE>regions</FILE>
|
||||
GdkPoint
|
||||
|
||||
<SUBSECTION>
|
||||
GdkRectangle
|
||||
gdk_rectangle_intersect
|
||||
gdk_rectangle_union
|
||||
|
||||
@@ -586,53 +586,53 @@ print_hello (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget, gpointer data)
|
||||
quit_cb (GtkWindow *window)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
gtk_window_close (window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
static void
|
||||
activate (GtkApplication *app,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GObject *window;
|
||||
GObject *button;
|
||||
gboolean done = FALSE;
|
||||
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
gtk_init ();
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
builder = gtk_builder_new ();
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (builder, "builder.ui", NULL);
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object (builder, "window");
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
GObject *window = gtk_builder_get_object (builder, "window");
|
||||
gtk_window_set_application (GTK_WINDOW (window), app);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button1");
|
||||
GObject *button = gtk_builder_get_object (builder, "button1");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button2");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "quit");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
/* We do not need the builder any more */
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||
|
||||
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
return status;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -971,6 +971,7 @@ gtk_editable_get_enable_undo
|
||||
gtk_editable_set_enable_undo
|
||||
<SUBSECTION>
|
||||
gtk_editable_install_properties
|
||||
gtk_editable_get_delegate
|
||||
gtk_editable_init_delegate
|
||||
gtk_editable_finish_delegate
|
||||
gtk_editable_delegate_set_property
|
||||
@@ -6176,6 +6177,8 @@ gtk_popover_menu_new_from_model
|
||||
gtk_popover_menu_new_from_model_full
|
||||
gtk_popover_menu_set_menu_model
|
||||
gtk_popover_menu_get_menu_model
|
||||
gtk_popover_menu_add_child
|
||||
gtk_popover_menu_remove_child
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_POPOVER_MENU
|
||||
@@ -6194,6 +6197,8 @@ GtkPopoverMenuBar
|
||||
gtk_popover_menu_bar_new_from_model
|
||||
gtk_popover_menu_bar_set_menu_model
|
||||
gtk_popover_menu_bar_get_menu_model
|
||||
gtk_popover_menu_bar_add_child
|
||||
gtk_popover_menu_bar_remove_child
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_POPOVER_MENU_BAR
|
||||
|
||||
BIN
docs/reference/gtk/images/box.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
docs/reference/gtk/images/calendar.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
docs/reference/gtk/images/centerbox.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
docs/reference/gtk/images/drawingarea.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.5 KiB |
BIN
docs/reference/gtk/images/emojichooser.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
docs/reference/gtk/images/expander.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 4.4 KiB |
BIN
docs/reference/gtk/images/grid.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 5.6 KiB |
BIN
docs/reference/gtk/images/menu.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
docs/reference/gtk/images/overlay.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.1 KiB |
BIN
docs/reference/gtk/images/popover.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
docs/reference/gtk/images/shortcuts-window.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.0 KiB |
BIN
docs/reference/gtk/images/windowcontrols.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
@@ -240,11 +240,14 @@ images = [
|
||||
'images/border1.png',
|
||||
'images/border2.png',
|
||||
'images/border3.png',
|
||||
'images/box.png',
|
||||
'images/box-expand.png',
|
||||
'images/box-packing.png',
|
||||
'images/builder-shortcuts.png',
|
||||
'images/button.png',
|
||||
'images/calendar.png',
|
||||
'images/capture-bubble.png',
|
||||
'images/centerbox.png',
|
||||
'images/check-button.png',
|
||||
'images/checks.png',
|
||||
'images/clocks-shortcuts.png',
|
||||
@@ -258,14 +261,17 @@ images = [
|
||||
'images/down-start.png',
|
||||
'images/drop-down.png',
|
||||
'images/drawing.png',
|
||||
'images/drawingarea.png',
|
||||
'images/ease-in-out.png',
|
||||
'images/ease-in.png',
|
||||
'images/ease-out.png',
|
||||
'images/ease.png',
|
||||
'images/editable-label.png',
|
||||
'images/emojichooser.png',
|
||||
'images/entry.png',
|
||||
'images/exampleapp.png',
|
||||
'images/expanders.png',
|
||||
'images/expander.png',
|
||||
'images/extensions.png',
|
||||
'images/figure-hierarchical-drawing.png',
|
||||
'images/figure-windowed-label.png',
|
||||
@@ -293,6 +299,7 @@ images = [
|
||||
'images/gradient2.png',
|
||||
'images/gradient3.png',
|
||||
'images/gradient4.png',
|
||||
'images/grid.png',
|
||||
'images/grid-packing.png',
|
||||
'images/handles.png',
|
||||
'images/headerbar.png',
|
||||
@@ -324,16 +331,19 @@ images = [
|
||||
'images/lockbutton-sorry.png',
|
||||
'images/lockbutton-unlocked.png',
|
||||
'images/media-controls.png',
|
||||
'images/menu.png',
|
||||
'images/menubar.png',
|
||||
'images/menu-button.png',
|
||||
'images/messagedialog.png',
|
||||
'images/multiline-text.png',
|
||||
'images/notebook.png',
|
||||
'images/options.png',
|
||||
'images/overlay.png',
|
||||
'images/pagesetupdialog.png',
|
||||
'images/panes.png',
|
||||
'images/password-entry.png',
|
||||
'images/picture.png',
|
||||
'images/popover.png',
|
||||
'images/popup-anchors.png',
|
||||
'images/popup-at.svg',
|
||||
'images/popup-flip.png',
|
||||
@@ -349,6 +359,7 @@ images = [
|
||||
'images/search-bar.png',
|
||||
'images/search-entry.png',
|
||||
'images/separator.png',
|
||||
'images/shortcuts-window.png',
|
||||
'images/sidebar.png',
|
||||
'images/slices.png',
|
||||
'images/sliders.png',
|
||||
@@ -367,6 +378,7 @@ images = [
|
||||
'images/video.png',
|
||||
'images/volumebutton.png',
|
||||
'images/widget-hvalign.png',
|
||||
'images/windowcontrols.png',
|
||||
'images/window-default.png',
|
||||
'images/window.png',
|
||||
'images/rich-list.png',
|
||||
|
||||
@@ -239,6 +239,39 @@ you get to the point that you actually build your application against
|
||||
GTK 4. Making it possible to prepare for these in GTK 3 would
|
||||
have been either impossible or impractical.
|
||||
|
||||
### Larger changes
|
||||
|
||||
Some of the larger themes of GTK 4 development are hard to cover in the form
|
||||
of checklist items, so we mention them separately up-front.
|
||||
|
||||
#### Subclassing
|
||||
|
||||
Compared to previous versions, GTK 4 emphasizes composition and delegation
|
||||
over subclassing. As a consequence, many widgets can no longer be subclassed.
|
||||
In most cases, you should look deriving your widget directly from GtkWidget
|
||||
and use complex widgets as child widgets instead of deriving from them.
|
||||
|
||||
#### Life-cycle handling
|
||||
|
||||
Widgets in GTK 4 are treated like any other objects - their parent widget
|
||||
holds a reference on them, and GTK holds a reference on toplevel windows.
|
||||
gtk_window_destroy() will drop the reference on the toplevel window, and
|
||||
cause the whole widget hierarchy to be finalized unless there are other
|
||||
references that keep widgets alive.
|
||||
|
||||
The #GtkWidget::destroy signal is emitted when a widget is disposed, and
|
||||
therefore can no longer be used to break reference cycles. A typical sign
|
||||
of a reference cycle involving a toplevel window is when closing the window
|
||||
does not make the application quit.
|
||||
|
||||
A good rule to follow is: If you set a widget pointer with
|
||||
gtk_widget_class_bind_template_child() in class_init(), you need to
|
||||
unparent it in dispose(). The slight complication here is that you need
|
||||
to respect the widget hierarchy while doing so. Ie if you set both `field1`
|
||||
and `field2`, but `field1` is an ancestor of `field2`, then you only need
|
||||
to unparent `field1` — doing so will remove the the entire subtree below
|
||||
`field1`, including `field2`.
|
||||
|
||||
### Stop using GdkScreen
|
||||
|
||||
The GdkScreen object has been removed in GTK 4. Most of its APIs already
|
||||
@@ -1047,12 +1080,12 @@ gtk_icon_paintable_get_icon_name() and set the icon name on a #GtkImage.
|
||||
|
||||
### Update to GtkFileChooser API changes
|
||||
|
||||
GtkFileChooser moved to a GFile-based API. If you need to convert a
|
||||
path or a URI, use g_file_new_for_path(), g_file_new_for_commandline_arg(),
|
||||
or g_file_new_for_uri(); similarly, if you need to get a path or a URI
|
||||
from a GFile, use g_file_get_path(), or g_file_get_uri(). With the
|
||||
removal or path and URI-based functions, the "local-only" property has
|
||||
been removed; GFile can be used to access non-local as well as local
|
||||
GtkFileChooser moved to a GFile-based API. If you need to convert a path
|
||||
or a URI, use g_file_new_for_path(), g_file_new_for_commandline_arg(),
|
||||
or g_file_new_for_uri(); similarly, if you need to get a path, name or URI
|
||||
from a GFile, use g_file_get_path(), g_file_get_basename() or g_file_get_uri().
|
||||
With the removal or path and URI-based functions, the "local-only" property
|
||||
has been removed; GFile can be used to access non-local as well as local
|
||||
resources.
|
||||
|
||||
The GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER action has been removed. Use
|
||||
|
||||
@@ -71,12 +71,12 @@ the question you have, this list is a good place to start.
|
||||
6. How do I use GTK with threads?
|
||||
|
||||
GTK requires that all GTK API calls are made from the same thread in which
|
||||
gtk_init() was called (the _main thread_).
|
||||
the #GtkApplication was created, or gtk_init() was called (the _main thread_).
|
||||
|
||||
If you want to take advantage of multi-threading in a GTK application,
|
||||
it is usually best to send long-running tasks to worker threads, and feed
|
||||
the results back to the main thread using g_idle_add() or GAsyncQueue. GIO
|
||||
offers useful tools for such an approach such as GTask.
|
||||
the results back to the main thread using g_idle_add() or #GAsyncQueue. GIO
|
||||
offers useful tools for such an approach such as #GTask.
|
||||
|
||||
7. How do I internationalize a GTK program?
|
||||
|
||||
|
||||
@@ -54,9 +54,16 @@ Each role name is part of the #GtkAccessibleRole enumeration.
|
||||
| `GRID_CELL` | An item in a grid | #GtkFlowBoxChild, #GtkGridView, #GtkColumnView |
|
||||
| `IMG` | An image | #GtkImage, #GtkPicture |
|
||||
| `LABEL` | A visible name or caption for a user interface component | #GtkLabel |
|
||||
| `LINK` | A clickable hyperlink | #GtkLinkButton |
|
||||
| `LIST` | A list of items | #GtkListBox |
|
||||
| `LIST_ITEM` | An item in a list | #GtkListBoxRow |
|
||||
| `MENU` | A menu | #GtkPopoverMenu |
|
||||
| `MENU_BAR` | A menubar | #GtkPopoverMenuBar |
|
||||
| `MENU_ITEM` | A menu item | Items in #GtkPopoverMenu |
|
||||
| `MENU_ITEM_CHECKBOX` | Check menu item | Items in #GtkPopoverMenu |
|
||||
| `MENU_ITEM_RADIO` | Radio menu item | Items in #GtkPopoverMenu |
|
||||
| `METER` | Represents a value within a known range | #GtkLevelBar |
|
||||
| `NONE` | Not represented in the accessibility tree | the slider of a #GtkScale |
|
||||
| `PROGRESS_BAR` | An element that display progress | #GtkProgressBar |
|
||||
| `RADIO` | A checkable input in a group of radio roles | #GtkCheckButton |
|
||||
| `ROW` | A row in a columned list | #GtkColumnView |
|
||||
@@ -106,9 +113,9 @@ for instance:
|
||||
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list
|
||||
of attributes for additional information.
|
||||
|
||||
#### List of accessible properties
|
||||
#### List of accessible states
|
||||
|
||||
Each state name is part of the #GtkAccessibleProperty enumeration.
|
||||
Each state name is part of the #GtkAccessibleState enumeration.
|
||||
|
||||
| State name | ARIA attribute | Value type | Notes |
|
||||
|------------|----------------|------------|-------|
|
||||
@@ -121,9 +128,9 @@ Each state name is part of the #GtkAccessibleProperty enumeration.
|
||||
| %GTK_ACCESSIBLE_STATE_PRESSED | “aria-pressed” | #GtkAccessibleTristate | Indicates the current state of a #GtkToggleButton |
|
||||
| %GTK_ACCESSIBLE_STATE_SELECTED | “aria-selected” | boolean or undefined | Set when a widget is selected |
|
||||
|
||||
#### List of accessible relations
|
||||
#### List of accessible properties
|
||||
|
||||
Each state name is part of the #GtkAccessibleRelation enumeration.
|
||||
Each property name is part of the #GtkAccessibleProperty enumeration.
|
||||
|
||||
| State name | ARIA attribute | Value type |
|
||||
|------------|----------------|------------|
|
||||
@@ -147,9 +154,9 @@ Each state name is part of the #GtkAccessibleRelation enumeration.
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
|
||||
|
||||
#### List of accessible states
|
||||
#### List of accessible relations
|
||||
|
||||
Each state name is part of the #GtkAccessibleState enumeration.
|
||||
Each relation name is part of the #GtkAccessibleRelation enumeration.
|
||||
|
||||
| State name | ARIA attribute | Value type |
|
||||
|------------|----------------|------------|
|
||||
@@ -183,7 +190,7 @@ with a form to fill out, you should ensure that:
|
||||
* each text entry widget in the form has the `GTK_ACCESSIBLE_RELATION_LABELLED_BY`
|
||||
relation pointing to the label widget that describes it
|
||||
|
||||
Another example: if you create a tool bar containing buttons with only icons,
|
||||
Another example: if you create a toolbar containing buttons with only icons,
|
||||
you should ensure that:
|
||||
|
||||
* the container has a `GTK_ACCESSIBLE_ROLE_TOOLBAR` role
|
||||
@@ -192,7 +199,7 @@ you should ensure that:
|
||||
"Paste", "Add layer", or "Remove"
|
||||
|
||||
GTK will try to fill in some information by using ancillary UI control
|
||||
property, for instance the accessible label will be taken from the label or
|
||||
properties, for instance the accessible label will be taken from the label or
|
||||
placeholder text used by the UI control, or from its tooltip, if the
|
||||
`GTK_ACCESSIBLE_PROPERTY_LABEL` property or the `GTK_ACCESSIBLE_RELATION_LABELLED_BY`
|
||||
relation are unset. Nevertheless, it is good practice and project hygiene
|
||||
@@ -220,3 +227,113 @@ which acts as a proxy to the specific platform's accessibility API:
|
||||
|
||||
Additionally, an ad hoc accessibility backend is available for the GTK
|
||||
testsuite, to ensure reproducibility of issues in the CI pipeline.
|
||||
|
||||
## Authoring practices {#authoring-practices}
|
||||
|
||||
The authoring practices are aimed at application developers, as well as
|
||||
developers of GUI elements based on GTK.
|
||||
|
||||
Functionally, #GtkAccessible roles, states, properties, and relations are
|
||||
analogous to a CSS for assistive technologies. For screen reader users, for
|
||||
instance, the various accessible attributes control the rendering of their
|
||||
non-visual experience. Incorrect roles and attributes may result in a
|
||||
completely inaccessible user interface.
|
||||
|
||||
### A role is a promise
|
||||
|
||||
The following code:
|
||||
|
||||
```c
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
|
||||
```
|
||||
|
||||
is a promise that the widget being created will provide the same keyboard
|
||||
interactions expected for a button. An accessible role of a button will not
|
||||
turn automatically any widget into a #GtkButton; but if your widget behaves
|
||||
like a button, using the %GTK_ACCESSIBLE_ROLE_BUTTON will allow any
|
||||
assistive technology to handle it like they would a #GtkButton.
|
||||
|
||||
### Attributes can both hide and enhance
|
||||
|
||||
Accessible attributes can be used to override the content of a UI element,
|
||||
for instance:
|
||||
|
||||
```c
|
||||
gtk_label_set_text (GTK_LABEL (label), "Some text");
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (label),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL,
|
||||
"Assistive technologies users will perceive "
|
||||
"this text, not the contents of the label",
|
||||
-1);
|
||||
```
|
||||
|
||||
In the example above, the "label" property will override the contents of the
|
||||
label widget.
|
||||
|
||||
The attributes can also enhance the UI:
|
||||
|
||||
```c
|
||||
gtk_button_set_label (GTK_BUTTON (button), "Download");
|
||||
gtk_box_append (GTK_BOX (button), button);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (label), "Final report.pdf");
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
||||
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY,
|
||||
g_list_append (NULL, label),
|
||||
-1);
|
||||
```
|
||||
|
||||
In the example above, an assistive technology will read the button's
|
||||
accessible label as "Download Final report.pdf".
|
||||
|
||||
The power of hiding and enhancing can be a double-edged sword, as it can
|
||||
lead to inadvertently overriding the accessible semantics of existing
|
||||
widgets.
|
||||
|
||||
## Design patterns and custom widgets
|
||||
|
||||
When creating custom widgets, following established patterns can help
|
||||
ensuring that the widgets work well for users of accessible technologies
|
||||
as well.
|
||||
|
||||
### Custom entries
|
||||
|
||||
For custom entries, it is highly recommended that you implement the
|
||||
#GtkEditable interface by using a #GtkText widget as delegate. If you
|
||||
do this, GTK will make your widgets text editing functionality accessible
|
||||
in the same way as a #GtkSpinButton or #GtkSearchEntry.
|
||||
|
||||
### Tab-based UI
|
||||
|
||||
If you make a tab-based interface, you should consider using #GtkStack
|
||||
as the core, and just make a custom tab widget to control the active
|
||||
stack page. When doing so, the following extra steps will ensure that
|
||||
your tabs are accessible in the same way as #GtkStackSwitcher or #GtkNotebook:
|
||||
|
||||
- Give your tab container the role %GTK_ACCESSIBLE_ROLE_TAB_LIST
|
||||
- Give your tab widgets the role %GTK_ACCESSIBLE_ROLE_TAB
|
||||
- Set up the %GTK_ACCESSIBLE_RELATION_CONTROLS relation between each
|
||||
tab and the #GtkStackPage object for its page
|
||||
- Set the %GTK_ACCESSIBLE_PROPERTY_SELECTED property on each tab, with
|
||||
the active tab getting the value %TRUE, all others %FALSE
|
||||
|
||||
To allow changing the active tab via accessible technologies, you can
|
||||
export actions. Since the accessibility interfaces only support actions
|
||||
without parameters, you can either provide `previous-tab` and `next-tab`
|
||||
actions on the tab container that let users step through the tabs one-by-one,
|
||||
or add a `activate-tab` action on each tab.
|
||||
|
||||
### Value controls
|
||||
|
||||
A value control (ie a widget that controls a one-dimensional quantity
|
||||
that can be represented by a #GtkAdjustment) can be represented to
|
||||
accessible technologies by setting the %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN,
|
||||
%GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, and %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW
|
||||
properties.
|
||||
|
||||
To allow changing the value via accessible technologies, you can export
|
||||
actions. Since the accessibility interfaces only support actions
|
||||
without parameters, you should provide actions such as `increase-value`
|
||||
and `decrease-value`.
|
||||
|
||||
@@ -6,210 +6,104 @@
|
||||
<section id="visual-display">
|
||||
<title>Display</title>
|
||||
<para role="gallery">
|
||||
<link linkend="GtkLabel">
|
||||
<inlinegraphic fileref="label.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkSpinner">
|
||||
<inlinegraphic fileref="spinner.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkStatusbar">
|
||||
<inlinegraphic fileref="statusbar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkLevelBar">
|
||||
<inlinegraphic fileref="levelbar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkProgressBar">
|
||||
<inlinegraphic fileref="progressbar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkInfoBar">
|
||||
<inlinegraphic fileref="info-bar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkScrollbar">
|
||||
<inlinegraphic fileref="scrollbar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkImage">
|
||||
<inlinegraphic fileref="image.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkSeparator">
|
||||
<inlinegraphic fileref="separator.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkTextView">
|
||||
<inlinegraphic fileref="multiline-text.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkScale">
|
||||
<inlinegraphic fileref="scales.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkGLArea">
|
||||
<inlinegraphic fileref="glarea.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPicture">
|
||||
<inlinegraphic fileref="picture.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkVideo">
|
||||
<inlinegraphic fileref="video.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkMediaControls">
|
||||
<inlinegraphic fileref="media-controls.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkLabel"><inlinegraphic fileref="label.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkSpinner"><inlinegraphic fileref="spinner.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkStatusbar"><inlinegraphic fileref="statusbar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkLevelBar"><inlinegraphic fileref="levelbar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkProgressBar"><inlinegraphic fileref="progressbar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkInfoBar"><inlinegraphic fileref="info-bar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkScrollbar"><inlinegraphic fileref="scrollbar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkImage"><inlinegraphic fileref="image.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPicture"><inlinegraphic fileref="picture.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkSeparator"><inlinegraphic fileref="separator.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkTextView"><inlinegraphic fileref="multiline-text.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkScale"><inlinegraphic fileref="scales.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkCalendar"><inlinegraphic fileref="calendar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkGLArea"><inlinegraphic fileref="glarea.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkDrawingArea"><inlinegraphic fileref="drawingarea.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkVideo"><inlinegraphic fileref="video.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkMediaControls"><inlinegraphic fileref="media-controls.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkWindowControls"><inlinegraphic fileref="windowcontrols.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkEmojiChooser"><inlinegraphic fileref="emojichooser.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPopoverMenu"><inlinegraphic fileref="menu.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPopoverMenuBar"><inlinegraphic fileref="menubar.png" format="PNG"></inlinegraphic></link>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="visual-buttons">
|
||||
<title>Buttons</title>
|
||||
<para role="gallery">
|
||||
<link linkend="GtkButton">
|
||||
<inlinegraphic fileref="button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkCheckButton">
|
||||
<inlinegraphic fileref="check-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkToggleButton">
|
||||
<inlinegraphic fileref="toggle-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkLinkButton">
|
||||
<inlinegraphic fileref="link-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
|
||||
<link linkend="GtkMenuButton">
|
||||
<inlinegraphic fileref="menu-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkLockButton">
|
||||
<inlinegraphic fileref="lockbutton.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkSpinButton">
|
||||
<inlinegraphic fileref="spinbutton.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkColorButton">
|
||||
<inlinegraphic fileref="color-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
|
||||
<link linkend="GtkSwitch">
|
||||
<inlinegraphic fileref="switch.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkComboBox">
|
||||
<inlinegraphic fileref="combo-box.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkComboBoxText">
|
||||
<inlinegraphic fileref="combo-box-text.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkFontButton">
|
||||
<inlinegraphic fileref="font-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
|
||||
<link linkend="GtkAppChooserButton">
|
||||
<inlinegraphic fileref="appchooserbutton.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkVolumeButton">
|
||||
<inlinegraphic fileref="volumebutton.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkFileChooserButton">
|
||||
<inlinegraphic fileref="file-button.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkDropDown">
|
||||
<inlinegraphic fileref="drop-down.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkButton"><inlinegraphic fileref="button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkToggleButton"><inlinegraphic fileref="toggle-button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkLinkButton"><inlinegraphic fileref="link-button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkCheckButton"><inlinegraphic fileref="check-button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkMenuButton"><inlinegraphic fileref="menu-button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkLockButton"><inlinegraphic fileref="lockbutton.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkVolumeButton"><inlinegraphic fileref="volumebutton.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkSwitch"><inlinegraphic fileref="switch.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkComboBox"><inlinegraphic fileref="combo-box.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkComboBoxText"><inlinegraphic fileref="combo-box-text.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkDropDown"><inlinegraphic fileref="drop-down.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkColorButton"><inlinegraphic fileref="color-button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkFontButton"><inlinegraphic fileref="font-button.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkAppChooserButton"><inlinegraphic fileref="appchooserbutton.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkFileChooserButton"><inlinegraphic fileref="file-button.png" format="PNG"></inlinegraphic></link>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="visual-entries">
|
||||
<title>Entries</title>
|
||||
<para role="gallery">
|
||||
<link linkend="GtkEntry">
|
||||
<inlinegraphic fileref="entry.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkSearchEntry">
|
||||
<inlinegraphic fileref="search-entry.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPasswordEntry">
|
||||
<inlinegraphic fileref="password-entry.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkEditableLabel">
|
||||
<inlinegraphic fileref="editable-label.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkEntry"><inlinegraphic fileref="entry.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkSearchEntry"><inlinegraphic fileref="search-entry.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPasswordEntry"><inlinegraphic fileref="password-entry.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkSpinButton"><inlinegraphic fileref="spinbutton.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkEditableLabel"><inlinegraphic fileref="editable-label.png" format="PNG"></inlinegraphic></link>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="visual-containers">
|
||||
<title>Containers</title>
|
||||
<para role="gallery">
|
||||
<link linkend="GtkScrolledWindow">
|
||||
<inlinegraphic fileref="scrolledwindow.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkHeaderBar">
|
||||
<inlinegraphic fileref="headerbar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkSearchBar">
|
||||
<inlinegraphic fileref="search-bar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkActionBar">
|
||||
<inlinegraphic fileref="action-bar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkListBox">
|
||||
<inlinegraphic fileref="list-box.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkFlowBox">
|
||||
<inlinegraphic fileref="flow-box.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkStack">
|
||||
<inlinegraphic fileref="stack.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkStackSwitcher">
|
||||
<inlinegraphic fileref="stackswitcher.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkStackSidebar">
|
||||
<inlinegraphic fileref="sidebar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkTreeView">
|
||||
<inlinegraphic fileref="list-and-tree.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkIconView">
|
||||
<inlinegraphic fileref="icon-view.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkNotebook">
|
||||
<inlinegraphic fileref="notebook.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkFrame">
|
||||
<inlinegraphic fileref="frame.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPaned">
|
||||
<inlinegraphic fileref="panes.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkBox"><inlinegraphic fileref="box.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkGrid"><inlinegraphic fileref="grid.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkCenterBox"><inlinegraphic fileref="centerbox.png" format="PNG"></inlinegraphic></link>
|
||||
</para>
|
||||
<para role="gallery">
|
||||
<link linkend="GtkScrolledWindow"><inlinegraphic fileref="scrolledwindow.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPaned"><inlinegraphic fileref="panes.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkFrame"><inlinegraphic fileref="frame.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkExpander"><inlinegraphic fileref="expander.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkSearchBar"><inlinegraphic fileref="search-bar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkActionBar"><inlinegraphic fileref="action-bar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkHeaderBar"><inlinegraphic fileref="headerbar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkNotebook"><inlinegraphic fileref="notebook.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkListBox"><inlinegraphic fileref="list-box.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkFlowBox"><inlinegraphic fileref="flow-box.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkTreeView"><inlinegraphic fileref="list-and-tree.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkIconView"><inlinegraphic fileref="icon-view.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkOverlay"><inlinegraphic fileref="overlay.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkStack"><inlinegraphic fileref="stack.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkStackSwitcher"><inlinegraphic fileref="stackswitcher.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkStackSidebar"><inlinegraphic fileref="sidebar.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPopover"><inlinegraphic fileref="popover.png" format="PNG"></inlinegraphic></link>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="visual-windows">
|
||||
<title>Windows</title>
|
||||
<para role="gallery">
|
||||
<link linkend="GtkWindow">
|
||||
<inlinegraphic fileref="window.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkMessageDialog">
|
||||
<inlinegraphic fileref="messagedialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkAboutDialog">
|
||||
<inlinegraphic fileref="aboutdialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkAssistant">
|
||||
<inlinegraphic fileref="assistant.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkColorChooserDialog">
|
||||
<inlinegraphic fileref="colorchooser.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkFileChooserDialog">
|
||||
<inlinegraphic fileref="filechooser.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkFontChooserDialog">
|
||||
<inlinegraphic fileref="fontchooser.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkAppChooserDialog">
|
||||
<inlinegraphic fileref="appchooserdialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPageSetupUnixDialog">
|
||||
<inlinegraphic fileref="pagesetupdialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPrintUnixDialog">
|
||||
<inlinegraphic fileref="printdialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkWindow"><inlinegraphic fileref="window.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkMessageDialog"><inlinegraphic fileref="messagedialog.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkAboutDialog"><inlinegraphic fileref="aboutdialog.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkAssistant"><inlinegraphic fileref="assistant.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkColorChooserDialog"><inlinegraphic fileref="colorchooser.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkFileChooserDialog"><inlinegraphic fileref="filechooser.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkFontChooserDialog"><inlinegraphic fileref="fontchooser.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkAppChooserDialog"><inlinegraphic fileref="appchooserdialog.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPageSetupUnixDialog"><inlinegraphic fileref="pagesetupdialog.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkPrintUnixDialog"><inlinegraphic fileref="printdialog.png" format="PNG"></inlinegraphic></link>
|
||||
<link linkend="GtkShortcutsWindow"><inlinegraphic fileref="shortcuts-window.png" format="PNG"></inlinegraphic></link>
|
||||
</para>
|
||||
</section>
|
||||
</para>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
if get_option('gtk_doc')
|
||||
doc_shooter_resources = gnome.compile_resources('shooter_resources',
|
||||
'shooter.gresource.xml',
|
||||
source_dir: '.')
|
||||
|
||||
doc_shooter_sources = [
|
||||
'shooter.c',
|
||||
'shadow.c',
|
||||
@@ -6,7 +10,8 @@ if get_option('gtk_doc')
|
||||
'../../tests/gtkgears.c',
|
||||
]
|
||||
|
||||
doc_shooter = executable('doc-shooter', doc_shooter_sources,
|
||||
doc_shooter = executable('doc-shooter',
|
||||
doc_shooter_sources, doc_shooter_resources,
|
||||
include_directories: [ confinc, gdkinc, gtkinc, testinc, ],
|
||||
dependencies: libgtk_dep)
|
||||
endif
|
||||
|
||||
@@ -112,11 +112,19 @@ snapshot_widget (GtkWidget *widget)
|
||||
|
||||
g_main_loop_unref (loop);
|
||||
g_object_unref (paintable);
|
||||
gtk_window_destroy (GTK_WINDOW (widget));
|
||||
gtk_window_destroy (GTK_WINDOW (gtk_widget_get_root (widget)));
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
quit_cb (gpointer data)
|
||||
{
|
||||
*(gboolean *)data = TRUE;
|
||||
g_main_context_wakeup (NULL);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -132,6 +140,7 @@ main (int argc, char **argv)
|
||||
char *filename;
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkWidget *widget;
|
||||
|
||||
info = node->data;
|
||||
|
||||
@@ -144,9 +153,29 @@ main (int argc, char **argv)
|
||||
NULL);
|
||||
}
|
||||
|
||||
//while (1) g_main_context_iteration (NULL, 1);
|
||||
if (info->snapshot_popover)
|
||||
{
|
||||
GtkWidget *button = gtk_window_get_child (GTK_WINDOW (info->window));
|
||||
|
||||
surface = snapshot_widget (info->window);
|
||||
gtk_menu_button_popup (GTK_MENU_BUTTON (button));
|
||||
widget = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button)));
|
||||
}
|
||||
else
|
||||
{
|
||||
widget = info->window;
|
||||
}
|
||||
|
||||
if (info->wait > 0)
|
||||
{
|
||||
gboolean quit = FALSE;
|
||||
|
||||
g_timeout_add (info->wait, quit_cb, &quit);
|
||||
|
||||
while (!quit)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
}
|
||||
|
||||
surface = snapshot_widget (widget);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
|
||||
cairo_image_surface_get_width (surface),
|
||||
|
||||
5
docs/tools/shooter.gresource.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<gresources>
|
||||
<gresource prefix="/">
|
||||
<file>shortcuts-boxes.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
120
docs/tools/shortcuts-boxes.ui
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkShortcutsWindow" id="shortcuts-boxes">
|
||||
<property name="modal">1</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsSection">
|
||||
<property name="section-name">shortcuts</property>
|
||||
<property name="max-height">12</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">Overview</property>
|
||||
<property name="view">overview</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator">F1</property>
|
||||
<property name="title" translatable="yes">Help</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl>n</property>
|
||||
<property name="title" translatable="yes">Create a new box</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl>f</property>
|
||||
<property name="title" translatable="yes">Search</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl>k</property>
|
||||
<property name="title" translatable="yes">Keyboard shortcuts</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl>q</property>
|
||||
<property name="title" translatable="yes">Close Window/Quit Boxes</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">Box Creation and Properties</property>
|
||||
<property name="view">wizard</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="direction">ltr</property>
|
||||
<property name="accelerator"><Alt>Right</property>
|
||||
<property name="title" translatable="yes">Switch to the next page</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="direction">ltr</property>
|
||||
<property name="accelerator"><Alt>Left</property>
|
||||
<property name="title" translatable="yes">Switch to the previous page</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="direction">rtl</property>
|
||||
<property name="accelerator"><Alt>Left</property>
|
||||
<property name="title" translatable="yes">Switch to the next page</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="direction">rtl</property>
|
||||
<property name="accelerator"><Alt>Right</property>
|
||||
<property name="title" translatable="yes">Switch to the previous page</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="title" translatable="yes">Box Display</property>
|
||||
<property name="view">display</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator">Control_L+Alt_L</property>
|
||||
<property name="title" translatable="yes">Grab/Ungrab keyboard</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="direction">ltr</property>
|
||||
<property name="accelerator"><Alt>Left</property>
|
||||
<property name="title" translatable="yes">Back to overview</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="direction">rtl</property>
|
||||
<property name="accelerator"><Alt>Right</property>
|
||||
<property name="title" translatable="yes">Back to overview</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator"><Ctrl>q</property>
|
||||
<property name="title" translatable="yes">Close window/Quit Boxes</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="accelerator">F11</property>
|
||||
<property name="title" translatable="yes">Fullscreen/Restore from fullscreen</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -33,6 +33,19 @@ new_widget_info (const char *name,
|
||||
gtk_window_set_resizable (GTK_WINDOW (info->window), FALSE);
|
||||
info->include_decorations = TRUE;
|
||||
}
|
||||
else if (GTK_IS_POPOVER (widget))
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
info->snapshot_popover = TRUE;
|
||||
info->window = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (info->window), 200, 200);
|
||||
gtk_window_set_decorated (GTK_WINDOW (info->window), FALSE);
|
||||
info->include_decorations = TRUE;
|
||||
button = gtk_menu_button_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), widget);
|
||||
gtk_window_set_child (GTK_WINDOW (info->window), button);
|
||||
}
|
||||
else
|
||||
{
|
||||
info->window = gtk_window_new ();
|
||||
@@ -54,7 +67,7 @@ new_widget_info (const char *name,
|
||||
gtk_widget_set_size_request (info->window, 240, 240);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return info;
|
||||
@@ -666,8 +679,9 @@ create_editable_label (void)
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("editable-label", vbox, MEDIUM);
|
||||
return new_widget_info ("editable-label", vbox, SMALL);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_separator (void)
|
||||
{
|
||||
@@ -1067,6 +1081,7 @@ create_picture (void)
|
||||
GtkWidget *vbox;
|
||||
GtkIconTheme *theme;
|
||||
GdkPaintable *paintable;
|
||||
GtkWidget *box;
|
||||
|
||||
theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
|
||||
paintable = GDK_PAINTABLE (gtk_icon_theme_lookup_icon (theme,
|
||||
@@ -1080,8 +1095,12 @@ create_picture (void)
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_append (GTK_BOX (box), g_object_new (GTK_TYPE_IMAGE, "hexpand", TRUE, NULL));
|
||||
gtk_box_append (GTK_BOX (box), widget);
|
||||
gtk_box_append (GTK_BOX (box), g_object_new (GTK_TYPE_IMAGE, "hexpand", TRUE, NULL));
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), box);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Picture"));
|
||||
|
||||
add_margin (vbox);
|
||||
@@ -1094,10 +1113,13 @@ create_video (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *vbox;
|
||||
WidgetInfo *info;
|
||||
|
||||
widget = gtk_video_new_for_filename ("../../demos/gtk-demo/gtk-logo.webm");
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
widget = gtk_video_new_for_filename ("demos/gtk-demo/gtk-logo.webm");
|
||||
gtk_video_set_autoplay (GTK_VIDEO (widget), TRUE);
|
||||
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
@@ -1105,7 +1127,10 @@ create_video (void)
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("video", vbox, SMALL);
|
||||
info = new_widget_info ("video", vbox, MEDIUM);
|
||||
info->wait = 2000;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
@@ -1113,8 +1138,13 @@ create_media_controls (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *vbox;
|
||||
GtkMediaStream *stream;
|
||||
WidgetInfo *info;
|
||||
|
||||
widget = gtk_media_controls_new (NULL);
|
||||
stream = gtk_media_file_new_for_filename ("demos/gtk-demo/gtk-logo.webm");
|
||||
gtk_media_stream_play (stream);
|
||||
widget = gtk_media_controls_new (stream);
|
||||
gtk_widget_set_size_request (widget, 210, -1);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
|
||||
@@ -1124,7 +1154,10 @@ create_media_controls (void)
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("media-controls", vbox, SMALL);
|
||||
info = new_widget_info ("media-controls", vbox, SMALL);
|
||||
info->wait = 2000;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
@@ -1151,25 +1184,18 @@ create_spinner (void)
|
||||
static WidgetInfo *
|
||||
create_volume_button (void)
|
||||
{
|
||||
GtkWidget *button, *box;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *popup;
|
||||
GtkWidget *widget, *vbox;
|
||||
|
||||
widget = gtk_window_new ();
|
||||
gtk_widget_set_size_request (widget, 100, 250);
|
||||
widget = gtk_volume_button_new ();
|
||||
gtk_scale_button_set_value (GTK_SCALE_BUTTON (widget), 33);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (widget), box);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Volume Button"));
|
||||
|
||||
button = gtk_volume_button_new ();
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
gtk_scale_button_set_value (GTK_SCALE_BUTTON (button), 33);
|
||||
popup = gtk_scale_button_get_popup (GTK_SCALE_BUTTON (button));
|
||||
gtk_widget_realize (widget);
|
||||
gtk_widget_show (popup);
|
||||
|
||||
return new_widget_info ("volumebutton", widget, ASIS);
|
||||
return new_widget_info ("volumebutton", vbox, SMALL);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
@@ -1358,6 +1384,7 @@ create_sidebar (void)
|
||||
gtk_widget_add_css_class (view, "view");
|
||||
gtk_widget_set_halign (view, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (view, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_hexpand (view, TRUE);
|
||||
gtk_stack_add_titled (GTK_STACK (stack), view, "page1", "Page 1");
|
||||
view = gtk_text_view_new ();
|
||||
gtk_stack_add_titled (GTK_STACK (stack), view, "page2", "Page 2");
|
||||
@@ -1373,7 +1400,7 @@ create_sidebar (void)
|
||||
gtk_box_append (GTK_BOX (hbox), stack);
|
||||
gtk_frame_set_child (GTK_FRAME (frame), hbox);
|
||||
|
||||
return new_widget_info ("sidebar", frame, ASIS);
|
||||
return new_widget_info ("sidebar", frame, MEDIUM);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
@@ -1471,6 +1498,7 @@ create_flow_box (void)
|
||||
static WidgetInfo *
|
||||
create_gl_area (void)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *gears;
|
||||
@@ -1487,12 +1515,598 @@ create_gl_area (void)
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (gears), GTK_STYLE_PROVIDER (provider), 800);
|
||||
g_object_unref (provider);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("GL Area"));
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
info = new_widget_info ("glarea", vbox, MEDIUM);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_window_controls (void)
|
||||
{
|
||||
GtkWidget *controls;
|
||||
GtkWidget *vbox;
|
||||
|
||||
controls = gtk_window_controls_new (GTK_PACK_END);
|
||||
gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS (controls),
|
||||
":minimize,maximize,close");
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
gtk_widget_set_halign (controls, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (controls, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), controls);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Window Controls"));
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("windowcontrols", vbox, SMALL);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_calendar (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *vbox;
|
||||
|
||||
widget = gtk_calendar_new ();
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Calendar"));
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("calendar", vbox, MEDIUM);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_emojichooser (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
WidgetInfo *info;
|
||||
|
||||
widget = gtk_emoji_chooser_new ();
|
||||
g_object_set (widget, "autohide", FALSE, NULL);
|
||||
|
||||
info = new_widget_info ("emojichooser", widget, ASIS);
|
||||
info->wait = 2000;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_expander (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_expander_new ("Expander");
|
||||
gtk_expander_set_child (GTK_EXPANDER (widget), gtk_label_new ("Hidden Content"));
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
|
||||
return new_widget_info ("expander", widget, SMALL);
|
||||
}
|
||||
|
||||
static void
|
||||
mapped_cb (GtkWidget *widget)
|
||||
{
|
||||
gtk_widget_child_focus (widget, GTK_DIR_RIGHT);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_menu_bar (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *vbox;
|
||||
GMenu *menu, *menu1;
|
||||
GMenuItem *item;
|
||||
|
||||
menu = g_menu_new ();
|
||||
menu1 = g_menu_new ();
|
||||
item = g_menu_item_new ("Item", "action");
|
||||
g_menu_append_item (menu1, item);
|
||||
g_menu_append_submenu (menu, "File", G_MENU_MODEL (menu1));
|
||||
g_object_unref (item);
|
||||
g_object_unref (menu1);
|
||||
menu1 = g_menu_new ();
|
||||
item = g_menu_item_new ("Item", "action");
|
||||
g_menu_append_item (menu1, item);
|
||||
g_menu_append_submenu (menu, "Edit", G_MENU_MODEL (menu1));
|
||||
g_object_unref (item);
|
||||
g_object_unref (menu1);
|
||||
menu1 = g_menu_new ();
|
||||
item = g_menu_item_new ("Item", "action");
|
||||
g_menu_append_item (menu1, item);
|
||||
g_menu_append_submenu (menu, "View", G_MENU_MODEL (menu1));
|
||||
g_object_unref (item);
|
||||
g_object_unref (menu1);
|
||||
|
||||
widget = gtk_popover_menu_bar_new_from_model (G_MENU_MODEL (menu));
|
||||
|
||||
g_object_unref (menu);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Menu Bar"));
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
g_signal_connect (widget, "map", G_CALLBACK (mapped_cb), NULL);
|
||||
|
||||
return new_widget_info ("menubar", vbox, SMALL);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_popover (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *child;
|
||||
WidgetInfo *info;
|
||||
|
||||
widget = gtk_popover_new ();
|
||||
gtk_widget_set_size_request (widget, 180, 180);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
g_object_set (widget, "autohide", FALSE, NULL);
|
||||
child = gtk_label_new ("Popover");
|
||||
gtk_widget_set_halign (child, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
|
||||
gtk_popover_set_child (GTK_POPOVER (widget), child);
|
||||
|
||||
info = new_widget_info ("popover", widget, ASIS);
|
||||
info->wait = 100;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_menu (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GMenu *menu, *menu1;
|
||||
GMenuItem *item;
|
||||
GSimpleActionGroup *group;
|
||||
GSimpleAction *action;
|
||||
GtkEventController *controller;
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
menu = g_menu_new ();
|
||||
menu1 = g_menu_new ();
|
||||
item = g_menu_item_new ("Item", "action");
|
||||
g_menu_append_item (menu1, item);
|
||||
g_menu_append_submenu (menu, "Style", G_MENU_MODEL (menu1));
|
||||
g_object_unref (item);
|
||||
g_object_unref (menu1);
|
||||
item = g_menu_item_new ("Transition", "menu.transition");
|
||||
g_menu_append_item (menu, item);
|
||||
g_object_unref (item);
|
||||
|
||||
menu1 = g_menu_new ();
|
||||
item = g_menu_item_new ("Inspector", "menu.inspector");
|
||||
g_menu_append_item (menu1, item);
|
||||
g_object_unref (item);
|
||||
item = g_menu_item_new ("About", "menu.about");
|
||||
g_menu_append_item (menu1, item);
|
||||
g_object_unref (item);
|
||||
g_menu_append_section (menu, NULL, G_MENU_MODEL (menu1));
|
||||
g_object_unref (menu1);
|
||||
|
||||
widget = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
|
||||
|
||||
g_object_unref (menu);
|
||||
|
||||
group = g_simple_action_group_new ();
|
||||
action = g_simple_action_new_stateful ("transition", NULL, g_variant_new_boolean (TRUE));
|
||||
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
action = g_simple_action_new ("inspector", NULL);
|
||||
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
action = g_simple_action_new ("about", NULL);
|
||||
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
|
||||
g_object_unref (action);
|
||||
|
||||
gtk_widget_insert_action_group (widget, "menu", G_ACTION_GROUP (group));
|
||||
|
||||
g_object_unref (group);
|
||||
|
||||
g_object_set (widget, "autohide", FALSE, NULL);
|
||||
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_F1, 0),
|
||||
gtk_named_action_new ("menu.about"));
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
|
||||
return new_widget_info ("menu", widget, ASIS);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_shortcuts_window (void)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *overlay;
|
||||
|
||||
builder = gtk_builder_new_from_resource ("/shortcuts-boxes.ui");
|
||||
overlay = GTK_WIDGET (gtk_builder_get_object (builder, "shortcuts-boxes"));
|
||||
g_object_set (overlay, "view-name", "display", NULL);
|
||||
g_object_ref (overlay);
|
||||
g_object_unref (builder);
|
||||
|
||||
return new_widget_info ("shortcuts-window", overlay, ASIS);
|
||||
}
|
||||
|
||||
static void
|
||||
oval_path (cairo_t *cr,
|
||||
double xc, double yc,
|
||||
double xr, double yr)
|
||||
{
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_translate (cr, xc, yc);
|
||||
cairo_scale (cr, 1.0, yr / xr);
|
||||
cairo_move_to (cr, xr, 0.0);
|
||||
cairo_arc (cr,
|
||||
0, 0,
|
||||
xr,
|
||||
0, 2 * G_PI);
|
||||
cairo_close_path (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
fill_checks (cairo_t *cr,
|
||||
int x, int y,
|
||||
int width, int height)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
#define CHECK_SIZE 16
|
||||
|
||||
cairo_rectangle (cr, x, y, width, height);
|
||||
cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
|
||||
cairo_fill (cr);
|
||||
|
||||
/* Only works for CHECK_SIZE a power of 2 */
|
||||
j = x & (-CHECK_SIZE);
|
||||
|
||||
for (; j < height; j += CHECK_SIZE)
|
||||
{
|
||||
i = y & (-CHECK_SIZE);
|
||||
for (; i < width; i += CHECK_SIZE)
|
||||
if ((i / CHECK_SIZE + j / CHECK_SIZE) % 2 == 0)
|
||||
cairo_rectangle (cr, i, j, CHECK_SIZE, CHECK_SIZE);
|
||||
}
|
||||
|
||||
cairo_set_source_rgb (cr, 0.7, 0.7, 0.7);
|
||||
cairo_fill (cr);
|
||||
|
||||
#undef CHECK_SIZE
|
||||
}
|
||||
|
||||
static void
|
||||
draw_3circles (cairo_t *cr,
|
||||
double xc, double yc,
|
||||
double radius,
|
||||
double alpha)
|
||||
{
|
||||
double subradius = radius * (2 / 3. - 0.1);
|
||||
|
||||
cairo_set_source_rgba (cr, 1., 0., 0., alpha);
|
||||
oval_path (cr,
|
||||
xc + radius / 3. * cos (G_PI * (0.5)),
|
||||
yc - radius / 3. * sin (G_PI * (0.5)),
|
||||
subradius, subradius);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_set_source_rgba (cr, 0., 1., 0., alpha);
|
||||
oval_path (cr,
|
||||
xc + radius / 3. * cos (G_PI * (0.5 + 2/.3)),
|
||||
yc - radius / 3. * sin (G_PI * (0.5 + 2/.3)),
|
||||
subradius, subradius);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_set_source_rgba (cr, 0., 0., 1., alpha);
|
||||
oval_path (cr,
|
||||
xc + radius / 3. * cos (G_PI * (0.5 + 4/.3)),
|
||||
yc - radius / 3. * sin (G_PI * (0.5 + 4/.3)),
|
||||
subradius, subradius);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
groups_draw (GtkDrawingArea *darea,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
cairo_surface_t *overlay, *punch, *circles;
|
||||
cairo_t *overlay_cr, *punch_cr, *circles_cr;
|
||||
|
||||
/* Fill the background */
|
||||
double radius = 0.5 * (width < height ? width : height) - 10;
|
||||
double xc = width / 2.;
|
||||
double yc = height / 2.;
|
||||
|
||||
overlay = cairo_surface_create_similar (cairo_get_target (cr),
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
width, height);
|
||||
|
||||
punch = cairo_surface_create_similar (cairo_get_target (cr),
|
||||
CAIRO_CONTENT_ALPHA,
|
||||
width, height);
|
||||
|
||||
circles = cairo_surface_create_similar (cairo_get_target (cr),
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
width, height);
|
||||
|
||||
fill_checks (cr, 0, 0, width, height);
|
||||
|
||||
/* Draw a black circle on the overlay
|
||||
*/
|
||||
overlay_cr = cairo_create (overlay);
|
||||
cairo_set_source_rgb (overlay_cr, 0., 0., 0.);
|
||||
oval_path (overlay_cr, xc, yc, radius, radius);
|
||||
cairo_fill (overlay_cr);
|
||||
|
||||
/* Draw 3 circles to the punch surface, then cut
|
||||
* that out of the main circle in the overlay
|
||||
*/
|
||||
punch_cr = cairo_create (punch);
|
||||
draw_3circles (punch_cr, xc, yc, radius, 1.0);
|
||||
cairo_destroy (punch_cr);
|
||||
|
||||
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_DEST_OUT);
|
||||
cairo_set_source_surface (overlay_cr, punch, 0, 0);
|
||||
cairo_paint (overlay_cr);
|
||||
|
||||
/* Now draw the 3 circles in a subgroup again
|
||||
* at half intensity, and use OperatorAdd to join up
|
||||
* without seams.
|
||||
*/
|
||||
circles_cr = cairo_create (circles);
|
||||
|
||||
cairo_set_operator (circles_cr, CAIRO_OPERATOR_OVER);
|
||||
draw_3circles (circles_cr, xc, yc, radius, 0.5);
|
||||
cairo_destroy (circles_cr);
|
||||
|
||||
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_ADD);
|
||||
cairo_set_source_surface (overlay_cr, circles, 0, 0);
|
||||
cairo_paint (overlay_cr);
|
||||
|
||||
cairo_destroy (overlay_cr);
|
||||
|
||||
cairo_set_source_surface (cr, overlay, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_surface_destroy (overlay);
|
||||
cairo_surface_destroy (punch);
|
||||
cairo_surface_destroy (circles);
|
||||
}
|
||||
|
||||
|
||||
static WidgetInfo *
|
||||
create_drawing_area (void)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *da;
|
||||
|
||||
widget = gtk_frame_new (NULL);
|
||||
da = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (da, 96, 96);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), groups_draw, NULL, NULL);
|
||||
gtk_frame_set_child (GTK_FRAME (widget), da);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
|
||||
|
||||
add_margin (widget);
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Drawing Area"));
|
||||
|
||||
info = new_widget_info ("glarea", widget, MEDIUM);
|
||||
add_margin (vbox);
|
||||
|
||||
info = new_widget_info ("drawingarea", vbox, MEDIUM);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_box (void)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *widget;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 40);
|
||||
gtk_widget_set_margin_top (hbox, 20);
|
||||
gtk_widget_set_margin_bottom (hbox, 20);
|
||||
gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
|
||||
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
GtkWidget *button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (widget), button);
|
||||
}
|
||||
gtk_box_append (GTK_BOX (widget), gtk_label_new ("⋯"));
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (hbox), widget);
|
||||
widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
GtkWidget *button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (widget), button);
|
||||
}
|
||||
gtk_box_append (GTK_BOX (widget), gtk_label_new ("⋮"));
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (hbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
|
||||
"label", "Horizontal and Vertical Boxes",
|
||||
"justify", GTK_JUSTIFY_CENTER,
|
||||
NULL));
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("box", vbox, MEDIUM);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_center_box (void)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *button;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
widget = gtk_center_box_new ();
|
||||
gtk_widget_set_margin_top (widget, 10);
|
||||
gtk_widget_set_margin_bottom (widget, 10);
|
||||
gtk_widget_set_margin_start (widget, 20);
|
||||
gtk_widget_set_margin_end (widget, 20);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_center_box_set_start_widget (GTK_CENTER_BOX (widget), button);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_center_box_set_center_widget (GTK_CENTER_BOX (widget), button);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
|
||||
"label", "Center Box",
|
||||
"justify", GTK_JUSTIFY_CENTER,
|
||||
NULL));
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("centerbox", vbox, SMALL);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_grid (void)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *button;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
|
||||
widget = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (widget), 4);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (widget), 4);
|
||||
gtk_widget_set_margin_top (widget, 20);
|
||||
gtk_widget_set_margin_bottom (widget, 20);
|
||||
gtk_widget_set_margin_start (widget, 20);
|
||||
gtk_widget_set_margin_end (widget, 20);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_grid_attach (GTK_GRID (widget), button, 0, 0, 1, 1);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_grid_attach (GTK_GRID (widget), button, 0, 1, 1, 1);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_grid_attach (GTK_GRID (widget), button, 1, 0, 1, 1);
|
||||
|
||||
button = gtk_button_new ();
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_grid_attach (GTK_GRID (widget), button, 1, 1, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (widget), gtk_label_new ("⋯"), 2, 0, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (widget), gtk_label_new ("⋮"), 0, 2, 1, 1);
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
|
||||
"label", "Grid",
|
||||
"justify", GTK_JUSTIFY_CENTER,
|
||||
NULL));
|
||||
add_margin (vbox);
|
||||
|
||||
return new_widget_info ("grid", vbox, MEDIUM);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_overlay (void)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *overlay;
|
||||
GtkWidget *label;
|
||||
GtkWidget *child;
|
||||
|
||||
widget = gtk_frame_new (NULL);
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_widget_add_css_class (widget, "view");
|
||||
label = gtk_label_new ("Content");
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_frame_set_child (GTK_FRAME (widget), overlay);
|
||||
gtk_overlay_set_child (GTK_OVERLAY (overlay), label);
|
||||
|
||||
child = gtk_frame_new (NULL);
|
||||
gtk_widget_add_css_class (child, "app-notification");
|
||||
gtk_frame_set_child (GTK_FRAME (child), gtk_label_new ("Overlay"));
|
||||
gtk_widget_set_valign (child, GTK_ALIGN_START);
|
||||
gtk_widget_set_halign (child, GTK_ALIGN_CENTER);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
|
||||
|
||||
gtk_box_append (GTK_BOX (vbox), widget);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Overlay"));
|
||||
|
||||
add_margin (vbox);
|
||||
|
||||
info = new_widget_info ("overlay", vbox, MEDIUM);
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -1501,6 +2115,18 @@ GList *
|
||||
get_all_widgets (void)
|
||||
{
|
||||
GList *retval = NULL;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider,
|
||||
"button.small {\n"
|
||||
" min-width: 16px;\n"
|
||||
" min-height: 16px;\n"
|
||||
" padding: 0;\n"
|
||||
"}", -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
|
||||
retval = g_list_prepend (retval, create_search_bar ());
|
||||
retval = g_list_prepend (retval, create_action_bar ());
|
||||
@@ -1562,6 +2188,19 @@ get_all_widgets (void)
|
||||
retval = g_list_prepend (retval, create_password_entry ());
|
||||
retval = g_list_prepend (retval, create_editable_label ());
|
||||
retval = g_list_prepend (retval, create_drop_down ());
|
||||
retval = g_list_prepend (retval, create_window_controls ());
|
||||
retval = g_list_prepend (retval, create_calendar ());
|
||||
retval = g_list_prepend (retval, create_emojichooser ());
|
||||
retval = g_list_prepend (retval, create_expander ());
|
||||
retval = g_list_prepend (retval, create_menu_bar ());
|
||||
retval = g_list_prepend (retval, create_popover ());
|
||||
retval = g_list_prepend (retval, create_menu ());
|
||||
retval = g_list_prepend (retval, create_shortcuts_window ());
|
||||
retval = g_list_prepend (retval, create_drawing_area ());
|
||||
retval = g_list_prepend (retval, create_box ());
|
||||
retval = g_list_prepend (retval, create_center_box ());
|
||||
retval = g_list_prepend (retval, create_grid ());
|
||||
retval = g_list_prepend (retval, create_overlay ());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ typedef struct WidgetInfo
|
||||
char *name;
|
||||
gboolean no_focus;
|
||||
gboolean include_decorations;
|
||||
gboolean snapshot_popover;
|
||||
guint wait;
|
||||
WidgetSize size;
|
||||
} WidgetInfo;
|
||||
|
||||
|
||||
@@ -11,49 +11,49 @@ print_hello (GtkWidget *widget,
|
||||
static void
|
||||
quit_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
gboolean *done = data;
|
||||
GtkWindow *window = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
gtk_window_close (window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
static void
|
||||
activate (GtkApplication *app,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GObject *window;
|
||||
GObject *button;
|
||||
gboolean done = FALSE;
|
||||
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
gtk_init ();
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
builder = gtk_builder_new ();
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (builder, "builder.ui", NULL);
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object (builder, "window");
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
GObject *window = gtk_builder_get_object (builder, "window");
|
||||
gtk_window_set_application (GTK_WINDOW (window), app);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button1");
|
||||
GObject *button = gtk_builder_get_object (builder, "button1");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "button2");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
||||
|
||||
button = gtk_builder_get_object (builder, "quit");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
|
||||
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
return 0;
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
#endif
|
||||
|
||||
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
|
||||
|
||||
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
display_broadway->core_pointer,
|
||||
NULL,
|
||||
message->base.time,
|
||||
0,
|
||||
message->pointer.state,
|
||||
message->scroll.dir == 0
|
||||
? GDK_SCROLL_UP
|
||||
: GDK_SCROLL_DOWN,
|
||||
|
||||
@@ -87,12 +87,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* GDK_WINDOWING_QUARTZ:
|
||||
* GDK_WINDOWING_MACOS:
|
||||
*
|
||||
* The #GDK_WINDOWING_QUARTZ macro is defined if the Quartz backend
|
||||
* The #GDK_WINDOWING_MACOS macro is defined if the MacOS backend
|
||||
* is supported.
|
||||
*
|
||||
* Use this macro to guard code that is specific to the Quartz backend.
|
||||
* Use this macro to guard code that is specific to the MacOS backend.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
*
|
||||
* These functions are used to create and destroy cursors. Cursors
|
||||
* are immutable objects, so once you created them, there is no way
|
||||
* to modify them later. Create a new cursor, when you want to change
|
||||
* to modify them later. Create a new cursor when you want to change
|
||||
* something about it.
|
||||
*
|
||||
* Cursors by themselves are not very interesting, they must be
|
||||
* bound to a window for users to see them. This is done with
|
||||
* gdk_surface_set_cursor() or gdk_surface_set_device_cursor().
|
||||
* Applications will typically use higher-level GTK+ functions such
|
||||
* Applications will typically use higher-level GTK functions such
|
||||
* as gtk_widget_set_cursor() instead.
|
||||
*
|
||||
* Cursors are not bound to a given #GdkDisplay, so they can be shared.
|
||||
@@ -59,16 +59,19 @@
|
||||
* There are multiple ways to create cursors. The platform's own cursors
|
||||
* can be created with gdk_cursor_new_from_name(). That function lists
|
||||
* the commonly available names that are shared with the CSS specification.
|
||||
* Other names may be available, depending on the platform in use.
|
||||
* Other names may be available, depending on the platform in use. On some
|
||||
* platforms, what images are used for named cursors may be influenced by
|
||||
* the cursor theme.
|
||||
*
|
||||
* Another option to create a cursor is to use gdk_cursor_new_from_texture()
|
||||
* and provide an image to use for the cursor.
|
||||
*
|
||||
* To ease work with unsupported cursors, a fallback cursor can be provided.
|
||||
* If a #GdkSurface cannot use a cursor because of the reasons mentioned above,
|
||||
* it will try the fallback cursor. Of course, fallback cursors can themselves
|
||||
* have fallback cursors again, so it is possible to provide a chain of
|
||||
* progressively easier to support cursors. If none of the provided cursors
|
||||
* can be supported, the default cursor will be the ultimate fallback.
|
||||
* it will try the fallback cursor. Fallback cursors can themselves have fallback
|
||||
* cursors again, so it is possible to provide a chain of progressively easier
|
||||
* to support cursors. If none of the provided cursors can be supported, the
|
||||
* default cursor will be the ultimate fallback.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -175,40 +178,40 @@ gdk_cursor_class_init (GdkCursorClass *cursor_class)
|
||||
object_class->finalize = gdk_cursor_finalize;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_FALLBACK,
|
||||
g_param_spec_object ("fallback",
|
||||
PROP_FALLBACK,
|
||||
g_param_spec_object ("fallback",
|
||||
P_("Fallback"),
|
||||
P_("Cursor image to fall back to if this cursor cannot be displayed"),
|
||||
GDK_TYPE_CURSOR,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_HOTSPOT_X,
|
||||
g_param_spec_int ("hotspot-x",
|
||||
PROP_HOTSPOT_X,
|
||||
g_param_spec_int ("hotspot-x",
|
||||
P_("Hotspot X"),
|
||||
P_("Horizontal offset of the cursor hotspot"),
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_HOTSPOT_Y,
|
||||
g_param_spec_int ("hotspot-y",
|
||||
PROP_HOTSPOT_Y,
|
||||
g_param_spec_int ("hotspot-y",
|
||||
P_("Hotspot Y"),
|
||||
P_("Vertical offset of the cursor hotspot"),
|
||||
0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_NAME,
|
||||
g_param_spec_string ("name",
|
||||
PROP_NAME,
|
||||
g_param_spec_string ("name",
|
||||
P_("Name"),
|
||||
P_("Name of this cursor"),
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXTURE,
|
||||
g_param_spec_object ("texture",
|
||||
PROP_TEXTURE,
|
||||
g_param_spec_object ("texture",
|
||||
P_("Texture"),
|
||||
P_("The texture displayed by this cursor"),
|
||||
GDK_TYPE_TEXTURE,
|
||||
@@ -345,8 +348,8 @@ gdk_cursor_new_from_name (const char *name,
|
||||
*/
|
||||
GdkCursor *
|
||||
gdk_cursor_new_from_texture (GdkTexture *texture,
|
||||
int hotspot_x,
|
||||
int hotspot_y,
|
||||
int hotspot_x,
|
||||
int hotspot_y,
|
||||
GdkCursor *fallback)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
|
||||
@@ -390,7 +393,7 @@ gdk_cursor_get_fallback (GdkCursor *cursor)
|
||||
* @cursor: a #GdkCursor.
|
||||
*
|
||||
* Returns the name of the cursor. If the cursor is not a named cursor, %NULL
|
||||
* will be returned and the GdkCursor::texture property will be set.
|
||||
* will be returned.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the name of the cursor or %NULL if it is not
|
||||
* a named cursor
|
||||
@@ -408,7 +411,7 @@ gdk_cursor_get_name (GdkCursor *cursor)
|
||||
* @cursor: a #GdkCursor.
|
||||
*
|
||||
* Returns the texture for the cursor. If the cursor is a named cursor, %NULL
|
||||
* will be returned and the GdkCursor::name property will be set.
|
||||
* will be returned.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the texture for cursor or %NULL if it is a
|
||||
* named cursor
|
||||
@@ -428,6 +431,10 @@ gdk_cursor_get_texture (GdkCursor *cursor)
|
||||
* Returns the horizontal offset of the hotspot. The hotspot indicates the
|
||||
* pixel that will be directly above the cursor.
|
||||
*
|
||||
* Note that named cursors may have a nonzero hotspot, but this function
|
||||
* will only return the hotspot position for cursors created with
|
||||
* gdk_cursor_new_from_texture().
|
||||
*
|
||||
* Returns: the horizontal offset of the hotspot or 0 for named cursors
|
||||
*/
|
||||
int
|
||||
@@ -445,6 +452,10 @@ gdk_cursor_get_hotspot_x (GdkCursor *cursor)
|
||||
* Returns the vertical offset of the hotspot. The hotspot indicates the
|
||||
* pixel that will be directly above the cursor.
|
||||
*
|
||||
* Note that named cursors may have a nonzero hotspot, but this function
|
||||
* will only return the hotspot position for cursors created with
|
||||
* gdk_cursor_new_from_texture().
|
||||
*
|
||||
* Returns: the vertical offset of the hotspot or 0 for named cursors
|
||||
*/
|
||||
int
|
||||
@@ -454,4 +465,3 @@ gdk_cursor_get_hotspot_y (GdkCursor *cursor)
|
||||
|
||||
return cursor->hotspot_y;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,15 +46,15 @@ GType gdk_cursor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor* gdk_cursor_new_from_texture (GdkTexture *texture,
|
||||
int hotspot_x,
|
||||
int hotspot_y,
|
||||
int hotspot_x,
|
||||
int hotspot_y,
|
||||
GdkCursor *fallback);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor* gdk_cursor_new_from_name (const char *name,
|
||||
GdkCursor* gdk_cursor_new_from_name (const char *name,
|
||||
GdkCursor *fallback);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
|
||||
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char *gdk_cursor_get_name (GdkCursor *cursor);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
@@ -36,16 +36,6 @@
|
||||
#include "x11/gdkprivate-x11.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
/* When the gdk_quartz_display_open function is removed We can
|
||||
* immediately include gdkquartzdisplaymanager.h here instead of
|
||||
* gdkprivate-quartz.h so that we won’t have to enable -xobjective-c
|
||||
* for the “generic” GDK source code.
|
||||
* #include "quartz/gdkquartzdisplaymanager.h"
|
||||
*/
|
||||
#include "quartz/gdkprivate-quartz.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_BROADWAY
|
||||
#include "broadway/gdkprivate-broadway.h"
|
||||
#endif
|
||||
@@ -98,8 +88,8 @@
|
||||
* }
|
||||
* else
|
||||
* #endif
|
||||
* #ifdef GDK_WINDOWING_QUARTZ
|
||||
* if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
* #ifdef GDK_WINDOWING_MACOS
|
||||
* if (GDK_IS_MACOS_DISPLAY (display))
|
||||
* {
|
||||
* // make Quartz-specific calls here
|
||||
* }
|
||||
@@ -263,9 +253,6 @@ struct _GdkBackend {
|
||||
};
|
||||
|
||||
static GdkBackend gdk_backends[] = {
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
{ "quartz", _gdk_quartz_display_open },
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
{ "macos", _gdk_macos_display_open },
|
||||
#endif
|
||||
@@ -305,7 +292,7 @@ gdk_display_manager_get (void)
|
||||
|
||||
if (manager == NULL)
|
||||
manager = g_object_new (GDK_TYPE_DISPLAY_MANAGER, NULL);
|
||||
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
@@ -344,7 +331,7 @@ gdk_display_get_default (void)
|
||||
* gdk_display_manager_set_default_display:
|
||||
* @manager: a #GdkDisplayManager
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
*
|
||||
* Sets @display as the default display.
|
||||
**/
|
||||
void
|
||||
|
||||
@@ -814,12 +814,17 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
|
||||
void
|
||||
_gdk_event_queue_flush (GdkDisplay *display)
|
||||
{
|
||||
GList *tmp_list;
|
||||
|
||||
for (tmp_list = display->queued_events.head; tmp_list; tmp_list = tmp_list->next)
|
||||
while (TRUE)
|
||||
{
|
||||
GdkEvent *event = tmp_list->data;
|
||||
GdkEvent *event;
|
||||
|
||||
event = (GdkEvent *)g_queue_pop_head (&display->queued_events);
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
event->flags |= GDK_EVENT_FLUSHED;
|
||||
_gdk_event_emit (event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
|
||||
/**
|
||||
* SECTION:gdkframeclock
|
||||
* @Short_description: Frame clock syncs painting to a window or display
|
||||
* @Title: Frame clock
|
||||
* @Title: GdkFrameClock
|
||||
* @Short_description: Synchronizes painting to a surface
|
||||
*
|
||||
* A #GdkFrameClock tells the application when to update and repaint a
|
||||
* window. This may be synced to the vertical refresh rate of the
|
||||
* A #GdkFrameClock tells the application when to update and repaint
|
||||
* a surface. This may be synced to the vertical refresh rate of the
|
||||
* monitor, for example. Even when the frame clock uses a simple timer
|
||||
* rather than a hardware-based vertical sync, the frame clock helps
|
||||
* because it ensures everything paints at the same time (reducing the
|
||||
|
||||
@@ -864,7 +864,7 @@ gdk_gl_context_get_use_es (GdkGLContext *context)
|
||||
return priv->use_es > 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void APIENTRY
|
||||
gl_debug_message_callback (GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
|
||||
@@ -49,10 +49,6 @@ struct _GdkGLContextClass
|
||||
GError **error);
|
||||
|
||||
cairo_region_t * (* get_damage) (GdkGLContext *context);
|
||||
|
||||
gboolean (* texture_from_surface) (GdkGLContext *context,
|
||||
cairo_surface_t *surface,
|
||||
cairo_region_t *region);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -35,7 +35,7 @@ void gtk_snapshot_pop (GdkSnapshot
|
||||
* @Short_description: An interface for a paintable region
|
||||
* @See_also: #ClutterContent, #GtkImage, #GdkTexture, #GtkSnapshot
|
||||
*
|
||||
* #GdkPaintable is a simple interface used by GDK and GDK to represent
|
||||
* #GdkPaintable is a simple interface used by GDK and GTK to represent
|
||||
* objects that can be painted anywhere at any size without requiring any
|
||||
* sort of layout. The interface is inspired by similar concepts elsewhere,
|
||||
* such as [ClutterContent](https://developer.gnome.org/clutter/stable/ClutterContent.html),
|
||||
@@ -347,22 +347,22 @@ gdk_paintable_get_intrinsic_height (GdkPaintable *paintable)
|
||||
* @paintable: a #GdkPaintable
|
||||
*
|
||||
* Gets the preferred aspect ratio the @paintable would like to be displayed at.
|
||||
* The aspect ration is the width divided by the height, so a value of 0.5 means
|
||||
* The aspect ratio is the width divided by the height, so a value of 0.5 means
|
||||
* that the @paintable prefers to be displayed twice as high as it is wide.
|
||||
* Consumers of this interface can use this to preserve aspect ratio when displaying
|
||||
* this paintable.
|
||||
* the paintable.
|
||||
*
|
||||
* This is a purely informational value and does not in any way limit the values
|
||||
* that may be passed to gdk_paintable_snapshot().
|
||||
*
|
||||
* Usually when a @paintable returns non-0 values from
|
||||
* Usually when a @paintable returns nonzero values from
|
||||
* gdk_paintable_get_intrinsic_width() and gdk_paintable_get_intrinsic_height()
|
||||
* the aspect ratio should conform to those values, though that is not required.
|
||||
*
|
||||
* If the @paintable does not have a preferred aspect ratio, it returns 0.0.
|
||||
* If the @paintable does not have a preferred aspect ratio, it returns 0.
|
||||
* Negative values are never returned.
|
||||
*
|
||||
* Returns: the intrinsic aspect ratio of @paintable or 0.0 if none.
|
||||
* Returns: the intrinsic aspect ratio of @paintable or 0 if none.
|
||||
*/
|
||||
double
|
||||
gdk_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
|
||||
@@ -379,9 +379,9 @@ gdk_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
|
||||
* gdk_paintable_invalidate_contents:
|
||||
* @paintable: a #GdkPaintable
|
||||
*
|
||||
* Called by implementations of #GdkPaintable to invalidate their contents.
|
||||
* Called by implementations of #GdkPaintable to invalidate their contents.
|
||||
* Unless the contents are invalidated, implementations must guarantee that
|
||||
* multiple calls to GdkPaintable::snapshot produce the same output.
|
||||
* multiple calls of gdk_paintable_snapshot() produce the same output.
|
||||
*
|
||||
* This function will emit the #GdkPaintable::invalidate-contents signal.
|
||||
*
|
||||
@@ -401,9 +401,9 @@ gdk_paintable_invalidate_contents (GdkPaintable *paintable)
|
||||
* gdk_paintable_invalidate_size:
|
||||
* @paintable: a #GdkPaintable
|
||||
*
|
||||
* Called by implementations of #GdkPaintable to invalidate their size.
|
||||
* As long as the size is not invalidated, @paintable must return the same values
|
||||
* for its width, height and intrinsic height.
|
||||
* Called by implementations of #GdkPaintable to invalidate their size.
|
||||
* As long as the size is not invalidated, @paintable must return the same
|
||||
* values for its intrinsic width, height and aspect ratio.
|
||||
*
|
||||
* This function will emit the #GdkPaintable::invalidate-size signal.
|
||||
*
|
||||
@@ -435,7 +435,7 @@ gdk_paintable_invalidate_size (GdkPaintable *paintable)
|
||||
* @concrete_height: (out): will be set to the concrete height
|
||||
* computed.
|
||||
*
|
||||
* Applies the sizing algorithm outlined in
|
||||
* Applies the sizing algorithm outlined in
|
||||
* https://drafts.csswg.org/css-images-3/#default-sizing
|
||||
* to the given @paintable. See that link for more details.
|
||||
*
|
||||
|
||||
@@ -27,9 +27,13 @@
|
||||
* SECTION:gdkpopup
|
||||
* @Short_description: Interface for popup surfaces
|
||||
* @Title: Popups
|
||||
* @See_also: #GdkToplevel, #GdkSurface
|
||||
*
|
||||
* A #GdkPopup is a surface that is attached to another surface,
|
||||
* and is positioned relative to it.
|
||||
* called its #GdkPopup:parent, and is positioned relative to it.
|
||||
*
|
||||
* #GdkPopups are typically used to implement menus and similar popups.
|
||||
* They can be modal, which is indicated by the #GdkPopup:autohide property.
|
||||
*/
|
||||
|
||||
G_DEFINE_INTERFACE (GdkPopup, gdk_popup, GDK_TYPE_SURFACE)
|
||||
|
||||
@@ -30,21 +30,23 @@
|
||||
|
||||
/**
|
||||
* SECTION:regions
|
||||
* @Short_description: Simple graphical data types
|
||||
* @Title: Points and Rectangles
|
||||
* @Short_description: Simple graphical data type
|
||||
* @Title: GdkRectangle
|
||||
*
|
||||
* GDK provides the #GdkPoint and #GdkRectangle data types for representing pixels
|
||||
* and sets of pixels on the screen. Together with Cairo’s #cairo_region_t data
|
||||
* type, they make up the central types for representing graphical data.
|
||||
*
|
||||
* A #GdkPoint represents an x and y coordinate of a point.
|
||||
* GDK provides a #GdkRectangle data type for representing rectangles.
|
||||
* Together with Cairo’s #cairo_region_t data type, these are the central
|
||||
* types for representing sets of pixels.
|
||||
*
|
||||
* A #GdkRectangle represents the position and size of a rectangle.
|
||||
* The intersection of two rectangles can be computed with
|
||||
* gdk_rectangle_intersect(). To find the union of two rectangles use
|
||||
* gdk_rectangle_union().
|
||||
*
|
||||
* #cairo_region_t is usually used for managing clipping of graphical operations.
|
||||
* #cairo_region_t is usually used for managing clipping of graphical
|
||||
* operations.
|
||||
*
|
||||
* The graphene library has a number of other data types for regions and
|
||||
* volumes in 2D and 3D.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
/**
|
||||
* SECTION:rgba_colors
|
||||
* @Title: GdkRGBA
|
||||
* @Short_description: RGBA colors
|
||||
* @Title: RGBA Colors
|
||||
*
|
||||
* #GdkRGBA is a convenient way to pass rgba colors around.
|
||||
* #GdkRGBA is a convenient way to pass colors around.
|
||||
* It’s based on cairo’s way to deal with colors and mirrors its behavior.
|
||||
* All values are in the range from 0.0 to 1.0 inclusive. So the color
|
||||
* (0.0, 0.0, 0.0, 0.0) represents transparent black and
|
||||
|
||||
@@ -55,10 +55,17 @@
|
||||
* SECTION:gdksurface
|
||||
* @Short_description: Onscreen display areas in the target window system
|
||||
* @Title: Surfaces
|
||||
* @See_also: #GdkToplevel, #GdkPopup
|
||||
*
|
||||
* A #GdkSurface is a (usually) rectangular region on the screen.
|
||||
* It’s a low-level object, used to implement high-level objects such as
|
||||
* #GtkWindow on the GTK level.
|
||||
* It’s a low-level object, used to implement high-level objects
|
||||
* such as #GtkWindow or #GtkDialog in GTK.
|
||||
*
|
||||
* The surfaces you see in practice are either #GdkToplevel or
|
||||
* #GdkPopup, and those interfaces provide much of the required
|
||||
* API to interact with these surfaces. Other, more specialized
|
||||
* surface types exist, but you will rarely interact with them
|
||||
* directly.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -1401,13 +1408,9 @@ impl_surface_add_update_area (GdkSurface *impl_surface,
|
||||
void
|
||||
gdk_surface_queue_render (GdkSurface *surface)
|
||||
{
|
||||
cairo_region_t *region;
|
||||
|
||||
g_return_if_fail (GDK_IS_SURFACE (surface));
|
||||
|
||||
region = cairo_region_create ();
|
||||
impl_surface_add_update_area (surface, region);
|
||||
cairo_region_destroy (region);
|
||||
gdk_surface_invalidate_rect (surface, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1488,7 +1491,9 @@ gdk_surface_freeze_updates (GdkSurface *surface)
|
||||
|
||||
surface->update_freeze_count++;
|
||||
if (surface->update_freeze_count == 1)
|
||||
{
|
||||
_gdk_frame_clock_uninhibit_freeze (surface->frame_clock);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2051,6 +2056,9 @@ update_cursor (GdkDisplay *display,
|
||||
GdkDeviceGrabInfo *grab;
|
||||
GdkCursor *cursor;
|
||||
|
||||
g_assert (display);
|
||||
g_assert (device);
|
||||
|
||||
pointer_info = _gdk_display_get_pointer_info (display, device);
|
||||
pointer_surface = pointer_info->surface_under_pointer;
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ gdk_texture_class_init (GdkTextureClass *klass)
|
||||
/**
|
||||
* GdkTexture:width:
|
||||
*
|
||||
* The width of the texture.
|
||||
* The width of the texture, in pixels.
|
||||
*/
|
||||
properties[PROP_WIDTH] =
|
||||
g_param_spec_int ("width",
|
||||
@@ -219,7 +219,7 @@ gdk_texture_class_init (GdkTextureClass *klass)
|
||||
/**
|
||||
* GdkTexture:height:
|
||||
*
|
||||
* The height of the texture.
|
||||
* The height of the texture, in pixels.
|
||||
*/
|
||||
properties[PROP_HEIGHT] =
|
||||
g_param_spec_int ("height",
|
||||
@@ -281,7 +281,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
|
||||
* gdk_texture_new_for_pixbuf:
|
||||
* @pixbuf: a #GdkPixbuf
|
||||
*
|
||||
* Creates a new texture object representing the GdkPixbuf.
|
||||
* Creates a new texture object representing the #GdkPixbuf.
|
||||
*
|
||||
* Returns: a new #GdkTexture
|
||||
*/
|
||||
@@ -316,7 +316,9 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
|
||||
* @resource_path: the path of the resource file
|
||||
*
|
||||
* Creates a new texture by loading an image from a resource.
|
||||
* The file format is detected automatically.
|
||||
* The file format is detected automatically, and can be any
|
||||
* format that is supported by the gdk-pixbuf library, such as
|
||||
* JPEG or PNG.
|
||||
*
|
||||
* It is a fatal error if @resource_path does not specify a valid
|
||||
* image resource and the program will abort if that happens.
|
||||
@@ -349,8 +351,12 @@ gdk_texture_new_from_resource (const char *resource_path)
|
||||
* @file: #GFile to load
|
||||
* @error: Return location for an error
|
||||
*
|
||||
* Creates a new texture by loading an image from a file. The file format is
|
||||
* detected automatically. If %NULL is returned, then @error will be set.
|
||||
* Creates a new texture by loading an image from a file.
|
||||
* The file format is detected automatically, and can be any
|
||||
* format that is supported by the gdk-pixbuf library, such as
|
||||
* JPEG or PNG.
|
||||
*
|
||||
* If %NULL is returned, then @error will be set.
|
||||
*
|
||||
* Return value: A newly-created #GdkTexture or %NULL if an error occurred.
|
||||
**/
|
||||
@@ -384,7 +390,7 @@ gdk_texture_new_from_file (GFile *file,
|
||||
* gdk_texture_get_width:
|
||||
* @texture: a #GdkTexture
|
||||
*
|
||||
* Returns the width of @texture.
|
||||
* Returns the width of @texture, in pixels.
|
||||
*
|
||||
* Returns: the width of the #GdkTexture
|
||||
*/
|
||||
@@ -400,7 +406,7 @@ gdk_texture_get_width (GdkTexture *texture)
|
||||
* gdk_texture_get_height:
|
||||
* @texture: a #GdkTexture
|
||||
*
|
||||
* Returns the height of the @texture.
|
||||
* Returns the height of the @texture, in pixels.
|
||||
*
|
||||
* Returns: the height of the #GdkTexture
|
||||
*/
|
||||
@@ -573,4 +579,3 @@ gdk_texture_save_to_png (GdkTexture *texture,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,14 @@
|
||||
* SECTION:gdktoplevel
|
||||
* @Short_description: Interface for toplevel surfaces
|
||||
* @Title: Toplevels
|
||||
* @See_also: #GdkSurface, #GdkPopup
|
||||
*
|
||||
* A #GdkToplevel is a freestanding toplevel surface.
|
||||
*
|
||||
* The #GdkToplevel interface provides useful APIs for
|
||||
* interacting with the windowing system, such as controlling
|
||||
* maximization and size of the surface, setting icons and
|
||||
* transient parents for dialogs.
|
||||
*/
|
||||
|
||||
G_DEFINE_INTERFACE (GdkToplevel, gdk_toplevel, GDK_TYPE_SURFACE)
|
||||
|
||||
@@ -53,20 +53,6 @@ G_BEGIN_DECLS
|
||||
*/
|
||||
#define GDK_CURRENT_TIME 0L
|
||||
|
||||
/**
|
||||
* GdkPoint:
|
||||
* @x: the x coordinate of the point
|
||||
* @y: the y coordinate of the point
|
||||
*
|
||||
* Defines the x and y coordinates of a point.
|
||||
*/
|
||||
struct _GdkPoint
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
typedef struct _GdkPoint GdkPoint;
|
||||
|
||||
/**
|
||||
* GdkRectangle:
|
||||
* @x: the x coordinate of the top left corner
|
||||
|
||||
@@ -57,12 +57,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setNeedsDisplay:(BOOL)needsDisplay
|
||||
{
|
||||
for (id child in [self subviews])
|
||||
[child setNeedsDisplay:needsDisplay];
|
||||
}
|
||||
|
||||
-(void)setOpaqueRegion:(cairo_region_t *)region
|
||||
{
|
||||
/* Do nothing */
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
|
||||
@implementation GdkMacosCairoSubview
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
g_clear_pointer (&self->clip, cairo_region_destroy);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(BOOL)isOpaque
|
||||
{
|
||||
return _isOpaque;
|
||||
@@ -95,6 +101,21 @@
|
||||
cr = cairo_create (dest);
|
||||
cairo_translate (cr, -abs_bounds.origin.x, -abs_bounds.origin.y);
|
||||
|
||||
/* Apply the clip if provided one */
|
||||
if (self->clip != NULL)
|
||||
{
|
||||
cairo_rectangle_int_t area;
|
||||
|
||||
n_rects = cairo_region_num_rectangles (self->clip);
|
||||
for (guint i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (self->clip, i, &area);
|
||||
cairo_rectangle (cr, area.x, area.y, area.width, area.height);
|
||||
}
|
||||
|
||||
cairo_clip (cr);
|
||||
}
|
||||
|
||||
/* Clip the cairo context based on the rectangles to be drawn
|
||||
* within the bounding box :rect.
|
||||
*/
|
||||
@@ -168,4 +189,14 @@
|
||||
self->_isOpaque = opaque;
|
||||
}
|
||||
|
||||
-(void)setClip:(cairo_region_t*)region
|
||||
{
|
||||
if (region != self->clip)
|
||||
{
|
||||
g_clear_pointer (&self->clip, cairo_region_destroy);
|
||||
if (region != NULL)
|
||||
self->clip = cairo_region_reference (region);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -26,10 +26,12 @@
|
||||
{
|
||||
BOOL _isOpaque;
|
||||
cairo_surface_t *cairoSurface;
|
||||
cairo_region_t *clip;
|
||||
}
|
||||
|
||||
-(void)setOpaque:(BOOL)opaque;
|
||||
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
|
||||
withDamage:(cairo_region_t *)region;
|
||||
-(void)setClip:(cairo_region_t*)region;
|
||||
|
||||
@end
|
||||
|
||||
@@ -53,6 +53,12 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)setNeedsDisplay:(BOOL)needsDisplay
|
||||
{
|
||||
for (id child in [self subviews])
|
||||
[child setNeedsDisplay:needsDisplay];
|
||||
}
|
||||
|
||||
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
|
||||
withDamage:(cairo_region_t *)cairoRegion
|
||||
{
|
||||
@@ -72,6 +78,7 @@
|
||||
|
||||
-(void)setOpaqueRegion:(cairo_region_t *)region
|
||||
{
|
||||
cairo_region_t *transparent_clip;
|
||||
NSRect abs_bounds;
|
||||
guint n_rects;
|
||||
|
||||
@@ -81,6 +88,17 @@
|
||||
abs_bounds = [self convertRect:[self bounds] toView:nil];
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
|
||||
/* First, we create a clip region for the transparent region to use so that
|
||||
* we dont end up exposing too much other than the corners on CSD.
|
||||
*/
|
||||
transparent_clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
|
||||
abs_bounds.origin.x, abs_bounds.origin.y,
|
||||
abs_bounds.size.width, abs_bounds.size.height
|
||||
});
|
||||
cairo_region_subtract (transparent_clip, region);
|
||||
[(GdkMacosCairoSubview *)self->transparent setClip:transparent_clip];
|
||||
cairo_region_destroy (transparent_clip);
|
||||
|
||||
/* The common case (at least for opaque windows and CSD) is that we will
|
||||
* have either one or two opaque rectangles. If we detect that the same
|
||||
* number of them are available as the previous, we can just resize the
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/* GdkMacosGLLayer.c
|
||||
*
|
||||
* Copyright © 2020 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/* Based on Chromium image_transport_surface_calayer_mac.mm
|
||||
* See the BSD-style license above.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <OpenGL/gl.h>
|
||||
|
||||
#import "GdkMacosGLLayer.h"
|
||||
|
||||
@implementation GdkMacosGLLayer
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
-(id)initWithContext:(NSOpenGLContext *)shared
|
||||
{
|
||||
[super init];
|
||||
_shared = [shared retain];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
[_shared release];
|
||||
_shared = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void)setContentsRect:(NSRect)bounds
|
||||
{
|
||||
_pixelSize = bounds.size;
|
||||
[super setContentsRect:bounds];
|
||||
}
|
||||
|
||||
-(CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
|
||||
{
|
||||
return CGLRetainPixelFormat ([[_shared pixelFormat] CGLPixelFormatObj]);
|
||||
}
|
||||
|
||||
-(CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat
|
||||
{
|
||||
CGLContextObj context = NULL;
|
||||
CGLCreateContext (pixelFormat, [_shared CGLContextObj], &context);
|
||||
return context;
|
||||
}
|
||||
|
||||
-(BOOL)canDrawInCGLContext:(CGLContextObj)glContext
|
||||
pixelFormat:(CGLPixelFormatObj)pixelFormat
|
||||
forLayerTime:(CFTimeInterval)timeInterval
|
||||
displayTime:(const CVTimeStamp*)timeStamp
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)drawInCGLContext:(CGLContextObj)glContext
|
||||
pixelFormat:(CGLPixelFormatObj)pixelFormat
|
||||
forLayerTime:(CFTimeInterval)timeInterval
|
||||
displayTime:(const CVTimeStamp*)timeStamp
|
||||
{
|
||||
if (_texture == 0)
|
||||
return;
|
||||
|
||||
glClearColor (1, 0, 1, 1);
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
GLint viewport[4] = {0, 0, 0, 0};
|
||||
glGetIntegerv (GL_VIEWPORT, viewport);
|
||||
NSSize viewportSize = NSMakeSize (viewport[2], viewport[3]);
|
||||
|
||||
/* Set the coordinate system to be one-to-one with pixels. */
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glOrtho (0, viewportSize.width, 0, viewportSize.height, -1, 1);
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
|
||||
/* Draw a fullscreen quad. */
|
||||
glColor4f (1, 1, 1, 1);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _texture);
|
||||
glBegin (GL_QUADS);
|
||||
{
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex2f (0, 0);
|
||||
glTexCoord2f (0, _pixelSize.height);
|
||||
glVertex2f (0, _pixelSize.height);
|
||||
glTexCoord2f (_pixelSize.width, _pixelSize.height);
|
||||
glVertex2f (_pixelSize.width, _pixelSize.height);
|
||||
glTexCoord2f (_pixelSize.width, 0);
|
||||
glVertex2f (_pixelSize.width, 0);
|
||||
}
|
||||
glEnd ();
|
||||
glBindTexture (0, _texture);
|
||||
glDisable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
[super drawInCGLContext:glContext
|
||||
pixelFormat:pixelFormat
|
||||
forLayerTime:timeInterval
|
||||
displayTime:timeStamp];
|
||||
}
|
||||
|
||||
-(void)setTexture:(GLuint)texture
|
||||
{
|
||||
_texture = texture;
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
@end
|
||||