]> git.0d.be Git - empathy.git/commitdiff
Updated empetit to use the new dispatcher.
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 30 Jan 2009 17:34:47 +0000 (17:34 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:34:47 +0000 (17:34 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=2338

tests/empetit.c

index 6ba5a2ad417490ab64bf6781b169b71cd6bd8a21..03c6ce6ccb81b55da0de5836279025cf0575376f 100644 (file)
@@ -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,
@@ -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);