]> git.0d.be Git - empathy.git/blob - contact-list/empathy-contact-list-main.c
2f432848071d8c734de880102a9cfa230e10b33e
[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 Xavier Claessens <xclaesse@gmail.com>
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  */
21
22 #include <config.h>
23
24 #include <stdlib.h>
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28
29 #include <libempathy/gossip-contact.h>
30 #include <libempathy/empathy-session.h>
31 #include <libempathy-gtk/gossip-contact-list.h>
32 #include <libempathy-gtk/gossip-private-chat.h>
33 #include <libempathy-gtk/gossip-stock.h>
34
35 static void
36 destroy_cb (GtkWidget *window,
37             gpointer   user_data)
38 {
39         gossip_stock_finalize ();
40         empathy_session_finalize ();
41         gtk_main_quit ();
42 }
43
44 static void
45 contact_chat_cb (GtkWidget     *list,
46                  GossipContact *contact,
47                  gpointer       user_data)
48 {
49         mission_control_request_channel (empathy_session_get_mission_control (),
50                                          gossip_contact_get_account (contact),
51                                          TP_IFACE_CHANNEL_TYPE_TEXT,
52                                          gossip_contact_get_handle (contact),
53                                          TP_HANDLE_TYPE_CONTACT,
54                                          NULL, NULL);
55 }
56
57 int
58 main (int argc, char *argv[])
59 {
60         GtkWidget *window;
61         GtkWidget *list;
62         GtkWidget *sw;
63
64         gtk_init (&argc, &argv);
65
66         empathy_session_connect ();
67
68         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
69         gossip_stock_init (window);
70
71         list = GTK_WIDGET (gossip_contact_list_new ());
72         sw = gtk_scrolled_window_new (NULL, NULL);      
73         gtk_container_add (GTK_CONTAINER (window), sw);
74         gtk_container_add (GTK_CONTAINER (sw), list);
75
76         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
77                                         GTK_POLICY_AUTOMATIC,
78                                         GTK_POLICY_AUTOMATIC);
79         gtk_widget_set_size_request (sw, 200, 400);
80
81         g_signal_connect (window, "destroy",
82                           G_CALLBACK (destroy_cb),
83                           NULL);
84         g_signal_connect (list, "contact-chat",
85                           G_CALLBACK (contact_chat_cb),
86                           NULL);
87
88         gtk_widget_show_all (window);
89
90         gtk_main ();
91
92         return EXIT_SUCCESS;
93 }
94