]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-contact-search-dialog.c
Show a profile info button in contact search results
[empathy.git] / libempathy-gtk / empathy-contact-search-dialog.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * empathy-contact-search-dialog.c
4  *
5  * Copyright (C) 2010-2011 Collabora Ltd.
6  *
7  * The code contained in this file is free software; you can redistribute
8  * it and/or modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either version
10  * 2.1 of the License, or (at your option) any later version.
11  *
12  * This file is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this code; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  * Authors:
22  *     Danielle Madeley <danielle.madeley@collabora.co.uk>
23  *     Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
24  */
25
26 #include <glib/gi18n.h>
27
28 #include <telepathy-glib/telepathy-glib.h>
29
30 #include <libempathy/empathy-contact-manager.h>
31 #include <libempathy/empathy-tp-contact-factory.h>
32
33 #include <libempathy-gtk/empathy-account-chooser.h>
34 #include <libempathy-gtk/empathy-cell-renderer-text.h>
35 #include <libempathy-gtk/empathy-cell-renderer-activatable.h>
36 #include <libempathy-gtk/empathy-images.h>
37
38 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
39 #include <libempathy/empathy-debug.h>
40
41 #include "empathy-contact-search-dialog.h"
42
43 #define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONTACT_SEARCH_DIALOG, EmpathyContactSearchDialogPrivate))
44
45 G_DEFINE_TYPE (EmpathyContactSearchDialog, empathy_contact_search_dialog, GTK_TYPE_DIALOG);
46
47 enum
48 {
49    NAME_COLUMN,
50    LOGIN_COLUMN,
51    N_COLUMNS
52 };
53
54 enum {
55    PAGE_SEARCH_RESULTS,
56    PAGE_NO_MATCH
57 };
58
59 typedef struct _EmpathyContactSearchDialogPrivate EmpathyContactSearchDialogPrivate;
60 struct _EmpathyContactSearchDialogPrivate
61 {
62   TpContactSearch *searcher;
63   GtkListStore *store;
64
65   GtkWidget *chooser;
66   GtkWidget *notebook;
67   GtkWidget *tree_view;
68   GtkWidget *spinner;
69   GtkWidget *add_button;
70   GtkWidget *find_button;
71   GtkWidget *no_contact_found;
72   GtkWidget *search_entry;
73   /* GtkWidget *server_entry; */
74 };
75
76 static void
77 empathy_contact_search_dialog_dispose (GObject *self)
78 {
79   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
80
81   tp_clear_object (&priv->searcher);
82
83   G_OBJECT_CLASS (empathy_contact_search_dialog_parent_class)->dispose (self);
84 }
85
86 static void
87 on_searcher_reset (GObject *source_object,
88     GAsyncResult *result,
89     gpointer user_data)
90 {
91   EmpathyContactSearchDialog *self = EMPATHY_CONTACT_SEARCH_DIALOG (user_data);
92   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
93   TpContactSearch *searcher = TP_CONTACT_SEARCH (source_object);
94   GError *error = NULL;
95   GHashTable *search;
96   const gchar *search_criteria;
97
98   tp_contact_search_reset_finish (searcher, result, &error);
99   if (error != NULL)
100     {
101       DEBUG ("Failed to reset the TpContactSearch: %s", error->message);
102       g_error_free (error);
103       return;
104     }
105
106   search = g_hash_table_new (g_str_hash, g_str_equal);
107
108   search_criteria = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
109
110   if (tp_strv_contains (tp_contact_search_get_search_keys (searcher), ""))
111     g_hash_table_insert (search, "", (gpointer) search_criteria);
112   else
113     g_hash_table_insert (search, "fn", (gpointer) search_criteria);
114
115   gtk_list_store_clear (priv->store);
116   tp_contact_search_start (priv->searcher, search);
117
118   g_hash_table_destroy (search);
119 }
120
121 static void
122 empathy_contact_search_dialog_do_search (EmpathyContactSearchDialog *self)
123 {
124   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
125
126   tp_contact_search_reset_async (priv->searcher,
127       NULL, /* gtk_entry_get_text (GTK_ENTRY (priv->server_entry)), */
128       0,
129       on_searcher_reset,
130       self);
131 }
132
133 static void
134 on_get_contact_factory_get_from_id_cb (TpConnection *connection,
135     EmpathyContact *contact,
136     const GError *error,
137     gpointer user_data,
138     GObject *object)
139 {
140     EmpathyContactManager *manager = empathy_contact_manager_dup_singleton ();
141
142     if (error != NULL)
143       {
144         g_warning ("Error while getting the contact: %s", error->message);
145         return;
146       }
147
148     empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), contact, "");
149 }
150
151 static void
152 add_selected_contact (EmpathyContactSearchDialog *self)
153 {
154   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
155   GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
156   TpConnection *conn;
157   GtkTreeIter iter;
158   GtkTreeModel *model;
159   gboolean sel;
160   gchar *id;
161
162   conn = empathy_account_chooser_get_connection (EMPATHY_ACCOUNT_CHOOSER (priv->chooser));
163
164   sel = gtk_tree_selection_get_selected (selection, &model, &iter);
165   g_return_if_fail (sel == TRUE);
166
167   gtk_tree_model_get (model, &iter, LOGIN_COLUMN, &id, -1);
168
169   DEBUG ("Requested to add contact: %s", id);
170
171   empathy_tp_contact_factory_get_from_id (conn, id,
172       on_get_contact_factory_get_from_id_cb, NULL,
173       NULL, NULL);
174 }
175
176 static void
177 empathy_contact_search_dialog_response (GtkDialog *self,
178     gint response)
179 {
180   switch (response)
181     {
182       case GTK_RESPONSE_APPLY:
183         add_selected_contact (EMPATHY_CONTACT_SEARCH_DIALOG (self));
184         break;
185       default:
186         gtk_widget_destroy (GTK_WIDGET (self));
187         break;
188     }
189 }
190
191 static void
192 empathy_contact_search_dialog_class_init (
193     EmpathyContactSearchDialogClass *klass)
194 {
195   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
196   GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
197
198   gobject_class->dispose = empathy_contact_search_dialog_dispose;
199
200   dialog_class->response = empathy_contact_search_dialog_response;
201
202   g_type_class_add_private (gobject_class,
203       sizeof (EmpathyContactSearchDialogPrivate));
204 }
205
206 static void
207 _on_search_state_changed_cb (TpContactSearch *searcher,
208     GParamSpec *pspec,
209     gpointer user_data)
210 {
211   EmpathyContactSearchDialog *self = EMPATHY_CONTACT_SEARCH_DIALOG (user_data);
212   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
213   TpChannelContactSearchState state;
214
215   g_object_get (searcher, "state", &state, NULL);
216
217   DEBUG ("new search status: %d", state);
218
219   if (state == TP_CHANNEL_CONTACT_SEARCH_STATE_IN_PROGRESS)
220     {
221       gtk_widget_show (priv->spinner);
222       gtk_spinner_start (GTK_SPINNER (priv->spinner));
223     }
224   else
225     {
226       gtk_widget_hide (priv->spinner);
227       gtk_spinner_stop (GTK_SPINNER (priv->spinner));
228     }
229
230   if (state == TP_CHANNEL_CONTACT_SEARCH_STATE_NOT_STARTED
231       || state == TP_CHANNEL_CONTACT_SEARCH_STATE_IN_PROGRESS)
232     {
233       gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
234           PAGE_SEARCH_RESULTS);
235     }
236   else
237     {
238       GtkTreeIter help_iter;
239
240       if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store),
241           &help_iter))
242         {
243           /* No results found, display a helpful message. */
244           gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
245               PAGE_NO_MATCH);
246         }
247     }
248 }
249
250 static void
251 _search_results_received (TpContactSearch *searcher,
252     GList *results,
253     EmpathyContactSearchDialog *self)
254 {
255   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
256   const TpContactInfoField *name;
257   GList *l;
258
259   for (l = results; l != NULL; l = l->next)
260     {
261       TpContactSearchResult *result = l->data;
262       GtkTreeIter iter;
263
264       gtk_list_store_append (priv->store, &iter);
265
266       name = tp_contact_search_result_get_field (result, "fn");
267
268       gtk_list_store_set (priv->store, &iter,
269           NAME_COLUMN, name ? name->field_value[0] : NULL,
270           LOGIN_COLUMN, tp_contact_search_result_get_identifier (result),
271           -1);
272     }
273 }
274
275 static void
276 on_searcher_created (GObject *source_object,
277     GAsyncResult *result,
278     gpointer user_data)
279 {
280   EmpathyContactSearchDialog *self;
281   EmpathyContactSearchDialogPrivate *priv;
282   GError *error = NULL;
283
284   if (EMPATHY_IS_CONTACT_SEARCH_DIALOG (user_data) == FALSE)
285     /* This happens if the dialog is closed before the callback is called */
286     return;
287
288   self = EMPATHY_CONTACT_SEARCH_DIALOG (user_data);
289   priv = GET_PRIVATE (self);
290
291   priv->searcher = tp_contact_search_new_finish (result, &error);
292   if (error != NULL)
293     {
294       DEBUG ("Failed to create a TpContactSearch: %s", error->message);
295       g_error_free (error);
296       return;
297     }
298
299   g_signal_connect (priv->searcher, "search-results-received",
300       G_CALLBACK (_search_results_received), self);
301   g_signal_connect (priv->searcher, "notify::state",
302       G_CALLBACK (_on_search_state_changed_cb), self);
303
304   gtk_widget_set_sensitive (priv->find_button, TRUE);
305 }
306
307 static void
308 on_selection_changed (GtkTreeSelection *selection,
309     gpointer user_data)
310 {
311   EmpathyContactSearchDialog *self;
312   EmpathyContactSearchDialogPrivate *priv;
313   gboolean sel;
314
315   self = EMPATHY_CONTACT_SEARCH_DIALOG (user_data);
316   priv = GET_PRIVATE (self);
317   sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
318
319   gtk_widget_set_sensitive (priv->add_button, sel);
320 }
321
322
323 static void
324 _account_chooser_changed (EmpathyAccountChooser *chooser,
325     EmpathyContactSearchDialog *self)
326 {
327   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
328   TpAccount *account = empathy_account_chooser_get_account (chooser);
329   TpConnection *conn = empathy_account_chooser_get_connection (chooser);
330   TpCapabilities *caps = tp_connection_get_capabilities (conn);
331   gboolean can_cs, can_set_limit, can_set_server;
332
333   can_cs = tp_capabilities_supports_contact_search (caps,
334       &can_set_limit, &can_set_server);
335   DEBUG ("The server supports cs|limit|server: %s|%s|%s",
336       can_cs ? "yes" : "no",
337       can_set_limit ? "yes" : "no",
338       can_set_server ? "yes" : "no");
339
340   /* gtk_widget_set_sensitive (priv->server_entry, can_set_server); */
341   gtk_widget_set_sensitive (priv->find_button, FALSE);
342
343   DEBUG ("New account is %s", tp_proxy_get_object_path (account));
344
345   tp_clear_object (&priv->searcher);
346   tp_contact_search_new_async (account,
347       NULL, /* gtk_entry_get_text (GTK_ENTRY (priv->server_entry)), */
348       0,
349       on_searcher_created, self);
350 }
351
352 static void
353 _on_button_search_clicked (GtkWidget *widget,
354     EmpathyContactSearchDialog *self)
355 {
356   empathy_contact_search_dialog_do_search (self);
357 }
358
359 #if 0
360 static void
361 on_server_changed_cb (GtkEditable *editable,
362     gpointer user_data)
363 {
364   EmpathyContactSearchDialog *self = EMPATHY_CONTACT_SEARCH_DIALOG (user_data);
365   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
366
367   g_return_if_fail (priv->searcher != NULL);
368
369   tp_contact_search_reset_async (priv->searcher,
370       gtk_entry_get_text (GTK_ENTRY (editable)),
371       0,
372       on_searcher_reset,
373       self);
374 }
375 #endif
376
377 typedef struct
378 {
379     EmpathyAccountChooserFilterResultCallback callback;
380     gpointer                                  user_data;
381 } FilterCallbackData;
382
383 static void
384 supports_contact_search_cb (GObject *conn,
385     GAsyncResult *result,
386     gpointer user_data)
387 {
388   FilterCallbackData *data = user_data;
389   GError *myerr = NULL;
390   TpCapabilities *caps;
391
392   if (!tp_proxy_prepare_finish (conn, result, &myerr))
393     {
394       data->callback (FALSE, data->user_data);
395       g_slice_free (FilterCallbackData, data);
396       return;
397     }
398
399   caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
400   data->callback (tp_capabilities_supports_contact_search (caps, NULL, NULL),
401     data->user_data);
402
403   g_slice_free (FilterCallbackData, data);
404 }
405
406 static void
407 empathy_account_chooser_filter_supports_contact_search (
408     TpAccount *account,
409     EmpathyAccountChooserFilterResultCallback callback,
410     gpointer callback_data,
411     gpointer user_data)
412 {
413   TpConnection *connection;
414   FilterCallbackData *cb_data;
415   GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
416
417   if (tp_account_get_connection_status (account, NULL)
418       != TP_CONNECTION_STATUS_CONNECTED)
419     {
420       callback (FALSE, callback_data);
421       return;
422     }
423
424   /* check if CM supports contact search */
425   connection = tp_account_get_connection (account);
426   if (connection == NULL)
427     {
428       callback (FALSE, callback_data);
429       return;
430     }
431
432   cb_data = g_slice_new0 (FilterCallbackData);
433   cb_data->callback = callback;
434   cb_data->user_data = callback_data;
435
436   tp_proxy_prepare_async (connection, features, supports_contact_search_cb,
437       cb_data);
438 }
439
440 static void
441 contact_search_dialog_row_activated_cb (GtkTreeView *tv,
442     GtkTreePath *path,
443     GtkTreeViewColumn *column,
444     EmpathyContactSearchDialog *self)
445 {
446   /* just emit the same response as the Add Button */
447   gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_APPLY);
448 }
449
450 static void
451 on_profile_button_got_contact_cb (TpConnection *connection,
452     EmpathyContact *contact,
453     const GError *error,
454     gpointer user_data,
455     GObject *object)
456 {
457  if (error != NULL)
458    {
459      g_warning ("Error while getting the contact: %s", error->message);
460      return;
461    }
462
463   empathy_contact_information_dialog_show (contact, NULL);
464 }
465
466 static void
467 on_profile_button_clicked_cb (EmpathyCellRendererActivatable *cell,
468     const gchar *path_string,
469     EmpathyContactSearchDialog *self)
470 {
471   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
472   GtkTreeSelection *selection;
473   TpConnection *conn;
474   GtkTreeIter iter;
475   GtkTreeModel *model;
476   gboolean valid;
477   gchar *id;
478
479   model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree_view));
480
481   conn = empathy_account_chooser_get_connection (
482       EMPATHY_ACCOUNT_CHOOSER (priv->chooser));
483
484   valid = gtk_tree_model_get_iter_from_string (model, &iter, path_string);
485   g_return_if_fail (valid == TRUE);
486
487   gtk_tree_model_get (model, &iter, LOGIN_COLUMN, &id, -1);
488
489   DEBUG ("Requested to show profile for contact: %s", id);
490
491   empathy_tp_contact_factory_get_from_id (conn, id,
492       on_profile_button_got_contact_cb, NULL,
493       NULL, NULL);
494 }
495
496 static void
497 empathy_contact_search_dialog_init (EmpathyContactSearchDialog *self)
498 {
499   EmpathyContactSearchDialogPrivate *priv = GET_PRIVATE (self);
500   GtkWidget *vbox, *hbox, *scrolled_window, *label;
501   GtkCellRenderer *cell;
502   GtkTreeViewColumn *col;
503   GtkTreeSelection *selection;
504   GtkSizeGroup *size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
505   gchar *tmp;
506
507   /* Title */
508   gtk_window_set_title (GTK_WINDOW (self), _("Search contacts"));
509
510   vbox = gtk_vbox_new (FALSE, 3);
511   gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
512
513   /* Account chooser */
514   hbox = gtk_hbox_new (FALSE, 6);
515   label = gtk_label_new (_("Account:"));
516   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
517   gtk_size_group_add_widget (size_group, label);
518
519   priv->chooser = empathy_account_chooser_new ();
520   empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (priv->chooser),
521       empathy_account_chooser_filter_supports_contact_search, NULL);
522   gtk_box_pack_start (GTK_BOX (hbox), priv->chooser, TRUE, TRUE, 0);
523   g_signal_connect (priv->chooser, "changed",
524       G_CALLBACK (_account_chooser_changed), self);
525
526   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
527
528 #if 0
529   /* Server entry */
530   priv->server_entry = gtk_entry_new ();
531   gtk_box_pack_start (GTK_BOX (vbox), priv->server_entry, FALSE, TRUE, 6);
532   g_signal_connect (GTK_EDITABLE (priv->server_entry), "changed",
533       G_CALLBACK (on_server_changed_cb), self);
534 #endif
535
536   /* Search input */
537   hbox = gtk_hbox_new (FALSE, 6);
538   label = gtk_label_new (_("Search: "));
539   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
540   gtk_size_group_add_widget (size_group, label);
541
542   priv->search_entry = gtk_entry_new ();
543   gtk_box_pack_start (GTK_BOX (hbox), priv->search_entry, TRUE, TRUE, 0);
544   g_signal_connect (priv->search_entry, "activate",
545       G_CALLBACK (_on_button_search_clicked), self);
546
547   priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
548   g_signal_connect (priv->find_button, "clicked",
549       G_CALLBACK (_on_button_search_clicked), self);
550   gtk_box_pack_end (GTK_BOX (hbox), priv->find_button, FALSE, TRUE, 0);
551
552   priv->spinner = gtk_spinner_new ();
553   gtk_box_pack_end (GTK_BOX (hbox), priv->spinner, FALSE, TRUE, 0);
554   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
555
556   /* Search results */
557   priv->store = gtk_list_store_new (N_COLUMNS,
558                                     G_TYPE_STRING,  /* Name */
559                                     G_TYPE_STRING); /* Login */
560
561   priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->store));
562   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
563   gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
564
565   g_signal_connect (priv->tree_view, "row-activated",
566       G_CALLBACK (contact_search_dialog_row_activated_cb), self);
567   g_signal_connect (selection, "changed",
568       G_CALLBACK (on_selection_changed), self);
569
570   gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
571
572   col = gtk_tree_view_column_new ();
573
574   cell = empathy_cell_renderer_text_new ();
575   gtk_tree_view_column_pack_start (col, cell, TRUE);
576   /* EmpathyCellRendererText displays "name" above and "status" below.
577    * We want the login above since it'll always be available, and the
578    * name below since we won't always have it. */
579   gtk_tree_view_column_add_attribute (col, cell,
580       "name", LOGIN_COLUMN);
581   gtk_tree_view_column_add_attribute (col, cell,
582       "status", NAME_COLUMN);
583
584   cell = empathy_cell_renderer_activatable_new ();
585   gtk_tree_view_column_pack_end (col, cell, FALSE);
586   g_object_set (cell, "stock-id", EMPATHY_IMAGE_CONTACT_INFORMATION, NULL);
587   g_signal_connect (cell, "path-activated",
588       G_CALLBACK (on_profile_button_clicked_cb), self);
589
590   gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), col);
591
592   gtk_dialog_add_button (GTK_DIALOG (self),
593       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
594
595   priv->add_button = gtk_dialog_add_button (GTK_DIALOG (self),
596       _("_Add Contact"), GTK_RESPONSE_APPLY);
597   gtk_widget_set_sensitive (priv->add_button, FALSE);
598   gtk_button_set_image (GTK_BUTTON (priv->add_button),
599       gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON));
600
601   /* Pack the dialog */
602   priv->notebook = gtk_notebook_new ();
603   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
604   g_object_set (priv->notebook, "margin", 6, NULL);
605
606   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
607   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
608       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
609
610   gtk_container_add (GTK_CONTAINER (scrolled_window), priv->tree_view);
611
612   priv->no_contact_found = gtk_label_new (NULL);
613   tmp = g_strdup_printf ("<b><span size='xx-large'>%s</span></b>",
614       _("No contacts found"));
615   gtk_label_set_markup (GTK_LABEL (priv->no_contact_found), tmp);
616   g_free (tmp);
617
618   gtk_label_set_ellipsize (GTK_LABEL (priv->no_contact_found),
619       PANGO_ELLIPSIZE_END);
620
621   gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), scrolled_window,
622       NULL);
623   gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
624       priv->no_contact_found, NULL);
625
626   gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 3);
627
628   gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (
629           GTK_DIALOG (self))), vbox, TRUE, TRUE, 0);
630
631   gtk_window_set_default_size (GTK_WINDOW (self), 200, 400);
632   gtk_widget_show_all (vbox);
633   gtk_widget_hide (priv->spinner);
634 }
635
636 GtkWidget *
637 empathy_contact_search_dialog_new (GtkWindow *parent)
638 {
639   GtkWidget *self;
640
641   g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
642
643   self = g_object_new (EMPATHY_TYPE_CONTACT_SEARCH_DIALOG, NULL);
644
645   if (parent != NULL)
646     {
647       gtk_window_set_transient_for (GTK_WINDOW (self), parent);
648     }
649
650   return self;
651 }