aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-01-11 00:35:56 +0800
committerChristian Persch <chpe@src.gnome.org>2004-01-11 00:35:56 +0800
commite3396ef5e3ae7fd5674eda19a893e7dca88bce35 (patch)
tree6315e5bc2549ec9db6109607fbb29596363d969e
parent80bc591b9024029ee12957944593053db6763c41 (diff)
downloadgsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.tar
gsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.tar.gz
gsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.tar.bz2
gsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.tar.lz
gsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.tar.xz
gsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.tar.zst
gsoc2013-epiphany-e3396ef5e3ae7fd5674eda19a893e7dca88bce35.zip
Implement history disabling.
2004-01-10 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-history.c: (ephy_history_get_type), (ephy_history_set_enabled), (ephy_history_set_property), (ephy_history_get_property), (ephy_history_class_init), (page_removed_from_host_cb), (disable_history_notifier), (ephy_history_init), (ephy_history_finalize), (ephy_history_new), (ephy_history_get_host), (ephy_history_visited), (ephy_history_add_page), (ephy_history_set_page_title), (ephy_history_clear), (ephy_history_is_enabled): * embed/ephy-history.h: * lib/ephy-node-db.c: (ephy_node_db_get_property), (ephy_node_db_set_property), (ephy_node_db_set_immutable): * lib/ephy-node-db.h: * lib/ephy-prefs.h: * src/bookmarks/ephy-bookmarks.c: (clear_favorites), (history_cleared_cb), (ephy_setup_history_notifiers): Implement history disabling.
-rw-r--r--ChangeLog20
-rw-r--r--embed/ephy-history.c165
-rw-r--r--embed/ephy-history.h7
-rw-r--r--lib/ephy-node-db.c15
-rw-r--r--lib/ephy-node-db.h3
-rw-r--r--lib/ephy-prefs.h37
-rw-r--r--src/bookmarks/ephy-bookmarks.c42
7 files changed, 237 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 667b03bf1..7801fe7d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2004-01-10 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/ephy-history.c: (ephy_history_get_type),
+ (ephy_history_set_enabled), (ephy_history_set_property),
+ (ephy_history_get_property), (ephy_history_class_init),
+ (page_removed_from_host_cb), (disable_history_notifier),
+ (ephy_history_init), (ephy_history_finalize), (ephy_history_new),
+ (ephy_history_get_host), (ephy_history_visited),
+ (ephy_history_add_page), (ephy_history_set_page_title),
+ (ephy_history_clear), (ephy_history_is_enabled):
+ * embed/ephy-history.h:
+ * lib/ephy-node-db.c: (ephy_node_db_get_property),
+ (ephy_node_db_set_property), (ephy_node_db_set_immutable):
+ * lib/ephy-node-db.h:
+ * lib/ephy-prefs.h:
+ * src/bookmarks/ephy-bookmarks.c: (clear_favorites),
+ (history_cleared_cb), (ephy_setup_history_notifiers):
+
+ Implement history disabling.
+
2004-01-09 Christopher James Lahey <clahey@ximian.com>
* data/epiphany-lockdown.schemas.in, lib/ephy-prefs.h: Added
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 8aae3eaf0..aa931c03f 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -27,6 +27,8 @@
#include "ephy-debug.h"
#include "ephy-node-db.h"
#include "ephy-node-common.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-prefs.h"
#include <time.h>
#include <string.h>
@@ -56,34 +58,37 @@ struct EphyHistoryPrivate
int autosave_timeout;
guint update_hosts_idle;
gboolean dirty;
+ gboolean enabled;
+ guint disable_history_notifier_id;
+};
+
+enum
+{
+ PROP_0,
+ PROP_ENABLED
};
enum
{
- ADD,
- UPDATE,
- REMOVE,
VISITED,
+ CLEARED,
LAST_SIGNAL
};
-static void
-ephy_history_class_init (EphyHistoryClass *klass);
-static void
-ephy_history_init (EphyHistory *tab);
-static void
-ephy_history_finalize (GObject *object);
+static guint signals[LAST_SIGNAL] = { 0 };
-static GObjectClass *parent_class = NULL;
+static void ephy_history_class_init (EphyHistoryClass *klass);
+static void ephy_history_init (EphyHistory *history);
+static void ephy_history_finalize (GObject *object);
-static guint ephy_history_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
GType
ephy_history_get_type (void)
{
- static GType ephy_history_type = 0;
+ static GType type = 0;
- if (ephy_history_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
@@ -98,12 +103,58 @@ ephy_history_get_type (void)
(GInstanceInitFunc) ephy_history_init
};
- ephy_history_type = g_type_register_static (G_TYPE_OBJECT,
- "EphyHistory",
- &our_info, 0);
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyHistory",
+ &our_info, 0);
}
- return ephy_history_type;
+ return type;
+}
+
+static void
+ephy_history_set_enabled (EphyHistory *history,
+ gboolean enabled)
+{
+ LOG ("ephy_history_set_enabled %d", enabled)
+
+ ephy_node_db_set_immutable (history->priv->db, !enabled);
+
+ if (enabled == FALSE)
+ {
+ ephy_history_clear (history);
+ }
+}
+
+static void
+ephy_history_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyHistory *history = EPHY_HISTORY (history);
+
+ switch (prop_id)
+ {
+ case PROP_ENABLED:
+ ephy_history_set_enabled (history, g_value_get_boolean (value));
+ break;
+ }
+}
+
+static void
+ephy_history_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyHistory *history = EPHY_HISTORY (history);
+
+ switch (prop_id)
+ {
+ case PROP_ENABLED:
+ g_value_set_boolean (value, history->priv->enabled);
+ break;
+ }
}
static void
@@ -114,8 +165,18 @@ ephy_history_class_init (EphyHistoryClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = ephy_history_finalize;
-
- ephy_history_signals[VISITED] =
+ object_class->get_property = ephy_history_get_property;
+ object_class->set_property = ephy_history_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_ENABLED,
+ g_param_spec_boolean ("enabled",
+ "Enabled",
+ "Enabled",
+ TRUE,
+ G_PARAM_READWRITE));
+
+ signals[VISITED] =
g_signal_new ("visited",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
@@ -126,6 +187,16 @@ ephy_history_class_init (EphyHistoryClass *klass)
1,
G_TYPE_STRING);
+ signals[CLEARED] =
+ g_signal_new ("cleared",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyHistoryClass, cleared),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_type_class_add_private (object_class, sizeof(EphyHistoryPrivate));
}
@@ -353,7 +424,7 @@ page_removed_from_host_cb (EphyNode *node,
guint old_index,
EphyHistory *eb)
{
- if (!eb->priv->update_hosts_idle)
+ if (eb->priv->update_hosts_idle == 0)
{
eb->priv->update_hosts_idle = g_idle_add
((GSourceFunc)update_hosts, eb);
@@ -374,6 +445,16 @@ connect_page_removed_from_host (char *url,
}
static void
+disable_history_notifier (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ EphyHistory *history)
+{
+ ephy_history_set_enabled
+ (history, !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_HISTORY));
+}
+
+static void
ephy_history_init (EphyHistory *eb)
{
GValue value = { 0, };
@@ -459,6 +540,11 @@ ephy_history_init (EphyHistory *eb)
g_timeout_add (HISTORY_SAVE_INTERVAL,
(GSourceFunc)periodic_save_cb,
eb);
+
+ disable_history_notifier (NULL, 0, NULL, eb);
+ eb->priv->disable_history_notifier_id = eel_gconf_notification_add
+ (CONF_LOCKDOWN_DISABLE_HISTORY,
+ (GConfClientNotifyFunc) disable_history_notifier, eb);
}
static void
@@ -483,6 +569,8 @@ ephy_history_finalize (GObject *object)
g_source_remove (eb->priv->autosave_timeout);
+ eel_gconf_notification_remove (eb->priv->disable_history_notifier_id);
+
LOG ("Global history finalized");
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -491,11 +579,7 @@ ephy_history_finalize (GObject *object)
EphyHistory *
ephy_history_new ()
{
- EphyHistory *eh;
-
- eh = EPHY_HISTORY (g_object_new (EPHY_TYPE_HISTORY, NULL));
-
- return eh;
+ return EPHY_HISTORY (g_object_new (EPHY_TYPE_HISTORY, NULL));
}
static void
@@ -550,6 +634,11 @@ ephy_history_get_host (EphyHistory *eh, const char *url)
g_return_val_if_fail (url != NULL, NULL);
+ if (eh->priv->enabled == FALSE)
+ {
+ return NULL;
+ }
+
now = time (NULL);
vfs_uri = gnome_vfs_uri_new (url);
@@ -696,7 +785,7 @@ ephy_history_visited (EphyHistory *eh, EphyNode *node)
eh->priv->last_page = node;
- g_signal_emit (G_OBJECT (eh), ephy_history_signals[VISITED], 0, url);
+ g_signal_emit (G_OBJECT (eh), signals[VISITED], 0, url);
}
int
@@ -724,6 +813,11 @@ ephy_history_add_page (EphyHistory *eb,
EphyNode *bm, *node, *host;
GValue value = { 0, };
+ if (eb->priv->enabled == FALSE)
+ {
+ return;
+ }
+
node = ephy_history_get_page (eb, url);
if (node)
{
@@ -786,7 +880,7 @@ ephy_history_set_page_title (EphyHistory *gh,
if (title == NULL || title[0] == '\0') return;
node = ephy_history_get_page (gh, url);
- if (!node) return;
+ if (node == NULL) return;
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, title);
@@ -842,12 +936,19 @@ ephy_history_clear (EphyHistory *gh)
{
EphyNode *node;
+ LOG ("clearing history")
+
+ ephy_node_db_set_immutable (gh->priv->db, FALSE);
+
while ((node = ephy_node_get_nth_child (gh->priv->pages, 0)) != NULL)
{
ephy_node_unref (node);
}
-
ephy_history_save (gh);
+
+ ephy_node_db_set_immutable (gh->priv->db, !gh->priv->enabled);
+
+ g_signal_emit (gh, signals[CLEARED], 0);
}
EphyNode *
@@ -870,3 +971,11 @@ ephy_history_get_last_page (EphyHistory *gh)
return ephy_node_get_property_string
(gh->priv->last_page, EPHY_NODE_PAGE_PROP_LOCATION);
}
+
+gboolean
+ephy_history_is_enabled (EphyHistory *history)
+{
+ g_return_val_if_fail (EPHY_IS_HISTORY (history), FALSE);
+
+ return history->priv->enabled;
+}
diff --git a/embed/ephy-history.h b/embed/ephy-history.h
index e3184156f..5a3ac1de3 100644
--- a/embed/ephy-history.h
+++ b/embed/ephy-history.h
@@ -63,7 +63,10 @@ struct EphyHistoryClass
{
GObjectClass parent_class;
- void (* visited) (const char *url);
+ /* Signals */
+ void (* visited) (EphyHistory *history,
+ const char *url);
+ void (* cleared) (EphyHistory *history);
};
GType ephy_history_get_type (void);
@@ -103,6 +106,8 @@ const char *ephy_history_get_icon (EphyHistory *gh,
void ephy_history_clear (EphyHistory *gh);
+gboolean ephy_history_is_enabled (EphyHistory *history);
+
G_END_DECLS
#endif
diff --git a/lib/ephy-node-db.c b/lib/ephy-node-db.c
index 43b6db39f..920bdf1fb 100644
--- a/lib/ephy-node-db.c
+++ b/lib/ephy-node-db.c
@@ -99,7 +99,6 @@ ephy_node_db_set_name (EphyNodeDb *db, const char *name)
g_hash_table_insert (ephy_node_databases, db->priv->name, db);
}
-
static void
ephy_node_db_get_property (GObject *object,
guint prop_id,
@@ -116,12 +115,11 @@ ephy_node_db_get_property (GObject *object,
g_value_set_string (value, db->priv->name);
break;
case PROP_IMMUTABLE:
- g_value_set_boolean (value, db->priv->immutable);
+ g_value_set_boolean (value, ephy_node_db_is_immutable (db));
break;
}
}
-
static void
ephy_node_db_set_property (GObject *object,
guint prop_id,
@@ -138,8 +136,7 @@ ephy_node_db_set_property (GObject *object,
ephy_node_db_set_name (db, g_value_get_string (value));
break;
case PROP_IMMUTABLE:
- db->priv->immutable = g_value_get_boolean (value);
- g_object_notify (G_OBJECT (db), "immutable");
+ ephy_node_db_set_immutable (db, g_value_get_boolean (value));
break;
}
}
@@ -253,6 +250,14 @@ ephy_node_db_is_immutable (EphyNodeDb *db)
return db->priv->immutable;
}
+void
+ephy_node_db_set_immutable (EphyNodeDb *db, gboolean immutable)
+{
+ db->priv->immutable = immutable;
+
+ g_object_notify (G_OBJECT (db), "immutable");
+}
+
EphyNode *
ephy_node_db_get_node_from_id (EphyNodeDb *db, long id)
{
diff --git a/lib/ephy-node-db.h b/lib/ephy-node-db.h
index 21206f2ff..f6138a427 100644
--- a/lib/ephy-node-db.h
+++ b/lib/ephy-node-db.h
@@ -75,6 +75,9 @@ const char *ephy_node_db_get_name (EphyNodeDb *db);
gboolean ephy_node_db_is_immutable (EphyNodeDb *db);
+void ephy_node_db_set_immutable (EphyNodeDb *db,
+ gboolean immutable);
+
EphyNode *ephy_node_db_get_node_from_id (EphyNodeDb *db,
long id);
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index ba49df410..d1cc998f7 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -27,32 +27,33 @@ G_BEGIN_DECLS
#define CONF_SCHEMA_VERSION "/apps/epiphany/schema_version"
/* General */
-#define CONF_GENERAL_HOMEPAGE "/apps/epiphany/general/homepage"
-#define CONF_ALWAYS_SHOW_TABS_BAR "/apps/epiphany/general/always_show_tabs_bar"
-#define CONF_WINDOWS_SHOW_TOOLBARS "/apps/epiphany/general/show_toolbars"
-#define CONF_WINDOWS_SHOW_BOOKMARKS_BAR "/apps/epiphany/general/show_bookmarks_bar"
-#define CONF_WINDOWS_SHOW_STATUSBAR "/apps/epiphany/general/show_statusbar"
-#define CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL "/apps/epiphany/general/middle_click_open_url"
-#define CONF_AUTO_OPEN_DOWNLOADS "/apps/epiphany/general/auto_open_downloads"
-#define CONF_DESKTOP_IS_HOME_DIR "/apps/nautilus/preferences/desktop_is_home_dir"
+#define CONF_GENERAL_HOMEPAGE "/apps/epiphany/general/homepage"
+#define CONF_ALWAYS_SHOW_TABS_BAR "/apps/epiphany/general/always_show_tabs_bar"
+#define CONF_WINDOWS_SHOW_TOOLBARS "/apps/epiphany/general/show_toolbars"
+#define CONF_WINDOWS_SHOW_BOOKMARKS_BAR "/apps/epiphany/general/show_bookmarks_bar"
+#define CONF_WINDOWS_SHOW_STATUSBAR "/apps/epiphany/general/show_statusbar"
+#define CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL "/apps/epiphany/general/middle_click_open_url"
+#define CONF_AUTO_OPEN_DOWNLOADS "/apps/epiphany/general/auto_open_downloads"
+#define CONF_DESKTOP_IS_HOME_DIR "/apps/nautilus/preferences/desktop_is_home_dir"
/* Directories */
-#define CONF_STATE_SAVE_DIR "/apps/epiphany/directories/save"
-#define CONF_STATE_SAVE_IMAGE_DIR "/apps/epiphany/directories/saveimage"
-#define CONF_STATE_OPEN_DIR "/apps/epiphany/directories/open"
-#define CONF_STATE_DOWNLOAD_DIR "/apps/epiphany/directories/download"
-#define CONF_STATE_UPLOAD_DIR "/apps/epiphany/directories/upload"
+#define CONF_STATE_SAVE_DIR "/apps/epiphany/directories/save"
+#define CONF_STATE_SAVE_IMAGE_DIR "/apps/epiphany/directories/saveimage"
+#define CONF_STATE_OPEN_DIR "/apps/epiphany/directories/open"
+#define CONF_STATE_DOWNLOAD_DIR "/apps/epiphany/directories/download"
+#define CONF_STATE_UPLOAD_DIR "/apps/epiphany/directories/upload"
/* Lockdown */
-#define CONF_LOCKDOWN_DISABLE_ARBITRARY_URL "/apps/epiphany/lockdown/disable_arbitrary_url"
+#define CONF_LOCKDOWN_DISABLE_ARBITRARY_URL "/apps/epiphany/lockdown/disable_arbitrary_url"
#define CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING "/apps/epiphany/lockdown/disable_bookmark_editing"
-#define CONF_LOCKDOWN_DISABLE_TOOLBAR_EDITING "/apps/epiphany/lockdown/disable_toolbar_editing"
-#define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history"
+#define CONF_LOCKDOWN_DISABLE_TOOLBAR_EDITING "/apps/epiphany/lockdown/disable_toolbar_editing"
+#define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history"
#define CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK "/desktop/gnome/lockdown/disable_save_to_disk"
+#define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history"
/* System prefs */
-#define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command"
-#define CONF_DESKTOP_TOOLBAR_STYLE "/desktop/gnome/interface/toolbar_style"
+#define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command"
+#define CONF_DESKTOP_TOOLBAR_STYLE "/desktop/gnome/interface/toolbar_style"
G_END_DECLS
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 1a8a703d5..b0b1190fa 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -391,14 +391,56 @@ history_site_visited_cb (EphyHistory *gh, const char *url, EphyBookmarks *eb)
}
static void
+clear_favorites (EphyBookmarks *bookmarks)
+{
+ EphyNode *node;
+ GPtrArray *children;
+ int i;
+ gboolean was_immutable;
+
+ /* clear the favourites */
+
+ was_immutable = ephy_node_db_is_immutable (bookmarks->priv->db);
+ ephy_node_db_set_immutable (bookmarks->priv->db, FALSE);
+
+ node = bookmarks->priv->favorites;
+ children = ephy_node_get_children (node);
+ for (i = children->len - 1; i >= 0; i--)
+ {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+
+ ephy_node_remove_child (node, kid);
+ }
+
+ ephy_node_db_set_immutable (bookmarks->priv->db, was_immutable);
+
+ ephy_bookmarks_update_favorites (bookmarks);
+}
+
+static void
+history_cleared_cb (EphyHistory *history, EphyBookmarks *bookmarks)
+{
+ clear_favorites (bookmarks);
+}
+
+static void
ephy_setup_history_notifiers (EphyBookmarks *eb)
{
EphyHistory *history;
history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
+ if (ephy_history_is_enabled (history) == FALSE)
+ {
+ clear_favorites (eb);
+ }
+
g_signal_connect (history, "visited",
G_CALLBACK (history_site_visited_cb), eb);
+ g_signal_connect (history, "cleared",
+ G_CALLBACK (history_cleared_cb), eb);
}
static void