From d09d8de870b6697c8a8b262e7e077b871a69b315 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 10 Dec 2012 08:09:59 -0500 Subject: Consolidate base utility libraries into libeutil. Evolution consists of entirely too many small utility libraries, which increases linking and loading time, places a burden on higher layers of the application (e.g. modules) which has to remember to link to all the small in-tree utility libraries, and makes it difficult to generate API documentation for these utility libraries in one Gtk-Doc module. Merge the following utility libraries under the umbrella of libeutil, and enforce a single-include policy on libeutil so we can reorganize the files as desired without disrupting its pseudo-public API. libemail-utils/libemail-utils.la libevolution-utils/libevolution-utils.la filter/libfilter.la widgets/e-timezone-dialog/libetimezonedialog.la widgets/menus/libmenus.la widgets/misc/libemiscwidgets.la widgets/table/libetable.la widgets/text/libetext.la This also merges libedataserverui from the Evolution-Data-Server module, since Evolution is its only consumer nowadays, and I'd like to make some improvements to those APIs without concern for backward-compatibility. And finally, start a Gtk-Doc module for libeutil. It's going to be a project just getting all the symbols _listed_ much less _documented_. But the skeletal structure is in place and I'm off to a good start. --- e-util/test-contact-store.c | 145 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 e-util/test-contact-store.c (limited to 'e-util/test-contact-store.c') diff --git a/e-util/test-contact-store.c b/e-util/test-contact-store.c new file mode 100644 index 0000000000..59ba42502b --- /dev/null +++ b/e-util/test-contact-store.c @@ -0,0 +1,145 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* test-contact-store.c - Test program for EContactStore. + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU Lesser General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Author: Hans Petter Jansson + */ + +#include + +static void +entry_changed (GtkWidget *entry, + EContactStore *contact_store) +{ + const gchar *text; + EBookQuery *query; + + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + query = e_book_query_any_field_contains (text); + e_contact_store_set_query (contact_store, query); + e_book_query_unref (query); +} + +static GtkTreeViewColumn * +create_text_column_for_field (EContactField field_id) +{ + GtkTreeViewColumn *column; + GtkCellRenderer *cell_renderer; + + column = gtk_tree_view_column_new (); + cell_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); + gtk_tree_view_column_pack_start (column, cell_renderer, TRUE); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_column_set_title (column, e_contact_pretty_name (field_id)); + gtk_tree_view_column_add_attribute (column, cell_renderer, "text", field_id); + gtk_tree_view_column_set_sort_column_id (column, field_id); + + return column; +} + +static gint +start_test (const gchar *param) +{ + EContactStore *contact_store; + GtkTreeModel *model_sort; + GtkWidget *scrolled_window; + GtkWidget *window; + GtkWidget *tree_view; + GtkWidget *vgrid; + GtkWidget *entry; + GtkTreeViewColumn *column; +#if 0 /* ACCOUNT_MGMT */ + EBookClient *book_client; +#endif /* ACCOUNT_MGMT */ + EBookQuery *book_query; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + vgrid = g_object_new (GTK_TYPE_GRID, + "orientation", GTK_ORIENTATION_VERTICAL, + "column-homogeneous", FALSE, + "row-spacing", 2, + NULL); + gtk_container_add (GTK_CONTAINER (window), vgrid); + + entry = gtk_entry_new (); + gtk_widget_set_halign (entry, GTK_ALIGN_FILL); + gtk_container_add (GTK_CONTAINER (vgrid), entry); + + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_set_hexpand (scrolled_window, TRUE); + gtk_widget_set_halign (scrolled_window, GTK_ALIGN_FILL); + gtk_widget_set_vexpand (scrolled_window, TRUE); + gtk_widget_set_valign (scrolled_window, GTK_ALIGN_FILL); + gtk_container_add (GTK_CONTAINER (vgrid), scrolled_window); + + contact_store = e_contact_store_new (); + model_sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (contact_store)); + tree_view = GTK_WIDGET (gtk_tree_view_new ()); + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model_sort); + + column = create_text_column_for_field (E_CONTACT_FILE_AS); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + + column = create_text_column_for_field (E_CONTACT_FULL_NAME); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + + column = create_text_column_for_field (E_CONTACT_EMAIL_1); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + + gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view); + +#if 0 /* ACCOUNT_MGMT */ + book_client = e_book_client_new_default (NULL); + g_warn_if_fail (e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, NULL)); + e_contact_store_add_client (contact_store, book_client); + g_object_unref (book_client); +#endif /* ACCOUNT_MGMT */ + + book_query = e_book_query_any_field_contains (""); + e_contact_store_set_query (contact_store, book_query); + e_book_query_unref (book_query); + + g_signal_connect (entry, "changed", G_CALLBACK (entry_changed), contact_store); + + gtk_widget_show_all (window); + + return FALSE; +} + +gint +main (gint argc, + gchar **argv) +{ + const gchar *param; + + gtk_init (&argc, &argv); + + if (argc < 2) + param = "???"; + else + param = argv[1]; + + g_idle_add ((GSourceFunc) start_test, (gpointer) param); + + gtk_main (); + + return 0; +} -- cgit