[bijiben] noteBook : note_new : cleanup code
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] noteBook : note_new : cleanup code
- Date: Wed, 1 May 2013 07:49:07 +0000 (UTC)
commit 382c5549352f8959efa6c6e976be130bac3f985d
Author: Pierre-Yves Luyten <py luyten fr>
Date: Wed May 1 09:47:56 2013 +0200
noteBook : note_new : cleanup code
One func is enough and no need for DEFAULT_TITLE on libbiji side
Also fix 699247
src/bjb-editor-toolbar.c | 2 +-
src/bjb-main-toolbar.c | 2 +-
src/bjb-main-view.c | 2 +-
src/libbiji/biji-note-book.c | 47 ++++++++++++-----------------------------
src/libbiji/biji-note-book.h | 7 +-----
5 files changed, 18 insertions(+), 42 deletions(-)
---
diff --git a/src/bjb-editor-toolbar.c b/src/bjb-editor-toolbar.c
index 35fd4a2..fd5a0f9 100644
--- a/src/bjb-editor-toolbar.c
+++ b/src/bjb-editor-toolbar.c
@@ -422,7 +422,7 @@ link_callback (GtkWidget *button, BjbEditorToolbar *self)
window = bjb_note_view_get_base_window (priv->view);
book = bjb_window_base_get_book(window);
- result = biji_note_book_get_new_note_from_string (book, link);
+ result = biji_note_book_note_new (book, link);
/* Change result color. */
if (biji_note_obj_get_rgba (priv->note, &color))
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index fa9241d..3e22541 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -93,7 +93,7 @@ on_new_note_clicked (GtkWidget *but, BjbMainView *view)
/* append note to collection */
book = bjb_window_base_get_book (bjb_main_view_get_window (view));
- result = biji_note_book_get_new_note_from_string (book, "");
+ result = biji_note_book_note_new (book, NULL);
/* Go to that note */
switch_to_note_view(view,result);
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index fc2b37d..2929715 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -452,7 +452,7 @@ on_drag_data_received (GtkWidget *widget,
/* FIXME Text is guchar utf 8, conversion to perform */
book = bjb_window_base_get_book (self->priv->window);
- ret = biji_note_book_new_note_with_text (book, (gchar*) text);
+ ret = biji_note_book_note_new (book, (gchar*) text);
switch_to_note_view (self, ret); // maybe AFTER drag finish?
g_free (text);
diff --git a/src/libbiji/biji-note-book.c b/src/libbiji/biji-note-book.c
index edf7319..0f85c30 100644
--- a/src/libbiji/biji-note-book.c
+++ b/src/libbiji/biji-note-book.c
@@ -502,50 +502,31 @@ get_note_skeleton (BijiNoteBook *book)
return ret;
}
-/* TODO : different New notes shall call a common
- * biji_note_obj_new with different properties : path mandatory,
- * optional title, raw_text, html, ... */
-
-BijiNoteObj*
-biji_note_book_get_new_note_from_string (BijiNoteBook *book,
- gchar *title)
-{
- BijiNoteObj *ret = get_note_skeleton (book);
-
- /* Note will copy title
- * We do NOT sanitize here because blank title is allowed ("initial") */
- if (title && g_strcmp0 (title, "") !=0)
- biji_note_obj_set_title (ret, title);
-
- biji_note_obj_save_note (ret);
- biji_note_book_append_new_note (book, ret, TRUE);
-
- return ret;
-}
-
static char*
wrap_note_content (char *content)
{
return g_strdup_printf("<html xmlns=\"http://www.w3.org/1999/xhtml\"><body>%s</body></html>", content);
}
-
BijiNoteObj *
-biji_note_book_new_note_with_text (BijiNoteBook *book,
- gchar *plain_text)
+biji_note_book_note_new (BijiNoteBook *book, gchar *str)
{
BijiNoteObj *ret = get_note_skeleton (book);
- gchar *unique_title = biji_note_book_get_unique_title (book, DEFAULT_NOTE_TITLE);
- gchar *html;
- /* Note will copy title, raw_text and html strings */
- biji_note_obj_set_title (ret, unique_title);
- g_free (unique_title);
+ if (str)
+ {
+ gchar *unique, *html;
+
+ unique = biji_note_book_get_unique_title (book, str);
+ html = wrap_note_content (str);
- biji_note_obj_set_raw_text (ret, plain_text);
- html = wrap_note_content (plain_text);
- biji_note_obj_set_html_content (ret, html);
- g_free (html);
+ biji_note_obj_set_title (ret, unique);
+ biji_note_obj_set_raw_text (ret, str);
+ biji_note_obj_set_html_content (ret, html);
+
+ g_free (unique);
+ g_free (html);
+ }
biji_note_obj_save_note (ret);
biji_note_book_append_new_note (book, ret, TRUE);
diff --git a/src/libbiji/biji-note-book.h b/src/libbiji/biji-note-book.h
index 083942a..498370b 100644
--- a/src/libbiji/biji-note-book.h
+++ b/src/libbiji/biji-note-book.h
@@ -7,8 +7,6 @@
G_BEGIN_DECLS
-#define DEFAULT_NOTE_TITLE "New Note"
-
/* The flag tells if view should reload the whole model or not */
typedef enum
{
@@ -63,12 +61,9 @@ BijiItem * biji_note_book_get_item_at_path (BijiNoteBook *book, gchar *path);
* Free the GList, not its content */
GList * biji_note_book_get_items (BijiNoteBook *book);
-/* New Notes */
BijiNoteObj* biji_note_get_new_from_file (const gchar* tomboy_format_note_path);
-BijiNoteObj * biji_note_book_get_new_note_from_string (BijiNoteBook *book, gchar *title);
-
-BijiNoteObj * biji_note_book_new_note_with_text (BijiNoteBook *book, gchar *plain_text);
+BijiNoteObj * biji_note_book_note_new (BijiNoteBook *book, gchar *str);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]