~ubuntu-branches/debian/sid/bijiben/sid

« back to all changes in this revision

Viewing changes to src/bjb-controller.c

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-03-26 21:19:36 UTC
  • Revision ID: package-import@ubuntu.com-20130326211936-tu8mpy82juohw8m2
Tags: upstream-3.8.0
ImportĀ upstreamĀ versionĀ 3.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * bjb-controller.c
 
3
 * Copyright (C) Pierre-Yves Luyten 2012, 2013 <py@luyten.fr>
 
4
 * 
 
5
 * bijiben is free software: you can redistribute it and/or modify it
 
6
 * under the terms of the GNU General Public License as published by the
 
7
 * Free Software Foundation, either version 3 of the License, or
 
8
 * (at your option) any later version.
 
9
 * 
 
10
 * bijiben is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
13
 * See the GNU General Public License for more details.
 
14
 * 
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include <libgd/gd.h>
 
20
 
 
21
#include "bjb-controller.h"
 
22
#include "bjb-main-view.h"
 
23
#include "bjb-window-base.h"
 
24
#include "utils/bjb-icons-colors.h"
 
25
 
 
26
 
 
27
/* Gobject */
 
28
 
 
29
struct _BjbControllerPrivate
 
30
{
 
31
  BijiNoteBook  *book ;
 
32
  gchar         *needle ;
 
33
  GtkTreeModel  *model ;
 
34
  GtkTreeModel  *completion;
 
35
 
 
36
  /* Optional
 
37
   * Currently Controller is window-wide, in order to live while
 
38
   * going from main view to note view.
 
39
   * But not app-wide : each win has its controller & needle.
 
40
   *
 
41
   * gd-main-view is setup by main-view to allow choosing pixbuf
 
42
   * according to grid / list view mode */
 
43
  GdMainView    *cur;
 
44
 
 
45
  /*  Private  */
 
46
  GList         *notes_to_show ;
 
47
  gboolean       connected;
 
48
  gulong         book_change;
 
49
};
 
50
 
 
51
enum {
 
52
  PROP_0,
 
53
  PROP_BOOK ,
 
54
  PROP_NEEDLE ,
 
55
  PROP_MODEL ,
 
56
  NUM_PROPERTIES
 
57
};
 
58
 
 
59
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
 
60
 
 
61
/* Currently used by toolbars */
 
62
enum {
 
63
  SEARCH_CHANGED,
 
64
  DISPLAY_NOTES_CHANGED, // either search or book change
 
65
  BJB_CONTROLLER_SIGNALS
 
66
};
 
67
 
 
68
static guint bjb_controller_signals [BJB_CONTROLLER_SIGNALS] = { 0 };
 
69
 
 
70
#define BJB_CONTROLLER_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BJB_TYPE_CONTROLLER, BjbControllerPrivate))
 
71
 
 
72
G_DEFINE_TYPE (BjbController, bjb_controller, G_TYPE_OBJECT);
 
73
 
 
74
/* GObject */
 
75
 
 
76
static void
 
77
bjb_controller_init (BjbController *self)
 
78
{
 
79
  BjbControllerPrivate *priv  ;
 
80
  GtkListStore     *store ;
 
81
  GtkListStore     *completion ;
 
82
 
 
83
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, 
 
84
                                            BJB_TYPE_CONTROLLER, 
 
85
                                            BjbControllerPrivate);
 
86
  priv = self->priv ;
 
87
 
 
88
  /* Create the columns */
 
89
  store = gtk_list_store_new (NUMBER_COLUMNS,
 
90
                              G_TYPE_STRING,   // urn
 
91
                              G_TYPE_STRING,   // uri
 
92
                              G_TYPE_STRING,   // name
 
93
                              G_TYPE_STRING,   // author
 
94
                              GDK_TYPE_PIXBUF,   // icon then note
 
95
                              G_TYPE_INT64,    // mtime
 
96
                              G_TYPE_BOOLEAN);   // state
 
97
 
 
98
  priv->model = GTK_TREE_MODEL(store) ;
 
99
  priv->notes_to_show = NULL;
 
100
  priv->needle = NULL;
 
101
  priv->connected = FALSE;
 
102
 
 
103
  completion  = gtk_list_store_new (1, G_TYPE_STRING);
 
