-
-
Notifications
You must be signed in to change notification settings - Fork 93
Added calendar widget #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Calendar widget styling | ||
| .widget-calendar { | ||
| padding: 12px; | ||
| margin: 8px; | ||
|
|
||
| .day-label { | ||
| font-size: 18px; | ||
| font-weight: bold; | ||
| color: var(--text-color); | ||
| margin-bottom: 2px; | ||
| } | ||
|
|
||
| .date-label { | ||
| font-size: 14px; | ||
| color: var(--text-color); | ||
| opacity: 0.8; | ||
| margin-bottom: 8px; | ||
| } | ||
|
|
||
| calendar { | ||
| background: rgba(var(--noti-bg), var(--noti-bg-alpha)); | ||
| border: var(--border); | ||
| border-radius: var(--border-radius); | ||
| padding: 8px; | ||
| color: var(--text-color); | ||
| font-size: 14px; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| using GLib; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||
|
|
||
| namespace SwayNotificationCenter.Widgets { | ||
| public class Calendar : BaseWidget { | ||
| public override string widget_name { | ||
| get { | ||
| return "calendar"; | ||
| } | ||
| } | ||
|
|
||
| Gtk.Calendar calendar; | ||
| Gtk.Label date_label; | ||
| Gtk.Label day_label; | ||
|
|
||
| public Calendar (string suffix) { | ||
| base (suffix); | ||
|
|
||
| Json.Object ?config = get_config (this); | ||
|
|
||
| var container = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); | ||
| container.set_margin_start (12); | ||
| container.set_margin_end (12); | ||
| container.set_margin_top (12); | ||
| container.set_margin_bottom (12); | ||
|
Comment on lines
+21
to
+24
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should set these through CSS so that it's user configurable |
||
| container.set_hexpand (true); | ||
|
|
||
| day_label = new Gtk.Label (""); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set the string argument to null instead of an empty string |
||
| day_label.add_css_class ("day-label"); | ||
| day_label.set_halign (Gtk.Align.START); | ||
|
|
||
| date_label = new Gtk.Label (""); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| date_label.add_css_class ("date-label"); | ||
| date_label.set_halign (Gtk.Align.START); | ||
|
|
||
| calendar = new Gtk.Calendar (); | ||
| calendar.set_hexpand (true); | ||
| calendar.add_css_class ("calendar-widget"); | ||
|
|
||
| if (config != null) { | ||
| bool ?show_day_label = get_prop<bool> (config, "show-day-label", null); | ||
| if (show_day_label == false) { | ||
| day_label.hide (); | ||
| } | ||
|
|
||
| bool ?show_date_label = get_prop<bool> (config, "show-date-label", null); | ||
| if (show_date_label == false) { | ||
| date_label.hide (); | ||
| } | ||
| } | ||
|
|
||
| container.append (day_label); | ||
| container.append (date_label); | ||
| container.append (calendar); | ||
| append (container); | ||
|
|
||
| calendar.day_selected.connect (update_labels); | ||
| update_labels (); | ||
| } | ||
|
|
||
| void update_labels () { | ||
| var now = new GLib.DateTime.now_local (); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| day_label.set_label (now.format ("%A")); | ||
| date_label.set_label (now.format ("%B %-d, %Y")); | ||
| } | ||
|
|
||
| public override void on_cc_visibility_change (bool value) { | ||
| if (value) { | ||
| update_labels (); | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might wanna use
.calendar-widgetinstead