Make calendars changable
This commit is contained in:
parent
871a14ddc0
commit
555c44c5c0
3 changed files with 12 additions and 7 deletions
12
src/main.py
12
src/main.py
|
@ -36,6 +36,7 @@ class JnotesApplication(Adw.Application):
|
||||||
|
|
||||||
calendar_set = None
|
calendar_set = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(application_id='net.jeena.jnotes',
|
super().__init__(application_id='net.jeena.jnotes',
|
||||||
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
|
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
|
||||||
|
@ -52,6 +53,7 @@ class JnotesApplication(Adw.Application):
|
||||||
win = self.props.active_window
|
win = self.props.active_window
|
||||||
if not win:
|
if not win:
|
||||||
win = JnotesWindow(application=self)
|
win = JnotesWindow(application=self)
|
||||||
|
win.sidebar.calendar_set.connect('row-selected', self.on_calendar_selected)
|
||||||
win.present()
|
win.present()
|
||||||
|
|
||||||
def callback(calendar_set):
|
def callback(calendar_set):
|
||||||
|
@ -60,14 +62,10 @@ class JnotesApplication(Adw.Application):
|
||||||
self.on_preferences_action(win, False)
|
self.on_preferences_action(win, False)
|
||||||
else:
|
else:
|
||||||
win.sidebar.set_calendars(self.calendar_set)
|
win.sidebar.set_calendars(self.calendar_set)
|
||||||
def callb(calendar):
|
|
||||||
win.notes_list.set_calendar(calendar)
|
|
||||||
Sync.get_calenndar_notes(self.calendar_set[0], callb)
|
|
||||||
|
|
||||||
Sync.set_spinner(win.sidebar.spinner)
|
Sync.set_spinner(win.sidebar.spinner)
|
||||||
Sync.get_calendar_set(callback)
|
Sync.get_calendar_set(callback)
|
||||||
|
|
||||||
|
|
||||||
def on_about_action(self, widget, _):
|
def on_about_action(self, widget, _):
|
||||||
"""Callback for the app.about action."""
|
"""Callback for the app.about action."""
|
||||||
about = Adw.AboutWindow(transient_for=self.props.active_window,
|
about = Adw.AboutWindow(transient_for=self.props.active_window,
|
||||||
|
@ -99,6 +97,12 @@ class JnotesApplication(Adw.Application):
|
||||||
if shortcuts:
|
if shortcuts:
|
||||||
self.set_accels_for_action(f"app.{name}", shortcuts)
|
self.set_accels_for_action(f"app.{name}", shortcuts)
|
||||||
|
|
||||||
|
def on_calendar_selected(self, container, row):
|
||||||
|
notes_list = self.props.active_window.notes_list
|
||||||
|
Sync.get_calenndar_notes(
|
||||||
|
self.calendar_set[row.get_index()],
|
||||||
|
lambda calendar: notes_list.set_calendar(calendar)
|
||||||
|
)
|
||||||
|
|
||||||
def main(version):
|
def main(version):
|
||||||
"""The application's entry point."""
|
"""The application's entry point."""
|
||||||
|
|
|
@ -16,6 +16,6 @@ class NotesList(Gtk.ScrolledWindow):
|
||||||
self.notes_list.bind_model(calendar, self.create_item_widget)
|
self.notes_list.bind_model(calendar, self.create_item_widget)
|
||||||
|
|
||||||
def create_item_widget(self, note):
|
def create_item_widget(self, note):
|
||||||
print(note.summary)
|
return Adw.ActionRow(title=note.summary,
|
||||||
return Gtk.Label(label=note.summary, halign="start",
|
subtitle=note.description)
|
||||||
hexpand=True, ellipsize=3)
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ class Sync():
|
||||||
@threaded
|
@threaded
|
||||||
def get_calenndar_notes(self, calendar, callback):
|
def get_calenndar_notes(self, calendar, callback):
|
||||||
self.spinner.start()
|
self.spinner.start()
|
||||||
|
calendar.remove_all()
|
||||||
remote_calendar = self.principal.calendar(calendar.displayname)
|
remote_calendar = self.principal.calendar(calendar.displayname)
|
||||||
for journal in remote_calendar.journals():
|
for journal in remote_calendar.journals():
|
||||||
summary = journal.icalendar_component.get("summary", "")
|
summary = journal.icalendar_component.get("summary", "")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue