summaryrefslogtreecommitdiff
path: root/src/contacts-ui-state.vala
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2018-01-13 18:28:28 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2018-01-13 18:28:28 +0100
commit279fecd0459f6b7e9112e7b3542c2d5300943d39 (patch)
tree8eadead06699ab535827f95732cf1cb7e98142dc /src/contacts-ui-state.vala
parent78862a18ce585451001cec0b0945ca64cf32a896 (diff)
downloadgnome-contacts-279fecd0459f6b7e9112e7b3542c2d5300943d39.tar.gz
Window: Implement the UI as an FSM.
This way it's clear what parts of the UI should be active when selecting, editing, ... It also allows us to get rid of a hard to follow combo of edit_mode/selection_mode/new_contact variables.
Diffstat (limited to 'src/contacts-ui-state.vala')
-rw-r--r--src/contacts-ui-state.vala60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/contacts-ui-state.vala b/src/contacts-ui-state.vala
new file mode 100644
index 0000000..ad7230b
--- /dev/null
+++ b/src/contacts-ui-state.vala
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Niels De Graef <nielsdegraef@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Roughly put, the behaviour of the UI of Contacts can be divided in several
+ * categories. We represent this with the UiState enum, which can be shared
+ * (and sync-ed) between the different parts of the app.
+ *
+ * Note that there is one exception to this: the initial setup is handled
+ * completely separately in the {@link SetupWindow}.
+ */
+public enum Contacts.UiState {
+ /**
+ * The start state: no contact is selected/displayed.
+ */
+ NORMAL,
+
+ /**
+ * A contact has been selected and is displayed.
+ */
+ SHOWING,
+
+ /**
+ * Zero or more contacts are selected (but this can be changed).
+ * No contact should be displayed.
+ */
+ SELECTING,
+
+ /**
+ * The selected contact is being edited.
+ */
+ UPDATING,
+
+ /**
+ * A new contact is being created.
+ */
+ CREATING;
+
+ /**
+ * Returns whether we're editing a contact, either by changing an existing
+ * one, or by creating a new one.
+ */
+ public bool editing () {
+ return this == UiState.UPDATING || this == UiState.CREATING;
+ }
+}