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+ }
0 commit comments