static void
init_infinity (GeditCollaborationWindowHelper *helper)
{
	InfGtkIo *io;
	InfCommunicationManager *communication_manager;
	InfXmppManager *xmpp_manager;
	InfCertificateCredentials *certificate_credentials;
	InfGtkBrowserModel *model_sort;

	io = inf_gtk_io_new ();
	communication_manager = inf_communication_manager_new ();
	xmpp_manager = inf_xmpp_manager_new ();
	certificate_credentials = inf_certificate_credentials_new ();

	helper->priv->io = INF_IO (io);
	helper->priv->certificate_credentials = certificate_credentials;
	helper->priv->browser_store = inf_gtk_browser_store_new (INF_IO (io),
	                                                         communication_manager);

	model_sort = INF_GTK_BROWSER_MODEL (
		inf_gtk_browser_model_sort_new (
			INF_GTK_BROWSER_MODEL (helper->priv->browser_store)
		)
	);

	gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model_sort),
	                                         compare_func,
	                                         NULL,
	                                         NULL);

	helper->priv->browser_view =
		inf_gtk_browser_view_new_with_model (model_sort);

	gtk_widget_show (helper->priv->browser_view);

	g_signal_connect_after (helper->priv->browser_store,
	                        "set-browser",
	                        G_CALLBACK (on_set_browser),
	                        helper);

	g_signal_connect (helper->priv->browser_view,
	                  "selection-changed",
	                  G_CALLBACK (on_selection_changed),
	                  helper);

	g_signal_connect (helper->priv->browser_view,
	                  "populate-popup",
	                  G_CALLBACK (on_populate_popup),
	                  helper);

	g_signal_connect (helper->priv->browser_view,
	                  "activate",
	                  G_CALLBACK (on_browser_activate),
	                  helper);

#ifdef LIBINFINITY_HAVE_AVAHI
	init_infinity_discovery (helper, xmpp_manager);
#endif

	init_bookmarks (helper);

	g_object_unref (communication_manager);
	g_object_unref (xmpp_manager);
}
int
main(int argc,
     char* argv[])
{
  InfGtkIo* io;
  InfConnectionManager* connection_manager;
#ifdef LIBINFINITY_HAVE_AVAHI
  InfXmppManager* xmpp_manager;
  InfDiscoveryAvahi* avahi;
#endif
  InfGtkBrowserStore* store;
  GtkWidget* view;
  GtkWidget* scroll;
  GtkWidget* window;

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

  io = inf_gtk_io_new();
#ifdef LIBINFINITY_HAVE_AVAHI
  xmpp_manager = inf_xmpp_manager_new();
  avahi = inf_discovery_avahi_new(INF_IO(io), xmpp_manager, NULL, NULL, NULL);
  g_object_unref(G_OBJECT(xmpp_manager));
#endif

  connection_manager = inf_connection_manager_new();
  store = inf_gtk_browser_store_new(INF_IO(io), connection_manager, NULL);
  g_object_unref(G_OBJECT(connection_manager));
  g_object_unref(G_OBJECT(io));

  g_signal_connect(
    G_OBJECT(store),
    "set-browser",
    G_CALLBACK(on_set_browser),
    NULL
  );

#ifdef LIBINFINITY_HAVE_AVAHI
  inf_gtk_browser_store_add_discovery(store, INF_DISCOVERY(avahi));
  g_object_unref(G_OBJECT(avahi));
#endif

  view = inf_gtk_browser_view_new_with_model(INF_GTK_BROWSER_MODEL(store));
  g_object_unref(G_OBJECT(store));
  gtk_widget_show(view);

  g_signal_connect(
    G_OBJECT(view),
    "activate",
    G_CALLBACK(on_activate),
    NULL
  );

  scroll = gtk_scrolled_window_new(NULL, NULL);

  gtk_scrolled_window_set_policy(
    GTK_SCROLLED_WINDOW(scroll),
    GTK_POLICY_AUTOMATIC,
    GTK_POLICY_AUTOMATIC
  );
  
  gtk_scrolled_window_set_shadow_type(
    GTK_SCROLLED_WINDOW(scroll),
    GTK_SHADOW_IN
  );

  gtk_container_add(GTK_CONTAINER(scroll), view);
  gtk_widget_show(scroll);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window),"Infinote Browser");
  gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
  gtk_window_set_icon_name(GTK_WINDOW(window), "infinote");
  gtk_container_set_border_width(GTK_CONTAINER(window), 6);
  gtk_container_add(GTK_CONTAINER(window), scroll);
  gtk_widget_show(window);
  
  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_destroy), NULL);

  gtk_main();
  return 0;
}