[evolution-data-server] Seal up libedataserverui classes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Seal up libedataserverui classes.
- Date: Mon, 19 Apr 2010 17:36:44 +0000 (UTC)
commit 748111b1508e8a5a05c514ebbb3f701bcf5941cf
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Apr 19 13:02:10 2010 -0400
Seal up libedataserverui classes.
Move all public members to a separate private structure. This breaks
ABI and API, but we've already bumped the libedataserverui soname.
Still need to go through these classes and add GObject properties so
they're more EBinding-friendly.
libedataserverui/e-cell-renderer-color.h | 2 +-
libedataserverui/e-contact-store.c | 251 +++++++++-----
libedataserverui/e-contact-store.h | 55 ++--
libedataserverui/e-destination-store.c | 222 ++++++++-----
libedataserverui/e-destination-store.h | 64 ++--
libedataserverui/e-name-selector-dialog.c | 444 ++++++++++++++-----------
libedataserverui/e-name-selector-dialog.h | 47 +--
libedataserverui/e-name-selector-entry.c | 474 +++++++++++++--------------
libedataserverui/e-name-selector-entry.h | 74 ++---
libedataserverui/e-name-selector-list.c | 246 ++++++++------
libedataserverui/e-name-selector-list.h | 45 ++--
libedataserverui/e-name-selector-model.c | 144 +++++----
libedataserverui/e-name-selector-model.h | 91 +++--
libedataserverui/e-name-selector.c | 152 +++++----
libedataserverui/e-name-selector.h | 61 +++--
libedataserverui/e-source-combo-box.h | 7 +-
libedataserverui/e-source-selector-dialog.h | 47 ++-
libedataserverui/e-tree-model-generator.c | 254 ++++++++-------
libedataserverui/e-tree-model-generator.h | 78 ++---
19 files changed, 1542 insertions(+), 1216 deletions(-)
---
diff --git a/libedataserverui/e-cell-renderer-color.h b/libedataserverui/e-cell-renderer-color.h
index a6cd6a4..0e0da70 100644
--- a/libedataserverui/e-cell-renderer-color.h
+++ b/libedataserverui/e-cell-renderer-color.h
@@ -21,9 +21,9 @@
#ifndef _E_CELL_RENDERER_COLOR_H_
#define _E_CELL_RENDERER_COLOR_H_
-#include <glib.h>
#include <gtk/gtk.h>
+/* Standard GObject macros */
#define E_TYPE_CELL_RENDERER_COLOR \
(e_cell_renderer_color_get_type ())
#define E_CELL_RENDERER_COLOR(obj) \
diff --git a/libedataserverui/e-contact-store.c b/libedataserverui/e-contact-store.c
index 6ad47d8..f5b0feb 100644
--- a/libedataserverui/e-contact-store.c
+++ b/libedataserverui/e-contact-store.c
@@ -28,20 +28,32 @@
#include <glib/gi18n-lib.h>
#include "e-contact-store.h"
-#define ITER_IS_VALID(contact_store, iter) ((iter)->stamp == (contact_store)->stamp)
-#define ITER_GET(iter) GPOINTER_TO_INT (iter->user_data)
-#define ITER_SET(contact_store, iter, index) \
-G_STMT_START { \
- (iter)->stamp = (contact_store)->stamp; \
- (iter)->user_data = GINT_TO_POINTER (index); \
-} G_STMT_END
+#define ITER_IS_VALID(contact_store, iter) \
+ ((iter)->stamp == (contact_store)->priv->stamp)
+#define ITER_GET(iter) \
+ GPOINTER_TO_INT (iter->user_data)
+#define ITER_SET(contact_store, iter, index) \
+ G_STMT_START { \
+ (iter)->stamp = (contact_store)->priv->stamp; \
+ (iter)->user_data = GINT_TO_POINTER (index); \
+ } G_STMT_END
+
+#define E_CONTACT_STORE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_CONTACT_STORE, EContactStorePrivate))
+
+struct _EContactStorePrivate {
+ gint stamp;
+ EBookQuery *query;
+ GArray *contact_sources;
+};
static void e_contact_store_tree_model_init (GtkTreeModelIface *iface);
-G_DEFINE_TYPE_EXTENDED (EContactStore, e_contact_store, G_TYPE_OBJECT, 0,
+G_DEFINE_TYPE_WITH_CODE (
+ EContactStore, e_contact_store, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, e_contact_store_tree_model_init))
-static void e_contact_store_finalize (GObject *object);
static GtkTreeModelFlags e_contact_store_get_flags (GtkTreeModel *tree_model);
static gint e_contact_store_get_n_columns (GtkTreeModel *tree_model);
static GType e_contact_store_get_column_type (GtkTreeModel *tree_model,
@@ -88,21 +100,59 @@ static void free_contact_ptrarray (GPtrArray *contacts);
static void clear_contact_source (EContactStore *contact_store, ContactSource *source);
static void stop_view (EContactStore *contact_store, EBookView *view);
-/* ------------------ *
- * Class/object setup *
- * ------------------ */
+static void
+contact_store_dispose (GObject *object)
+{
+ EContactStorePrivate *priv;
+ gint ii;
+
+ priv = E_CONTACT_STORE_GET_PRIVATE (object);
+
+ /* Free sources and cached contacts */
+ for (ii = 0; ii < priv->contact_sources->len; ii++) {
+ ContactSource *source;
-static GObjectClass *parent_class = NULL;
+ source = &g_array_index (
+ priv->contact_sources, ContactSource, ii);
+
+ clear_contact_source (E_CONTACT_STORE (object), source);
+ free_contact_ptrarray (source->contacts);
+ g_object_unref (source->book);
+ }
+ g_array_set_size (priv->contact_sources, 0);
+
+ if (priv->query != NULL) {
+ g_object_unref (priv->query);
+ priv->query = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_contact_store_parent_class)->dispose (object);
+}
+
+static void
+contact_store_finalize (GObject *object)
+{
+ EContactStorePrivate *priv;
+
+ priv = E_CONTACT_STORE_GET_PRIVATE (object);
+
+ g_array_free (priv->contact_sources, TRUE);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_contact_store_parent_class)->finalize (object);
+}
static void
e_contact_store_class_init (EContactStoreClass *class)
{
GObjectClass *object_class;
- parent_class = g_type_class_peek_parent (class);
- object_class = (GObjectClass *) class;
+ g_type_class_add_private (class, sizeof (EContactStorePrivate));
- object_class->finalize = e_contact_store_finalize;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = contact_store_dispose;
+ object_class->finalize = contact_store_finalize;
}
static void
@@ -125,34 +175,13 @@ e_contact_store_tree_model_init (GtkTreeModelIface *iface)
static void
e_contact_store_init (EContactStore *contact_store)
{
- contact_store->stamp = g_random_int ();
- contact_store->query = NULL;
- contact_store->contact_sources = g_array_new (FALSE, FALSE, sizeof (ContactSource));
-}
+ GArray *contact_sources;
-static void
-e_contact_store_finalize (GObject *object)
-{
- EContactStore *contact_store = E_CONTACT_STORE (object);
- gint i;
+ contact_sources = g_array_new (FALSE, FALSE, sizeof (ContactSource));
- /* Free sources and cached contacts */
-
- for (i = 0; i < contact_store->contact_sources->len; i++) {
- ContactSource *source = &g_array_index (contact_store->contact_sources, ContactSource, i);
-
- clear_contact_source (contact_store, source);
-
- free_contact_ptrarray (source->contacts);
- g_object_unref (source->book);
- }
-
- g_array_free (contact_store->contact_sources, TRUE);
- if (contact_store->query)
- e_book_query_unref (contact_store->query);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ contact_store->priv = E_CONTACT_STORE_GET_PRIVATE (contact_store);
+ contact_store->priv->stamp = g_random_int ();
+ contact_store->priv->contact_sources = contact_sources;
}
/**
@@ -165,7 +194,7 @@ e_contact_store_finalize (GObject *object)
EContactStore *
e_contact_store_new (void)
{
- return E_CONTACT_STORE (g_object_new (E_TYPE_CONTACT_STORE, NULL));
+ return g_object_new (E_TYPE_CONTACT_STORE, NULL);
}
/* ------------------ *
@@ -220,12 +249,15 @@ row_changed (EContactStore *contact_store, gint n)
static gint
find_contact_source_by_book (EContactStore *contact_store, EBook *book)
{
+ GArray *array;
gint i;
- for (i = 0; i < contact_store->contact_sources->len; i++) {
+ array = contact_store->priv->contact_sources;
+
+ for (i = 0; i < array->len; i++) {
ContactSource *source;
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ source = &g_array_index (array, ContactSource, i);
if (source->book == book)
return i;
}
@@ -236,12 +268,14 @@ find_contact_source_by_book (EContactStore *contact_store, EBook *book)
EBookView *
find_contact_source_by_book_return_view(EContactStore *contact_store, EBook *book)
{
+ ContactSource *source = NULL;
+ GArray *array;
gint i;
- ContactSource *source = NULL;
+ array = contact_store->priv->contact_sources;
- for (i = 0; i < contact_store->contact_sources->len; i++) {
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ for (i = 0; i < array->len; i++) {
+ source = &g_array_index (array, ContactSource, i);
if (source->book == book)
break;
}
@@ -251,12 +285,15 @@ find_contact_source_by_book_return_view(EContactStore *contact_store, EBook *boo
static gint
find_contact_source_by_view (EContactStore *contact_store, EBookView *book_view)
{
+ GArray *array;
gint i;
- for (i = 0; i < contact_store->contact_sources->len; i++) {
+ array = contact_store->priv->contact_sources;
+
+ for (i = 0; i < array->len; i++) {
ContactSource *source;
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ source = &g_array_index (array, ContactSource, i);
if (source->book_view == book_view ||
source->book_view_pending == book_view)
return i;
@@ -268,12 +305,15 @@ find_contact_source_by_view (EContactStore *contact_store, EBookView *book_view)
static gint
find_contact_source_by_offset (EContactStore *contact_store, gint offset)
{
+ GArray *array;
gint i;
- for (i = 0; i < contact_store->contact_sources->len; i++) {
+ array = contact_store->priv->contact_sources;
+
+ for (i = 0; i < array->len; i++) {
ContactSource *source;
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ source = &g_array_index (array, ContactSource, i);
if (source->contacts->len > offset)
return i;
@@ -286,11 +326,14 @@ find_contact_source_by_offset (EContactStore *contact_store, gint offset)
static gint
find_contact_source_by_pointer (EContactStore *contact_store, ContactSource *source)
{
+ GArray *array;
gint i;
- i = ((gchar *) source - (gchar *) contact_store->contact_sources->data) / sizeof (ContactSource);
+ array = contact_store->priv->contact_sources;
+
+ i = ((gchar *) source - (gchar *) array->data) / sizeof (ContactSource);
- if (i < 0 || i >= contact_store->contact_sources->len)
+ if (i < 0 || i >= array->len)
return -1;
return i;
@@ -299,15 +342,18 @@ find_contact_source_by_pointer (EContactStore *contact_store, ContactSource *sou
static gint
get_contact_source_offset (EContactStore *contact_store, gint contact_source_index)
{
+ GArray *array;
gint offset = 0;
gint i;
- g_assert (contact_source_index < contact_store->contact_sources->len);
+ array = contact_store->priv->contact_sources;
+
+ g_assert (contact_source_index < array->len);
for (i = 0; i < contact_source_index; i++) {
ContactSource *source;
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ source = &g_array_index (array, ContactSource, i);
offset += source->contacts->len;
}
@@ -317,13 +363,16 @@ get_contact_source_offset (EContactStore *contact_store, gint contact_source_ind
static gint
count_contacts (EContactStore *contact_store)
{
+ GArray *array;
gint count = 0;
gint i;
- for (i = 0; i < contact_store->contact_sources->len; i++) {
+ array = contact_store->priv->contact_sources;
+
+ for (i = 0; i < array->len; i++) {
ContactSource *source;
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ source = &g_array_index (array, ContactSource, i);
count += source->contacts->len;
}
@@ -333,10 +382,11 @@ count_contacts (EContactStore *contact_store)
static gint
find_contact_by_view_and_uid (EContactStore *contact_store, EBookView *find_view, const gchar *find_uid)
{
- gint source_index;
+ GArray *array;
ContactSource *source;
- GPtrArray *contacts;
- gint i;
+ GPtrArray *contacts;
+ gint source_index;
+ gint i;
g_return_val_if_fail (find_uid != NULL, -1);
@@ -344,7 +394,8 @@ find_contact_by_view_and_uid (EContactStore *contact_store, EBookView *find_view
if (source_index < 0)
return -1;
- source = &g_array_index (contact_store->contact_sources, ContactSource, source_index);
+ array = contact_store->priv->contact_sources;
+ source = &g_array_index (array, ContactSource, source_index);
if (find_view == source->book_view)
contacts = source->contacts; /* Current view */
@@ -365,10 +416,13 @@ find_contact_by_view_and_uid (EContactStore *contact_store, EBookView *find_view
static gint
find_contact_by_uid (EContactStore *contact_store, const gchar *find_uid)
{
+ GArray *array;
gint i;
- for (i = 0; i < contact_store->contact_sources->len; i++) {
- ContactSource *source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ array = contact_store->priv->contact_sources;
+
+ for (i = 0; i < array->len; i++) {
+ ContactSource *source = &g_array_index (array, ContactSource, i);
gint j;
for (j = 0; j < source->contacts->len; j++) {
@@ -386,29 +440,34 @@ find_contact_by_uid (EContactStore *contact_store, const gchar *find_uid)
static EBook *
get_book_at_row (EContactStore *contact_store, gint row)
{
+ GArray *array;
ContactSource *source;
- gint source_index;
+ gint source_index;
source_index = find_contact_source_by_offset (contact_store, row);
if (source_index < 0)
return NULL;
- source = &g_array_index (contact_store->contact_sources, ContactSource, source_index);
+ array = contact_store->priv->contact_sources;
+ source = &g_array_index (array, ContactSource, source_index);
+
return source->book;
}
static EContact *
get_contact_at_row (EContactStore *contact_store, gint row)
{
+ GArray *array;
ContactSource *source;
- gint source_index;
- gint offset;
+ gint source_index;
+ gint offset;
source_index = find_contact_source_by_offset (contact_store, row);
if (source_index < 0)
return NULL;
- source = &g_array_index (contact_store->contact_sources, ContactSource, source_index);
+ array = contact_store->priv->contact_sources;
+ source = &g_array_index (array, ContactSource, source_index);
offset = get_contact_source_offset (contact_store, source_index);
row -= offset;
@@ -421,13 +480,15 @@ static gboolean
find_contact_source_details_by_view (EContactStore *contact_store, EBookView *book_view,
ContactSource **contact_source, gint *offset)
{
- gint source_index;
+ GArray *array;
+ gint source_index;
source_index = find_contact_source_by_view (contact_store, book_view);
if (source_index < 0)
return FALSE;
- *contact_source = &g_array_index (contact_store->contact_sources, ContactSource, source_index);
+ array = contact_store->priv->contact_sources;
+ *contact_source = &g_array_index (array, ContactSource, source_index);
*offset = get_contact_source_offset (contact_store, source_index);
return TRUE;
@@ -721,13 +782,13 @@ query_contact_source (EContactStore *contact_store, ContactSource *source)
g_assert (source->book != NULL);
- if (!contact_store->query) {
+ if (!contact_store->priv->query) {
clear_contact_source (contact_store, source);
return;
}
if (!e_book_is_opened (source->book) ||
- !e_book_get_book_view (source->book, contact_store->query, NULL, -1, &view, NULL))
+ !e_book_get_book_view (source->book, contact_store->priv->query, NULL, -1, &view, NULL))
view = NULL;
if (source->book_view) {
@@ -841,15 +902,18 @@ e_contact_store_find_contact (EContactStore *contact_store, const gchar *uid,
GList *
e_contact_store_get_books (EContactStore *contact_store)
{
+ GArray *array;
GList *book_list = NULL;
- gint i;
+ gint i;
g_return_val_if_fail (E_IS_CONTACT_STORE (contact_store), NULL);
- for (i = 0; i < contact_store->contact_sources->len; i++) {
+ array = contact_store->priv->contact_sources;
+
+ for (i = 0; i < array->len; i++) {
ContactSource *source;
- source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ source = &g_array_index (array, ContactSource, i);
book_list = g_list_prepend (book_list, source->book);
}
@@ -866,7 +930,8 @@ e_contact_store_get_books (EContactStore *contact_store)
void
e_contact_store_add_book (EContactStore *contact_store, EBook *book)
{
- ContactSource source;
+ GArray *array;
+ ContactSource source;
ContactSource *indexed_source;
g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
@@ -877,13 +942,14 @@ e_contact_store_add_book (EContactStore *contact_store, EBook *book)
return;
}
+ array = contact_store->priv->contact_sources;
+
memset (&source, 0, sizeof (ContactSource));
source.book = g_object_ref (book);
source.contacts = g_ptr_array_new ();
- g_array_append_val (contact_store->contact_sources, source);
+ g_array_append_val (array, source);
- indexed_source = &g_array_index (contact_store->contact_sources, ContactSource,
- contact_store->contact_sources->len - 1);
+ indexed_source = &g_array_index (array, ContactSource, array->len - 1);
query_contact_source (contact_store, indexed_source);
}
@@ -898,8 +964,9 @@ e_contact_store_add_book (EContactStore *contact_store, EBook *book)
void
e_contact_store_remove_book (EContactStore *contact_store, EBook *book)
{
+ GArray *array;
ContactSource *source;
- gint source_index;
+ gint source_index;
g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
g_return_if_fail (E_IS_BOOK (book));
@@ -910,12 +977,14 @@ e_contact_store_remove_book (EContactStore *contact_store, EBook *book)
return;
}
- source = &g_array_index (contact_store->contact_sources, ContactSource, source_index);
+ array = contact_store->priv->contact_sources;
+
+ source = &g_array_index (array, ContactSource, source_index);
clear_contact_source (contact_store, source);
free_contact_ptrarray (source->contacts);
g_object_unref (book);
- g_array_remove_index (contact_store->contact_sources, source_index); /* Preserve order */
+ g_array_remove_index (array, source_index); /* Preserve order */
}
/**
@@ -929,25 +998,27 @@ e_contact_store_remove_book (EContactStore *contact_store, EBook *book)
void
e_contact_store_set_query (EContactStore *contact_store, EBookQuery *book_query)
{
+ GArray *array;
gint i;
g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
- if (book_query == contact_store->query)
+ if (book_query == contact_store->priv->query)
return;
- if (contact_store->query)
- e_book_query_unref (contact_store->query);
+ if (contact_store->priv->query)
+ e_book_query_unref (contact_store->priv->query);
- contact_store->query = book_query;
+ contact_store->priv->query = book_query;
if (book_query)
e_book_query_ref (book_query);
/* Query books */
- for (i = 0; i < contact_store->contact_sources->len; i++) {
+ array = contact_store->priv->contact_sources;
+ for (i = 0; i < array->len; i++) {
ContactSource *contact_source;
- contact_source = &g_array_index (contact_store->contact_sources, ContactSource, i);
+ contact_source = &g_array_index (array, ContactSource, i);
query_contact_source (contact_store, contact_source);
}
}
@@ -966,7 +1037,7 @@ e_contact_store_peek_query (EContactStore *contact_store)
{
g_return_val_if_fail (E_IS_CONTACT_STORE (contact_store), NULL);
- return contact_store->query;
+ return contact_store->priv->query;
}
/* ---------------- *
diff --git a/libedataserverui/e-contact-store.h b/libedataserverui/e-contact-store.h
index e3929aa..513615e 100644
--- a/libedataserverui/e-contact-store.h
+++ b/libedataserverui/e-contact-store.h
@@ -50,41 +50,42 @@
G_BEGIN_DECLS
-typedef struct _EContactStore EContactStore;
-typedef struct _EContactStoreClass EContactStoreClass;
-
-struct _EContactStoreClass {
- GObjectClass parent_class;
-};
+typedef struct _EContactStore EContactStore;
+typedef struct _EContactStoreClass EContactStoreClass;
+typedef struct _EContactStorePrivate EContactStorePrivate;
struct _EContactStore {
- GObject parent;
-
- /* Private */
+ GObject parent;
+ EContactStorePrivate *priv;
+};
- gint stamp;
- EBookQuery *query;
- GArray *contact_sources;
+struct _EContactStoreClass {
+ GObjectClass parent_class;
};
-GType e_contact_store_get_type (void);
-EContactStore *e_contact_store_new (void);
+GType e_contact_store_get_type (void);
+EContactStore * e_contact_store_new (void);
-EBook *e_contact_store_get_book (EContactStore *contact_store, GtkTreeIter *iter);
-EContact *e_contact_store_get_contact (EContactStore *contact_store, GtkTreeIter *iter);
-gboolean e_contact_store_find_contact (EContactStore *contact_store, const gchar *uid,
- GtkTreeIter *iter);
+EBook * e_contact_store_get_book (EContactStore *contact_store,
+ GtkTreeIter *iter);
+EContact * e_contact_store_get_contact (EContactStore *contact_store,
+ GtkTreeIter *iter);
+gboolean e_contact_store_find_contact (EContactStore *contact_store,
+ const gchar *uid,
+ GtkTreeIter *iter);
/* Returns a shallow copy; free the list when done, but don't unref elements */
-GList *e_contact_store_get_books (EContactStore *contact_store);
-
-void e_contact_store_add_book (EContactStore *contact_store, EBook *book);
-void e_contact_store_remove_book (EContactStore *contact_store, EBook *book);
-
-void e_contact_store_set_query (EContactStore *contact_store, EBookQuery *book_query);
-EBookQuery *e_contact_store_peek_query (EContactStore *contact_store);
-
-EBookView *find_contact_source_by_book_return_view(EContactStore *contact_store, EBook *book);
+GList * e_contact_store_get_books (EContactStore *contact_store);
+void e_contact_store_add_book (EContactStore *contact_store,
+ EBook *book);
+void e_contact_store_remove_book (EContactStore *contact_store,
+ EBook *book);
+void e_contact_store_set_query (EContactStore *contact_store,
+ EBookQuery *book_query);
+EBookQuery * e_contact_store_peek_query (EContactStore *contact_store);
+EBookView * find_contact_source_by_book_return_view
+ (EContactStore *contact_store,
+ EBook *book);
G_END_DECLS
diff --git a/libedataserverui/e-destination-store.c b/libedataserverui/e-destination-store.c
index 4577776..c84611a 100644
--- a/libedataserverui/e-destination-store.c
+++ b/libedataserverui/e-destination-store.c
@@ -28,26 +28,37 @@
#include <glib/gi18n-lib.h>
#include "e-destination-store.h"
-#define ITER_IS_VALID(destination_store, iter) ((iter)->stamp == (destination_store)->stamp)
-#define ITER_GET(iter) GPOINTER_TO_INT (iter->user_data)
-#define ITER_SET(destination_store, iter, index) \
-G_STMT_START { \
- (iter)->stamp = (destination_store)->stamp; \
- (iter)->user_data = GINT_TO_POINTER (index); \
-} G_STMT_END
+#define ITER_IS_VALID(destination_store, iter) \
+ ((iter)->stamp == (destination_store)->priv->stamp)
+#define ITER_GET(iter) \
+ GPOINTER_TO_INT (iter->user_data)
+#define ITER_SET(destination_store, iter, index) \
+ G_STMT_START { \
+ (iter)->stamp = (destination_store)->priv->stamp; \
+ (iter)->user_data = GINT_TO_POINTER (index); \
+ } G_STMT_END
+
+#define E_DESTINATION_STORE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_DESTINATION_STORE, EDestinationStorePrivate))
+
+struct _EDestinationStorePrivate {
+ GPtrArray *destinations;
+ gint stamp;
+};
static GType column_types [E_DESTINATION_STORE_NUM_COLUMNS];
static void e_destination_store_tree_model_init (GtkTreeModelIface *iface);
-G_DEFINE_TYPE_EXTENDED (EDestinationStore, e_destination_store, G_TYPE_OBJECT, 0,
+G_DEFINE_TYPE_EXTENDED (
+ EDestinationStore, e_destination_store, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, e_destination_store_tree_model_init);
column_types [E_DESTINATION_STORE_COLUMN_NAME] = G_TYPE_STRING;
column_types [E_DESTINATION_STORE_COLUMN_EMAIL] = G_TYPE_STRING;
column_types [E_DESTINATION_STORE_COLUMN_ADDRESS] = G_TYPE_STRING;
- )
+)
-static void e_destination_store_finalize (GObject *object);
static GtkTreeModelFlags e_destination_store_get_flags (GtkTreeModel *tree_model);
static gint e_destination_store_get_n_columns (GtkTreeModel *tree_model);
static GType e_destination_store_get_column_type (GtkTreeModel *tree_model,
@@ -79,21 +90,50 @@ static gboolean e_destination_store_iter_parent (GtkTreeModel *tre
static void destination_changed (EDestinationStore *destination_store, EDestination *destination);
static void stop_destination (EDestinationStore *destination_store, EDestination *destination);
-/* ------------------ *
- * Class/object setup *
- * ------------------ */
+static void
+destination_store_dispose (GObject *object)
+{
+ EDestinationStorePrivate *priv;
+ gint ii;
-static GObjectClass *parent_class = NULL;
+ priv = E_DESTINATION_STORE_GET_PRIVATE (object);
+
+ for (ii = 0; ii < priv->destinations->len; ii++) {
+ EDestination *destination;
+
+ destination = g_ptr_array_index (priv->destinations, ii);
+ stop_destination (E_DESTINATION_STORE (object), destination);
+ g_object_unref (destination);
+ }
+ g_ptr_array_set_size (priv->destinations, 0);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_destination_store_parent_class)->dispose (object);
+}
+
+static void
+destination_store_finalize (GObject *object)
+{
+ EDestinationStorePrivate *priv;
+
+ priv = E_DESTINATION_STORE_GET_PRIVATE (object);
+
+ g_ptr_array_free (priv->destinations, TRUE);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_destination_store_parent_class)->finalize (object);
+}
static void
e_destination_store_class_init (EDestinationStoreClass *class)
{
GObjectClass *object_class;
- parent_class = g_type_class_peek_parent (class);
- object_class = (GObjectClass *) class;
+ g_type_class_add_private (class, sizeof (EDestinationStorePrivate));
- object_class->finalize = e_destination_store_finalize;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = destination_store_dispose;
+ object_class->finalize = destination_store_finalize;
}
static void
@@ -116,27 +156,10 @@ e_destination_store_tree_model_init (GtkTreeModelIface *iface)
static void
e_destination_store_init (EDestinationStore *destination_store)
{
- destination_store->stamp = g_random_int ();
- destination_store->destinations = g_ptr_array_new ();
-}
-
-static void
-e_destination_store_finalize (GObject *object)
-{
- EDestinationStore *destination_store = E_DESTINATION_STORE (object);
- gint i;
-
- for (i = 0; i < destination_store->destinations->len; i++) {
- EDestination *destination = g_ptr_array_index (destination_store->destinations, i);
-
- stop_destination (destination_store, destination);
- g_object_unref (destination);
- }
-
- g_ptr_array_free (destination_store->destinations, TRUE);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ destination_store->priv =
+ E_DESTINATION_STORE_GET_PRIVATE (destination_store);
+ destination_store->priv->destinations = g_ptr_array_new ();
+ destination_store->priv->stamp = g_random_int ();
}
/**
@@ -149,11 +172,7 @@ e_destination_store_finalize (GObject *object)
EDestinationStore *
e_destination_store_new (void)
{
- EDestinationStore *destination_store;
-
- destination_store = E_DESTINATION_STORE (g_object_new (E_TYPE_DESTINATION_STORE, NULL));
-
- return destination_store;
+ return g_object_new (E_TYPE_DESTINATION_STORE, NULL);
}
/* ------------------ *
@@ -208,10 +227,15 @@ row_changed (EDestinationStore *destination_store, gint n)
static gint
find_destination_by_pointer (EDestinationStore *destination_store, EDestination *destination)
{
+ GPtrArray *array;
gint i;
- for (i = 0; i < destination_store->destinations->len; i++) {
- EDestination *destination_here = g_ptr_array_index (destination_store->destinations, i);
+ array = destination_store->priv->destinations;
+
+ for (i = 0; i < array->len; i++) {
+ EDestination *destination_here;
+
+ destination_here = g_ptr_array_index (array, i);
if (destination_here == destination)
return i;
@@ -223,12 +247,18 @@ find_destination_by_pointer (EDestinationStore *destination_store, EDestination
static gint
find_destination_by_email (EDestinationStore *destination_store, EDestination *destination)
{
+ GPtrArray *array;
gint i;
const gchar *e_mail = e_destination_get_email (destination);
- for (i = 0; i < destination_store->destinations->len; i++) {
- EDestination *destination_here = g_ptr_array_index (destination_store->destinations, i);
- const gchar *mail = e_destination_get_email (destination_here);
+ array = destination_store->priv->destinations;
+
+ for (i = 0; i < array->len; i++) {
+ EDestination *destination_here;
+ const gchar *mail;
+
+ destination_here = g_ptr_array_index (array, i);
+ mail = e_destination_get_email (destination_here);
if (g_str_equal (e_mail, mail))
return i;
@@ -285,14 +315,16 @@ destination_changed (EDestinationStore *destination_store, EDestination *destina
EDestination *
e_destination_store_get_destination (EDestinationStore *destination_store, GtkTreeIter *iter)
{
+ GPtrArray *array;
gint index;
g_return_val_if_fail (E_IS_DESTINATION_STORE (destination_store), NULL);
g_return_val_if_fail (ITER_IS_VALID (destination_store, iter), NULL);
+ array = destination_store->priv->destinations;
index = ITER_GET (iter);
- return g_ptr_array_index (destination_store->destinations, index);
+ return g_ptr_array_index (array, index);
}
/**
@@ -308,12 +340,17 @@ GList *
e_destination_store_list_destinations (EDestinationStore *destination_store)
{
GList *destination_list = NULL;
+ GPtrArray *array;
gint i;
g_return_val_if_fail (E_IS_DESTINATION_STORE (destination_store), NULL);
- for (i = 0; i < destination_store->destinations->len; i++) {
- EDestination *destination = g_ptr_array_index (destination_store->destinations, i);
+ array = destination_store->priv->destinations;
+
+ for (i = 0; i < array->len; i++) {
+ EDestination *destination;
+
+ destination = g_ptr_array_index (array, i);
destination_list = g_list_prepend (destination_list, destination);
}
@@ -335,6 +372,8 @@ void
e_destination_store_insert_destination (EDestinationStore *destination_store,
gint index, EDestination *destination)
{
+ GPtrArray *array;
+
g_return_if_fail (E_IS_DESTINATION_STORE (destination_store));
g_return_if_fail (index >= 0);
@@ -345,18 +384,18 @@ e_destination_store_insert_destination (EDestinationStore *destination_store,
g_object_ref (destination);
- index = MIN (index, destination_store->destinations->len);
+ array = destination_store->priv->destinations;
+ index = MIN (index, array->len);
- g_ptr_array_set_size (destination_store->destinations,
- destination_store->destinations->len + 1);
+ g_ptr_array_set_size (array, array->len + 1);
- if (destination_store->destinations->len - 1 - index > 0) {
- memmove (destination_store->destinations->pdata + index + 1,
- destination_store->destinations->pdata + index,
- (destination_store->destinations->len - 1 - index) * sizeof (gpointer));
+ if (array->len - 1 - index > 0) {
+ memmove (array->pdata + index + 1,
+ array->pdata + index,
+ (array->len - 1 - index) * sizeof (gpointer));
}
- destination_store->destinations->pdata [index] = destination;
+ array->pdata[index] = destination;
start_destination (destination_store, destination);
row_inserted (destination_store, index);
}
@@ -372,6 +411,8 @@ e_destination_store_insert_destination (EDestinationStore *destination_store,
void
e_destination_store_append_destination (EDestinationStore *destination_store, EDestination *destination)
{
+ GPtrArray *array;
+
g_return_if_fail (E_IS_DESTINATION_STORE (destination_store));
if (find_destination_by_email (destination_store, destination) >= 0 && !e_destination_is_evolution_list (destination)) {
@@ -379,11 +420,12 @@ e_destination_store_append_destination (EDestinationStore *destination_store, ED
return;
}
+ array = destination_store->priv->destinations;
g_object_ref (destination);
- g_ptr_array_add (destination_store->destinations, destination);
+ g_ptr_array_add (array, destination);
start_destination (destination_store, destination);
- row_inserted (destination_store, destination_store->destinations->len - 1);
+ row_inserted (destination_store, array->len - 1);
}
/**
@@ -397,6 +439,7 @@ e_destination_store_append_destination (EDestinationStore *destination_store, ED
void
e_destination_store_remove_destination (EDestinationStore *destination_store, EDestination *destination)
{
+ GPtrArray *array;
gint n;
g_return_if_fail (E_IS_DESTINATION_STORE (destination_store));
@@ -410,7 +453,8 @@ e_destination_store_remove_destination (EDestinationStore *destination_store, ED
stop_destination (destination_store, destination);
g_object_unref (destination);
- g_ptr_array_remove_index (destination_store->destinations, n);
+ array = destination_store->priv->destinations;
+ g_ptr_array_remove_index (array, n);
row_deleted (destination_store, n);
}
@@ -418,21 +462,23 @@ void
e_destination_store_remove_destination_nth (EDestinationStore *destination_store, gint n)
{
EDestination *destination;
+ GPtrArray *array;
- g_return_if_fail ( n >= 0);
+ g_return_if_fail (n >= 0);
- destination = g_ptr_array_index(destination_store->destinations, n);
+ array = destination_store->priv->destinations;
+ destination = g_ptr_array_index (array, n);
stop_destination (destination_store, destination);
g_object_unref (destination);
- g_ptr_array_remove_index (destination_store->destinations, n);
+ g_ptr_array_remove_index (array, n);
row_deleted (destination_store, n);
}
guint
e_destination_store_get_destination_count (EDestinationStore *destination_store)
{
- return destination_store->destinations->len;
+ return destination_store->priv->destinations->len;
}
/* ---------------- *
@@ -468,14 +514,19 @@ e_destination_store_get_column_type (GtkTreeModel *tree_model,
static gboolean
e_destination_store_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path)
{
- EDestinationStore *destination_store = E_DESTINATION_STORE (tree_model);
- gint index;
+ EDestinationStore *destination_store;
+ GPtrArray *array;
+ gint index;
g_return_val_if_fail (E_IS_DESTINATION_STORE (tree_model), FALSE);
g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
+ destination_store = E_DESTINATION_STORE (tree_model);
+
index = gtk_tree_path_get_indices (path)[0];
- if (index >= destination_store->destinations->len)
+ array = destination_store->priv->destinations;
+
+ if (index >= array->len)
return FALSE;
ITER_SET (destination_store, iter, index);
@@ -512,7 +563,7 @@ e_destination_store_iter_next (GtkTreeModel *tree_model,
index = ITER_GET (iter);
- if (index + 1 < destination_store->destinations->len) {
+ if (index + 1 < destination_store->priv->destinations->len) {
ITER_SET (destination_store, iter, index + 1);
return TRUE;
}
@@ -534,7 +585,7 @@ e_destination_store_iter_children (GtkTreeModel *tree_model,
return FALSE;
/* But if parent == NULL we return the list itself as children of the root. */
- if (destination_store->destinations->len <= 0)
+ if (destination_store->priv->destinations->len <= 0)
return FALSE;
ITER_SET (destination_store, iter, 0);
@@ -562,7 +613,7 @@ e_destination_store_iter_n_children (GtkTreeModel *tree_model,
g_return_val_if_fail (E_IS_DESTINATION_STORE (tree_model), -1);
if (iter == NULL)
- return destination_store->destinations->len;
+ return destination_store->priv->destinations->len;
g_return_val_if_fail (ITER_IS_VALID (destination_store, iter), -1);
return 0;
@@ -581,7 +632,7 @@ e_destination_store_iter_nth_child (GtkTreeModel *tree_model,
if (parent)
return FALSE;
- if (n < destination_store->destinations->len) {
+ if (n < destination_store->priv->destinations->len) {
ITER_SET (destination_store, iter, n);
return TRUE;
}
@@ -604,11 +655,12 @@ e_destination_store_get_value (GtkTreeModel *tree_model,
GValue *value)
{
EDestinationStore *destination_store = E_DESTINATION_STORE (tree_model);
- EDestination *destination;
- const gchar *string;
- GString *string_new;
- gint row;
- EContact *contact;
+ EDestination *destination;
+ GString *string_new;
+ EContact *contact;
+ GPtrArray *array;
+ const gchar *string;
+ gint row;
g_return_if_fail (E_IS_DESTINATION_STORE (tree_model));
g_return_if_fail (column < E_DESTINATION_STORE_NUM_COLUMNS);
@@ -616,11 +668,13 @@ e_destination_store_get_value (GtkTreeModel *tree_model,
g_value_init (value, column_types [column]);
+ array = destination_store->priv->destinations;
+
row = ITER_GET (iter);
- if (row >= destination_store->destinations->len)
+ if (row >= array->len)
return;
- destination = g_ptr_array_index (destination_store->destinations, row);
+ destination = g_ptr_array_index (array, row);
g_assert (destination);
switch (column) {
@@ -661,3 +715,11 @@ e_destination_store_get_value (GtkTreeModel *tree_model,
break;
}
}
+
+gint
+e_destination_store_get_stamp (EDestinationStore *destination_store)
+{
+ g_return_val_if_fail (E_IS_DESTINATION_STORE (destination_store), 0);
+
+ return destination_store->priv->stamp;
+}
diff --git a/libedataserverui/e-destination-store.h b/libedataserverui/e-destination-store.h
index b0a3bea..67f2a79 100644
--- a/libedataserverui/e-destination-store.h
+++ b/libedataserverui/e-destination-store.h
@@ -47,51 +47,55 @@
G_BEGIN_DECLS
-typedef struct _EDestinationStore EDestinationStore;
-typedef struct _EDestinationStoreClass EDestinationStoreClass;
+typedef struct _EDestinationStore EDestinationStore;
+typedef struct _EDestinationStoreClass EDestinationStoreClass;
+typedef struct _EDestinationStorePrivate EDestinationStorePrivate;
struct _EDestinationStore {
- GObject parent;
-
- /* Private */
-
- gint stamp;
- GPtrArray *destinations;
+ GObject parent;
+ EDestinationStorePrivate *priv;
};
struct _EDestinationStoreClass {
GObjectClass parent_class;
};
-typedef enum
-{
+typedef enum {
E_DESTINATION_STORE_COLUMN_NAME,
E_DESTINATION_STORE_COLUMN_EMAIL,
E_DESTINATION_STORE_COLUMN_ADDRESS,
-
E_DESTINATION_STORE_NUM_COLUMNS
-}
-EDestinationStoreColumnType;
+} EDestinationStoreColumnType;
-GType e_destination_store_get_type (void);
-EDestinationStore *e_destination_store_new (void);
-
-EDestination *e_destination_store_get_destination (EDestinationStore *destination_store,
- GtkTreeIter *iter);
+GType e_destination_store_get_type (void);
+EDestinationStore *
+ e_destination_store_new (void);
+EDestination * e_destination_store_get_destination
+ (EDestinationStore *destination_store,
+ GtkTreeIter *iter);
/* Returns a shallow copy; free the list when done, but don't unref elements */
-GList *e_destination_store_list_destinations (EDestinationStore *destination_store);
-
-void e_destination_store_insert_destination (EDestinationStore *destination_store,
- gint index, EDestination *destination);
-void e_destination_store_append_destination (EDestinationStore *destination_store,
- EDestination *destination);
-void e_destination_store_remove_destination (EDestinationStore *destination_store,
- EDestination *destination);
-void e_destination_store_remove_destination_nth (EDestinationStore *destination_store,
- gint n);
-guint e_destination_store_get_destination_count (EDestinationStore *destination_store);
-GtkTreePath *e_destination_store_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter);
+GList * e_destination_store_list_destinations
+ (EDestinationStore *destination_store);
+
+void e_destination_store_insert_destination
+ (EDestinationStore *destination_store,
+ gint index,
+ EDestination *destination);
+void e_destination_store_append_destination
+ (EDestinationStore *destination_store,
+ EDestination *destination);
+void e_destination_store_remove_destination
+ (EDestinationStore *destination_store,
+ EDestination *destination);
+void e_destination_store_remove_destination_nth
+ (EDestinationStore *destination_store,
+ gint n);
+guint e_destination_store_get_destination_count
+ (EDestinationStore *destination_store);
+GtkTreePath * e_destination_store_get_path (GtkTreeModel *tree_model,
+ GtkTreeIter *iter);
+gint e_destination_store_get_stamp (EDestinationStore *destination_store);
G_END_DECLS
diff --git a/libedataserverui/e-name-selector-dialog.c b/libedataserverui/e-name-selector-dialog.c
index ba89489..18b8341 100644
--- a/libedataserverui/e-name-selector-dialog.c
+++ b/libedataserverui/e-name-selector-dialog.c
@@ -35,6 +35,10 @@
#include "e-name-selector-dialog.h"
#include "e-name-selector-entry.h"
+#define E_NAME_SELECTOR_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_NAME_SELECTOR_DIALOG, ENameSelectorDialogPrivate))
+
typedef struct {
gchar *name;
@@ -52,9 +56,21 @@ typedef struct {
ENameSelectorDialog *dlg_ptr;
} SelData;
-typedef struct _ENameSelectorDialogPrivate ENameSelectorDialogPrivate;
-struct _ENameSelectorDialogPrivate
-{
+struct _ENameSelectorDialogPrivate {
+
+ EBook *pending_book;
+ ENameSelectorModel *name_selector_model;
+ GtkTreeModelSort *contact_sort;
+
+ GtkBuilder *gui;
+ GtkTreeView *contact_view;
+ GtkLabel *status_label;
+ GtkBox *destination_box;
+ GtkEntry *search_entry;
+ GtkSizeGroup *button_size_group;
+
+ GArray *sections;
+
guint destination_index;
GSList *user_query_fields;
};
@@ -84,21 +100,6 @@ static void destination_column_formatter (GtkTreeViewColumn *column, GtkCel
G_DEFINE_TYPE (ENameSelectorDialog, e_name_selector_dialog, GTK_TYPE_DIALOG)
-#define E_NAME_SELECTOR_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((obj), E_TYPE_NAME_SELECTOR_DIALOG, ENameSelectorDialogPrivate))
-
-static void
-e_name_selector_dialog_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
-}
-
-static void
-e_name_selector_dialog_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
-}
-
static void
e_name_selector_dialog_populate_categories (ENameSelectorDialog *name_selector_dialog)
{
@@ -107,7 +108,7 @@ e_name_selector_dialog_populate_categories (ENameSelectorDialog *name_selector_d
/* "Any Category" is preloaded. */
combo_box = GTK_WIDGET (gtk_builder_get_object (
- name_selector_dialog->gui, "combobox-category"));
+ name_selector_dialog->priv->gui, "combobox-category"));
if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)) == -1)
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
@@ -141,21 +142,22 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
gchar *uid;
GError *error = NULL;
- ENameSelectorDialogPrivate *priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (name_selector_dialog);
- priv->destination_index = 0;
- priv->user_query_fields = NULL;
+ name_selector_dialog->priv =
+ E_NAME_SELECTOR_DIALOG_GET_PRIVATE (name_selector_dialog);
/* Get GtkBuilder GUI */
uifile = g_build_filename (E_DATA_SERVER_UI_UIDIR,
"e-name-selector-dialog.ui",
NULL);
- name_selector_dialog->gui = gtk_builder_new ();
- gtk_builder_set_translation_domain (name_selector_dialog->gui, GETTEXT_PACKAGE);
+ name_selector_dialog->priv->gui = gtk_builder_new ();
+ gtk_builder_set_translation_domain (
+ name_selector_dialog->priv->gui, GETTEXT_PACKAGE);
- if (!gtk_builder_add_from_file (name_selector_dialog->gui, uifile, &error)) {
+ if (!gtk_builder_add_from_file (
+ name_selector_dialog->priv->gui, uifile, &error)) {
g_free (uifile);
- g_object_unref (name_selector_dialog->gui);
- name_selector_dialog->gui = NULL;
+ g_object_unref (name_selector_dialog->priv->gui);
+ name_selector_dialog->priv->gui = NULL;
g_warning ("%s: Cannot load e-name-selector-dialog.ui file, %s", G_STRFUNC, error ? error->message : "Unknown error");
@@ -167,11 +169,12 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
g_free (uifile);
- widget = GTK_WIDGET (gtk_builder_get_object (name_selector_dialog->gui, "name-selector-box"));
+ widget = GTK_WIDGET (gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "name-selector-box"));
if (!widget) {
g_warning ("%s: Cannot load e-name-selector-dialog.ui file", G_STRFUNC);
- g_object_unref (name_selector_dialog->gui);
- name_selector_dialog->gui = NULL;
+ g_object_unref (name_selector_dialog->priv->gui);
+ name_selector_dialog->priv->gui = NULL;
return;
}
@@ -179,7 +182,7 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
if (!e_book_get_addressbooks (&source_list, NULL)) {
g_warning ("ENameSelectorDialog can't find any addressbooks!");
- g_object_unref (name_selector_dialog->gui);
+ g_object_unref (name_selector_dialog->priv->gui);
return;
}
@@ -196,18 +199,23 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
/* Store pointers to relevant widgets */
- name_selector_dialog->contact_view = GTK_TREE_VIEW (
- gtk_builder_get_object (name_selector_dialog->gui, "source-tree-view"));
- name_selector_dialog->status_label = GTK_LABEL (
- gtk_builder_get_object (name_selector_dialog->gui, "status-message"));
- name_selector_dialog->destination_box = GTK_BOX (
- gtk_builder_get_object (name_selector_dialog->gui, "destination-box"));
- name_selector_dialog->search_entry = GTK_ENTRY (
- gtk_builder_get_object (name_selector_dialog->gui, "search"));
+ name_selector_dialog->priv->contact_view = GTK_TREE_VIEW (
+ gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "source-tree-view"));
+ name_selector_dialog->priv->status_label = GTK_LABEL (
+ gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "status-message"));
+ name_selector_dialog->priv->destination_box = GTK_BOX (
+ gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "destination-box"));
+ name_selector_dialog->priv->search_entry = GTK_ENTRY (
+ gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "search"));
/* Create size group for transfer buttons */
- name_selector_dialog->button_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ name_selector_dialog->priv->button_size_group =
+ gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* Set up contacts view */
@@ -218,28 +226,35 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
(GtkTreeCellDataFunc) contact_column_formatter,
name_selector_dialog, NULL);
- selection = gtk_tree_view_get_selection (name_selector_dialog->contact_view);
+ selection = gtk_tree_view_get_selection (
+ name_selector_dialog->priv->contact_view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
- gtk_tree_view_append_column (name_selector_dialog->contact_view, column);
- g_signal_connect_swapped (name_selector_dialog->contact_view, "row-activated",
- G_CALLBACK (contact_activated), name_selector_dialog);
+ gtk_tree_view_append_column (
+ name_selector_dialog->priv->contact_view, column);
+ g_signal_connect_swapped (
+ name_selector_dialog->priv->contact_view, "row-activated",
+ G_CALLBACK (contact_activated), name_selector_dialog);
/* Listen for changes to the contact selection */
- contact_selection = gtk_tree_view_get_selection (name_selector_dialog->contact_view);
+ contact_selection = gtk_tree_view_get_selection (
+ name_selector_dialog->priv->contact_view);
g_signal_connect_swapped (contact_selection, "changed",
G_CALLBACK (contact_selection_changed), name_selector_dialog);
/* Set up our data structures */
- name_selector_dialog->name_selector_model = e_name_selector_model_new ();
- name_selector_dialog->sections = g_array_new (FALSE, FALSE, sizeof (Section));
+ name_selector_dialog->priv->name_selector_model =
+ e_name_selector_model_new ();
+ name_selector_dialog->priv->sections =
+ g_array_new (FALSE, FALSE, sizeof (Section));
gconf_client = gconf_client_get_default();
uid = gconf_client_get_string (gconf_client, "/apps/evolution/addressbook/display/primary_addressbook",
NULL);
/* read user_query_fields here, because we are using it in call of setup_name_selector_model */
- priv->user_query_fields = gconf_client_get_list (gconf_client, USER_QUERY_FIELDS, GCONF_VALUE_STRING, NULL);
+ name_selector_dialog->priv->user_query_fields = gconf_client_get_list (
+ gconf_client, USER_QUERY_FIELDS, GCONF_VALUE_STRING, NULL);
g_object_unref (gconf_client);
setup_name_selector_model (name_selector_dialog);
@@ -258,19 +273,22 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
g_free (uid);
}
- label = GTK_WIDGET (gtk_builder_get_object (name_selector_dialog->gui, "AddressBookLabel"));
+ label = GTK_WIDGET (gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "AddressBookLabel"));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
gtk_widget_show (widget);
- container = GTK_WIDGET (gtk_builder_get_object (name_selector_dialog->gui, "source-menu-box"));
+ container = GTK_WIDGET (gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "source-menu-box"));
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
e_name_selector_dialog_populate_categories (name_selector_dialog);
/* Set up search-as-you-type signal */
- widget = GTK_WIDGET (gtk_builder_get_object (name_selector_dialog->gui, "search"));
+ widget = GTK_WIDGET (gtk_builder_get_object (
+ name_selector_dialog->priv->gui, "search"));
g_signal_connect_swapped (widget, "changed", G_CALLBACK (search_changed), name_selector_dialog);
/* Display initial source */
@@ -293,55 +311,47 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
gtk_widget_grab_focus (widget);
}
-/* Partial, repeatable destruction. Release references. */
static void
e_name_selector_dialog_dispose (GObject *object)
{
- ENameSelectorDialog *name_selector_dialog = E_NAME_SELECTOR_DIALOG (object);
+ ENameSelectorDialogPrivate *priv;
- remove_books (name_selector_dialog);
- shutdown_name_selector_model (name_selector_dialog);
+ priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (object);
- if (G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->dispose)
- G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->dispose (object);
+ remove_books (E_NAME_SELECTOR_DIALOG (object));
+ shutdown_name_selector_model (E_NAME_SELECTOR_DIALOG (object));
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->dispose (object);
}
-/* Final, one-time destruction. Free all. */
static void
e_name_selector_dialog_finalize (GObject *object)
{
- ENameSelectorDialog *name_selector_dialog = E_NAME_SELECTOR_DIALOG (object);
- ENameSelectorDialogPrivate *priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (name_selector_dialog);
+ ENameSelectorDialogPrivate *priv;
- if (priv && priv->user_query_fields) {
- g_slist_foreach (priv->user_query_fields, (GFunc)g_free, NULL);
- g_slist_free (priv->user_query_fields);
- priv->user_query_fields = NULL;
- }
+ priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (object);
+
+ g_slist_foreach (priv->user_query_fields, (GFunc)g_free, NULL);
+ g_slist_free (priv->user_query_fields);
- g_array_free (name_selector_dialog->sections, TRUE);
- g_object_unref (name_selector_dialog->button_size_group);
+ g_array_free (priv->sections, TRUE);
+ g_object_unref (priv->button_size_group);
- if (G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->finalize)
- G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->finalize (object);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_name_selector_dialog_parent_class)->finalize (object);
}
static void
-e_name_selector_dialog_class_init (ENameSelectorDialogClass *name_selector_dialog_class)
+e_name_selector_dialog_class_init (ENameSelectorDialogClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (name_selector_dialog_class);
-
- object_class->get_property = e_name_selector_dialog_get_property;
- object_class->set_property = e_name_selector_dialog_set_property;
- object_class->dispose = e_name_selector_dialog_dispose;
- object_class->finalize = e_name_selector_dialog_finalize;
+ GObjectClass *object_class;
- /* Install properties */
-
- /* Install signals */
-
- g_type_class_add_private (object_class, sizeof(ENameSelectorDialogPrivate));
+ g_type_class_add_private (class, sizeof (ENameSelectorDialogPrivate));
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = e_name_selector_dialog_dispose;
+ object_class->finalize = e_name_selector_dialog_finalize;
}
/**
@@ -384,11 +394,13 @@ sort_iter_to_contact_store_iter (ENameSelectorDialog *name_selector_dialog, GtkT
GtkTreeIter child_iter;
gint email_n_local;
- contact_filter = e_name_selector_model_peek_contact_filter (name_selector_dialog->name_selector_model);
+ contact_filter = e_name_selector_model_peek_contact_filter (
+ name_selector_dialog->priv->name_selector_model);
- gtk_tree_model_sort_convert_iter_to_child_iter (name_selector_dialog->contact_sort,
- &child_iter, iter);
- e_tree_model_generator_convert_iter_to_child_iter (contact_filter, iter, &email_n_local, &child_iter);
+ gtk_tree_model_sort_convert_iter_to_child_iter (
+ name_selector_dialog->priv->contact_sort, &child_iter, iter);
+ e_tree_model_generator_convert_iter_to_child_iter (
+ contact_filter, iter, &email_n_local, &child_iter);
if (email_n)
*email_n = email_n_local;
@@ -423,10 +435,11 @@ remove_books (ENameSelectorDialog *name_selector_dialog)
GList *books;
GList *l;
- if (!name_selector_dialog->name_selector_model)
+ if (!name_selector_dialog->priv->name_selector_model)
return;
- contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
+ contact_store = e_name_selector_model_peek_contact_store (
+ name_selector_dialog->priv->name_selector_model);
/* Remove books (should be just one) being viewed */
books = e_contact_store_get_books (contact_store);
@@ -437,10 +450,10 @@ remove_books (ENameSelectorDialog *name_selector_dialog)
g_list_free (books);
/* See if we have a book pending; stop loading it if so */
- if (name_selector_dialog->pending_book) {
- e_book_cancel (name_selector_dialog->pending_book, NULL);
- g_object_unref (name_selector_dialog->pending_book);
- name_selector_dialog->pending_book = NULL;
+ if (name_selector_dialog->priv->pending_book) {
+ e_book_cancel (name_selector_dialog->priv->pending_book, NULL);
+ g_object_unref (name_selector_dialog->priv->pending_book);
+ name_selector_dialog->priv->pending_book = NULL;
}
}
@@ -453,8 +466,9 @@ find_section_by_transfer_button (ENameSelectorDialog *name_selector_dialog, GtkB
{
gint i;
- for (i = 0; i < name_selector_dialog->sections->len; i++) {
- Section *section = &g_array_index (name_selector_dialog->sections, Section, i);
+ for (i = 0; i < name_selector_dialog->priv->sections->len; i++) {
+ Section *section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, i);
if (section->transfer_button == transfer_button)
return i;
@@ -468,8 +482,9 @@ find_section_by_tree_view (ENameSelectorDialog *name_selector_dialog, GtkTreeVie
{
gint i;
- for (i = 0; i < name_selector_dialog->sections->len; i++) {
- Section *section = &g_array_index (name_selector_dialog->sections, Section, i);
+ for (i = 0; i < name_selector_dialog->priv->sections->len; i++) {
+ Section *section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, i);
if (section->destination_view == tree_view)
return i;
@@ -483,8 +498,9 @@ find_section_by_name (ENameSelectorDialog *name_selector_dialog, const gchar *na
{
gint i;
- for (i = 0; i < name_selector_dialog->sections->len; i++) {
- Section *section = &g_array_index (name_selector_dialog->sections, Section, i);
+ for (i = 0; i < name_selector_dialog->priv->sections->len; i++) {
+ Section *section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, i);
if (!strcmp (name, section->name))
return i;
@@ -574,7 +590,9 @@ add_section (ENameSelectorDialog *name_selector_dialog,
widget = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.transfer_button));
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 6);
- gtk_size_group_add_widget (name_selector_dialog->button_size_group, GTK_WIDGET (section.transfer_button));
+ gtk_size_group_add_widget (
+ name_selector_dialog->priv->button_size_group,
+ GTK_WIDGET (section.transfer_button));
/*to get the image embedded in the button*/
widget = gtk_alignment_new (0.7, 0.5, 0.0, 0.0);
@@ -595,7 +613,9 @@ add_section (ENameSelectorDialog *name_selector_dialog,
widget = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.remove_button));
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, TRUE, 0);
- gtk_size_group_add_widget (name_selector_dialog->button_size_group, GTK_WIDGET (section.remove_button));
+ gtk_size_group_add_widget (
+ name_selector_dialog->priv->button_size_group,
+ GTK_WIDGET (section.remove_button));
gtk_widget_set_sensitive (GTK_WIDGET (section.remove_button), FALSE);
widget = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@@ -647,15 +667,16 @@ add_section (ENameSelectorDialog *name_selector_dialog,
gtk_widget_show_all (GTK_WIDGET (section.section_box));
/* Pack this section's box into the dialog */
- gtk_box_pack_start (name_selector_dialog->destination_box,
- GTK_WIDGET (section.section_box), TRUE, TRUE, 0);
+ gtk_box_pack_start (
+ name_selector_dialog->priv->destination_box,
+ GTK_WIDGET (section.section_box), TRUE, TRUE, 0);
- g_array_append_val (name_selector_dialog->sections, section);
+ g_array_append_val (name_selector_dialog->priv->sections, section);
/* Make sure UI is consistent */
contact_selection_changed (name_selector_dialog);
- return name_selector_dialog->sections->len - 1;
+ return name_selector_dialog->priv->sections->len - 1;
}
static void
@@ -664,9 +685,10 @@ free_section (ENameSelectorDialog *name_selector_dialog, gint n)
Section *section;
g_assert (n >= 0);
- g_assert (n < name_selector_dialog->sections->len);
+ g_assert (n < name_selector_dialog->priv->sections->len);
- section = &g_array_index (name_selector_dialog->sections, Section, n);
+ section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, n);
g_free (section->name);
gtk_widget_destroy (GTK_WIDGET (section->section_box));
@@ -678,8 +700,9 @@ model_section_added (ENameSelectorDialog *name_selector_dialog, const gchar *nam
gchar *pretty_name;
EDestinationStore *destination_store;
- e_name_selector_model_peek_section (name_selector_dialog->name_selector_model, name,
- &pretty_name, &destination_store);
+ e_name_selector_model_peek_section (
+ name_selector_dialog->priv->name_selector_model,
+ name, &pretty_name, &destination_store);
add_section (name_selector_dialog, name, pretty_name, destination_store);
g_free (pretty_name);
}
@@ -693,7 +716,8 @@ model_section_removed (ENameSelectorDialog *name_selector_dialog, const gchar *n
g_assert (section_index >= 0);
free_section (name_selector_dialog, section_index);
- g_array_remove_index (name_selector_dialog->sections, section_index);
+ g_array_remove_index (
+ name_selector_dialog->priv->sections, section_index);
}
/* -------------------- *
@@ -704,9 +728,9 @@ static void
status_message(EBookView *view, const gchar *message, ENameSelectorDialog *dialog)
{
if (message == NULL)
- gtk_label_set_text(dialog->status_label, "");
+ gtk_label_set_text (dialog->priv->status_label, "");
else
- gtk_label_set_text(dialog->status_label, message);
+ gtk_label_set_text (dialog->priv->status_label, message);
}
static void
@@ -724,19 +748,22 @@ book_opened (EBook *book, EBookStatus status, gpointer data)
if (status != E_BOOK_ERROR_OK) {
/* TODO: Handle errors gracefully */
- gtk_label_set_text(name_selector_dialog->status_label, "Error loading addressbook");
+ gtk_label_set_text(
+ name_selector_dialog->priv->status_label,
+ "Error loading addressbook");
g_warning ("ENameSelectorDialog failed to open book!");
return;
}
- contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
+ contact_store = e_name_selector_model_peek_contact_store (
+ name_selector_dialog->priv->name_selector_model);
e_contact_store_add_book (contact_store, book);
view = find_contact_source_by_book_return_view(contact_store, book);
g_signal_connect(view, "status_message", G_CALLBACK(status_message), name_selector_dialog);
g_signal_connect(view, "sequence_complete", G_CALLBACK(sequence_complete), name_selector_dialog);
g_object_unref (book);
- name_selector_dialog->pending_book = NULL;
+ name_selector_dialog->priv->pending_book = NULL;
}
static void
@@ -751,8 +778,8 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
remove_books (name_selector_dialog);
/* Start loading selected book */
- name_selector_dialog->pending_book = e_load_book_source (source, book_opened,
- name_selector_dialog);
+ name_selector_dialog->priv->pending_book = e_load_book_source (
+ source, book_opened, name_selector_dialog);
}
/* --------------- *
@@ -774,14 +801,14 @@ search_changed (ENameSelectorDialog *name_selector_dialog)
gchar *user_fields_str;
combo_box = GTK_WIDGET (gtk_builder_get_object (
- name_selector_dialog->gui, "combobox-category"));
+ name_selector_dialog->priv->gui, "combobox-category"));
if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box)) == -1)
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
category = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo_box));
category_escaped = escape_sexp_string (category);
- text = gtk_entry_get_text (name_selector_dialog->search_entry);
+ text = gtk_entry_get_text (name_selector_dialog->priv->search_entry);
text_escaped = escape_sexp_string (text);
user_fields_str = ens_util_populate_user_query_fields (priv->user_query_fields, text, text_escaped);
@@ -809,7 +836,7 @@ search_changed (ENameSelectorDialog *name_selector_dialog)
book_query = e_book_query_from_string (query_string);
contact_store = e_name_selector_model_peek_contact_store (
- name_selector_dialog->name_selector_model);
+ name_selector_dialog->priv->name_selector_model);
e_contact_store_set_query (contact_store, book_query);
e_book_query_unref (book_query);
@@ -828,12 +855,14 @@ contact_selection_changed (ENameSelectorDialog *name_selector_dialog)
gboolean have_selection = FALSE;
gint i;
- contact_selection = gtk_tree_view_get_selection (name_selector_dialog->contact_view);
+ contact_selection = gtk_tree_view_get_selection (
+ name_selector_dialog->priv->contact_view);
if (gtk_tree_selection_count_selected_rows (contact_selection))
have_selection = TRUE;
- for (i = 0; i < name_selector_dialog->sections->len; i++) {
- Section *section = &g_array_index (name_selector_dialog->sections, Section, i);
+ for (i = 0; i < name_selector_dialog->priv->sections->len; i++) {
+ Section *section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, i);
gtk_widget_set_sensitive (GTK_WIDGET (section->transfer_button), have_selection);
}
}
@@ -848,20 +877,20 @@ contact_activated (ENameSelectorDialog *name_selector_dialog, GtkTreePath *path)
Section *section;
gint email_n;
- ENameSelectorDialogPrivate *priv;
-
/* When a contact is activated, we transfer it to the first destination on our list */
- contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
+ contact_store = e_name_selector_model_peek_contact_store (
+ name_selector_dialog->priv->name_selector_model);
/* If we have no sections, we can't transfer */
- if (name_selector_dialog->sections->len == 0)
+ if (name_selector_dialog->priv->sections->len == 0)
return;
/* Get the contact to be transferred */
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (name_selector_dialog->contact_sort),
- &iter, path))
+ if (!gtk_tree_model_get_iter (
+ GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort),
+ &iter, path))
g_assert_not_reached ();
sort_iter_to_contact_store_iter (name_selector_dialog, &iter, &email_n);
@@ -872,16 +901,19 @@ contact_activated (ENameSelectorDialog *name_selector_dialog, GtkTreePath *path)
return;
}
- priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (name_selector_dialog);
-
- section = &g_array_index (name_selector_dialog->sections, Section, priv->destination_index);
- if (!e_name_selector_model_peek_section (name_selector_dialog->name_selector_model,
- section->name, NULL, &destination_store)) {
+ section = &g_array_index (
+ name_selector_dialog->priv->sections,
+ Section, name_selector_dialog->priv->destination_index);
+ if (!e_name_selector_model_peek_section (
+ name_selector_dialog->priv->name_selector_model,
+ section->name, NULL, &destination_store)) {
g_warning ("ENameSelectorDialog has a section unknown to the model!");
return;
}
- add_destination (name_selector_dialog->name_selector_model, destination_store, contact, email_n);
+ add_destination (
+ name_selector_dialog->priv->name_selector_model,
+ destination_store, contact, email_n);
}
static void
@@ -896,26 +928,32 @@ destination_activated (ENameSelectorDialog *name_selector_dialog, GtkTreePath *p
/* When a destination is activated, we remove it from the section */
- section_index = find_section_by_tree_view (name_selector_dialog, tree_view);
+ section_index = find_section_by_tree_view (
+ name_selector_dialog, tree_view);
if (section_index < 0) {
g_warning ("ENameSelectorDialog got activation from unknown view!");
return;
}
- section = &g_array_index (name_selector_dialog->sections, Section, section_index);
- if (!e_name_selector_model_peek_section (name_selector_dialog->name_selector_model,
- section->name, NULL, &destination_store)) {
+ section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, section_index);
+ if (!e_name_selector_model_peek_section (
+ name_selector_dialog->priv->name_selector_model,
+ section->name, NULL, &destination_store)) {
g_warning ("ENameSelectorDialog has a section unknown to the model!");
return;
}
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (destination_store), &iter, path))
+ if (!gtk_tree_model_get_iter (
+ GTK_TREE_MODEL (destination_store), &iter, path))
g_assert_not_reached ();
- destination = e_destination_store_get_destination (destination_store, &iter);
+ destination = e_destination_store_get_destination (
+ destination_store, &iter);
g_assert (destination);
- e_destination_store_remove_destination (destination_store, destination);
+ e_destination_store_remove_destination (
+ destination_store, destination);
}
static gboolean
@@ -928,15 +966,18 @@ remove_selection (ENameSelectorDialog *name_selector_dialog, GtkTreeView *tree_v
GtkTreeSelection *selection;
GList *rows, *l;
- section_index = find_section_by_tree_view (name_selector_dialog, tree_view);
+ section_index = find_section_by_tree_view (
+ name_selector_dialog, tree_view);
if (section_index < 0) {
g_warning ("ENameSelectorDialog got key press from unknown view!");
return FALSE;
}
- section = &g_array_index (name_selector_dialog->sections, Section, section_index);
- if (!e_name_selector_model_peek_section (name_selector_dialog->name_selector_model,
- section->name, NULL, &destination_store)) {
+ section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, section_index);
+ if (!e_name_selector_model_peek_section (
+ name_selector_dialog->priv->name_selector_model,
+ section->name, NULL, &destination_store)) {
g_warning ("ENameSelectorDialog has a section unknown to the model!");
return FALSE;
}
@@ -960,10 +1001,12 @@ remove_selection (ENameSelectorDialog *name_selector_dialog, GtkTreeView *tree_v
gtk_tree_path_free (path);
- destination = e_destination_store_get_destination (destination_store, &iter);
+ destination = e_destination_store_get_destination (
+ destination_store, &iter);
g_assert (destination);
- e_destination_store_remove_destination (destination_store, destination);
+ e_destination_store_remove_destination (
+ destination_store, destination);
}
g_list_free (rows);
@@ -1007,8 +1050,10 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog, GtkButton *t
/* Get the contact to be transferred */
- contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
- selection = gtk_tree_view_get_selection (name_selector_dialog->contact_view);
+ contact_store = e_name_selector_model_peek_contact_store (
+ name_selector_dialog->priv->name_selector_model);
+ selection = gtk_tree_view_get_selection (
+ name_selector_dialog->priv->contact_view);
if (!gtk_tree_selection_count_selected_rows (selection)) {
g_warning ("ENameSelectorDialog transfer button clicked, but no selection!");
@@ -1016,15 +1061,18 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog, GtkButton *t
}
/* Get the target section */
- section_index = find_section_by_transfer_button (name_selector_dialog, transfer_button);
+ section_index = find_section_by_transfer_button (
+ name_selector_dialog, transfer_button);
if (section_index < 0) {
g_warning ("ENameSelectorDialog got click from unknown button!");
return;
}
- section = &g_array_index (name_selector_dialog->sections, Section, section_index);
- if (!e_name_selector_model_peek_section (name_selector_dialog->name_selector_model,
- section->name, NULL, &destination_store)) {
+ section = &g_array_index (
+ name_selector_dialog->priv->sections, Section, section_index);
+ if (!e_name_selector_model_peek_section (
+ name_selector_dialog->priv->name_selector_model,
+ section->name, NULL, &destination_store)) {
g_warning ("ENameSelectorDialog has a section unknown to the model!");
return;
}
@@ -1036,8 +1084,9 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog, GtkButton *t
GtkTreeIter iter;
GtkTreePath *path = l->data;
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (name_selector_dialog->contact_sort),
- &iter, path)) {
+ if (!gtk_tree_model_get_iter (
+ GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort),
+ &iter, path)) {
gtk_tree_path_free (path);
return;
}
@@ -1052,7 +1101,9 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog, GtkButton *t
return;
}
- add_destination (name_selector_dialog->name_selector_model, destination_store, contact, email_n);
+ add_destination (
+ name_selector_dialog->priv->name_selector_model,
+ destination_store, contact, email_n);
}
g_list_free (rows);
}
@@ -1071,15 +1122,17 @@ setup_name_selector_model (ENameSelectorDialog *name_selector_dialog)
/* Create new destination sections in UI */
- new_sections = e_name_selector_model_list_sections (name_selector_dialog->name_selector_model);
+ new_sections = e_name_selector_model_list_sections (
+ name_selector_dialog->priv->name_selector_model);
for (l = new_sections; l; l = g_list_next (l)) {
gchar *name = l->data;
gchar *pretty_name;
EDestinationStore *destination_store;
- e_name_selector_model_peek_section (name_selector_dialog->name_selector_model,
- name, &pretty_name, &destination_store);
+ e_name_selector_model_peek_section (
+ name_selector_dialog->priv->name_selector_model,
+ name, &pretty_name, &destination_store);
add_section (name_selector_dialog, name, pretty_name, destination_store);
@@ -1091,27 +1144,33 @@ setup_name_selector_model (ENameSelectorDialog *name_selector_dialog)
/* Connect to section add/remove signals */
- g_signal_connect_swapped (name_selector_dialog->name_selector_model, "section-added",
- G_CALLBACK (model_section_added), name_selector_dialog);
- g_signal_connect_swapped (name_selector_dialog->name_selector_model, "section-removed",
- G_CALLBACK (model_section_removed), name_selector_dialog);
+ g_signal_connect_swapped (
+ name_selector_dialog->priv->name_selector_model, "section-added",
+ G_CALLBACK (model_section_added), name_selector_dialog);
+ g_signal_connect_swapped (
+ name_selector_dialog->priv->name_selector_model, "section-removed",
+ G_CALLBACK (model_section_removed), name_selector_dialog);
/* Get contact store and its filter wrapper */
- contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
- contact_filter = e_name_selector_model_peek_contact_filter (name_selector_dialog->name_selector_model);
+ contact_store = e_name_selector_model_peek_contact_store (
+ name_selector_dialog->priv->name_selector_model);
+ contact_filter = e_name_selector_model_peek_contact_filter (
+ name_selector_dialog->priv->name_selector_model);
/* Create sorting model on top of filter, assign it to view */
- name_selector_dialog->contact_sort = GTK_TREE_MODEL_SORT (
+ name_selector_dialog->priv->contact_sort = GTK_TREE_MODEL_SORT (
gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (contact_filter)));
/* sort on full name as we display full name in name selector dialog */
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (name_selector_dialog->contact_sort),
- E_CONTACT_FULL_NAME, GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_column_id (
+ GTK_TREE_SORTABLE (name_selector_dialog->priv->contact_sort),
+ E_CONTACT_FULL_NAME, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (name_selector_dialog->contact_view,
- GTK_TREE_MODEL (name_selector_dialog->contact_sort));
+ gtk_tree_view_set_model (
+ name_selector_dialog->priv->contact_view,
+ GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort));
/* Make sure UI is consistent */
@@ -1126,26 +1185,27 @@ shutdown_name_selector_model (ENameSelectorDialog *name_selector_dialog)
/* Rid UI of previous destination sections */
- for (i = 0; i < name_selector_dialog->sections->len; i++)
+ for (i = 0; i < name_selector_dialog->priv->sections->len; i++)
free_section (name_selector_dialog, i);
- g_array_set_size (name_selector_dialog->sections, 0);
+ g_array_set_size (name_selector_dialog->priv->sections, 0);
/* Free sorting model */
- if (name_selector_dialog->contact_sort) {
- g_object_unref (name_selector_dialog->contact_sort);
- name_selector_dialog->contact_sort = NULL;
+ if (name_selector_dialog->priv->contact_sort) {
+ g_object_unref (name_selector_dialog->priv->contact_sort);
+ name_selector_dialog->priv->contact_sort = NULL;
}
/* Free backend model */
- if (name_selector_dialog->name_selector_model) {
- g_signal_handlers_disconnect_matched (name_selector_dialog->name_selector_model,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_dialog);
+ if (name_selector_dialog->priv->name_selector_model) {
+ g_signal_handlers_disconnect_matched (
+ name_selector_dialog->priv->name_selector_model,
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_dialog);
- g_object_unref (name_selector_dialog->name_selector_model);
- name_selector_dialog->name_selector_model = NULL;
+ g_object_unref (name_selector_dialog->priv->name_selector_model);
+ name_selector_dialog->priv->name_selector_model = NULL;
}
}
@@ -1163,11 +1223,15 @@ contact_column_formatter (GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkT
gint email_n;
contact_store_iter = *iter;
- sort_iter_to_contact_store_iter (name_selector_dialog, &contact_store_iter, &email_n);
+ sort_iter_to_contact_store_iter (
+ name_selector_dialog, &contact_store_iter, &email_n);
- contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->name_selector_model);
- contact = e_contact_store_get_contact (contact_store, &contact_store_iter);
- email_list = e_name_selector_model_get_contact_emails_without_used (name_selector_dialog->name_selector_model, contact, TRUE);
+ contact_store = e_name_selector_model_peek_contact_store (
+ name_selector_dialog->priv->name_selector_model);
+ contact = e_contact_store_get_contact (
+ contact_store, &contact_store_iter);
+ email_list = e_name_selector_model_get_contact_emails_without_used (
+ name_selector_dialog->priv->name_selector_model, contact, TRUE);
email_str = g_list_nth_data (email_list, email_n);
full_name_str = e_contact_get (contact, E_CONTACT_FULL_NAME);
@@ -1231,7 +1295,7 @@ e_name_selector_dialog_peek_model (ENameSelectorDialog *name_selector_dialog)
{
g_return_val_if_fail (E_IS_NAME_SELECTOR_DIALOG (name_selector_dialog), NULL);
- return name_selector_dialog->name_selector_model;
+ return name_selector_dialog->priv->name_selector_model;
}
/**
@@ -1248,11 +1312,11 @@ e_name_selector_dialog_set_model (ENameSelectorDialog *name_selector_dialog,
g_return_if_fail (E_IS_NAME_SELECTOR_DIALOG (name_selector_dialog));
g_return_if_fail (E_IS_NAME_SELECTOR_MODEL (model));
- if (model == name_selector_dialog->name_selector_model)
+ if (model == name_selector_dialog->priv->name_selector_model)
return;
shutdown_name_selector_model (name_selector_dialog);
- name_selector_dialog->name_selector_model = g_object_ref (model);
+ name_selector_dialog->priv->name_selector_model = g_object_ref (model);
setup_name_selector_model (name_selector_dialog);
}
@@ -1268,12 +1332,10 @@ void
e_name_selector_dialog_set_destination_index (ENameSelectorDialog *name_selector_dialog,
guint index)
{
- ENameSelectorDialogPrivate *priv;
-
- priv = E_NAME_SELECTOR_DIALOG_GET_PRIVATE (name_selector_dialog);
+ g_return_if_fail (E_IS_NAME_SELECTOR_DIALOG (name_selector_dialog));
- if (index >= name_selector_dialog->sections->len)
+ if (index >= name_selector_dialog->priv->sections->len)
return;
- priv->destination_index = index;
+ name_selector_dialog->priv->destination_index = index;
}
diff --git a/libedataserverui/e-name-selector-dialog.h b/libedataserverui/e-name-selector-dialog.h
index 76cd3c6..b7b5fb8 100644
--- a/libedataserverui/e-name-selector-dialog.h
+++ b/libedataserverui/e-name-selector-dialog.h
@@ -50,41 +50,30 @@
G_BEGIN_DECLS
-typedef struct _ENameSelectorDialog ENameSelectorDialog;
+typedef struct _ENameSelectorDialog ENameSelectorDialog;
typedef struct _ENameSelectorDialogClass ENameSelectorDialogClass;
-
-struct _ENameSelectorDialogClass {
- GtkDialogClass parent_class;
-};
+typedef struct _ENameSelectorDialogPrivate ENameSelectorDialogPrivate;
struct _ENameSelectorDialog {
- GtkDialog parent;
-
- /* Private */
-
- EBook *pending_book;
- gpointer unused; /* Maintain ABI compatibility */
- ENameSelectorModel *name_selector_model;
- GtkTreeModelSort *contact_sort;
-
- GtkBuilder *gui;
- GtkTreeView *contact_view;
- GtkLabel *status_label;
- GtkBox *destination_box;
- GtkEntry *search_entry;
- GtkSizeGroup *button_size_group;
-
- GArray *sections;
+ GtkDialog parent;
+ ENameSelectorDialogPrivate *priv;
};
-GType e_name_selector_dialog_get_type (void);
-ENameSelectorDialog *e_name_selector_dialog_new (void);
+struct _ENameSelectorDialogClass {
+ GtkDialogClass parent_class;
+};
-ENameSelectorModel *e_name_selector_dialog_peek_model (ENameSelectorDialog *name_selector_dialog);
-void e_name_selector_dialog_set_model (ENameSelectorDialog *name_selector_dialog,
- ENameSelectorModel *model);
-void e_name_selector_dialog_set_destination_index (ENameSelectorDialog *name_selector_dialog,
- guint index);
+GType e_name_selector_dialog_get_type (void);
+ENameSelectorDialog *
+ e_name_selector_dialog_new (void);
+ENameSelectorModel *
+ e_name_selector_dialog_peek_model
+ (ENameSelectorDialog *name_selector_dialog);
+void e_name_selector_dialog_set_model(ENameSelectorDialog *name_selector_dialog,
+ ENameSelectorModel *model);
+void e_name_selector_dialog_set_destination_index
+ (ENameSelectorDialog *name_selector_dialog,
+ guint index);
G_END_DECLS
diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c
index f429002..382f170 100644
--- a/libedataserverui/e-name-selector-entry.c
+++ b/libedataserverui/e-name-selector-entry.c
@@ -33,10 +33,43 @@
#include "e-name-selector-entry.h"
+#define E_NAME_SELECTOR_ENTRY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_NAME_SELECTOR_ENTRY, ENameSelectorEntryPrivate))
+
+struct _ENameSelectorEntryPrivate {
+
+ PangoAttrList *attr_list;
+ ESourceList *source_list;
+ EContactStore *contact_store;
+ ETreeModelGenerator *email_generator;
+ EDestinationStore *destination_store;
+ GtkEntryCompletion *entry_completion;
+
+ guint type_ahead_complete_cb_id;
+ guint update_completions_cb_id;
+
+ EDestination *popup_destination;
+
+ gpointer (*contact_editor_func) (EBook *,
+ EContact *,
+ gboolean,
+ gboolean);
+ gpointer (*contact_list_editor_func)
+ (EBook *,
+ EContact *,
+ gboolean,
+ gboolean);
+
+ gboolean is_completing;
+ GSList *user_query_fields;
+};
+
enum {
UPDATED,
LAST_SIGNAL
};
+
static guint signals[LAST_SIGNAL] = { 0 };
static guint COMPLETION_CUE_MIN_LEN = 0;
static gboolean COMPLETION_FORCE_SHOW_ADDRESS = FALSE;
@@ -44,15 +77,6 @@ static gboolean COMPLETION_FORCE_SHOW_ADDRESS = FALSE;
G_DEFINE_TYPE (ENameSelectorEntry, e_name_selector_entry, GTK_TYPE_ENTRY)
-typedef struct _ENameSelectorEntryPrivate ENameSelectorEntryPrivate;
-struct _ENameSelectorEntryPrivate
-{
- gboolean is_completing;
- GSList *user_query_fields;
-};
-
-#define E_NAME_SELECTOR_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), E_TYPE_NAME_SELECTOR_ENTRY, ENameSelectorEntryPrivate))
-
/* 1/3 of the second to wait until invoking autocomplete lookup */
#define AUTOCOMPLETE_TIMEOUT 333
@@ -62,9 +86,6 @@ struct _ENameSelectorEntryPrivate
id = g_timeout_add (AUTOCOMPLETE_TIMEOUT, \
(GSourceFunc) func, ptr);
-static void e_name_selector_entry_dispose (GObject *object);
-static void e_name_selector_entry_finalize (GObject *object);
-
static void destination_row_inserted (ENameSelectorEntry *name_selector_entry, GtkTreePath *path, GtkTreeIter *iter);
static void destination_row_changed (ENameSelectorEntry *name_selector_entry, GtkTreePath *path, GtkTreeIter *iter);
static void destination_row_deleted (ENameSelectorEntry *name_selector_entry, GtkTreePath *path);
@@ -76,100 +97,66 @@ static void setup_default_contact_store (ENameSelectorEntry *name_selector_entry
static void deep_free_list (GList *list);
static void
-e_name_selector_entry_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
-}
-
-static void
-e_name_selector_entry_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
-}
-
-static void
-e_name_selector_entry_realize (GtkWidget *widget)
-{
- ENameSelectorEntry *name_selector_entry = E_NAME_SELECTOR_ENTRY (widget);
-
- GTK_WIDGET_CLASS (e_name_selector_entry_parent_class)->realize (widget);
-
- if (!name_selector_entry->contact_store) {
- setup_default_contact_store (name_selector_entry);
- }
-}
-
-/* Partial, repeatable destruction. Release references. */
-static void
-e_name_selector_entry_dispose (GObject *object)
+name_selector_entry_dispose (GObject *object)
{
- ENameSelectorEntry *name_selector_entry = E_NAME_SELECTOR_ENTRY (object);
ENameSelectorEntryPrivate *priv;
- priv = E_NAME_SELECTOR_ENTRY_GET_PRIVATE (name_selector_entry);
+ priv = E_NAME_SELECTOR_ENTRY_GET_PRIVATE (object);
- if (name_selector_entry->entry_completion) {
- g_object_unref (name_selector_entry->entry_completion);
- name_selector_entry->entry_completion = NULL;
+ if (priv->entry_completion) {
+ g_object_unref (priv->entry_completion);
+ priv->entry_completion = NULL;
}
- if (name_selector_entry->destination_store) {
- g_object_unref (name_selector_entry->destination_store);
- name_selector_entry->destination_store = NULL;
+ if (priv->destination_store) {
+ g_object_unref (priv->destination_store);
+ priv->destination_store = NULL;
}
- if (priv && priv->user_query_fields) {
- g_slist_foreach (priv->user_query_fields, (GFunc)g_free, NULL);
- g_slist_free (priv->user_query_fields);
- priv->user_query_fields = NULL;
- }
+ g_slist_foreach (priv->user_query_fields, (GFunc)g_free, NULL);
+ g_slist_free (priv->user_query_fields);
+ priv->user_query_fields = NULL;
- if (G_OBJECT_CLASS (e_name_selector_entry_parent_class)->dispose)
- G_OBJECT_CLASS (e_name_selector_entry_parent_class)->dispose (object);
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_name_selector_entry_parent_class)->dispose (object);
}
-/* Final, one-time destruction. Free all. */
static void
-e_name_selector_entry_finalize (GObject *object)
+name_selector_entry_realize (GtkWidget *widget)
{
- if (G_OBJECT_CLASS (e_name_selector_entry_parent_class)->finalize)
- G_OBJECT_CLASS (e_name_selector_entry_parent_class)->finalize (object);
-}
+ ENameSelectorEntryPrivate *priv;
-static void
-e_name_selector_entry_updated (ENameSelectorEntry *entry, gchar *email)
-{
- g_return_if_fail (E_IS_NAME_SELECTOR_ENTRY (entry));
+ priv = E_NAME_SELECTOR_ENTRY_GET_PRIVATE (widget);
+
+ /* Chain up to parent's realize() method. */
+ GTK_WIDGET_CLASS (e_name_selector_entry_parent_class)->realize (widget);
+
+ if (priv->contact_store == NULL)
+ setup_default_contact_store (E_NAME_SELECTOR_ENTRY (widget));
}
static void
-e_name_selector_entry_class_init (ENameSelectorEntryClass *name_selector_entry_class)
+e_name_selector_entry_class_init (ENameSelectorEntryClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (name_selector_entry_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (name_selector_entry_class);
-
- object_class->get_property = e_name_selector_entry_get_property;
- object_class->set_property = e_name_selector_entry_set_property;
- object_class->dispose = e_name_selector_entry_dispose;
- object_class->finalize = e_name_selector_entry_finalize;
- name_selector_entry_class->updated = e_name_selector_entry_updated;
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
- widget_class->realize = e_name_selector_entry_realize;
+ g_type_class_add_private (class, sizeof (ENameSelectorEntryPrivate));
- /* Install properties */
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = name_selector_entry_dispose;
- /* Install signals */
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = name_selector_entry_realize;
- signals[UPDATED] = g_signal_new ("updated",
- E_TYPE_NAME_SELECTOR_ENTRY,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ENameSelectorEntryClass, updated),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- g_type_class_add_private (object_class, sizeof(ENameSelectorEntryPrivate));
+ signals[UPDATED] = g_signal_new (
+ "updated",
+ E_TYPE_NAME_SELECTOR_ENTRY,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ENameSelectorEntryClass, updated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
}
/* Remove unquoted commas and control characters from string */
@@ -374,7 +361,7 @@ find_destination_by_index (ENameSelectorEntry *name_selector_entry, gint index)
GtkTreeIter iter;
path = gtk_tree_path_new_from_indices (index, -1);
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (name_selector_entry->destination_store),
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (name_selector_entry->priv->destination_store),
&iter, path)) {
/* If we have zero destinations, getting a NULL destination at index 0
* is valid. */
@@ -385,7 +372,7 @@ find_destination_by_index (ENameSelectorEntry *name_selector_entry, gint index)
}
gtk_tree_path_free (path);
- return e_destination_store_get_destination (name_selector_entry->destination_store, &iter);
+ return e_destination_store_get_destination (name_selector_entry->priv->destination_store, &iter);
}
/* Finds the destination in model */
@@ -534,12 +521,12 @@ set_completion_query (ENameSelectorEntry *name_selector_entry, const gchar *cue_
priv = E_NAME_SELECTOR_ENTRY_GET_PRIVATE (name_selector_entry);
- if (!name_selector_entry->contact_store)
+ if (!name_selector_entry->priv->contact_store)
return;
if (!cue_str) {
/* Clear the store */
- e_contact_store_set_query (name_selector_entry->contact_store, NULL);
+ e_contact_store_set_query (name_selector_entry->priv->contact_store, NULL);
return;
}
@@ -567,7 +554,7 @@ set_completion_query (ENameSelectorEntry *name_selector_entry, const gchar *cue_
ENS_DEBUG (g_print ("%s\n", query_str));
book_query = e_book_query_from_string (query_str);
- e_contact_store_set_query (name_selector_entry->contact_store, book_query);
+ e_contact_store_set_query (name_selector_entry->priv->contact_store, book_query);
e_book_query_unref (book_query);
g_free (query_str);
@@ -718,14 +705,14 @@ find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *
g_assert (cue_str);
- if (!name_selector_entry->contact_store)
+ if (!name_selector_entry->priv->contact_store)
return FALSE;
cue_len = strlen (cue_str);
ENS_DEBUG (g_print ("Completing '%s'\n", cue_str));
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (name_selector_entry->contact_store), &iter))
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (name_selector_entry->priv->contact_store), &iter))
return FALSE;
do {
@@ -734,7 +721,7 @@ find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *
EContactField current_field;
gboolean matches;
- current_contact = e_contact_store_get_contact (name_selector_entry->contact_store, &iter);
+ current_contact = e_contact_store_get_contact (name_selector_entry->priv->contact_store, &iter);
if (!current_contact)
continue;
@@ -744,7 +731,7 @@ find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *
best_field_rank = current_field_rank;
best_field = current_field;
}
- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (name_selector_entry->contact_store), &iter));
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (name_selector_entry->priv->contact_store), &iter));
if (!best_contact)
return FALSE;
@@ -774,10 +761,10 @@ generate_attribute_list (ENameSelectorEntry *name_selector_entry)
attr_list = pango_attr_list_new ();
- if (name_selector_entry->attr_list)
- pango_attr_list_unref (name_selector_entry->attr_list);
+ if (name_selector_entry->priv->attr_list)
+ pango_attr_list_unref (name_selector_entry->priv->attr_list);
- name_selector_entry->attr_list = attr_list;
+ name_selector_entry->priv->attr_list = attr_list;
/* Parse the entry's text and apply attributes to real contacts */
@@ -811,7 +798,7 @@ expose_event (ENameSelectorEntry *name_selector_entry)
PangoLayout *layout;
layout = gtk_entry_get_layout (GTK_ENTRY (name_selector_entry));
- pango_layout_set_attributes (layout, name_selector_entry->attr_list);
+ pango_layout_set_attributes (layout, name_selector_entry->priv->attr_list);
return FALSE;
}
@@ -864,7 +851,7 @@ type_ahead_complete (ENameSelectorEntry *name_selector_entry)
g_signal_handlers_block_by_func (name_selector_entry, user_insert_text, name_selector_entry);
g_signal_handlers_block_by_func (name_selector_entry, user_delete_text, name_selector_entry);
- g_signal_handlers_block_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_block_by_func (name_selector_entry->priv->destination_store,
destination_row_changed, name_selector_entry);
if (textrep_len > range_len) {
@@ -892,7 +879,7 @@ type_ahead_complete (ENameSelectorEntry *name_selector_entry)
generate_attribute_list (name_selector_entry);
}
- g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_unblock_by_func (name_selector_entry->priv->destination_store,
destination_row_changed, name_selector_entry);
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
g_signal_handlers_unblock_by_func (name_selector_entry, user_insert_text, name_selector_entry);
@@ -907,10 +894,10 @@ clear_completion_model (ENameSelectorEntry *name_selector_entry)
priv = E_NAME_SELECTOR_ENTRY_GET_PRIVATE (name_selector_entry);
- if (!name_selector_entry->contact_store)
+ if (!name_selector_entry->priv->contact_store)
return;
- e_contact_store_set_query (name_selector_entry->contact_store, NULL);
+ e_contact_store_set_query (name_selector_entry->priv->contact_store, NULL);
priv->is_completing = FALSE;
}
@@ -944,7 +931,7 @@ static gboolean
type_ahead_complete_on_timeout_cb (ENameSelectorEntry *name_selector_entry)
{
type_ahead_complete (name_selector_entry);
- name_selector_entry->type_ahead_complete_cb_id = 0;
+ name_selector_entry->priv->type_ahead_complete_cb_id = 0;
return FALSE;
}
@@ -952,7 +939,7 @@ static gboolean
update_completions_on_timeout_cb (ENameSelectorEntry *name_selector_entry)
{
update_completion_model (name_selector_entry);
- name_selector_entry->update_completions_cb_id = 0;
+ name_selector_entry->priv->update_completions_cb_id = 0;
return FALSE;
}
@@ -969,11 +956,11 @@ insert_destination_at_position (ENameSelectorEntry *name_selector_entry, gint po
destination = build_destination_at_position (text, pos);
g_assert (destination);
- g_signal_handlers_block_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_block_by_func (name_selector_entry->priv->destination_store,
destination_row_inserted, name_selector_entry);
- e_destination_store_insert_destination (name_selector_entry->destination_store,
+ e_destination_store_insert_destination (name_selector_entry->priv->destination_store,
index, destination);
- g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_unblock_by_func (name_selector_entry->priv->destination_store,
destination_row_inserted, name_selector_entry);
g_object_unref (destination);
}
@@ -997,10 +984,10 @@ modify_destination_at_position (ENameSelectorEntry *name_selector_entry, gint po
if (e_destination_get_contact (destination))
rebuild_attributes = TRUE;
- g_signal_handlers_block_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_block_by_func (name_selector_entry->priv->destination_store,
destination_row_changed, name_selector_entry);
e_destination_set_raw (destination, raw_address);
- g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_unblock_by_func (name_selector_entry->priv->destination_store,
destination_row_changed, name_selector_entry);
g_free (raw_address);
@@ -1088,11 +1075,11 @@ remove_destination_by_index (ENameSelectorEntry *name_selector_entry, gint index
destination = find_destination_by_index (name_selector_entry, index);
if (destination) {
- g_signal_handlers_block_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_block_by_func (name_selector_entry->priv->destination_store,
destination_row_deleted, name_selector_entry);
- e_destination_store_remove_destination (name_selector_entry->destination_store,
+ e_destination_store_remove_destination (name_selector_entry->priv->destination_store,
destination);
- g_signal_handlers_unblock_by_func (name_selector_entry->destination_store,
+ g_signal_handlers_unblock_by_func (name_selector_entry->priv->destination_store,
destination_row_deleted, name_selector_entry);
}
}
@@ -1213,8 +1200,8 @@ user_insert_text (ENameSelectorEntry *name_selector_entry, gchar *new_text,
if (chars_inserted >= 1) {
/* If the user inserted one character, kick off completion */
- re_set_timeout (name_selector_entry->update_completions_cb_id, update_completions_on_timeout_cb, name_selector_entry);
- re_set_timeout (name_selector_entry->type_ahead_complete_cb_id, type_ahead_complete_on_timeout_cb, name_selector_entry);
+ re_set_timeout (name_selector_entry->priv->update_completions_cb_id, update_completions_on_timeout_cb, name_selector_entry);
+ re_set_timeout (name_selector_entry->priv->type_ahead_complete_cb_id, type_ahead_complete_on_timeout_cb, name_selector_entry);
}
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
@@ -1255,7 +1242,7 @@ user_delete_text (ENameSelectorEntry *name_selector_entry, gint start_pos, gint
if (end_pos - start_pos == 1) {
/* Might be backspace; update completion model so dropdown is accurate */
- re_set_timeout (name_selector_entry->update_completions_cb_id, update_completions_on_timeout_cb, name_selector_entry);
+ re_set_timeout (name_selector_entry->priv->update_completions_cb_id, update_completions_on_timeout_cb, name_selector_entry);
}
index_start = get_index_at_position (text, start_pos);
@@ -1413,9 +1400,9 @@ user_delete_text (ENameSelectorEntry *name_selector_entry, gint start_pos, gint
generate_attribute_list (name_selector_entry);
/* Prevent type-ahead completion */
- if (name_selector_entry->type_ahead_complete_cb_id) {
- g_source_remove (name_selector_entry->type_ahead_complete_cb_id);
- name_selector_entry->type_ahead_complete_cb_id = 0;
+ if (name_selector_entry->priv->type_ahead_complete_cb_id) {
+ g_source_remove (name_selector_entry->priv->type_ahead_complete_cb_id);
+ name_selector_entry->priv->type_ahead_complete_cb_id = 0;
}
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
@@ -1432,16 +1419,16 @@ completion_match_selected (ENameSelectorEntry *name_selector_entry, GtkTreeModel
GtkTreeIter contact_iter;
gint email_n;
- if (!name_selector_entry->contact_store)
+ if (!name_selector_entry->priv->contact_store)
return FALSE;
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model),
&generator_iter, iter);
- e_tree_model_generator_convert_iter_to_child_iter (name_selector_entry->email_generator,
+ e_tree_model_generator_convert_iter_to_child_iter (name_selector_entry->priv->email_generator,
&contact_iter, &email_n,
&generator_iter);
- contact = e_contact_store_get_contact (name_selector_entry->contact_store, &contact_iter);
+ contact = e_contact_store_get_contact (name_selector_entry->priv->contact_store, &contact_iter);
cursor_pos = gtk_editable_get_position (GTK_EDITABLE (name_selector_entry));
/* Set the contact in the model's destination */
@@ -1554,9 +1541,9 @@ sanitize_entry (ENameSelectorEntry *name_selector_entry)
GString *str = g_string_new ("");
g_signal_handlers_block_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
- g_signal_handlers_block_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+ g_signal_handlers_block_matched (name_selector_entry->priv->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
- known = e_destination_store_list_destinations (name_selector_entry->destination_store);
+ known = e_destination_store_list_destinations (name_selector_entry->priv->destination_store);
for (l = known, n = 0; l != NULL; l = l->next, n++) {
EDestination *dest = l->data;
@@ -1578,7 +1565,7 @@ sanitize_entry (ENameSelectorEntry *name_selector_entry)
g_list_free (known);
for (l = del; l != NULL; l = l->next) {
- e_destination_store_remove_destination_nth (name_selector_entry->destination_store, GPOINTER_TO_INT (l->data));
+ e_destination_store_remove_destination_nth (name_selector_entry->priv->destination_store, GPOINTER_TO_INT (l->data));
}
g_list_free (del);
@@ -1586,7 +1573,7 @@ sanitize_entry (ENameSelectorEntry *name_selector_entry)
g_string_free (str, TRUE);
- g_signal_handlers_unblock_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+ g_signal_handlers_unblock_matched (name_selector_entry->priv->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
g_signal_handlers_unblock_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
generate_attribute_list (name_selector_entry);
@@ -1601,9 +1588,9 @@ user_focus_in (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_foc
EDestination *dest_dummy = e_destination_new ();
g_signal_handlers_block_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
- g_signal_handlers_block_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+ g_signal_handlers_block_matched (name_selector_entry->priv->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
- known = e_destination_store_list_destinations (name_selector_entry->destination_store);
+ known = e_destination_store_list_destinations (name_selector_entry->priv->destination_store);
for (l = known, n = 0; l != NULL; l = l->next, n++) {
EDestination *dest = l->data;
@@ -1623,7 +1610,7 @@ user_focus_in (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_foc
g_list_free (known);
/* Add a blank destination */
- e_destination_store_append_destination (name_selector_entry->destination_store, dest_dummy);
+ e_destination_store_append_destination (name_selector_entry->priv->destination_store, dest_dummy);
if (str->str && str->str[0])
g_string_append (str, ", ");
@@ -1631,7 +1618,7 @@ user_focus_in (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_foc
g_string_free (str, TRUE);
- g_signal_handlers_unblock_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+ g_signal_handlers_unblock_matched (name_selector_entry->priv->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
g_signal_handlers_unblock_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
generate_attribute_list (name_selector_entry);
@@ -1650,14 +1637,14 @@ user_focus_out (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_fo
entry_activate (name_selector_entry);
}
- if (name_selector_entry->type_ahead_complete_cb_id) {
- g_source_remove (name_selector_entry->type_ahead_complete_cb_id);
- name_selector_entry->type_ahead_complete_cb_id = 0;
+ if (name_selector_entry->priv->type_ahead_complete_cb_id) {
+ g_source_remove (name_selector_entry->priv->type_ahead_complete_cb_id);
+ name_selector_entry->priv->type_ahead_complete_cb_id = 0;
}
- if (name_selector_entry->update_completions_cb_id) {
- g_source_remove (name_selector_entry->update_completions_cb_id);
- name_selector_entry->update_completions_cb_id = 0;
+ if (name_selector_entry->priv->update_completions_cb_id) {
+ g_source_remove (name_selector_entry->priv->update_completions_cb_id);
+ name_selector_entry->priv->update_completions_cb_id = 0;
}
clear_completion_model (name_selector_entry);
@@ -1707,16 +1694,16 @@ contact_layout_pixbuffer (GtkCellLayout *cell_layout, GtkCellRenderer *cell, Gtk
EContactPhoto *photo;
GdkPixbuf *pixbuf = NULL;
- if (!name_selector_entry->contact_store)
+ if (!name_selector_entry->priv->contact_store)
return;
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model),
&generator_iter, iter);
- e_tree_model_generator_convert_iter_to_child_iter (name_selector_entry->email_generator,
+ e_tree_model_generator_convert_iter_to_child_iter (name_selector_entry->priv->email_generator,
&contact_store_iter, &email_n,
&generator_iter);
- contact = e_contact_store_get_contact (name_selector_entry->contact_store, &contact_store_iter);
+ contact = e_contact_store_get_contact (name_selector_entry->priv->contact_store, &contact_store_iter);
if (!contact) {
g_object_set (cell, "pixbuf", pixbuf, NULL);
return;
@@ -1780,16 +1767,16 @@ contact_layout_formatter (GtkCellLayout *cell_layout, GtkCellRenderer *cell, Gtk
gchar *email_str;
gint email_n;
- if (!name_selector_entry->contact_store)
+ if (!name_selector_entry->priv->contact_store)
return;
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model),
&generator_iter, iter);
- e_tree_model_generator_convert_iter_to_child_iter (name_selector_entry->email_generator,
+ e_tree_model_generator_convert_iter_to_child_iter (name_selector_entry->priv->email_generator,
&contact_store_iter, &email_n,
&generator_iter);
- contact = e_contact_store_get_contact (name_selector_entry->contact_store, &contact_store_iter);
+ contact = e_contact_store_get_contact (name_selector_entry->priv->contact_store, &contact_store_iter);
email_list = e_contact_get (contact, E_CONTACT_EMAIL);
email_str = g_list_nth_data (email_list, email_n);
file_as_str = e_contact_get (contact, E_CONTACT_FILE_AS);
@@ -1838,37 +1825,37 @@ generate_contact_rows (EContactStore *contact_store, GtkTreeIter *iter,
static void
ensure_type_ahead_complete_on_timeout (ENameSelectorEntry *name_selector_entry)
{
- re_set_timeout (name_selector_entry->type_ahead_complete_cb_id, type_ahead_complete_on_timeout_cb, name_selector_entry);
+ re_set_timeout (name_selector_entry->priv->type_ahead_complete_cb_id, type_ahead_complete_on_timeout_cb, name_selector_entry);
}
static void
setup_contact_store (ENameSelectorEntry *name_selector_entry)
{
- if (name_selector_entry->email_generator) {
- g_object_unref (name_selector_entry->email_generator);
- name_selector_entry->email_generator = NULL;
+ if (name_selector_entry->priv->email_generator) {
+ g_object_unref (name_selector_entry->priv->email_generator);
+ name_selector_entry->priv->email_generator = NULL;
}
- if (name_selector_entry->contact_store) {
- name_selector_entry->email_generator =
- e_tree_model_generator_new (GTK_TREE_MODEL (name_selector_entry->contact_store));
+ if (name_selector_entry->priv->contact_store) {
+ name_selector_entry->priv->email_generator =
+ e_tree_model_generator_new (GTK_TREE_MODEL (name_selector_entry->priv->contact_store));
- e_tree_model_generator_set_generate_func (name_selector_entry->email_generator,
+ e_tree_model_generator_set_generate_func (name_selector_entry->priv->email_generator,
(ETreeModelGeneratorGenerateFunc) generate_contact_rows,
name_selector_entry, NULL);
/* Assign the store to the entry completion */
- gtk_entry_completion_set_model (name_selector_entry->entry_completion,
- GTK_TREE_MODEL (name_selector_entry->email_generator));
+ gtk_entry_completion_set_model (name_selector_entry->priv->entry_completion,
+ GTK_TREE_MODEL (name_selector_entry->priv->email_generator));
/* Set up callback for incoming matches */
- g_signal_connect_swapped (name_selector_entry->contact_store, "row-inserted",
+ g_signal_connect_swapped (name_selector_entry->priv->contact_store, "row-inserted",
G_CALLBACK (ensure_type_ahead_complete_on_timeout), name_selector_entry);
} else {
/* Remove the store from the entry completion */
- gtk_entry_completion_set_model (name_selector_entry->entry_completion, NULL);
+ gtk_entry_completion_set_model (name_selector_entry->priv->entry_completion, NULL);
}
}
@@ -1878,12 +1865,12 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
GSList *groups;
GSList *l;
- g_return_if_fail (name_selector_entry->contact_store == NULL);
+ g_return_if_fail (name_selector_entry->priv->contact_store == NULL);
/* Create a book for each completion source, and assign them to the contact store */
- name_selector_entry->contact_store = e_contact_store_new ();
- groups = e_source_list_peek_groups (name_selector_entry->source_list);
+ name_selector_entry->priv->contact_store = e_contact_store_new ();
+ groups = e_source_list_peek_groups (name_selector_entry->priv->source_list);
for (l = groups; l; l = g_slist_next (l)) {
ESourceGroup *group = l->data;
@@ -1904,7 +1891,7 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
if (!book)
continue;
- e_contact_store_add_book (name_selector_entry->contact_store, book);
+ e_contact_store_add_book (name_selector_entry->priv->contact_store, book);
g_object_unref (book);
}
}
@@ -1922,7 +1909,7 @@ destination_row_changed (ENameSelectorEntry *name_selector_entry, GtkTreePath *p
gint n;
n = gtk_tree_path_get_indices (path) [0];
- destination = e_destination_store_get_destination (name_selector_entry->destination_store, iter);
+ destination = e_destination_store_get_destination (name_selector_entry->priv->destination_store, iter);
if (!destination)
return;
@@ -1964,7 +1951,7 @@ destination_row_inserted (ENameSelectorEntry *name_selector_entry, GtkTreePath *
gint n;
n = gtk_tree_path_get_indices (path) [0];
- destination = e_destination_store_get_destination (name_selector_entry->destination_store, iter);
+ destination = e_destination_store_get_destination (name_selector_entry->priv->destination_store, iter);
g_assert (n >= 0);
g_assert (destination != NULL);
@@ -2078,24 +2065,24 @@ setup_destination_store (ENameSelectorEntry *name_selector_entry)
{
GtkTreeIter iter;
- g_signal_connect_swapped (name_selector_entry->destination_store, "row-changed",
+ g_signal_connect_swapped (name_selector_entry->priv->destination_store, "row-changed",
G_CALLBACK (destination_row_changed), name_selector_entry);
- g_signal_connect_swapped (name_selector_entry->destination_store, "row-deleted",
+ g_signal_connect_swapped (name_selector_entry->priv->destination_store, "row-deleted",
G_CALLBACK (destination_row_deleted), name_selector_entry);
- g_signal_connect_swapped (name_selector_entry->destination_store, "row-inserted",
+ g_signal_connect_swapped (name_selector_entry->priv->destination_store, "row-inserted",
G_CALLBACK (destination_row_inserted), name_selector_entry);
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (name_selector_entry->destination_store), &iter))
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (name_selector_entry->priv->destination_store), &iter))
return;
do {
GtkTreePath *path;
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (name_selector_entry->destination_store), &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (name_selector_entry->priv->destination_store), &iter);
g_assert (path);
destination_row_inserted (name_selector_entry, path, &iter);
- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (name_selector_entry->destination_store), &iter));
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (name_selector_entry->priv->destination_store), &iter));
}
static gboolean
@@ -2114,9 +2101,9 @@ prepare_popup_destination (ENameSelectorEntry *name_selector_entry, GdkEventButt
if (event_button->button != 3)
return FALSE;
- if (name_selector_entry->popup_destination) {
- g_object_unref (name_selector_entry->popup_destination);
- name_selector_entry->popup_destination = NULL;
+ if (name_selector_entry->priv->popup_destination) {
+ g_object_unref (name_selector_entry->priv->popup_destination);
+ name_selector_entry->priv->popup_destination = NULL;
}
gtk_entry_get_layout_offsets (GTK_ENTRY (name_selector_entry),
@@ -2140,7 +2127,7 @@ prepare_popup_destination (ENameSelectorEntry *name_selector_entry, GdkEventButt
return FALSE;
/* TODO: Unref destination when we finalize */
- name_selector_entry->popup_destination = g_object_ref (destination);
+ name_selector_entry->priv->popup_destination = g_object_ref (destination);
return FALSE;
}
@@ -2177,7 +2164,7 @@ editor_closed_cb (GtkObject *editor, gpointer data)
gint email_num;
ENameSelectorEntry *name_selector_entry = E_NAME_SELECTOR_ENTRY (data);
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
contact = e_destination_get_contact (destination);
if (!contact)
return;
@@ -2185,8 +2172,8 @@ editor_closed_cb (GtkObject *editor, gpointer data)
if (!contact_uid)
return;
- if (name_selector_entry->contact_store) {
- books = e_contact_store_get_books (name_selector_entry->contact_store);
+ if (name_selector_entry->priv->contact_store) {
+ books = e_contact_store_get_books (name_selector_entry->priv->contact_store);
book = find_book_by_contact (books, contact_uid);
g_list_free (books);
} else {
@@ -2210,7 +2197,7 @@ popup_activate_inline_expand (ENameSelectorEntry *name_selector_entry, GtkWidget
{
const gchar *email_list, *text;
gchar *sanitized_text;
- EDestination *destination = name_selector_entry->popup_destination;
+ EDestination *destination = name_selector_entry->priv->popup_destination;
gint position, start, end;
position = GPOINTER_TO_INT(g_object_get_data ((GObject *)name_selector_entry, "index"));
@@ -2243,7 +2230,7 @@ popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu
EContact *contact;
gchar *contact_uid;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
if (!destination)
return;
@@ -2254,8 +2241,8 @@ popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu
contact_uid = e_contact_get (contact, E_CONTACT_UID);
if (!contact_uid)
return;
- if (name_selector_entry->contact_store) {
- books = e_contact_store_get_books (name_selector_entry->contact_store);
+ if (name_selector_entry->priv->contact_store) {
+ books = e_contact_store_get_books (name_selector_entry->priv->contact_store);
/*FIXME: read URI from contact and get the book ?*/
book = find_book_by_contact (books, contact_uid);
g_list_free (books);
@@ -2270,20 +2257,20 @@ popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu
if (e_destination_is_evolution_list (destination)) {
GtkWidget *contact_list_editor;
- if (!name_selector_entry->contact_list_editor_func)
+ if (!name_selector_entry->priv->contact_list_editor_func)
return;
- contact_list_editor = (*name_selector_entry->contact_list_editor_func) (book, contact, FALSE, TRUE);
+ contact_list_editor = (*name_selector_entry->priv->contact_list_editor_func) (book, contact, FALSE, TRUE);
g_object_ref (name_selector_entry);
g_signal_connect (contact_list_editor, "editor_closed",
G_CALLBACK (editor_closed_cb), name_selector_entry);
} else {
GtkWidget *contact_editor;
- if (!name_selector_entry->contact_editor_func)
+ if (!name_selector_entry->priv->contact_editor_func)
return;
- contact_editor = (*name_selector_entry->contact_editor_func) (book, contact, FALSE, TRUE);
+ contact_editor = (*name_selector_entry->priv->contact_editor_func) (book, contact, FALSE, TRUE);
g_object_ref (name_selector_entry);
g_signal_connect (contact_editor, "editor_closed",
G_CALLBACK (editor_closed_cb), name_selector_entry);
@@ -2297,7 +2284,7 @@ popup_activate_email (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_i
EContact *contact;
gint email_num;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
if (!destination)
return;
@@ -2325,7 +2312,7 @@ popup_activate_cut (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_ite
gchar *pemail = NULL;
GtkClipboard *clipboard;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
contact_email =e_destination_get_address(destination);
g_signal_handlers_block_by_func (name_selector_entry, user_insert_text, name_selector_entry);
@@ -2339,7 +2326,7 @@ popup_activate_cut (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_ite
gtk_clipboard_set_text (clipboard, pemail, strlen (pemail));
gtk_editable_delete_text (GTK_EDITABLE (name_selector_entry), 0, 0);
- e_destination_store_remove_destination (name_selector_entry->destination_store, destination);
+ e_destination_store_remove_destination (name_selector_entry->priv->destination_store, destination);
g_free (pemail);
g_signal_handlers_unblock_by_func (name_selector_entry, user_delete_text, name_selector_entry);
@@ -2354,7 +2341,7 @@ popup_activate_copy (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_it
gchar *pemail;
GtkClipboard *clipboard;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
contact_email = e_destination_get_address(destination);
g_signal_handlers_block_by_func (name_selector_entry, user_insert_text, name_selector_entry);
@@ -2417,7 +2404,7 @@ populate_popup (ENameSelectorEntry *name_selector_entry, GtkMenu *menu)
gboolean is_list;
gboolean show_menu = FALSE;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
if (!destination)
return;
@@ -2654,87 +2641,88 @@ cut_clipboard (GtkEntry *entry, ENameSelectorEntry *name_selector_entry)
static void
e_name_selector_entry_init (ENameSelectorEntry *name_selector_entry)
{
- GtkCellRenderer *renderer;
- ENameSelectorEntryPrivate *priv;
- GConfClient *gconf;
+ GtkCellRenderer *renderer;
+ GConfClient *gconf;
- priv = E_NAME_SELECTOR_ENTRY_GET_PRIVATE (name_selector_entry);
+ name_selector_entry->priv =
+ E_NAME_SELECTOR_ENTRY_GET_PRIVATE (name_selector_entry);
- /* Source list */
+ /* Source list */
- if (!e_book_get_addressbooks (&name_selector_entry->source_list, NULL)) {
+ if (!e_book_get_addressbooks (&name_selector_entry->priv->source_list, NULL)) {
g_warning ("ENameSelectorEntry can't find any addressbooks!");
return;
- }
+ }
- /* read minimum_query_length from gconf*/
- gconf = gconf_client_get_default();
- if (COMPLETION_CUE_MIN_LEN == 0) {
+ /* read minimum_query_length from gconf*/
+ gconf = gconf_client_get_default();
+ if (COMPLETION_CUE_MIN_LEN == 0) {
if ((COMPLETION_CUE_MIN_LEN = gconf_client_get_int (gconf, MINIMUM_QUERY_LENGTH, NULL)))
;
else COMPLETION_CUE_MIN_LEN = 3;
- }
- COMPLETION_FORCE_SHOW_ADDRESS = gconf_client_get_bool (gconf, FORCE_SHOW_ADDRESS, NULL);
- priv->user_query_fields = gconf_client_get_list (gconf, USER_QUERY_FIELDS, GCONF_VALUE_STRING, NULL);
- g_object_unref (G_OBJECT (gconf));
+ }
+ COMPLETION_FORCE_SHOW_ADDRESS = gconf_client_get_bool (gconf, FORCE_SHOW_ADDRESS, NULL);
+ name_selector_entry->priv->user_query_fields = gconf_client_get_list (
+ gconf, USER_QUERY_FIELDS, GCONF_VALUE_STRING, NULL);
+ g_object_unref (G_OBJECT (gconf));
- /* Edit signals */
+ /* Edit signals */
- g_signal_connect (name_selector_entry, "insert-text", G_CALLBACK (user_insert_text), name_selector_entry);
- g_signal_connect (name_selector_entry, "delete-text", G_CALLBACK (user_delete_text), name_selector_entry);
- g_signal_connect (name_selector_entry, "focus-out-event", G_CALLBACK (user_focus_out), name_selector_entry);
- g_signal_connect_after (name_selector_entry, "focus-in-event", G_CALLBACK (user_focus_in), name_selector_entry);
+ g_signal_connect (name_selector_entry, "insert-text", G_CALLBACK (user_insert_text), name_selector_entry);
+ g_signal_connect (name_selector_entry, "delete-text", G_CALLBACK (user_delete_text), name_selector_entry);
+ g_signal_connect (name_selector_entry, "focus-out-event", G_CALLBACK (user_focus_out), name_selector_entry);
+ g_signal_connect_after (name_selector_entry, "focus-in-event", G_CALLBACK (user_focus_in), name_selector_entry);
- /* Exposition */
+ /* Exposition */
- g_signal_connect (name_selector_entry, "expose-event", G_CALLBACK (expose_event), name_selector_entry);
+ g_signal_connect (name_selector_entry, "expose-event", G_CALLBACK (expose_event), name_selector_entry);
- /* Activation: Complete current entry if possible */
+ /* Activation: Complete current entry if possible */
- g_signal_connect (name_selector_entry, "activate", G_CALLBACK (entry_activate), name_selector_entry);
+ g_signal_connect (name_selector_entry, "activate", G_CALLBACK (entry_activate), name_selector_entry);
- /* Pop-up menu */
+ /* Pop-up menu */
- g_signal_connect (name_selector_entry, "button-press-event", G_CALLBACK (prepare_popup_destination), name_selector_entry);
- g_signal_connect (name_selector_entry, "populate-popup", G_CALLBACK (populate_popup), name_selector_entry);
+ g_signal_connect (name_selector_entry, "button-press-event", G_CALLBACK (prepare_popup_destination), name_selector_entry);
+ g_signal_connect (name_selector_entry, "populate-popup", G_CALLBACK (populate_popup), name_selector_entry);
/* Clipboard signals */
g_signal_connect (name_selector_entry, "copy-clipboard", G_CALLBACK (copy_clipboard), name_selector_entry);
g_signal_connect (name_selector_entry, "cut-clipboard", G_CALLBACK (cut_clipboard), name_selector_entry);
- /* Completion */
+ /* Completion */
- name_selector_entry->email_generator = NULL;
+ name_selector_entry->priv->email_generator = NULL;
- name_selector_entry->entry_completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_match_func (name_selector_entry->entry_completion,
+ name_selector_entry->priv->entry_completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_match_func (name_selector_entry->priv->entry_completion,
(GtkEntryCompletionMatchFunc) completion_match_cb, NULL, NULL);
- g_signal_connect_swapped (name_selector_entry->entry_completion, "match-selected",
+ g_signal_connect_swapped (name_selector_entry->priv->entry_completion, "match-selected",
G_CALLBACK (completion_match_selected), name_selector_entry);
- gtk_entry_set_completion (GTK_ENTRY (name_selector_entry), name_selector_entry->entry_completion);
+ gtk_entry_set_completion (GTK_ENTRY (name_selector_entry), name_selector_entry->priv->entry_completion);
renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (name_selector_entry->entry_completion), renderer, FALSE);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (name_selector_entry->entry_completion),
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (name_selector_entry->priv->entry_completion), renderer, FALSE);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (name_selector_entry->priv->entry_completion),
GTK_CELL_RENDERER (renderer),
(GtkCellLayoutDataFunc) contact_layout_pixbuffer,
name_selector_entry, NULL);
- /* Completion list name renderer */
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (name_selector_entry->entry_completion),
+ /* Completion list name renderer */
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (name_selector_entry->priv->entry_completion),
renderer, TRUE);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (name_selector_entry->entry_completion),
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (name_selector_entry->priv->entry_completion),
GTK_CELL_RENDERER (renderer),
(GtkCellLayoutDataFunc) contact_layout_formatter,
name_selector_entry, NULL);
- /* Destination store */
+ /* Destination store */
- name_selector_entry->destination_store = e_destination_store_new ();
- setup_destination_store (name_selector_entry);
- priv->is_completing = FALSE;
+ name_selector_entry->priv->destination_store = e_destination_store_new ();
+ setup_destination_store (name_selector_entry);
+ name_selector_entry->priv->is_completing = FALSE;
}
/**
@@ -2763,7 +2751,7 @@ e_name_selector_entry_peek_contact_store (ENameSelectorEntry *name_selector_entr
{
g_return_val_if_fail (E_IS_NAME_SELECTOR_ENTRY (name_selector_entry), NULL);
- return name_selector_entry->contact_store;
+ return name_selector_entry->priv->contact_store;
}
/**
@@ -2780,14 +2768,14 @@ e_name_selector_entry_set_contact_store (ENameSelectorEntry *name_selector_entry
g_return_if_fail (E_IS_NAME_SELECTOR_ENTRY (name_selector_entry));
g_return_if_fail (contact_store == NULL || E_IS_CONTACT_STORE (contact_store));
- if (contact_store == name_selector_entry->contact_store)
+ if (contact_store == name_selector_entry->priv->contact_store)
return;
- if (name_selector_entry->contact_store)
- g_object_unref (name_selector_entry->contact_store);
- name_selector_entry->contact_store = contact_store;
- if (name_selector_entry->contact_store)
- g_object_ref (name_selector_entry->contact_store);
+ if (name_selector_entry->priv->contact_store)
+ g_object_unref (name_selector_entry->priv->contact_store);
+ name_selector_entry->priv->contact_store = contact_store;
+ if (name_selector_entry->priv->contact_store)
+ g_object_ref (name_selector_entry->priv->contact_store);
setup_contact_store (name_selector_entry);
}
@@ -2805,7 +2793,7 @@ e_name_selector_entry_peek_destination_store (ENameSelectorEntry *name_selector_
{
g_return_val_if_fail (E_IS_NAME_SELECTOR_ENTRY (name_selector_entry), NULL);
- return name_selector_entry->destination_store;
+ return name_selector_entry->priv->destination_store;
}
/**
@@ -2823,15 +2811,23 @@ e_name_selector_entry_set_destination_store (ENameSelectorEntry *name_selector_
g_return_if_fail (E_IS_NAME_SELECTOR_ENTRY (name_selector_entry));
g_return_if_fail (E_IS_DESTINATION_STORE (destination_store));
- if (destination_store == name_selector_entry->destination_store)
+ if (destination_store == name_selector_entry->priv->destination_store)
return;
- g_object_unref (name_selector_entry->destination_store);
- name_selector_entry->destination_store = g_object_ref (destination_store);
+ g_object_unref (name_selector_entry->priv->destination_store);
+ name_selector_entry->priv->destination_store = g_object_ref (destination_store);
setup_destination_store (name_selector_entry);
}
+EDestination *
+e_name_selector_entry_get_popup_destination (ENameSelectorEntry *name_selector_entry)
+{
+ g_return_val_if_fail (E_IS_NAME_SELECTOR_ENTRY (name_selector_entry), NULL);
+
+ return name_selector_entry->priv->popup_destination;
+}
+
/**
* e_name_selector_entry_set_contact_editor_func:
*
@@ -2840,7 +2836,7 @@ e_name_selector_entry_set_destination_store (ENameSelectorEntry *name_selector_
void
e_name_selector_entry_set_contact_editor_func (ENameSelectorEntry *name_selector_entry, gpointer func)
{
- name_selector_entry->contact_editor_func = func;
+ name_selector_entry->priv->contact_editor_func = func;
}
/**
@@ -2851,5 +2847,5 @@ e_name_selector_entry_set_contact_editor_func (ENameSelectorEntry *name_selector
void
e_name_selector_entry_set_contact_list_editor_func (ENameSelectorEntry *name_selector_entry, gpointer func)
{
- name_selector_entry->contact_list_editor_func = func;
+ name_selector_entry->priv->contact_list_editor_func = func;
}
diff --git a/libedataserverui/e-name-selector-entry.h b/libedataserverui/e-name-selector-entry.h
index e7ae409..99a18ab 100644
--- a/libedataserverui/e-name-selector-entry.h
+++ b/libedataserverui/e-name-selector-entry.h
@@ -67,56 +67,52 @@
G_BEGIN_DECLS
-typedef struct _ENameSelectorEntry ENameSelectorEntry;
+typedef struct _ENameSelectorEntry ENameSelectorEntry;
typedef struct _ENameSelectorEntryClass ENameSelectorEntryClass;
+typedef struct _ENameSelectorEntryPrivate ENameSelectorEntryPrivate;
+
+struct _ENameSelectorEntry {
+ GtkEntry parent;
+ ENameSelectorEntryPrivate *priv;
+};
struct _ENameSelectorEntryClass {
GtkEntryClass parent_class;
+
void (*updated) (ENameSelectorEntry *entry, gchar *email);
+
gpointer reserved1;
gpointer reserved2;
};
-struct _ENameSelectorEntry {
- GtkEntry parent;
-
- /* Private */
-
- PangoAttrList *attr_list;
- ESourceList *source_list;
- EContactStore *contact_store;
- ETreeModelGenerator *email_generator;
- EDestinationStore *destination_store;
- GtkEntryCompletion *entry_completion;
-
- guint type_ahead_complete_cb_id;
- guint update_completions_cb_id;
-
- EDestination *popup_destination;
-
- /* TEMPORARY */
- gpointer (*contact_editor_func) (EBook *, EContact *, gboolean, gboolean);
- gpointer (*contact_list_editor_func) (EBook *, EContact *, gboolean, gboolean);
-};
-
-GType e_name_selector_entry_get_type (void);
-ENameSelectorEntry *e_name_selector_entry_new (void);
-
-EContactStore *e_name_selector_entry_peek_contact_store (ENameSelectorEntry *name_selector_entry);
-void e_name_selector_entry_set_contact_store (ENameSelectorEntry *name_selector_entry,
- EContactStore *contact_store);
-
-EDestinationStore *e_name_selector_entry_peek_destination_store (ENameSelectorEntry *name_selector_entry);
-void e_name_selector_entry_set_destination_store (ENameSelectorEntry *name_selector_entry,
- EDestinationStore *destination_store);
+GType e_name_selector_entry_get_type (void);
+ENameSelectorEntry *
+ e_name_selector_entry_new (void);
+EContactStore * e_name_selector_entry_peek_contact_store
+ (ENameSelectorEntry *name_selector_entry);
+void e_name_selector_entry_set_contact_store
+ (ENameSelectorEntry *name_selector_entry,
+ EContactStore *contact_store);
+EDestinationStore *
+ e_name_selector_entry_peek_destination_store
+ (ENameSelectorEntry *name_selector_entry);
+void e_name_selector_entry_set_destination_store
+ (ENameSelectorEntry *name_selector_entry,
+ EDestinationStore *destination_store);
+EDestination * e_name_selector_entry_get_popup_destination
+ (ENameSelectorEntry *name_selector_entry);
/* TEMPORARY API - DO NOT USE */
-void e_name_selector_entry_set_contact_editor_func (ENameSelectorEntry *name_selector_entry,
- gpointer func);
-void e_name_selector_entry_set_contact_list_editor_func (ENameSelectorEntry *name_selector_entry,
- gpointer func);
-
-gchar *ens_util_populate_user_query_fields (GSList *user_query_fields, const gchar *cue_str, const gchar *encoded_cue_str);
+void e_name_selector_entry_set_contact_editor_func
+ (ENameSelectorEntry *name_selector_entry,
+ gpointer func);
+void e_name_selector_entry_set_contact_list_editor_func
+ (ENameSelectorEntry *name_selector_entry,
+ gpointer func);
+gchar * ens_util_populate_user_query_fields
+ (GSList *user_query_fields,
+ const gchar *cue_str,
+ const gchar *encoded_cue_str);
G_END_DECLS
diff --git a/libedataserverui/e-name-selector-list.c b/libedataserverui/e-name-selector-list.c
index 2b14601..f3be29c 100644
--- a/libedataserverui/e-name-selector-list.c
+++ b/libedataserverui/e-name-selector-list.c
@@ -37,12 +37,21 @@
#include <libedataserverui/e-name-selector-entry.h>
#include "e-name-selector-list.h"
+#define E_NAME_SELECTOR_LIST_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_NAME_SELECTOR_LIST, ENameSelectorListPrivate))
+
#define MAX_ROW 10
-G_DEFINE_TYPE (ENameSelectorList, e_name_selector_list, E_TYPE_NAME_SELECTOR_ENTRY)
+struct _ENameSelectorListPrivate {
+ GtkWindow *popup;
+ GtkWidget *tree_view;
+ GtkWidget *menu;
+ EDestinationStore *store;
+ gint rows;
+};
-static void e_name_selector_list_dispose (GObject *object);
-static void e_name_selector_list_finalize (GObject *object);
+G_DEFINE_TYPE (ENameSelectorList, e_name_selector_list, E_TYPE_NAME_SELECTOR_ENTRY)
/* Signals */
@@ -53,19 +62,19 @@ enl_popup_size (ENameSelectorList *list)
GtkAllocation allocation;
GtkTreeViewColumn *column = NULL;
- column = gtk_tree_view_get_column ( GTK_TREE_VIEW (list->tree_view), 0);
+ column = gtk_tree_view_get_column ( GTK_TREE_VIEW (list->priv->tree_view), 0);
if (column)
gtk_tree_view_column_cell_get_size (column, NULL, NULL, NULL, NULL, &height);
/* Show a maximum of 10 rows in the popup list view */
- count = list->rows;
+ count = list->priv->rows;
if (count > MAX_ROW)
count = MAX_ROW;
if (count <= 0)
count = 1;
gtk_widget_get_allocation (GTK_WIDGET (list), &allocation);
- gtk_widget_set_size_request (list->tree_view, allocation.width - 3 , height * count);
+ gtk_widget_set_size_request (list->priv->tree_view, allocation.width - 3 , height * count);
}
static void
@@ -82,18 +91,20 @@ enl_popup_position (ENameSelectorList *list)
gdk_window_get_origin (window, &x, &y);
y = y + allocation.height;
- gtk_window_move (list->popup, x, y);
+ gtk_window_move (list->priv->popup, x, y);
}
static void
enl_popup_grab (ENameSelectorList *list)
{
+ EDestinationStore *store;
+ ENameSelectorEntry *entry;
GdkWindow *window;
gint len;
- window = gtk_widget_get_window (GTK_WIDGET (list->popup));
+ window = gtk_widget_get_window (GTK_WIDGET (list->priv->popup));
- gtk_grab_add (GTK_WIDGET (list->popup));
+ gtk_grab_add (GTK_WIDGET (list->priv->popup));
gdk_pointer_grab (window, TRUE,
GDK_BUTTON_PRESS_MASK |
@@ -105,7 +116,11 @@ enl_popup_grab (ENameSelectorList *list)
gtk_widget_grab_focus ((GtkWidget *)list);
/* Build the listview from the model */
- gtk_tree_view_set_model (GTK_TREE_VIEW (list->tree_view), GTK_TREE_MODEL(((ENameSelectorEntry *)list)->destination_store));
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ store = e_name_selector_entry_peek_destination_store (entry);
+ gtk_tree_view_set_model (
+ GTK_TREE_VIEW (list->priv->tree_view),
+ GTK_TREE_MODEL (store));
/* If any selection of text is present, unselect it */
len = strlen(gtk_entry_get_text(GTK_ENTRY(list)));
@@ -115,11 +130,11 @@ enl_popup_grab (ENameSelectorList *list)
static void
enl_popup_ungrab (ENameSelectorList *list)
{
- if (!gtk_widget_has_grab (GTK_WIDGET (list->popup)))
+ if (!gtk_widget_has_grab (GTK_WIDGET (list->priv->popup)))
return;
gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gtk_grab_remove (GTK_WIDGET (list->popup));
+ gtk_grab_remove (GTK_WIDGET (list->priv->popup));
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
}
@@ -139,10 +154,10 @@ static gboolean
enl_entry_focus_out (ENameSelectorList *list, GdkEventFocus *event, gpointer dummy)
{
/* When we lose focus and popup is still present hide it. Dont do it, when we click the popup. Look for grab */
- if (gtk_widget_get_visible (GTK_WIDGET (list->popup))
- && !gtk_widget_has_grab (GTK_WIDGET (list->popup))) {
+ if (gtk_widget_get_visible (GTK_WIDGET (list->priv->popup))
+ && !gtk_widget_has_grab (GTK_WIDGET (list->priv->popup))) {
enl_popup_ungrab (list);
- gtk_widget_hide ((GtkWidget *)list->popup);
+ gtk_widget_hide ((GtkWidget *)list->priv->popup);
return FALSE;
}
@@ -162,7 +177,7 @@ enl_popup_button_press (GtkWidget *widget,
#endif
return FALSE;
/* if we come here, it's usually time to popdown */
- gtk_widget_hide ((GtkWidget *)list->popup);
+ gtk_widget_hide ((GtkWidget *)list->priv->popup);
return TRUE;
}
@@ -182,7 +197,7 @@ enl_popup_enter_notify (GtkWidget *widget,
GdkEventCrossing *event,
ENameSelectorList *list)
{
- if (event->type == GDK_ENTER_NOTIFY && !gtk_widget_has_grab (GTK_WIDGET (list->popup)))
+ if (event->type == GDK_ENTER_NOTIFY && !gtk_widget_has_grab (GTK_WIDGET (list->priv->popup)))
enl_popup_grab (list);
return TRUE;
@@ -192,21 +207,29 @@ static void
enl_tree_select_node (ENameSelectorList *list,
gint n)
{
+ EDestinationStore *store;
+ ENameSelectorEntry *entry;
GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+ GtkTreeView *tree_view;
GtkTreeIter iter;
GtkTreePath *path;
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->tree_view));
- iter.stamp = ((ENameSelectorEntry *) list)->destination_store->stamp;
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ tree_view = GTK_TREE_VIEW (list->priv->tree_view);
+ store = e_name_selector_entry_peek_destination_store (entry);
+ selection = gtk_tree_view_get_selection (tree_view);
+ iter.stamp = e_destination_store_get_stamp (store);
iter.user_data = GINT_TO_POINTER (n-1);
gtk_tree_selection_unselect_all (selection);
gtk_tree_selection_select_iter (selection, &iter);
- path = e_destination_store_get_path (GTK_TREE_MODEL(((ENameSelectorEntry *) list)->destination_store), &iter);
- gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW (list->tree_view), path, gtk_tree_view_get_column( GTK_TREE_VIEW (list->tree_view), 0), FALSE, 0, 0);
- gtk_tree_view_set_cursor ( GTK_TREE_VIEW (list->tree_view), path, gtk_tree_view_get_column( GTK_TREE_VIEW (list->tree_view), 0), FALSE);
- gtk_widget_grab_focus (list->tree_view);
+ column = gtk_tree_view_get_column (tree_view, 0);
+ path = e_destination_store_get_path (GTK_TREE_MODEL (store), &iter);
+ gtk_tree_view_scroll_to_cell (tree_view, path, column, FALSE, 0, 0);
+ gtk_tree_view_set_cursor (tree_view, path, column, FALSE);
+ gtk_widget_grab_focus (GTK_WIDGET (tree_view));
/*Fixme: We should grab the focus to the column. How? */
gtk_tree_path_free (path);
@@ -217,11 +240,17 @@ enl_entry_key_press_event (ENameSelectorList *list,
GdkEventKey *event,
gpointer dummy)
{
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
+
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ store = e_name_selector_entry_peek_destination_store (entry);
+
if ( (event->state & GDK_CONTROL_MASK) && (event->keyval == GDK_Down)) {
enl_popup_position (list);
- gtk_widget_show_all (GTK_WIDGET (list->popup));
+ gtk_widget_show_all (GTK_WIDGET (list->priv->popup));
enl_popup_grab (list);
- list->rows = e_destination_store_get_destination_count (((ENameSelectorEntry *) list)->destination_store);
+ list->priv->rows = e_destination_store_get_destination_count (store);
enl_popup_size (list);
enl_tree_select_node (list, 1);
return TRUE;
@@ -232,18 +261,23 @@ enl_entry_key_press_event (ENameSelectorList *list,
static void
delete_row (GtkTreePath *path, ENameSelectorList *list)
{
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
GtkTreeIter iter;
gint n, len;
GtkTreeSelection *selection;
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (E_NAME_SELECTOR_ENTRY (list)->destination_store), &iter, path))
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ store = e_name_selector_entry_peek_destination_store (entry);
+
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
return;
- selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (list->tree_view));
- len = e_destination_store_get_destination_count (E_NAME_SELECTOR_ENTRY (list)->destination_store);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->priv->tree_view));
+ len = e_destination_store_get_destination_count (store);
n = GPOINTER_TO_INT (iter.user_data);
- e_destination_store_remove_destination_nth (((ENameSelectorEntry *) list)->destination_store, n);
+ e_destination_store_remove_destination_nth (store, n);
/* If the last one is deleted select the last but one or the deleted +1 */
if (n == len -1)
@@ -252,13 +286,13 @@ delete_row (GtkTreePath *path, ENameSelectorList *list)
/* We deleted the last entry */
if (len == 1) {
enl_popup_ungrab (list);
- if (list->menu)
- gtk_menu_popdown(GTK_MENU (list->menu));
- gtk_widget_hide ( GTK_WIDGET (list->popup));
+ if (list->priv->menu)
+ gtk_menu_popdown (GTK_MENU (list->priv->menu));
+ gtk_widget_hide (GTK_WIDGET (list->priv->popup));
return;
}
- iter.stamp = ((ENameSelectorEntry *) list)->destination_store->stamp;
+ iter.stamp = e_destination_store_get_stamp (store);
iter.user_data = GINT_TO_POINTER (n);
gtk_tree_selection_unselect_all (selection);
@@ -266,9 +300,8 @@ delete_row (GtkTreePath *path, ENameSelectorList *list)
gtk_tree_path_free (path);
- list->rows = e_destination_store_get_destination_count (((ENameSelectorEntry *) list)->destination_store);
+ list->priv->rows = e_destination_store_get_destination_count (store);
enl_popup_size (list);
-
}
static void
@@ -278,7 +311,7 @@ popup_activate_email (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_i
EContact *contact;
gint email_num;
- destination = name_selector_entry->popup_destination;
+ destination = e_name_selector_entry_get_popup_destination (name_selector_entry);
if (!destination)
return;
@@ -352,7 +385,8 @@ enl_tree_button_press_event (GtkWidget *widget,
{
GtkWidget *menu;
EDestination *destination;
- ENameSelectorEntry *name_selector_entry;
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
EContact *contact;
GtkWidget *menu_item;
GList *email_list = NULL, *l;
@@ -363,16 +397,22 @@ enl_tree_button_press_event (GtkWidget *widget,
gboolean is_list;
gboolean show_menu = FALSE;
GtkTreeSelection *selection;
+ GtkTreeView *tree_view;
GtkTreePath *path;
PopupDeleteRowInfo *row_info;
GtkTreeIter iter;
- if (!gtk_widget_has_grab (GTK_WIDGET (list->popup)))
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ tree_view = GTK_TREE_VIEW (list->priv->tree_view);
+ store = e_name_selector_entry_peek_destination_store (entry);
+
+ if (!gtk_widget_has_grab (GTK_WIDGET (list->priv->popup)))
enl_popup_grab (list);
- gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW (list->tree_view), event->x, event->y, &path, NULL);
- selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (list->tree_view));
- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (E_NAME_SELECTOR_ENTRY (list)->destination_store), &iter, path))
+ gtk_tree_view_get_dest_row_at_pos (
+ tree_view, event->x, event->y, &path, NULL);
+ selection = gtk_tree_view_get_selection (tree_view);
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
return FALSE;
gtk_tree_selection_unselect_all (selection);
@@ -382,9 +422,7 @@ enl_tree_button_press_event (GtkWidget *widget,
return FALSE;
}
- name_selector_entry = E_NAME_SELECTOR_ENTRY (list);
-
- destination = e_destination_store_get_destination ( ((ENameSelectorEntry *)list)->destination_store, &iter);
+ destination = e_destination_store_get_destination (store, &iter);
if (!destination)
return FALSE;
@@ -393,12 +431,12 @@ enl_tree_button_press_event (GtkWidget *widget,
if (!contact)
return FALSE;
- if (list->menu) {
- gtk_menu_popdown (GTK_MENU (list->menu));
+ if (list->priv->menu) {
+ gtk_menu_popdown (GTK_MENU (list->priv->menu));
}
menu = gtk_menu_new ();
g_signal_connect (menu, "deactivate", G_CALLBACK(menu_deactivate), list);
- list->menu = menu;
+ list->priv->menu = menu;
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, gtk_get_current_event_time());
email_num = e_destination_get_email_num (destination);
@@ -461,7 +499,7 @@ enl_tree_button_press_event (GtkWidget *widget,
if (i == email_num && len > 1) {
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (popup_activate_email),
- name_selector_entry);
+ entry);
}
}
g_list_foreach (email_list, (GFunc) g_free, NULL);
@@ -500,14 +538,16 @@ enl_tree_key_press_event (GtkWidget *w,
{
if (event->keyval == GDK_Escape) {
enl_popup_ungrab (list);
- gtk_widget_hide ( GTK_WIDGET (list->popup));
+ gtk_widget_hide ( GTK_WIDGET (list->priv->popup));
return TRUE;
} else if (event->keyval == GDK_Delete) {
GtkTreeSelection *selection;
+ GtkTreeView *tree_view;
GList *paths;
- selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (list->tree_view));
- paths = gtk_tree_selection_get_selected_rows (selection, (GtkTreeModel **)&(E_NAME_SELECTOR_ENTRY (list)->destination_store));
+ tree_view = GTK_TREE_VIEW (list->priv->tree_view);
+ selection = gtk_tree_view_get_selection (tree_view);
+ paths = gtk_tree_selection_get_selected_rows (selection, NULL);
paths = g_list_reverse (paths);
g_list_foreach (paths, (GFunc) delete_row, list);
g_list_free (paths);
@@ -516,7 +556,7 @@ enl_tree_key_press_event (GtkWidget *w,
&& event->keyval != GDK_Control_R && event->keyval != GDK_Control_L) {
enl_popup_ungrab (list);
- gtk_widget_hide ( GTK_WIDGET (list->popup));
+ gtk_widget_hide ( GTK_WIDGET (list->priv->popup));
gtk_widget_event (GTK_WIDGET (list), (GdkEvent *)event);
return TRUE;
}
@@ -527,61 +567,55 @@ enl_tree_key_press_event (GtkWidget *w,
void
e_name_selector_list_expand_clicked(ENameSelectorList *list)
{
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
+
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ store = e_name_selector_entry_peek_destination_store (entry);
- if (!gtk_widget_get_visible (GTK_WIDGET (list->popup))) {
+ if (!gtk_widget_get_visible (GTK_WIDGET (list->priv->popup))) {
enl_popup_position (list);
- gtk_widget_show_all (GTK_WIDGET (list->popup));
+ gtk_widget_show_all (GTK_WIDGET (list->priv->popup));
enl_popup_grab (list);
- list->rows = e_destination_store_get_destination_count (((ENameSelectorEntry *) list)->destination_store);
+ list->priv->rows = e_destination_store_get_destination_count (store);
enl_popup_size (list);
enl_tree_select_node (list, 1);
}
else {
enl_popup_ungrab (list);
- if (list->menu)
- gtk_menu_popdown(GTK_MENU (list->menu));
- gtk_widget_hide (GTK_WIDGET (list->popup));
+ if (list->priv->menu)
+ gtk_menu_popdown(GTK_MENU (list->priv->menu));
+ gtk_widget_hide (GTK_WIDGET (list->priv->popup));
}
}
-/* Object Methods */
-static void
-e_name_selector_list_dispose (GObject *object)
-{
- if (G_OBJECT_CLASS (e_name_selector_list_parent_class)->dispose)
- G_OBJECT_CLASS (e_name_selector_list_parent_class)->dispose (object);
-}
static void
-e_name_selector_list_finalize (GObject *object)
+name_selector_list_realize (GtkWidget *widget)
{
- if (G_OBJECT_CLASS (e_name_selector_list_parent_class)->finalize)
- G_OBJECT_CLASS (e_name_selector_list_parent_class)->finalize (object);
-}
+ ENameSelectorList *list;
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
-static void
-e_name_selector_list_realize (GtkWidget *widget)
-{
- ENameSelectorList *list = (ENameSelectorList *)widget;
+ /* Chain up to parent's realize() method. */
GTK_WIDGET_CLASS (e_name_selector_list_parent_class)->realize (widget);
- gtk_tree_view_set_model ( GTK_TREE_VIEW (list->tree_view), GTK_TREE_MODEL(((ENameSelectorEntry *)list)->destination_store));
+ list = E_NAME_SELECTOR_LIST (widget);
+ entry = E_NAME_SELECTOR_ENTRY (widget);
+ store = e_name_selector_entry_peek_destination_store (entry);
+
+ gtk_tree_view_set_model (
+ GTK_TREE_VIEW (list->priv->tree_view), GTK_TREE_MODEL (store));
}
static void
-e_name_selector_list_class_init (ENameSelectorListClass *name_selector_list_class)
+e_name_selector_list_class_init (ENameSelectorListClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (name_selector_list_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (name_selector_list_class);
-
- object_class->dispose = e_name_selector_list_dispose;
- object_class->finalize = e_name_selector_list_finalize;
-
- widget_class->realize = e_name_selector_list_realize;
+ GtkWidgetClass *widget_class;
- /* Install properties */
-
- /* Install signals */
+ g_type_class_add_private (class, sizeof (ENameSelectorListPrivate));
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = name_selector_list_realize;
}
static void
@@ -591,20 +625,26 @@ e_name_selector_list_init (ENameSelectorList *list)
GtkWidget *scroll, *popup_frame, *vbox;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
- ENameSelectorEntry *entry = E_NAME_SELECTOR_ENTRY (list);
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
GtkEntryCompletion *completion;
- list->store = e_destination_store_new ();
- list->menu = NULL;
+ list->priv = E_NAME_SELECTOR_LIST_GET_PRIVATE (list);
+
+ list->priv->store = e_destination_store_new ();
+ list->priv->menu = NULL;
+
+ entry = E_NAME_SELECTOR_ENTRY (list);
+ store = e_name_selector_entry_peek_destination_store (entry);
- list->tree_view = GTK_WIDGET (gtk_tree_view_new_with_model (GTK_TREE_MODEL(entry->destination_store)));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list->tree_view), FALSE);
- gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (list->tree_view), FALSE);
+ list->priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list->priv->tree_view), FALSE);
+ gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (list->priv->tree_view), FALSE);
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->tree_view));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list->priv->tree_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
gtk_tree_selection_unselect_all (selection);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (list->tree_view), FALSE);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (list->priv->tree_view), FALSE);
completion = gtk_entry_get_completion (GTK_ENTRY(list));
gtk_entry_completion_set_inline_completion (completion, TRUE);
@@ -612,7 +652,7 @@ e_name_selector_list_init (ENameSelectorList *list)
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Name", renderer, "text", E_DESTINATION_STORE_COLUMN_ADDRESS, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (list->tree_view), column);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (list->priv->tree_view), column);
gtk_tree_view_column_set_clickable (column, TRUE);
scroll = gtk_scrolled_window_new (NULL, NULL);
@@ -625,19 +665,19 @@ e_name_selector_list_init (ENameSelectorList *list)
gtk_scrolled_window_get_vscrollbar (
GTK_SCROLLED_WINDOW (scroll)), -1, 0);
- list->popup = GTK_WINDOW (gtk_window_new (GTK_WINDOW_POPUP));
- gtk_window_set_resizable (GTK_WINDOW (list->popup), FALSE);
+ list->priv->popup = GTK_WINDOW (gtk_window_new (GTK_WINDOW_POPUP));
+ gtk_window_set_resizable (GTK_WINDOW (list->priv->popup), FALSE);
popup_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (popup_frame),
GTK_SHADOW_ETCHED_IN);
- gtk_container_add (GTK_CONTAINER (list->popup), popup_frame);
+ gtk_container_add (GTK_CONTAINER (list->priv->popup), popup_frame);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (popup_frame), vbox);
- gtk_container_add (GTK_CONTAINER (scroll), list->tree_view);
+ gtk_container_add (GTK_CONTAINER (scroll), list->priv->tree_view);
gtk_box_pack_start (GTK_BOX (vbox), scroll,
TRUE, TRUE, 0);
@@ -645,12 +685,12 @@ e_name_selector_list_init (ENameSelectorList *list)
g_signal_connect (GTK_WIDGET (list), "focus-out-event", G_CALLBACK(enl_entry_focus_out), NULL);
g_signal_connect (GTK_WIDGET (list), "key-press-event", G_CALLBACK(enl_entry_key_press_event), NULL);
- g_signal_connect_after (list->tree_view, "key-press-event", G_CALLBACK(enl_tree_key_press_event), list);
- g_signal_connect (list->tree_view, "button-press-event", G_CALLBACK (enl_tree_button_press_event), list);
+ g_signal_connect_after (list->priv->tree_view, "key-press-event", G_CALLBACK(enl_tree_key_press_event), list);
+ g_signal_connect (list->priv->tree_view, "button-press-event", G_CALLBACK (enl_tree_button_press_event), list);
- g_signal_connect (GTK_WIDGET (list->popup), "button-press-event", G_CALLBACK(enl_popup_button_press), list);
- g_signal_connect (GTK_WIDGET (list->popup), "focus-out-event", G_CALLBACK(enl_popup_focus_out), list);
- g_signal_connect (GTK_WIDGET (list->popup), "enter-notify-event", G_CALLBACK (enl_popup_enter_notify), list);
+ g_signal_connect (GTK_WIDGET (list->priv->popup), "button-press-event", G_CALLBACK(enl_popup_button_press), list);
+ g_signal_connect (GTK_WIDGET (list->priv->popup), "focus-out-event", G_CALLBACK(enl_popup_focus_out), list);
+ g_signal_connect (GTK_WIDGET (list->priv->popup), "enter-notify-event", G_CALLBACK (enl_popup_enter_notify), list);
}
diff --git a/libedataserverui/e-name-selector-list.h b/libedataserverui/e-name-selector-list.h
index edd1f00..1e0bca9 100644
--- a/libedataserverui/e-name-selector-list.h
+++ b/libedataserverui/e-name-selector-list.h
@@ -32,49 +32,46 @@
#include <libedataserverui/e-tree-model-generator.h>
#include <libedataserverui/e-name-selector-entry.h>
-G_BEGIN_DECLS
-
/* Standard GObject macros */
#define E_TYPE_NAME_SELECTOR_LIST \
(e_name_selector_list_get_type ())
#define E_NAME_SELECTOR_LIST(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), e_name_selector_list_get_type (), ENameSelectorEntry))
+ ((obj), E_TYPE_NAME_SELECTOR_LIST, ENameSelectorList))
#define E_NAME_SELECTOR_LIST_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
- ((cls), e_name_selector_list_get_type (), ENameSelectorEntryClass))
+ ((cls), E_TYPE_NAME_SELECTOR_LIST, ENameSelectorListClass))
#define E_IS_NAME_SELECTOR_LIST(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), e_name_selector_list_get_type ()))
+ ((obj), E_TYPE_NAME_SELECTOR_LIST))
#define E_IS_NAME_SELECTOR_LIST_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
- ((cls), e_name_selector_list_get_type ()))
+ ((cls), E_TYPE_NAME_SELECTOR_LIST))
#define E_NAME_SELECTOR_LIST_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_NAME_SELECTOR_LIST_TYPE, ENameSelectorEntryClass))
-
-typedef struct _ENameSelectorList ENameSelectorList;
-typedef struct _ENameSelectorListClass ENameSelectorListClass;
+ ((obj), E_TYPE_NAME_SELECTOR_LIST, ENameSelectorListClass))
-struct _ENameSelectorListClass {
- ENameSelectorEntryClass parent_class;
+G_BEGIN_DECLS
- /* Signals */
-};
+typedef struct _ENameSelectorList ENameSelectorList;
+typedef struct _ENameSelectorListClass ENameSelectorListClass;
+typedef struct _ENameSelectorListPrivate ENameSelectorListPrivate;
struct _ENameSelectorList {
- ENameSelectorEntry parent;
+ ENameSelectorEntry parent;
+ ENameSelectorListPrivate *priv;
+};
- GtkWindow *popup;
- GtkWidget *tree_view;
- GtkWidget *menu;
- EDestinationStore *store;
- gint rows;
+struct _ENameSelectorListClass {
+ ENameSelectorEntryClass parent_class;
};
-GType e_name_selector_list_get_type (void);
-ENameSelectorList *e_name_selector_list_new (void);
-void e_name_selector_list_expand_clicked (ENameSelectorList *list);
+GType e_name_selector_list_get_type (void);
+ENameSelectorList *
+ e_name_selector_list_new (void);
+void e_name_selector_list_expand_clicked
+ (ENameSelectorList *list);
G_END_DECLS
-#endif
+
+#endif /* E_NAME_SELECTOR_LIST_H */
diff --git a/libedataserverui/e-name-selector-model.c b/libedataserverui/e-name-selector-model.c
index 033ec19..40064b2 100644
--- a/libedataserverui/e-name-selector-model.c
+++ b/libedataserverui/e-name-selector-model.c
@@ -29,6 +29,10 @@
#include <glib/gi18n-lib.h>
#include "e-name-selector-model.h"
+#define E_NAME_SELECTOR_MODEL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_NAME_SELECTOR_MODEL, ENameSelectorModelPrivate))
+
typedef struct {
gchar *name;
gchar *pretty_name;
@@ -37,6 +41,13 @@ typedef struct {
}
Section;
+struct _ENameSelectorModelPrivate {
+ GArray *sections;
+ EContactStore *contact_store;
+ ETreeModelGenerator *contact_filter;
+ GHashTable *destination_uid_hash;
+};
+
static gint generate_contact_rows (EContactStore *contact_store, GtkTreeIter *iter,
ENameSelectorModel *name_selector_model);
static void override_email_address (EContactStore *contact_store, GtkTreeIter *iter,
@@ -63,66 +74,75 @@ G_DEFINE_TYPE (ENameSelectorModel, e_name_selector_model, G_TYPE_OBJECT)
static void
e_name_selector_model_init (ENameSelectorModel *name_selector_model)
{
- name_selector_model->sections = g_array_new (FALSE, FALSE, sizeof (Section));
- name_selector_model->contact_store = e_contact_store_new ();
-
- name_selector_model->contact_filter =
- e_tree_model_generator_new (GTK_TREE_MODEL (name_selector_model->contact_store));
- e_tree_model_generator_set_generate_func (name_selector_model->contact_filter,
+ name_selector_model->priv =
+ E_NAME_SELECTOR_MODEL_GET_PRIVATE (name_selector_model);
+ name_selector_model->priv->sections = g_array_new (FALSE, FALSE, sizeof (Section));
+ name_selector_model->priv->contact_store = e_contact_store_new ();
+
+ name_selector_model->priv->contact_filter =
+ e_tree_model_generator_new (GTK_TREE_MODEL (name_selector_model->priv->contact_store));
+ e_tree_model_generator_set_generate_func (name_selector_model->priv->contact_filter,
(ETreeModelGeneratorGenerateFunc) generate_contact_rows,
name_selector_model, NULL);
- e_tree_model_generator_set_modify_func (name_selector_model->contact_filter,
+ e_tree_model_generator_set_modify_func (name_selector_model->priv->contact_filter,
(ETreeModelGeneratorModifyFunc) override_email_address,
name_selector_model, NULL);
- g_object_unref (name_selector_model->contact_store);
+ g_object_unref (name_selector_model->priv->contact_store);
- name_selector_model->destination_uid_hash = NULL;
+ name_selector_model->priv->destination_uid_hash = NULL;
}
static void
-e_name_selector_model_finalize (GObject *object)
+name_selector_model_finalize (GObject *object)
{
- ENameSelectorModel *name_selector_model = E_NAME_SELECTOR_MODEL (object);
- gint i;
+ ENameSelectorModelPrivate *priv;
+ gint i;
+
+ priv = E_NAME_SELECTOR_MODEL_GET_PRIVATE (object);
- for (i = 0; i < name_selector_model->sections->len; i++)
- free_section (name_selector_model, i);
+ for (i = 0; i < priv->sections->len; i++)
+ free_section (E_NAME_SELECTOR_MODEL (object), i);
- g_array_free (name_selector_model->sections, TRUE);
- g_object_unref (name_selector_model->contact_filter);
+ g_array_free (priv->sections, TRUE);
+ g_object_unref (priv->contact_filter);
- if (name_selector_model->destination_uid_hash)
- g_hash_table_destroy (name_selector_model->destination_uid_hash);
+ if (priv->destination_uid_hash)
+ g_hash_table_destroy (priv->destination_uid_hash);
- if (G_OBJECT_CLASS (e_name_selector_model_parent_class)->finalize)
- G_OBJECT_CLASS (e_name_selector_model_parent_class)->finalize (object);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_name_selector_model_parent_class)->finalize (object);
}
static void
-e_name_selector_model_class_init (ENameSelectorModelClass *name_selector_model_class)
+e_name_selector_model_class_init (ENameSelectorModelClass *class)
{
- GObjectClass *object_class = G_OBJECT_CLASS (name_selector_model_class);
-
- object_class->finalize = e_name_selector_model_finalize;
-
- signals [SECTION_ADDED] =
- g_signal_new ("section-added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ENameSelectorModelClass, section_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- signals [SECTION_REMOVED] =
- g_signal_new ("section-removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ENameSelectorModelClass, section_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (ENameSelectorModelPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = name_selector_model_finalize;
+
+ signals[SECTION_ADDED] = g_signal_new (
+ "section-added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ENameSelectorModelClass, section_added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[SECTION_REMOVED] = g_signal_new (
+ "section-removed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ENameSelectorModelClass, section_removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
}
/**
@@ -169,12 +189,12 @@ generate_contact_rows (EContactStore *contact_store, GtkTreeIter *iter,
if (!contact_uid)
return 0; /* Can happen with broken databases */
- for (i = 0; i < name_selector_model->sections->len; i++) {
+ for (i = 0; i < name_selector_model->priv->sections->len; i++) {
Section *section;
GList *destinations;
GList *l;
- section = &g_array_index (name_selector_model->sections, Section, i);
+ section = &g_array_index (name_selector_model->priv->sections, Section, i);
destinations = e_destination_store_list_destinations (section->destination_store);
for (l = destinations; l; l = g_list_next (l)) {
@@ -240,7 +260,7 @@ HashCompare;
static void
emit_destination_uid_changes_cb (gchar *uid_num, gpointer value, HashCompare *hash_compare)
{
- EContactStore *contact_store = hash_compare->name_selector_model->contact_store;
+ EContactStore *contact_store = hash_compare->name_selector_model->priv->contact_store;
if (!hash_compare->other_hash || !g_hash_table_lookup (hash_compare->other_hash, uid_num)) {
GtkTreeIter iter;
@@ -273,8 +293,8 @@ destinations_changed (ENameSelectorModel *name_selector_model)
destination_uid_hash_new = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- for (i = 0; i < name_selector_model->sections->len; i++) {
- Section *section = &g_array_index (name_selector_model->sections, Section, i);
+ for (i = 0; i < name_selector_model->priv->sections->len; i++) {
+ Section *section = &g_array_index (name_selector_model->priv->sections, Section, i);
GList *destinations;
GList *l;
@@ -294,8 +314,8 @@ destinations_changed (ENameSelectorModel *name_selector_model)
g_list_free (destinations);
}
- destination_uid_hash_old = name_selector_model->destination_uid_hash;
- name_selector_model->destination_uid_hash = destination_uid_hash_new;
+ destination_uid_hash_old = name_selector_model->priv->destination_uid_hash;
+ name_selector_model->priv->destination_uid_hash = destination_uid_hash_new;
hash_compare.name_selector_model = name_selector_model;
@@ -318,9 +338,9 @@ free_section (ENameSelectorModel *name_selector_model, gint n)
Section *section;
g_assert (n >= 0);
- g_assert (n < name_selector_model->sections->len);
+ g_assert (n < name_selector_model->priv->sections->len);
- section = &g_array_index (name_selector_model->sections, Section, n);
+ section = &g_array_index (name_selector_model->priv->sections, Section, n);
g_signal_handlers_disconnect_matched (section->destination_store, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, name_selector_model);
@@ -337,8 +357,8 @@ find_section_by_name (ENameSelectorModel *name_selector_model, const gchar *name
g_assert (name != NULL);
- for (i = 0; i < name_selector_model->sections->len; i++) {
- Section *section = &g_array_index (name_selector_model->sections, Section, i);
+ for (i = 0; i < name_selector_model->priv->sections->len; i++) {
+ Section *section = &g_array_index (name_selector_model->priv->sections, Section, i);
if (!strcmp (name, section->name))
return i;
@@ -364,7 +384,7 @@ e_name_selector_model_peek_contact_store (ENameSelectorModel *name_selector_mode
{
g_return_val_if_fail (E_IS_NAME_SELECTOR_MODEL (name_selector_model), NULL);
- return name_selector_model->contact_store;
+ return name_selector_model->priv->contact_store;
}
/**
@@ -381,7 +401,7 @@ e_name_selector_model_peek_contact_filter (ENameSelectorModel *name_selector_mod
{
g_return_val_if_fail (E_IS_NAME_SELECTOR_MODEL (name_selector_model), NULL);
- return name_selector_model->contact_filter;
+ return name_selector_model->priv->contact_filter;
}
/**
@@ -402,8 +422,8 @@ e_name_selector_model_list_sections (ENameSelectorModel *name_selector_model)
g_return_val_if_fail (E_IS_NAME_SELECTOR_MODEL (name_selector_model), NULL);
/* Do this backwards so we can use g_list_prepend () and get correct order */
- for (i = name_selector_model->sections->len - 1; i >= 0; i--) {
- Section *section = &g_array_index (name_selector_model->sections, Section, i);
+ for (i = name_selector_model->priv->sections->len - 1; i >= 0; i--) {
+ Section *section = &g_array_index (name_selector_model->priv->sections, Section, i);
gchar *name;
name = g_strdup (section->name);
@@ -456,7 +476,7 @@ e_name_selector_model_add_section (ENameSelectorModel *name_selector_model,
g_signal_connect_swapped (section.destination_store, "row-inserted",
G_CALLBACK (destinations_changed), name_selector_model);
- g_array_append_val (name_selector_model->sections, section);
+ g_array_append_val (name_selector_model->priv->sections, section);
destinations_changed (name_selector_model);
g_signal_emit (name_selector_model, signals [SECTION_ADDED], 0, name);
@@ -484,7 +504,7 @@ e_name_selector_model_remove_section (ENameSelectorModel *name_selector_model, c
}
free_section (name_selector_model, n);
- g_array_remove_index_fast (name_selector_model->sections, n); /* Order doesn't matter */
+ g_array_remove_index_fast (name_selector_model->priv->sections, n); /* Order doesn't matter */
destinations_changed (name_selector_model);
g_signal_emit (name_selector_model, signals [SECTION_REMOVED], 0, name);
@@ -517,7 +537,7 @@ e_name_selector_model_peek_section (ENameSelectorModel *name_selector_model, con
return FALSE;
}
- section = &g_array_index (name_selector_model->sections, Section, n);
+ section = &g_array_index (name_selector_model->priv->sections, Section, n);
if (pretty_name)
*pretty_name = g_strdup (section->pretty_name);
@@ -559,12 +579,12 @@ e_name_selector_model_get_contact_emails_without_used (ENameSelectorModel *name_
email_list = e_contact_get (contact, E_CONTACT_EMAIL);
emails = g_list_length (email_list);
- for (i = 0; i < name_selector_model->sections->len; i++) {
+ for (i = 0; i < name_selector_model->priv->sections->len; i++) {
Section *section;
GList *destinations;
GList *l;
- section = &g_array_index (name_selector_model->sections, Section, i);
+ section = &g_array_index (name_selector_model->priv->sections, Section, i);
destinations = e_destination_store_list_destinations (section->destination_store);
for (l = destinations; l; l = g_list_next (l)) {
diff --git a/libedataserverui/e-name-selector-model.h b/libedataserverui/e-name-selector-model.h
index 2b5ded3..0dec785 100644
--- a/libedataserverui/e-name-selector-model.h
+++ b/libedataserverui/e-name-selector-model.h
@@ -28,58 +28,77 @@
#include <libedataserverui/e-contact-store.h>
#include <libedataserverui/e-destination-store.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_NAME_SELECTOR_MODEL \
+ (e_name_selector_model_get_type ())
+#define E_NAME_SELECTOR_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_NAME_SELECTOR_MODEL, ENameSelectorModel))
+#define E_NAME_SELECTOR_MODEL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_NAME_SELECTOR_MODEL, ENameSelectorModelClass))
+#define E_IS_NAME_SELECTOR_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_NAME_SELECTOR_MODEL))
+#define E_IS_NAME_SELECTOR_MODEL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_NAME_SELECTOR_MODEL))
+#define E_NAME_SELECTOR_MODEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_NAME_SELECTOR_MODEL, ENameSelectorModelClass))
-#define E_TYPE_NAME_SELECTOR_MODEL (e_name_selector_model_get_type ())
-#define E_NAME_SELECTOR_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_NAME_SELECTOR_MODEL, ENameSelectorModel))
-#define E_NAME_SELECTOR_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_NAME_SELECTOR_MODEL, ENameSelectorModelClass))
-#define E_IS_NAME_SELECTOR_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_NAME_SELECTOR_MODEL))
-#define E_IS_NAME_SELECTOR_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_NAME_SELECTOR_MODEL))
+G_BEGIN_DECLS
-typedef struct _ENameSelectorModel ENameSelectorModel;
-typedef struct _ENameSelectorModelClass ENameSelectorModelClass;
+typedef struct _ENameSelectorModel ENameSelectorModel;
+typedef struct _ENameSelectorModelClass ENameSelectorModelClass;
+typedef struct _ENameSelectorModelPrivate ENameSelectorModelPrivate;
struct _ENameSelectorModel {
- GObject parent;
-
- /* Private */
-
- GArray *sections;
- EContactStore *contact_store;
- ETreeModelGenerator *contact_filter;
-
- GHashTable *destination_uid_hash;
+ GObject parent;
+ ENameSelectorModelPrivate *priv;
};
struct _ENameSelectorModelClass {
GObjectClass parent_class;
/* Signals */
- void (* section_added) (gchar *name);
- void (* section_removed) (gchar *name);
+ void (*section_added) (gchar *name);
+ void (*section_removed) (gchar *name);
};
-GType e_name_selector_model_get_type (void);
-ENameSelectorModel *e_name_selector_model_new (void);
-
-EContactStore *e_name_selector_model_peek_contact_store (ENameSelectorModel *name_selector_model);
-ETreeModelGenerator *e_name_selector_model_peek_contact_filter (ENameSelectorModel *name_selector_model);
+GType e_name_selector_model_get_type (void);
+ENameSelectorModel *
+ e_name_selector_model_new (void);
+EContactStore * e_name_selector_model_peek_contact_store
+ (ENameSelectorModel *name_selector_model);
+ETreeModelGenerator *
+ e_name_selector_model_peek_contact_filter
+ (ENameSelectorModel *name_selector_model);
/* Deep copy of section names; free strings and list when you're done */
-GList *e_name_selector_model_list_sections (ENameSelectorModel *name_selector_model);
+GList * e_name_selector_model_list_sections
+ (ENameSelectorModel *name_selector_model);
/* pretty_name will be newly allocated, but destination_store must be reffed if you keep it */
-gboolean e_name_selector_model_peek_section (ENameSelectorModel *name_selector_model,
- const gchar *name, gchar **pretty_name,
- EDestinationStore **destination_store);
-void e_name_selector_model_add_section (ENameSelectorModel *name_selector_model,
- const gchar *name, const gchar *pretty_name,
- EDestinationStore *destination_store);
-void e_name_selector_model_remove_section (ENameSelectorModel *name_selector_model,
- const gchar *name);
-
-GList *e_name_selector_model_get_contact_emails_without_used (ENameSelectorModel *name_selector_model, EContact *contact, gboolean remove_used);
-void e_name_selector_model_free_emails_list (GList *email_list);
+gboolean e_name_selector_model_peek_section
+ (ENameSelectorModel *name_selector_model,
+ const gchar *name,
+ gchar **pretty_name,
+ EDestinationStore **destination_store);
+void e_name_selector_model_add_section
+ (ENameSelectorModel *name_selector_model,
+ const gchar *name,
+ const gchar *pretty_name,
+ EDestinationStore *destination_store);
+void e_name_selector_model_remove_section
+ (ENameSelectorModel *name_selector_model,
+ const gchar *name);
+GList * e_name_selector_model_get_contact_emails_without_used
+ (ENameSelectorModel *name_selector_model,
+ EContact *contact,
+ gboolean remove_used);
+void e_name_selector_model_free_emails_list
+ (GList *email_list);
G_END_DECLS
diff --git a/libedataserverui/e-name-selector.c b/libedataserverui/e-name-selector.c
index 5ad7426..a910869 100644
--- a/libedataserverui/e-name-selector.c
+++ b/libedataserverui/e-name-selector.c
@@ -35,34 +35,31 @@
#include <libedataserverui/e-book-auth-util.h>
#include "e-name-selector.h"
+#define E_NAME_SELECTOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_NAME_SELECTOR, ENameSelectorPrivate))
+
typedef struct {
- gchar *name;
+ gchar *name;
ENameSelectorEntry *entry;
-}
-Section;
+} Section;
typedef struct {
EBook *book;
- guint is_completion_book : 1;
-}
-SourceBook;
-
-typedef struct _ENameSelectorPrivate ENameSelectorPrivate;
+ guint is_completion_book : 1;
+} SourceBook;
struct _ENameSelectorPrivate {
+ ENameSelectorModel *model;
+ ENameSelectorDialog *dialog;
+
+ GArray *sections;
+
GThread *load_book_thread;
gboolean load_cancelled;
GArray *source_books;
};
-#define E_NAME_SELECTOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_NAME_SELECTOR, ENameSelectorPrivate))
-
-static void e_name_selector_finalize (GObject *object);
-
-/* ------------------ *
- * Class/object setup *
- * ------------------ */
-
G_DEFINE_TYPE (ENameSelector, e_name_selector, G_TYPE_OBJECT)
static gpointer
@@ -115,11 +112,11 @@ load_books_thread (gpointer user_data)
if (!priv->load_cancelled) {
EContactStore *store;
- if (name_selector->sections) {
+ if (name_selector->priv->sections) {
gint j;
- for (j = 0; j < name_selector->sections->len && !priv->load_cancelled; j++) {
- Section *section = &g_array_index (name_selector->sections, Section, j);
+ for (j = 0; j < name_selector->priv->sections->len && !priv->load_cancelled; j++) {
+ Section *section = &g_array_index (name_selector->priv->sections, Section, j);
if (section->entry) {
store = e_name_selector_entry_peek_contact_store (section->entry);
@@ -138,34 +135,7 @@ load_books_thread (gpointer user_data)
}
static void
-e_name_selector_class_init (ENameSelectorClass *name_selector_class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (name_selector_class);
-
- object_class->finalize = e_name_selector_finalize;
-
- g_type_class_add_private (name_selector_class, sizeof (ENameSelectorPrivate));
-}
-
-static void
-e_name_selector_init (ENameSelector *name_selector)
-{
- ENameSelectorPrivate *priv;
-
- priv = E_NAME_SELECTOR_GET_PRIVATE (name_selector);
-
- name_selector->sections = g_array_new (FALSE, FALSE, sizeof (Section));
- name_selector->model = e_name_selector_model_new ();
-
- priv->source_books = g_array_new (FALSE, FALSE, sizeof (SourceBook));
- priv->load_cancelled = FALSE;
- priv->load_book_thread = g_thread_create (load_books_thread, name_selector, TRUE, NULL);
-}
-
-static void
-e_name_selector_finalize (GObject *object)
+name_selector_finalize (GObject *object)
{
ENameSelectorPrivate *priv;
@@ -191,8 +161,39 @@ e_name_selector_finalize (GObject *object)
priv->source_books = NULL;
}
- if (G_OBJECT_CLASS (e_name_selector_parent_class)->finalize)
- G_OBJECT_CLASS (e_name_selector_parent_class)->finalize (object);
+ /* Chain up to parent's finalize() methods. */
+ G_OBJECT_CLASS (e_name_selector_parent_class)->finalize (object);
+}
+
+static void
+e_name_selector_class_init (ENameSelectorClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (ENameSelectorPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = name_selector_finalize;
+}
+
+static void
+e_name_selector_init (ENameSelector *name_selector)
+{
+ GArray *sections;
+ GArray *source_books;
+ GThread *load_book_thread;
+
+ sections = g_array_new (FALSE, FALSE, sizeof (Section));
+ source_books = g_array_new (FALSE, FALSE, sizeof (SourceBook));
+
+ load_book_thread = g_thread_create (
+ load_books_thread, name_selector, TRUE, NULL);
+
+ name_selector->priv = E_NAME_SELECTOR_GET_PRIVATE (name_selector);
+ name_selector->priv->sections = sections;
+ name_selector->priv->model = e_name_selector_model_new ();
+ name_selector->priv->source_books = source_books;
+ name_selector->priv->load_book_thread = load_book_thread;
}
/**
@@ -205,7 +206,7 @@ e_name_selector_finalize (GObject *object)
ENameSelector *
e_name_selector_new (void)
{
- return E_NAME_SELECTOR (g_object_new (E_TYPE_NAME_SELECTOR, NULL));
+ return g_object_new (E_TYPE_NAME_SELECTOR, NULL);
}
/* ------- *
@@ -215,6 +216,7 @@ e_name_selector_new (void)
static gint
add_section (ENameSelector *name_selector, const gchar *name)
{
+ GArray *array;
Section section;
g_assert (name != NULL);
@@ -222,19 +224,23 @@ add_section (ENameSelector *name_selector, const gchar *name)
memset (§ion, 0, sizeof (Section));
section.name = g_strdup (name);
- g_array_append_val (name_selector->sections, section);
- return name_selector->sections->len - 1;
+ array = name_selector->priv->sections;
+ g_array_append_val (array, section);
+ return array->len - 1;
}
static gint
find_section_by_name (ENameSelector *name_selector, const gchar *name)
{
+ GArray *array;
gint i;
g_assert (name != NULL);
- for (i = 0; i < name_selector->sections->len; i++) {
- Section *section = &g_array_index (name_selector->sections, Section, i);
+ array = name_selector->priv->sections;
+
+ for (i = 0; i < array->len; i++) {
+ Section *section = &g_array_index (array, Section, i);
if (!strcmp (name, section->name))
return i;
@@ -260,7 +266,7 @@ e_name_selector_peek_model (ENameSelector *name_selector)
{
g_return_val_if_fail (E_IS_NAME_SELECTOR (name_selector), NULL);
- return name_selector->model;
+ return name_selector->priv->model;
}
/**
@@ -276,14 +282,22 @@ e_name_selector_peek_dialog (ENameSelector *name_selector)
{
g_return_val_if_fail (E_IS_NAME_SELECTOR (name_selector), NULL);
- if (!name_selector->dialog) {
- name_selector->dialog = e_name_selector_dialog_new ();
- e_name_selector_dialog_set_model (name_selector->dialog, name_selector->model);
- g_signal_connect (name_selector->dialog, "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete), name_selector);
+ if (name_selector->priv->dialog == NULL) {
+ ENameSelectorDialog *dialog;
+ ENameSelectorModel *model;
+
+ dialog = e_name_selector_dialog_new ();
+ name_selector->priv->dialog = dialog;
+
+ model = e_name_selector_peek_model (name_selector);
+ e_name_selector_dialog_set_model (dialog, model);
+
+ g_signal_connect (
+ dialog, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), name_selector);
}
- return name_selector->dialog;
+ return name_selector->priv->dialog;
}
/**
@@ -300,6 +314,7 @@ ENameSelectorEntry *
e_name_selector_peek_section_entry (ENameSelector *name_selector, const gchar *name)
{
ENameSelectorPrivate *priv;
+ ENameSelectorModel *model;
EDestinationStore *destination_store;
Section *section;
gint n;
@@ -308,16 +323,17 @@ e_name_selector_peek_section_entry (ENameSelector *name_selector, const gchar *n
g_return_val_if_fail (name != NULL, NULL);
priv = E_NAME_SELECTOR_GET_PRIVATE (name_selector);
+ model = e_name_selector_peek_model (name_selector);
- if (!e_name_selector_model_peek_section (name_selector->model, name,
- NULL, &destination_store))
+ if (!e_name_selector_model_peek_section (
+ model, name, NULL, &destination_store))
return NULL;
n = find_section_by_name (name_selector, name);
if (n < 0)
n = add_section (name_selector, name);
- section = &g_array_index (name_selector->sections, Section, n);
+ section = &g_array_index (name_selector->priv->sections, Section, n);
if (!section->entry) {
EContactStore *contact_store;
@@ -365,6 +381,7 @@ ENameSelectorList *
e_name_selector_peek_section_list (ENameSelector *name_selector, const gchar *name)
{
ENameSelectorPrivate *priv;
+ ENameSelectorModel *model;
EDestinationStore *destination_store;
Section *section;
gint n;
@@ -373,16 +390,17 @@ e_name_selector_peek_section_list (ENameSelector *name_selector, const gchar *na
g_return_val_if_fail (name != NULL, NULL);
priv = E_NAME_SELECTOR_GET_PRIVATE (name_selector);
+ model = e_name_selector_peek_model (name_selector);
- if (!e_name_selector_model_peek_section (name_selector->model, name,
- NULL, &destination_store))
+ if (!e_name_selector_model_peek_section (
+ model, name, NULL, &destination_store))
return NULL;
n = find_section_by_name (name_selector, name);
if (n < 0)
n = add_section (name_selector, name);
- section = &g_array_index (name_selector->sections, Section, n);
+ section = &g_array_index (name_selector->priv->sections, Section, n);
if (!section->entry) {
EContactStore *contact_store;
diff --git a/libedataserverui/e-name-selector.h b/libedataserverui/e-name-selector.h
index dc284d2..1d12d37 100644
--- a/libedataserverui/e-name-selector.h
+++ b/libedataserverui/e-name-selector.h
@@ -31,39 +31,54 @@
#include <libedataserverui/e-name-selector-entry.h>
#include <libedataserverui/e-name-selector-list.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_NAME_SELECTOR \
+ (e_name_selector_get_type ())
+#define E_NAME_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_NAME_SELECTOR, ENameSelector))
+#define E_NAME_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_NAME_SELECTOR, ENameSelectorClass))
+#define E_IS_NAME_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_NAME_SELECTOR))
+#define E_IS_NAME_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_NAME_SELECTOR))
+#define E_NAME_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_NAME_SELECTOR, ENameSelectorClass))
-#define E_TYPE_NAME_SELECTOR (e_name_selector_get_type ())
-#define E_NAME_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_NAME_SELECTOR, ENameSelector))
-#define E_NAME_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_NAME_SELECTOR, ENameSelectorClass))
-#define E_IS_NAME_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_NAME_SELECTOR))
-#define E_IS_NAME_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_NAME_SELECTOR))
+G_BEGIN_DECLS
-typedef struct _ENameSelector ENameSelector;
-typedef struct _ENameSelectorClass ENameSelectorClass;
+typedef struct _ENameSelector ENameSelector;
+typedef struct _ENameSelectorClass ENameSelectorClass;
+typedef struct _ENameSelectorPrivate ENameSelectorPrivate;
struct _ENameSelector {
- GObject parent;
-
- /* Private */
-
- ENameSelectorModel *model;
- ENameSelectorDialog *dialog;
-
- GArray *sections;
+ GObject parent;
+ ENameSelectorPrivate *priv;
};
struct _ENameSelectorClass {
GObjectClass parent_class;
};
-GType e_name_selector_get_type (void);
-ENameSelector *e_name_selector_new (void);
-
-ENameSelectorModel *e_name_selector_peek_model (ENameSelector *name_selector);
-ENameSelectorDialog *e_name_selector_peek_dialog (ENameSelector *name_selector);
-ENameSelectorEntry *e_name_selector_peek_section_entry (ENameSelector *name_selector, const gchar *name);
-ENameSelectorList *e_name_selector_peek_section_list (ENameSelector *name_selector, const gchar *name);
+GType e_name_selector_get_type (void);
+ENameSelector * e_name_selector_new (void);
+ENameSelectorModel *
+ e_name_selector_peek_model (ENameSelector *name_selector);
+ENameSelectorDialog *
+ e_name_selector_peek_dialog (ENameSelector *name_selector);
+ENameSelectorEntry *
+ e_name_selector_peek_section_entry
+ (ENameSelector *name_selector,
+ const gchar *name);
+ENameSelectorList *
+ e_name_selector_peek_section_list
+ (ENameSelector *name_selector,
+ const gchar *name);
G_END_DECLS
diff --git a/libedataserverui/e-source-combo-box.h b/libedataserverui/e-source-combo-box.h
index 60c73f7..652d997 100644
--- a/libedataserverui/e-source-combo-box.h
+++ b/libedataserverui/e-source-combo-box.h
@@ -18,8 +18,8 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef _E_SOURCE_COMBO_BOX_H_
-#define _E_SOURCE_COMBO_BOX_H_
+#ifndef E_SOURCE_COMBO_BOX_H
+#define E_SOURCE_COMBO_BOX_H
#include <gtk/gtk.h>
#include <libedataserver/e-source-list.h>
@@ -53,7 +53,6 @@ typedef struct _ESourceComboBoxPrivate ESourceComboBoxPrivate;
**/
struct _ESourceComboBox {
GtkComboBox parent;
-
ESourceComboBoxPrivate *priv;
};
@@ -81,4 +80,4 @@ void e_source_combo_box_set_active_uid
G_END_DECLS
-#endif /* _E_SOURCE_COMBO_BOX_H_ */
+#endif /* E_SOURCE_COMBO_BOX_H */
diff --git a/libedataserverui/e-source-selector-dialog.h b/libedataserverui/e-source-selector-dialog.h
index 1db9fe4..b7455a7 100644
--- a/libedataserverui/e-source-selector-dialog.h
+++ b/libedataserverui/e-source-selector-dialog.h
@@ -21,23 +21,36 @@
* Author: Rodrigo Moya <rodrigo novell com>
*/
-#ifndef _E_SOURCE_SELECTOR_DIALOG_H_
-#define _E_SOURCE_SELECTOR_DIALOG_H_
+#ifndef E_SOURCE_SELECTOR_DIALOG_H
+#define E_SOURCE_SELECTOR_DIALOG_H
#include <gtk/gtk.h>
#include "libedataserver/e-source-list.h"
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_SOURCE_SELECTOR_DIALOG \
+ (e_source_selector_dialog_get_type ())
+#define E_SOURCE_SELECTOR_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SOURCE_SELECTOR_DIALOG, ESourceSelectorDialog))
+#define E_SOURCE_SELECTOR_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SOURCE_SELECTOR_DIALOG, ESourceSelectorDialogClass))
+#define E_IS_SOURCE_SELECTOR_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SOURCE_SELECTOR_DIALOG))
+#define E_IS_SOURCE_SELECTOR_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SOURCE_SELECTOR_DIALOG))
+#define E_SOURCE_SELECTOR_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SOURCE_SELECTOR_DIALOG, ESourceSelectorDialogClass))
-#define E_TYPE_SOURCE_SELECTOR_DIALOG (e_source_selector_dialog_get_type ())
-#define E_SOURCE_SELECTOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_SELECTOR_DIALOG, ESourceSelectorDialog))
-#define E_SOURCE_SELECTOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_SELECTOR_DIALOG, ESourceSelectorDialogClass))
-#define E_IS_SOURCE_SELECTOR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_SELECTOR_DIALOG))
-#define E_IS_SOURCE_SELECTOR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_SELECTOR_DIALOG))
+G_BEGIN_DECLS
-typedef struct _ESourceSelectorDialog ESourceSelectorDialog;
+typedef struct _ESourceSelectorDialog ESourceSelectorDialog;
+typedef struct _ESourceSelectorDialogClass ESourceSelectorDialogClass;
typedef struct _ESourceSelectorDialogPrivate ESourceSelectorDialogPrivate;
-typedef struct _ESourceSelectorDialogClass ESourceSelectorDialogClass;
struct _ESourceSelectorDialog {
GtkDialog parent;
@@ -48,12 +61,14 @@ struct _ESourceSelectorDialogClass {
GtkDialogClass parent_class;
};
-GType e_source_selector_dialog_get_type (void);
-
-GtkWidget *e_source_selector_dialog_new (GtkWindow *parent, ESourceList *source_list);
-gboolean e_source_selector_dialog_select_default_source (ESourceSelectorDialog *dialog);
-ESource *e_source_selector_dialog_peek_primary_selection (ESourceSelectorDialog *dialog);
+GType e_source_selector_dialog_get_type (void);
+GtkWidget * e_source_selector_dialog_new (GtkWindow *parent,
+ ESourceList *source_list);
+gboolean e_source_selector_dialog_select_default_source
+ (ESourceSelectorDialog *dialog);
+ESource * e_source_selector_dialog_peek_primary_selection
+ (ESourceSelectorDialog *dialog);
G_END_DECLS
-#endif
+#endif /* E_SOURCE_SELECTOR_DIALOG_H */
diff --git a/libedataserverui/e-tree-model-generator.c b/libedataserverui/e-tree-model-generator.c
index b1237f7..ce2a489 100644
--- a/libedataserverui/e-tree-model-generator.c
+++ b/libedataserverui/e-tree-model-generator.c
@@ -30,26 +30,43 @@
#define ETMG_DEBUG(x)
-#define ITER_IS_VALID(tree_model_generator, iter) ((iter)->stamp == (tree_model_generator)->stamp)
-#define ITER_GET(iter, group, index) \
-G_STMT_START { \
- *(group) = (iter)->user_data; \
- *(index) = GPOINTER_TO_INT ((iter)->user_data2); \
-} G_STMT_END
-
-#define ITER_SET(tree_model_generator, iter, group, index) \
-G_STMT_START { \
- (iter)->stamp = (tree_model_generator)->stamp; \
- (iter)->user_data = group; \
- (iter)->user_data2 = GINT_TO_POINTER (index); \
-} G_STMT_END
+#define ITER_IS_VALID(tree_model_generator, iter) \
+ ((iter)->stamp == (tree_model_generator)->priv->stamp)
+#define ITER_GET(iter, group, index) \
+ G_STMT_START { \
+ *(group) = (iter)->user_data; \
+ *(index) = GPOINTER_TO_INT ((iter)->user_data2); \
+ } G_STMT_END
+
+#define ITER_SET(tree_model_generator, iter, group, index) \
+ G_STMT_START { \
+ (iter)->stamp = (tree_model_generator)->priv->stamp; \
+ (iter)->user_data = group; \
+ (iter)->user_data2 = GINT_TO_POINTER (index); \
+ } G_STMT_END
+
+#define E_TREE_MODEL_GENERATOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TREE_MODEL_GENERATOR, ETreeModelGeneratorPrivate))
+
+struct _ETreeModelGeneratorPrivate {
+ GtkTreeModel *child_model;
+ GArray *root_nodes;
+ gint stamp;
+
+ ETreeModelGeneratorGenerateFunc generate_func;
+ gpointer generate_func_data;
+
+ ETreeModelGeneratorModifyFunc modify_func;
+ gpointer modify_func_data;
+};
static void e_tree_model_generator_tree_model_init (GtkTreeModelIface *iface);
-G_DEFINE_TYPE_EXTENDED (ETreeModelGenerator, e_tree_model_generator, G_TYPE_OBJECT, 0,
+G_DEFINE_TYPE_WITH_CODE (
+ ETreeModelGenerator, e_tree_model_generator, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, e_tree_model_generator_tree_model_init))
-static void e_tree_model_generator_finalize (GObject *object);
static GtkTreeModelFlags e_tree_model_generator_get_flags (GtkTreeModel *tree_model);
static gint e_tree_model_generator_get_n_columns (GtkTreeModel *tree_model);
static GType e_tree_model_generator_get_column_type (GtkTreeModel *tree_model,
@@ -106,18 +123,31 @@ enum {
* Class/object setup *
* ------------------ */
-static GObjectClass *parent_class = NULL;
-
static void
-e_tree_model_generator_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+tree_model_generator_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
ETreeModelGenerator *tree_model_generator = E_TREE_MODEL_GENERATOR (object);
switch (prop_id)
{
case PROP_CHILD_MODEL:
- g_value_set_object (value, tree_model_generator->child_model);
+ tree_model_generator->priv->child_model = g_value_get_object (value);
+ g_object_ref (tree_model_generator->priv->child_model);
+
+ if (tree_model_generator->priv->root_nodes)
+ release_node_map (tree_model_generator->priv->root_nodes);
+ tree_model_generator->priv->root_nodes =
+ build_node_map (tree_model_generator, NULL, NULL, -1);
+
+ g_signal_connect_swapped (tree_model_generator->priv->child_model, "row-changed",
+ G_CALLBACK (child_row_changed), tree_model_generator);
+ g_signal_connect_swapped (tree_model_generator->priv->child_model, "row-deleted",
+ G_CALLBACK (child_row_deleted), tree_model_generator);
+ g_signal_connect_swapped (tree_model_generator->priv->child_model, "row-inserted",
+ G_CALLBACK (child_row_inserted), tree_model_generator);
break;
default:
@@ -127,28 +157,17 @@ e_tree_model_generator_get_property (GObject *object, guint prop_id,
}
static void
-e_tree_model_generator_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+tree_model_generator_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
ETreeModelGenerator *tree_model_generator = E_TREE_MODEL_GENERATOR (object);
switch (prop_id)
{
case PROP_CHILD_MODEL:
- tree_model_generator->child_model = g_value_get_object (value);
- g_object_ref (tree_model_generator->child_model);
-
- if (tree_model_generator->root_nodes)
- release_node_map (tree_model_generator->root_nodes);
- tree_model_generator->root_nodes =
- build_node_map (tree_model_generator, NULL, NULL, -1);
-
- g_signal_connect_swapped (tree_model_generator->child_model, "row-changed",
- G_CALLBACK (child_row_changed), tree_model_generator);
- g_signal_connect_swapped (tree_model_generator->child_model, "row-deleted",
- G_CALLBACK (child_row_deleted), tree_model_generator);
- g_signal_connect_swapped (tree_model_generator->child_model, "row-inserted",
- G_CALLBACK (child_row_inserted), tree_model_generator);
+ g_value_set_object (value, tree_model_generator->priv->child_model);
break;
default:
@@ -158,23 +177,46 @@ e_tree_model_generator_set_property (GObject *object, guint prop_id,
}
static void
-e_tree_model_generator_class_init (ETreeModelGeneratorClass *class)
+tree_model_generator_finalize (GObject *object)
{
- GObjectClass *object_class;
+ ETreeModelGenerator *tree_model_generator = E_TREE_MODEL_GENERATOR (object);
- parent_class = g_type_class_peek_parent (class);
- object_class = (GObjectClass *) class;
+ if (tree_model_generator->priv->child_model) {
+ g_signal_handlers_disconnect_matched (tree_model_generator->priv->child_model,
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
+ tree_model_generator);
+ g_object_unref (tree_model_generator->priv->child_model);
+ }
- object_class->get_property = e_tree_model_generator_get_property;
- object_class->set_property = e_tree_model_generator_set_property;
- object_class->finalize = e_tree_model_generator_finalize;
+ if (tree_model_generator->priv->root_nodes)
+ release_node_map (tree_model_generator->priv->root_nodes);
- g_object_class_install_property (object_class, PROP_CHILD_MODEL,
- g_param_spec_object ("child-model",
- "Child Model",
- "The child model to extend",
- G_TYPE_OBJECT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_tree_model_generator_parent_class)->finalize (object);
+}
+
+static void
+e_tree_model_generator_class_init (ETreeModelGeneratorClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (ETreeModelGeneratorPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->get_property = tree_model_generator_get_property;
+ object_class->set_property = tree_model_generator_set_property;
+ object_class->finalize = tree_model_generator_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CHILD_MODEL,
+ g_param_spec_object (
+ "child-model",
+ "Child Model",
+ "The child model to extend",
+ G_TYPE_OBJECT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
static void
@@ -197,27 +239,11 @@ e_tree_model_generator_tree_model_init (GtkTreeModelIface *iface)
static void
e_tree_model_generator_init (ETreeModelGenerator *tree_model_generator)
{
- tree_model_generator->stamp = g_random_int ();
- tree_model_generator->root_nodes = g_array_new (FALSE, FALSE, sizeof (Node));
-}
-
-static void
-e_tree_model_generator_finalize (GObject *object)
-{
- ETreeModelGenerator *tree_model_generator = E_TREE_MODEL_GENERATOR (object);
-
- if (tree_model_generator->child_model) {
- g_signal_handlers_disconnect_matched (tree_model_generator->child_model,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL,
- tree_model_generator);
- g_object_unref (tree_model_generator->child_model);
- }
-
- if (tree_model_generator->root_nodes)
- release_node_map (tree_model_generator->root_nodes);
+ tree_model_generator->priv =
+ E_TREE_MODEL_GENERATOR_GET_PRIVATE (tree_model_generator);
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ tree_model_generator->priv->stamp = g_random_int ();
+ tree_model_generator->priv->root_nodes = g_array_new (FALSE, FALSE, sizeof (Node));
}
/* ------------------ *
@@ -359,9 +385,9 @@ build_node_map (ETreeModelGenerator *tree_model_generator, GtkTreeIter *parent_i
gboolean result;
if (parent_iter)
- result = gtk_tree_model_iter_children (tree_model_generator->child_model, &iter, parent_iter);
+ result = gtk_tree_model_iter_children (tree_model_generator->priv->child_model, &iter, parent_iter);
else
- result = gtk_tree_model_get_iter_first (tree_model_generator->child_model, &iter);
+ result = gtk_tree_model_get_iter_first (tree_model_generator->priv->child_model, &iter);
if (!result)
return NULL;
@@ -378,15 +404,15 @@ build_node_map (ETreeModelGenerator *tree_model_generator, GtkTreeIter *parent_i
node->parent_group = parent_group;
node->parent_index = parent_index;
- if (tree_model_generator->generate_func)
+ if (tree_model_generator->priv->generate_func)
node->n_generated =
- tree_model_generator->generate_func (tree_model_generator->child_model,
- &iter, tree_model_generator->generate_func_data);
+ tree_model_generator->priv->generate_func (tree_model_generator->priv->child_model,
+ &iter, tree_model_generator->priv->generate_func_data);
else
node->n_generated = 1;
node->child_nodes = build_node_map (tree_model_generator, &iter, group, i);
- } while (gtk_tree_model_iter_next (tree_model_generator->child_model, &iter));
+ } while (gtk_tree_model_iter_next (tree_model_generator->priv->child_model, &iter));
return group;
}
@@ -416,7 +442,7 @@ get_node_by_child_path (ETreeModelGenerator *tree_model_generator, GtkTreePath *
GArray *group;
gint depth;
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
for (depth = 0; depth < gtk_tree_path_get_depth (path); depth++) {
gint index;
@@ -463,10 +489,10 @@ create_node_at_child_path (ETreeModelGenerator *tree_model_generator, GtkTreePat
group = node->child_nodes;
parent_index = gtk_tree_path_get_indices (parent_path) [gtk_tree_path_get_depth (parent_path) - 1];
} else {
- if (!tree_model_generator->root_nodes)
- tree_model_generator->root_nodes = g_array_new (FALSE, FALSE, sizeof (Node));
+ if (!tree_model_generator->priv->root_nodes)
+ tree_model_generator->priv->root_nodes = g_array_new (FALSE, FALSE, sizeof (Node));
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
parent_index = -1;
}
@@ -549,7 +575,7 @@ delete_node_at_child_path (ETreeModelGenerator *tree_model_generator, GtkTreePat
if (node) {
group = node->child_nodes;
} else {
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
}
gtk_tree_path_free (parent_path);
@@ -591,10 +617,10 @@ child_row_changed (ETreeModelGenerator *tree_model_generator, GtkTreePath *path,
gint n_generated;
gint i;
- if (tree_model_generator->generate_func)
+ if (tree_model_generator->priv->generate_func)
n_generated =
- tree_model_generator->generate_func (tree_model_generator->child_model,
- iter, tree_model_generator->generate_func_data);
+ tree_model_generator->priv->generate_func (tree_model_generator->priv->child_model,
+ iter, tree_model_generator->priv->generate_func_data);
else
n_generated = 1;
@@ -632,10 +658,10 @@ child_row_inserted (ETreeModelGenerator *tree_model_generator, GtkTreePath *path
Node *node;
gint n_generated;
- if (tree_model_generator->generate_func)
+ if (tree_model_generator->priv->generate_func)
n_generated =
- tree_model_generator->generate_func (tree_model_generator->child_model,
- iter, tree_model_generator->generate_func_data);
+ tree_model_generator->priv->generate_func (tree_model_generator->priv->child_model,
+ iter, tree_model_generator->priv->generate_func_data);
else
n_generated = 1;
@@ -713,7 +739,7 @@ e_tree_model_generator_get_model (ETreeModelGenerator *tree_model_generator)
{
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model_generator), NULL);
- return tree_model_generator->child_model;
+ return tree_model_generator->priv->child_model;
}
/**
@@ -737,8 +763,8 @@ e_tree_model_generator_set_generate_func (ETreeModelGenerator *tree_model_genera
{
g_return_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model_generator));
- tree_model_generator->generate_func = func;
- tree_model_generator->generate_func_data = data;
+ tree_model_generator->priv->generate_func = func;
+ tree_model_generator->priv->generate_func_data = data;
}
/**
@@ -760,8 +786,8 @@ e_tree_model_generator_set_modify_func (ETreeModelGenerator *tree_model_generato
{
g_return_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model_generator));
- tree_model_generator->modify_func = func;
- tree_model_generator->modify_func_data = data;
+ tree_model_generator->priv->modify_func = func;
+ tree_model_generator->priv->modify_func_data = data;
}
/**
@@ -786,7 +812,7 @@ e_tree_model_generator_convert_child_path_to_path (ETreeModelGenerator *tree_mod
path = gtk_tree_path_new ();
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
for (depth = 0; depth < gtk_tree_path_get_depth (child_path); depth++) {
Node *node;
@@ -830,11 +856,11 @@ e_tree_model_generator_convert_child_iter_to_iter (ETreeModelGenerator *tree_mod
g_return_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model_generator));
- path = gtk_tree_model_get_path (tree_model_generator->child_model, child_iter);
+ path = gtk_tree_model_get_path (tree_model_generator->priv->child_model, child_iter);
if (!path)
return;
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
for (depth = 0; depth < gtk_tree_path_get_depth (path); depth++) {
Node *node;
@@ -878,7 +904,7 @@ e_tree_model_generator_convert_path_to_child_path (ETreeModelGenerator *tree_mod
path = gtk_tree_path_new ();
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
for (depth = 0; depth < gtk_tree_path_get_depth (generator_path); depth++) {
Node *node;
@@ -947,7 +973,7 @@ e_tree_model_generator_convert_iter_to_child_iter (ETreeModelGenerator *tree_mod
}
if (child_iter)
- gtk_tree_model_get_iter (tree_model_generator->child_model, child_iter, path);
+ gtk_tree_model_get_iter (tree_model_generator->priv->child_model, child_iter, path);
if (permutation_n)
*permutation_n = internal_offset;
@@ -965,7 +991,7 @@ e_tree_model_generator_get_flags (GtkTreeModel *tree_model)
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), 0);
- return gtk_tree_model_get_flags (tree_model_generator->child_model);
+ return gtk_tree_model_get_flags (tree_model_generator->priv->child_model);
}
static gint
@@ -975,7 +1001,7 @@ e_tree_model_generator_get_n_columns (GtkTreeModel *tree_model)
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), 0);
- return gtk_tree_model_get_n_columns (tree_model_generator->child_model);
+ return gtk_tree_model_get_n_columns (tree_model_generator->priv->child_model);
}
static GType
@@ -986,7 +1012,7 @@ e_tree_model_generator_get_column_type (GtkTreeModel *tree_model,
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), G_TYPE_INVALID);
- return gtk_tree_model_get_column_type (tree_model_generator->child_model, index);
+ return gtk_tree_model_get_column_type (tree_model_generator->priv->child_model, index);
}
static gboolean
@@ -1000,7 +1026,7 @@ e_tree_model_generator_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, Gt
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), FALSE);
g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
- group = tree_model_generator->root_nodes;
+ group = tree_model_generator->priv->root_nodes;
if (!group)
return FALSE;
@@ -1103,11 +1129,11 @@ e_tree_model_generator_iter_children (GtkTreeModel *tree_model,
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), FALSE);
if (!parent) {
- if (!tree_model_generator->root_nodes ||
- !count_generated_nodes (tree_model_generator->root_nodes))
+ if (!tree_model_generator->priv->root_nodes ||
+ !count_generated_nodes (tree_model_generator->priv->root_nodes))
return FALSE;
- ITER_SET (tree_model_generator, iter, tree_model_generator->root_nodes, 0);
+ ITER_SET (tree_model_generator, iter, tree_model_generator->priv->root_nodes, 0);
return TRUE;
}
@@ -1140,8 +1166,8 @@ e_tree_model_generator_iter_has_child (GtkTreeModel *tree_model,
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), FALSE);
if (iter == NULL) {
- if (!tree_model_generator->root_nodes ||
- !count_generated_nodes (tree_model_generator->root_nodes))
+ if (!tree_model_generator->priv->root_nodes ||
+ !count_generated_nodes (tree_model_generator->priv->root_nodes))
return FALSE;
return TRUE;
@@ -1175,8 +1201,8 @@ e_tree_model_generator_iter_n_children (GtkTreeModel *tree_model,
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), 0);
if (iter == NULL)
- return tree_model_generator->root_nodes ?
- count_generated_nodes (tree_model_generator->root_nodes) : 0;
+ return tree_model_generator->priv->root_nodes ?
+ count_generated_nodes (tree_model_generator->priv->root_nodes) : 0;
ITER_GET (iter, &group, &index);
index = generated_offset_to_child_offset (group, index, NULL);
@@ -1205,13 +1231,13 @@ e_tree_model_generator_iter_nth_child (GtkTreeModel *tree_model,
g_return_val_if_fail (E_IS_TREE_MODEL_GENERATOR (tree_model), FALSE);
if (!parent) {
- if (!tree_model_generator->root_nodes)
+ if (!tree_model_generator->priv->root_nodes)
return FALSE;
- if (n >= count_generated_nodes (tree_model_generator->root_nodes))
+ if (n >= count_generated_nodes (tree_model_generator->priv->root_nodes))
return FALSE;
- ITER_SET (tree_model_generator, iter, tree_model_generator->root_nodes, n);
+ ITER_SET (tree_model_generator, iter, tree_model_generator->priv->root_nodes, n);
return TRUE;
}
@@ -1276,13 +1302,13 @@ e_tree_model_generator_get_value (GtkTreeModel *tree_model,
e_tree_model_generator_convert_iter_to_child_iter (tree_model_generator, &child_iter,
&permutation_n, iter);
- if (tree_model_generator->modify_func) {
- tree_model_generator->modify_func (tree_model_generator->child_model,
+ if (tree_model_generator->priv->modify_func) {
+ tree_model_generator->priv->modify_func (tree_model_generator->priv->child_model,
&child_iter, permutation_n,
column, value,
- tree_model_generator->modify_func_data);
+ tree_model_generator->priv->modify_func_data);
return;
}
- gtk_tree_model_get_value (tree_model_generator->child_model, &child_iter, column, value);
+ gtk_tree_model_get_value (tree_model_generator->priv->child_model, &child_iter, column, value);
}
diff --git a/libedataserverui/e-tree-model-generator.h b/libedataserverui/e-tree-model-generator.h
index 1b82ee2..a69993a 100644
--- a/libedataserverui/e-tree-model-generator.h
+++ b/libedataserverui/e-tree-model-generator.h
@@ -52,52 +52,48 @@ typedef void (*ETreeModelGeneratorModifyFunc) (GtkTreeModel *model, GtkTreeIte
gint permutation_n, gint column, GValue *value,
gpointer data);
-typedef struct _ETreeModelGenerator ETreeModelGenerator;
-typedef struct _ETreeModelGeneratorClass ETreeModelGeneratorClass;
-
-struct _ETreeModelGeneratorClass {
- GObjectClass parent_class;
-};
+typedef struct _ETreeModelGenerator ETreeModelGenerator;
+typedef struct _ETreeModelGeneratorClass ETreeModelGeneratorClass;
+typedef struct _ETreeModelGeneratorPrivate ETreeModelGeneratorPrivate;
struct _ETreeModelGenerator {
- GObject parent;
-
- /* Private */
-
- gint stamp;
- GtkTreeModel *child_model;
- GArray *root_nodes;
-
- ETreeModelGeneratorGenerateFunc generate_func;
- gpointer generate_func_data;
-
- ETreeModelGeneratorModifyFunc modify_func;
- gpointer modify_func_data;
+ GObject parent;
+ ETreeModelGeneratorPrivate *priv;
};
-GType e_tree_model_generator_get_type (void);
-
-ETreeModelGenerator *e_tree_model_generator_new (GtkTreeModel *child_model);
-GtkTreeModel *e_tree_model_generator_get_model (ETreeModelGenerator *tree_model_generator);
-
-void e_tree_model_generator_set_generate_func (ETreeModelGenerator *tree_model_generator,
- ETreeModelGeneratorGenerateFunc func,
- gpointer data, GDestroyNotify destroy);
-void e_tree_model_generator_set_modify_func (ETreeModelGenerator *tree_model_generator,
- ETreeModelGeneratorModifyFunc func,
- gpointer data, GDestroyNotify destroy);
+struct _ETreeModelGeneratorClass {
+ GObjectClass parent_class;
+};
-GtkTreePath *e_tree_model_generator_convert_child_path_to_path (ETreeModelGenerator *tree_model_generator,
- GtkTreePath *child_path);
-void e_tree_model_generator_convert_child_iter_to_iter (ETreeModelGenerator *tree_model_generator,
- GtkTreeIter *generator_iter,
- GtkTreeIter *child_iter);
-GtkTreePath *e_tree_model_generator_convert_path_to_child_path (ETreeModelGenerator *tree_model_generator,
- GtkTreePath *generator_path);
-void e_tree_model_generator_convert_iter_to_child_iter (ETreeModelGenerator *tree_model_generator,
- GtkTreeIter *child_iter,
- gint *permutation_n,
- GtkTreeIter *generator_iter);
+GType e_tree_model_generator_get_type (void);
+ETreeModelGenerator *
+ e_tree_model_generator_new (GtkTreeModel *child_model);
+GtkTreeModel * e_tree_model_generator_get_model(ETreeModelGenerator *tree_model_generator);
+void e_tree_model_generator_set_generate_func
+ (ETreeModelGenerator *tree_model_generator,
+ ETreeModelGeneratorGenerateFunc func,
+ gpointer data,
+ GDestroyNotify destroy);
+void e_tree_model_generator_set_modify_func
+ (ETreeModelGenerator *tree_model_generator,
+ ETreeModelGeneratorModifyFunc func,
+ gpointer data,
+ GDestroyNotify destroy);
+GtkTreePath * e_tree_model_generator_convert_child_path_to_path
+ (ETreeModelGenerator *tree_model_generator,
+ GtkTreePath *child_path);
+void e_tree_model_generator_convert_child_iter_to_iter
+ (ETreeModelGenerator *tree_model_generator,
+ GtkTreeIter *generator_iter,
+ GtkTreeIter *child_iter);
+GtkTreePath * e_tree_model_generator_convert_path_to_child_path
+ (ETreeModelGenerator *tree_model_generator,
+ GtkTreePath *generator_path);
+void e_tree_model_generator_convert_iter_to_child_iter
+ (ETreeModelGenerator *tree_model_generator,
+ GtkTreeIter *child_iter,
+ gint *permutation_n,
+ GtkTreeIter *generator_iter);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]