Replace Notes window with sidebar

This commit is contained in:
Jeena 2024-03-01 16:57:22 +09:00
parent 595c456518
commit c0d9da7947
5 changed files with 53 additions and 23 deletions

View file

@ -29,7 +29,7 @@ from .preferences import PreferencesWindow
from .sidebar import Sidebar
from .sync import Sync
from .notes_list import NotesList
from .note_edit import NoteEditWindow
from .note_edit import NoteEdit
class JnotesApplication(Adw.Application):
@ -108,10 +108,7 @@ class JnotesApplication(Adw.Application):
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()
self.props.active_window.note_edit.set_note(note)
def main(version):
"""The application's entry point."""

View file

@ -21,8 +21,8 @@ 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'
class NoteEdit(Gtk.ScrolledWindow):
__gtype_name__ = 'NoteEdit'
summary = Gtk.Template.Child()
description = Gtk.Template.Child()
@ -32,9 +32,8 @@ class NoteEditWindow(Adw.Window):
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)
self.summary.get_buffer().set_text(self.note.summary)
self.description.get_buffer().set_text(self.note.description)
def on_save_button_pressed(self, widget):
print("save button pressed")

View file

@ -1,22 +1,44 @@
<?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">
<template class="NoteEdit" parent="GtkScrolledWindow">
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="GtkHeaderBar"/>
<object class="AdwPreferencesGroup">
<property name="title">Summary</property>
<child>
<object class="GtkTextView" id="summary">
<property name="height-request">42</property>
<property name="top-margin">12</property>
<property name="bottom-margin">12</property>
<property name="left-margin">12</property>
<property name="right-margin">12</property>
<property name="wrap-mode">3</property>
<property name="css-classes">card</property>
</object>"
</child>
</object>
</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 class="AdwPreferencesGroup">
<property name="title">Description</property>
<child>
<object class="GtkTextView" id="description">
<property name="height-request">200</property>
<property name="top-margin">12</property>
<property name="bottom-margin">12</property>
<property name="left-margin">12</property>
<property name="right-margin">12</property>
<property name="wrap-mode">3</property>
<property name="css-classes">card</property>
</object>
</child>
</object>
</child>
</object>

View file

@ -56,7 +56,18 @@
</object>
</child>
<property name="content">
<object class="NotesList" id="notes_list"></object>
<object class="AdwOverlaySplitView" id="content_split_view">
<property name="min-sidebar-width">200</property>
<property name="max-sidebar-width">400</property>
<property name="sidebar-width-fraction">0.40</property>
<property name="sidebar-position">1</property>
<property name="content">
<object class="NotesList" id="notes_list"></object>
</property>
<property name="sidebar">
<object class="NoteEdit" id="note_edit"></object>
</property>
</object>
</property>
</object>
</property>

View file

@ -27,6 +27,7 @@ class JnotesWindow(Adw.ApplicationWindow):
sidebar = Gtk.Template.Child()
notes_list = Gtk.Template.Child()
note_edit = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)