From 1743162eef31aab9bb28a2c8201240e7dc4bd1cd Mon Sep 17 00:00:00 2001 From: Chris Lahey Date: Fri, 9 Jan 2004 20:49:11 +0000 Subject: Added disable_bookmark_editing key. * data/epiphany-lockdown.schemas.in, lib/ephy-prefs.h: Added disable_bookmark_editing key. * lib/ephy-node-db.c, ephy-node-db.h, ephy-node.c: Added immutable property. * lib/egg/egg-editable-toolbar.c (drag_data_received_cb, toolbar_drag_motion_cb), src/ephy-toolbars-model.c (impl_get_item_id): Made these handle immutable models/node_dbs. * src/ephy-automation.c, src/ephy-session.c: Don't show the bookmark editor if disabled. * src/ephy-window.c: Disable a bunch of menus if bookmark editing is disabled. * src/bookmarks/ephy-bookmarks-import.c, src/bookmarks/ephy-bookmarks.c: Disable bookmark editing and importing is key is set. Uses immutable property. --- src/bookmarks/ephy-bookmarks-import.c | 32 ++++++++++++++++++++++++++++---- src/bookmarks/ephy-bookmarks.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) (limited to 'src/bookmarks') diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c index 53849cc1c..d38c1f5d0 100644 --- a/src/bookmarks/ephy-bookmarks-import.c +++ b/src/bookmarks/ephy-bookmarks-import.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2003 Marco Pesenti Gritti * @@ -32,6 +33,9 @@ #include "ephy-bookmarks-import.h" #include "ephy-debug.h" +#include "ephy-prefs.h" + +#include "eel-gconf-extensions.h" /** * NSItemType: netscape bookmark item type @@ -59,6 +63,8 @@ bookmark_add (EphyBookmarks *bookmarks, bmk = ephy_bookmarks_add (bookmarks, title, address); + if (bmk == NULL) return NULL; + if (topic_name) { topic = ephy_bookmarks_find_keyword (bookmarks, topic_name, FALSE); @@ -67,7 +73,10 @@ bookmark_add (EphyBookmarks *bookmarks, topic = ephy_bookmarks_add_keyword (bookmarks, topic_name); } - ephy_bookmarks_set_keyword (bookmarks, topic, bmk); + if (topic != NULL) + { + ephy_bookmarks_set_keyword (bookmarks, topic, bmk); + } } return bmk; @@ -79,6 +88,8 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks, { char *type; + if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE; + type = gnome_vfs_get_mime_type (filename); LOG ("Importing bookmarks of type %s", type) @@ -371,7 +382,7 @@ xbel_parse_folder (EphyBookmarks *eb, xmlTextReaderPtr reader) xmlFree (title); - g_return_val_if_fail (EPHY_IS_NODE (keyword), list); + if (keyword == NULL) return list; for (l = list; l != NULL; l = l->next) { @@ -565,11 +576,17 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks, const char *filename) { FILE *bf; /* bookmark file */ - GString *name = g_string_new (NULL); + GString *name; gchar *parsedname; GString *url = g_string_new (NULL); GList *folders = NULL, *l; + if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE; + + name = g_string_new (NULL); + url = g_string_new (NULL); + + if (!(bf = fopen (filename, "r"))) { g_warning ("Failed to open file: %s\n", filename); return FALSE; @@ -638,6 +655,8 @@ ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks, xmlTextReaderPtr reader; GList *list; + if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE; + if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE) { return FALSE; @@ -758,7 +777,10 @@ parse_rdf_item (EphyBookmarks *bookmarks, topic = ephy_bookmarks_add_keyword (bookmarks, topic_name); } - ephy_bookmarks_set_keyword (bookmarks, topic, bmk); + if (topic != NULL) + { + ephy_bookmarks_set_keyword (bookmarks, topic, bmk); + } } xmlFree (title); @@ -776,6 +798,8 @@ ephy_bookmarks_import_rdf (EphyBookmarks *bookmarks, xmlNodePtr child; xmlNodePtr root; + if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE; + if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE) return FALSE; diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 2c4fdd413..1a8a703d5 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -33,6 +33,9 @@ #include "ephy-toolbars-model.h" #include "ephy-bookmarks-export.h" #include "ephy-bookmarks-import.h" +#include "ephy-prefs.h" + +#include "eel-gconf-extensions.h" #include #include @@ -61,6 +64,8 @@ struct EphyBookmarksPrivate EphyNode *smartbookmarks; EphyNode *lower_fav; double lower_score; + + guint disable_bookmark_editing_notifier_id; }; typedef struct @@ -496,6 +501,23 @@ topics_removed_cb (EphyNode *node, g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0); } +static void +update_bookmark_editing (EphyBookmarks *eb) +{ + g_object_set (G_OBJECT (eb->priv->db), + "immutable", eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING), + NULL); +} + +static void +disable_bookmark_editing_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EphyBookmarks *eb) +{ + update_bookmark_editing (eb); +} + static void ephy_bookmarks_init (EphyBookmarks *eb) { @@ -599,6 +621,11 @@ ephy_bookmarks_init (EphyBookmarks *eb) } } + eb->priv->disable_bookmark_editing_notifier_id = eel_gconf_notification_add + (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING, + (GConfClientNotifyFunc)disable_bookmark_editing_notifier, eb); + update_bookmark_editing (eb); + ephy_setup_history_notifiers (eb); ephy_bookmarks_update_favorites (eb); } @@ -608,6 +635,8 @@ ephy_bookmarks_finalize (GObject *object) { EphyBookmarks *eb = EPHY_BOOKMARKS (object); + eel_gconf_notification_remove (eb->priv->disable_bookmark_editing_notifier_id); + if (eb->priv->save_timeout_id != 0) { g_source_remove (eb->priv->save_timeout_id); @@ -685,6 +714,8 @@ ephy_bookmarks_add (EphyBookmarks *eb, bm = ephy_node_new (eb->priv->db); + if (bm == NULL) return NULL; + g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, title); ephy_node_set_property (bm, EPHY_NODE_BMK_PROP_TITLE, @@ -938,6 +969,8 @@ ephy_bookmarks_add_keyword (EphyBookmarks *eb, key = ephy_node_new (eb->priv->db); + if (key == NULL) return NULL; + g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, name); ephy_node_set_property (key, EPHY_NODE_KEYWORD_PROP_NAME, -- cgit v1.2.3