[bijiben] noteObj/view : Really ensure the note has a title
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] noteObj/view : Really ensure the note has a title
- Date: Thu, 14 Mar 2013 23:16:23 +0000 (UTC)
commit d516c0ff157108a58252115f0b081edb6844a5b3
Author: Pierre-Yves Luyten <py luyten fr>
Date: Fri Mar 15 00:14:59 2013 +0100
noteObj/view : Really ensure the note has a title
The user might keep first row empty and not below. In such case we should not use the first row as a
title.
src/bjb-note-view.c | 29 +++++++++++++++++++++++++----
src/libbiji/biji-note-obj.c | 18 ++++++++++++++----
2 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/src/bjb-note-view.c b/src/bjb-note-view.c
index ffe284a..1f73916 100644
--- a/src/bjb-note-view.c
+++ b/src/bjb-note-view.c
@@ -75,15 +75,33 @@ struct _BjbNoteViewPrivate {
};
static void
+bjb_note_view_disconnect (BjbNoteViewPrivate *priv)
+{
+ if (priv->renamed != 0)
+ g_signal_handler_disconnect (priv->note, priv->renamed);
+
+ if (priv->destroy != 0)
+ g_signal_handler_disconnect (priv->window, priv->destroy);
+
+ if (priv->deleted != 0)
+ g_signal_handler_disconnect (priv->note, priv->deleted);
+
+ if (priv->color != 0)
+ g_signal_handler_disconnect (priv->note, priv->color);
+
+ priv->renamed =0;
+ priv->destroy = 0,
+ priv->deleted = 0;
+ priv->color =0;
+}
+
+static void
bjb_note_view_finalize(GObject *object)
{
BjbNoteView *self = BJB_NOTE_VIEW (object) ;
BjbNoteViewPrivate *priv = self->priv;
- g_signal_handler_disconnect (priv->note, priv->renamed);
- g_signal_handler_disconnect (priv->window, priv->destroy);
- g_signal_handler_disconnect (priv->note, priv->deleted);
- g_signal_handler_disconnect (priv->note, priv->color);
+ bjb_note_view_disconnect (priv);
g_clear_object (&priv->view);
g_clear_object (&priv->accel);
@@ -170,6 +188,9 @@ just_switch_to_main_view(BjbNoteView *self)
{
GtkWindow *window;
+ /* Avoid stupid crash */
+ bjb_note_view_disconnect (self->priv);
+
window = GTK_WINDOW(self->priv->window);
gtk_window_remove_accel_group (window, self->priv->accel);
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index 8a9cddc..b8491e3 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -862,23 +862,33 @@ biji_note_obj_is_opened (BijiNoteObj *note)
static void
_biji_note_obj_close (BijiNoteObj *note)
{
- note->priv->editor = NULL;
+ BijiNoteObjPrivate *priv = note->priv;
+ priv->editor = NULL;
/* Delete if note is totaly blank
* Actually we just need to remove it from book
* since no change could trigger save */
- if (!note->priv->raw_text)
+ if (!priv->raw_text)
{
- biji_note_book_remove_note (note->priv->book, note);
+ biji_note_book_remove_note (priv->book, note);
}
+ /* If the note only has one row. put some title */
else if (!biji_note_obj_title_survives (note))
{
gchar *title = biji_note_book_get_unique_title (biji_note_obj_get_note_book (note),
- note->priv->raw_text);
+ priv->raw_text);
biji_note_obj_set_title (note, title);
g_free (title);
}
+
+ /* Else the note is not empty & has more than a row.
+ * But the first row might still be empty.*/
+ else if (!biji_note_id_get_title (priv->id) ||
+ g_strcmp0 (biji_note_id_get_title (priv->id),"")==0)
+ {
+ biji_note_obj_set_title (note, priv->raw_text);
+ }
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]