#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) \
#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,
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
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;
}
/**
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);
}
/* ------------------ *
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;
}
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;
}
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;
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;
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;
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;
}
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;
}
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);
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 */
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++) {
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;
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;
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) {
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);
}
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));
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);
}
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));
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 */
}
/**
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);
}
}
{
g_return_val_if_fail (E_IS_CONTACT_STORE (contact_store), NULL);
- return contact_store->query;
+ return contact_store->priv->query;
}
/* ---------------- *
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
#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,
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
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 ();
}
/**
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);
}
/* ------------------ *
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;
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;
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);
}
/**
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);
}
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);
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);
}
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)) {
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);
}
/**
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));
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);
}
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;
}
/* ---------------- *
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);
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;
}
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);
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;
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;
}
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);
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) {
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;
+}
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
#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;
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;
};
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)
{
/* "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);
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");
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;
}
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;
}
/* 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 */
(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);
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 */
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;
}
/**
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;
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);
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;
}
}
{
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;
{
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;
{
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;
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);
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);
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
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));
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);
}
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);
}
/* -------------------- *
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
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
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);
}
/* --------------- *
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);
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);
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);
}
}
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);
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
/* 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
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;
}
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);
/* 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!");
}
/* 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;
}
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;
}
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);
}
/* 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);
/* 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 */
/* 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;
}
}
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);
{
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;
}
/**
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);
}
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;
}
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
#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;
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
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);
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 */
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. */
}
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 */
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;
}
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);
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 {
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;
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;
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 */
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;
}
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) {
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);
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;
}
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;
}
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;
}
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);
}
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);
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);
}
}
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);
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);
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);
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 */
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;
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);
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);
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;
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, ", ");
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);
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);
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;
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);
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);
}
}
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;
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);
}
}
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;
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);
{
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
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),
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;
}
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;
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 {
{
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"));
EContact *contact;
gchar *contact_uid;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
if (!destination)
return;
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);
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);
EContact *contact;
gint email_num;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
if (!destination)
return;
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);
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);
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);
gboolean is_list;
gboolean show_menu = FALSE;
- destination = name_selector_entry->popup_destination;
+ destination = name_selector_entry->priv->popup_destination;
if (!destination)
return;
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;
}
/**
{
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;
}
/**
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);
}
{
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;
}
/**
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:
*
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;
}
/**
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;
}
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
#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 */
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
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 |
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)));
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);
}
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;
}
#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;
}
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;
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);
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;
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)
/* 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);
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
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;
{
GtkWidget *menu;
EDestination *destination;
- ENameSelectorEntry *name_selector_entry;
+ ENameSelectorEntry *entry;
+ EDestinationStore *store;
EContact *contact;
GtkWidget *menu_item;
GList *email_list = NULL, *l;
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);
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;
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);
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);
{
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);
&& 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;
}
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
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);
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);
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);
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);
}
#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 */
#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;
}
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,
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);
}
/**
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)) {
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;
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;
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;
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);
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;
{
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;
}
/**
{
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;
}
/**
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);
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);
}
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);
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);
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)) {
#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
#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
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);
}
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;
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;
}
/**
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);
}
/* ------- *
static gint
add_section (ENameSelector *name_selector, const gchar *name)
{
+ GArray *array;
Section section;
g_assert (name != NULL);
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;
{
g_return_val_if_fail (E_IS_NAME_SELECTOR (name_selector), NULL);
- return name_selector->model;
+ return name_selector->priv->model;
}
/**
{
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;
}
/**
e_name_selector_peek_section_entry (ENameSelector *name_selector, const gchar *name)
{
ENameSelectorPrivate *priv;
+ ENameSelectorModel *model;
EDestinationStore *destination_store;
Section *section;
gint 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;
e_name_selector_peek_section_list (ENameSelector *name_selector, const gchar *name)
{
ENameSelectorPrivate *priv;
+ ENameSelectorModel *model;
EDestinationStore *destination_store;
Section *section;
gint 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;
#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
* 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>
**/
struct _ESourceComboBox {
GtkComboBox parent;
-
ESourceComboBoxPrivate *priv;
};
G_END_DECLS
-#endif /* _E_SOURCE_COMBO_BOX_H_ */
+#endif /* E_SOURCE_COMBO_BOX_H */
* 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;
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 */
#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,
* 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:
}
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:
}
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
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));
}
/* ------------------ *
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;
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;
}
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;
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;
}
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);
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;
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;
{
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;
}
/**
{
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;
}
/**
{
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;
}
/**
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;
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;
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;
}
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;
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
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
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
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;
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;
}
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;
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);
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;
}
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);
}
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