Make calendars changable

This commit is contained in:
Jeena 2024-02-17 08:30:22 +09:00
parent 871a14ddc0
commit 555c44c5c0
3 changed files with 12 additions and 7 deletions

View file

@ -36,6 +36,7 @@ class JnotesApplication(Adw.Application):
calendar_set = None
def __init__(self):
super().__init__(application_id='net.jeena.jnotes',
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
@ -52,6 +53,7 @@ class JnotesApplication(Adw.Application):
win = self.props.active_window
if not win:
win = JnotesWindow(application=self)
win.sidebar.calendar_set.connect('row-selected', self.on_calendar_selected)
win.present()
def callback(calendar_set):
@ -60,14 +62,10 @@ class JnotesApplication(Adw.Application):
self.on_preferences_action(win, False)
else:
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.get_calendar_set(callback)
def on_about_action(self, widget, _):
"""Callback for the app.about action."""
about = Adw.AboutWindow(transient_for=self.props.active_window,
@ -99,6 +97,12 @@ class JnotesApplication(Adw.Application):
if 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):
"""The application's entry point."""

View file

@ -16,6 +16,6 @@ class NotesList(Gtk.ScrolledWindow):
self.notes_list.bind_model(calendar, self.create_item_widget)
def create_item_widget(self, note):
print(note.summary)
return Gtk.Label(label=note.summary, halign="start",
hexpand=True, ellipsize=3)
return Adw.ActionRow(title=note.summary,
subtitle=note.description)

View file

@ -94,6 +94,7 @@ class Sync():
@threaded
def get_calenndar_notes(self, calendar, callback):
self.spinner.start()
calendar.remove_all()
remote_calendar = self.principal.calendar(calendar.displayname)
for journal in remote_calendar.journals():
summary = journal.icalendar_component.get("summary", "")