elementaryart team mailing list archive
-
elementaryart team
-
Mailing list archive
-
Message #02096
[Merge] lp:~mefrio-g/granite/icon-factory into lp:granite
Mario Guerriero has proposed merging lp:~mefrio-g/granite/icon-factory into lp:granite.
Requested reviews:
elementary Pantheon team (elementary-pantheon)
For more details, see:
https://code.launchpad.net/~mefrio-g/granite/icon-factory/+merge/107036
--
https://code.launchpad.net/~mefrio-g/granite/icon-factory/+merge/107036
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'lib/CMakeLists.txt'
--- lib/CMakeLists.txt 2012-05-15 04:26:30 +0000
+++ lib/CMakeLists.txt 2012-05-23 15:00:31 +0000
@@ -60,6 +60,7 @@
Services/Paths.vala
Services/System.vala
Services/Contractor.vala
+ Services/IconFactory.vala
Widgets/WrapLabel.vala
Widgets/AboutDialog.vala
Widgets/ModeButton.vala
=== added file 'lib/Services/IconFactory.vala'
--- lib/Services/IconFactory.vala 1970-01-01 00:00:00 +0000
+++ lib/Services/IconFactory.vala 2012-05-23 15:00:31 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 ammonkey <am.monkeyd@xxxxxxxxx>
+ * Copyright (C) 2012 Mario Guerriero <mario@xxxxxxxxxxxxxxxx>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Granite.Services {
+
+ public static IconFactory? icon_factory = null;
+
+ public class IconFactory : GLib.Object {
+
+ private Gtk.IconTheme icon_theme;
+
+ public class IconFactory () {
+ icon_theme = Gtk.IconTheme.get_default ();
+ }
+
+ public static IconFactory get_default () {
+ if (icon_factory != null)
+ return icon_factory;
+
+ icon_factory = new IconFactory ();
+ return icon_factory;
+ }
+
+ public Gdk.Pixbuf? load_symbolic_icon (Gtk.StyleContext style, string iconname, int size) {
+ Gdk.Pixbuf px = null;
+
+ ThemedIcon themed_icon = new ThemedIcon.with_default_fallbacks (iconname);
+ Gtk.IconInfo icon_info = icon_theme.lookup_by_gicon ((GLib.Icon) themed_icon, size, Gtk.IconLookupFlags.GENERIC_FALLBACK);
+ try {
+ px = icon_info.load_symbolic_for_context (style);
+ } catch (Error err) {
+ stderr.printf ("Unable to load symbolic icon: %s", err.message);
+ }
+
+ return px;
+ }
+
+ }
+}
\ No newline at end of file
Follow ups