[california/wip/740088-invite] Use default email address for Organizer
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/740088-invite] Use default email address for Organizer
- Date: Thu, 20 Nov 2014 20:01:55 +0000 (UTC)
commit e64c9db4d4f8f44ad8b1e997148ec12bf3acdd97
Author: Jim Nelson <jim yorba org>
Date: Thu Nov 20 12:01:22 2014 -0800
Use default email address for Organizer
This introduces some clean-up to the Deck/Card system; more to come.
src/activator/activator-instance-list.vala | 2 +-
.../google/google-authenticating-pane.vala | 2 +-
src/activator/google/google-login-pane.vala | 2 +-
src/component/component-instance.vala | 8 +++
src/host/host-attendees-editor.vala | 46 +++++++++++++++++---
src/host/host-create-update-event.vala | 8 ++-
src/host/host-create-update-recurring.vala | 2 +-
src/host/host-event-time-settings.vala | 2 +-
src/manager/manager-calendar-list.vala | 4 +-
src/toolkit/toolkit-card.vala | 12 +-----
src/toolkit/toolkit-deck.vala | 28 +++++-------
11 files changed, 71 insertions(+), 45 deletions(-)
---
diff --git a/src/activator/activator-instance-list.vala b/src/activator/activator-instance-list.vala
index f3bf575..16532bc 100644
--- a/src/activator/activator-instance-list.vala
+++ b/src/activator/activator-instance-list.vala
@@ -63,7 +63,7 @@ public class InstanceList : Gtk.Grid, Toolkit.Card {
}
private void start(Instance activator) {
- jump_to_card_by_name(activator.first_card_id, null);
+ jump_to_card_by_id(activator.first_card_id, null);
}
private Gtk.Widget model_presentation(Instance activator) {
diff --git a/src/activator/google/google-authenticating-pane.vala
b/src/activator/google/google-authenticating-pane.vala
index 12c107e..a329b3e 100644
--- a/src/activator/google/google-authenticating-pane.vala
+++ b/src/activator/google/google-authenticating-pane.vala
@@ -134,7 +134,7 @@ public class AuthenticatingPane : Gtk.Grid, Toolkit.Card {
// delay gives the user a chance to see what's transpired
yield sleep_msec_async(SUCCESS_DELAY_MSEC);
- jump_to_card_by_name(CalendarListPane.ID, new CalendarListPane.Message(
+ jump_to_card_by_id(CalendarListPane.ID, new CalendarListPane.Message(
credentials.username, own_calendars, all_calendars));
}
diff --git a/src/activator/google/google-login-pane.vala b/src/activator/google/google-login-pane.vala
index 956bfab..e1f5907 100644
--- a/src/activator/google/google-login-pane.vala
+++ b/src/activator/google/google-login-pane.vala
@@ -56,7 +56,7 @@ internal class LoginPane : Gtk.Grid, Toolkit.Card {
[GtkCallback]
private void on_login_button_clicked() {
- jump_to_card_by_name(AuthenticatingPane.ID, new AuthenticatingPane.Message(
+ jump_to_card_by_id(AuthenticatingPane.ID, new AuthenticatingPane.Message(
account_entry.text, password_entry.text));
}
}
diff --git a/src/component/component-instance.vala b/src/component/component-instance.vala
index 45f8ee4..2c534f2 100644
--- a/src/component/component-instance.vala
+++ b/src/component/component-instance.vala
@@ -180,8 +180,12 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
* merely modify the list, the property can be watched for changes with the "notify" and/or
* "altered" signals.
*
+ * Note that it's possible for an ORGANIZER to also be an ATTENDEE.
+ *
* See [[https://tools.ietf.org/html/rfc5545#section-3.8.4.3]] In particular, note that the
* { link organizer} must be specified in group-scheduled calendar entity.
+ *
+ * @see attendees
*/
public Gee.Set<Person> organizers { get; private set; default = new Gee.HashSet<Person>(); }
@@ -193,7 +197,11 @@ public abstract class Instance : BaseObject, Gee.Hashable<Instance> {
* merely modify the list, the property can be watched for changes with the "notify" and/or
* "altered" signals.
*
+ * Note that it's possible for an ATTENDEE to also be an ORGANIZER.
+ *
* See [[https://tools.ietf.org/html/rfc5545#section-3.8.4.1]]
+ *
+ * @see organizers
*/
public Gee.Set<Person> attendees { get; private set; default = new Gee.HashSet<Person>(); }
diff --git a/src/host/host-attendees-editor.vala b/src/host/host-attendees-editor.vala
index 91355e5..0b8024a 100644
--- a/src/host/host-attendees-editor.vala
+++ b/src/host/host-attendees-editor.vala
@@ -8,7 +8,17 @@ namespace California.Host {
[GtkTemplate (ui = "/org/yorba/california/rc/attendees-editor.ui")]
public class AttendeesEditor : Gtk.Box, Toolkit.Card {
- public const string ID = "CaliforniaHostAttendeesEditor";
+ private const string ID = "CaliforniaHostAttendeesEditor";
+
+ private class Message : Object {
+ public Component.Event event;
+ public Backing.CalendarSource calendar_source;
+
+ public Message(Component.Event event, Backing.CalendarSource calendar_source) {
+ this.event = event;
+ this.calendar_source = calendar_source;
+ }
+ }
private class AttendeePresentation : Gtk.Box {
public Component.Person attendee { get; private set; }
@@ -72,6 +82,7 @@ public class AttendeesEditor : Gtk.Box, Toolkit.Card {
private Gtk.Button accept_button;
private new Component.Event? event = null;
+ private Backing.CalendarSource? calendar_source = null;
private Toolkit.ListBoxModel<Component.Person> guest_model;
private Toolkit.EntryClearTextConnector entry_clear_connector = new Toolkit.EntryClearTextConnector();
@@ -116,10 +127,16 @@ public class AttendeesEditor : Gtk.Box, Toolkit.Card {
return true;
}
- public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message) {
- event = message as Component.Event;
- if (event == null)
- return;
+ public static void pass_message(Toolkit.Card caller, Component.Event event,
+ Backing.CalendarSource calendar_source) {
+ caller.jump_to_card_by_id(ID, new Message(event, calendar_source));
+ }
+
+ public void jumped_to(Toolkit.Card? from, Toolkit.Card.Jump reason, Value? message_value) {
+ Message message = (Message) message_value;
+
+ event = message.event;
+ calendar_source = message.calendar_source;
// clear list and add all attendees who are not organizers
guest_model.clear();
@@ -128,9 +145,21 @@ public class AttendeesEditor : Gtk.Box, Toolkit.Card {
.to_array_list()
);
- // we only support one organizer, so use first one in form
+ // clear organizer entry and populate from supplied information
+ organizer_entry.text = "";
+
+ // we only support one organizer, so use first one in form, otherwise use default from
+ // calendar source
if (!event.organizers.is_empty)
organizer_entry.text = traverse<Component.Person>(event.organizers).first().mailbox;
+ else if (!String.is_empty(calendar_source.mailbox))
+ organizer_entry.text = calendar_source.mailbox;
+
+ // if organizer has been filled-in, give focus to guest entry
+ if (String.is_empty(organizer_entry.text))
+ organizer_entry.grab_focus();
+ else
+ add_guest_entry.grab_focus();
}
[GtkCallback]
@@ -181,6 +210,7 @@ public class AttendeesEditor : Gtk.Box, Toolkit.Card {
[GtkCallback]
private void on_accept_button_clicked() {
+ // organizer required if one or more guests invited
Component.Person? organizer = null;
if (guest_model.size > 0) {
organizer = make_person(organizer_entry.text, Component.Person.Relationship.ORGANIZER);
@@ -188,14 +218,16 @@ public class AttendeesEditor : Gtk.Box, Toolkit.Card {
return;
}
+ // remove organizer if no guests, set organizer if guests
event.clear_organizers();
if (organizer != null)
event.add_organizers(iterate<Component.Person>(organizer).to_array_list());
+ // add all guests as attendees
event.clear_attendees();
event.add_attendees(guest_model.all());
- jump_to_card_by_name(CreateUpdateEvent.ID, event);
+ jump_to_card_by_id(CreateUpdateEvent.ID, event);
}
[GtkCallback]
diff --git a/src/host/host-create-update-event.vala b/src/host/host-create-update-event.vala
index 36f4a12..5cb62c5 100644
--- a/src/host/host-create-update-event.vala
+++ b/src/host/host-create-update-event.vala
@@ -260,7 +260,7 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
update_component(event, true);
// send off to recurring editor
- jump_to_card_by_name(CreateUpdateRecurring.ID, event);
+ jump_to_card_by_id(CreateUpdateRecurring.ID, event);
}
[GtkCallback]
@@ -271,12 +271,13 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
// save changes with what's in the component now
update_component(event, true);
- jump_to_card_by_name(EventTimeSettings.ID, dt);
+ jump_to_card_by_id(EventTimeSettings.ID, dt);
}
[GtkCallback]
private void on_attendees_button_clicked() {
- jump_to_card_by_name(AttendeesEditor.ID, event);
+ if (calendar_model.active != null)
+ AttendeesEditor.pass_message(this, event, calendar_model.active);
}
private void on_accept_button_clicked() {
@@ -436,6 +437,7 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
// Make list of invitees, which are attendees who are not organizers
Gee.List<Component.Person> invitees = traverse<Component.Person>(event.attendees)
.filter(attendee => !event.organizers.contains(attendee))
+ .filter(attendee => attendee.send_invite)
.sort()
.to_array_list();
diff --git a/src/host/host-create-update-recurring.vala b/src/host/host-create-update-recurring.vala
index f52f899..7fec886 100644
--- a/src/host/host-create-update-recurring.vala
+++ b/src/host/host-create-update-recurring.vala
@@ -492,7 +492,7 @@ public class CreateUpdateRecurring : Gtk.Grid, Toolkit.Card {
[GtkCallback]
private void on_ok_button_clicked() {
update_master();
- jump_to_card_by_name(CreateUpdateEvent.ID, event);
+ jump_to_card_by_id(CreateUpdateEvent.ID, event);
}
private bool can_make_rrule() {
diff --git a/src/host/host-event-time-settings.vala b/src/host/host-event-time-settings.vala
index ee30a08..917623a 100644
--- a/src/host/host-event-time-settings.vala
+++ b/src/host/host-event-time-settings.vala
@@ -159,7 +159,7 @@ public class EventTimeSettings : Gtk.Box, Toolkit.Card {
else
message.reset_exact_time_span(get_exact_time_span());
- jump_to_card_by_name(CreateUpdateEvent.ID, message);
+ jump_to_card_by_id(CreateUpdateEvent.ID, message);
}
private void freeze_widget_notifications() {
diff --git a/src/manager/manager-calendar-list.vala b/src/manager/manager-calendar-list.vala
index 78cbf4a..0c964d1 100644
--- a/src/manager/manager-calendar-list.vala
+++ b/src/manager/manager-calendar-list.vala
@@ -128,7 +128,7 @@ internal class CalendarList : Gtk.Grid, Toolkit.Card {
[GtkCallback]
private void on_add_button_clicked() {
- jump_to_card_by_name(Activator.InstanceList.ID, null);
+ jump_to_card_by_id(Activator.InstanceList.ID, null);
}
[GtkCallback]
@@ -143,7 +143,7 @@ internal class CalendarList : Gtk.Grid, Toolkit.Card {
[GtkCallback]
private void on_remove_button_clicked() {
if (model.selected != null)
- jump_to_card_by_name(RemoveCalendar.ID, model.selected);
+ jump_to_card_by_id(RemoveCalendar.ID, model.selected);
}
[GtkCallback]
diff --git a/src/toolkit/toolkit-card.vala b/src/toolkit/toolkit-card.vala
index fbdd817..2150176 100644
--- a/src/toolkit/toolkit-card.vala
+++ b/src/toolkit/toolkit-card.vala
@@ -97,21 +97,11 @@ public interface Card : Gtk.Widget {
public Deck? deck { get { return parent as Deck; } }
/**
- * Fired when the { link Card} wishes to jump to another Card in the same { link Deck.}
- *
- * Each Card can accept a message which parameterizes its activation. It's up to Cards
- * navigating to the new one to construct and pass an appropriate message.
- *
- * @see jump_to_card_by_name
- */
- public signal void jump_to_card(Card next, Value? message);
-
- /**
* Fired when the { link Card} wishes to jump to another Card by its name.
*
* @see jump_to_card
*/
- public signal void jump_to_card_by_name(string name, Value? message);
+ public signal void jump_to_card_by_id(string id, Value? message);
/**
* Fired when the { link Card} wishes to jump to the previous Card in the { link Deck}.
diff --git a/src/toolkit/toolkit-deck.vala b/src/toolkit/toolkit-deck.vala
index 9a3563b..b1a5646 100644
--- a/src/toolkit/toolkit-deck.vala
+++ b/src/toolkit/toolkit-deck.vala
@@ -41,7 +41,7 @@ public class Deck : Gtk.Stack {
private Gee.List<Card> list = new Gee.LinkedList<Card>();
private Gee.Deque<Card> navigation_stack = new Gee.LinkedList<Card>();
- private Gee.HashMap<string, Card> names = new Gee.HashMap<string, Card>();
+ private Gee.HashMap<string, Card> ids = new Gee.HashMap<string, Card>();
/**
* Fired before { link Card}s are added or removed.
@@ -78,7 +78,7 @@ public class Deck : Gtk.Stack {
}
~Deck() {
- foreach (Card card in names.values) {
+ foreach (Card card in ids.values) {
card.map.disconnect(on_card_mapped);
card.realize.disconnect(on_card_realized);
}
@@ -87,8 +87,7 @@ public class Deck : Gtk.Stack {
private void on_child_to_top() {
// disconnect from previous top card and push onto nav stack
if (top != null) {
- top.jump_to_card.disconnect(on_jump_to_card_instance);
- top.jump_to_card_by_name.disconnect(on_jump_to_card_by_name);
+ top.jump_to_card_by_id.disconnect(on_jump_to_card_by_id);
top.jump_back.disconnect(on_jump_back);
top.jump_home.disconnect(on_jump_home);
top.dismiss.disconnect(on_dismiss);
@@ -101,8 +100,7 @@ public class Deck : Gtk.Stack {
// make new visible child top Card and connect to its signals
top = visible_child as Card;
if (top != null) {
- top.jump_to_card.connect(on_jump_to_card_instance);
- top.jump_to_card_by_name.connect(on_jump_to_card_by_name);
+ top.jump_to_card_by_id.connect(on_jump_to_card_by_id);
top.jump_back.connect(on_jump_back);
top.jump_home.connect(on_jump_home);
top.dismiss.connect(on_dismiss);
@@ -138,14 +136,14 @@ public class Deck : Gtk.Stack {
foreach (Card card in cards) {
// each card must have a unique name
assert(!String.is_empty(card.card_id));
- assert(!names.has_key(card.card_id));
+ assert(!ids.has_key(card.card_id));
if (String.is_empty(card.title))
add_named(card, card.card_id);
else
add_titled(card, card.card_id, card.title);
- names.set(card.card_id, card);
+ ids.set(card.card_id, card);
// deal with initial_focus and default_widget when mapped, as the calls aren't
// guaranteed to work during programmatic navigation (especially for the first card,
@@ -179,7 +177,7 @@ public class Deck : Gtk.Stack {
adding_removing_cards(null, cards);
foreach (Card card in cards) {
- if (!names.has_key(card.card_id)) {
+ if (!ids.has_key(card.card_id)) {
message("Card %s not found in Deck", card.card_id);
continue;
@@ -194,7 +192,7 @@ public class Deck : Gtk.Stack {
top = null;
navigation_stack.remove(card);
- names.unset(card.card_id);
+ ids.unset(card.card_id);
list.remove(card);
}
@@ -252,7 +250,7 @@ public class Deck : Gtk.Stack {
}
// do nothing if not registered with this Deck
- if (!names.values.contains(next)) {
+ if (!ids.values.contains(next)) {
GLib.message("Card %s not registered with Deck", next.card_id);
return;
@@ -262,12 +260,8 @@ public class Deck : Gtk.Stack {
next.jumped_to(card, reason, strip_null_value(message));
}
- private void on_jump_to_card_instance(Card card, Card next, Value? message) {
- on_jump_to_card(card, next, Card.Jump.DIRECT, message);
- }
-
- private void on_jump_to_card_by_name(Card card, string name, Value? message) {
- Card? next = names.get(name);
+ private void on_jump_to_card_by_id(Card card, string id, Value? message) {
+ Card? next = ids.get(id);
if (next != null)
on_jump_to_card(card, next, Card.Jump.DIRECT, message);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]