Require desktop-file-utiles and shared-mime-info for %post spec fragment
[moonshot-ui.git] / src / moonshot-utils.vala
index b6e4410..25af1e4 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
@@ -40,3 +49,23 @@ public Gdk.Pixbuf? find_icon (string name, int size)
         return null;
     }
 }
+
+public extern unowned string GetUserName();
+public extern unowned string GetFlatStoreUsersFilePath();
+
+public bool UserForcesFlatFileStore()
+{
+    string username = GetUserName();
+    string flatstore_users_filename = GetFlatStoreUsersFilePath();
+    FileStream flatstore_users = FileStream.open(flatstore_users_filename, "r");
+    if (flatstore_users == null) {
+        return false;
+    }
+    string? flatstore_username = null;
+    while ((flatstore_username = flatstore_users.read_line()) != null) {
+        if (username == flatstore_username) {
+            return true;
+        }
+    }
+    return false;
+}