[gnome-notes] load last opened note on application startup
- From: Isaque Galdino de Araujo <igaldino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-notes] load last opened note on application startup
- Date: Tue, 4 May 2021 13:10:21 +0000 (UTC)
commit 1afdc346598654a7ba895bbc631b3985dbccffc7
Author: Jonathan Kang <jonathankang gnome org>
Date: Fri Mar 19 10:52:37 2021 +0800
load last opened note on application startup
data/org.gnome.Notes.gschema.xml | 5 +++++
src/bjb-application.c | 8 +++++++-
src/bjb-window-base.c | 6 +++++-
3 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.Notes.gschema.xml b/data/org.gnome.Notes.gschema.xml
index 22d49e7..3d49182 100644
--- a/data/org.gnome.Notes.gschema.xml
+++ b/data/org.gnome.Notes.gschema.xml
@@ -24,6 +24,11 @@
<summary>Primary notes provider to use for new notes.</summary>
<description>The primary notebook is the place where new notes are created.</description>
</key>
+ <key type="s" name="last-opened-item">
+ <default>''</default>
+ <summary>Note path of the notes opened when Notes quits last time.</summary>
+ <description>This stores the note path of the last opened item, so that we can open it on
startup.</description>
+ </key>
<key name="window-maximized" type="b">
<default>false</default>
<summary>Window maximized</summary>
diff --git a/src/bjb-application.c b/src/bjb-application.c
index ed413ff..521fd4c 100644
--- a/src/bjb-application.c
+++ b/src/bjb-application.c
@@ -169,7 +169,7 @@ bijiben_open_path (BjbApplication *self,
item = biji_manager_get_item_at_path (self->manager, path);
- if (BIJI_IS_NOTE_OBJ (item) || !window)
+ if (!window)
bijiben_new_window_internal (self, BIJI_NOTE_OBJ (item));
else
bjb_window_base_load_note_item (window, item);
@@ -388,6 +388,7 @@ static void
bijiben_startup (GApplication *application)
{
BjbApplication *self;
+ char *path;
g_autofree gchar *storage_path = NULL;
g_autofree gchar *default_color = NULL;
g_autoptr(GFile) storage = NULL;
@@ -456,6 +457,11 @@ bijiben_startup (GApplication *application)
self->manager = biji_manager_new (storage, &color);
biji_manager_load_providers_async (self->manager, manager_ready_cb, self);
+
+ /* Load last opened note item. */
+ path = g_settings_get_string (G_SETTINGS (self->settings), "last-opened-item");
+ if (!bijiben_open_path (self, path, NULL))
+ g_queue_push_head (&self->files_to_open, path);
}
static void
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index b217d98..6deef81 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -199,6 +199,10 @@ static void
bjb_window_base_finalize (GObject *object)
{
BjbWindowBase *self = BJB_WINDOW_BASE (object);
+ GSettings *settings = G_SETTINGS (self->settings);
+
+ if (self->note != NULL)
+ g_settings_set_string (settings, "last-opened-item", biji_note_obj_get_path (self->note));
if (self->display_notebooks_changed != 0)
g_signal_handler_disconnect (self->controller, self->display_notebooks_changed);
@@ -991,7 +995,7 @@ bjb_window_base_set_active (BjbWindowBase *self, gboolean active)
{
gboolean available;
- available = (self->current_view != BJB_WINDOW_BASE_NOTE_VIEW);
+ available = (self->current_view == BJB_WINDOW_BASE_MAIN_VIEW);
if (active == TRUE)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]