[bijiben] controller: show search results according to trashed



commit b81cdc7151cd47354270f5787a56a7414a38ec64
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Mon Mar 17 00:02:05 2014 +0100

    controller: show search results according to trashed
    
    now trash bin shows trashed notes.
    standard view shows standard notes.
    
    First, this allows to search inside Trash view.
    Second, this obviously fixes one bug
    where notes result appeared while viewing trash bin.

 src/bjb-controller.c |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/src/bjb-controller.c b/src/bjb-controller.c
index b328f16..3f60ad9 100644
--- a/src/bjb-controller.c
+++ b/src/bjb-controller.c
@@ -447,6 +447,40 @@ update (BjbController *self)
 }
 
 
+
+static void
+_add_if_group_match (BjbController  *self,
+                    GList         **to_show,
+                    gpointer       *item,
+                    gint           *count)
+{
+  gboolean trashed, match;
+  BijiNoteObj *note;
+
+  if (BIJI_IS_NOTE_OBJ (*item))
+  {
+    match = FALSE;
+    note = BIJI_NOTE_OBJ (*item);
+    trashed = biji_note_obj_is_trashed (note);
+
+    if ((trashed==FALSE && self->priv->group == BIJI_LIVING_ITEMS) ||
+        (trashed==TRUE  && self->priv->group == BIJI_ARCHIVED_ITEMS))
+      match = TRUE;
+  }
+
+  else
+  {
+    match = TRUE;
+  }
+
+  if (match)
+  {
+    *to_show = g_list_prepend (*to_show, *item);
+    *count = *count + 1;
+  }
+}
+
+
 static void
 update_controller_callback (GList *result,
                             gpointer user_data)
@@ -478,8 +512,10 @@ update_controller_callback (GList *result,
   {
     if (i< priv->n_items_to_show)
     {
-      priv->items_to_show = g_list_prepend (priv->items_to_show, l->data);
-      i ++;
+      _add_if_group_match (self,
+                           &priv->items_to_show,
+                           &l->data,
+                          &i);
     }
 
     else if (l->next != NULL)
@@ -506,8 +542,6 @@ update_controller_callback (GList *result,
 
 
 
-
-
 void
 bjb_controller_apply_needle (BjbController *self)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]