[gnome-notes] bjb-note-view: Display text indicating that note is detached
- From: Isaque Galdino de Araujo <igaldino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-notes] bjb-note-view: Display text indicating that note is detached
- Date: Tue, 4 May 2021 13:10:21 +0000 (UTC)
commit 68c817a831eddaf84bbe4e1f0fbe779ae331c440
Author: Jonathan Kang <jonathankang gnome org>
Date: Mon Mar 22 09:19:56 2021 +0800
bjb-note-view: Display text indicating that note is detached
src/bjb-detached-window.c | 24 +++++++++++++++++++++++-
src/bjb-detached-window.h | 4 +++-
src/bjb-note-view.c | 28 +++++++++++++++++++++++++++-
src/bjb-note-view.h | 7 +++++--
src/bjb-window-base.c | 4 +++-
5 files changed, 61 insertions(+), 6 deletions(-)
---
diff --git a/src/bjb-detached-window.c b/src/bjb-detached-window.c
index b643010..b32bc16 100644
--- a/src/bjb-detached-window.c
+++ b/src/bjb-detached-window.c
@@ -25,6 +25,7 @@
enum
{
PROP_0,
+ PROP_NOTE_VIEW,
PROP_NOTE,
PROP_WIDTH,
PROP_HEIGHT,
@@ -39,6 +40,7 @@ struct _BjbDetachedWindow
int width;
int height;
BijiNoteObj *note;
+ BjbNoteView *note_view;
BjbWindowBase *main_win;
GtkWidget *headerbar;
@@ -250,6 +252,11 @@ bjb_detached_window_finalize (GObject *object)
{
BjbDetachedWindow *self = BJB_DETACHED_WINDOW (object);
+ if (BJB_IS_NOTE_VIEW (self->note_view))
+ {
+ bjb_note_view_set_detached (self->note_view, FALSE);
+ }
+
g_object_unref (self->note);
G_OBJECT_CLASS (bjb_detached_window_parent_class)->finalize (object);
@@ -265,6 +272,9 @@ bjb_detached_window_get_property (GObject *object,
switch (property_id)
{
+ case PROP_NOTE_VIEW:
+ g_value_set_object (value, self->note_view);
+ break;
case PROP_NOTE:
g_value_set_object (value, self->note);
break;
@@ -293,6 +303,9 @@ bjb_detached_window_set_property (GObject *object,
switch (property_id)
{
+ case PROP_NOTE_VIEW:
+ self->note_view = g_value_get_object (value);
+ break;
case PROP_NOTE:
self->note = g_value_dup_object (value);
break;
@@ -322,6 +335,13 @@ bjb_detached_window_class_init (BjbDetachedWindowClass *klass)
object_class->get_property = bjb_detached_window_get_property;
object_class->set_property = bjb_detached_window_set_property;
+ properties[PROP_NOTE_VIEW] = g_param_spec_object ("note-view",
+ "NoteView",
+ "Note widget detached from",
+ BJB_TYPE_NOTE_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS);
properties[PROP_NOTE] = g_param_spec_object ("note",
"NoteObj",
"Currently opened note",
@@ -370,13 +390,15 @@ bjb_detached_window_init (BjbDetachedWindow *self)
}
BjbDetachedWindow *
-bjb_detached_window_new (BijiNoteObj *note,
+bjb_detached_window_new (BjbNoteView *note_view,
+ BijiNoteObj *note,
int width,
int height,
BjbWindowBase *main_win)
{
return g_object_new (BJB_TYPE_DETACHED_WINDOW,
"application", g_application_get_default (),
+ "note-view", note_view,
"note", note,
"width", width,
"height", height,
diff --git a/src/bjb-detached-window.h b/src/bjb-detached-window.h
index 08243b5..a8b127b 100644
--- a/src/bjb-detached-window.h
+++ b/src/bjb-detached-window.h
@@ -22,6 +22,7 @@
#include <handy.h>
#include <libbiji/libbiji.h>
+#include "bjb-note-view.h"
#include "bjb-window-base.h"
G_BEGIN_DECLS
@@ -30,7 +31,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (BjbDetachedWindow, bjb_detached_window, BJB, DETACHED_WINDOW, HdyApplicationWindow)
-BjbDetachedWindow *bjb_detached_window_new (BijiNoteObj *note,
+BjbDetachedWindow *bjb_detached_window_new (BjbNoteView *note_view,
+ BijiNoteObj *note,
int width,
int height,
BjbWindowBase *main_win);
diff --git a/src/bjb-note-view.c b/src/bjb-note-view.c
index f8b1230..f1d3328 100644
--- a/src/bjb-note-view.c
+++ b/src/bjb-note-view.c
@@ -48,6 +48,8 @@ struct _BjbNoteView
BijiWebkitEditor *editor;
GtkWidget *box;
GtkWidget *edit_bar;
+ GtkWidget *label;
+ GtkWidget *stack;
};
G_DEFINE_TYPE (BjbNoteView, bjb_note_view, GTK_TYPE_OVERLAY)
@@ -56,6 +58,20 @@ static void on_window_closed(GtkWidget *window,gpointer note);
static gboolean on_note_trashed (BijiNoteObj *note, BjbNoteView *view);
static void on_note_color_changed_cb (BijiNoteObj *note, BjbNoteView *self);
+void
+bjb_note_view_set_detached (BjbNoteView *self,
+ gboolean detached)
+{
+ if (detached)
+ {
+ gtk_stack_set_visible_child (GTK_STACK (self->stack), self->label);
+ }
+ else
+ {
+ gtk_stack_set_visible_child (GTK_STACK (self->stack), self->box);
+ }
+}
+
static void
bjb_note_view_disconnect (BjbNoteView *self)
{
@@ -193,9 +209,19 @@ bjb_note_view_constructed (GObject *obj)
g_signal_connect(self->window,"destroy",
G_CALLBACK(on_window_closed), self->note);
+ self->stack = gtk_stack_new ();
+ gtk_widget_show (self->stack);
+ gtk_container_add (GTK_CONTAINER (self), self->stack);
+
+ /* Label used to indicate that note is opened in another window. */
+ self->label = gtk_label_new (_("This note is being viewed in another window."));
+ gtk_widget_show (self->label);
+ gtk_stack_add_named (GTK_STACK (self->stack), self->label, "label");
+
self->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (self), self->box);
gtk_widget_show (self->box);
+ gtk_stack_add_named (GTK_STACK (self->stack), self->box, "note-box");
+ gtk_stack_set_visible_child (GTK_STACK (self->stack), self->box);
/* Text Editor (WebKitMainView) */
gtk_box_pack_start (GTK_BOX (self->box), GTK_WIDGET(self->view), TRUE, TRUE, 0);
diff --git a/src/bjb-note-view.h b/src/bjb-note-view.h
index 0d98da0..b75c5d0 100644
--- a/src/bjb-note-view.h
+++ b/src/bjb-note-view.h
@@ -28,8 +28,11 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (BjbNoteView, bjb_note_view, BJB, NOTE_VIEW, GtkOverlay)
-BjbNoteView *bjb_note_view_new (GtkWidget *win,
- BijiNoteObj* note);
+void bjb_note_view_set_detached (BjbNoteView *self,
+ gboolean detached);
+
+BjbNoteView *bjb_note_view_new (GtkWidget *win,
+ BijiNoteObj *note);
GtkWidget *bjb_note_view_get_base_window (BjbNoteView *v);
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index 6deef81..34ac54c 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -356,7 +356,9 @@ on_detach_window_cb (GSimpleAction *action,
else
bjb_window_base_switch_to (self, BJB_WINDOW_BASE_MAIN_VIEW);
- detached_window = bjb_detached_window_new (note, width, height, self);
+ bjb_note_view_set_detached (self->note_view, TRUE);
+
+ detached_window = bjb_detached_window_new (self->note_view, note, width, height, self);
gtk_widget_show_all (GTK_WIDGET (detached_window));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]