static gint64 biji_note_obj_get_mtime (BijiItem *note) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), 0); return biji_note_id_get_mtime (BIJI_NOTE_OBJ (note)->priv->id); }
gboolean biji_note_obj_set_mtime (BijiNoteObj* n, gint64 mtime) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (n), FALSE); return biji_note_id_set_mtime (n->priv->id, mtime); }
void bjb_window_base_switch_to_item (BjbWindowBase *bwb, BijiItem *item) { BjbWindowBasePriv *priv = bwb->priv; GtkWidget *w = GTK_WIDGET (bwb); bjb_search_toolbar_disconnect (priv->search_bar); bjb_search_toolbar_fade_out (priv->search_bar); destroy_note_if_needed (bwb); if (BIJI_IS_NOTE_OBJ (item)) { BijiNoteObj *note = BIJI_NOTE_OBJ (item); priv->note = note; priv->note_view = bjb_note_view_new (w, note); gtk_stack_add_named (priv->stack, GTK_WIDGET (priv->note_view), "note-view"); g_object_add_weak_pointer (G_OBJECT (priv->note_view), (gpointer *) &priv->note_view); bjb_window_base_switch_to (bwb, BJB_WINDOW_BASE_NOTE_VIEW); gtk_widget_show (w); bjb_note_view_grab_focus (priv->note_view); } }
gboolean biji_note_obj_set_last_metadata_change_date (BijiNoteObj* n, gint64 time) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ(n), FALSE); return biji_note_id_set_last_metadata_change_date (n->priv->id, time); }
static void switch_to_item (BjbMainView *view, BijiItem *to_open) { if (BIJI_IS_NOTE_OBJ (to_open)) { /* If the note is already opened in another window, just show it. */ if (biji_note_obj_is_opened (BIJI_NOTE_OBJ (to_open))) { GList *notes ; notes = gtk_application_get_windows(GTK_APPLICATION(g_application_get_default())); g_list_foreach (notes, show_window_if_note, to_open); return ; } /* Otherwise, leave main view */ switch_to_note_view (view, BIJI_NOTE_OBJ (to_open)); } /* Notebook * TODO : check if already opened (same as above) */ else if (BIJI_IS_NOTEBOOK (to_open)) { bjb_controller_set_notebook (view->priv->controller, BIJI_NOTEBOOK (to_open)); } }
GList * biji_note_obj_get_notebooks (BijiNoteObj *n) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (n), NULL); return g_hash_table_get_values (n->priv->labels); }
/*static */ gboolean biji_note_obj_add_notebook (BijiItem *item, BijiItem *notebook, gchar *title) { BijiNoteObj *note; gchar *label = title; g_return_val_if_fail (BIJI_IS_NOTE_OBJ (item), FALSE); note = BIJI_NOTE_OBJ (item); if (BIJI_IS_NOTEBOOK (notebook)) label = (gchar*) biji_item_get_title (notebook); if (biji_note_obj_has_notebook (item, label)) return FALSE; g_hash_table_add (note->priv->labels, g_strdup (label)); if (BIJI_IS_NOTEBOOK (notebook)) { biji_push_existing_notebook_to_note ( note, label, _biji_notebook_refresh, notebook); // Tracker biji_note_id_set_last_metadata_change_date (note->priv->id, g_get_real_time () / G_USEC_PER_SEC); biji_note_obj_save_note (note); } return TRUE; }
gboolean biji_note_book_add_item (BijiNoteBook *book, BijiItem *item, gboolean notify) { g_return_val_if_fail (BIJI_IS_NOTE_BOOK (book), FALSE); g_return_val_if_fail (BIJI_IS_ITEM (item), FALSE); const gchar *uid; gboolean retval = TRUE; uid = biji_item_get_uuid (item); if (g_hash_table_lookup (book->priv->items, uid)) retval = FALSE; else if (BIJI_IS_NOTE_OBJ (item)) _biji_note_book_add_one_item (book, item); else if (BIJI_IS_COLLECTION (item)) { g_hash_table_insert (book->priv->items, (gpointer) biji_item_get_uuid (item), item); g_signal_connect (item, "deleted", G_CALLBACK (on_item_deleted_cb), book); } if (retval && notify) biji_note_book_notify_changed (book, BIJI_BOOK_ITEM_ADDED, item); return retval; }
gboolean biji_note_obj_set_note_create_date (BijiNoteObj* n,gchar *date) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ(n), FALSE); return biji_note_id_set_create_date (n->priv->id, date); }
gint64 biji_note_obj_get_create_date (BijiNoteObj *note) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), 0); return biji_note_id_get_create_date (note->priv->id); }
gchar * biji_note_obj_get_last_metadata_change_date (BijiNoteObj *note) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL); return biji_note_id_get_last_metadata_change_date (note->priv->id); }
gchar * biji_note_obj_get_title(BijiNoteObj *obj) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ(obj), NULL); return biji_note_id_get_title (obj->priv->id); }
static const gchar * biji_note_obj_get_title (BijiItem *note) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL); return biji_note_id_get_title (BIJI_NOTE_OBJ (note)->priv->id); }
gboolean biji_note_obj_set_create_date (BijiNoteObj *note, gint64 time) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), FALSE); return biji_note_id_set_create_date (note->priv->id, time); }
gboolean biji_note_book_remove_note(BijiNoteBook *book,BijiNoteObj *note) { g_return_val_if_fail(BIJI_IS_NOTE_BOOK(book),FALSE); g_return_val_if_fail(BIJI_IS_NOTE_OBJ(note),FALSE); return _note_book_remove_one_note(book,note); }
static const gchar * biji_note_obj_get_path (BijiItem *item) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (item), NULL); BijiNoteObj *note = BIJI_NOTE_OBJ (item); return biji_note_id_get_path (note->priv->id); }
void biji_note_obj_set_icon (BijiNoteObj *note, GdkPixbuf *pix) { g_return_if_fail (BIJI_IS_NOTE_OBJ (note)); if (!note->priv->icon) note->priv->icon = pix; else g_warning ("Cannot use _set_icon_ with iconified note. This has no sense."); }
static void bjb_selection_toolbar_set_item_visibility (BjbSelectionToolbar *self) { BjbSelectionToolbarPrivate *priv; GList *l, *selection; GdkRGBA color; g_return_if_fail (BJB_IS_SELECTION_TOOLBAR (self)); priv = self->priv; selection = bjb_main_view_get_selected_items (priv->view); /* Color */ gtk_widget_set_sensitive (priv->toolbar_color, FALSE); for (l=selection; l !=NULL; l=l->next) { if (!biji_item_has_color (l->data)) { gtk_widget_set_sensitive (priv->toolbar_color, FALSE); break; } else if (BIJI_IS_NOTE_OBJ (l->data)) { if (biji_note_obj_get_rgba (BIJI_NOTE_OBJ (l->data), &color)) { gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->toolbar_color), &color); gtk_widget_set_sensitive (priv->toolbar_color, TRUE); break; } } } /* Organize */ gtk_widget_set_sensitive (priv->toolbar_tag, TRUE); for (l=selection; l!=NULL; l=l->next) { if (!biji_item_is_collectable (l->data)) { gtk_widget_set_sensitive (priv->toolbar_tag, FALSE); break; } } g_list_free (selection); }
void biji_note_obj_set_all_dates_now (BijiNoteObj *note) { gint64 time; BijiNoteID *id; g_return_if_fail (BIJI_IS_NOTE_OBJ (note)); id = note->priv->id; time = g_get_real_time () / G_USEC_PER_SEC; biji_note_id_set_create_date (id, time); biji_note_id_set_last_metadata_change_date (id, time); biji_note_id_set_mtime (id, time); }
gboolean biji_note_obj_get_rgba(BijiNoteObj *n, GdkRGBA *rgba) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (n), FALSE); if (n->priv->color && rgba) { *rgba = *(n->priv->color); return TRUE; } return FALSE; }
gboolean biji_note_obj_add_tag (BijiNoteObj *note, gchar *tag) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), FALSE); g_return_val_if_fail (tag != NULL, FALSE); g_return_val_if_fail (! _biji_note_obj_has_tag (note, tag), FALSE); note->priv->tags = g_list_prepend (note->priv->tags, g_strdup (tag)); if (BIJI_IS_NOTE_BOOK (note->priv->book)) _biji_note_book_add_note_to_tag_book (note->priv->book, note, tag); biji_note_id_set_last_metadata_change_date_now (note->priv->id); return TRUE; }
static void _biji_note_book_add_one_note(BijiNoteBook *book,BijiNoteObj *note) { g_return_if_fail(BIJI_IS_NOTE_OBJ(note)); gint i ; _biji_note_book_sanitize_title(book,note); /* Welcome to the book ! */ _biji_note_obj_set_book(note,(gpointer)book); // Handle tags GList *note_tags = _biji_note_obj_get_tags(note) ; for ( i=0 ; i<g_list_length (note_tags) ; i++ ) { TagBook *tag_book; tag_book = biji_book_get_or_create_tag_book(book, g_list_nth_data (note_tags,i)); // Handle template if ( note_obj_is_template(note) ) { tag_book->template_note = note ; } else { tag_book->notes = g_list_append(tag_book->notes,note) ; tag_book->length ++ ; } } // Add it to the list and emit signal g_hash_table_insert (book->priv->notes, biji_note_obj_get_path (note), note); book->priv->note_renamed = g_signal_connect(note,"renamed", G_CALLBACK(notify_changed),book); g_signal_connect (note,"changed", G_CALLBACK(notify_changed),book); //TODO g_signal_connect(note,"deleted"...) ; g_signal_emit ( G_OBJECT (book), biji_book_signals[BOOK_AMENDED],0); }
gchar * biji_note_obj_get_icon_file (BijiNoteObj *note) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL); const gchar *uuid; gchar *basename, *filename; uuid = BIJI_NOTE_OBJ_GET_CLASS (note)->get_basename (note); basename = biji_str_mass_replace (uuid, ".note", ".png", ".txt", ".png", NULL); filename = g_build_filename (g_get_user_cache_dir (), g_get_application_name (), basename, NULL); g_free (basename); return filename; }
static void action_color_selected_items (GtkWidget *w, BjbSelectionToolbar *self) { GList *l, *selection; GdkRGBA color = {0,0,0,0}; gtk_widget_set_visible (GTK_WIDGET (self), TRUE); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (w), &color); selection = bjb_main_view_get_selected_items (self->priv->view); for (l=selection; l !=NULL; l=l->next) { if (BIJI_IS_NOTE_OBJ (l->data)) biji_note_obj_set_rgba (l->data, &color); } g_list_free (selection); }
gboolean biji_note_obj_remove_notebook (BijiItem *item, BijiItem *notebook) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (item), FALSE); g_return_val_if_fail (BIJI_IS_NOTEBOOK (notebook), FALSE); BijiNoteObj *note = BIJI_NOTE_OBJ (item); if (g_hash_table_remove (note->priv->labels, biji_item_get_title (notebook))) { biji_remove_notebook_from_note ( note, notebook, _biji_notebook_refresh, notebook); // tracker. biji_note_id_set_last_metadata_change_date (note->priv->id, g_get_real_time () / G_USEC_PER_SEC); biji_note_obj_save_note (note); return TRUE; } return FALSE; }
static void render_type (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { BijiItem *item; const gchar *str; BjbMainView *self; self = data; str = NULL; item = _get_item_for_tree_path (tree_model, iter, self); if (item != NULL) { if BIJI_IS_NOTEBOOK (item) str= _("Notebook"); else if BIJI_IS_NOTE_OBJ (item) str = _("Note"); }
static void _biji_note_book_add_one_item (BijiNoteBook *book, BijiItem *item) { g_return_if_fail (BIJI_IS_ITEM (item)); /* Add it to the list */ g_hash_table_insert (book->priv->items, (gpointer) biji_item_get_uuid (item), item); /* Notify */ if (BIJI_IS_NOTE_OBJ (item)) { g_signal_connect (item, "changed", G_CALLBACK (book_on_note_changed_cb), book); g_signal_connect (item, "renamed", G_CALLBACK (book_on_note_changed_cb), book); g_signal_connect (item, "color-changed", G_CALLBACK (book_on_item_icon_changed_cb), book); } else if (BIJI_IS_COLLECTION (item)) { g_signal_connect (item, "deleted", G_CALLBACK (on_item_deleted_cb), book); g_signal_connect (item , "icon-changed", G_CALLBACK (book_on_item_icon_changed_cb), book); } }
gboolean note_obj_is_template (BijiNoteObj *n) { g_return_val_if_fail(BIJI_IS_NOTE_OBJ(n),FALSE); return n->priv->is_template; }
/* Notes collection */ void note_book_append_new_note(BijiNoteBook *book,BijiNoteObj *note) { if (BIJI_IS_NOTE_BOOK(book) && BIJI_IS_NOTE_OBJ(note)) _biji_note_book_add_one_note (book,note); }