Skip to content

Commit

Permalink
rewrite preferences window
Browse files Browse the repository at this point in the history
  • Loading branch information
IamRezaMousavi committed Apr 1, 2024
1 parent cc0b2fa commit 5642469
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 112 deletions.
4 changes: 2 additions & 2 deletions [email protected]/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export const Calendar = GObject.registerClass({
this._weekStart = 6;

this.settings = settings;
this.usePersianWeekday = this.settings.get_boolean('calendar-weekday-persian-number');
this.usePersianDay = this.settings.get_boolean('calendar-day-persian-number');
this.usePersianWeekday = this.settings.get_boolean('calendar-persian-weekday');
this.usePersianDay = this.settings.get_boolean('calendar-persian-number');

this._settings = new Gio.Settings({schema_id: 'org.gnome.desktop.calendar'});
this._settings.connect(`changed::${SHOW_WEEKDATE_KEY}`, this._onSettingsChange.bind(this));
Expand Down
2 changes: 1 addition & 1 deletion [email protected]/dateMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class DateMenuButton extends PanelMenu.Button {

_updateCalendarDisplay() {
let displayFormat = this.settings.get_string('panel-format');
let usePersianDigit = this.settings.get_boolean('top-panel-persian-number');
let usePersianDigit = this.settings.get_boolean('panel-persian-number');
let date = new PersianDate();
this._calendarDisplay.set_text(
usePersianDigit
Expand Down
18 changes: 9 additions & 9 deletions [email protected]/eventSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
GregorianEvents,
PersianEvents,
HijriEvents,
UnofficialWorldEvents
InternationalEvents
} from './events.js';


Expand All @@ -22,7 +22,7 @@ export const EventSource = GObject.registerClass({
this._gregorianEvents = new GregorianEvents();
this._persianEvents = new PersianEvents();
this._hijriEvents = new HijriEvents();
this._unofficialWorldEvents = new UnofficialWorldEvents();
this._InternationalEvents = new InternationalEvents();
}

getEvents(_begin, _end) {
Expand All @@ -46,10 +46,10 @@ export const EventSource = GObject.registerClass({
this._result = this._result.concat(hijriEvents);
}

let unofficialEventsActive = this.settings.get_boolean('unofficial-events-active');
if (unofficialEventsActive) {
let unofficialEvents = this._unofficialWorldEvents.getEvents(_begin);
this._result = this._result.concat(unofficialEvents);
let internationalEventsActive = this.settings.get_boolean('international-events-active');
if (internationalEventsActive) {
let internationalEvents = this._InternationalEvents.getEvents(_begin);
this._result = this._result.concat(internationalEvents);
}

return this._result;
Expand All @@ -59,16 +59,16 @@ export const EventSource = GObject.registerClass({
let gregorianEventsActive = this.settings.get_boolean('gregorian-events-active');
let persianEventsActive = this.settings.get_boolean('persian-events-active');
let hijriEventsActive = this.settings.get_boolean('hijri-events-active');
let unofficialEventsActive = this.settings.get_boolean('unofficial-events-active');
let internationalEventsActive = this.settings.get_boolean('international-events-active');
let has = false;
if (gregorianEventsActive)
has ||= this._gregorianEvents.hasEvents(_day);
if (persianEventsActive)
has ||= this._persianEvents.hasEvents(_day);
if (hijriEventsActive)
has ||= this._hijriEvents.hasEvents(_day);
if (unofficialEventsActive)
has ||= this._unofficialWorldEvents.hasEvents(_day);
if (internationalEventsActive)
has ||= this._InternationalEvents.hasEvents(_day);
return has;
}

Expand Down
2 changes: 1 addition & 1 deletion [email protected]/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './events/gregorianEvents.js';
export * from './events/persianEvents.js';
export * from './events/hijriEvents.js';
export * from './events/unofficialWorldEvents.js';
export * from './events/internationalEvents.js';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import {CalendarEvent, CalendarEvents} from './calendarEvent.js';

export const UnofficialWorldEvents = class UnofficialWorldEvents extends CalendarEvents {
export const InternationalEvents = class InternationalEvents extends CalendarEvents {
constructor() {
super();
this._events.set('7-1', [new CalendarEvent('روز جهانی بال مرغ', false)]);
Expand Down
16 changes: 8 additions & 8 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export default class PersianCalendar extends Extension {
Gio.SettingsBindFlags.DEFAULT
);

this.settings.connect('changed::position', () => {
this.settings.connect('changed::indicator-position', () => {
this.disable();
this.enable();
});
this.settings.connect('changed::index', () => {
this.settings.connect('changed::indicator-index', () => {
this.disable();
this.enable();
});
Expand All @@ -57,17 +57,17 @@ export default class PersianCalendar extends Extension {
this.enable();
});

this.settings.connect('changed::top-panel-persian-number', () => {
this.settings.connect('changed::panel-persian-number', () => {
this.disable();
this.enable();
});

this.settings.connect('changed::calendar-weekday-persian-number', () => {
this.settings.connect('changed::calendar-persian-weekday', () => {
this.disable();
this.enable();
});

this.settings.connect('changed::calendar-day-persian-number', () => {
this.settings.connect('changed::calendar-persian-number', () => {
this.disable();
this.enable();
});
Expand All @@ -87,16 +87,16 @@ export default class PersianCalendar extends Extension {
this.enable();
});

this.settings.connect('changed::unofficial-events-active', () => {
this.settings.connect('changed::international-events-active', () => {
this.disable();
this.enable();
});

Main.panel.addToStatusArea(
this.uuid,
this._indicator,
this.settings.get_int('index'),
this.settings.get_string('position')
this.settings.get_int('indicator-index'),
this.settings.get_string('indicator-position')
);
}

Expand Down
Loading

0 comments on commit 5642469

Please sign in to comment.