[geary/mjog/mutiple-main-windows: 12/14] Move global GTK CSS loading from main window to the app
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/mutiple-main-windows: 12/14] Move global GTK CSS loading from main window to the app
- Date: Mon, 18 Nov 2019 04:32:38 +0000 (UTC)
commit 1ea97dcdb67fc93413ba7cc83126596e10c4a221
Author: Michael Gratton <mike vee net>
Date: Mon Nov 18 13:53:20 2019 +1100
Move global GTK CSS loading from main window to the app
src/client/application/application-client.vala | 32 ++++++++++++++++++++++
.../application/application-main-window.vala | 31 +++------------------
2 files changed, 36 insertions(+), 27 deletions(-)
---
diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala
index c858076b..7e5a3ba1 100644
--- a/src/client/application/application-client.vala
+++ b/src/client/application/application-client.vala
@@ -424,6 +424,23 @@ public class Application.Client : Gtk.Application {
add_edit_accelerators(Action.Edit.REDO, { "<Ctrl><Shift>Z" });
add_edit_accelerators(Action.Edit.UNDO, { "<Ctrl>Z" });
+ // Load Geary GTK CSS
+ var provider = new Gtk.CssProvider();
+ Gtk.StyleContext.add_provider_for_screen(
+ Gdk.Display.get_default().get_default_screen(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
+ );
+ provider.parsing_error.connect(on_css_parse_error);
+ try {
+ var file = GLib.File.new_for_uri(
+ "resource:///org/gnome/Geary/geary.css"
+ );
+ provider.load_from_file(file);
+ } catch (GLib.Error error) {
+ warning("Could not load CSS: %s", error.message);
+ }
+
MainWindow.add_accelerators(this);
Composer.Widget.add_accelerators(this);
Components.Inspector.add_accelerators(this);
@@ -1066,4 +1083,19 @@ public class Application.Client : Gtk.Application {
}
}
+ private void on_css_parse_error(Gtk.CssSection section, GLib.Error error) {
+ uint start = section.get_start_line();
+ uint end = section.get_end_line();
+ if (start == end) {
+ warning(
+ "Error parsing %s:%u: %s",
+ section.get_file().get_uri(), start, error.message
+ );
+ } else {
+ warning(
+ "Error parsing %s:%u-%u: %s",
+ section.get_file().get_uri(), start, end, error.message
+ );
+ }
+ }
}
diff --git a/src/client/application/application-main-window.vala
b/src/client/application/application-main-window.vala
index 0deab873..b8b2c39a 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -284,6 +284,10 @@ public class Application.MainWindow :
load_config(application.config);
restore_saved_window_state();
+ if (_PROFILE != "") {
+ this.get_style_context().add_class("devel");
+ }
+
// Edit actions
this.edit_actions.add_action_entries(EDIT_ACTIONS, this);
insert_action_group(Action.Edit.GROUP_NAME, this.edit_actions);
@@ -291,7 +295,6 @@ public class Application.MainWindow :
// Window actions
add_action_entries(MainWindow.WINDOW_ACTIONS, this);
- set_styling();
setup_layout(application.config);
on_change_orientation();
@@ -889,32 +892,6 @@ public class Application.MainWindow :
notification.show();
}
- private void set_styling() {
- Gtk.CssProvider provider = new Gtk.CssProvider();
- Gtk.StyleContext.add_provider_for_screen(Gdk.Display.get_default().get_default_screen(),
- provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-
- if (_PROFILE != "") {
- Gtk.StyleContext ctx = this.get_style_context();
- ctx.add_class("devel");
- }
-
- provider.parsing_error.connect((section, error) => {
- uint start = section.get_start_line();
- uint end = section.get_end_line();
- if (start == end)
- debug("Error parsing css on line %u: %s", start, error.message);
- else
- debug("Error parsing css on lines %u-%u: %s", start, end, error.message);
- });
- try {
- File file = File.new_for_uri(@"resource:///org/gnome/Geary/geary.css");
- provider.load_from_file(file);
- } catch (Error e) {
- error("Could not load CSS: %s", e.message);
- }
- }
-
private void setup_layout(Configuration config) {
this.notify["has-toplevel-focus"].connect(on_has_toplevel_focus);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]