~bcurtiswx/ubuntu/precise/empathy/3.4.2.1-0ubuntu1

« back to all changes in this revision

Viewing changes to tests/empetit.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-11-16 23:40:52 UTC
  • mfrom: (1.1.39 upstream)
  • mto: (6.3.7 experimental)
  • mto: This revision was merged to the branch mainline in revision 80.
  • Revision ID: james.westby@ubuntu.com-20091116234052-7hhwrpeln4mwdyw7
Tags: upstream-2.29.2
ImportĀ upstreamĀ versionĀ 2.29.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "config.h"
2
 
 
3
 
#include <gtk/gtk.h>
4
 
 
5
 
#include <libempathy/empathy-contact-manager.h>
6
 
#include <libempathy/empathy-dispatcher.h>
7
 
 
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>
11
 
 
12
 
static GtkWidget *window = NULL;
13
 
 
14
 
static void
15
 
chat_cb (EmpathyDispatchOperation *dispatch,
16
 
         const GError *error,
17
 
         gpointer user_data)
18
 
{
19
 
  GtkWidget *dialog;
20
 
 
21
 
  if (error != NULL)
22
 
    {
23
 
      dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
24
 
          GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s",
25
 
          error->message ? error->message : "No error message");
26
 
 
27
 
      gtk_dialog_run (GTK_DIALOG (dialog));
28
 
    }
29
 
 
30
 
  gtk_widget_destroy (window);
31
 
}
32
 
 
33
 
static void
34
 
clicked_cb (GtkButton *button,
35
 
            gpointer data)
36
 
{
37
 
  EmpathyContactSelector *selector = EMPATHY_CONTACT_SELECTOR (data);
38
 
  EmpathyContact *contact;
39
 
 
40
 
  contact = empathy_contact_selector_dup_selected (selector);
41
 
 
42
 
  if (!contact)
43
 
    return;
44
 
 
45
 
  empathy_dispatcher_chat_with_contact (contact, chat_cb, NULL);
46
 
 
47
 
  g_object_unref (contact);
48
 
}
49
 
 
50
 
int main (int argc,
51
 
          char *argv[])
52
 
{
53
 
  EmpathyContactManager *manager;
54
 
  GtkWidget *vbox, *button, *selector;
55
 
 
56
 
  gtk_init (&argc, &argv);
57
 
 
58
 
  empathy_gtk_init ();
59
 
 
60
 
  manager = empathy_contact_manager_dup_singleton ();
61
 
  selector = empathy_contact_selector_new (EMPATHY_CONTACT_LIST (manager));
62
 
 
63
 
  empathy_contact_selector_set_visible (EMPATHY_CONTACT_SELECTOR (selector),
64
 
      (EmpathyContactSelectorFilterFunc) empathy_contact_can_send_files, NULL);
65
 
 
66
 
  vbox = gtk_vbox_new (FALSE, 2);
67
 
 
68
 
  gtk_box_pack_start (GTK_BOX (vbox), selector, FALSE, FALSE, 5);
69
 
 
70
 
  button = gtk_button_new_with_label ("Chat");
71
 
  g_signal_connect (G_OBJECT (button), "clicked",
72
 
      G_CALLBACK (clicked_cb), (gpointer) selector);
73
 
  gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 5);
74
 
 
75
 
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
76
 
  g_signal_connect (G_OBJECT (window), "destroy",
77
 
      gtk_main_quit, NULL);
78
 
  gtk_window_set_title (GTK_WINDOW (window),"Empetit");
79
 
  gtk_container_set_border_width (GTK_CONTAINER (window), 5);
80
 
  gtk_container_add (GTK_CONTAINER (window), vbox);
81
 
  gtk_widget_show_all (window);
82
 
 
83
 
  gtk_main ();
84
 
 
85
 
  g_object_unref (manager);
86
 
 
87
 
  return 0;
88
 
}