searchbar.c 18.6 KB
Newer Older
Julien Bonjean's avatar
Julien Bonjean committed
1
/*
2
 *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
Julien Bonjean's avatar
Julien Bonjean committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 *  Author: Antoine Reversat <antoine.reversat@savoirfairelinux.com>
 *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
 *  Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22
23
24
25
26
27
28
29
30
31
 *
 *  Additional permission under GNU GPL version 3 section 7:
 *
 *  If you modify this program, or any covered work, by linking or
 *  combining it with the OpenSSL project's OpenSSL library (or a
 *  modified version of that library), containing parts covered by the
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 *  grants you additional permission to convey the resulting work.
 *  Corresponding Source for a non-source form of such a combination
 *  shall include the source code for the parts of OpenSSL used as well
 *  as that of the covered work.
Julien Bonjean's avatar
Julien Bonjean committed
32
33
34
 */

#include <searchbar.h>
35
#include <calltree.h>
36
37
#include <config/addressbook-config.h>
#include <contacts/addressbook.h>
38
// #include <contacts/addressbook/eds.h>
39
#include <contacts/addrbookfactory.h>
Julien Bonjean's avatar
Julien Bonjean committed
40

41
GtkWidget * searchbox;
42
GtkWidget * addressbookentry;
43

44
GtkWidget * cbox;
45
GtkListStore * liststore = NULL;
46
47
48

gint cboxSignalId;

49
static GtkWidget *menu = NULL;
Julien Bonjean's avatar
Julien Bonjean committed
50

51
52
53
54
55
56
57
/**
 * Searchbar icons
 */
GdkPixbuf *incoming_pixbuf = NULL;
GdkPixbuf *outgoing_pixbuf = NULL;
GdkPixbuf *missed_pixbuf = NULL;

58
59
60
61
62

void searchbar_addressbook_activated (GtkEntry *entry, gchar *arg1 UNUSED, gpointer data UNUSED)
{
    DEBUG ("Searchbar: Entry activated");

63
64
    if(abookfactory_is_addressbook_loaded()) {
        AddrBookFactory *factory = abookfactory_get_factory();
65
66
67
	AddressBook_Config *addressbook_config; 
        addressbook_config_load_parameters(&addressbook_config);
        factory->addrbook->search(factory->addrbook, entry, addressbook_config);
68
    }
69
70
}

71
void searchbar_entry_changed (GtkEntry* entry UNUSED, gchar* arg1 UNUSED, gpointer data UNUSED)
72
{
73
    DEBUG ("Searchbar: Entry changed");
74

75
    if (active_calltree == contacts) {
76
77
        // Search made only when text entry is activated
        // addressbook_search (entry);
Julien Bonjean's avatar
Julien Bonjean committed
78
    } else if (active_calltree == history) {
79
        history_search();
Julien Bonjean's avatar
Julien Bonjean committed
80
81
82
    }
}

83
static void cbox_changed_cb (GtkWidget *widget, gpointer user_data UNUSED)
84
{
85
    if(abookfactory_is_addressbook_loaded()) {
86
        DEBUG("Searchbar: Set new addressbook");
87
        AddrBookFactory *factory = abookfactory_get_factory();
88
        factory->addrbook->set_current_book (gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget)));
89
90
91
        AddressBook_Config *addressbook_config;
        addressbook_config_load_parameters(&addressbook_config);
        factory->addrbook->search(factory->addrbook, GTK_ENTRY(addressbookentry), addressbook_config);
92
    }
93
94
}

95
void set_focus_on_addressbook_searchbar ()
96
97
98
99
{
    gtk_widget_grab_focus (addressbookentry);
}

