[latexila] Override some CSS properties for Adwaita
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Override some CSS properties for Adwaita
- Date: Sun, 28 Sep 2014 15:12:36 +0000 (UTC)
commit 4da5ea288d5e443c89a542b5a558fc180b09a8f4
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Aug 19 21:24:06 2014 +0200
Override some CSS properties for Adwaita
src/latexila.gresource.xml | 4 ++++
src/latexila.vala | 41 +++++++++++++++++++++++++++++++++++++++++
src/main_window.vala | 3 +++
src/ui/latexila.adwaita.css | 3 +++
4 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/latexila.gresource.xml b/src/latexila.gresource.xml
index 0f55e5f..1491956 100644
--- a/src/latexila.gresource.xml
+++ b/src/latexila.gresource.xml
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
+ <gresource prefix="/org/gnome/latexila">
+ <file>ui/latexila.adwaita.css</file>
+ </gresource>
+
<gresource prefix="/org/gnome/latexila/stock-icons">
<!--
List of icons that are registered as new stock icons, so it can be used
diff --git a/src/latexila.vala b/src/latexila.vala
index fc42a6b..154794a 100644
--- a/src/latexila.vala
+++ b/src/latexila.vala
@@ -21,6 +21,8 @@
public class Latexila : Gtk.Application
{
+ static Gtk.CssProvider? _provider = null;
+
public Latexila ()
{
Object (application_id: "org.gnome.latexila");
@@ -107,6 +109,7 @@ public class Latexila : Gtk.Application
hold ();
set_application_icons ();
new StockIcons ();
+ setup_theme_extensions ();
AppSettings.get_default ();
create_window ();
@@ -139,6 +142,44 @@ public class Latexila : Gtk.Application
Gtk.Window.set_default_icon_list ((owned) list);
}
+ private void setup_theme_extensions ()
+ {
+ Gtk.Settings settings = Gtk.Settings.get_default ();
+ settings.notify["gtk-theme-name"].connect (update_theme);
+ update_theme ();
+ }
+
+ private void update_theme ()
+ {
+ Gtk.Settings settings = Gtk.Settings.get_default ();
+ Gdk.Screen screen = Gdk.Screen.get_default ();
+
+ if (settings.gtk_theme_name == "Adwaita")
+ {
+ if (_provider == null)
+ {
+ _provider = new Gtk.CssProvider ();
+ File file = File.new_for_uri ("resource:///org/gnome/latexila/ui/latexila.adwaita.css");
+ try
+ {
+ _provider.load_from_file (file);
+ }
+ catch (Error e)
+ {
+ warning ("Cannot load CSS: %s", e.message);
+ }
+ }
+
+ Gtk.StyleContext.add_provider_for_screen (screen, _provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+ else if (_provider != null)
+ {
+ Gtk.StyleContext.remove_provider_for_screen (screen, _provider);
+ _provider = null;
+ }
+ }
+
private void reopen_files ()
{
GLib.Settings editor_settings =
diff --git a/src/main_window.vala b/src/main_window.vala
index d088542..2f43880 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -371,6 +371,9 @@ public class MainWindow : Window
Toolbar edit_toolbar = _ui_manager.get_widget ("/EditToolbar") as Toolbar;
edit_toolbar.set_style (ToolbarStyle.ICONS);
+ StyleContext context = edit_toolbar.get_style_context ();
+ context.add_class ("latexila-edit-toolbar");
+
edit_toolbar.show_all ();
ToggleAction action =
diff --git a/src/ui/latexila.adwaita.css b/src/ui/latexila.adwaita.css
new file mode 100644
index 0000000..4c8e071
--- /dev/null
+++ b/src/ui/latexila.adwaita.css
@@ -0,0 +1,3 @@
+.primary-toolbar .button, .latexila-edit-toolbar .button {
+ padding: 2px;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]