[gnome-maps] placeBar: Show contact avatars



commit 10320f4bfc924ed41657e599e9f63a5361a58fa5
Author: James Westman <james flyingpimonster net>
Date:   Tue Jan 5 13:07:41 2021 -0600

    placeBar: Show contact avatars

 data/ui/place-bar.ui |  9 +++++++++
 src/placeBar.js      | 15 +++++++++++++++
 2 files changed, 24 insertions(+)
---
diff --git a/data/ui/place-bar.ui b/data/ui/place-bar.ui
index 2845f468..28825b11 100644
--- a/data/ui/place-bar.ui
+++ b/data/ui/place-bar.ui
@@ -20,6 +20,15 @@
                     <property name="visible">True</property>
                     <property name="orientation">horizontal</property>
                     <property name="hexpand">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="HdyAvatar" id="contactAvatar">
+                        <property name="visible">False</property>
+                        <property name="can_focus">False</property>
+                        <property name="show_initials">True</property>
+                        <property name="size">32</property>
+                      </object>
+                    </child>
                     <child>
                       <object class="GtkLabel" id="title">
                         <style>
diff --git a/src/placeBar.js b/src/placeBar.js
index 708cf56c..72aae6e2 100644
--- a/src/placeBar.js
+++ b/src/placeBar.js
@@ -25,9 +25,11 @@ const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
 
 const Application = imports.application;
+const ContactPlace = imports.contactPlace;
 const PlaceButtons = imports.placeButtons;
 const PlaceDialog = imports.placeDialog;
 const PlaceFormatter = imports.placeFormatter;
+const Utils = imports.utils;
 
 var PlaceBar = GObject.registerClass({
     Template: 'resource:///org/gnome/Maps/ui/place-bar.ui',
@@ -35,6 +37,7 @@ var PlaceBar = GObject.registerClass({
                         'altSendToButton',
                         'box',
                         'eventbox',
+                        'contactAvatar',
                         'title' ],
     Properties: {
         'place': GObject.ParamSpec.object('place',
@@ -73,6 +76,18 @@ var PlaceBar = GObject.registerClass({
         let formatter = new PlaceFormatter.PlaceFormatter(this.place);
         this._title.label = formatter.title;
 
+        if (this.place instanceof ContactPlace.ContactPlace) {
+            this._contactAvatar.visible = true;
+            this._contactAvatar.text = formatter.title;
+
+            this._contactAvatar.set_image_load_func(null);
+            Utils.load_icon(this.place.icon, 32, (pixbuf) => {
+                this._contactAvatar.set_image_load_func((size) => Utils.loadAvatar(pixbuf, size));
+            });
+        } else {
+            this._contactAvatar.visible = false;
+        }
+
         this._buttons.place = this.place;
 
         this._altSendToButton.visible = this.place.isCurrentLocation;


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