aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--embed/ephy-cookie-manager.c4
-rw-r--r--embed/ephy-cookie-manager.h6
-rw-r--r--embed/ephy-password-manager.c2
-rw-r--r--embed/ephy-password-manager.h2
-rw-r--r--embed/ephy-permission-manager.c2
-rw-r--r--embed/ephy-permission-manager.h2
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp2
-rwxr-xr-xsrc/pdm-dialog.c148
9 files changed, 130 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 15d311da7..5a15c72fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2003-11-26 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/ephy-cookie-manager.c: (ephy_cookie_copy),
+ (ephy_cookie_manager_remove_cookie):
+ * embed/ephy-cookie-manager.h:
+ * embed/ephy-password-manager.c: (ephy_password_info_copy):
+ * embed/ephy-password-manager.h:
+ * embed/ephy-permission-manager.c: (ephy_permission_info_copy):
+ * embed/ephy-permission-manager.h:
+ * embed/mozilla/mozilla-embed-single.cpp:
+
+ Mark parameters "const" where appropriate.
+
+ * src/pdm-dialog.c: (pdm_cmd_delete_selection), (compare_cookies),
+ (cookie_to_iter), (cookie_added_cb), (cookie_changed_cb),
+ (cookie_deleted_cb), (cookies_cleared_cb),
+ (pdm_dialog_fill_cookies_list), (pdm_dialog_fill_passwords_list),
+ (pdm_dialog_init):
+
+ Make the cookies list auto-updating.
+
2003-11-26 Marco Pesenti Gritti <marco@gnome.org>
* data/ui/epiphany-ui.xml:
diff --git a/embed/ephy-cookie-manager.c b/embed/ephy-cookie-manager.c
index df079bddf..321384579 100644
--- a/embed/ephy-cookie-manager.c
+++ b/embed/ephy-cookie-manager.c
@@ -58,7 +58,7 @@ ephy_cookie_new (void)
* Return value: a copy of @cookie.
**/
EphyCookie *
-ephy_cookie_copy (EphyCookie *cookie)
+ephy_cookie_copy (const EphyCookie *cookie)
{
EphyCookie *copy = g_new0 (EphyCookie, 1);
@@ -242,7 +242,7 @@ ephy_cookie_manager_list_cookies (EphyCookieManager *manager)
**/
void
ephy_cookie_manager_remove_cookie (EphyCookieManager *manager,
- EphyCookie *cookie)
+ const EphyCookie *cookie)
{
EphyCookieManagerIFace *iface = EPHY_COOKIE_MANAGER_GET_CLASS (manager);
iface->remove (manager, cookie);
diff --git a/embed/ephy-cookie-manager.h b/embed/ephy-cookie-manager.h
index c82ace19e..c7ae0adc6 100644
--- a/embed/ephy-cookie-manager.h
+++ b/embed/ephy-cookie-manager.h
@@ -90,7 +90,7 @@ struct EphyCookieManagerIFace
/* Methods */
GList * (* list) (EphyCookieManager *manager);
void (* remove) (EphyCookieManager *manager,
- EphyCookie *cookie);
+ const EphyCookie *cookie);
void (* clear) (EphyCookieManager *manager);
};
@@ -100,7 +100,7 @@ GType ephy_cookie_get_type (void);
EphyCookie *ephy_cookie_new (void);
-EphyCookie *ephy_cookie_copy (EphyCookie *cookie);
+EphyCookie *ephy_cookie_copy (const EphyCookie *cookie);
void ephy_cookie_free (EphyCookie *cookie);
@@ -111,7 +111,7 @@ GType ephy_cookie_manager_get_type (void);
GList * ephy_cookie_manager_list_cookies (EphyCookieManager *manager);
void ephy_cookie_manager_remove_cookie (EphyCookieManager *manager,
- EphyCookie *cookie);
+ const EphyCookie *cookie);
void ephy_cookie_manager_clear (EphyCookieManager *manager);
diff --git a/embed/ephy-password-manager.c b/embed/ephy-password-manager.c
index d9b7e8dc2..14de93d79 100644
--- a/embed/ephy-password-manager.c
+++ b/embed/ephy-password-manager.c
@@ -75,7 +75,7 @@ ephy_password_info_new (const char *host,
* Return value: a copy of @info
**/
EphyPasswordInfo *
-ephy_password_info_copy (EphyPasswordInfo *info)
+ephy_password_info_copy (const EphyPasswordInfo *info)
{
EphyPasswordInfo *copy = g_new0 (EphyPasswordInfo, 1);
diff --git a/embed/ephy-password-manager.h b/embed/ephy-password-manager.h
index 34d33b0f9..d8ff42943 100644
--- a/embed/ephy-password-manager.h
+++ b/embed/ephy-password-manager.h
@@ -66,7 +66,7 @@ EphyPasswordInfo *ephy_password_info_new (const char *host,
const char *username,
const char *password);
-EphyPasswordInfo *ephy_password_info_copy (EphyPasswordInfo *info);
+EphyPasswordInfo *ephy_password_info_copy (const EphyPasswordInfo *info);
void ephy_password_info_free (EphyPasswordInfo *info);
diff --git a/embed/ephy-permission-manager.c b/embed/ephy-permission-manager.c
index c2518b94c..9ef7512a9 100644
--- a/embed/ephy-permission-manager.c
+++ b/embed/ephy-permission-manager.c
@@ -73,7 +73,7 @@ ephy_permission_info_new (const char *host,
* Return value: a copy of @info
**/
EphyPermissionInfo *
-ephy_permission_info_copy (EphyPermissionInfo *info)
+ephy_permission_info_copy (const EphyPermissionInfo *info)
{
EphyPermissionInfo *copy = g_new0 (EphyPermissionInfo, 1);
diff --git a/embed/ephy-permission-manager.h b/embed/ephy-permission-manager.h
index 1afa829ea..644797925 100644
--- a/embed/ephy-permission-manager.h
+++ b/embed/ephy-permission-manager.h
@@ -90,7 +90,7 @@ EphyPermissionInfo *ephy_permission_info_new (const char *host,
EphyPermissionType type,
gboolean allowed);
-EphyPermissionInfo *ephy_permission_info_copy (EphyPermissionInfo *info);
+EphyPermissionInfo *ephy_permission_info_copy (const EphyPermissionInfo *info);
void ephy_permission_info_free (EphyPermissionInfo *info);
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 55bac6535..63fce2f09 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -638,7 +638,7 @@ impl_list_cookies (EphyCookieManager *manager)
static void
impl_remove_cookie (EphyCookieManager *manager,
- EphyCookie *cookie)
+ const EphyCookie *cookie)
{
nsresult rv;
nsCOMPtr<nsICookieManager> cookieManager =
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index 9b638dd2b..137da4837 100755
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -38,6 +38,7 @@
#include <glib/gi18n.h>
#include <time.h>
+#include <string.h>
typedef struct PdmActionInfo PdmActionInfo;
@@ -59,6 +60,7 @@ struct PdmActionInfo
int remove_id;
int data_col;
gboolean filled;
+ gboolean delete_row_on_remove;
};
#define EPHY_PDM_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_PDM_DIALOG, PdmDialogPrivate))
@@ -271,7 +273,11 @@ pdm_cmd_delete_selection (PdmActionInfo *action)
action->remove (action, g_value_get_boxed (&val));
g_value_unset (&val);
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ /* for cookies we delete from callback, for passwords right here */
+ if (action->delete_row_on_remove)
+ {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ }
gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
gtk_tree_path_free (path);
@@ -425,35 +431,118 @@ pdm_dialog_cookies_construct (PdmActionInfo *info)
setup_action (info);
}
+static gboolean
+compare_cookies (const EphyCookie *cookie1,
+ const EphyCookie *cookie2)
+{
+ g_return_val_if_fail (cookie1 != NULL || cookie2 != NULL, FALSE);
+
+ return (strcmp (cookie1->domain, cookie2->domain) == 0
+ && strcmp (cookie2->path, cookie2->path) == 0
+ && strcmp (cookie2->name, cookie2->name) == 0);
+}
+
+static gboolean
+cookie_to_iter (GtkTreeModel *model,
+ const EphyCookie *cookie,
+ GtkTreeIter *iter)
+{
+ gboolean valid;
+ gboolean found = FALSE;
+
+ valid = gtk_tree_model_get_iter_first (model, iter);
+
+ while (valid)
+ {
+ EphyCookie *data;
+
+ gtk_tree_model_get (model, iter,
+ COL_COOKIES_DATA, &data,
+ -1);
+
+ found = compare_cookies (cookie, data);
+
+ ephy_cookie_free (data);
+
+ if (found) break;
+
+ valid = gtk_tree_model_iter_next (model, iter);
+ }
+
+ return found;
+}
+
static void
cookie_added_cb (EphyCookieManager *manager,
- gpointer data,
+ const EphyCookie *cookie,
PdmDialog *dialog)
{
+ PdmActionInfo *info = dialog->priv->cookies;
+
LOG ("cookie_added_cb")
+
+ info->add (info, (gpointer) ephy_cookie_copy (cookie));
}
static void
cookie_changed_cb (EphyCookieManager *manager,
- gpointer data,
+ const EphyCookie *cookie,
PdmDialog *dialog)
{
+ PdmActionInfo *info = dialog->priv->cookies;
+ GtkTreeIter iter;
+
LOG ("cookie_changed_cb")
+
+ if (cookie_to_iter (info->model, cookie, &iter))
+ {
+ gtk_list_store_remove (GTK_LIST_STORE (info->model), &iter);
+ info->add (info, (gpointer) ephy_cookie_copy (cookie));
+ }
+ else
+ {
+ g_warning ("Unable to find changed cookie in list!\n");
+ }
}
static void
cookie_deleted_cb (EphyCookieManager *manager,
- gpointer data,
+ const EphyCookie *cookie,
PdmDialog *dialog)
{
+ PdmActionInfo *info = dialog->priv->cookies;
+ GtkTreeIter iter;
+
LOG ("cookie_deleted_cb")
+
+ if (cookie_to_iter (info->model, cookie, &iter))
+ {
+ gtk_list_store_remove (GTK_LIST_STORE (info->model), &iter);
+ }
+ else
+ {
+ g_warning ("Unable to find deleted cookie in list!\n");
+ }
}
static void
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);
+ }
}
static void
@@ -480,13 +569,13 @@ pdm_dialog_fill_cookies_list (PdmActionInfo *info)
info->filled = TRUE;
/* Now connect the callbacks on the EphyCookieManager */
- g_signal_connect_object (manager, "added",
+ g_signal_connect_object (manager, "cookie-added",
G_CALLBACK (cookie_added_cb), info->dialog, 0);
- g_signal_connect_object (manager, "changed",
+ g_signal_connect_object (manager, "cookie-changed",
G_CALLBACK (cookie_changed_cb), info->dialog, 0);
- g_signal_connect_object (manager, "deleted",
+ g_signal_connect_object (manager, "cookie-deleted",
G_CALLBACK (cookie_deleted_cb), info->dialog, 0);
- g_signal_connect_object (manager, "cleared",
+ g_signal_connect_object (manager, "cookies-cleared",
G_CALLBACK (cookies_cleared_cb), info->dialog, 0);
}
@@ -596,37 +685,6 @@ pdm_dialog_passwords_construct (PdmActionInfo *info)
}
static void
-password_added_cb (EphyPasswordManager *manager,
- gpointer data,
- PdmDialog *dialog)
-{
- LOG ("password_added_cb")
-}
-
-static void
-password_changed_cb (EphyPasswordManager *manager,
- gpointer data,
- PdmDialog *dialog)
-{
- LOG ("password_changed_cb")
-}
-
-static void
-password_deleted_cb (EphyPasswordManager *manager,
- gpointer data,
- PdmDialog *dialog)
-{
- LOG ("password_deleted_cb")
-}
-
-static void
-passwords_cleared_cb (EphyPasswordManager *manager,
- PdmDialog *dialog)
-{
- LOG ("password_cleared_cb")
-}
-
-static void
pdm_dialog_fill_passwords_list (PdmActionInfo *info)
{
EphyPasswordManager *manager;
@@ -648,16 +706,6 @@ pdm_dialog_fill_passwords_list (PdmActionInfo *info)
g_list_free (list);
info->filled = TRUE;
-
- /* now connect the callbacks on the EphyPasswordManager */
- g_signal_connect_object (manager, "added",
- G_CALLBACK (password_added_cb), info->dialog, 0);
- g_signal_connect_object (manager, "changed",
- G_CALLBACK (password_changed_cb), info->dialog, 0);
- g_signal_connect_object (manager, "deleted",
- G_CALLBACK (password_deleted_cb), info->dialog, 0);
- g_signal_connect_object (manager, "cleared",
- G_CALLBACK (passwords_cleared_cb), info->dialog, 0);
}
static void
@@ -762,6 +810,7 @@ pdm_dialog_init (PdmDialog *dialog)
cookies->remove_id = PROP_COOKIES_REMOVE;
cookies->data_col = COL_COOKIES_DATA;
cookies->filled = FALSE;
+ cookies->delete_row_on_remove = FALSE;
passwords = g_new0 (PdmActionInfo, 1);
passwords->construct = pdm_dialog_passwords_construct;
@@ -773,6 +822,7 @@ pdm_dialog_init (PdmDialog *dialog)
passwords->remove_id = PROP_PASSWORDS_REMOVE;
passwords->data_col = COL_PASSWORDS_DATA;
passwords->filled = FALSE;
+ passwords->delete_row_on_remove = TRUE;
dialog->priv->cookies = cookies;
dialog->priv->passwords = passwords;