104
  priv->completion = GTK_TREE_MODEL (completion);
 
105
}
 
106
 
 
107
static void
 
108
free_notes_store(BjbController *self)
 
109
{
 
110
  GtkListStore *store ;
 
111
 
 
112
  store = GTK_LIST_STORE (self->priv->model) ;
 
113
 
 
114
  gtk_list_store_clear(store);
 
115
}
 
116
 
 
117
static void
 
118
bjb_controller_finalize (GObject *object)
 
119
{
 
120
  BjbController *self = BJB_CONTROLLER(object);
 
121
  BjbControllerPrivate *priv = self->priv ;
 
122
 
 
123
  free_notes_store (self);
 
124
  g_object_unref (priv->model);
 
125
 
 
126
  g_object_unref (priv->completion);
 
127
  g_free (priv->needle);
 
128
  g_list_free (priv->notes_to_show);
 
129
 
 
130
  G_OBJECT_CLASS (bjb_controller_parent_class)->finalize (object);
 
131
}
 
132
 
 
133
static void
 
134
bjb_controller_get_property (GObject  *object,
 
135
               guint     property_id,
 
136
               GValue   *value,
 
137
               GParamSpec *pspec)
 
138
{
 
139
  BjbController *self = BJB_CONTROLLER (object);
 
140
 
 
141
  switch (property_id)
 
142
  {
 
143
  case PROP_BOOK:
 
144
    g_value_set_object (value, self->priv->book);
 
145
    break;
 
146
  case PROP_NEEDLE:
 
147
    g_value_set_string(value, self->priv->needle);
 
148
    break;
 
149
  case PROP_MODEL:
 
150
    g_value_set_object(value, self->priv->model);
 
151
    break;
 
152
  default:
 
153
    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
154
    break;
 
155
  }
 
156
}
 
157
 
 
158
static void
 
159
bjb_controller_set_property (GObject  *object,
 
160
               guint     property_id,
 
161
               const GValue *value,
 
162
               GParamSpec *pspec)
 
163
{
 
164
  BjbController *self = BJB_CONTROLLER (object);
 
165
 
 
166
  switch (property_id)
 
167
  {
 
168
  case PROP_BOOK:
 
169
    bjb_controller_set_book(self,g_value_get_object(value));
 
170
    break;
 
171
  case PROP_NEEDLE:
 
172
    bjb_controller_set_needle(self,g_value_get_string(value));
 
173
    break;
 
174
  default:
 
175
    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
176
    break;
 
177
  }
 
178
}
 
179
 
 
180
static void
 
181
bjb_controller_add_note (BjbController *self,
 
182
                         BijiNoteObj   *note,
 
183
                         gboolean       prepend)
 
184
{
 
185
  GtkTreeIter    iter;
 
186
  GtkListStore  *store;
 
187
  GdkPixbuf     *pix = NULL;
 
188
  gchar         *path;
 
189
 
 
190
  g_return_if_fail (BIJI_IS_NOTE_OBJ (note));
 
191
  store = GTK_LIST_STORE (self->priv->model);
 
192
 
 
193
  if (prepend)
 
194
    gtk_list_store_insert (store, &iter, 0);
 
195
 
 
196
  else
 
197
    gtk_list_store_append (store, &iter);
 
198
 
 
199
  /* Only append notes which are not templates. Currently useless */
 
200
  if ( biji_note_obj_is_template (note) == FALSE)
 
201
  {
 
202
 
 
203
    /* First , if there is a gd main view , and if gd main view
 
204
     * is a list, then load the 16x16 note pixbuf
 
205
     * This is probably not correct but allows a nice list view */
 
206
    if (self->priv->cur)
 
207
    {
 
208
      if (gd_main_view_get_view_type (self->priv->cur) == GD_MAIN_VIEW_LIST)
 
209
        pix = get_note_pixbuf();
 
210
    }
 
211
 
 
212
    /* If no gd-main-view or if not list view,
 
213
     * load the icon for grid */
 
214
    if (!pix)
 
215
      pix = biji_note_obj_get_icon (note);
 
216
 
 
217
    /* Appart from pixbuf, both icon & list view types
 
218
     * currently use the same model */
 
219
    path = biji_note_obj_get_path (note);
 
220
 
 
221
    gtk_list_store_set (store, 
 
222
                        &iter,
 
223
                        COL_URN,    path,
 
224
                        COL_URI,    path,
 
225
                        COL_NAME,   biji_note_obj_get_title(note),
 
226
                        COL_AUTHOR,   NULL,
 
227
                        COL_IMAGE,  pix,
 
228
                        COL_MTIME,  biji_note_obj_get_last_change_date_sec(note),
 
229
                        COL_SELECTED, FALSE,
 
230
                        -1);
 
231
 
 
232
    g_free (path);
 
233
  }
 
234
 
 
235
 
 
236
}
 
