Skip to content

Commit

Permalink
Added Button Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
SoNiC-HeRE committed Feb 25, 2023
1 parent 6728f0d commit 8b53bab
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/Library/demos/Button/main.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Gtk 4.0;
using Adw 1;

Adw.StatusPage{
title: "Button";
description: "A simple way to trigger an event";

Box {
orientation: vertical;

Box {
orientation: vertical;
halign: center;

Button test_button {
label: "Active Button";
margin-bottom: 30;
styles ["pill","flat"]
}

Button disabled_button {
label: "Disabled Button";
margin-bottom: 30;
sensitive: false;
styles ["pill","destructive-action"]
}

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

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

LinkButton{
label: "Human Interface Guidelines";
uri: "https://developer.gnome.org/hig/patterns/controls/buttons.html";
}

}
}
}
19 changes: 19 additions & 0 deletions src/Library/demos/Button/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Gtk from "gi://Gtk?version=4.0";
import GObject from "gi://GObject";

const test_button = workbench.builder.get_object("test_button");
function handle_click() {
const dialog = new Gtk.MessageDialog({
text: "Button was Clicked",
transient_for: workbench.window,
modal: true,
buttons: Gtk.ButtonsType.OK,
});
dialog.connect("response", () => {
dialog.close();
});

dialog.present();
}

test_button.connect("clicked", handle_click);
10 changes: 10 additions & 0 deletions src/Library/demos/Button/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Button",
"category": "user_interface",
"description": "A simple way to trigger an event",
"panels": [
"ui",
"preview"
],
"autorun": true
}
3 changes: 3 additions & 0 deletions src/app.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
<file>Library/demos/Custom Widget/main.ui</file>
<file>Library/demos/Custom Widget/main.js</file>
<file>Library/demos/Custom Widget/main.json</file>
<file>Library/demos/Button/main.blp</file>
<file>Library/demos/Button/main.json</file>
<file>Library/demos/Button/main.js</file>
</gresource>
</gresources>

0 comments on commit 8b53bab

Please sign in to comment.