Save changes on server
This commit is contained in:
parent
95091ae54e
commit
5bc0a2f480
2 changed files with 38 additions and 4 deletions
|
@ -108,9 +108,10 @@ class JnotesApplication(Adw.Application):
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_note_selected(self, container, row):
|
def on_note_selected(self, container, row):
|
||||||
calendar = self.props.active_window.notes_list.calendar
|
if row:
|
||||||
note = calendar[row.get_index()]
|
calendar = self.props.active_window.notes_list.calendar
|
||||||
self.props.active_window.note_edit.set_note(note)
|
note = calendar[row.get_index()]
|
||||||
|
self.props.active_window.note_edit.set_note(note)
|
||||||
|
|
||||||
def main(version):
|
def main(version):
|
||||||
"""The application's entry point."""
|
"""The application's entry point."""
|
||||||
|
|
35
src/sync.py
35
src/sync.py
|
@ -99,10 +99,28 @@ class Sync():
|
||||||
for journal in remote_calendar.journals():
|
for journal in remote_calendar.journals():
|
||||||
summary = journal.icalendar_component.get("summary", "")
|
summary = journal.icalendar_component.get("summary", "")
|
||||||
description = journal.icalendar_component.get("description", "")
|
description = journal.icalendar_component.get("description", "")
|
||||||
calendar.add_note(Note(calendar, summary, description))
|
note = Note(calendar, summary, description)
|
||||||
|
note.journal = journal
|
||||||
|
note.uid = journal.icalendar_component.get("uid", "")
|
||||||
|
print(journal.data)
|
||||||
|
calendar.add_note(note)
|
||||||
self.spinner.stop()
|
self.spinner.stop()
|
||||||
callback(calendar)
|
callback(calendar)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@threaded
|
||||||
|
def save_calendar_note(self, note, callback):
|
||||||
|
self.spinner.start()
|
||||||
|
remote_calendar = self.principal.calendar(note.calendar.displayname)
|
||||||
|
journal = note.journal.icalendar_component
|
||||||
|
journal["summary"] = note.summary
|
||||||
|
journal["description"] = note.description
|
||||||
|
note.journal.save()
|
||||||
|
uid = ""
|
||||||
|
self.spinner.stop()
|
||||||
|
callback(uid)
|
||||||
|
|
||||||
|
|
||||||
class CalendarSet(Gio.ListStore):
|
class CalendarSet(Gio.ListStore):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -133,17 +151,32 @@ class Calendar(Gio.ListStore):
|
||||||
def on_notify_note_changed(self, note, gparamstring):
|
def on_notify_note_changed(self, note, gparamstring):
|
||||||
(found, position) = self.find(note)
|
(found, position) = self.find(note)
|
||||||
if found:
|
if found:
|
||||||
|
note.dirty = True
|
||||||
self.items_changed(position, 1, 1)
|
self.items_changed(position, 1, 1)
|
||||||
|
note.sync()
|
||||||
|
|
||||||
class Note(GObject.GObject):
|
class Note(GObject.GObject):
|
||||||
__gtype_name__ = "Note"
|
__gtype_name__ = "Note"
|
||||||
uid = None
|
uid = None
|
||||||
calendar = None
|
calendar = None
|
||||||
|
journal = None
|
||||||
summary = GObject.property(type=str)
|
summary = GObject.property(type=str)
|
||||||
description = GObject.property(type=str)
|
description = GObject.property(type=str)
|
||||||
|
dirty = GObject.Property(type=bool, default=False)
|
||||||
|
|
||||||
def __init__(self, calendar, summary, description):
|
def __init__(self, calendar, summary, description):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.calendar = calendar
|
self.calendar = calendar
|
||||||
self.summary = summary
|
self.summary = summary
|
||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
|
def sync(self):
|
||||||
|
if self.dirty:
|
||||||
|
def callback(uid):
|
||||||
|
self.dirty = False
|
||||||
|
if uid:
|
||||||
|
self.uid = uid
|
||||||
|
Sync.save_calendar_note(self, callback)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue