[polari/wip/fmuellner/bg-app: 4/7] application: Add application style only once
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/bg-app: 4/7] application: Add application style only once
- Date: Mon, 14 Nov 2016 13:00:32 +0000 (UTC)
commit 232f63aa8c8e0086cf9febcb535f71980f6e7918
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 11 13:44:58 2016 +0100
application: Add application style only once
We currently add the application style when initializing the main
window, which is fine as long as the window is truly unique.
However once we allow running the app in the background, this won't
be the case anymore - the window can be closed and a new one opened
at a later point. So to make sure the custom style is only added once,
add it during application startup instead.
https://bugzilla.gnome.org/show_bug.cgi?id=770750
src/application.js | 13 +++++++++++++
src/mainWindow.js | 18 ------------------
2 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 6a4d057..6e2f40d 100644
--- a/src/application.js
+++ b/src/application.js
@@ -1,3 +1,4 @@
+const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
@@ -164,6 +165,18 @@ const Application = new Lang.Class({
this.pasteManager = new PasteManager.PasteManager();
this.notificationQueue = new AppNotifications.NotificationQueue();
this.commandOutputQueue = new AppNotifications.CommandOutputQueue();
+
+ let provider = new Gtk.CssProvider();
+ let uri = 'resource:///org/gnome/Polari/css/application.css';
+ let file = Gio.File.new_for_uri(uri);
+ try {
+ provider.load_from_file(Gio.File.new_for_uri(uri));
+ } catch(e) {
+ logError(e, "Failed to add application style");
+ }
+ Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
},
vfunc_activate: function() {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index cc420af..0f690f9 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -133,8 +133,6 @@ const MainWindow = new Lang.Class({
this.parent(params);
- this._addApplicationStyle();
-
this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
this._gtkSettings = Gtk.Settings.get_default();
@@ -314,22 +312,6 @@ const MainWindow = new Lang.Class({
});
},
- _addApplicationStyle: function() {
- let provider = new Gtk.CssProvider();
- let uri = 'resource:///org/gnome/Polari/css/application.css';
- let file = Gio.File.new_for_uri(uri);
- try {
- provider.load_from_file(Gio.File.new_for_uri(uri));
- } catch(e) {
- logError(e, "Failed to add application style");
- }
- Gtk.StyleContext.add_provider_for_screen(
- this.get_screen(),
- provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
- );
- },
-
_onRoomsLoaded: function(mgr) {
if (this.active_room)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]