aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/empetit.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/empetit.c b/tests/empetit.c
index 6ba5a2ad4..03c6ce6cc 100644
--- a/tests/empetit.c
+++ b/tests/empetit.c
@@ -8,6 +8,7 @@
#include <libempathy-gtk/empathy-contact-list-store.h>
#include <libempathy-gtk/empathy-contact-selector.h>
+static GtkWidget *window = NULL;
static void
destroy_cb (GtkWidget *widget,
@@ -18,6 +19,25 @@ destroy_cb (GtkWidget *widget,
static void
+chat_cb (EmpathyDispatchOperation *dispatch,
+ const GError *error,
+ gpointer user_data)
+{
+ GtkWidget *dialog;
+
+ if (error != NULL)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ error->message ? error->message : "No error message");
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ }
+
+ gtk_widget_destroy (window);
+}
+
+static void
clicked_cb (GtkButton *button,
gpointer data)
{
@@ -29,17 +49,20 @@ clicked_cb (GtkButton *button,
if (!contact)
return;
- empathy_dispatcher_chat_with_contact (contact);
+ /* This is required otherwise the dispatcher isn't ref'd, and so it
+ * disappears by the time the callback gets called. It's deliberately not
+ * freed otherwise it segfaults... sigh */
+ empathy_dispatcher_dup_singleton ();
+ empathy_dispatcher_chat_with_contact (contact, chat_cb, NULL);
}
-
int main (int argc,
char *argv[])
{
EmpathyContactManager *manager;
EmpathyContactListStore *store;
EmpathyContactSelector *selector;
- GtkWidget *window, *vbox, *button;
+ GtkWidget *vbox, *button;
gchar *icon_path;
gtk_init (&argc, &argv);