237
 
 
238
/* If the user searches for notes, is the note searched? */
 
239
static void
 
240
bjb_controller_add_note_if_needed (BjbController *self,
 
241
                                   BijiNoteObj   *note,
 
242
                                   gboolean       prepend)
 
243
{
 
244
  gboolean need_to_add_note =FALSE;
 
245
  gchar *title, *content;
 
246
  GList *collections, *l;
 
247
  BjbControllerPrivate *priv = self->priv;
 
248
 
 
249
  /* No note... */
 
250
  if (!note || !BIJI_IS_NOTE_OBJ (note))
 
251
    return;
 
252
 
 
253
  /* No search - we add the note */
 
254
  if (!priv->needle || g_strcmp0 (priv->needle, "")==0)
 
255
  {
 
256
    need_to_add_note = TRUE;
 
257
  }
 
258
 
 
259
  /* a search.. we test...*/
 
260
  else
 
261
  {
 
262
 
 
263
    title = biji_note_obj_get_title (note);
 
264
    content = biji_note_get_raw_text (note);
 
265
 
 
266
    /* matching title or content ... */
 
267
    if (g_strrstr (title  , priv->needle) != NULL ||
 
268
        g_strrstr (content, priv->needle) != NULL  )
 
269
      need_to_add_note = TRUE;
 
270
 
 
271
    /* last chance, matching collections... */
 
272
    else
 
273
    {
 
274
      collections = biji_note_obj_get_collections (note);
 
275
    
 
276
      for (l = collections; l != NULL; l=l->next)
 
277
      {
 
278
        if (g_strrstr (l->data, title))
 
279
        {
 
280
          need_to_add_note = TRUE;
 
281
          break;
 
282
        }
 
283
      }
 
284
 
 
285
      g_list_free (collections);
 
286
    }
 
287
  }
 
288
 
 
289
  if (need_to_add_note)
 
290
    bjb_controller_add_note (self, note, prepend);
 
291
}
 
292
 
 
293
void
 
294
bjb_controller_update_view (BjbController *self)
 
295
{
 
296
  GList *notes, *l;
 
297
 
 
298
  /* Do not update if nothing to show */
 
299
  if (!self->priv->cur)
 
300
    return;
 
301
 
 
302
  notes = self->priv->notes_to_show ;
 
303
  free_notes_store (self);
 
304
 
 
305
  for (l = notes; l != NULL; l = l->next)
 
306
  {
 
307
    bjb_controller_add_note (self, l->data, FALSE);
 
308
  }
 
309
}
 
310
 
 
311
static gint
 
312
most_recent_note_first (gconstpointer a, gconstpointer b)
 
313
{
 
314
  BijiNoteObj *one = BIJI_NOTE_OBJ (a);
 
315
  BijiNoteObj *other = BIJI_NOTE_OBJ (b);
 
316
  
 
317
  glong result = biji_note_obj_get_last_change_date_sec (other);
 
318
  return result - biji_note_obj_get_last_change_date_sec (one);
 
319
}
 
320
 
 
321
static void
 
322
sort_notes( BjbController *self)
 
323
{
 
324
  self->priv->notes_to_show = g_list_sort (self->priv->notes_to_show,
 
325
                                           most_recent_note_first);
 
326
}
 
327
 
 
328
static void
 
329
sort_and_update (BjbController *self)
 
330
{
 
331
  sort_notes (self);
 
332
  bjb_controller_update_view (self);
 
333
 
 
334
  g_signal_emit (G_OBJECT (self), bjb_controller_signals[DISPLAY_NOTES_CHANGED],0);
 
335
}
 
336
 
 
337
static void
 
