Add note edit window
This commit is contained in:
parent
555c44c5c0
commit
d451318029
8 changed files with 82 additions and 6 deletions
|
@ -6,5 +6,6 @@
|
||||||
<file preprocess="xml-stripblanks">ui/help-overlay.ui</file>
|
<file preprocess="xml-stripblanks">ui/help-overlay.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/sidebar.ui</file>
|
<file preprocess="xml-stripblanks">ui/sidebar.ui</file>
|
||||||
<file preprocess="xml-stripblanks">ui/notes_list.ui</file>
|
<file preprocess="xml-stripblanks">ui/notes_list.ui</file>
|
||||||
|
<file preprocess="xml-stripblanks">ui/note_edit.ui</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|
11
src/main.py
11
src/main.py
|
@ -29,6 +29,7 @@ from .preferences import PreferencesWindow
|
||||||
from .sidebar import Sidebar
|
from .sidebar import Sidebar
|
||||||
from .sync import Sync
|
from .sync import Sync
|
||||||
from .notes_list import NotesList
|
from .notes_list import NotesList
|
||||||
|
from .note_edit import NoteEditWindow
|
||||||
|
|
||||||
|
|
||||||
class JnotesApplication(Adw.Application):
|
class JnotesApplication(Adw.Application):
|
||||||
|
@ -36,7 +37,6 @@ 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)
|
||||||
|
@ -54,6 +54,7 @@ class JnotesApplication(Adw.Application):
|
||||||
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.sidebar.calendar_set.connect('row-selected', self.on_calendar_selected)
|
||||||
|
win.notes_list.notes_list.connect('row-selected', self.on_note_selected)
|
||||||
win.present()
|
win.present()
|
||||||
|
|
||||||
def callback(calendar_set):
|
def callback(calendar_set):
|
||||||
|
@ -104,6 +105,14 @@ class JnotesApplication(Adw.Application):
|
||||||
lambda calendar: notes_list.set_calendar(calendar)
|
lambda calendar: notes_list.set_calendar(calendar)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def on_note_selected(self, container, row):
|
||||||
|
calendar = self.props.active_window.notes_list.calendar
|
||||||
|
note = calendar[row.get_index()]
|
||||||
|
edit_dialog = NoteEditWindow(transient_for=self.props.active_window)
|
||||||
|
edit_dialog.set_note(note)
|
||||||
|
edit_dialog.present()
|
||||||
|
|
||||||
|
|
||||||
def main(version):
|
def main(version):
|
||||||
"""The application's entry point."""
|
"""The application's entry point."""
|
||||||
app = JnotesApplication()
|
app = JnotesApplication()
|
||||||
|
|
|
@ -35,6 +35,7 @@ jnotes_sources = [
|
||||||
'sync.py',
|
'sync.py',
|
||||||
'sidebar.py',
|
'sidebar.py',
|
||||||
'notes_list.py',
|
'notes_list.py',
|
||||||
|
'note_edit.py',
|
||||||
]
|
]
|
||||||
|
|
||||||
install_data(jnotes_sources, install_dir: moduledir)
|
install_data(jnotes_sources, install_dir: moduledir)
|
||||||
|
|
40
src/note_edit.py
Normal file
40
src/note_edit.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# note_edit.py
|
||||||
|
#
|
||||||
|
# Copyright 2024 Jeena
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from gi.repository import Adw
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path='/net/jeena/jnotes/ui/note_edit.ui')
|
||||||
|
class NoteEditWindow(Adw.Window):
|
||||||
|
__gtype_name__ = 'NoteEditWindow'
|
||||||
|
|
||||||
|
summary = Gtk.Template.Child()
|
||||||
|
description = Gtk.Template.Child()
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
def set_note(self, note):
|
||||||
|
self.note = note
|
||||||
|
self.summary.set_text(self.note.summary)
|
||||||
|
buffer = self.description.get_buffer()
|
||||||
|
buffer.set_text(self.note.description)
|
||||||
|
|
||||||
|
def on_save_button_pressed(self, widget):
|
||||||
|
print("save button pressed")
|
|
@ -8,14 +8,15 @@ class NotesList(Gtk.ScrolledWindow):
|
||||||
__gtype_name__ = 'NotesList'
|
__gtype_name__ = 'NotesList'
|
||||||
|
|
||||||
notes_list = Gtk.Template.Child()
|
notes_list = Gtk.Template.Child()
|
||||||
|
calendar = None
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def set_calendar(self, calendar):
|
def set_calendar(self, calendar):
|
||||||
self.notes_list.bind_model(calendar, self.create_item_widget)
|
self.calendar = calendar
|
||||||
|
self.notes_list.bind_model(self.calendar, self.create_item_widget)
|
||||||
|
|
||||||
def create_item_widget(self, note):
|
def create_item_widget(self, note):
|
||||||
return Adw.ActionRow(title=note.summary,
|
return Adw.ActionRow(title=note.summary, subtitle=note.description)
|
||||||
subtitle=note.description)
|
|
||||||
|
|
||||||
|
|
25
src/ui/note_edit.ui
Normal file
25
src/ui/note_edit.ui
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="NoteEditWindow" parent="AdwWindow">
|
||||||
|
<property name="title" translatable="yes">Notes</property>
|
||||||
|
<property name="width-request">400</property>
|
||||||
|
<property name="height-request">400</property>
|
||||||
|
<property name="content">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHeaderBar"/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="summary"></object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTextView" id="description">
|
||||||
|
<property name="width-request">100%</property>
|
||||||
|
<property name="height-request">100%</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>
|
|
@ -15,7 +15,6 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox" id="notes_list">
|
<object class="GtkListBox" id="notes_list">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="selection-mode">none</property>
|
|
||||||
<style>
|
<style>
|
||||||
<class name="boxed-list" />
|
<class name="boxed-list" />
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
<template class="JnotesWindow" parent="AdwApplicationWindow">
|
<template class="JnotesWindow" parent="AdwApplicationWindow">
|
||||||
<property name="title" translatable="yes">To-Do</property>
|
<property name="title" translatable="yes">Notes</property>
|
||||||
<property name="width-request">800</property>
|
<property name="width-request">800</property>
|
||||||
<property name="height-request">800</property>
|
<property name="height-request">800</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue