[gnome-shell] Add missing gtkutil.js file from previous commit



commit 3e33ee648104365115ac72bc143661f2d845df1a
Author: Colin Walters <walters verbum org>
Date:   Tue Apr 7 17:15:02 2009 -0400

    Add missing gtkutil.js file from previous commit
---
 js/ui/gtkutil.js |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/js/ui/gtkutil.js b/js/ui/gtkutil.js
new file mode 100644
index 0000000..56a9004
--- /dev/null
+++ b/js/ui/gtkutil.js
@@ -0,0 +1,30 @@
+/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
+
+const Lang = imports.lang;
+
+const Clutter = imports.gi.Clutter;
+const Gtk = imports.gi.Gtk;
+
+function loadIconToTexture(gicon, size, fallback) {
+    let iconTheme = Gtk.IconTheme.get_default();
+
+    let path = null;
+    let icon = null;
+    if (gicon != null) {
+        let iconinfo = iconTheme.lookup_by_gicon(gicon, size, Gtk.IconLookupFlags.NO_SVG);
+        if (iconinfo)
+            path = iconinfo.get_filename();
+    }
+    if (path) {
+        try {
+            icon = new Clutter.Texture({ width: size, height: size, load_async: true });
+            icon.set_from_file(path);
+            return icon;
+        } catch (e) {
+            icon = null;
+        }
+    }
+    if (icon == null && fallback)
+        icon = new Clutter.Texture({ width: size, height: size });
+    return icon;
+}
\ No newline at end of file



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