338
update_controller_callback (GObject *source_object,
 
339
                            GAsyncResult *res,
 
340
                            gpointer user_data)
 
341
{
 
342
  GList *result;
 
343
  BjbController *self = BJB_CONTROLLER (user_data);
 
344
 
 
345
  result = biji_get_notes_with_strings_or_collection_finish (source_object, res, self->priv->book);
 
346
  self->priv->notes_to_show = result;
 
347
  sort_and_update (self);
 
348
}          
 
349
 
 
350
void
 
351
bjb_controller_apply_needle (BjbController *self)
 
352
{
 
353
  BjbControllerPrivate *priv = self->priv;
 
354
  gchar *needle;
 
355
 
 
356
  if (priv->notes_to_show)
 
357
    g_clear_pointer (&priv->notes_to_show, g_list_free);
 
358
  
 
359
  needle = priv->needle;
 
360
 
 
361
  /* Show all notes */
 
362
  if (needle == NULL || g_strcmp0 (needle,"") == 0)
 
363
  {
 
364
    priv->notes_to_show = biji_note_book_get_notes (self->priv->book);
 
365
    sort_and_update (self);
 
366
    return;
 
367
  }
 
368
 
 
369
  biji_get_notes_with_string_or_collection_async (needle, update_controller_callback, self);
 
370
}
 
371
 
 
372
static void
 
373
on_needle_changed ( BjbController *self )
 
374
{
 
375
  bjb_controller_apply_needle (self);
 
376
  g_signal_emit (self, bjb_controller_signals[SEARCH_CHANGED], 0);
 
377
}
 
378
 
 
379
static void
 
380
add_note_to_completion(BijiNoteObj *note , BjbController *self)
 
381
{
 
382
  GtkListStore *store;
 
383
  GtkTreeIter iter;
 
384
 
 
385
  store = GTK_LIST_STORE(self->priv->completion);
 
386
 
 
387
  // Search Tag.
 
388
  gtk_list_store_append (store, &iter);
 
389
  gtk_list_store_set (store, 
 
390
                      &iter, 
 
391
                      0, 
 
392
                      biji_note_obj_get_title(note),
 
393
                      -1);
 
394
}
 
395
 
 
396
static void
 
397
refresh_completion(BjbController *self)
 
398
{
 
399
  GList *notes = biji_note_book_get_notes (self->priv->book);
 
400
  gtk_list_store_clear(GTK_LIST_STORE(self->priv->completion));
 
401
 
 
402
  if (notes)
 
403
  {
 
404
    g_list_foreach (notes, (GFunc)add_note_to_completion, self);
 
405
    g_list_free (notes);
 
406
  }
 
407
}
 
408
 
 
409
static gboolean
 
410
bjb_controller_get_iter_at_note (BjbController *self, BijiNoteObj *note, GtkTreeIter **iter)
 
411
{
 
412
  BjbControllerPrivate *priv = self->priv;
 
413
  gchar *needle = biji_note_obj_get_path (note);
 
414
  gboolean retval = FALSE;
 
415
  gboolean still = gtk_tree_model_get_iter_first (priv->model, *iter);
 
416
 
 
417
  while (still)
 
418
  {
 
419
    gchar *note_path;
 
420
 
 
421
    gtk_tree_model_get (priv->model, *iter, GD_MAIN_COLUMN_URI, &note_path,-1);
 
422
 
 
423
    if (g_strcmp0 (note_path, needle)==0)
 
424
      retval = TRUE;
 
425
 
 
426
    g_free (note_path);
 
427
 
 
428
    if (retval)
 
429
      break;
 
430
 
 
431
    else
 
432
      still = gtk_tree_model_iter_next (priv->model, *iter);
 
433
  }
 
434
 
 
435
  g_free (needle);
 
436
  return retval;
 
437
}
 
438
 
 
439
/* Depending on the change at data level,
 
440
 * the view has to be totaly refreshed or just amended */
 
441
static void
 
442
on_book_changed (BijiNoteBook           *book,
 
443
                 BijiNoteBookChangeFlag  flag,
 
444
                 gpointer               *note_obj,
 
445
                 BjbController          *self)
 
