Skip to content

Commit

Permalink
Support other session modes
Browse files Browse the repository at this point in the history
and use default gnome calendar format for days with events
and use the same style for holidays in the tray bar
and fixes #10 and fixes #144
  • Loading branch information
omid committed Jun 14, 2024
1 parent 857d8bf commit b9202db
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 76 deletions.
8 changes: 4 additions & 4 deletions [email protected]/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ export class Calendar {

if (is_same_month) {
if (events[0]) {
styleClass += ' pcalendar-day-with-events ';
styleClass += ' calendar-day-with-events pcalendar-day-with-events ';
}
style += `font-weight:600;`;
style += `font-weight:400;`;

if (events[1]) {
styleClass += ' calendar-weekend pcalendar-weekend ';
Expand Down Expand Up @@ -429,14 +429,14 @@ export class Calendar {

_getDateButton(date, dayOfWeek, calendar) {
const button = new St.Button({
label: this.format(
label: this._str.transDigits(this.format(
this._settings.get_string(`${calendar}-display-format`),
date.day,
date.month,
date.year,
dayOfWeek,
calendar,
),
)),
style_class: 'calendar-day-base pcalendar-date-label',
x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
Expand Down
101 changes: 55 additions & 46 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const PersianCalendar = GObject.registerClass(
this.label.set_style('color:');
}
}));

///
this.event_hooks.push(this._settings.connect('changed::widget-format', () => this._updateDate(true, true)));

Expand Down Expand Up @@ -114,51 +114,17 @@ const PersianCalendar = GObject.registerClass(
// this._settings.connect('changed::font', this._onFontChangeForCalendar.bind(this));
// this._settings.connect('changed::custom-font', this._onFontChangeForCalendar.bind(this));
// //////////////////////////////

this._generateConverterPart();
this._genConverterPart();

// action buttons
const actionButtons = new PopupMenu.PopupBaseMenuItem({
this._actionButtonsPart = new PopupMenu.PopupBaseMenuItem({
reactive: false,
can_focus: false,
});
this.menu.addMenuItem(actionButtons);

// Add preferences button
let icon = new St.Icon({
icon_name: 'emblem-system-symbolic',
style_class: 'popup-menu-icon calendar-popup-menu-icon',
});

const preferencesIcon = new St.Button({
child: icon,
style_class: 'button system-menu-action calendar-preferences-button',
reactive: true,
can_focus: true,
x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
});
preferencesIcon.connect('clicked', () => {
this._openPreferences();
});
actionButtons.actor.add_child(preferencesIcon);

// Add Nowruz button
icon = new St.Icon({
icon_name: 'emblem-favorite-symbolic',
style_class: 'popup-menu-icon calendar-popup-menu-icon',
});

const nowruzIcon = new St.Button({
child: icon,
style_class: 'button system-menu-action calendar-preferences-button',
reactive: true,
can_focus: true,
x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
});
nowruzIcon.connect('clicked', this._showNowruzNotification.bind(this));
actionButtons.actor.add_child(nowruzIcon);
this.menu.addMenuItem(this._actionButtonsPart);
this._genActionButtonsPart();
this.event_hooks.push(Main.sessionMode.connect('updated', () => this._genActionButtonsPart()));

this.menu.connect('open-state-changed', (isOpen) => {
if (isOpen) {
Expand All @@ -171,6 +137,47 @@ const PersianCalendar = GObject.registerClass(
this.show();
}

_genActionButtonsPart() {
this._actionButtonsPart.remove_all_children();
if (!Main.sessionMode.isLocked) {
// Add preferences button
let icon = new St.Icon({
icon_name: 'emblem-system-symbolic',
style_class: 'popup-menu-icon calendar-popup-menu-icon',
});

const preferencesIcon = new St.Button({
child: icon,
style_class: 'button system-menu-action calendar-preferences-button',
reactive: true,
can_focus: true,
x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
});
preferencesIcon.connect('clicked', () => {
this._openPreferences();
});
this._actionButtonsPart.actor.add_child(preferencesIcon);

// Add Nowruz button
icon = new St.Icon({
icon_name: 'emblem-favorite-symbolic',
style_class: 'popup-menu-icon calendar-popup-menu-icon',
});

const nowruzIcon = new St.Button({
child: icon,
style_class: 'button system-menu-action calendar-preferences-button',
reactive: true,
can_focus: true,
x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
});
nowruzIcon.connect('clicked', this._showNowruzNotification.bind(this));
this._actionButtonsPart.actor.add_child(nowruzIcon);
}
}

_onFontChangeForIcon() {
// const font_desc = Pango.FontDescription.from_string(this._settings.get_string('font'));
// font_desc = Pango.FontDescription.from_string(font_desc.get_family());
Expand Down Expand Up @@ -214,8 +221,10 @@ const PersianCalendar = GObject.registerClass(
// is holiday?
if (events[1]) {
this.label.add_style_class_name('pcalendar-tray-holiday');
this.label.add_style_class_name('pcalendar-tray-holiday-light-dark');
} else {
this.label.remove_style_class_name('pcalendar-tray-holiday');
this.label.remove_style_class_name('pcalendar-tray-holiday-light-dark');
}

this.label.set_text(
Expand Down Expand Up @@ -246,7 +255,7 @@ const PersianCalendar = GObject.registerClass(
return true;
}

_generateConverterPart() {
_genConverterPart() {
// Add date conversion button
const converterMenu = new PopupMenu.PopupSubMenuMenuItem(this._gettext.__('Date conversion'));
converterMenu.actor.add_style_class_name('pcalendar-font');
Expand Down Expand Up @@ -480,20 +489,20 @@ const PersianCalendar = GObject.registerClass(
month_delta,
).format(month_delta, day_delta, pdate.year + 1);
}
this.nowruz_notify(this._str.transDigits(nowruz));
this._nowruzNotify(this._str.transDigits(nowruz));
} else if (day_delta !== 0) {
nowruz = this._gettext.n__(
'%d day left to Nowruz %d',
'%d days left to Nowruz %d',
day_delta,
).format(day_delta, pdate.year + 1);
this.nowruz_notify(this._str.transDigits(nowruz));
this._nowruzNotify(this._str.transDigits(nowruz));
} else {
this.nowruz_notify(this._gettext.__('Happy New Year'));
this._nowruzNotify(this._gettext.__('Happy New Year'));
}
}

nowruz_notify(title) {
_nowruzNotify(title) {
this.notify(title, undefined, 'emblem-favorite-symbolic');
}

Expand Down
24 changes: 12 additions & 12 deletions [email protected]/locale/fa_IR/LC_MESSAGES/persian-calendar.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-04 10:03+0200\n"
"POT-Creation-Date: 2024-06-14 12:56+0200\n"
"PO-Revision-Date: 2022-04-02 12:52+0430\n"
"Last-Translator: eshagh <[email protected]>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -433,56 +433,56 @@ msgid "Zihajje"
msgstr "ذیحجه"

#. Add date conversion button
#: [email protected]/extension.js:251
#: [email protected]/extension.js:260
msgid "Date conversion"
msgstr "تبدیل تاریخ"

#: [email protected]/extension.js:272
#: [email protected]/extension.js:281
msgid "from Persian"
msgstr "از هـ.خورشیدی"

#: [email protected]/extension.js:284
#: [email protected]/extension.js:293
msgid "from Gregorian"
msgstr "از میلادی"

#: [email protected]/extension.js:296
#: [email protected]/extension.js:305
msgid "from Hijri"
msgstr "از هـ.قمری"

#: [email protected]/extension.js:319
#: [email protected]/extension.js:328
msgid "year"
msgstr "سال"

#: [email protected]/extension.js:328
#: [email protected]/extension.js:337
msgid "month"
msgstr "ماه"

#: [email protected]/extension.js:337
#: [email protected]/extension.js:346
msgid "day"
msgstr "روز"

#: [email protected]/extension.js:472
#: [email protected]/extension.js:481
#, javascript-format
msgid "%d month and 1 day left to Nowruz %d"
msgid_plural "%d months and 1 day left to Nowruz %d"
msgstr[0] "%d ماه و ۱ روز مانده به نوروز %d"
msgstr[1] "%d ماه و ۱ روز مانده به نوروز %d"

#: [email protected]/extension.js:478
#: [email protected]/extension.js:487
#, javascript-format
msgid "%d month and %d days left to Nowruz %d"
msgid_plural "%d months and %d days left to Nowruz %d"
msgstr[0] "%d ماه و %d روز مانده به نوروز %d"
msgstr[1] "%d ماه و %d روز مانده به نوروز %d"

#: [email protected]/extension.js:486
#: [email protected]/extension.js:495
#, javascript-format
msgid "%d day left to Nowruz %d"
msgid_plural "%d days left to Nowruz %d"
msgstr[0] "%d روز مانده به نوروز %d"
msgstr[1] "%d روز مانده به نوروز %d"

#: [email protected]/extension.js:492
#: [email protected]/extension.js:501
msgid "Happy New Year"
msgstr "سال نو مبارک"

Expand Down
24 changes: 12 additions & 12 deletions [email protected]/locale/persian-calendar.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-04 12:10+0200\n"
"POT-Creation-Date: 2024-06-14 13:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -433,56 +433,56 @@ msgid "Zihajje"
msgstr ""

#. Add date conversion button
#: [email protected]/extension.js:251
#: [email protected]/extension.js:260
msgid "Date conversion"
msgstr ""

#: [email protected]/extension.js:272
#: [email protected]/extension.js:281
msgid "from Persian"
msgstr ""

#: [email protected]/extension.js:284
#: [email protected]/extension.js:293
msgid "from Gregorian"
msgstr ""

#: [email protected]/extension.js:296
#: [email protected]/extension.js:305
msgid "from Hijri"
msgstr ""

#: [email protected]/extension.js:319
#: [email protected]/extension.js:328
msgid "year"
msgstr ""

#: [email protected]/extension.js:328
#: [email protected]/extension.js:337
msgid "month"
msgstr ""

#: [email protected]/extension.js:337
#: [email protected]/extension.js:346
msgid "day"
msgstr ""

#: [email protected]/extension.js:472
#: [email protected]/extension.js:481
#, javascript-format
msgid "%d month and 1 day left to Nowruz %d"
msgid_plural "%d months and 1 day left to Nowruz %d"
msgstr[0] ""
msgstr[1] ""

#: [email protected]/extension.js:478
#: [email protected]/extension.js:487
#, javascript-format
msgid "%d month and %d days left to Nowruz %d"
msgid_plural "%d months and %d days left to Nowruz %d"
msgstr[0] ""
msgstr[1] ""

#: [email protected]/extension.js:486
#: [email protected]/extension.js:495
#, javascript-format
msgid "%d day left to Nowruz %d"
msgid_plural "%d days left to Nowruz %d"
msgstr[0] ""
msgstr[1] ""

#: [email protected]/extension.js:492
#: [email protected]/extension.js:501
msgid "Happy New Year"
msgstr ""

Expand Down
7 changes: 6 additions & 1 deletion [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
],
"url": "https://github.com/omid/Persian-Calendar-for-Gnome-Shell",
"uuid": "[email protected]",
"version": 112
"session-modes": [
"user",
"unlock-dialog",
"gdm"
],
"version": 113
}
3 changes: 3 additions & 0 deletions [email protected]/stylesheet-light.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pcalendar-tray-holiday-light-dark {
background-image: url("resource:///org/gnome/shell/theme/calendar-today-light.svg");
}
6 changes: 5 additions & 1 deletion [email protected]/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
font-weight: 500;
}

.pcalendar-tray-holiday-light-dark {
background-image: url("resource:///org/gnome/shell/theme/calendar-today.svg");
}

.pcalendar-tray-holiday {
text-decoration: underline;
background-size: contain;
font-weight: 900;
}

Expand Down

0 comments on commit b9202db

Please sign in to comment.