aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c32
-rw-r--r--src/bookmarks/ephy-bookmarks.c33
-rw-r--r--src/ephy-automation.c3
-rw-r--r--src/ephy-session.c7
-rwxr-xr-xsrc/ephy-toolbars-model.c16
-rw-r--r--src/ephy-window.c18
6 files changed, 96 insertions, 13 deletions
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 <string.h>
#include <glib/gi18n.h>
@@ -61,6 +64,8 @@ struct EphyBookmarksPrivate
EphyNode *smartbookmarks;
EphyNode *lower_fav;
double lower_score;
+
+ guint disable_bookmark_editing_notifier_id;
};
typedef struct
@@ -497,6 +502,23 @@ topics_removed_cb (EphyNode *node,
}
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)
{
GValue value = { 0, };
@@ -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,
diff --git a/src/ephy-automation.c b/src/ephy-automation.c
index 33f5dc822..586587adf 100644
--- a/src/ephy-automation.c
+++ b/src/ephy-automation.c
@@ -27,6 +27,8 @@
#include "ephy-session.h"
#include "ephy-bookmarks.h"
#include "ephy-bookmarks-import.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-prefs.h"
#include <string.h>
#include <bonobo/bonobo-main.h>
@@ -128,6 +130,7 @@ impl_ephy_automation_open_bookmarks_editor (PortableServer_Servant _servant,
{
GtkWidget *editor;
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return;
editor = ephy_shell_get_bookmarks_editor (ephy_shell);
gtk_window_present (GTK_WINDOW (editor));
diff --git a/src/ephy-session.c b/src/ephy-session.c
index b1225a45a..527c84f46 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -33,6 +33,8 @@
#include "ephy-bookmarks-editor.h"
#include "ephy-string.h"
#include "ephy-file-helpers.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-prefs.h"
#include "ephy-debug.h"
#include <glib/gi18n.h>
@@ -646,7 +648,10 @@ ephy_session_load (EphySession *session,
if (id && xmlStrEqual (BOOKMARKS_EDITOR_ID, id))
{
- widget = ephy_shell_get_bookmarks_editor (ephy_shell);
+ if (!eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING))
+ {
+ widget = ephy_shell_get_bookmarks_editor (ephy_shell);
+ }
}
else if (id && xmlStrEqual (HISTORY_WINDOW_ID, id))
{
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index 8e0c578b4..132172f91 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -202,20 +202,22 @@ impl_get_item_id (EggToolbarsModel *t,
}
node = ephy_bookmarks_add (bookmarks, title, netscape_url[URL]);
- g_return_val_if_fail (node != NULL, NULL);
- gh = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
- icon = ephy_history_get_icon (gh, netscape_url[URL]);
-
- if (icon)
+ if (node != NULL)
{
- ephy_bookmarks_set_icon (bookmarks, netscape_url[URL], icon);
+ gh = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
+ icon = ephy_history_get_icon (gh, netscape_url[URL]);
+
+ if (icon)
+ {
+ ephy_bookmarks_set_icon (bookmarks, netscape_url[URL], icon);
+ }
}
}
g_strfreev (netscape_url);
- g_return_val_if_fail (node != NULL, NULL);
+ if (node == NULL) return NULL;
return ephy_toolbars_model_get_action_name
(model, ephy_node_get_id (node));
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 48513c880..f66d4119d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -333,6 +333,7 @@ struct EphyWindowPrivate
guint show_statusbar_notifier_id;
guint hide_menubar_notifier_id;
guint disable_save_to_disk_notifier_id;
+ guint disable_bookmark_editing_notifier_id;
guint browse_with_caret_notifier_id;
};
@@ -1695,7 +1696,7 @@ update_actions (EphyWindow *window)
GtkActionGroup *action_group = GTK_ACTION_GROUP (window->priv->action_group);
GtkActionGroup *popups_action_group = GTK_ACTION_GROUP (window->priv->popups_action_group);
GtkAction *action;
- gboolean save_to_disk;
+ gboolean bookmarks_editable, save_to_disk;
action = gtk_action_group_get_action (action_group, "ViewToolbar");
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
@@ -1712,6 +1713,16 @@ update_actions (EphyWindow *window)
eel_gconf_get_boolean (CONF_WINDOWS_SHOW_STATUSBAR));
g_object_set (action, "sensitive", eel_gconf_key_is_writable (CONF_WINDOWS_SHOW_STATUSBAR), NULL);
+ bookmarks_editable = !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING);
+ action = gtk_action_group_get_action (action_group, "GoBookmarks");
+ g_object_set (action, "sensitive", bookmarks_editable, NULL);
+ action = gtk_action_group_get_action (action_group, "FileBookmarkPage");
+ g_object_set (action, "sensitive", bookmarks_editable, NULL);
+ action = gtk_action_group_get_action (popups_action_group, "ContextBookmarkPage");
+ g_object_set (action, "sensitive", bookmarks_editable, NULL);
+ action = gtk_action_group_get_action (popups_action_group, "BookmarkLink");
+ g_object_set (action, "sensitive", bookmarks_editable, NULL);
+
save_to_disk = !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK);
action = gtk_action_group_get_action (action_group, "FileSaveAs");
g_object_set (action, "sensitive", save_to_disk, NULL);
@@ -1851,6 +1862,10 @@ ephy_window_init (EphyWindow *window)
(CONF_LOCKDOWN_HIDE_MENUBAR,
(GConfClientNotifyFunc)chrome_notifier, window);
+ window->priv->disable_bookmark_editing_notifier_id = eel_gconf_notification_add
+ (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING,
+ (GConfClientNotifyFunc)actions_notifier, window);
+
window->priv->disable_save_to_disk_notifier_id = eel_gconf_notification_add
(CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK,
(GConfClientNotifyFunc)actions_notifier, window);
@@ -1877,6 +1892,7 @@ ephy_window_finalize (GObject *object)
eel_gconf_notification_remove (window->priv->show_bookmarks_bar_notifier_id);
eel_gconf_notification_remove (window->priv->show_statusbar_notifier_id);
eel_gconf_notification_remove (window->priv->hide_menubar_notifier_id);
+ eel_gconf_notification_remove (window->priv->disable_bookmark_editing_notifier_id);
eel_gconf_notification_remove (window->priv->disable_save_to_disk_notifier_id);
eel_gconf_notification_remove (window->priv->browse_with_caret_notifier_id);