diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-08-22 00:33:59 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-08-22 00:33:59 +0800 |
commit | 6bb4c6468a602920f04f7d38f4de7247d8719de5 (patch) | |
tree | 186b443aa7a08203c9b081e4b04fcc459856753a | |
parent | eaa082e9d2e5ac4fb69799596ce234c35f32aeab (diff) | |
download | gsoc2013-epiphany-6bb4c6468a602920f04f7d38f4de7247d8719de5.tar.gz gsoc2013-epiphany-6bb4c6468a602920f04f7d38f4de7247d8719de5.tar.zst gsoc2013-epiphany-6bb4c6468a602920f04f7d38f4de7247d8719de5.zip |
Keep the passwords list in the pdm dialogue up-to-date wrt. new passwords
2004-08-21 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-password-manager.c: (ephy_password_manager_get_type),
(ephy_password_manager_base_init):
* embed/ephy-password-manager.h:
* embed/mozilla/EphySingle.cpp:
* src/pdm-dialog.c: (cookies_cleared_cb),
(pdm_dialog_fill_cookies_list), (passwords_changed_cb),
(pdm_dialog_fill_passwords_list), (pdm_dialog_password_remove),
(pdm_dialog_finalize):
Keep the passwords list in the pdm dialogue up-to-date wrt.
new passwords saved from web pages.
Fixes bug #150296.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | embed/ephy-password-manager.c | 31 | ||||
-rw-r--r-- | embed/ephy-password-manager.h | 3 | ||||
-rw-r--r-- | embed/mozilla/EphySingle.cpp | 10 | ||||
-rwxr-xr-x | src/pdm-dialog.c | 67 |
5 files changed, 105 insertions, 21 deletions
@@ -1,5 +1,20 @@ 2004-08-21 Christian Persch <chpe@cvs.gnome.org> + * embed/ephy-password-manager.c: (ephy_password_manager_get_type), + (ephy_password_manager_base_init): + * embed/ephy-password-manager.h: + * embed/mozilla/EphySingle.cpp: + * src/pdm-dialog.c: (cookies_cleared_cb), + (pdm_dialog_fill_cookies_list), (passwords_changed_cb), + (pdm_dialog_fill_passwords_list), (pdm_dialog_password_remove), + (pdm_dialog_finalize): + + Keep the passwords list in the pdm dialogue up-to-date wrt. + new passwords saved from web pages. + Fixes bug #150296. + +2004-08-21 Christian Persch <chpe@cvs.gnome.org> + * src/ephy-window.c: Set accel for normal zoom, as per HIG. diff --git a/embed/ephy-password-manager.c b/embed/ephy-password-manager.c index b1b4a5b02..c0f1e7838 100644 --- a/embed/ephy-password-manager.c +++ b/embed/ephy-password-manager.c @@ -106,6 +106,8 @@ ephy_password_info_free (EphyPasswordInfo *info) /* EphyPasswordManager */ +static void ephy_password_manager_base_init (gpointer g_class); + GType ephy_password_manager_get_type (void) { @@ -116,7 +118,7 @@ ephy_password_manager_get_type (void) static const GTypeInfo our_info = { sizeof (EphyPasswordManagerIface), - NULL, + ephy_password_manager_base_init, NULL, }; @@ -129,6 +131,33 @@ ephy_password_manager_get_type (void) return type; } +static void +ephy_password_manager_base_init (gpointer g_class) +{ + static gboolean initialised = FALSE; + + if (initialised == FALSE) + { + /** + * EphyPasswordManager::changed + * @manager: the #EphyPermissionManager + * + * The ::passwords-changed signal is emitted when the list of passwords + * has changed. + */ + g_signal_new ("passwords-changed", + EPHY_TYPE_PASSWORD_MANAGER, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyPasswordManagerIface, changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + + initialised = TRUE; + } +} + /** * ephy_password_manager_add: * @manager: the #EphyPasswordManager diff --git a/embed/ephy-password-manager.h b/embed/ephy-password-manager.h index 1d0d5c0f4..a9ae67f21 100644 --- a/embed/ephy-password-manager.h +++ b/embed/ephy-password-manager.h @@ -50,6 +50,9 @@ struct EphyPasswordManagerIface { GTypeInterface base_iface; + /* Signals */ + void (* changed) (EphyPasswordManager *manager); + /* Methods */ void (* add) (EphyPasswordManager *manager, EphyPasswordInfo *info); diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp index e8f2d4ee4..bd7f0a718 100644 --- a/embed/mozilla/EphySingle.cpp +++ b/embed/mozilla/EphySingle.cpp @@ -60,6 +60,7 @@ EphySingle::Init (EphyEmbedSingle *aOwner) rv |= mObserverService->AddObserver (this, "cookie-rejected", PR_FALSE); rv |= mObserverService->AddObserver (this, "perm-changed", PR_FALSE); rv |= mObserverService->AddObserver (this, "network:offline-status-changed", PR_FALSE); + rv |= mObserverService->AddObserver (this, "signonChanged", PR_FALSE); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); mOwner = aOwner; @@ -79,6 +80,7 @@ EphySingle::Detach () mObserverService->RemoveObserver (this, "cookie-changed"); mObserverService->RemoveObserver (this, "cookie-rejected"); mObserverService->RemoveObserver (this, "perm-changed"); + mObserverService->RemoveObserver (this, "signonChanged"); mObserverService->RemoveObserver (this, "network:offline-status-changed"); } @@ -215,6 +217,14 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject, rv = NS_ERROR_FAILURE; } } + else if (strcmp (aTopic, "signonChanged") == 0) + { + /* aData can be PRUnichar[] "signons", "rejects", "nocaptures" and "nopreviews" */ + if (aData[0] == 's') + { + g_signal_emit_by_name (mOwner, "passwords-changed"); + } + } else if (strcmp (aTopic, "network:offline-status-changed") == 0) { /* aData is either (PRUnichar[]) "offline" or "online" */ diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c index c718681b9..d934225ac 100755 --- a/src/pdm-dialog.c +++ b/src/pdm-dialog.c @@ -540,19 +540,10 @@ cookies_cleared_cb (EphyCookieManager *manager, PdmDialog *dialog) { PdmActionInfo *info = dialog->priv->cookies; - GtkTreeIter iter; - gboolean valid; LOG ("cookies_cleared_cb") - valid = gtk_tree_model_get_iter_first (info->model, &iter); - - while (valid) - { - gtk_list_store_remove (GTK_LIST_STORE (info->model), &iter); - - valid = gtk_tree_model_iter_next (info->model, &iter); - } + gtk_list_store_clear (GTK_LIST_STORE (info->model)); } static void @@ -579,14 +570,14 @@ pdm_dialog_fill_cookies_list (PdmActionInfo *info) info->filled = TRUE; /* Now connect the callbacks on the EphyCookieManager */ - g_signal_connect_object (manager, "cookie-added", - G_CALLBACK (cookie_added_cb), info->dialog, 0); - g_signal_connect_object (manager, "cookie-changed", - G_CALLBACK (cookie_changed_cb), info->dialog, 0); - g_signal_connect_object (manager, "cookie-deleted", - G_CALLBACK (cookie_deleted_cb), info->dialog, 0); - g_signal_connect_object (manager, "cookies-cleared", - G_CALLBACK (cookies_cleared_cb), info->dialog, 0); + g_signal_connect (manager, "cookie-added", + G_CALLBACK (cookie_added_cb), info->dialog); + g_signal_connect (manager, "cookie-changed", + G_CALLBACK (cookie_changed_cb), info->dialog); + g_signal_connect (manager, "cookie-deleted", + G_CALLBACK (cookie_deleted_cb), info->dialog); + g_signal_connect (manager, "cookies-cleared", + G_CALLBACK (cookies_cleared_cb), info->dialog); } static void @@ -695,13 +686,25 @@ pdm_dialog_passwords_construct (PdmActionInfo *info) } static void +passwords_changed_cb (EphyPasswordManager *manager, + PdmDialog *dialog) +{ + LOG ("passwords changed") + + /* since the callback doesn't carry any information about what + * exactly has changed, we have to rebuild the list from scratch. + */ + gtk_list_store_clear (GTK_LIST_STORE (dialog->priv->passwords->model)); + + dialog->priv->passwords->fill (dialog->priv->passwords); +} + +static void pdm_dialog_fill_passwords_list (PdmActionInfo *info) { EphyPasswordManager *manager; GList *list, *l; - g_assert (info->filled == FALSE); - manager = EPHY_PASSWORD_MANAGER (ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell))); @@ -715,6 +718,13 @@ pdm_dialog_fill_passwords_list (PdmActionInfo *info) /* the element data has been consumed, so we need only to free the list */ g_list_free (list); + /* Let's get notified when the list changes */ + if (info->filled == FALSE) + { + g_signal_connect (manager, "passwords-changed", + G_CALLBACK (passwords_changed_cb), info->dialog); + } + info->filled = TRUE; } @@ -757,7 +767,18 @@ pdm_dialog_password_remove (PdmActionInfo *info, manager = EPHY_PASSWORD_MANAGER (ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell))); + /* we don't remove the password from the liststore in the callback + * like we do for cookies, since the callback doesn't carry that + * information, and we'd have to reload the whole list, losing the + * selection in the process. + */ + g_signal_handlers_block_by_func + (manager, G_CALLBACK (passwords_changed_cb), info); + ephy_password_manager_remove (manager, pinfo); + + g_signal_handlers_unblock_by_func + (manager, G_CALLBACK (passwords_changed_cb), info); } /* common routines */ @@ -847,6 +868,12 @@ static void pdm_dialog_finalize (GObject *object) { PdmDialog *dialog = EPHY_PDM_DIALOG (object); + GObject *single; + + single = ephy_embed_shell_get_embed_single (embed_shell); + + g_signal_handlers_disconnect_matched + (single, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object); dialog->priv->cookies->destruct (dialog->priv->cookies); dialog->priv->passwords->destruct (dialog->priv->passwords); |