[california/wip/731543-attendees] UI tweaking



commit 3c65c74310edb6fee1413b18ac6fa1d164c9e29d
Author: Jim Nelson <jim yorba org>
Date:   Wed Nov 12 16:53:57 2014 -0800

    UI tweaking

 src/collection/collection-iterable.vala |   12 ++++++++++++
 src/component/component-instance.vala   |    6 +++---
 src/host/host-create-update-event.vala  |   21 +++++++++++++++++++++
 src/host/host-show-event.vala           |    5 +++++
 src/toolkit/toolkit-listbox-model.vala  |    2 +-
 5 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/src/collection/collection-iterable.vala b/src/collection/collection-iterable.vala
index 9a67a6d..cd1afbd 100644
--- a/src/collection/collection-iterable.vala
+++ b/src/collection/collection-iterable.vala
@@ -285,6 +285,18 @@ public class Iterable<G> : Object {
         return true;
     }
     
+    /**
+     * The total number of items held in the { link Iterable}.
+     */
+    public int count() {
+        int count = 0;
+        Gee.Iterator<G> iter = iterator();
+        while (iter.next())
+            count++;
+        
+        return count;
+    }
+    
     public int count_matching(owned Gee.Predicate<G> f) {
         int count = 0;
         foreach (G g in this) {
diff --git a/src/component/component-instance.vala b/src/component/component-instance.vala
index 97f6933..1334ddc 100644
--- a/src/component/component-instance.vala
+++ b/src/component/component-instance.vala
@@ -548,14 +548,14 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
         attendees = new Gee.HashSet<Person>();
     }
     
-    private Gee.Set<Person> add_persons(Gee.Set<Person> existing, Gee.Collection<Person> to_add) {
-        Gee.Set<Person> copy = traverse<Person>(attendees).to_hash_set();
+    private static Gee.Set<Person> add_persons(Gee.Set<Person> existing, Gee.Collection<Person> to_add) {
+        Gee.Set<Person> copy = traverse<Person>(existing).to_hash_set();
         copy.add_all(to_add);
         
         return copy;
     }
     
-    private Gee.Set<Person> remove_persons(Gee.Set<Person> existing, Gee.Collection<Person> to_remove) {
+    private static Gee.Set<Person> remove_persons(Gee.Set<Person> existing, Gee.Collection<Person> 
to_remove) {
         return traverse<Person>(existing)
             .filter(person => !to_remove.contains(person))
             .to_hash_set();
diff --git a/src/host/host-create-update-event.vala b/src/host/host-create-update-event.vala
index 74d8f8e..0045b43 100644
--- a/src/host/host-create-update-event.vala
+++ b/src/host/host-create-update-event.vala
@@ -93,6 +93,9 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
         update_this_button.clicked.connect(on_update_this_button_clicked);
         cancel_recurring_button.clicked.connect(on_cancel_recurring_button_clicked);
         
+        attendees_text.query_tooltip.connect(on_attendees_text_query_tooltip);
+        attendees_text.has_tooltip = true;
+        
         rotating_button_box.pack_end(FAMILY_NORMAL, cancel_button);
         rotating_button_box.pack_end(FAMILY_NORMAL, accept_button);
         
@@ -159,6 +162,7 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
         description_textview.buffer.text = event.description ?? "";
         attendees_text.label = traverse<Component.Person>(event.attendees)
             .filter(attendee => !event.organizers.contains(attendee))
+            .sort()
             .to_string(stringify_attendees);
         if (String.is_empty(attendees_text.label))
             attendees_text.label = _("None");
@@ -182,11 +186,28 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
         rotating_button_box.family = FAMILY_NORMAL;
     }
     
+    private bool on_attendees_text_query_tooltip(Gtk.Widget widget, int x, int y, bool keyboard,
+        Gtk.Tooltip tooltip) {
+        if (!attendees_text.get_layout().is_ellipsized())
+            return false;
+        
+        tooltip.set_text(traverse<Component.Person>(event.attendees)
+            .filter(attendee => !event.organizers.contains(attendee))
+            .sort()
+            .to_string(stringify_attendees_tooltip));
+        
+        return true;
+    }
+    
     private string? stringify_attendees(Component.Person person, bool is_first, bool is_last) {
         // Email address followed by common separator, i.e. "alice example com, bob example com"
         return !is_last ? _("%s, ").printf(person.full_mailbox) : person.full_mailbox;
     }
     
+    private string? stringify_attendees_tooltip(Component.Person person, bool is_first, bool is_last) {
+        return !is_last ? "%s\n".printf(person.full_mailbox) : person.full_mailbox;
+    }
+    
     private void on_update_time_summary() {
         // use the Message, not the Event, to load this up
         time_summary_label.visible = true;
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 2c76355..8511eaa 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -171,6 +171,7 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
         string organizers = traverse<Component.Person>(event.organizers)
             .sort()
             .to_string(stringify_person) ?? "";
+        organizers_label.label = ngettext("Organizer", "Organizers", event.organizers.size);
         set_label(organizers_label, organizers_text, organizers);
         
         // attendees as a sort LF-delimited string w/ organizers removed
@@ -178,6 +179,10 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
             .filter(person => !event.organizers.contains(person))
             .sort()
             .to_string(stringify_person) ?? "";
+        int attendee_count = traverse<Component.Person>(event.attendees)
+            .filter(person => !event.organizers.contains(person))
+            .count();
+        attendees_label.label = ngettext("Guest", "Guests", attendee_count);
         set_label(attendees_label, attendees_text, attendees);
         
         // calendar
diff --git a/src/toolkit/toolkit-listbox-model.vala b/src/toolkit/toolkit-listbox-model.vala
index b043fda..efe3e95 100644
--- a/src/toolkit/toolkit-listbox-model.vala
+++ b/src/toolkit/toolkit-listbox-model.vala
@@ -242,7 +242,7 @@ public class ListBoxModel<G> : BaseObject {
      * Each removed item generates a { link removed} signal.
      */
     public void clear() {
-        foreach (G item in items.keys)
+        foreach (G item in items.keys.to_array())
             remove(item);
     }
     


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