446
{
 
447
  BjbControllerPrivate *priv = self->priv;
 
448
  BijiNoteObj *note = BIJI_NOTE_OBJ (note_obj);
 
449
  GtkTreeIter iter;
 
450
  GtkTreeIter *p_iter = &iter;
 
451
 
 
452
  switch (flag)
 
453
  {
 
454
    /* If this is a *new* note, per def prepend
 
455
     * But do not add a new note to a search window */
 
456
    case BIJI_BOOK_NOTE_ADDED:
 
457
        bjb_controller_add_note_if_needed (self, note, TRUE);
 
458
        priv->notes_to_show = g_list_prepend (priv->notes_to_show, note);
 
459
        g_signal_emit (G_OBJECT (self), bjb_controller_signals[DISPLAY_NOTES_CHANGED],0);
 
460
      break;
 
461
 
 
462
    /* If the note is *amended*, then per definition we prepend.
 
463
     * but if we add other ordering this does not work */
 
464
    case BIJI_BOOK_NOTE_AMENDED:
 
465
      if (bjb_controller_get_iter_at_note (self, note, &p_iter))
 
466
      {
 
467
        gtk_list_store_remove (GTK_LIST_STORE (priv->model), p_iter);
 
468
        bjb_controller_add_note_if_needed (self, note, TRUE);
 
469
      }
 
470
      break;
 
471
 
 
472
    /* If color changed we just amend the icon */
 
473
    case BIJI_BOOK_NOTE_COLORED:
 
474
      if (gd_main_view_get_view_type (priv->cur) == GD_MAIN_VIEW_ICON
 
475
          && bjb_controller_get_iter_at_note (self, note, &p_iter))
 
476
        gtk_list_store_set (GTK_LIST_STORE (priv->model), p_iter,
 
477
                            COL_IMAGE, biji_note_obj_get_icon (note), -1);
 
478
      break;
 
479
 
 
480
    case BIJI_BOOK_NOTE_TRASHED:
 
481
      if (bjb_controller_get_iter_at_note (self, note, &p_iter))
 
482
        gtk_list_store_remove (GTK_LIST_STORE (priv->model), p_iter);
 
483
 
 
484
      priv->notes_to_show = g_list_remove (priv->notes_to_show, note);
 
485
      g_signal_emit (G_OBJECT (self), bjb_controller_signals[DISPLAY_NOTES_CHANGED],0);
 
486
      break;
 
487
 
 
488
    default:
 
489
      bjb_controller_apply_needle (self);
 
490
  }
 
491
 
 
492
  /* FIXME we refresh the whole completion model each time */
 
493
  refresh_completion(self);
 
494
}
 
495
 
 
496
void
 
497
bjb_controller_connect (BjbController *self)
 
498
{
 
499
  BjbControllerPrivate *priv = self->priv;
 
500
  
 
501
  if (!priv->connected)
 
502
  {
 
503
    priv->book_change = g_signal_connect (self->priv->book, "changed",
 
504
                                     G_CALLBACK(on_book_changed), self);
 
505
    priv->connected = TRUE;
 
506
  }
 
507
}
 
508
 
 
509
void
 
510
bjb_controller_disconnect (BjbController *self)
 
511
{
 
512
  BjbControllerPrivate *priv = self->priv;
 
513
 
 
514
  g_signal_handler_disconnect (priv->book, priv->book_change);
 
515
  priv->book_change = 0;
 
516
}
 
517
 
 
518
static void
 
519
bjb_controller_constructed (GObject *obj)
 
520
{
 
521
  G_OBJECT_CLASS(bjb_controller_parent_class)->constructed(obj);
 
522
}
 
523
 
 
524
static void
 
525
bjb_controller_class_init (BjbControllerClass *klass)
 
