コード例 #1
0
static void
contact_widget_groups_setup (EmpathyContactWidget *information)
{
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS)
    {
      information->manager = empathy_contact_manager_dup_singleton ();
      contact_widget_model_setup (information);
    }
}
コード例 #2
0
GtkWidget *
empathy_contact_add_menu_item_new (EmpathyContact *contact)
{
	GtkWidget *item;
	GtkWidget *image;
	EmpathyContactManager *manager;
	TpConnection *connection;
	GList *l, *members;
	gboolean found = FALSE;
	EmpathyContactListFlags flags;

	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);

	if (!empathy_contact_manager_initialized ()) {
		return NULL;
	}

	manager = empathy_contact_manager_dup_singleton ();
	connection = empathy_contact_get_connection (contact);

	flags = empathy_contact_manager_get_flags_for_connection (manager,
			connection);

	if (!(flags & EMPATHY_CONTACT_LIST_CAN_ADD)) {
		return NULL;
	}

	members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (manager));
	for (l = members; l; l = l->next) {
		if (!found && empathy_contact_equal (l->data, contact)) {
			found = TRUE;
			/* we keep iterating so that we don't leak contact
			 * refs */
		}

		g_object_unref (l->data);
	}
	g_list_free (members);
	g_object_unref (manager);

	if (found) {
		return NULL;
	}

	item = gtk_image_menu_item_new_with_mnemonic (_("_Add Contact…"));
	image = gtk_image_new_from_icon_name (GTK_STOCK_ADD,
					      GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);

	g_signal_connect (item, "activate",
			G_CALLBACK (empathy_contact_add_menu_item_activated),
			contact);

	return item;
}
static gboolean
can_add_contact_to_account (McAccount *account,
			    gpointer   user_data)
{
	EmpathyContactManager *mgr;
	gboolean               result;

	mgr = empathy_contact_manager_dup_singleton ();
	result = empathy_contact_manager_can_add (mgr, account);
	g_object_unref (mgr);

	return result;
}
コード例 #4
0
static GtkWidget *
get_contacts_widget (NstPlugin *plugin)
{
  EmpathyContactManager *manager;
  GtkWidget *selector;

  manager = empathy_contact_manager_dup_singleton ();
  selector = empathy_contact_selector_new (EMPATHY_CONTACT_LIST (manager));

  empathy_contact_selector_set_visible (EMPATHY_CONTACT_SELECTOR (selector),
      (EmpathyContactSelectorFilterFunc) empathy_contact_can_send_files, NULL);

  g_object_unref (manager);

  return selector;
}
コード例 #5
0
ファイル: megaphone-applet.c プロジェクト: james-w/empathy
static void
megaphone_applet_show_preferences (MegaphoneApplet *applet)
{
	GtkWidget               *dialog;
	GtkWidget               *scroll;
	EmpathyContactListView  *contact_list;
	EmpathyContactListStore *contact_store;
	EmpathyContactManager   *contact_manager;

	dialog = gtk_dialog_new_with_buttons (_("Select contact..."),
					      NULL, 0,
					      GTK_STOCK_CANCEL,
					      GTK_RESPONSE_REJECT,
					      GTK_STOCK_OK,
					      GTK_RESPONSE_ACCEPT,
					      NULL);

	/* Show all contacts, even offline and sort alphabetically */
	contact_manager = empathy_contact_manager_dup_singleton ();
	contact_store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (contact_manager));
	g_object_set (contact_store,
		      "is-compact", TRUE,
		      "show-avatars", TRUE,
		      "show-offline", TRUE,
		      "sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME,
		      NULL);
	contact_list = empathy_contact_list_view_new (contact_store,
						      EMPATHY_CONTACT_LIST_FEATURE_NONE,
						      EMPATHY_CONTACT_FEATURE_NONE);
	g_object_unref (contact_manager);
	g_object_unref (contact_store);
	gtk_widget_show (GTK_WIDGET (contact_list));

	gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 500);
	scroll = gtk_scrolled_window_new (NULL, NULL);
	gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (contact_list));
	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), scroll);
	gtk_widget_show (scroll);
	
	g_object_set_data (G_OBJECT (dialog), "contact-list", contact_list);

	g_signal_connect (dialog, "response",
			  G_CALLBACK (megaphone_applet_preferences_response_cb),
			  applet);

	gtk_widget_show (dialog);
}
コード例 #6
0
static void
favourite_menu_item_toggled_cb (GtkCheckMenuItem *item,
	EmpathyContact *contact)
{
	EmpathyContactManager *manager;
	EmpathyContactList *list;

	manager = empathy_contact_manager_dup_singleton ();
	list = EMPATHY_CONTACT_LIST (manager);

	if (gtk_check_menu_item_get_active (item)) {
		empathy_contact_list_add_to_favourites (list, contact);
	} else {
		empathy_contact_list_remove_from_favourites (list, contact);
	}

	g_object_unref (manager);
}
コード例 #7
0
static gboolean
can_add_contact_to_account (EmpathyAccount *account,
			    gpointer   user_data)
{
	EmpathyContactManager *contact_manager;
	TpConnection          *connection;
	gboolean               result;

	connection = empathy_account_get_connection (account);
	if (connection == NULL)
		return FALSE;

	contact_manager = empathy_contact_manager_dup_singleton ();
	result = empathy_contact_manager_can_add (contact_manager, connection);
	g_object_unref (contact_manager);

	return result;
}
コード例 #8
0
int
main (int argc,
    char **argv)
  {
    EmpathyContactManager *manager;
    GtkWidget *dialog;

    gtk_init (&argc, &argv);
    empathy_gtk_init ();

    manager = empathy_contact_manager_dup_singleton ();
    dialog = empathy_contact_blocking_dialog_new (NULL);

    gtk_dialog_run (GTK_DIALOG (dialog));

    g_object_unref (manager);
    return 0;
  }
