diff options
author | Chris Toshok <toshok@ximian.com> | 2004-07-31 02:06:17 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2004-07-31 02:06:17 +0800 |
commit | 47912d36f7826239b9eb93d5db3fc26daed612f8 (patch) | |
tree | 69c5b0514f659026b172313c3f313bd391a5c2fe /addressbook/gui/component/addressbook-view.c | |
parent | a07cfcb2bd8587ab0f52ec5539b426bac27de30e (diff) | |
download | gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.tar gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.tar.gz gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.tar.bz2 gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.tar.lz gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.tar.xz gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.tar.zst gsoc2013-evolution-47912d36f7826239b9eb93d5db3fc26daed612f8.zip |
[ fixes #61365 and other misc issues with the addressbook source editors ]
2004-07-30 Chris Toshok <toshok@ximian.com>
[ fixes #61365 and other misc issues with the addressbook source
editors ]
* gui/component/ldap-config.glade: change the
supported-bases-dialog to be initially hidden.
* gui/component/addressbook-view.c (editor_weak_notify): new
function, remove the editor from our hash.
(source_list_changed_cb): destroy the editors for given sources if
they're up when the source disappears.
(edit_addressbook_cb): add the editor (and some other misc info we
need) to our uid_to_editor hash so we can look it up later. only
create the editor if one doesn't exist for the given source.
(destroy_editor): GHFunc that destroys the widgets.
(addressbook_view_dispose): destroy uid_to_editor.
(addressbook_view_init): init uid_to_editor.
* gui/component/addressbook-config.h: change return values for
_edit_source and _new_source - they both return GtkWidget*s now.
* gui/component/addressbook-config.c (addressbook_ldap_init):
attempt set the protocol version to LDAPv3. This makes the
ldap_auth stuff work if the server requires v3.
(addressbook_root_dse_query): we don't need the separate window
arg, since all of this now happens *before* the supported bases
dialog is shown. we just use the source dialog's window for the
various error dialogs.
(do_ldap_root_dse_query): same.
(query_for_supported_bases): same, and set the supported bases
dialog as transient-for the source dialog, and make it modal.
Lastly, don't make the editor modal.
(addressbook_config_edit_source): return the editor's window.
(addressbook_config_create_new_source): same.
svn path=/trunk/; revision=26778
Diffstat (limited to 'addressbook/gui/component/addressbook-view.c')
-rw-r--r-- | addressbook/gui/component/addressbook-view.c | 86 |
1 files changed, 82 insertions, 4 deletions
diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index cfedd0b949..9b3db0c3b2 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -84,6 +84,8 @@ struct _AddressbookViewPrivate { GConfClient *gconf_client; GHashTable *uid_to_view; + GHashTable *uid_to_editor; + EBook *book; guint activity_id; ESourceList *source_list; @@ -112,6 +114,22 @@ static void addressbook_view_init (AddressbookView *view); static void addressbook_view_class_init (AddressbookViewClass *klass); static void addressbook_view_dispose (GObject *object); +typedef struct { + GtkWidget *editor; + char *uid; + AddressbookView *view; +} EditorUidClosure; + +static void +editor_weak_notify (gpointer data, GObject *o) +{ + EditorUidClosure *closure = data; + AddressbookViewPrivate *priv = closure->view->priv; + + g_hash_table_remove (priv->uid_to_editor, + closure->uid); +} + static EABView * get_current_view (AddressbookView *view) { @@ -469,15 +487,14 @@ source_list_changed_cb (ESourceList *source_list, AddressbookView *view) uids = NULL; g_hash_table_foreach (priv->uid_to_view, (GHFunc)gather_uids_foreach, &uids); - for (l = uids; l; l = l->next) { char *uid = l->data; if (e_source_list_peek_source_by_uid (source_list, uid)) { /* the source still exists, do nothing */ } else { - /* the source no longer exists, remove the - view and remove it from our hash table. */ + /* the source no longer exists, remove its + view remove it from our hash table. */ v = g_hash_table_lookup (priv->uid_to_view, uid); g_hash_table_remove (priv->uid_to_view, uid); @@ -487,6 +504,27 @@ source_list_changed_cb (ESourceList *source_list, AddressbookView *view) g_object_unref (v); } } + g_list_free (uids); + + uids = NULL; + g_hash_table_foreach (priv->uid_to_editor, (GHFunc)gather_uids_foreach, &uids); + for (l = uids; l; l = l->next) { + char *uid = l->data; + if (e_source_list_peek_source_by_uid (source_list, uid)) { + /* the source still exists, do nothing */ + } + else { + /* the source no longer exists, remove its + editor remove it from our hash table. */ + EditorUidClosure *closure = g_hash_table_lookup (priv->uid_to_editor, + uid); + g_object_weak_unref (G_OBJECT (closure->editor), + editor_weak_notify, closure); + gtk_widget_destroy (closure->editor); + g_hash_table_remove (priv->uid_to_editor, uid); + } + } + g_list_free (uids); /* make sure we've got the current view selected and updated properly */ @@ -676,13 +714,34 @@ edit_addressbook_cb (GtkWidget *widget, AddressbookView *view) { AddressbookViewPrivate *priv = view->priv; ESource *selected_source; + const char *uid;; + EditorUidClosure *closure; selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector)); if (!selected_source) return; - addressbook_config_edit_source (gtk_widget_get_toplevel (widget), selected_source); + uid = e_source_peek_uid (selected_source); + + closure = g_hash_table_lookup (priv->uid_to_editor, uid); + if (!closure) { + char *uid_copy = g_strdup (uid); + + closure = g_new (EditorUidClosure, 1); + closure->editor = addressbook_config_edit_source (gtk_widget_get_toplevel (widget), selected_source); + closure->uid = uid_copy; + closure->view = view; + + g_hash_table_insert (priv->uid_to_editor, + uid_copy, + closure); + + g_object_weak_ref (G_OBJECT (closure->editor), + editor_weak_notify, closure); + } + + gtk_window_present (GTK_WINDOW (closure->editor)); } /* Callbacks. */ @@ -1010,6 +1069,7 @@ addressbook_view_init (AddressbookView *view) priv->gconf_client = addressbook_component_peek_gconf_client (addressbook_component_peek ()); priv->uid_to_view = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, NULL); + priv->uid_to_editor = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free); priv->notebook = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE); @@ -1079,6 +1139,19 @@ addressbook_view_init (AddressbookView *view) } static void +destroy_editor (char *key, + gpointer value, + gpointer nada) +{ + EditorUidClosure *closure = value; + + g_object_weak_unref (G_OBJECT (closure->editor), + editor_weak_notify, closure); + + gtk_widget_destroy (GTK_WIDGET (closure->editor)); +} + +static void addressbook_view_dispose (GObject *object) { AddressbookView *view = ADDRESSBOOK_VIEW (object); @@ -1096,6 +1169,11 @@ addressbook_view_dispose (GObject *object) if (priv->uid_to_view) g_hash_table_destroy (priv->uid_to_view); + if (priv->uid_to_editor) { + g_hash_table_foreach (priv->uid_to_editor, (GHFunc)destroy_editor, NULL); + g_hash_table_destroy (priv->uid_to_editor); + } + if (priv->creatable_items_handler) g_object_unref (priv->creatable_items_handler); |