Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Mar 20, 2023
1 parent 310a5e5 commit 9c7cda0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 54 deletions.
38 changes: 9 additions & 29 deletions src/Library/demos/Calendar/main.blp
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,23 @@ using Adw 1;

Adw.StatusPage {
title: "Calendar";
description: "Widget that helps you keep track of events";
description: "Display a Gregorian calendar, one month at a time";

Box {
orientation: vertical;
halign: center;
Box {
orientation: vertical;
halign: center;

Calendar calendar {
show-day-names: true;
show-week-numbers: true;
show-week-numbers: false;
show-heading: true;
margin-bottom: 18;
}

Box {
spacing: 6;
halign: center;
margin-bottom: 12;

Button mark {
icon-name: "plus";
}

Button remove_mark {
icon-name: "minus";
}
day: 1;
}

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







}
28 changes: 4 additions & 24 deletions src/Library/demos/Calendar/main.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
const calendar = workbench.builder.get_object("calendar");
const mark = workbench.builder.get_object("mark");
const remove_mark = workbench.builder.get_object("remove_mark");

calendar.connect("notify::day", () => {
console.log(`Selected Date: ${calendar.get_date().format("%x")}`);
console.log(calendar.get_date().format("%x"));
});

calendar.connect("notify::month", () => {
console.log(`Switched to Month: ${calendar.get_date().format("%B")}`);
console.log(calendar.get_date().format("%B"));
});

calendar.connect("notify::year", () => {
console.log(`Switched to Year: ${calendar.get_date().format("%Y")}`);
console.log(calendar.get_date().format("%Y"));
});

mark.connect("clicked", () => {
const selectedDate = calendar.get_date().format("%d");
console.log(
calendar.get_day_is_marked(selectedDate)
? "Date already marked"
: "Date marked",
);
calendar.mark_day(selectedDate);
});

remove_mark.connect("clicked", () => {
const selectedDate = calendar.get_date().format("%d");
console.log(
calendar.get_day_is_marked(selectedDate)
? "Date Unmarked"
: "Date not yet marked",
);
calendar.unmark_day(selectedDate);
});
calendar.mark_day(15);
2 changes: 1 addition & 1 deletion src/Library/demos/Calendar/main.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Calendar",
"category": "user_interface",
"description": "Widget that helps you keep track of events",
"description": "Display a Gregorian calendar, one month at a time",
"panels": [
"ui",
"preview"
Expand Down
Binary file added src/Library/demos/Picture/bbb.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/Library/demos/Picture/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Picture",
"category": "user_interface",
"description": "Something something",
"panels": [
"preview",
"ui"
],
"autorun": true
}

0 comments on commit 9c7cda0

Please sign in to comment.