100
101
102
103
104
void update_searchbar_addressbook_list()
{
    GtkTreeIter iter, activeIter;
    gchar *activeText;
    GSList *book_list_iterator;
105
    book_data_t *book_data;
106
107
108
109
    GSList *books_data = NULL;

    if(abookfactory_is_addressbook_loaded()) {
        AddrBookFactory *factory = abookfactory_get_factory();
110
        books_data = factory->addrbook->get_books_data(dbus_get_addressbook_list());
111
112
113
    }

    if(books_data == NULL) {
114
        ERROR("Searchbar: No books data found");
115
116
    	return;
    }
117
118
    DEBUG ("Searchbar: Update addressbook list");

119
120
121
122
123
    // we must disconnect signal from teh cbox while updating its content
    gtk_signal_disconnect (cbox, cboxSignalId);

    // store the current active text
    activeText = g_strdup (gtk_combo_box_get_active_text (GTK_COMBO_BOX (cbox)));
124
125
126
127
128
    if(activeText == NULL) {

        activeText = g_strdup ("");
    }

129
130
131
132
133
134
135
136
137
    gtk_list_store_clear (liststore);

    // Populate menu
    gboolean activeIsSet = FALSE;

    for (book_list_iterator = books_data; book_list_iterator != NULL; book_list_iterator
            = book_list_iterator->next) {
        book_data = (book_data_t *) book_list_iterator->data;

138
139
        if (book_data && book_data->active) {

140
141
142
143

            gtk_list_store_append (liststore, &iter);
            gtk_list_store_set (liststore, &iter, 0, book_data->name, -1);

144
            if (g_strcmp0 (book_data->name, activeText) == 0) {
145
146
147
148
149
150
                activeIter = iter;
                activeIsSet = TRUE;
            }
        }
    }

151
152
153
154
155
156
157
158
159
160
161
    if(abookfactory_is_addressbook_loaded()) {
        AddrBookFactory *factory = abookfactory_get_factory();
        if (activeIsSet) {
            gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cbox), &activeIter);
            factory->addrbook->set_current_book(activeText);
        }
        else {
            gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), 0);
            gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbox));
            factory->addrbook->set_current_book(gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbox)));
        }
162
163
    }

164
165
166
167
168
169
    g_free (activeText);
    cboxSignalId = gtk_signal_connect (GTK_OBJECT (cbox), "changed", G_CALLBACK (cbox_changed_cb), NULL);
}


static void select_search_type (GtkWidget *item, GtkEntry  *entry UNUSED)
170
{
171
172
173
    
    if(abookfactory_is_addressbook_loaded()) {
        AddrBookFactory *factory = abookfactory_get_factory();
174

175
        DEBUG ("Searchbar: %s", gtk_menu_item_get_label (GTK_MENU_ITEM (item)));
176

177
        gtk_entry_set_icon_tooltip_text (GTK_ENTRY (addressbookentry), GTK_ENTRY_ICON_PRIMARY,
178
                                     gtk_menu_item_get_label (GTK_MENU_ITEM (item)));
179
180


181
        if (g_strcmp0 ("Search is", gtk_menu_item_get_label (GTK_MENU_ITEM (item))) == 0) {
182
183
            factory->addrbook->set_search_type(ABOOK_QUERY_IS);
        }
184
        else if (g_strcmp0 ("Search begins with", gtk_menu_item_get_label (GTK_MENU_ITEM (item))) == 0) {
185
186
            factory->addrbook->set_search_type(ABOOK_QUERY_BEGINS_WITH);
        }
187
        else if (g_strcmp0 ("Search contains", gtk_menu_item_get_label (GTK_MENU_ITEM (item))) == 0) {
188
189
            factory->addrbook->set_search_type(ABOOK_QUERY_CONTAINS);
        }
190
191
192
193
  
        AddressBook_Config *addressbook_config;
        addressbook_config_load_parameters(&addressbook_config);
        factory->addrbook->search (factory->addrbook, GTK_ENTRY (addressbookentry), addressbook_config);
194
    }
195

196
197
}

Julien Bonjean's avatar
Julien Bonjean committed
198
static void search_all (GtkWidget *item UNUSED, GtkEntry  *entry)
199
{
200
201
    HistorySearchType = SEARCH_ALL;

202
203
    gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
    gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY,
Julien Bonjean's avatar
Julien Bonjean committed
204
                                     g_markup_printf_escaped ("%s\n%s",
205
206
                                             _ ("Search all"),
                                             _ ("Click here to change the search type")));
207

208
    history_search();
Julien Bonjean's avatar
Julien Bonjean committed
209
}
Julien Bonjean's avatar
Julien Bonjean committed
210

Julien Bonjean's avatar
Julien Bonjean committed
211
static void search_by_missed (GtkWidget *item UNUSED, GtkEntry  *entry)
212
{
213
    HistorySearchType = SEARCH_MISSED;
214

215
    gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, missed_pixbuf);
216
    gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY,
Julien Bonjean's avatar
Julien Bonjean committed
217
                                     g_markup_printf_escaped ("%s\n%s",
218
219
                                             _ ("Search by missed call"),
                                             _ ("Click here to change the search type")));
220
    history_search();
