[calls] dbus: Expose path to avatar icon file if it exists



commit 8f9f7311fa7095492c2c900a23610e3b86a874dd
Author: Guido Günther <agx sigxcpu org>
Date:   Wed Nov 17 18:51:52 2021 +0100

    dbus: Expose path to avatar icon file if it exists
    
    We only support file based GLoadableIcon atm. Support for bytestreams
    can be added later on.

 src/calls-dbus-manager.c          | 29 ++++++++++++++++++++++++++++-
 src/dbus/org.gnome.Calls.Call.xml |  7 +++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/src/calls-dbus-manager.c b/src/calls-dbus-manager.c
index 46b9915c..ce8cf2e2 100644
--- a/src/calls-dbus-manager.c
+++ b/src/calls-dbus-manager.c
@@ -100,6 +100,29 @@ on_handle_call_hangup (CallsDBusCallsCall    *skeleton,
   return TRUE;
 }
 
+static gboolean
+(avatar_loadable_icon_transform_to_image_path) (GBinding *binding,
+                                                const GValue *from_value,
+                                                GValue *to_value,
+                                                gpointer user_data)
+{
+  GLoadableIcon *icon = G_LOADABLE_ICON (g_value_get_object(from_value));
+
+  if (icon == NULL) {
+    g_value_set_string (to_value, NULL);
+    return TRUE;
+  }
+
+  if (G_IS_FILE_ICON (icon)) {
+    GFile *file = g_file_icon_get_file (G_FILE_ICON (icon));
+
+    g_value_take_string (to_value, g_file_get_path (file));
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
 
 static void
 call_added_cb (CallsDBusManager *self, CallsCall *call)
@@ -133,7 +156,11 @@ call_added_cb (CallsDBusManager *self, CallsCall *call)
   match = calls_call_get_contact (call);
   if (calls_best_match_has_individual (match)) {
     g_object_bind_property (match, "name", iface, "display-name", G_BINDING_SYNC_CREATE);
-    /* TODO: avatar once https://source.puri.sm/Librem5/calls/-/issues/161 is fixed */
+    g_object_bind_property_full (match, "avatar",
+                                 iface, "image-path",
+                                 G_BINDING_SYNC_CREATE,
+                                 avatar_loadable_icon_transform_to_image_path,
+                                 NULL, NULL, NULL);
   }
   g_object_set_data_full (G_OBJECT (object), "contact", g_steal_pointer (&match), g_object_unref);
 
diff --git a/src/dbus/org.gnome.Calls.Call.xml b/src/dbus/org.gnome.Calls.Call.xml
index 57fc77ff..9fac6f67 100644
--- a/src/dbus/org.gnome.Calls.Call.xml
+++ b/src/dbus/org.gnome.Calls.Call.xml
@@ -40,6 +40,13 @@
         </doc:description>
       </doc:doc>
     </property>
+    <property name="ImagePath" type="s" access="read">
+      <doc:doc>
+        <doc:description>
+          <doc:para>The path to an image to display for this call.</doc:para>
+        </doc:description>
+      </doc:doc>
+    </property>
     <property name="Protocol" type="s" access="read">
       <doc:doc>
         <doc:description>


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