panel.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import Adw from 'gi://Adw';
  2. import GLib from 'gi://GLib';
  3. import GObject from 'gi://GObject';
  4. import Gio from 'gi://Gio';
  5. export const Panel = GObject.registerClass({
  6. GTypeName: 'Panel',
  7. Template: GLib.uri_resolve_relative(import.meta.url, '../ui/panel.ui', GLib.UriFlags.NONE),
  8. InternalChildren: [
  9. 'blur',
  10. 'pipeline_choose_row',
  11. 'mode_static',
  12. 'mode_dynamic',
  13. 'sigma_row',
  14. 'sigma',
  15. 'brightness_row',
  16. 'brightness',
  17. 'unblur_in_overview',
  18. 'force_light_text',
  19. 'override_background',
  20. 'style_panel',
  21. 'override_background_dynamically',
  22. 'hidetopbar_compatibility',
  23. 'dtp_blur_original_panel'
  24. ],
  25. }, class Panel extends Adw.PreferencesPage {
  26. constructor(preferences, pipelines_manager, pipelines_page) {
  27. super({});
  28. this.preferences = preferences;
  29. this.pipelines_manager = pipelines_manager;
  30. this.pipelines_page = pipelines_page;
  31. this.preferences.panel.settings.bind(
  32. 'blur', this._blur, 'active',
  33. Gio.SettingsBindFlags.DEFAULT
  34. );
  35. this._pipeline_choose_row.initialize(
  36. this.preferences.panel, this.pipelines_manager, this.pipelines_page
  37. );
  38. this.change_blur_mode(this.preferences.panel.STATIC_BLUR, true);
  39. this._mode_static.connect('toggled',
  40. () => this.preferences.panel.STATIC_BLUR = this._mode_static.active
  41. );
  42. this.preferences.panel.STATIC_BLUR_changed(
  43. () => this.change_blur_mode(this.preferences.panel.STATIC_BLUR, false)
  44. );
  45. this.preferences.panel.settings.bind(
  46. 'sigma', this._sigma, 'value',
  47. Gio.SettingsBindFlags.DEFAULT
  48. );
  49. this.preferences.panel.settings.bind(
  50. 'brightness', this._brightness, 'value',
  51. Gio.SettingsBindFlags.DEFAULT
  52. );
  53. this.preferences.panel.settings.bind(
  54. 'unblur-in-overview', this._unblur_in_overview, 'active',
  55. Gio.SettingsBindFlags.DEFAULT
  56. );
  57. this.preferences.panel.settings.bind(
  58. 'force-light-text', this._force_light_text, 'active',
  59. Gio.SettingsBindFlags.DEFAULT
  60. );
  61. this.preferences.panel.settings.bind(
  62. 'override-background',
  63. this._override_background, 'enable-expansion',
  64. Gio.SettingsBindFlags.DEFAULT
  65. );
  66. this.preferences.panel.settings.bind(
  67. 'style-panel', this._style_panel, 'selected',
  68. Gio.SettingsBindFlags.DEFAULT
  69. );
  70. this.preferences.panel.settings.bind(
  71. 'override-background-dynamically',
  72. this._override_background_dynamically, 'active',
  73. Gio.SettingsBindFlags.DEFAULT
  74. );
  75. this.preferences.hidetopbar.settings.bind(
  76. 'compatibility', this._hidetopbar_compatibility, 'active',
  77. Gio.SettingsBindFlags.DEFAULT
  78. );
  79. this.preferences.dash_to_panel.settings.bind(
  80. 'blur-original-panel', this._dtp_blur_original_panel, 'active',
  81. Gio.SettingsBindFlags.DEFAULT
  82. );
  83. }
  84. change_blur_mode(is_static_blur, first_run) {
  85. this._mode_static.set_active(is_static_blur);
  86. if (first_run)
  87. this._mode_dynamic.set_active(!is_static_blur);
  88. this._pipeline_choose_row.set_visible(is_static_blur);
  89. this._sigma_row.set_visible(!is_static_blur);
  90. this._brightness_row.set_visible(!is_static_blur);
  91. }
  92. });