Julien Bonjean's avatar
Julien Bonjean committed
221
}
222

Julien Bonjean's avatar
Julien Bonjean committed
223
static void search_by_incoming (GtkWidget *item UNUSED, GtkEntry *entry)
224
{
225
    HistorySearchType = SEARCH_INCOMING;
226

227
    gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, incoming_pixbuf);
228
    gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY,
Julien Bonjean's avatar
Julien Bonjean committed
229
                                     g_markup_printf_escaped ("%s\n%s",
230
231
                                             _ ("Search by incoming call"),
                                             _ ("Click here to change the search type")));
232
    history_search();
Julien Bonjean's avatar
Julien Bonjean committed
233
}
234

Julien Bonjean's avatar
Julien Bonjean committed
235
static void search_by_outgoing (GtkWidget *item UNUSED, GtkEntry  *entry)
236
{
237
    HistorySearchType = SEARCH_OUTGOING;
238

239
    gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, outgoing_pixbuf);
240
    gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY,
Julien Bonjean's avatar
Julien Bonjean committed
241
                                     g_markup_printf_escaped ("%s\n%s",
242
243
                                             _ ("Search by outgoing call"),
                                             _ ("Click here to change the search type")));
244
    history_search();
Julien Bonjean's avatar
Julien Bonjean committed
245
}
246

Julien Bonjean's avatar
Julien Bonjean committed
247
static void icon_press_cb (GtkEntry *entry, gint position, GdkEventButton *event, gpointer data UNUSED)
248
{
249
250
    DEBUG ("Searchbar: Icon pressed");

251
    if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree == history)
Julien Bonjean's avatar
Julien Bonjean committed
252
253
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
                        event->button, event->time);
254
    else if (position == GTK_ENTRY_ICON_PRIMARY && active_calltree == contacts) {
255
256
257
        GtkWidget *addrbook_menu = addressbook_menu_new();
        gtk_menu_popup (GTK_MENU (addrbook_menu), NULL, NULL, NULL, NULL,
                        event->button, event->time);
258
    } else
259
260
        gtk_entry_set_text (entry, "");
}
261

Julien Bonjean's avatar
Julien Bonjean committed
262
static void text_changed_cb (GtkEntry *entry, GParamSpec *pspec UNUSED)
263
{
264
265
266
267
    gboolean has_text;

    has_text = gtk_entry_get_text_length (entry) > 0;
    gtk_entry_set_icon_sensitive (entry, GTK_ENTRY_ICON_SECONDARY, has_text);
Julien Bonjean's avatar
Julien Bonjean committed
268
269
}

270

271

