Adjust classification banner for GNOME 47 changes
Clutter.Color no longer exists. (Also remove the adwaita shim, which is a left-over from previous RHEL versions that did not include libadwaita) Resolves: https://issues.redhat.com/browse/RHEL-51223
This commit is contained in:
parent
30e2a973f6
commit
8c0a4d8dd4
@ -1,19 +1,17 @@
|
||||
From d5dd07519ab1fe58717b538c49b3b94c840af67e Mon Sep 17 00:00:00 2001
|
||||
From 950f0fded26d8664bce5410db4c280674147cdd8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||||
Date: Thu, 2 Dec 2021 19:39:50 +0100
|
||||
Subject: [PATCH 3/5] Add classification-banner
|
||||
Subject: [PATCH] Add classification-banner
|
||||
|
||||
---
|
||||
extensions/classification-banner/adwShim.js | 202 ++++++++++++++++++
|
||||
extensions/classification-banner/extension.js | 162 ++++++++++++++
|
||||
extensions/classification-banner/extension.js | 163 +++++++++++++++
|
||||
extensions/classification-banner/meson.build | 9 +
|
||||
.../classification-banner/metadata.json.in | 11 +
|
||||
...tensions.classification-banner.gschema.xml | 29 +++
|
||||
extensions/classification-banner/prefs.js | 192 +++++++++++++++++
|
||||
extensions/classification-banner/prefs.js | 192 ++++++++++++++++++
|
||||
.../classification-banner/stylesheet.css | 3 +
|
||||
meson.build | 1 +
|
||||
8 files changed, 609 insertions(+)
|
||||
create mode 100644 extensions/classification-banner/adwShim.js
|
||||
7 files changed, 408 insertions(+)
|
||||
create mode 100644 extensions/classification-banner/extension.js
|
||||
create mode 100644 extensions/classification-banner/meson.build
|
||||
create mode 100644 extensions/classification-banner/metadata.json.in
|
||||
@ -21,224 +19,17 @@ Subject: [PATCH 3/5] Add classification-banner
|
||||
create mode 100644 extensions/classification-banner/prefs.js
|
||||
create mode 100644 extensions/classification-banner/stylesheet.css
|
||||
|
||||
diff --git a/extensions/classification-banner/adwShim.js b/extensions/classification-banner/adwShim.js
|
||||
new file mode 100644
|
||||
index 00000000..46a8afca
|
||||
--- /dev/null
|
||||
+++ b/extensions/classification-banner/adwShim.js
|
||||
@@ -0,0 +1,202 @@
|
||||
+/* exported init PreferencesPage PreferencesGroup ActionRow ComboRow */
|
||||
+const { Gio, GObject, Gtk } = imports.gi;
|
||||
+
|
||||
+function init() {
|
||||
+}
|
||||
+
|
||||
+var PreferencesGroup = GObject.registerClass(
|
||||
+class PreferencesGroup extends Gtk.Widget {
|
||||
+ _init(params) {
|
||||
+ super._init({
|
||||
+ ...params,
|
||||
+ layout_manager: new Gtk.BinLayout(),
|
||||
+ });
|
||||
+
|
||||
+ this._listBox = new Gtk.ListBox({
|
||||
+ css_classes: ['rich-list'],
|
||||
+ show_separators: true,
|
||||
+ selection_mode: Gtk.SelectionMode.NONE,
|
||||
+ });
|
||||
+
|
||||
+ const frame = new Gtk.Frame({ child: this._listBox });
|
||||
+ frame.set_parent(this);
|
||||
+ }
|
||||
+
|
||||
+ add(child) {
|
||||
+ this._listBox.append(child);
|
||||
+ }
|
||||
+});
|
||||
+
|
||||
+var PreferencesPage = GObject.registerClass(
|
||||
+class PreferencesPage extends Gtk.Widget {
|
||||
+ _init(params) {
|
||||
+ super._init({
|
||||
+ ...params,
|
||||
+ layout_manager: new Gtk.BinLayout(),
|
||||
+ });
|
||||
+
|
||||
+ const scrolledWindow = new Gtk.ScrolledWindow({
|
||||
+ hscrollbar_policy: Gtk.PolicyType.NEVER,
|
||||
+ });
|
||||
+ scrolledWindow.set_parent(this);
|
||||
+
|
||||
+ this._box = new Gtk.Box({
|
||||
+ orientation: Gtk.Orientation.VERTICAL,
|
||||
+ halign: Gtk.Align.CENTER,
|
||||
+ spacing: 24,
|
||||
+ margin_top: 24,
|
||||
+ margin_bottom: 24,
|
||||
+ margin_start: 12,
|
||||
+ margin_end: 12,
|
||||
+ });
|
||||
+ scrolledWindow.set_child(this._box);
|
||||
+
|
||||
+ const provider = new Gtk.CssProvider();
|
||||
+ provider.load_from_data('* { min-width: 500px; }');
|
||||
+ this._box.get_style_context().add_provider(provider,
|
||||
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
+ }
|
||||
+
|
||||
+ add(child) {
|
||||
+ this._box.append(child);
|
||||
+ }
|
||||
+});
|
||||
+
|
||||
+var ActionRow = GObject.registerClass({
|
||||
+ Properties: {
|
||||
+ 'activatable-widget': GObject.ParamSpec.object(
|
||||
+ 'activatable-widget', 'activatable-widget', 'activatable-widget',
|
||||
+ GObject.ParamFlags.READWRITE,
|
||||
+ Gtk.Widget),
|
||||
+ 'title': GObject.ParamSpec.string(
|
||||
+ 'title', 'title', 'title',
|
||||
+ GObject.ParamFlags.READWRITE,
|
||||
+ null),
|
||||
+ },
|
||||
+}, class ActionRow extends Gtk.ListBoxRow {
|
||||
+ _init(params) {
|
||||
+ super._init(params);
|
||||
+
|
||||
+ const box = new Gtk.Box({
|
||||
+ spacing: 12,
|
||||
+ });
|
||||
+ this.set_child(box);
|
||||
+
|
||||
+ this._prefixes = new Gtk.Box({
|
||||
+ spacing: 12,
|
||||
+ visible: false,
|
||||
+ });
|
||||
+ box.append(this._prefixes);
|
||||
+
|
||||
+ this._title = new Gtk.Label({
|
||||
+ css_classes: ['title'],
|
||||
+ hexpand: true,
|
||||
+ xalign: 0,
|
||||
+ });
|
||||
+ box.append(this._title);
|
||||
+
|
||||
+ this._suffixes = new Gtk.Box({
|
||||
+ spacing: 12,
|
||||
+ visible: false,
|
||||
+ });
|
||||
+ box.append(this._suffixes);
|
||||
+
|
||||
+ this.bind_property('title',
|
||||
+ this._title, 'label',
|
||||
+ GObject.BindingFlags.SYNC_CREATE);
|
||||
+
|
||||
+ this.connect('notify::parent', () => {
|
||||
+ const parent = this.get_parent();
|
||||
+ parent?.connect('row-activated', (list, row) => {
|
||||
+ if (row === this)
|
||||
+ this.activate();
|
||||
+ });
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ vfunc_activate() {
|
||||
+ this.activatable_widget?.mnemonic_activate(false);
|
||||
+ }
|
||||
+
|
||||
+ activate() {
|
||||
+ this.vfunc_activate();
|
||||
+ }
|
||||
+
|
||||
+ add_prefix(child) {
|
||||
+ this._prefixes.append(child);
|
||||
+ this._prefixes.show();
|
||||
+ }
|
||||
+
|
||||
+ add_suffix(child) {
|
||||
+ this._suffixes.append(child);
|
||||
+ this._suffixes.show();
|
||||
+ }
|
||||
+});
|
||||
+
|
||||
+var ComboRow = GObject.registerClass({
|
||||
+ Properties: {
|
||||
+ 'selected-item': GObject.ParamSpec.object(
|
||||
+ 'selected-item', 'selected-item', 'selected-item',
|
||||
+ GObject.ParamFlags.READABLE,
|
||||
+ GObject.Object),
|
||||
+ 'model': GObject.ParamSpec.object(
|
||||
+ 'model', 'model', 'model',
|
||||
+ GObject.ParamFlags.READWRITE,
|
||||
+ Gio.ListModel),
|
||||
+ 'list-factory': GObject.ParamSpec.object(
|
||||
+ 'list-factory', 'list-factory', 'list-factory',
|
||||
+ GObject.ParamFlags.READWRITE,
|
||||
+ Gtk.ListItemFactory),
|
||||
+ 'expression': Gtk.param_spec_expression(
|
||||
+ 'expression', 'expression', 'expression',
|
||||
+ GObject.ParamFlags.READWRITE),
|
||||
+ },
|
||||
+}, class ComboRow extends ActionRow {
|
||||
+ _init(params) {
|
||||
+ super._init({
|
||||
+ ...params,
|
||||
+ activatable: true,
|
||||
+ });
|
||||
+
|
||||
+ const box = new Gtk.Box({
|
||||
+ valign: Gtk.Align.CENTER,
|
||||
+ });
|
||||
+ box.append(new Gtk.Image({
|
||||
+ icon_name: 'pan-down-symbolic',
|
||||
+ }));
|
||||
+ this.add_suffix(box);
|
||||
+
|
||||
+ this._popover = new Gtk.Popover();
|
||||
+ this._popover.set_parent(box);
|
||||
+
|
||||
+ this._selection = new Gtk.SingleSelection();
|
||||
+ this._selected = -1;
|
||||
+
|
||||
+ this._listView = new Gtk.ListView({
|
||||
+ model: this._selection,
|
||||
+ single_click_activate: true,
|
||||
+ });
|
||||
+ this._popover.set_child(this._listView);
|
||||
+
|
||||
+ this._listView.connect('activate', (view, pos) => {
|
||||
+ this._selected = pos;
|
||||
+ this.notify('selected-item');
|
||||
+ this._popover.popdown();
|
||||
+ });
|
||||
+
|
||||
+ this.bind_property('model',
|
||||
+ this._selection, 'model',
|
||||
+ GObject.BindingFlags.SYNC_CREATE);
|
||||
+ this.bind_property('list-factory',
|
||||
+ this._listView, 'factory',
|
||||
+ GObject.BindingFlags.SYNC_CREATE);
|
||||
+ }
|
||||
+
|
||||
+ get selected_item() {
|
||||
+ return this._selection.selected_item;
|
||||
+ }
|
||||
+
|
||||
+ vfunc_activate() {
|
||||
+ this._popover.popup();
|
||||
+ }
|
||||
+});
|
||||
diff --git a/extensions/classification-banner/extension.js b/extensions/classification-banner/extension.js
|
||||
new file mode 100644
|
||||
index 00000000..e872d57d
|
||||
index 00000000..32c7d794
|
||||
--- /dev/null
|
||||
+++ b/extensions/classification-banner/extension.js
|
||||
@@ -0,0 +1,162 @@
|
||||
@@ -0,0 +1,163 @@
|
||||
+// SPDX-FileCopyrightText: 2021 Florian Müllner <fmuellner@gnome.org>
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+import Clutter from 'gi://Clutter';
|
||||
+import Cogl from 'gi://Cogl';
|
||||
+import Gio from 'gi://Gio';
|
||||
+import GLib from 'gi://GLib';
|
||||
+import GObject from 'gi://GObject';
|
||||
@ -338,7 +129,7 @@ index 00000000..e872d57d
|
||||
+
|
||||
+ #getColorSetting(key) {
|
||||
+ const str = this.#settings.get_string(key);
|
||||
+ const [valid, color] = Clutter.Color.from_string(str);
|
||||
+ const [valid, color] = Cogl.Color.from_string(str);
|
||||
+ if (!valid)
|
||||
+ return '';
|
||||
+ const {red, green, blue, alpha} = color;
|
||||
|
Loading…
Reference in New Issue
Block a user