[california] Don't allow create/update/remove on read-only cals: Closes bgo#726985
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Don't allow create/update/remove on read-only cals: Closes bgo#726985
- Date: Thu, 24 Apr 2014 00:29:16 +0000 (UTC)
commit 503780bd35b73a66f87af8efb4b552338791c010
Author: Jim Nelson <jim yorba org>
Date: Wed Apr 23 17:27:44 2014 -0700
Don't allow create/update/remove on read-only cals: Closes bgo#726985
src/backing/backing-source.vala | 10 ++++++++++
src/backing/eds/backing-eds-calendar-source.vala | 6 ++++++
src/host/host-create-update-event.vala | 2 +-
src/host/host-import-calendar.vala | 2 +-
src/host/host-quick-create-event.vala | 2 +-
src/host/host-show-event.vala | 3 ++-
6 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/backing/backing-source.vala b/src/backing/backing-source.vala
index c45625f..b907d7f 100644
--- a/src/backing/backing-source.vala
+++ b/src/backing/backing-source.vala
@@ -20,6 +20,7 @@ public abstract class Source : BaseObject, Gee.Comparable<Source> {
public const string PROP_IS_AVAILABLE = "is-available";
public const string PROP_TITLE = "title";
public const string PROP_VISIBLE = "visible";
+ public const string PROP_READONLY = "read-only";
public const string PROP_COLOR = "color";
/**
@@ -58,6 +59,15 @@ public abstract class Source : BaseObject, Gee.Comparable<Source> {
public bool visible { get; set; }
/**
+ * Whether the { link Source} is read-only.
+ *
+ * If true, write operations (create, update, remove) should not be attempted.
+ *
+ * It's possible this can change at run-time by the backend.
+ */
+ public bool read_only { get; protected set; }
+
+ /**
* The suggested color to use when displaying the { link Source} or information about or from
* it.
*/
diff --git a/src/backing/eds/backing-eds-calendar-source.vala
b/src/backing/eds/backing-eds-calendar-source.vala
index 9888257..535014b 100644
--- a/src/backing/eds/backing-eds-calendar-source.vala
+++ b/src/backing/eds/backing-eds-calendar-source.vala
@@ -25,6 +25,9 @@ internal class EdsCalendarSource : CalendarSource {
this.eds_source = eds_source;
this.eds_calendar = eds_calendar;
+ // read-only until opened, when state can be determined from client
+ read_only = true;
+
// use unidirectional bindings so source updates (writing) only occurs when changed from
// within the app
eds_source.bind_property("display-name", this, PROP_TITLE, BindingFlags.SYNC_CREATE);
@@ -113,12 +116,15 @@ internal class EdsCalendarSource : CalendarSource {
internal async void open_async(Cancellable? cancellable) throws Error {
client = (E.CalClient) yield E.CalClient.connect(eds_source, E.CalClientSourceType.EVENTS,
cancellable);
+
+ client.bind_property("readonly", this, PROP_READONLY, BindingFlags.SYNC_CREATE);
}
// Invoked by EdsStore when closing and dropping all its refs
internal async void close_async(Cancellable? cancellable) throws Error {
// no close -- just drop the ref
client = null;
+ read_only = true;
}
private void check_open() throws BackingError {
diff --git a/src/host/host-create-update-event.vala b/src/host/host-create-update-event.vala
index fa43c28..4c9c494 100644
--- a/src/host/host-create-update-event.vala
+++ b/src/host/host-create-update-event.vala
@@ -89,7 +89,7 @@ public class CreateUpdateEvent : Gtk.Grid, Toolkit.Card {
(cal) => cal.title);
foreach (Backing.CalendarSource calendar_source in
Backing.Manager.instance.get_sources_of_type<Backing.CalendarSource>()) {
- if (!calendar_source.visible)
+ if (!calendar_source.visible || calendar_source.read_only)
continue;
calendar_model.add(calendar_source);
diff --git a/src/host/host-import-calendar.vala b/src/host/host-import-calendar.vala
index 5c58bac..17b821b 100644
--- a/src/host/host-import-calendar.vala
+++ b/src/host/host-import-calendar.vala
@@ -46,7 +46,7 @@ public class ImportCalendar : Gtk.Dialog {
}
private bool model_filter(Backing.CalendarSource calendar_source) {
- return calendar_source.visible;
+ return calendar_source.visible && !calendar_source.read_only;
}
private void on_row_selected() {
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index c0639f7..c271b51 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -37,7 +37,7 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
(cal) => cal.title);
foreach (Backing.CalendarSource calendar_source in
Backing.Manager.instance.get_sources_of_type<Backing.CalendarSource>()) {
- if (calendar_source.visible)
+ if (calendar_source.visible && !calendar_source.read_only)
model.add(calendar_source);
}
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 963149e..6bf03f3 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -122,7 +122,8 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
// don't current support updating or removing recurring events properly; see
// https://bugzilla.gnome.org/show_bug.cgi?id=725786
// https://bugzilla.gnome.org/show_bug.cgi?id=725787
- bool visible = !event.is_recurring;
+ bool read_only = event.calendar_source != null && event.calendar_source.read_only;
+ bool visible = !event.is_recurring && !read_only;
update_button.visible = visible;
update_button.no_show_all = !visible;
remove_button.visible = visible;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]