272
273
274
275
276
277
278
279
280
281
GtkWidget *addressbook_menu_new (void)
{

    GtkWidget *menu, *item;

    // Create the menu
    menu = gtk_menu_new ();
    gtk_menu_attach_to_widget (GTK_MENU (menu), contacts->searchbar, NULL);

    // Populate menu
282
283
284
285
286
287
288
289
290
291
292
    item = gtk_menu_item_new_with_label ("Search is");
    g_signal_connect (item, "activate", G_CALLBACK (select_search_type), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_menu_item_new_with_label ("Search begins with");
    g_signal_connect (item, "activate", G_CALLBACK (select_search_type), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_menu_item_new_with_label ("Search contains");
    g_signal_connect (item, "activate", G_CALLBACK (select_search_type), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
293
294
295
296
297
298

    gtk_widget_show_all (menu);

    return menu;
}

299
300
301
GtkWidget* history_searchbar_new (void)
{
    GtkWidget *ret, *item, *image;
Julien Bonjean's avatar
Julien Bonjean committed
302

Julien Bonjean's avatar
Julien Bonjean committed
303
    ret = gtk_hbox_new (FALSE, 0);
Julien Bonjean's avatar
Julien Bonjean committed
304

305
#if GTK_CHECK_VERSION(2,16,0)
306

307
308
    searchbox = gtk_entry_new();
    gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
309

310
311
312
313
    missed_pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/missed.svg", NULL);
    incoming_pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/incoming.svg", NULL);
    outgoing_pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/outgoing.svg", NULL);

314
315
    // Set the clean insensitive
    text_changed_cb (GTK_ENTRY (searchbox), NULL);
316

317
    g_signal_connect (searchbox, "icon-press", G_CALLBACK (icon_press_cb), NULL);
318
    g_signal_connect (searchbox, "notify::text", G_CALLBACK (text_changed_cb), NULL);
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
    //g_signal_connect (searchbox, "activate", G_CALLBACK (activate_cb), NULL);

    // Set up the search icon
    search_all (NULL, GTK_ENTRY (searchbox));

    // Create the menu
    menu = gtk_menu_new ();
    gtk_menu_attach_to_widget (GTK_MENU (menu), searchbox, NULL);

    image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
    item = gtk_image_menu_item_new_with_label ("Search all");
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
    g_signal_connect (item, "activate", G_CALLBACK (search_all), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_image_menu_item_new_with_label ("Search by missed call");
    image = gtk_image_new_from_file (ICONS_DIR "/missed.svg");
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
    g_signal_connect (item, "activate", G_CALLBACK (search_by_missed), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_image_menu_item_new_with_label ("Search by incoming call");
    image = gtk_image_new_from_file (ICONS_DIR "/incoming.svg");
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
    g_signal_connect (item, "activate", G_CALLBACK (search_by_incoming), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    item = gtk_image_menu_item_new_with_label ("Search by outgoing call");
    image = gtk_image_new_from_file (ICONS_DIR "/outgoing.svg");
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
    g_signal_connect (item, "activate", G_CALLBACK (search_by_outgoing), searchbox);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

    gtk_widget_show_all (menu);

354
#else
355
    searchbox = sexy_icon_entry_new();
Julien Bonjean's avatar
Julien Bonjean committed
356
357
358
    image = gtk_image_new_from_stock (GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
    sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (searchbox), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image));
    sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (searchbox));
359
#endif
360

Julien Bonjean's avatar
Julien Bonjean committed
361
    g_signal_connect_after (GTK_ENTRY (searchbox), "changed", G_CALLBACK (searchbar_entry_changed), NULL);
362
    g_signal_connect_after (G_OBJECT (searchbox), "focus-in-event",
Julien Bonjean's avatar
Julien Bonjean committed
363
                            G_CALLBACK (focus_on_searchbar_in), NULL);
364
    g_signal_connect_after (G_OBJECT (searchbox), "focus-out-event",
Julien Bonjean's avatar
Julien Bonjean committed
365
                            G_CALLBACK (focus_on_searchbar_out), NULL);
366

Julien Bonjean's avatar
Julien Bonjean committed
367
368
    gtk_box_pack_start (GTK_BOX (ret), searchbox, TRUE, TRUE, 0);
    history_set_searchbar_widget (searchbox);
369
370
371
372

    return ret;
}

Julien Bonjean's avatar
Julien Bonjean committed
373
374
GtkWidget* contacts_searchbar_new ()
{
375
376

    GtkWidget *ret;
377
378
    GtkWidget *align;
    int count, cbox_height, cbox_width;
379
380
    GtkTreeIter iter, activeIter;
    GtkCellRenderer *cell;
381
    gchar **book_list;
382
383
384
    // gchar *current_addressbook = NULL;

    DEBUG ("Addressbook: Create addressbook search bar");
385

Julien Bonjean's avatar
Julien Bonjean committed
386
    ret = gtk_hbox_new (FALSE, 0);
387

388
    liststore = gtk_list_store_new (1,G_TYPE_STRING);
389

390
    // Create combo box to select current addressbook
391
392
393
394
    if(!abookfactory_is_addressbook_loaded()) {
    	return NULL;
    }

395
396
    book_list = dbus_get_addressbook_list();

397
    AddrBookFactory *factory = abookfactory_get_factory();
398
    
399
    factory->addrbook->init(book_list);
400

401
402
    GSList *book_list_iterator;
    book_data_t *book_data;
403
    GSList *books_data = factory->addrbook->get_books_data(book_list);
404
    
405
406
    // Populate menu
    count = 0;
407
    gboolean activeIsSet = FALSE;
408

409
    for (book_list_iterator = books_data; book_list_iterator != NULL;
410
             book_list_iterator = book_list_iterator->next) {
411
412
        book_data = (book_data_t *) book_list_iterator->data;

413
414
        DEBUG("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %s", book_data->name);

415
        if (book_data->active) {
416
417

            gtk_list_store_append (liststore, &iter);
418

419
            gtk_list_store_set (liststore, &iter, 0, book_data->name, -1);
420

421
            if (book_data->isdefault) {
422
                activeIter = iter;
423
424
425
426
427
                activeIsSet = TRUE;
            }

            count++;
        }
428
429
    }

430
431
    // current_addressbook = get_current_addressbook();

432
433
434
435
436
    cbox = gtk_combo_box_new_with_model ( (GtkTreeModel *) liststore);

    if (activeIsSet)
        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cbox), &activeIter);
    else
437
438
        gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), 0);

439
440
441
442
443
444
445
446
    align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
    gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 2, 6, 6);
    gtk_container_add (GTK_CONTAINER (align), cbox);

    gtk_widget_get_size_request (GTK_WIDGET (cbox), &cbox_width, &cbox_height);
    gtk_widget_set_size_request (GTK_WIDGET (cbox), cbox_width, 26);

    cboxSignalId = gtk_signal_connect (GTK_OBJECT (cbox), "changed", G_CALLBACK (cbox_changed_cb), NULL);
