Update list UI when details change
This commit is contained in:
parent
ed63ac8e78
commit
5fbcb03d73
6 changed files with 40 additions and 16 deletions
|
@ -100,8 +100,10 @@ class JnotesApplication(Adw.Application):
|
||||||
|
|
||||||
def on_calendar_selected(self, container, row):
|
def on_calendar_selected(self, container, row):
|
||||||
notes_list = self.props.active_window.notes_list
|
notes_list = self.props.active_window.notes_list
|
||||||
|
cal_row = self.calendar_set[row.get_index()]
|
||||||
|
self.props.active_window.notes_list_page.set_title(cal_row.displayname)
|
||||||
Sync.get_calenndar_notes(
|
Sync.get_calenndar_notes(
|
||||||
self.calendar_set[row.get_index()],
|
cal_row,
|
||||||
lambda calendar: notes_list.set_calendar(calendar)
|
lambda calendar: notes_list.set_calendar(calendar)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,12 @@ class NoteEdit(Gtk.ScrolledWindow):
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def on_summary_changed(self, s):
|
def on_summary_changed(self, s):
|
||||||
pass
|
|
||||||
summary = s.get_text(s.get_start_iter(), s.get_end_iter(), False)
|
summary = s.get_text(s.get_start_iter(), s.get_end_iter(), False)
|
||||||
if self.note.summary != summary:
|
if self.note.summary != summary:
|
||||||
self.note.set_property("summary", summary)
|
self.note.set_property("summary", summary)
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def on_description_changed(self, d):
|
def on_description_changed(self, d):
|
||||||
pass
|
|
||||||
description = d.get_text(d.get_start_iter(), d.get_end_iter(), False)
|
description = d.get_text(d.get_start_iter(), d.get_end_iter(), False)
|
||||||
if self.note.description != description:
|
if self.note.description != description:
|
||||||
self.note.description = description
|
self.note.set_property("description", description)
|
||||||
|
|
20
src/sync.py
20
src/sync.py
|
@ -104,6 +104,10 @@ class Sync():
|
||||||
callback(calendar)
|
callback(calendar)
|
||||||
|
|
||||||
class CalendarSet(Gio.ListStore):
|
class CalendarSet(Gio.ListStore):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(item_type=Calendar)
|
||||||
|
|
||||||
def add_calendar(self, calendar):
|
def add_calendar(self, calendar):
|
||||||
self.append(calendar)
|
self.append(calendar)
|
||||||
|
|
||||||
|
@ -111,22 +115,32 @@ class CalendarSet(Gio.ListStore):
|
||||||
self.remove(calendar)
|
self.remove(calendar)
|
||||||
|
|
||||||
class Calendar(Gio.ListStore):
|
class Calendar(Gio.ListStore):
|
||||||
|
__gtype_name__ = "Calendar"
|
||||||
displayname = None
|
displayname = None
|
||||||
cal_id = None
|
cal_id = None
|
||||||
|
|
||||||
def __init__(self, displayname, cal_id):
|
def __init__(self, displayname, cal_id):
|
||||||
super().__init__()
|
super().__init__(item_type=Note)
|
||||||
self.displayname = displayname
|
self.displayname = displayname
|
||||||
self.cal_id = cal_id
|
self.cal_id = cal_id
|
||||||
|
|
||||||
def add_note(self, note):
|
def add_note(self, note):
|
||||||
|
# Listen for changes in note to update the list UI
|
||||||
|
note.connect("notify::summary", self.on_notify_note_changed)
|
||||||
|
note.connect("notify::description", self.on_notify_note_changed)
|
||||||
self.append(note)
|
self.append(note)
|
||||||
|
|
||||||
|
def on_notify_note_changed(self, note, gparamstring):
|
||||||
|
(found, position) = self.find(note)
|
||||||
|
if found:
|
||||||
|
self.items_changed(position, 1, 1)
|
||||||
|
|
||||||
class Note(GObject.GObject):
|
class Note(GObject.GObject):
|
||||||
|
__gtype_name__ = "Note"
|
||||||
uid = None
|
uid = None
|
||||||
calendar = None
|
calendar = None
|
||||||
summary = None
|
summary = GObject.property(type=str)
|
||||||
description = None
|
description = GObject.property(type=str)
|
||||||
|
|
||||||
def __init__(self, calendar, summary, description):
|
def __init__(self, calendar, summary, description):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="spacing">24</property>
|
<property name="spacing">24</property>
|
||||||
<property name="margin-top">-12</property>
|
<property name="margin-top">0</property>
|
||||||
<property name="margin-bottom">12</property>
|
<property name="margin-bottom">12</property>
|
||||||
<property name="margin-start">12</property>
|
<property name="margin-start">12</property>
|
||||||
<property name="margin-end">12</property>
|
<property name="margin-end">12</property>
|
||||||
|
@ -21,7 +21,11 @@
|
||||||
<property name="right-margin">12</property>
|
<property name="right-margin">12</property>
|
||||||
<property name="wrap-mode">3</property>
|
<property name="wrap-mode">3</property>
|
||||||
<property name="css-classes">card</property>
|
<property name="css-classes">card</property>
|
||||||
<signal name="preedit-changed" handler="on_summary_changed" swapped="no" />
|
<property name="buffer">
|
||||||
|
<object class="GtkTextBuffer">
|
||||||
|
<signal name="changed" handler="on_summary_changed" swapped="no" />"
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>"
|
</object>"
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -38,7 +42,11 @@
|
||||||
<property name="right-margin">12</property>
|
<property name="right-margin">12</property>
|
||||||
<property name="wrap-mode">3</property>
|
<property name="wrap-mode">3</property>
|
||||||
<property name="css-classes">card</property>
|
<property name="css-classes">card</property>
|
||||||
<signal name="preedit-changed" handler="on_description_changed" swapped="no" />
|
<property name="buffer">
|
||||||
|
<object class="GtkTextBuffer">
|
||||||
|
<signal name="changed" handler="on_description_changed" swapped="no" />"
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -35,16 +35,16 @@
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwNavigationPage">
|
<object class="AdwNavigationPage" id="notes_list_page">
|
||||||
<property name="title" translatable="yes">Note</property>
|
<property name="title" translatable="no">Notes</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="AdwOverlaySplitView" id="split_view2">
|
<object class="AdwOverlaySplitView">
|
||||||
<property name="sidebar-position">1</property>
|
<property name="sidebar-position">1</property>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar" id="header_bar3">
|
<object class="AdwHeaderBar">
|
||||||
<property name="show-title">False</property>
|
<property name="show-title">True</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<property name="sidebar">
|
<property name="sidebar">
|
||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar" id="header_bar2">
|
<object class="AdwHeaderBar">
|
||||||
<property name="show-title">False</property>
|
<property name="show-title">False</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
@ -26,10 +26,12 @@ class JnotesWindow(Adw.ApplicationWindow):
|
||||||
__gtype_name__ = 'JnotesWindow'
|
__gtype_name__ = 'JnotesWindow'
|
||||||
|
|
||||||
sidebar = Gtk.Template.Child()
|
sidebar = Gtk.Template.Child()
|
||||||
|
notes_list_page = Gtk.Template.Child()
|
||||||
notes_list = Gtk.Template.Child()
|
notes_list = Gtk.Template.Child()
|
||||||
note_edit = Gtk.Template.Child()
|
note_edit = Gtk.Template.Child()
|
||||||
spinner = Gtk.Template.Child()
|
spinner = Gtk.Template.Child()
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue