File tree Expand file tree Collapse file tree
src/Library/demos/Toggle Button Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using Gtk 4.0;
2+ using Adw 1;
3+
4+ Adw.StatusPage {
5+ title: "Toggle Button";
6+ description: _("Represent active-state visually");
7+
8+ Box {
9+ orientation: vertical;
10+
11+ Box {
12+ orientation: horizontal;
13+ halign: center;
14+ margin-bottom: 6;
15+ styles ["linked"]
16+
17+ ToggleButton button_no_look {
18+ active: true;
19+ icon-name: "eye-not-looking-symbolic";
20+ }
21+
22+ ToggleButton button_look {
23+ active: false;
24+ icon-name: "eye-open-negative-filled-symbolic";
25+ group: button_no_look;
26+ }
27+ }
28+
29+ Label {
30+ label: "Grouped";
31+ margin-bottom: 24;
32+ }
33+
34+ Box {
35+ orientation: horizontal;
36+ halign: center;
37+ spacing: 6;
38+ margin-bottom: 6;
39+
40+ ToggleButton button_camera {
41+ active: false;
42+ icon-name: "photo-camera-symbolic";
43+ halign: center;
44+ }
45+
46+ ToggleButton button_flashlight {
47+ active: false;
48+ icon-name: "flashlight-symbolic";
49+ halign: center;
50+ }
51+ }
52+
53+ Label {
54+ label: "Independent";
55+ margin-bottom: 24;
56+ }
57+
58+ ToggleButton button_console {
59+ halign: center;
60+ margin-bottom: 6;
61+
62+ Adw.ButtonContent {
63+ halign: center;
64+ valign: center;
65+ label: "Console";
66+ icon-name: "terminal-symbolic";
67+ }
68+ }
69+
70+ Label {
71+ label: "With label";
72+ margin-bottom: 24;
73+ }
74+
75+ LinkButton{
76+ label: "Tutorial";
77+ uri: "https://developer.gnome.org/documentation/tutorials/beginners/components/toggle.html";
78+ }
79+
80+ LinkButton{
81+ label: "API Reference";
82+ uri: "https://docs.gtk.org/gtk4/class.ToggleButton.html";
83+ }
84+
85+ LinkButton{
86+ label: "Human Interface Guidelines";
87+ uri: "https://developer.gnome.org/hig/patterns/controls/buttons.html";
88+ }
89+ }
90+ }
Original file line number Diff line number Diff line change 1+ const buttons = {
2+ button_no_look : "Don't look" ,
3+ button_look : "Look" ,
4+ button_camera : "Camera" ,
5+ button_flashlight : "Flashlight" ,
6+ button_console : "Console" ,
7+ } ;
8+
9+ for ( const [ id , name ] of Object . entries ( buttons ) ) {
10+ const button = workbench . builder . get_object ( id ) ;
11+ button . connect ( "notify::active" , ( ) => {
12+ console . log ( `${ name } ${ button . active ? "On" : "Off" } ` ) ;
13+ } ) ;
14+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " Toggle Button" ,
3+ "category" : " user_interface" ,
4+ "description" : " Represent active-state visually" ,
5+ "panels" : [
6+ " ui" ,
7+ " preview"
8+ ],
9+ "autorun" : true
10+ }
You can’t perform that action at this time.
0 commit comments