447
    // cbox_changed_cb (GTK_WIDGET (cbox), NULL);
448
449
450
451

    cell = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cbox), cell, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cbox), cell, "text", 0, NULL);
452

453

454
#if GTK_CHECK_VERSION(2,16,0)
455

456
    // GdkPixbuf *pixbuf;
457

458
    gchar *tooltip_text = g_strdup ("Search is");
459
460
461

    addressbookentry = gtk_entry_new();
    gtk_entry_set_icon_from_stock (GTK_ENTRY (addressbookentry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
462
463
    // pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL);
    gtk_entry_set_icon_from_stock (GTK_ENTRY (addressbookentry), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
464
465
    gtk_entry_set_icon_tooltip_text (GTK_ENTRY (addressbookentry), GTK_ENTRY_ICON_PRIMARY,
                                     tooltip_text);
466

467
468

    // Set the clean insensitive
469
    text_changed_cb (GTK_ENTRY (addressbookentry), NULL);
470

471
472
    g_signal_connect (addressbookentry, "notify::text", G_CALLBACK (text_changed_cb), NULL);
    g_signal_connect (addressbookentry, "icon-press", G_CALLBACK (icon_press_cb), NULL);
473

474
475
476
477
#else

    GtkWidget *image;

478
    addressbookentry = sexy_icon_entry_new();
Julien Bonjean's avatar
Julien Bonjean committed
479
    image = gtk_image_new_from_stock (GTK_STOCK_FIND , GTK_ICON_SIZE_SMALL_TOOLBAR);
480
481
    sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (addressbookentry), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE (image));
    sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (addressbookentry));
482
#endif
483

484
485
    gtk_entry_set_activates_default (GTK_ENTRY (addressbookentry), TRUE);
    g_signal_connect_after (GTK_ENTRY (addressbookentry), "activate", G_CALLBACK (searchbar_addressbook_activated), NULL);
486

487
    g_signal_connect_after (GTK_ENTRY (addressbookentry), "changed", G_CALLBACK (searchbar_entry_changed), NULL);
488

489
    g_signal_connect_after (G_OBJECT (addressbookentry), "focus-in-event",
Julien Bonjean's avatar
Julien Bonjean committed
490
                            G_CALLBACK (focus_on_searchbar_in), NULL);
491
    g_signal_connect_after (G_OBJECT (addressbookentry), "focus-out-event",
Julien Bonjean's avatar
Julien Bonjean committed
492
                            G_CALLBACK (focus_on_searchbar_out), NULL);
493

494

495
    gtk_box_pack_start (GTK_BOX (ret), align, TRUE, TRUE, 0);
496
497
498
    gtk_box_pack_start (GTK_BOX (ret), addressbookentry, TRUE, TRUE, 0);

    g_free (tooltip_text);
499
    g_strfreev (book_list);
500
501
502
503

    // current_addressbook = gtk_combo_box_get_active_text (GTK_COMBO_BOX (cbox));
    // set_current_addressbook (current_addressbook);

504
    return ret;
Julien Bonjean's avatar
Julien Bonjean committed
505
506
}

Julien Bonjean's avatar
Julien Bonjean committed
507
508
509
void activateWaitingLayer()
{
    gtk_widget_show (waitingLayer);
Julien Bonjean's avatar
Julien Bonjean committed
510
511
}

Julien Bonjean's avatar
Julien Bonjean committed
512
513
514
void deactivateWaitingLayer()
{
    gtk_widget_hide (waitingLayer);
Julien Bonjean's avatar
Julien Bonjean committed
515
}
516
517
518
519
520

SearchType get_current_history_search_type (void)
{
    return HistorySearchType;
}