Merge branch 'master' of http://www.project-moonshot.org/git/moonshot-ui
[moonshot-ui.git] / src / moonshot-utils.vala
index 9f11c12..402e6d7 100644 (file)
@@ -14,8 +14,17 @@ public Gdk.Pixbuf? find_icon_sized (string name, Gtk.IconSize icon_size)
  * load them manually.
  */
 
+public bool gtk_available = false;
+
+public Gdk.Pixbuf? get_pixbuf(IdCard id)
+{
+    return find_icon("avatar-default", 48);
+}
+
 public Gdk.Pixbuf? find_icon (string name, int size)
 {
+    if (!gtk_available)
+        return null;
     try
     {
 #if OS_WIN32
@@ -23,11 +32,12 @@ public Gdk.Pixbuf? find_icon (string name, int size)
 
         // Hack to allow running within the source tree
         int last_dir_index = base_path.last_index_of_char ('\\');
-        if (base_path.substring (last_dir_index) == "\\src")
+        if (base_path.substring (last_dir_index) == "\\.libs" || base_path.substring (last_dir_index) == "src")
             base_path = base_path.slice(0, last_dir_index);
 
         string? filename = Path.build_filename (base_path, "share", "icons", "%s.png".printf (name));
         return new Gdk.Pixbuf.from_file_at_size (filename, size, size);
+
 #else
         var icon_theme = Gtk.IconTheme.get_default ();
         return icon_theme.load_icon (name, size, Gtk.IconLookupFlags.FORCE_SIZE);