aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-02-17 10:00:32 +0800
committerChris Toshok <toshok@src.gnome.org>2003-02-17 10:00:32 +0800
commit9e048335b618fea2076c690479cd655d35a56515 (patch)
treed60440f1c22cfca6281597e67ecd8f00ae2e5ab7 /addressbook/gui
parentaba27fbc03e26cf04ed7d9204968317e69112640 (diff)
downloadgsoc2013-evolution-9e048335b618fea2076c690479cd655d35a56515.tar.gz
gsoc2013-evolution-9e048335b618fea2076c690479cd655d35a56515.tar.zst
gsoc2013-evolution-9e048335b618fea2076c690479cd655d35a56515.zip
disconnect search_started and search_result. (addressbook_compare): if
2003-02-16 Chris Toshok <toshok@ximian.com> * gui/widgets/e-addressbook-reflow-adapter.c (unlink_model): disconnect search_started and search_result. (addressbook_compare): if we're loading, just compare model positions (so we just append while loading). (remove_card): use e_reflow_model_item_removed. (search_started): new function, set loading = TRUE. (search_result): new function, set loading = FALSE and emit "comparison_changed". (e_addressbook_reflow_adapter_init): init loading and the new signal ids. (e_addressbook_reflow_adapter_construct): connect "search_started" and "search_result". * gui/widgets/e-addressbook-model.h (struct _EAddressbookModelClass): add search_started signal. * gui/widgets/e-addressbook-model.c (e_addressbook_model_class_init): new signal "search_started". (book_view_loaded): emit "search_started" after "model_changed". (remove_card): simplify this, and use CARD_REMOVED all the time, instead of just in the single card case. svn path=/trunk/; revision=19916
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c34
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h1
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c118
3 files changed, 98 insertions, 55 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index df537cbdf7..782516d86a 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -39,6 +39,7 @@ enum {
enum {
WRITABLE_STATUS,
STATUS_MESSAGE,
+ SEARCH_STARTED,
SEARCH_RESULT,
FOLDER_BAR_MESSAGE,
CARD_ADDED,
@@ -201,13 +202,8 @@ remove_card(EBookView *book_view,
EAddressbookModel *model)
{
int i = 0;
- int num_deleted = 0;
GList *l;
- /* XXX this is really broken. the CARD_REMOVED signal should
- be enough for us, but the !(*@#& EReflow mess can't delete
- single objects at a time. In fact it can't remove objects
- at all. every deletion = model_changed. */
for (l = ids; l; l = l->next) {
char *id = l->data;
for ( i = 0; i < model->data_count; i++) {
@@ -216,23 +212,16 @@ remove_card(EBookView *book_view,
memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *));
model->data_count--;
- num_deleted++;
+ g_signal_emit (model,
+ e_addressbook_model_signals [CARD_REMOVED], 0,
+ i);
+
break;
}
}
}
- if (num_deleted == 1) {
- g_signal_emit (model,
- e_addressbook_model_signals [CARD_REMOVED], 0,
- i);
- update_folder_bar_message (model);
- }
- else if (num_deleted > 1) {
- g_signal_emit (model,
- e_addressbook_model_signals [MODEL_CHANGED], 0);
- update_folder_bar_message (model);
- }
+ update_folder_bar_message (model);
}
static void
@@ -351,6 +340,15 @@ e_addressbook_model_class_init (GObjectClass *object_class)
G_TYPE_NONE,
1, G_TYPE_POINTER);
+ e_addressbook_model_signals [SEARCH_STARTED] =
+ g_signal_new ("search_started",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EAddressbookModelClass, search_started),
+ NULL, NULL,
+ e_addressbook_marshal_NONE__NONE,
+ G_TYPE_NONE, 0);
+
e_addressbook_model_signals [SEARCH_RESULT] =
g_signal_new ("search_result",
G_OBJECT_CLASS_TYPE (object_class),
@@ -490,6 +488,8 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
g_signal_emit (model,
e_addressbook_model_signals [MODEL_CHANGED], 0);
g_signal_emit (model,
+ e_addressbook_model_signals [SEARCH_STARTED], 0);
+ g_signal_emit (model,
e_addressbook_model_signals [STOP_STATE_CHANGED], 0);
}
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index c5d9e6ca84..57cfe6f729 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -49,6 +49,7 @@ struct _EAddressbookModelClass {
* Signals
*/
void (*writable_status) (EAddressbookModel *model, gboolean writable);
+ void (*search_started) (EAddressbookModel *model);
void (*search_result) (EAddressbookModel *model, EBookViewStatus status);
void (*status_message) (EAddressbookModel *model, const gchar *message);
void (*folder_bar_message) (EAddressbookModel *model, const gchar *message);
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index 0beb305384..070173fda7 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -21,8 +21,11 @@
struct _EAddressbookReflowAdapterPrivate {
EAddressbookModel *model;
-
+
+ gboolean loading;
+
int create_card_id, remove_card_id, modify_card_id, model_changed_id;
+ int search_started_id, search_result_id;
};
#define PARENT_TYPE e_reflow_model_get_type()
@@ -59,15 +62,22 @@ unlink_model(EAddressbookReflowAdapter *adapter)
if (priv->model && priv->modify_card_id)
g_signal_handler_disconnect (priv->model,
priv->modify_card_id);
-
if (priv->model && priv->model_changed_id)
g_signal_handler_disconnect (priv->model,
priv->model_changed_id);
+ if (priv->model && priv->search_started_id)
+ g_signal_handler_disconnect (priv->model,
+ priv->search_started_id);
+ if (priv->model && priv->search_result_id)
+ g_signal_handler_disconnect (priv->model,
+ priv->search_result_id);
priv->create_card_id = 0;
priv->remove_card_id = 0;
priv->modify_card_id = 0;
priv->model_changed_id = 0;
+ priv->search_started_id = 0;
+ priv->search_result_id = 0;
if (priv->model)
g_object_unref (priv->model);
@@ -115,17 +125,14 @@ addressbook_count (EReflowModel *erm)
static int
addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent)
{
- /* XXX ugh, an extra pango layout step for every minicard
- whether it's displayed or not? */
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm);
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- /* FIXME */
ECardSimpleField field;
int count = 0;
- int height;
char *string;
ECardSimple *simple = e_card_simple_new (e_addressbook_model_card_at (priv->model, i));
PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (parent)->canvas), "");
+ int height;
string = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FILE_AS);
height = text_height (layout, string ? string : "") + 10.0;
@@ -168,27 +175,32 @@ addressbook_compare (EReflowModel *erm, int n1, int n2)
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm);
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
ECard *card1, *card2;
-
- card1 = e_addressbook_model_card_at (priv->model, n1);
- card2 = e_addressbook_model_card_at (priv->model, n2);
-
- if (card1 && card2) {
- char *file_as1, *file_as2;
- file_as1 = card1->file_as;
- file_as2 = card2->file_as;
- if (file_as1 && file_as2)
- return g_utf8_collate(file_as1, file_as2);
- if (file_as1)
+
+ if (priv->loading) {
+ return n1-n2;
+ }
+ else {
+ card1 = e_addressbook_model_card_at (priv->model, n1);
+ card2 = e_addressbook_model_card_at (priv->model, n2);
+
+ if (card1 && card2) {
+ char *file_as1, *file_as2;
+ file_as1 = card1->file_as;
+ file_as2 = card2->file_as;
+ if (file_as1 && file_as2)
+ return g_utf8_collate(file_as1, file_as2);
+ if (file_as1)
+ return -1;
+ if (file_as2)
+ return 1;
+ return strcmp(e_card_get_id(card1), e_card_get_id(card2));
+ }
+ if (card1)
return -1;
- if (file_as2)
+ if (card2)
return 1;
- return strcmp(e_card_get_id(card1), e_card_get_id(card2));
+ return 0;
}
- if (card1)
- return -1;
- if (card2)
- return 1;
- return 0;
}
static int
@@ -238,12 +250,10 @@ addressbook_reincarnate (EReflowModel *erm, int i, GnomeCanvasItem *item)
NULL);
}
-
-
static void
-create_card(EAddressbookModel *model,
- gint index, gint count,
- EAddressbookReflowAdapter *adapter)
+create_card (EAddressbookModel *model,
+ gint index, gint count,
+ EAddressbookReflowAdapter *adapter)
{
e_reflow_model_items_inserted (E_REFLOW_MODEL (adapter),
index,
@@ -251,29 +261,50 @@ create_card(EAddressbookModel *model,
}
static void
-remove_card(EAddressbookModel *model,
- gint index,
- EAddressbookReflowAdapter *adapter)
+remove_card (EAddressbookModel *model,
+ gint index,
+ EAddressbookReflowAdapter *adapter)
{
- e_reflow_model_changed (E_REFLOW_MODEL (adapter));
+ e_reflow_model_item_removed (E_REFLOW_MODEL (adapter), index);
}
static void
-modify_card(EAddressbookModel *model,
- gint index,
- EAddressbookReflowAdapter *adapter)
+modify_card (EAddressbookModel *model,
+ gint index,
+ EAddressbookReflowAdapter *adapter)
{
e_reflow_model_item_changed (E_REFLOW_MODEL (adapter), index);
}
static void
-model_changed(EAddressbookModel *model,
- EAddressbookReflowAdapter *adapter)
+model_changed (EAddressbookModel *model,
+ EAddressbookReflowAdapter *adapter)
{
e_reflow_model_changed (E_REFLOW_MODEL (adapter));
}
static void
+search_started (EAddressbookModel *model,
+ EAddressbookReflowAdapter *adapter)
+{
+ EAddressbookReflowAdapterPrivate *priv = adapter->priv;
+
+ priv->loading = TRUE;
+}
+
+static void
+search_result (EAddressbookModel *model,
+ EBookViewStatus status,
+ EAddressbookReflowAdapter *adapter)
+{
+ EAddressbookReflowAdapterPrivate *priv = adapter->priv;
+
+ priv->loading = FALSE;
+
+ e_reflow_model_comparison_changed (E_REFLOW_MODEL (adapter));
+}
+
+static void
addressbook_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object);
@@ -396,10 +427,13 @@ e_addressbook_reflow_adapter_init (GtkObject *object)
priv = adapter->priv = g_new0 (EAddressbookReflowAdapterPrivate, 1);
+ priv->loading = FALSE;
priv->create_card_id = 0;
priv->remove_card_id = 0;
priv->modify_card_id = 0;
priv->model_changed_id = 0;
+ priv->search_started_id = 0;
+ priv->search_result_id = 0;
}
GType
@@ -451,6 +485,14 @@ e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter,
"model_changed",
G_CALLBACK(model_changed),
adapter);
+ priv->search_started_id = g_signal_connect(priv->model,
+ "search_started",
+ G_CALLBACK(search_started),
+ adapter);
+ priv->search_result_id = g_signal_connect(priv->model,
+ "search_result",
+ G_CALLBACK(search_result),
+ adapter);
}
EReflowModel *