示例#1
0
static void
on_biji_note_obj_closed_cb (BijiNoteObj *note)
{
  BijiNoteObjPrivate *priv;
  BijiItem *item;
  const gchar *title;

  priv = note->priv;
  item = BIJI_ITEM (note);
  priv->editor = NULL;
  title = biji_item_get_title (item);

#ifdef BUILD_ZEITGEIST
  insert_zeitgeist (note, ZEITGEIST_ZG_LEAVE_EVENT);
#endif /* BUILD_ZEITGEIST */

  /*
   * Delete (not _trash_ if note is totaly blank
   * A Cancellable would be better than needs->save
   */
  if (biji_note_id_get_content (priv->id) == NULL)
  {
    priv->needs_save = FALSE;
    biji_item_delete (item);
  }

  /* If the note has no title */
  else if (title == NULL)
  {
    title = biji_note_obj_get_raw_text (note);
    biji_note_obj_set_title (note, title);
  }
}
示例#2
0
/* 
 * TODO : move this to local provider.
 */
static BijiNoteObj *
biji_note_book_local_note_new           (BijiNoteBook *book, gchar *str)
{
  BijiNoteObj *ret = get_note_skeleton (book);

  if (str)
  {
    gchar *unique, *html;

    unique = biji_note_book_get_unique_title (book, str);
    html = html_from_plain_text (str);

    biji_note_obj_set_title (ret, unique);
    biji_note_obj_set_raw_text (ret, str);
    biji_note_obj_set_html (ret, html);

    g_free (unique);
    g_free (html);
  }

  biji_note_obj_save_note (ret);
  biji_note_book_add_item (book, BIJI_ITEM (ret), TRUE);

  return ret;
}
示例#3
0
BijiNoteObj*
biji_note_book_get_new_note_from_string (BijiNoteBook *book,
                                         gchar *title)
{
  BijiNoteObj *ret = get_note_skeleton (book);

  /* Note will copy title */
  biji_note_obj_set_title (ret, title);

  biji_note_obj_save_note (ret);
  note_book_append_new_note (book,ret);

  return ret ;
}
示例#4
0
BijiNoteObj *
biji_note_book_new_note_with_text (BijiNoteBook *book,
                                   gchar *plain_text)
{
  BijiNoteObj *ret = get_note_skeleton (book);

  /* Note will copy title, raw_text and html strings */
  biji_note_obj_set_title (ret, DEFAULT_NOTE_TITLE);
  biji_note_obj_set_raw_text (ret, g_strdup (plain_text));
  biji_note_obj_set_html_content (ret, plain_text);

  biji_note_obj_save_note (ret);
  note_book_append_new_note (book,ret);

  return ret;
}
示例#5
0
/* If title not unique, add sufffix "n", starting with 2, until ok */
static void
_biji_note_book_sanitize_title (BijiNoteBook *book, BijiNoteObj *note)
{   
  gchar *title = biji_note_obj_get_title (note);
  gchar *new_title = g_strdup (title);
  gint suffix = 2;

  while (!_biji_note_book_is_title_unique (book, new_title))
  {
    g_free (new_title);
    new_title = g_strdup_printf("%s (%i)", title, suffix);
    suffix++;
  }

  if ( g_strcmp0 (new_title, title) != 0)
    biji_note_obj_set_title (note, new_title);

  g_free(new_title);
}