5 #include <libempathy/empathy-contact-manager.h>
6 #include <libempathy/empathy-dispatcher.h>
8 #include <libempathy-gtk/empathy-ui-utils.h>
9 #include <libempathy-gtk/empathy-contact-list-store.h>
10 #include <libempathy-gtk/empathy-contact-selector.h>
12 static GtkWidget *window = NULL;
15 chat_cb (EmpathyDispatchOperation *dispatch,
23 dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
24 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
25 error->message ? error->message : "No error message");
27 gtk_dialog_run (GTK_DIALOG (dialog));
30 gtk_widget_destroy (window);
34 clicked_cb (GtkButton *button,
37 EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (data);
38 EmpathyContact *contact;
40 contact = empathy_contact_selector_get_selected (selector);
45 /* This is required otherwise the dispatcher isn't ref'd, and so it
46 * disappears by the time the callback gets called. It's deliberately not
47 * freed otherwise it segfaults... sigh */
48 empathy_dispatcher_dup_singleton ();
49 empathy_dispatcher_chat_with_contact (contact, chat_cb, NULL);
55 EmpathyContactManager *manager;
56 EmpathyContactListStore *store;
57 GtkWidget *vbox, *button, *selector;
59 gtk_init (&argc, &argv);
63 manager = empathy_contact_manager_dup_singleton ();
64 store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (manager));
66 vbox = gtk_vbox_new (FALSE, 2);
68 selector = empathy_contact_selector_new (store);
69 gtk_box_pack_start (GTK_BOX (vbox), selector, FALSE, FALSE, 5);
71 button = gtk_button_new_with_label ("Chat");
72 g_signal_connect (G_OBJECT (button), "clicked",
73 G_CALLBACK (clicked_cb), (gpointer) selector);
74 gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 5);
76 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
77 g_signal_connect (G_OBJECT (window), "destroy",
79 gtk_window_set_title (GTK_WINDOW (window),"Empetit");
80 gtk_container_set_border_width (GTK_CONTAINER (window), 5);
81 gtk_container_add (GTK_CONTAINER (window), vbox);
82 gtk_widget_show_all (window);
86 g_object_unref (store);
87 g_object_unref (manager);