about.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict'
  2. import GLib from 'gi://GLib';
  3. import Adw from 'gi://Adw';
  4. import GObject from 'gi://GObject';
  5. import Gio from 'gi://Gio';
  6. import Gtk from 'gi://Gtk';
  7. import Gdk from 'gi://Gdk';
  8. export const About = GObject.registerClass({
  9. GTypeName: 'AboutPrefs',
  10. Template: GLib.Uri.resolve_relative(import.meta.url, '../ui/about.ui',GLib.UriFlags.NONE),
  11. InternalChildren: [
  12. 'app_icon_image',
  13. 'app_name_label',
  14. 'version_label',
  15. ]
  16. }, class About extends Adw.PreferencesPage {
  17. constructor(window) {
  18. super({});
  19. this._app_icon_image.gicon = Gio.icon_new_for_string(`${GLib.Uri.resolve_relative(import.meta.url, '../icons/threshold-active.svg',GLib.UriFlags.NONE)}`);
  20. this._app_name_label.label = window._metadata.name;
  21. this._version_label.label = window._metadata.version.toString();
  22. // setup menu actions
  23. const actionGroup = new Gio.SimpleActionGroup();
  24. window.insert_action_group('prefs', actionGroup);
  25. // a list of actions with their associated link
  26. const actions = [
  27. {
  28. name: 'open-bug-report',
  29. link: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/issues'
  30. },
  31. {
  32. name: 'open-readme',
  33. link: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/'
  34. },
  35. {
  36. name: 'open-license',
  37. link: 'https://gitlab.com/marcosdalvarez/thinkpad-battery-threshold-extension/-/blob/main/LICENSE'
  38. },
  39. ];
  40. actions.forEach(action => {
  41. let act = new Gio.SimpleAction({ name: action.name });
  42. act.connect(
  43. 'activate',
  44. _ => Gtk.show_uri(window, action.link, Gdk.CURRENT_TIME)
  45. );
  46. actionGroup.add_action(act);
  47. });
  48. }
  49. });