Skip to content

Commit fb4e0c7

Browse files
committed
add about page in the preferences
1 parent bb759e0 commit fb4e0c7

4 files changed

Lines changed: 153 additions & 5 deletions

File tree

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
# Weekly Commits (GNOME extension)
2-
## See your past weeks' GitHub contributions in the top bar
1+
<table>
2+
<tr>
3+
<td style="vertical-align: middle; width: 72px;">
4+
<img src="weekly-commits-logo.png" alt="Weekly Commits Logo" width="64">
5+
</td>
6+
<td style="vertical-align: middle;">
7+
<h1>Weekly Commits (GNOME extension)</h1>
8+
<h3>See your past weeks' GitHub contributions in the top bar</h3>
9+
</td>
10+
</tr>
11+
</table>
12+
13+
![Screenshot](screenshot.png)
14+
315
![GitHub](https://img.shields.io/github/license/funinkina/weekly-commits)
416
![GitHub issues](https://img.shields.io/github/issues/funinkina/weekly-commits)
517
![GitHub last commit](https://img.shields.io/github/last-commit/funinkina/weekly-commits)
618
![GitHub stars](https://img.shields.io/github/stars/funinkina/weekly-commits)
719

8-
9-
![Screenshot](screenshot.png)
10-
1120
## Get this extension on GNOME Extensions
1221
> [!NOTE]
1322
> This extension is not yet available in the GNOME Extensions website. You can install it manually by following the instructions below.

about.js

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
'use strict';
2+
import Adw from 'gi://Adw';
3+
import Gio from 'gi://Gio';
4+
import GObject from 'gi://GObject';
5+
import Gtk from 'gi://Gtk';
6+
import GLib from 'gi://GLib';
7+
import GdkPixbuf from 'gi://GdkPixbuf';
8+
import { gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
9+
10+
export default class About extends Adw.PreferencesPage {
11+
static {
12+
GObject.registerClass(this);
13+
}
14+
15+
constructor(extensionObject) {
16+
super({
17+
title: _('About'),
18+
icon_name: 'help-about-symbolic',
19+
name: 'about'
20+
});
21+
22+
const extensionDir = extensionObject.path;
23+
const iconFile = GLib.build_filenamev([extensionDir, 'weekly-commits-logo.png']);
24+
const extensionName = extensionObject.metadata.name;
25+
const githubLink = 'https://github.com/funinkina/weekly-commits';
26+
const issueFeatureLink = 'https://github.com/funinkina/weekly-commits/issues/new';
27+
const authorBlogsLink = 'https://funinkina.is-a.dev/';
28+
29+
const headerGroup = new Adw.PreferencesGroup();
30+
this.add(headerGroup);
31+
32+
const headerBox = new Gtk.Box({
33+
orientation: Gtk.Orientation.VERTICAL,
34+
spacing: 10,
35+
margin_top: 24,
36+
margin_bottom: 24,
37+
hexpand: true,
38+
halign: Gtk.Align.CENTER
39+
});
40+
41+
const iconImage = new Gtk.Image({
42+
pixel_size: 128
43+
});
44+
45+
try {
46+
if (Gio.File.new_for_path(iconFile).query_exists(null)) {
47+
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(iconFile, 128, 128);
48+
iconImage.set_from_pixbuf(pixbuf);
49+
} else {
50+
iconImage.set_from_icon_name('application-x-addon-symbolic');
51+
}
52+
} catch (e) {
53+
console.error(`Error loading icon: ${e.message}`);
54+
iconImage.set_from_icon_name('application-x-addon-symbolic');
55+
}
56+
57+
const nameLabel = new Gtk.Label({
58+
label: `<b><span size="large">${extensionName}</span></b>`,
59+
use_markup: true
60+
});
61+
62+
const authorLabel = new Gtk.Label({
63+
label: `<span size="small">by funinkina</span>`,
64+
use_markup: true
65+
});
66+
67+
headerBox.append(iconImage);
68+
headerBox.append(nameLabel);
69+
headerBox.append(authorLabel);
70+
headerGroup.add(headerBox);
71+
72+
const linksGroup = new Adw.PreferencesGroup();
73+
this.add(linksGroup);
74+
75+
const githubRow = new Adw.ActionRow({
76+
title: _('GitHub Repository'),
77+
subtitle: githubLink,
78+
activatable: true
79+
});
80+
81+
const githubIcon = new Gtk.Image({
82+
icon_name: 'web-browser-symbolic'
83+
});
84+
githubRow.add_prefix(githubIcon);
85+
linksGroup.add(githubRow);
86+
this._makeRowClickable(githubRow, githubLink);
87+
88+
const issueRow = new Adw.ActionRow({
89+
title: _('Report Issue or Request Feature'),
90+
subtitle: _('Help improve this extension'),
91+
activatable: true
92+
});
93+
94+
const issueIcon = new Gtk.Image({
95+
icon_name: 'dialog-question-symbolic'
96+
});
97+
issueRow.add_prefix(issueIcon);
98+
linksGroup.add(issueRow);
99+
this._makeRowClickable(issueRow, issueFeatureLink);
100+
101+
const authorGroup = new Adw.PreferencesGroup({
102+
title: _('More About the Author')
103+
});
104+
this.add(authorGroup);
105+
106+
const moreInfo = new Adw.ActionRow({
107+
title: _('More about me'),
108+
subtitle: authorBlogsLink,
109+
activatable: true
110+
});
111+
112+
const blogIcon = new Gtk.Image({
113+
icon_name: 'user-info-symbolic'
114+
});
115+
moreInfo.add_prefix(blogIcon);
116+
authorGroup.add(moreInfo);
117+
this._makeRowClickable(moreInfo, authorBlogsLink);
118+
}
119+
120+
_makeRowClickable(row, link) {
121+
row.set_tooltip_text(link);
122+
row.connect('activated', () => {
123+
try {
124+
Gio.AppInfo.launch_default_for_uri_async(link, null, null, (source, result) => {
125+
try {
126+
Gio.AppInfo.launch_default_for_uri_finish(result);
127+
} catch (e) {
128+
console.error(`Error opening link ${link}: ${e.message}`);
129+
}
130+
});
131+
} catch (e) {
132+
console.error(`Error launching URI ${link}: ${e.message}`);
133+
}
134+
});
135+
}
136+
}

prefs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Adw from 'gi://Adw';
22
import Gtk from 'gi://Gtk';
33

44
import { ExtensionPreferences, gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
5+
import About from './about.js';
56

67
export default class WeeklyCommitsPreferences extends ExtensionPreferences {
78
fillPreferencesWindow(window) {
@@ -11,6 +12,8 @@ export default class WeeklyCommitsPreferences extends ExtensionPreferences {
1112
page.set_title(_('Settings'));
1213
page.set_icon_name('preferences-system-symbolic');
1314
window.add(page);
15+
window.add(new About(this));
16+
window.set_title(_('Weekly Commits Settings'));
1417

1518
const group = new Adw.PreferencesGroup();
1619
group.set_title(_('GitHub Credentials'));

weekly-commits-logo.png

4.38 KB
Loading

0 commit comments

Comments
 (0)