コード例 #1
0
ファイル: dates_navigator.c プロジェクト: GNOME/dates
/*
 * Populate the navigator with events from given calendar matching query,
 * using the specified format
 */
void
dates_navigator_model_populate (DatesNavigatorModel * nav, ECal * ecal,
								const gchar * query, DNTimeFormat format)
{
	GError * error = NULL;
	GtkListStore * store =
		GTK_LIST_STORE (gtk_tree_model_filter_get_model (
							GTK_TREE_MODEL_FILTER (nav)));

	g_return_if_fail (store);
	
	if (nav->priv->cview)
	{
		g_object_unref (nav->priv->cview);
		nav->priv->cview = NULL;
	}

	gtk_list_store_clear  (store);

	e_cal_get_query (ecal, query, &nav->priv->cview, &error);
	
	if (error)
	{
		g_warning ("%s: %s (%s)", __FUNCTION__, error->message, query);
		g_error_free (error);
		return;
	}

	/* Attach signals and start view */
	g_signal_connect (nav->priv->cview, "objects-added",
					  G_CALLBACK (ecal_objects_changed), nav);
	g_signal_connect (nav->priv->cview, "objects-modified",
					  G_CALLBACK (ecal_objects_changed), nav);
	g_signal_connect (nav->priv->cview, "objects-removed",
					  G_CALLBACK (ecal_objects_removed), nav);

	nav->priv->format = format;
	
	e_cal_view_start (nav->priv->cview);
}
コード例 #2
0
/* Creates a calendar client and tries to load the specified URI into it */
static void
create_client (ECal **client,
               const gchar *uri,
               ECalSourceType type,
               gboolean only_if_exists)
{
	const gchar *results;
	ECalView *query;
	gchar *cal_uri;
	GError *error = NULL;

	cal_uri = g_strconcat ("file://", uri, NULL);
	/* FIXME We don't build ECals from URIs anymore. */
	/* *client = e_cal_new_from_uri (cal_uri, type); */
	*client = NULL;
	if (!*client) {
		g_message (G_STRLOC ": could not create the client");
		exit (1);
	}

	g_object_weak_ref (G_OBJECT (*client), client_destroy_cb, NULL);

	cl_printf (*client, "Calendar loading `%s'...\n", uri);

	if (!e_cal_open (*client, only_if_exists, &error)) {
		cl_printf (*client, "Load/create %s\n", error->message);
		exit (1);
	}
	g_clear_error (&error);

	if (!e_cal_get_query (*client, "(contains? \"any\" \"Event\")", &query, NULL)) {
		cl_printf (*client, G_STRLOC ": Unable to obtain query");
		exit (1);
	}

	g_signal_connect (
		G_OBJECT (query), "objects_added",
		G_CALLBACK (objects_added_cb), client);
	g_signal_connect (
		G_OBJECT (query), "objects_modified",
		G_CALLBACK (objects_modified_cb), client);
	g_signal_connect (
		G_OBJECT (query), "objects_removed",
		G_CALLBACK (objects_removed_cb), client);
	g_signal_connect (
		G_OBJECT (query), "view_complete",
		G_CALLBACK (view_complete_cb), client);

	e_cal_view_start (query);

	results = all_tests (*client, uri);
	cl_printf (*client, "\n\n\n*************Tests run: %d****************\n\n", tests_run);
	cl_printf (*client, "*************Tests passed: %d*************\n\n\n", tests_passed);
	if (results != NULL)
		cl_printf (*client, "***Failures********%s\n", results);

	cl_printf (*client, "dump of the test calendar data");
	list_uids (*client);
	g_free (cal_uri);

}