[gnome-notes] window-base: Only destroy note view when needed
- From: Isaque Galdino de Araujo <igaldino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-notes] window-base: Only destroy note view when needed
- Date: Tue, 4 May 2021 13:10:20 +0000 (UTC)
commit 8d20a86c38cd36398aa98ef63bfe2ec4e1256fb4
Author: Jonathan Kang <jonathankang gnome org>
Date: Thu Jan 21 17:05:26 2021 +0800
window-base: Only destroy note view when needed
src/bjb-window-base.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index de427e7..016f759 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -80,6 +80,19 @@ struct _BjbWindowBase
/* Gobject */
G_DEFINE_TYPE (BjbWindowBase, bjb_window_base, HDY_TYPE_APPLICATION_WINDOW)
+static void
+destroy_note_if_needed (BjbWindowBase *self)
+{
+ self->note = NULL;
+
+ if (self->note_view && GTK_IS_WIDGET (self->note_view))
+ gtk_widget_destroy (GTK_WIDGET (self->note_view));
+
+ gtk_widget_hide (self->title_entry);
+
+ self->note_view = NULL;
+}
+
static void
on_note_renamed (BijiItem *note,
BjbWindowBase *self)
@@ -381,7 +394,8 @@ on_trash_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- BijiNoteObj *note = bjb_window_base_get_note (BJB_WINDOW_BASE (user_data));
+ BjbWindowBase *self = BJB_WINDOW_BASE (user_data);
+ BijiNoteObj *note = bjb_window_base_get_note (self);
if (!note)
return;
@@ -389,6 +403,8 @@ on_trash_cb (GSimpleAction *action,
/* Delete the note from notebook
* The deleted note will emit a signal. */
biji_item_trash (BIJI_ITEM (note));
+
+ destroy_note_if_needed (self);
}
static void
@@ -638,26 +654,9 @@ bjb_window_base_get_note (BjbWindowBase *self)
return self->note;
}
-
-
-static void
-destroy_note_if_needed (BjbWindowBase *self)
-{
- self->note = NULL;
-
- if (self->note_view && GTK_IS_WIDGET (self->note_view))
- gtk_widget_destroy (GTK_WIDGET (self->note_view));
-
- gtk_widget_hide (self->title_entry);
-
- self->note_view = NULL;
-}
-
void
bjb_window_base_switch_to (BjbWindowBase *self, BjbWindowViewType type)
{
- destroy_note_if_needed (self);
-
switch (type)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]