static void on_save_timeout (BijiNoteObj *self) { BijiNoteObjPrivate *priv = self->priv; /* g_mutex_lock (priv->mutex); */ if (!priv->needs_save) return; g_object_ref (self); /* Each note type serializes its own way * FIXME: common tracker would make sense */ BIJI_NOTE_OBJ_GET_CLASS (self)->save_note (self); #ifdef BUILD_ZEITGEIST insert_zeitgeist (self, ZEITGEIST_ZG_MODIFY_EVENT); #endif /* BUILD_ZEITGEIST */ priv->needs_save = FALSE; g_object_unref (self); }
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); } }
GtkWidget * biji_note_obj_open (BijiNoteObj *note) { note->priv->editor = biji_webkit_editor_new (note); g_signal_connect_swapped (note->priv->editor, "destroy", G_CALLBACK (on_biji_note_obj_closed_cb), note); #ifdef BUILD_ZEITGEIST insert_zeitgeist (note, ZEITGEIST_ZG_ACCESS_EVENT); #endif /* BUILD_ZEITGEIST */ return GTK_WIDGET (note->priv->editor); }
/* First cancel timeout * this func is most probably stupid it might exists (move file) */ gboolean biji_note_obj_trash (BijiItem *item) { BijiNoteObj *note_to_kill; BijiNoteObjPrivate *priv; GFile *icon; gchar *icon_path; gboolean result; note_to_kill = BIJI_NOTE_OBJ (item); priv = note_to_kill->priv; icon = NULL; icon_path = NULL; result = FALSE; /* The event has to be logged before the note is actually deleted */ #ifdef BUILD_ZEITGEIST insert_zeitgeist (note_to_kill, ZEITGEIST_ZG_DELETE_EVENT); #endif /* BUILD_ZEITGEIST */ priv->needs_save = FALSE; biji_timeout_cancel (priv->timeout); result = BIJI_NOTE_OBJ_GET_CLASS (note_to_kill)->archive (note_to_kill); if (result == TRUE) { /* Delete icon file */ icon_path = biji_note_obj_get_icon_file (note_to_kill); icon = g_file_new_for_path (icon_path); g_file_delete (icon, NULL, NULL); } g_free (icon_path); if (icon != NULL) g_object_unref (icon); return result; }
static void on_find_create_event (GObject *log, GAsyncResult *res, gpointer user_data) { GError *error; ZeitgeistResultSet *events; error = NULL; events = zeitgeist_log_find_events_finish (ZEITGEIST_LOG (log), res, &error); if (error) { g_warning ("Error reading results: %s", error->message); g_error_free (error); return; } if (zeitgeist_result_set_size (events) == 0) insert_zeitgeist (BIJI_NOTE_OBJ (user_data), ZEITGEIST_ZG_CREATE_EVENT); g_object_unref (events); }