Skip to content

Commit

Permalink
library: Add Toggle Button Entry (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoNiC-HeRE committed Mar 21, 2023
1 parent bc7568d commit 8e2c8df
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/Library/demos/Toggle Button/main.blp
@@ -0,0 +1,90 @@
using Gtk 4.0;
using Adw 1;

Adw.StatusPage {
title: "Toggle Button";
description: _("Represent active-state visually");

Box {
orientation: vertical;

Box {
orientation: horizontal;
halign: center;
margin-bottom: 6;
styles ["linked"]

ToggleButton button_no_look {
active: true;
icon-name: "eye-not-looking-symbolic";
}

ToggleButton button_look {
active: false;
icon-name: "eye-open-negative-filled-symbolic";
group: button_no_look;
}
}

Label {
label: "Grouped";
margin-bottom: 24;
}

Box {
orientation: horizontal;
halign: center;
spacing: 6;
margin-bottom: 6;

ToggleButton button_camera {
active: false;
icon-name: "photo-camera-symbolic";
halign: center;
}

ToggleButton button_flashlight {
active: false;
icon-name: "flashlight-symbolic";
halign: center;
}
}

Label {
label: "Independent";
margin-bottom: 24;
}

ToggleButton button_console {
halign: center;
margin-bottom: 6;

Adw.ButtonContent {
halign: center;
valign: center;
label: "Console";
icon-name: "terminal-symbolic";
}
}

Label {
label: "With label";
margin-bottom: 24;
}

LinkButton{
label: "Tutorial";
uri: "https://developer.gnome.org/documentation/tutorials/beginners/components/toggle.html";
}

LinkButton{
label: "API Reference";
uri: "https://docs.gtk.org/gtk4/class.ToggleButton.html";
}

LinkButton{
label: "Human Interface Guidelines";
uri: "https://developer.gnome.org/hig/patterns/controls/buttons.html";
}
}
}
14 changes: 14 additions & 0 deletions src/Library/demos/Toggle Button/main.js
@@ -0,0 +1,14 @@
const buttons = {
button_no_look: "Don't look",
button_look: "Look",
button_camera: "Camera",
button_flashlight: "Flashlight",
button_console: "Console",
};

for (const [id, name] of Object.entries(buttons)) {
const button = workbench.builder.get_object(id);
button.connect("notify::active", () => {
console.log(`${name} ${button.active ? "On" : "Off"}`);
});
}
10 changes: 10 additions & 0 deletions src/Library/demos/Toggle Button/main.json
@@ -0,0 +1,10 @@
{
"name": "Toggle Button",
"category": "user_interface",
"description": "Represent active-state visually",
"panels": [
"ui",
"preview"
],
"autorun": true
}

0 comments on commit 8e2c8df

Please sign in to comment.