]> Pileus Git - lackey/commitdiff
Add calendar edit/save functions
authorAndy Spencer <andy753421@gmail.com>
Mon, 26 Jan 2015 20:52:06 +0000 (20:52 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 5 Dec 2016 08:28:53 +0000 (08:28 +0000)
The calendar should set a form field using form_set to do it's editing.
Also move the edit types into cal.h so that it cal.h doesn't depend on
view stuff.

cals/dummy.c
cals/ical.c
src/cal.c
src/cal.h
src/view.c
src/view.h

index 1f57b1149b506760c64a1d2b908c18152a665265..9de8ed979564815b91d691911a9bf3c177a1df7b 100644 (file)
@@ -99,3 +99,12 @@ todo_t *dummy_todos(date_t start, date_t end)
        }
        return enable ? todo.next : 0;
 }
+
+/* Edit functions */
+void dummy_edit(edit_t mode)
+{
+}
+
+void dummy_save(edit_t mode)
+{
+}
index 57fff1eb1e9a779dbbd02f182e1b6f649bc98511..898bf61271ebaed88d1f5cffe0bfc04559036309 100644 (file)
@@ -332,6 +332,15 @@ todo_t *ical_todos(date_t _start, date_t _end)
        return todos;
 }
 
+/* Edit functions */
+void ical_edit(edit_t mode)
+{
+}
+
+void ical_save(edit_t mode)
+{
+}
+
 /* Test functions */
 void ical_printr(icalcomponent *comp, int depth)
 {
index afc18f01670f5abd6a5203287e64190811d7fa6b..5d5c637ff1c43199f8e80a71f9af3b544c4c24d2 100644 (file)
--- a/src/cal.c
+++ b/src/cal.c
@@ -26,7 +26,9 @@
        void     name##_config(const char *group, const char *name, const char *key, const char *value); \
        cal_t   *name##_cals(void); \
        event_t *name##_events(date_t start, date_t end); \
-       todo_t  *name##_todos(date_t start, date_t end)
+       todo_t  *name##_todos(date_t start, date_t end); \
+       void     name##_edit(edit_t mode); \
+       void     name##_save(edit_t mode)
 
 /* Prototypes */
 CAL(dummy);
@@ -201,6 +203,26 @@ void cal_config(const char *group, const char *name, const char *key, const char
                ical_config(group, name, key, value);
 }
 
+/* Edit functions */
+void cal_edit(edit_t mode)
+{
+       const cal_t *cal =
+               mode == EDIT_EVENT ? EVENT->cal :
+               mode == EDIT_TODO  ? TODO->cal  : CAL;
+       debug("cal_edit");
+       if (match(cal->type, "dummy")) dummy_edit(mode);
+       if (match(cal->type, "ical"))  ical_edit(mode);
+}
+
+void cal_save(edit_t mode)
+{
+       const cal_t *cal =
+               mode == EDIT_EVENT ? EVENT->cal :
+               mode == EDIT_TODO  ? TODO->cal  : CAL;
+       if (match(cal->type, "dummy")) dummy_save(mode);
+       if (match(cal->type, "ical"))  ical_save(mode);
+}
+
 /* Find event for matching target date */
 event_t *find_event(date_t *target)
 {
index 7d308ec23fe47f60dad9681571407685af30941f..07f113b7f578c60b95cbcd88fca28aaa9055a23c 100644 (file)
--- a/src/cal.h
+++ b/src/cal.h
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/* Edit modes */
+typedef enum {
+       EDIT_NONE,
+       EDIT_CAL,
+       EDIT_EVENT,
+       EDIT_TODO,
+} edit_t;
+
 /* Cal status types */
 typedef enum {
        NEW  = 0,
@@ -64,5 +72,9 @@ void cal_init(void);
 void cal_load(year_t year, month_t month, day_t day, int days);
 void cal_config(const char *group, const char *name, const char *key, const char *value);
 
+/* Edit functions */
+void cal_edit(edit_t edit);
+void cal_save(edit_t edit);
+
 /* Event functions */
 event_t *find_event(date_t *target);
index cfff88e0e14a6321220cec9ce72428179bf22952..3268617287835c842e1c18bf3d6562d71f516dec 100644 (file)
@@ -441,6 +441,7 @@ void view_config(const char *group, const char *name, const char *key, const cha
 void view_edit(edit_t mode)
 {
        EDIT = mode;
+       cal_edit(mode);
        set_view(active, &edit_view);
 }
 
index b896beaffb8dd048f69a7a8a776015991cadd336..facb2044d057d6a58b0ea3ec154304cd862d36cf 100644 (file)
 #define SHOW_DETAILS 0x1
 #define SHOW_ACTIVE  0x2
 
-/* Edit modes */
-typedef enum {
-       EDIT_NONE,
-       EDIT_CAL,
-       EDIT_EVENT,
-       EDIT_TODO,
-} edit_t;
-
 /* Config data */
 extern int COMPACT; // reduce layout spacing
 extern int MORNING; // first line to display