[gnome-weather] Util: load stylesheets from resources, not files



commit 1d2d455a500ed84ea8547c624d206fd94b8a3715
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Jun 2 17:10:43 2013 +0200

    Util: load stylesheets from resources, not files
    
    Let's clean the code for the only case we use, and introduce a
    better convention for future copy-pastes of util.js

 src/main.js |    2 +-
 src/util.js |    7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/src/main.js b/src/main.js
index 25cbc3f..6695f58 100644
--- a/src/main.js
+++ b/src/main.js
@@ -64,7 +64,7 @@ const Application = new Lang.Class({
         let resource = Gio.Resource.load(pkg.pkgdatadir + '/gnome-weather.gresource');
         resource._register();
 
-        Util.loadStyleSheet(Gio.file_new_for_uri('resource:///org/gnome/weather/application.css'));
+        Util.loadStyleSheet('/org/gnome/weather/application.css');
 
         let settings = Gtk.Settings.get_for_screen(Gdk.Screen.get_default());
         settings.gtk_application_prefer_dark_theme = true;
diff --git a/src/util.js b/src/util.js
index c7553cd..d7642a1 100644
--- a/src/util.js
+++ b/src/util.js
@@ -36,12 +36,9 @@ function loadUI(resourcePath, objects) {
     return ui;
 }
 
-function loadStyleSheet(file) {
-    file = file || Gio.file_new_for_path(GLib.build_filenamev([pkg.pkgdatadir,
-                                                               'application.css']));
-
+function loadStyleSheet(resource) {
     let provider = new Gtk.CssProvider();
-    provider.load_from_file(file);
+    provider.load_from_file(Gio.File.new_for_uri('resource://' + resource));
     Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                              provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]