]> git.0d.be Git - empathy.git/commitdiff
Added Elliot's empetit test program.
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Fri, 30 Jan 2009 17:34:38 +0000 (17:34 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:34:38 +0000 (17:34 +0000)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=2335

tests/.gitignore
tests/Makefile.am
tests/empetit.c [new file with mode: 0644]

index b012f8091227b6060c5423e21e1ba16089713dc0..08278b7bca76ca3fa452edf6d0bf4a4b362adf15 100644 (file)
@@ -3,3 +3,4 @@ contact-manager
 contact-run-until-ready
 contact-run-until-ready-2
 *.log
+empetit
index 6736f3661816183b38a0139eb9818dcc512cae53..9a91e9d92cb7eeed777df2c55527dd44709612c1 100644 (file)
@@ -12,6 +12,7 @@ EXTRA_DIST =          \
 
 AM_CPPFLAGS =                                          \
        -I$(top_srcdir)                                 \
+       -DPKGDATADIR=\""$(pkgdatadir)"\"                \
        $(EMPATHY_CFLAGS)                               \
        $(WARN_CFLAGS)
 
@@ -23,11 +24,13 @@ LDADD =                                                             \
 noinst_PROGRAMS =                      \
        contact-manager                 \
        contact-run-until-ready         \
-       contact-run-until-ready-2
+       contact-run-until-ready-2       \
+       empetit
 
 contact_manager_SOURCES = contact-manager.c
 contact_run_until_ready_SOURCES = contact-run-until-ready.c
 contact_run_until_ready_2_SOURCES = contact-run-until-ready-2.c
+empetit_SOURCES = empetit.c
 
 check_PROGRAMS = check-main
 TESTS = check-main
diff --git a/tests/empetit.c b/tests/empetit.c
new file mode 100644 (file)
index 0000000..99f25f8
--- /dev/null
@@ -0,0 +1,78 @@
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-dispatcher.h>
+
+#include <libempathy-gtk/empathy-contact-list-store.h>
+#include <libempathy-gtk/empathy-contact-selector.h>
+
+
+static void
+destroy_cb (GtkWidget *widget,
+            gpointer data)
+{
+  gtk_main_quit ();
+}
+
+
+static void
+clicked_cb (GtkButton *button,
+            gpointer data)
+{
+  EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (data);
+  EmpathyContact *contact;
+
+  contact = empathy_contact_selector_get_selected (selector);
+
+  if (!contact)
+    return;
+
+  empathy_dispatcher_chat_with_contact (contact);
+}
+
+
+int main (int argc,
+          char *argv[])
+{
+  EmpathyContactManager *manager;
+  EmpathyContactListStore *store;
+  EmpathyContactSelector *selector;
+  GtkWidget *window, *vbox, *button;
+  gchar *icon_path;
+
+  gtk_init (&argc, &argv);
+
+  icon_path = g_build_path (G_DIR_SEPARATOR_S, PKGDATADIR, "icons", NULL);
+  gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_path);
+  g_free (icon_path);
+
+  manager = empathy_contact_manager_new ();
+  store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (manager));
+
+  vbox = gtk_vbox_new (FALSE, 2);
+
+  selector = empathy_contact_selector_new (store);
+  gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (selector), FALSE, FALSE, 5);
+
+  button = gtk_button_new_with_label ("Chat");
+  g_signal_connect (G_OBJECT (button), "clicked",
+      G_CALLBACK (clicked_cb), (gpointer) selector);
+  gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 5);
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  g_signal_connect (G_OBJECT (window), "destroy",
+      G_CALLBACK (destroy_cb), NULL);
+  gtk_window_set_title (GTK_WINDOW (window),"Empetit");
+  gtk_container_set_border_width (GTK_CONTAINER (window), 5);
+  gtk_container_add (GTK_CONTAINER (window), vbox);
+  gtk_widget_show_all (window);
+
+  gtk_main ();
+
+  g_object_unref (store);
+  g_object_unref (manager);
+
+  return 0;
+}