]> git.0d.be Git - empathy.git/blob - contact-list/empathy-contact-list-main.c
[darcs-to-svn @ Connect accounts in empathy-launcher, not in empathy-contact-list]
[empathy.git] / contact-list / empathy-contact-list-main.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2007 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  * 
20  * Authors: Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include <config.h>
24
25 #include <stdlib.h>
26
27 #include <glib.h>
28 #include <gtk/gtk.h>
29
30 #include <libtelepathy/tp-helpers.h>
31 #include <libmissioncontrol/mission-control.h>
32
33 #include <libempathy/empathy-session.h>
34 #include <libempathy/gossip-contact.h>
35 #include <libempathy-gtk/gossip-contact-list.h>
36 #include <libempathy-gtk/gossip-private-chat.h>
37 #include <libempathy-gtk/gossip-stock.h>
38
39 static void
40 destroy_cb (GtkWidget *window,
41             gpointer   user_data)
42 {
43         gossip_stock_finalize ();
44         empathy_session_finalize ();
45         gtk_main_quit ();
46 }
47
48 static void
49 contact_chat_cb (GtkWidget      *list,
50                  GossipContact  *contact,
51                  MissionControl *mc)
52 {
53         mission_control_request_channel (mc,
54                                          gossip_contact_get_account (contact),
55                                          TP_IFACE_CHANNEL_TYPE_TEXT,
56                                          gossip_contact_get_handle (contact),
57                                          TP_HANDLE_TYPE_CONTACT,
58                                          NULL, NULL);
59 }
60
61 int
62 main (int argc, char *argv[])
63 {
64         GtkWidget *window;
65         GtkWidget *list;
66         GtkWidget *sw;
67
68         gtk_init (&argc, &argv);
69
70         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
71         gossip_stock_init (window);
72
73         list = GTK_WIDGET (gossip_contact_list_new ());
74         sw = gtk_scrolled_window_new (NULL, NULL);      
75         gtk_container_add (GTK_CONTAINER (window), sw);
76         gtk_container_add (GTK_CONTAINER (sw), list);
77
78         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
79                                         GTK_POLICY_AUTOMATIC,
80                                         GTK_POLICY_AUTOMATIC);
81         gtk_widget_set_size_request (sw, 200, 400);
82
83         g_signal_connect (window, "destroy",
84                           G_CALLBACK (destroy_cb),
85                           NULL);
86         g_signal_connect (list, "contact-chat",
87                           G_CALLBACK (contact_chat_cb),
88                           mission_control_new (tp_get_bus ()));
89
90         gtk_widget_show_all (window);
91
92         gtk_main ();
93
94         return EXIT_SUCCESS;
95 }
96