aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2004-01-17 08:52:06 +0800
committerHans Petter <hansp@src.gnome.org>2004-01-17 08:52:06 +0800
commitfa20d6a1f4c0c792ceefa031922da750eb60c32e (patch)
tree16859d85dc3efa973fc9f233dd65ef43e0dd798a
parent661c8fe4978af68a06b3c67076606edc8de7a068 (diff)
downloadgsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.tar
gsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.tar.gz
gsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.tar.bz2
gsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.tar.lz
gsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.tar.xz
gsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.tar.zst
gsoc2013-evolution-fa20d6a1f4c0c792ceefa031922da750eb60c32e.zip
Don't run callback if the action was cancelled. (load_source_cb): Ditto.
2004-01-16 Hans Petter Jansson <hpj@ximian.com> * gui/component/addressbook.c (load_source_auth_cb): Don't run callback if the action was cancelled. (load_source_cb): Ditto. (addressbook_load_source): Return an ID for the load attempt. (addressbook_load_source_cancel): Implement, allows cancelling a load attempt. * gui/contact-editor/e-contact-editor.c (new_target_cb): Clear the values for in-progress load operation. Only unref new_book if it's non-NULL. (cancel_load): Implement. Cancels the load operation if one is in progress. (source_selected): Cancel any running load operation before starting a new one. Set up in-progress values. (e_contact_editor_init): Clear the in-progress values. (e_contact_editor_dispose): Cancel load operation. (e_contact_editor_set_property): If a new target book is set, cancel any conflicting load operation in progress. * gui/widgets/e-addressbook-view.c (set_paned_position): Remove debug output. (get_paned_position): Ditto. svn path=/trunk/; revision=24287
-rw-r--r--addressbook/ChangeLog25
-rw-r--r--addressbook/gui/component/addressbook.c24
-rw-r--r--addressbook/gui/component/addressbook.h3
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c34
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h4
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c4
6 files changed, 84 insertions, 10 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 5c7f028102..33c8cb16f3 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,28 @@
+2004-01-16 Hans Petter Jansson <hpj@ximian.com>
+
+ * gui/component/addressbook.c (load_source_auth_cb): Don't run
+ callback if the action was cancelled.
+ (load_source_cb): Ditto.
+ (addressbook_load_source): Return an ID for the load attempt.
+ (addressbook_load_source_cancel): Implement, allows cancelling a
+ load attempt.
+
+ * gui/contact-editor/e-contact-editor.c (new_target_cb): Clear the
+ values for in-progress load operation. Only unref new_book if it's
+ non-NULL.
+ (cancel_load): Implement. Cancels the load operation if one is in
+ progress.
+ (source_selected): Cancel any running load operation before starting
+ a new one. Set up in-progress values.
+ (e_contact_editor_init): Clear the in-progress values.
+ (e_contact_editor_dispose): Cancel load operation.
+ (e_contact_editor_set_property): If a new target book is set, cancel
+ any conflicting load operation in progress.
+
+ * gui/widgets/e-addressbook-view.c (set_paned_position): Remove
+ debug output.
+ (get_paned_position): Ditto.
+
2004-01-16 JP Rosevear <jpr@ximian.com>
* gui/component/addressbook.c (set_prop): only set the menus and
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index b317e46c12..1062e2632d 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -682,6 +682,7 @@ typedef struct {
EBookCallback cb;
ESource *source;
gpointer closure;
+ guint cancelled : 1;
} LoadSourceData;
static void
@@ -689,6 +690,11 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
{
LoadSourceData *data = closure;
+ if (data->cancelled) {
+ g_free (data);
+ return;
+ }
+
if (status != E_BOOK_ERROR_OK) {
if (status == E_BOOK_ERROR_CANCELLED) {
/* the user clicked cancel in the password dialog */
@@ -805,6 +811,11 @@ load_source_cb (EBook *book, EBookStatus status, gpointer closure)
{
LoadSourceData *load_source_data = closure;
+ if (load_source_data->cancelled) {
+ g_free (load_source_data);
+ return;
+ }
+
if (status == E_BOOK_ERROR_OK && book != NULL) {
const gchar *auth;
@@ -825,7 +836,7 @@ load_source_cb (EBook *book, EBookStatus status, gpointer closure)
g_free (load_source_data);
}
-void
+guint
addressbook_load_source (EBook *book, ESource *source,
EBookCallback cb, gpointer closure)
{
@@ -834,8 +845,19 @@ addressbook_load_source (EBook *book, ESource *source,
load_source_data->cb = cb;
load_source_data->closure = closure;
load_source_data->source = g_object_ref (source);
+ load_source_data->cancelled = FALSE;
e_book_async_load_source (book, source, load_source_cb, load_source_data);
+
+ return GPOINTER_TO_UINT (load_source_data);
+}
+
+void
+addressbook_load_source_cancel (guint id)
+{
+ LoadSourceData *load_source_data = GUINT_TO_POINTER (id);
+
+ load_source_data->cancelled = TRUE;
}
void
diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h
index 16395789e2..875752e0c3 100644
--- a/addressbook/gui/component/addressbook.h
+++ b/addressbook/gui/component/addressbook.h
@@ -12,7 +12,8 @@
#if 0
void addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure);
#endif
-void addressbook_load_source (EBook *book, ESource *source, EBookCallback cb, gpointer closure);
+guint addressbook_load_source (EBook *book, ESource *source, EBookCallback cb, gpointer closure);
+void addressbook_load_source_cancel (guint id);
void addressbook_load_default_book (EBookCallback open_response, gpointer closure);
void addressbook_show_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status);
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index a3ea73d957..65106bc9ad 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -964,6 +964,9 @@ address_mailing_changed (GtkWidget *widget, EContactEditor *editor)
static void
new_target_cb (EBook *new_book, EBookStatus status, EContactEditor *editor)
{
+ editor->load_source_id = 0;
+ editor->load_book = NULL;
+
if (status != E_BOOK_ERROR_OK || new_book == NULL) {
GtkWidget *source_option_menu;
@@ -972,7 +975,9 @@ new_target_cb (EBook *new_book, EBookStatus status, EContactEditor *editor)
source_option_menu = glade_xml_get_widget (editor->gui, "source-option-menu-source");
e_source_option_menu_select (E_SOURCE_OPTION_MENU (source_option_menu),
e_book_get_source (editor->target_book));
- g_object_unref (new_book);
+
+ if (new_book)
+ g_object_unref (new_book);
return;
}
@@ -981,9 +986,21 @@ new_target_cb (EBook *new_book, EBookStatus status, EContactEditor *editor)
}
static void
+cancel_load (EContactEditor *editor)
+{
+ if (editor->load_source_id) {
+ addressbook_load_source_cancel (editor->load_source_id);
+ editor->load_source_id = 0;
+
+ g_object_unref (editor->load_book);
+ editor->load_book = NULL;
+ }
+}
+
+static void
source_selected (GtkWidget *source_option_menu, ESource *source, EContactEditor *editor)
{
- EBook *new_book;
+ cancel_load (editor);
if (e_source_equal (e_book_get_source (editor->target_book), source))
return;
@@ -993,8 +1010,9 @@ source_selected (GtkWidget *source_option_menu, ESource *source, EContactEditor
return;
}
- new_book = e_book_new ();
- addressbook_load_source (new_book, source, (EBookCallback) new_target_cb, editor);
+ editor->load_book = e_book_new ();
+ editor->load_source_id = addressbook_load_source (editor->load_book, source,
+ (EBookCallback) new_target_cb, editor);
}
/* This function tells you whether name_to_style will make sense. */
@@ -1928,6 +1946,9 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
e_contact_editor->source_editable = TRUE;
e_contact_editor->target_editable = TRUE;
+ e_contact_editor->load_source_id = 0;
+ e_contact_editor->load_book = NULL;
+
gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL, NULL);
e_contact_editor->gui = gui;
@@ -2113,6 +2134,8 @@ e_contact_editor_dispose (GObject *object) {
g_object_unref(e_contact_editor->gui);
e_contact_editor->gui = NULL;
}
+
+ cancel_load (e_contact_editor);
}
static void
@@ -2264,6 +2287,9 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
if (changed)
command_state_changed (editor);
+ /* If we're trying to load a new target book, cancel that here. */
+ cancel_load (editor);
+
/* XXX more here about editable/etc. */
break;
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index ddb4ad3a5f..069cc7d0cc 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -108,6 +108,10 @@ struct _EContactEditor
guint in_async_call : 1;
EList *writable_fields;
+
+ /* ID for async load_source call */
+ guint load_source_id;
+ EBook *load_book;
};
struct _EContactEditorClass
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 3e58c2651c..04f28671f5 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -363,8 +363,6 @@ set_paned_position (EABView *eav)
GConfClient *gconf_client;
gint pos;
- g_print (G_STRLOC "\n");
-
gconf_client = gconf_client_get_default ();
pos = gconf_client_get_int (gconf_client, "/apps/evolution/addressbook/display/vpane_position", NULL);
if (pos < 1)
@@ -379,8 +377,6 @@ get_paned_position (EABView *eav)
GConfClient *gconf_client;
gint pos;
- g_print (G_STRLOC "\n");
-
gconf_client = gconf_client_get_default ();
pos = gtk_paned_get_position (GTK_PANED (eav->paned));