526
{
 
527
  GObjectClass* object_class = G_OBJECT_CLASS (klass);
 
528
 
 
529
  g_type_class_add_private (klass, sizeof (BjbControllerPrivate));
 
530
 
 
531
  object_class->get_property = bjb_controller_get_property;
 
532
  object_class->set_property = bjb_controller_set_property;
 
533
  object_class->finalize = bjb_controller_finalize;
 
534
  object_class->constructed = bjb_controller_constructed;
 
535
 
 
536
  bjb_controller_signals[SEARCH_CHANGED] = g_signal_new ( "search-changed" ,
 
537
                                                  G_OBJECT_CLASS_TYPE (klass),
 
538
                                                  G_SIGNAL_RUN_LAST,
 
539
                                                  0, 
 
540
                                                  NULL, 
 
541
                                                  NULL,
 
542
                                                  g_cclosure_marshal_VOID__VOID,
 
543
                                                  G_TYPE_NONE,
 
544
                                                  0);
 
545
 
 
546
  bjb_controller_signals[DISPLAY_NOTES_CHANGED] = g_signal_new ( "display-notes-changed" ,
 
547
                                                  G_OBJECT_CLASS_TYPE (klass),
 
548
                                                  G_SIGNAL_RUN_LAST,
 
549
                                                  0, 
 
550
                                                  NULL, 
 
551
                                                  NULL,
 
552
                                                  g_cclosure_marshal_VOID__BOOLEAN,
 
553
                                                  G_TYPE_NONE,
 
554
                                                  0);
 
555
 
 
556
  properties[PROP_BOOK] = g_param_spec_object ("book",
 
557
                                               "Book",
 
558
                                               "The BijiNoteBook",
 
559
                                               BIJI_TYPE_NOTE_BOOK,
 
560
                                               G_PARAM_READWRITE |
 
561
                                               G_PARAM_CONSTRUCT |
 
562
                                               G_PARAM_STATIC_STRINGS);
 
563
 
 
564
  properties[PROP_NEEDLE] = g_param_spec_string ("needle",
 
565
                                                 "Needle",
 
566
                                                 "String to search notes",
 
567
                                                 NULL,
 
568
                                                 G_PARAM_READWRITE |
 
569
                                                 G_PARAM_CONSTRUCT |
 
570
                                                 G_PARAM_STATIC_STRINGS);
 
571
 
 
572
 
 
573
  properties[PROP_MODEL] = g_param_spec_object ("model",
 
574
                                                "Model",
 
575
                                                "The GtkTreeModel",
 
576
                                                GTK_TYPE_TREE_MODEL,
 
577
                                                G_PARAM_READABLE  |
 
578
                                                G_PARAM_STATIC_STRINGS);
 
579
 
 
580
  g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
 
581
 
 
582
}
 
583
 
 
584
BjbController *
 
585
bjb_controller_new (BijiNoteBook *book, 
 
586
                           gchar *needle)
 
587
{
 
588
  return g_object_new ( BJB_TYPE_CONTROLLER,
 
589
              "book", book,
 
590
              "needle", needle,
 
591
              NULL); 
 
592
}
 
593
 
 
594
void
 
595
bjb_controller_set_book (BjbController *self, BijiNoteBook  *book )
 
596
{
 
597
  self->priv->book = book ;
 
598
  
 
599
  /* Only update completion.
 
600
   * Notes model is updated when needle changes */
 
601
  refresh_completion(self);
 
602
}
 
603
 
 
604
void
 
605
bjb_controller_set_needle (BjbController *self, const gchar *needle )
 
606
{
 
607
  if (self->priv->needle)
 
608
    g_free (self->priv->needle);
 
609
 
 
610
  self->priv->needle = g_strdup (needle);
 
611
  on_needle_changed (self);
 
612
}
 
613
 
 
614
gchar *
 
615
bjb_controller_get_needle (BjbController *self)
 
616
{
 
617
  if (!self->priv->needle)
 
618
    return NULL;
 
619
 
 
620
  return self->priv->needle;
 
621
}
 
622
 
 
623
GtkTreeModel *
 
624
bjb_controller_get_model  (BjbController *self)
 
625
{
 
626
  return self->priv->model ;
 
627
}
 
628
 
 
629
GtkTreeModel *
 
630
bjb_controller_get_completion(BjbController *self)
 
631
{
 
632
  return self->priv->completion ;
 
633
}
 
634
 
 
635
void
 
636
bjb_controller_set_main_view (BjbController *self, GdMainView *current)
 
637
{
 
638
  /* Refresh the model */
 
639
  self->priv->cur = current;
 
640
  bjb_controller_update_view (self);
 
641
}
 
642
 
 
643
gboolean
 
644
bjb_controller_shows_notes (BjbController *self)
 
645
{
 
646
  if (self->priv->notes_to_show)
 
647
    return TRUE;
 
648
 
 
649
  return FALSE;
 
650
}