コード例 #9
0
GtkWidget *
empathy_contact_favourite_menu_item_new (EmpathyContact *contact)
{
	GtkWidget *item;
	EmpathyContactManager *manager;

	item = gtk_check_menu_item_new_with_label (_("Favorite"));

	manager = empathy_contact_manager_dup_singleton ();
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
		empathy_contact_list_is_favourite (EMPATHY_CONTACT_LIST (manager),
						   contact));

	g_signal_connect (item, "toggled",
			  G_CALLBACK (favourite_menu_item_toggled_cb),
			  contact);

	g_object_unref (manager);
	return item;
}
コード例 #10
0
static void
new_contact_response_cb (GtkDialog *dialog,
			 gint       response,
			 GtkWidget *contact_widget)
{
	EmpathyContactManager *manager;
	EmpathyContact         *contact;

	manager = empathy_contact_manager_dup_singleton ();
	contact = empathy_contact_widget_get_contact (contact_widget);

	if (contact && response == GTK_RESPONSE_OK) {
		empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
					  contact, "");
	}

	new_contact_dialog = NULL;
	gtk_widget_destroy (GTK_WIDGET (dialog));
	g_object_unref (manager);
}
コード例 #11
0
static void
empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
					 EmpathyContact   *contact)
{
	static guint block_signal = 0;
	EmpathyContactManager *manager;
	gboolean blocked, abusive;

	if (block_signal > 0)
		return;

	blocked = gtk_check_menu_item_get_active (item);

	if (blocked) {
		/* confirm the user really wishes to block the contact */
		GtkWidget *parent;
		GdkPixbuf *avatar;

		/* gtk_menu_get_attach_widget () doesn't behave properly here
		 * for some reason */
		parent = g_object_get_data (
			G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (item))),
			"window");

		avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 48, 48);

		if (!empathy_block_contact_dialog_show (GTK_WINDOW (parent),
					contact, avatar, &abusive))
			return;
	}

	manager = empathy_contact_manager_dup_singleton ();
	empathy_contact_list_set_blocked (EMPATHY_CONTACT_LIST (manager),
					  contact, blocked, abusive);
	g_object_unref (manager);

	/* update the toggle with the blocked status */
	block_signal++;
	gtk_check_menu_item_set_active (item, blocked);
	block_signal--;
}
コード例 #12
0
GtkWidget *
empathy_contact_edit_menu_item_new (EmpathyContact *contact)
{
	EmpathyContactManager *manager;
	GtkWidget *item;
	GtkWidget *image;
	gboolean enable = FALSE;

	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);

	if (empathy_contact_manager_initialized ()) {
		TpConnection *connection;
		EmpathyContactListFlags flags;

		manager = empathy_contact_manager_dup_singleton ();
		connection = empathy_contact_get_connection (contact);
		flags = empathy_contact_manager_get_flags_for_connection (
				manager, connection);

		enable = (flags & EMPATHY_CONTACT_LIST_CAN_ALIAS ||
		          flags & EMPATHY_CONTACT_LIST_CAN_GROUP);

		g_object_unref (manager);
	}

	item = gtk_image_menu_item_new_with_mnemonic (
						     C_("Edit contact (contextual menu)",
						        "_Edit"));
	image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
					      GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
	gtk_widget_show (image);

	gtk_widget_set_sensitive (item, enable);

	g_signal_connect_swapped (item, "activate",
				  G_CALLBACK (contact_edit_menu_item_activate_cb),
				  contact);

	return item;
}
コード例 #13
0
static GtkWidget *
empathy_contact_block_menu_item_new (EmpathyContact *contact)
{
	GtkWidget *item;
	EmpathyContactManager *manager;
	TpConnection *connection;
	EmpathyContactListFlags flags;
	gboolean blocked;

	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);

	manager = empathy_contact_manager_dup_singleton ();

	if (!empathy_contact_manager_initialized ()) {
		return NULL;
	}

	connection = empathy_contact_get_connection (contact);

	flags = empathy_contact_manager_get_flags_for_connection (manager,
			connection);

	if (!(flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)) {
		return NULL;
	}

	item = gtk_check_menu_item_new_with_mnemonic (_("_Block Contact"));
	blocked = empathy_contact_list_get_blocked (
			EMPATHY_CONTACT_LIST (manager),
			contact);

	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), blocked);

	g_signal_connect (item, "toggled",
			G_CALLBACK (empathy_contact_block_menu_item_toggled),
			contact);

	return item;
}
コード例 #14
0
static void
subscription_dialog_response_cb (GtkDialog *dialog,
				 gint       response,
				 GtkWidget *contact_widget)
{
	EmpathyContactManager *manager;
	EmpathyContact        *contact;

	manager = empathy_contact_manager_dup_singleton ();
	contact = empathy_contact_widget_get_contact (contact_widget);

	if (response == GTK_RESPONSE_YES) {
		empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager),
					  contact, "");
	}
	else if (response == GTK_RESPONSE_NO) {
		empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager),
					     contact, "");
	}

	subscription_dialogs = g_list_remove (subscription_dialogs, dialog);
	gtk_widget_destroy (GTK_WIDGET (dialog));
	g_object_unref (manager);
}
コード例 #15
0
/**
 * empathy_contact_widget_new:
 * @contact: an #EmpathyContact
 * @flags: #EmpathyContactWidgetFlags for the new contact widget
 *
 * Creates a new #EmpathyContactWidget.
 *
 * Return value: a new #EmpathyContactWidget
 */
