Skip to content

Commit 8ae759e

Browse files
committed
re-use Clutter and make it work in both worlds!
1 parent 39b390b commit 8ae759e

File tree

10 files changed

+330
-336
lines changed

10 files changed

+330
-336
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ release: eslint _version_bump _build
2626
git push --tags
2727
$(MAKE) zip
2828

29-
zip: _build
30-
cd build && zip -qr ../"$(_UUID)$(_VERSION).zip" .
29+
zip: export _VERSION=$(shell jq '.version' $(_UUID)/metadata.json)
30+
zip: eslint _build
31+
cd build && zip -qr ../"$(_UUID).$(_VERSION).zip" .
3132
$(MAKE) clean
3233

3334
eslint:

PersianCalendar@oxygenws.com/Calendar.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
const St = imports.gi.St;
4-
const Gtk = imports.gi.Gtk;
5-
const Gdk = imports.gi.Gdk;
3+
import Clutter from 'gi://Clutter';
4+
import St from 'gi://St';
65

76
import * as PersianDate from './PersianDate.js';
87
import * as HijriDate from './HijriDate.js';
@@ -45,19 +44,11 @@ export class Calendar {
4544
this._selectedDate.getDate(),
4645
);
4746

48-
this.actor = new Gtk.Grid({
49-
column_homogeneous: false,
50-
row_homogeneous: false,
51-
column_spacing: 6,
52-
row_spacing: 6,
47+
this.actor = new St.Widget({
48+
style_class: 'calendar',
49+
layout_manager: new Clutter.GridLayout(),
50+
reactive: true,
5351
});
54-
this.actor.add_css_class('calendar');
55-
56-
const click = new Gtk.GestureClick();
57-
click.connect('pressed', (_gesture, nPress, x, y) => {
58-
log(`Grid pressed at ${x}, ${y}`);
59-
});
60-
this.actor.add_controller(click);
6152
this.actor.connect('scroll-event', this._onScroll.bind(this));
6253

6354
this._buildHeader();
@@ -190,12 +181,12 @@ export class Calendar {
190181

191182
_onScroll(actor, event) {
192183
switch (event.get_scroll_direction()) {
193-
case Gdk.ScrollDirection.UP:
194-
case Gdk.ScrollDirection.RIGHT:
184+
case Clutter.ScrollDirection.UP:
185+
case Clutter.ScrollDirection.RIGHT:
195186
this._onNextMonthButtonClicked();
196187
break;
197-
case Gdk.ScrollDirection.DOWN:
198-
case Gdk.ScrollDirection.LEFT:
188+
case Clutter.ScrollDirection.DOWN:
189+
case Clutter.ScrollDirection.LEFT:
199190
this._onPrevMonthButtonClicked();
200191
break;
201192
default:
@@ -402,7 +393,7 @@ export class Calendar {
402393
const bottomLabel = new St.Label({
403394
text: this._str.transDigits(events[0]),
404395
style_class: 'pcalendar-event-label',
405-
x_align: Gtk.ActorAlign.FILL,
396+
x_align: Clutter.ActorAlign.FILL,
406397
x_expand: true,
407398
});
408399
// this._setFont(bottomLabel);

PersianCalendar@oxygenws.com/extension.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
66
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
77
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
88

9-
const GObject = imports.gi.GObject;
10-
const GLib = imports.gi.GLib;
11-
const St = imports.gi.St;
12-
const Gio = imports.gi.Gio;
9+
import GObject from 'gi://GObject';
10+
import St from 'gi://St';
11+
import Gio from 'gi://Gio';
12+
import GLib from 'gi://GLib';
13+
import Clutter from 'gi://Clutter';
1314

1415
import { Events } from './Events.js';
1516
import * as PersianDate from './PersianDate.js';
@@ -35,7 +36,7 @@ const PersianCalendar = GObject.registerClass(
3536
this._settings = extension._settings;
3637
this._gettext = extension._gettext;
3738
this._str = new Str(this._gettext);
38-
this._locale = new Locale(this._gettext);
39+
this._locale = new Locale(this._gettext, Clutter.get_default_text_direction());
3940
this._events = new Events(this._settings, this._str);
4041
this._openPreferences = () => this._extension.openPreferences();
4142

@@ -150,6 +151,7 @@ const PersianCalendar = GObject.registerClass(
150151
style_class: 'button system-menu-action calendar-preferences-button',
151152
reactive: true,
152153
can_focus: true,
154+
x_align: Clutter.ActorAlign.CENTER,
153155
x_expand: true,
154156
});
155157
preferencesIcon.connect('clicked', () => {
@@ -168,6 +170,7 @@ const PersianCalendar = GObject.registerClass(
168170
style_class: 'button system-menu-action calendar-preferences-button',
169171
reactive: true,
170172
can_focus: true,
173+
x_align: Clutter.ActorAlign.CENTER,
171174
x_expand: true,
172175
});
173176
nowruzIcon.connect('clicked', this._showNowruzNotification.bind(this));

0 commit comments

Comments
 (0)