From: Jonny Lamb Date: Fri, 30 Jan 2009 17:34:47 +0000 (+0000) Subject: Updated empetit to use the new dispatcher. X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=c0c10affc5a017649df2ebcc2930741ed0256225 Updated empetit to use the new dispatcher. Signed-off-by: Jonny Lamb svn path=/trunk/; revision=2338 --- diff --git a/tests/empetit.c b/tests/empetit.c index 6ba5a2ad..03c6ce6c 100644 --- a/tests/empetit.c +++ b/tests/empetit.c @@ -8,6 +8,7 @@ #include #include +static GtkWidget *window = NULL; static void destroy_cb (GtkWidget *widget, @@ -17,6 +18,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);