GtkWidget *
empathy_contact_widget_new (EmpathyContact *contact,
                            EmpathyContactWidgetFlags flags)
{
  EmpathyContactWidget *information;
  GtkBuilder *gui;
  gchar *filename;

  g_return_val_if_fail (contact == NULL || EMPATHY_IS_CONTACT (contact), NULL);

  information = g_slice_new0 (EmpathyContactWidget);
  information->flags = flags;

  filename = empathy_file_lookup ("empathy-contact-widget.ui",
      "libempathy-gtk");
  gui = empathy_builder_get_file (filename,
       "vbox_contact_widget", &information->vbox_contact_widget,
       "hbox_contact", &information->hbox_contact,
       "hbox_presence", &information->hbox_presence,
       "label_alias", &information->label_alias,
       "image_state", &information->image_state,
       "table_contact", &information->table_contact,
       "vbox_avatar", &information->vbox_avatar,
       "vbox_location", &information->vbox_location,
       "subvbox_location", &information->subvbox_location,
       "label_location", &information->label_location,
#if HAVE_LIBCHAMPLAIN
       "viewport_map", &information->viewport_map,
#endif
       "vbox_groups", &information->vbox_groups,
       "entry_group", &information->entry_group,
       "button_group", &information->button_group,
       "treeview_groups", &information->treeview_groups,
       "vbox_details", &information->vbox_details,
       "table_details", &information->table_details,
       "hbox_details_requested", &information->hbox_details_requested,
       "vbox_client", &information->vbox_client,
       "table_client", &information->table_client,
       "hbox_client_requested", &information->hbox_client_requested,
       NULL);
  g_free (filename);

  empathy_builder_connect (gui, information,
      "vbox_contact_widget", "destroy", contact_widget_destroy_cb,
      "entry_group", "changed", contact_widget_entry_group_changed_cb,
      "entry_group", "activate", contact_widget_entry_group_activate_cb,
      "button_group", "clicked", contact_widget_button_group_clicked_cb,
      NULL);
  information->table_location = NULL;

  g_object_set_data (G_OBJECT (information->vbox_contact_widget),
      "EmpathyContactWidget",
      information);

  information->manager = empathy_contact_manager_dup_singleton ();

  /* Create widgets */
  contact_widget_contact_setup (information);
  contact_widget_groups_setup (information);
  contact_widget_details_setup (information);
  contact_widget_client_setup (information);

  if (contact != NULL)
    contact_widget_set_contact (information, contact);
  else if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT ||
      information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
    contact_widget_change_contact (information);

  return empathy_builder_unref_and_keep_widget (gui,
    information->vbox_contact_widget);
}
コード例 #16
0
/*
 * Block contact dialog
 */
