aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c63
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h2
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c23
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h2
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c6
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h1
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c27
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h3
8 files changed, 103 insertions, 24 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 9df7ab7225..830b70879c 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -33,13 +33,8 @@ enum {
};
static void
-addressbook_destroy(GtkObject *object)
+remove_book_view(EAddressbookModel *model)
{
- EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object);
- int i;
-
- if (model->get_view_idle)
- g_source_remove(model->get_view_idle);
if (model->book_view && model->create_card_id)
gtk_signal_disconnect(GTK_OBJECT (model->book_view),
model->create_card_id);
@@ -49,11 +44,31 @@ addressbook_destroy(GtkObject *object)
if (model->book_view && model->modify_card_id)
gtk_signal_disconnect(GTK_OBJECT (model->book_view),
model->modify_card_id);
- if (model->book)
- gtk_object_unref(GTK_OBJECT(model->book));
+
+ model->create_card_id = 0;
+ model->remove_card_id = 0;
+ model->modify_card_id = 0;
+
if (model->book_view)
gtk_object_unref(GTK_OBJECT(model->book_view));
+ model->book_view = NULL;
+}
+
+static void
+addressbook_destroy(GtkObject *object)
+{
+ EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object);
+ int i;
+
+ if (model->get_view_idle)
+ g_source_remove(model->get_view_idle);
+
+ remove_book_view(model);
+
+ if (model->book)
+ gtk_object_unref(GTK_OBJECT(model->book));
+
for ( i = 0; i < model->data_count; i++ ) {
gtk_object_unref(GTK_OBJECT(model->data[i]));
}
@@ -265,6 +280,7 @@ e_addressbook_model_init (GtkObject *object)
model->data = NULL;
model->data_count = 0;
model->editable = TRUE;
+ model->first_get_view = TRUE;
}
static void
@@ -272,17 +288,7 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
{
EAddressbookModel *model = closure;
int i;
- if (model->book_view && model->create_card_id)
- gtk_signal_disconnect(GTK_OBJECT (model->book_view),
- model->create_card_id);
- if (model->book_view && model->remove_card_id)
- gtk_signal_disconnect(GTK_OBJECT (model->book_view),
- model->remove_card_id);
- if (model->book_view && model->modify_card_id)
- gtk_signal_disconnect(GTK_OBJECT (model->book_view),
- model->modify_card_id);
- if (model->book_view)
- gtk_object_unref(GTK_OBJECT(model->book_view));
+ remove_book_view(model);
model->book_view = book_view;
if (model->book_view)
gtk_object_ref(GTK_OBJECT(model->book_view));
@@ -313,8 +319,18 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
static gboolean
get_view(EAddressbookModel *model)
{
- if (model->book && model->query)
- e_book_get_book_view(model->book, model->query, book_view_loaded, model);
+ if (model->book && model->query) {
+ if (model->first_get_view) {
+ char *capabilities;
+ capabilities = e_book_get_static_capabilities(model->book);
+ if (strstr(capabilities, "local")) {
+ e_book_get_book_view(model->book, model->query, book_view_loaded, model);
+ }
+ model->first_get_view = FALSE;
+ }
+ else
+ e_book_get_book_view(model->book, model->query, book_view_loaded, model);
+ }
model->get_view_idle = 0;
return FALSE;
@@ -421,3 +437,8 @@ e_addressbook_model_new (void)
return E_TABLE_MODEL(et);
}
+
+void e_addressbook_model_stop (EAddressbookModel *model)
+{
+ remove_book_view(model);
+}
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 0bde425a25..860fb641ac 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -36,6 +36,7 @@ typedef struct {
int create_card_id, remove_card_id, modify_card_id;
guint editable : 1;
+ guint first_get_view : 1;
} EAddressbookModel;
@@ -50,5 +51,6 @@ ETableModel *e_addressbook_model_new (void);
/* Returns object with ref count of 1. */
ECard *e_addressbook_model_get_card(EAddressbookModel *model,
int row);
+void e_addressbook_model_stop (EAddressbookModel *model);
#endif /* _E_ADDRESSBOOK_MODEL_H_ */
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 1700cfdc89..bd229fad25 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -709,3 +709,26 @@ e_addressbook_view_delete_selection(EAddressbookView *view)
if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD)
e_minicard_view_widget_remove_selection (E_MINICARD_VIEW_WIDGET(view->object), card_deleted_cb, NULL);
}
+
+void
+e_addressbook_view_show_all(EAddressbookView *view)
+{
+ gtk_object_set(GTK_OBJECT(view),
+ "query", NULL,
+ NULL);
+}
+
+void
+e_addressbook_view_stop(EAddressbookView *view)
+{
+ switch(view->view_type) {
+ case E_ADDRESSBOOK_VIEW_MINICARD:
+ e_minicard_view_widget_stop(E_MINICARD_VIEW_WIDGET (view->object));
+ break;
+ case E_ADDRESSBOOK_VIEW_TABLE:
+ e_addressbook_model_stop(E_ADDRESSBOOK_MODEL (view->object));
+ break;
+ case E_ADDRESSBOOK_VIEW_NONE:
+ break;
+ }
+}
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index 0509e897e6..60da283a75 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -79,6 +79,8 @@ GtkType e_addressbook_view_get_type (void);
void e_addressbook_view_print (EAddressbookView *view);
void e_addressbook_view_delete_selection (EAddressbookView *view);
+void e_addressbook_view_show_all (EAddressbookView *view);
+void e_addressbook_view_stop (EAddressbookView *view);
#ifdef __cplusplus
}
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index f23d3e4476..c6809bf1d0 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -268,3 +268,9 @@ void e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view,
if (view->emv)
e_minicard_view_jump_to_letter(E_MINICARD_VIEW(view->emv), letter);
}
+
+void
+e_minicard_view_widget_stop(EMinicardViewWidget *view)
+{
+ e_minicard_view_stop(E_MINICARD_VIEW(view->emv));
+}
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index 952e60ee65..cf20c9a4df 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -63,6 +63,7 @@ void e_minicard_view_widget_remove_selection (EMinicardViewWidget *view,
gpointer closure);
void e_minicard_view_widget_jump_to_letter (EMinicardViewWidget *view,
char letter);
+void e_minicard_view_widget_stop (EMinicardViewWidget *view);
GtkWidget *e_minicard_view_widget_new (void);
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 249c987802..7169e41542 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -105,6 +105,7 @@ e_minicard_view_init (EMinicardView *view)
view->remove_card_id = 0;
view->modify_card_id = 0;
view->canvas_destroy_id = 0;
+ view->first_get_view = TRUE;
gtk_object_set(GTK_OBJECT(view),
"empty_message", _("\n\nThere are no items to show in this view\n\n"
@@ -191,8 +192,18 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
static gboolean
get_view(EMinicardView *view)
{
- if (view->book && view->query)
- e_book_get_book_view(view->book, view->query, book_view_loaded, view);
+ if (view->book && view->query) {
+ if (view->first_get_view) {
+ char *capabilities;
+ capabilities = e_book_get_static_capabilities(view->book);
+ if (strstr(capabilities, "local")) {
+ e_book_get_book_view(view->book, view->query, book_view_loaded, view);
+ }
+ view->first_get_view = FALSE;
+ }
+ else
+ e_book_get_book_view(view->book, view->query, book_view_loaded, view);
+ }
view->get_view_idle = 0;
return FALSE;
@@ -423,10 +434,20 @@ compare_to_letter(EMinicard *card, char *letter)
}
}
-void e_minicard_view_jump_to_letter (EMinicardView *view,
+void
+e_minicard_view_jump_to_letter (EMinicardView *view,
char letter)
{
e_reflow_sorted_jump(E_REFLOW_SORTED(view),
(GCompareFunc) compare_to_letter,
&letter);
}
+
+void
+e_minicard_view_stop (EMinicardView *view)
+{
+ disconnect_signals(view);
+ if (view->book_view)
+ gtk_object_unref(GTK_OBJECT(view->book_view));
+ view->book_view = NULL;
+}
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index f12f0d43cf..e4c1be870a 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -73,6 +73,8 @@ struct _EMinicardView
int canvas_destroy_id;
int create_card_id, remove_card_id, modify_card_id;
+
+ guint first_get_view : 1;
};
struct _EMinicardViewClass
@@ -86,6 +88,7 @@ void e_minicard_view_remove_selection (EMinicardView *view,
gpointer closure);
void e_minicard_view_jump_to_letter (EMinicardView *view,
char letter);
+void e_minicard_view_stop (EMinicardView *view);
#ifdef __cplusplus
}