[bijiben] No more biji_manager_remove
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] No more biji_manager_remove
- Date: Fri, 11 Apr 2014 19:25:20 +0000 (UTC)
commit 7c8e79c706c867edbe412bc5aff2eb0ae71f6f06
Author: Pierre-Yves Luyten <py luyten fr>
Date: Thu Apr 10 01:56:09 2014 +0200
No more biji_manager_remove
Use biji_item_trash directly, no manager is needed.
Manager will see the item signal.
src/bjb-main-toolbar.c | 4 +-
src/bjb-selection-toolbar.c | 7 +---
src/libbiji/biji-local-note.c | 20 ++++-----
src/libbiji/biji-manager.c | 82 ++++++++++++++++++++---------------------
src/libbiji/biji-manager.h | 41 +++++++++-----------
src/libbiji/biji-note-obj.c | 51 ++++++++++++++-----------
src/tags | 29 ++++++++++++++
7 files changed, 127 insertions(+), 107 deletions(-)
---
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index e41293e..6a0b239 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -727,9 +727,7 @@ trash_item_callback (GtkWidget *item, gpointer user_data)
/* Delete the note from notebook
* The deleted note will emit a signal. */
- biji_manager_remove_item (
- bjb_window_base_get_manager (GTK_WIDGET (self->priv->window)),
- BIJI_ITEM (self->priv->note));
+ biji_item_trash (BIJI_ITEM (self->priv->note));
}
diff --git a/src/bjb-selection-toolbar.c b/src/bjb-selection-toolbar.c
index 7d49732..568493f 100644
--- a/src/bjb-selection-toolbar.c
+++ b/src/bjb-selection-toolbar.c
@@ -118,15 +118,10 @@ static void
action_trash_selected_items (GtkWidget *w, BjbSelectionToolbar *self)
{
GList *l, *selection;
- BijiManager *manager;
selection = bjb_main_view_get_selected_items (self->priv->view);
- manager = bjb_window_base_get_manager (bjb_main_view_get_window (self->priv->view));
-
for (l=selection; l !=NULL; l=l->next)
- {
- biji_manager_remove_item (manager, BIJI_ITEM (l->data));
- }
+ biji_item_trash (BIJI_ITEM (l->data));
bjb_main_view_set_selection_mode (self->priv->view, FALSE);
g_list_free (selection);
diff --git a/src/libbiji/biji-local-note.c b/src/libbiji/biji-local-note.c
index 8c0415d..3a9a9b6 100644
--- a/src/libbiji/biji-local-note.c
+++ b/src/libbiji/biji-local-note.c
@@ -280,6 +280,8 @@ delete_file (GObject *note,
}
+/* Do not check if note is already trashed
+ * eg, note is empty */
static gboolean
local_note_delete (BijiItem *item)
{
@@ -290,18 +292,14 @@ local_note_delete (BijiItem *item)
g_debug ("local note delete : %s", g_file_get_path (self->priv->location));
- if (self->priv->trashed == TRUE)
- {
- biji_note_delete_from_tracker (BIJI_NOTE_OBJ (self));
- g_file_delete_async (self->priv->location,
- G_PRIORITY_LOW,
- NULL, /* Cancellable */
- delete_file,
- self);
- return TRUE;
- }
+ biji_note_delete_from_tracker (BIJI_NOTE_OBJ (self));
+ g_file_delete_async (self->priv->location,
+ G_PRIORITY_LOW,
+ NULL, /* Cancellable */
+ delete_file,
+ self);
- return FALSE;
+ return TRUE;
}
diff --git a/src/libbiji/biji-manager.c b/src/libbiji/biji-manager.c
index 0149f78..5bc6c19 100644
--- a/src/libbiji/biji-manager.c
+++ b/src/libbiji/biji-manager.c
@@ -289,29 +289,55 @@ biji_manager_notify_changed (BijiManager *manager,
static void
-on_item_deleted_cb (BijiItem *item, BijiManager *manager)
+on_item_deleted_cb (BijiItem *item, BijiManager *self)
{
BijiItem *to_delete;
const gchar *path;
- gboolean retval;
+ GHashTable *store;
+ BijiItemsGroup group;
to_delete = NULL;
- retval = FALSE;
path = biji_item_get_uuid (item);
- to_delete = g_hash_table_lookup (manager->priv->archives, path);
+ store = NULL;
- if (to_delete != NULL)
- retval = TRUE;
+ if ((to_delete = g_hash_table_lookup (self->priv->archives, path)))
+ {
+ store = self->priv->archives;
+ group = BIJI_ARCHIVED_ITEMS;
+ }
+ else if ((to_delete = g_hash_table_lookup (self->priv->items, path)))
+ {
+ store = self->priv->items;
+ group = BIJI_LIVING_ITEMS;
+ }
- if (!retval)
+ if (store == NULL)
return;
- g_hash_table_remove (manager->priv->archives, path);
- biji_manager_notify_changed (manager,
- BIJI_ARCHIVED_ITEMS,
- BIJI_MANAGER_ITEM_DELETED,
- item);
+
+ g_hash_table_remove (store, path);
+ biji_manager_notify_changed (self, group,
+ BIJI_MANAGER_ITEM_DELETED, item);
+}
+
+
+/* Signal if item is known */
+static void
+on_item_trashed_cb (BijiItem *item, BijiManager *self)
+{
+ const gchar *path;
+
+ path = biji_item_get_uuid (item);
+ item = g_hash_table_lookup (self->priv->items, path);
+
+ if (item == NULL)
+ return;
+
+ biji_manager_notify_changed (self, BIJI_LIVING_ITEMS, BIJI_MANAGER_ITEM_TRASHED, item);
+ g_hash_table_insert (self->priv->archives,
+ (gpointer) biji_item_get_uuid (item), item);
+ g_hash_table_remove (self->priv->items, path);
}
@@ -408,6 +434,8 @@ biji_manager_add_item (BijiManager *manager,
/* Connect */
g_signal_connect (item, "deleted",
G_CALLBACK (on_item_deleted_cb), manager);
+ g_signal_connect (item, "trashed",
+ G_CALLBACK (on_item_trashed_cb), manager);
g_signal_connect (item, "restored",
G_CALLBACK (on_item_restored_cb), manager);
@@ -621,36 +649,6 @@ biji_manager_get_default_color (BijiManager *manager, GdkRGBA *color)
}
-gboolean
-biji_manager_remove_item (BijiManager *manager, BijiItem *item)
-{
- g_return_val_if_fail (BIJI_IS_MANAGER (manager), FALSE);
- g_return_val_if_fail (BIJI_IS_ITEM (item), FALSE);
-
- BijiItem *to_delete = NULL;
- const gchar *path;
- gboolean retval = FALSE;
-
- path = biji_item_get_uuid (item);
- to_delete = g_hash_table_lookup (manager->priv->items, path);
-
- if (to_delete)
- {
- /* Signal before doing anything here. So the note is still
- * fully available for signal receiver. */
- biji_manager_notify_changed (manager, BIJI_LIVING_ITEMS, BIJI_MANAGER_ITEM_TRASHED, to_delete);
- biji_item_trash (item);
- g_hash_table_insert (manager->priv->archives,
- (gpointer) biji_item_get_uuid (item), item);
- g_hash_table_remove (manager->priv->items, path);
-
- retval = TRUE;
- }
-
- return retval;
-}
-
-
GList *
biji_manager_get_items (BijiManager *manager,
diff --git a/src/libbiji/biji-manager.h b/src/libbiji/biji-manager.h
index 4775761..834b929 100644
--- a/src/libbiji/biji-manager.h
+++ b/src/libbiji/biji-manager.h
@@ -66,21 +66,21 @@ GType biji_manager_get_type (void) G_GNUC_CONST;
-BijiManager *biji_manager_new (GFile *location,
- GdkRGBA *color,
- GError **error);
+BijiManager *biji_manager_new (GFile *location,
+ GdkRGBA *color,
+ GError **error);
void biji_manager_import_uri (BijiManager *manager,
- gchar *target_provider_id,
- gchar *uri);
+ gchar *target_provider_id,
+ gchar *uri);
void biji_manager_add_goa_object (BijiManager *manager,
- GoaObject *object);
+ GoaObject *object);
-/* <ProviderInfo*> */
-GList *biji_manager_get_providers (BijiManager *manager);
+
+GList *biji_manager_get_providers (BijiManager *manager); /* <ProviderInfo*> */
#if BUILD_ZEITGEIST
@@ -91,12 +91,13 @@ TrackerSparqlConnection
*biji_manager_get_tracker_connection (BijiManager *manager);
+
void biji_manager_get_default_color (BijiManager *manager,
- GdkRGBA *color);
+ GdkRGBA *color);
gchar *biji_manager_get_unique_title (BijiManager *manager,
- const gchar *title);
+ const gchar *title);
gboolean biji_manager_add_item (BijiManager *manager,
@@ -111,12 +112,8 @@ void biji_manager_notify_changed (BijiManager *mana
BijiItem *item);
-gboolean biji_manager_remove_item (BijiManager *manager,
- BijiItem *item);
-
-
BijiItem *biji_manager_get_item_at_path (BijiManager *manager,
- const gchar *path);
+ const gchar *path);
/* Get all items, either notes or notebooks
@@ -142,16 +139,16 @@ BijiNoteObj *biji_note_get_new_from_file (BijiManager *manager,
BijiNoteObj *biji_manager_note_new (BijiManager *manager,
- gchar *str,
- gchar *provider_id);
+ gchar *str,
+ gchar *provider_id);
BijiNoteObj *biji_manager_note_new_full (BijiManager *manager,
- gchar *provider_id,
- gchar *suggested_path,
- BijiInfoSet *info,
- gchar *html,
- GdkRGBA *color);
+ gchar *provider_id,
+ gchar *suggested_path,
+ BijiInfoSet *info,
+ gchar *html,
+ GdkRGBA *color);
G_END_DECLS
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index d51f45a..5aa6f42 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -241,10 +241,13 @@ biji_note_obj_trash (BijiItem *item)
BijiNoteObjPrivate *priv;
GFile *icon;
gchar *icon_path;
- gboolean result = FALSE;
+ 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
@@ -253,17 +256,18 @@ biji_note_obj_trash (BijiItem *item)
priv->needs_save = FALSE;
biji_timeout_cancel (priv->timeout);
-
result = BIJI_NOTE_OBJ_GET_CLASS (note_to_kill)->archive (note_to_kill);
- /* 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);
+ 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);
+ }
- if (icon_path != NULL)
- g_free (icon_path);
+ g_free (icon_path);
if (icon != NULL)
g_object_unref (icon);
@@ -848,36 +852,37 @@ biji_note_obj_is_opened (BijiNoteObj *note)
}
static void
-_biji_note_obj_close (BijiNoteObj *note)
+on_biji_note_obj_closed_cb (BijiNoteObj *note)
{
BijiNoteObjPrivate *priv;
BijiItem *item;
- BijiManager *manager;
const gchar *title;
priv = note->priv;
item = BIJI_ITEM (note);
- manager = biji_item_get_manager (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 if note is totaly blank
- * Actually we just need to remove it from manager
- * since no change could trigger save */
+ /*
+ * 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)
- biji_manager_remove_item (manager, item);
+ {
+ priv->needs_save = FALSE;
+ biji_item_delete (item);
+ }
/* If the note has no title */
- title = biji_item_get_title (item);
- if (title == NULL)
- {
- title = biji_note_obj_get_raw_text (note);
- biji_note_obj_set_title (note, title);
- }
-
+ else if (title == NULL)
+ {
+ title = biji_note_obj_get_raw_text (note);
+ biji_note_obj_set_title (note, title);
+ }
}
GtkWidget *
@@ -886,7 +891,7 @@ biji_note_obj_open (BijiNoteObj *note)
note->priv->editor = biji_webkit_editor_new (note);
g_signal_connect_swapped (note->priv->editor, "destroy",
- G_CALLBACK (_biji_note_obj_close), note);
+ G_CALLBACK (on_biji_note_obj_closed_cb), note);
#ifdef BUILD_ZEITGEIST
insert_zeitgeist (note, ZEITGEIST_ZG_ACCESS_EVENT);
diff --git a/src/tags b/src/tags
new file mode 100644
index 0000000..0c24acb
--- /dev/null
+++ b/src/tags
@@ -0,0 +1,29 @@
+!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
+!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
+!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert users sourceforge net/
+!_TAG_PROGRAM_NAME Exuberant Ctags //
+!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
+!_TAG_PROGRAM_VERSION 5.8 //
+GET_PRIVATE bjb-note-view.c 42;" d file:
+G_DEFINE_TYPE bjb-note-view.c /^G_DEFINE_TYPE (BjbNoteView, bjb_note_view, GTK_TYPE_OVERLAY)$/;" f
+NUM_PROPERTIES bjb-note-view.c /^ NUM_PROPERTIES$/;" e enum:__anon1 file:
+PROP_0 bjb-note-view.c /^ PROP_0,$/;" e enum:__anon1 file:
+PROP_NOTE bjb-note-view.c /^ PROP_NOTE,$/;" e enum:__anon1 file:
+PROP_PARENT bjb-note-view.c /^ PROP_PARENT,$/;" e enum:__anon1 file:
+PROP_WINDOW bjb-note-view.c /^ PROP_WINDOW,$/;" e enum:__anon1 file:
+bjb_note_view_class_init bjb-note-view.c /^bjb_note_view_class_init (BjbNoteViewClass *klass)$/;"
f file:
+bjb_note_view_constructed bjb-note-view.c /^bjb_note_view_constructed (GObject *obj)$/;" f file:
+bjb_note_view_disconnect bjb-note-view.c /^bjb_note_view_disconnect (BjbNoteView *self)$/;" f
file:
+bjb_note_view_finalize bjb-note-view.c /^bjb_note_view_finalize(GObject *object)$/;" f file:
+bjb_note_view_get_base_window bjb-note-view.c /^bjb_note_view_get_base_window (BjbNoteView *v)$/;" f
+bjb_note_view_get_property bjb-note-view.c /^bjb_note_view_get_property (GObject *object,$/;" f
file:
+bjb_note_view_grab_focus bjb-note-view.c /^bjb_note_view_grab_focus (BjbNoteView *view)$/;" f
+bjb_note_view_init bjb-note-view.c /^bjb_note_view_init (BjbNoteView *self)$/;" f file:
+bjb_note_view_last_updated_actor_new bjb-note-view.c /^bjb_note_view_last_updated_actor_new (BjbNoteView
*self)$/;" f
+bjb_note_view_new bjb-note-view.c /^bjb_note_view_new (GtkWidget *win, GtkWidget *parent, BijiNoteObj*
note)$/;" f
+bjb_note_view_set_property bjb-note-view.c /^bjb_note_view_set_property ( GObject *object,$/;"
f file:
+copy_note_color_to_last_updated_background bjb-note-view.c /^copy_note_color_to_last_updated_background
(BjbNoteView *self)$/;" f file:
+just_switch_to_main_view bjb-note-view.c /^just_switch_to_main_view(BjbNoteView *self)$/;" f
file:
+on_note_trashed bjb-note-view.c /^on_note_trashed (BijiNoteObj *note, BjbNoteView *view)$/;" f
file:
+on_window_closed bjb-note-view.c /^on_window_closed(GtkWidget *window,gpointer note)$/;" f file:
+properties bjb-note-view.c /^static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };$/;" v
file:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]