gboolean
empathy_block_individual_dialog_show (GtkWindow *parent,
    FolksIndividual *individual,
    GdkPixbuf *avatar,
    gboolean *abusive)
{
  EmpathyContactManager *contact_manager =
    empathy_contact_manager_dup_singleton ();
  GtkWidget *dialog;
  GtkWidget *abusive_check = NULL;
  GeeSet *personas;
  GeeIterator *iter;
  GString *text = g_string_new ("");
  GString *blocked_str = g_string_new ("");
  GString *notblocked_str = g_string_new ("");
  guint npersonas_blocked = 0, npersonas_notblocked = 0;
  gboolean can_report_abuse = FALSE;
  int res;

  dialog = gtk_message_dialog_new (parent,
      GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
      _("Block %s?"),
      folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));

  if (avatar != NULL)
    {
      GtkWidget *image = gtk_image_new_from_pixbuf (avatar);
      gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
      gtk_widget_show (image);
    }

  /* build a list of personas that support blocking */
  personas = folks_individual_get_personas (individual);
  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
  while (gee_iterator_next (iter))
    {
      TpfPersona *persona = gee_iterator_get (iter);
      TpContact *contact;
      EmpathyContactListFlags flags;
      GString *s;
      char *str;

      if (!TPF_IS_PERSONA (persona))
          goto while_finish;

      contact = tpf_persona_get_contact (persona);
      if (contact == NULL)
        goto while_finish;

      flags = empathy_contact_manager_get_flags_for_connection (
          contact_manager, tp_contact_get_connection (contact));

      if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
        {
          s = blocked_str;
          npersonas_blocked++;
        }
      else
        {
          s = notblocked_str;
          npersonas_notblocked++;
        }

      if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
        can_report_abuse = TRUE;

      str = contact_pretty_name (contact);
      g_string_append_printf (s, "\n " BULLET_POINT " %s", str);
      g_free (str);

while_finish:
      g_clear_object (&persona);
    }
  g_clear_object (&iter);

  g_string_append_printf (text,
      _("Are you sure you want to block '%s' from contacting you again?"),
      folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));

  if (npersonas_blocked > 0)
    g_string_append_printf (text, "\n\n%s\n%s",
        ngettext ("The following identity will be blocked:",
                  "The following identities will be blocked:",
                  npersonas_blocked),
        blocked_str->str);

  if (npersonas_notblocked > 0)
    g_string_append_printf (text, "\n\n%s\n%s",
        ngettext ("The following identity can not be blocked:",
                  "The following identities can not be blocked:",
                  npersonas_notblocked),
        notblocked_str->str);

  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
    "%s", text->str);

  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      _("_Block"), GTK_RESPONSE_REJECT,
      NULL);

  if (can_report_abuse)
    {
      GtkWidget *vbox;

      vbox = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
      abusive_check = gtk_check_button_new_with_mnemonic (
          ngettext ("_Report this contact as abusive",
                    "_Report these contacts as abusive",
                    npersonas_blocked));

      gtk_box_pack_start (GTK_BOX (vbox), abusive_check, FALSE, TRUE, 0);
      gtk_widget_show (abusive_check);
    }

  g_object_unref (contact_manager);
  g_string_free (text, TRUE);
  g_string_free (blocked_str, TRUE);
  g_string_free (notblocked_str, TRUE);

  res = gtk_dialog_run (GTK_DIALOG (dialog));

  if (abusive != NULL)
    {
      if (abusive_check != NULL)
        *abusive = gtk_toggle_button_get_active (
            GTK_TOGGLE_BUTTON (abusive_check));
      else
        *abusive = FALSE;
    }

  gtk_widget_destroy (dialog);

  return res == GTK_RESPONSE_REJECT;
}
コード例 #17
0
GtkWidget *
empathy_main_window_show (void)
{
	EmpathyMainWindow        *window;
	EmpathyContactList       *list_iface;
	EmpathyContactMonitor    *monitor;
	GtkBuilder               *gui;
	EmpathyConf              *conf;
	GtkWidget                *sw;
	GtkToggleAction          *show_offline_widget;
	GtkWidget                *ebox;
	GtkAction                *show_map_widget;
	GtkToolItem              *item;
	gboolean                  show_offline;
	gchar                    *filename;
	GSList                   *l;

	if (main_window) {
		empathy_window_present (GTK_WINDOW (main_window->window));
		return main_window->window;
	}

	main_window = g_new0 (EmpathyMainWindow, 1);
	window = main_window;

	/* Set up interface */
	filename = empathy_file_lookup ("empathy-main-window.ui", "src");
	gui = empathy_builder_get_file (filename,
				       "main_window", &window->window,
				       "main_vbox", &window->main_vbox,
				       "errors_vbox", &window->errors_vbox,
				       "ui_manager", &window->ui_manager,
				       "view_show_offline", &show_offline_widget,
				       "view_show_protocols", &window->show_protocols,
				       "view_sort_by_name", &window->sort_by_name,
				       "view_sort_by_status", &window->sort_by_status,
				       "view_normal_size_with_avatars", &window->normal_with_avatars,
				       "view_normal_size", &window->normal_size,
				       "view_compact_size", &window->compact_size,
				       "view_history", &window->view_history,
				       "view_show_map", &show_map_widget,
				       "room_join_favorites", &window->room_join_favorites,
				       "presence_toolbar", &window->presence_toolbar,
				       "roster_scrolledwindow", &sw,
				       NULL);
	g_free (filename);

	empathy_builder_connect (gui, window,
			      "main_window", "destroy", main_window_destroy_cb,
			      "main_window", "key-press-event", main_window_key_press_event_cb,
			      "chat_quit", "activate", main_window_chat_quit_cb,
			      "chat_new_message", "activate", main_window_chat_new_message_cb,
			      "chat_new_call", "activate", main_window_chat_new_call_cb,
			      "view_history", "activate", main_window_view_history_cb,
			      "room_join_new", "activate", main_window_room_join_new_cb,
			      "room_join_favorites", "activate", main_window_room_join_favorites_cb,
			      "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
			      "chat_add_contact", "activate", main_window_chat_add_contact_cb,
			      "view_show_ft_manager", "activate", main_window_view_show_ft_manager,
			      "view_show_offline", "toggled", main_window_view_show_offline_cb,
			      "view_show_protocols", "toggled", main_window_view_show_protocols_cb,
			      "view_sort_by_name", "changed", main_window_view_sort_contacts_cb,
			      "view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb,
			      "view_show_map", "activate", main_window_view_show_map_cb,
			      "edit", "activate", main_window_edit_cb,
			      "edit_accounts", "activate", main_window_edit_accounts_cb,
			      "edit_personal_information", "activate", main_window_edit_personal_information_cb,
			      "edit_preferences", "activate", main_window_edit_preferences_cb,
			      "help_about", "activate", main_window_help_about_cb,
			      "help_debug", "activate", main_window_help_debug_cb,
			      "help_contents", "activate", main_window_help_contents_cb,
			      NULL);

	/* Set up connection related widgets. */
	main_window_connection_items_setup (window, gui);

	g_object_ref (window->ui_manager);
	g_object_unref (gui);

#if !HAVE_LIBCHAMPLAIN
	gtk_action_set_visible (show_map_widget, FALSE);
#endif

	window->account_manager = tp_account_manager_dup ();

	tp_account_manager_prepare_async (window->account_manager, NULL,
					  account_manager_prepared_cb, window);

	window->errors = g_hash_table_new_full (g_direct_hash,
						g_direct_equal,
						g_object_unref,
						NULL);

	window->status_changed_handlers = g_hash_table_new_full (g_direct_hash,
								 g_direct_equal,
								 NULL,
								 NULL);

	/* Set up menu */
	main_window_favorite_chatroom_menu_setup (window);

	window->edit_context = gtk_ui_manager_get_widget (window->ui_manager,
		"/menubar/edit/edit_context");
	window->edit_context_separator = gtk_ui_manager_get_widget (window->ui_manager,
		"/menubar/edit/edit_context_separator");
	gtk_widget_hide (window->edit_context);
	gtk_widget_hide (window->edit_context_separator);

	/* Set up contact list. */
	empathy_status_presets_get_all ();

	/* Set up presence chooser */
	window->presence_chooser = empathy_presence_chooser_new ();
	gtk_widget_show (window->presence_chooser);
	item = gtk_tool_item_new ();
	gtk_widget_show (GTK_WIDGET (item));
	gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
	gtk_tool_item_set_is_important (item, TRUE);
	gtk_tool_item_set_expand (item, TRUE);
	gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);

	/* Set up the throbber */
	ebox = gtk_event_box_new ();
	gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
	gtk_widget_set_tooltip_text (ebox, _("Show and edit accounts"));
	g_signal_connect (ebox,
			  "button-press-event",
			  G_CALLBACK (main_window_throbber_button_press_event_cb),
			  window);
	gtk_widget_show (ebox);

	window->throbber = ephy_spinner_new ();
	ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
	gtk_widget_show (window->throbber);

	item = gtk_tool_item_new ();
	gtk_container_add (GTK_CONTAINER (item), ebox);
	gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
	gtk_widget_show (GTK_WIDGET (item));

	list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ());
	monitor = empathy_contact_list_get_monitor (list_iface);
	window->list_store = empathy_contact_list_store_new (list_iface);
	window->list_view = empathy_contact_list_view_new (window->list_store,
							   EMPATHY_CONTACT_LIST_FEATURE_ALL,
							   EMPATHY_CONTACT_FEATURE_ALL);
	g_signal_connect (monitor, "contact-presence-changed",
			  G_CALLBACK (main_window_contact_presence_changed_cb), window);
	window->butterfly_log_migration_contact_added_id =  g_signal_connect (monitor, "contact-added",
			  G_CALLBACK (main_window_contact_added_cb), window);
	g_object_unref (list_iface);

	gtk_widget_show (GTK_WIDGET (window->list_view));
	gtk_container_add (GTK_CONTAINER (sw),
			   GTK_WIDGET (window->list_view));
	g_signal_connect (window->list_view, "row-activated",
			  G_CALLBACK (main_window_row_activated_cb),
			  window);

	/* Load user-defined accelerators. */
	main_window_accels_load ();

	/* Set window size. */
	empathy_geometry_bind (GTK_WINDOW (window->window), GEOMETRY_NAME);

	/* Enable event handling */
	window->event_manager = empathy_event_manager_dup_singleton ();
	g_signal_connect (window->event_manager, "event-added",
			  G_CALLBACK (main_window_event_added_cb),
			  window);
	g_signal_connect (window->event_manager, "event-removed",
			  G_CALLBACK (main_window_event_removed_cb),
			  window);

	g_signal_connect (window->account_manager, "account-validity-changed",
			  G_CALLBACK (main_window_account_validity_changed_cb),
			  window);
	g_signal_connect (window->account_manager, "account-removed",
			  G_CALLBACK (main_window_account_removed_cb),
			  window);
	g_signal_connect (window->account_manager, "account-disabled",
			  G_CALLBACK (main_window_account_disabled_cb),
			  window);

	l = empathy_event_manager_get_events (window->event_manager);
	while (l) {
		main_window_event_added_cb (window->event_manager,
					    l->data, window);
		l = l->next;
	}

	conf = empathy_conf_get ();

	/* Show offline ? */
	empathy_conf_get_bool (conf,
			      EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
			      &show_offline);
	empathy_conf_notify_add (conf,
				EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
				main_window_notify_show_offline_cb,
				show_offline_widget);

	gtk_toggle_action_set_active (show_offline_widget, show_offline);

	/* Show protocol ? */
	empathy_conf_notify_add (conf,
				 EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
				 (EmpathyConfNotifyFunc) main_window_notify_show_protocols_cb,
				 window);

	main_window_notify_show_protocols_cb (conf,
					    EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
					    window);

	/* Sort by name / by status ? */
	empathy_conf_notify_add (conf,
				 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
				 (EmpathyConfNotifyFunc) main_window_notify_sort_contact_cb,
				 window);

	main_window_notify_sort_contact_cb (conf,
					    EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
					    window);

	/* Contacts list size */
	empathy_conf_notify_add (conf,
				 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
				 (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb,
				 window);
	empathy_conf_notify_add (conf,
				 EMPATHY_PREFS_UI_SHOW_AVATARS,
				 (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb,
				 window);

	main_window_notify_contact_list_size_cb (conf,
						 EMPATHY_PREFS_UI_SHOW_AVATARS,
						 window);

	return window->window;
}