aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/egg/egg-editable-toolbar.c20
-rw-r--r--lib/ephy-node-db.c32
-rw-r--r--lib/ephy-node-db.h2
-rw-r--r--lib/ephy-node.c26
-rw-r--r--lib/ephy-prefs.h1
5 files changed, 67 insertions, 14 deletions
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 746affc42..7d1fe1f8a 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -419,8 +419,7 @@ drag_data_received_cb (GtkWidget *widget,
target = gtk_drag_dest_find_target (widget, context, NULL);
type = egg_toolbars_model_get_item_type (etoolbar->priv->model, target);
- id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type,
- selection_data->data);
+ id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type, selection_data->data);
/* This function can be called for two reasons
*
@@ -433,6 +432,13 @@ drag_data_received_cb (GtkWidget *widget,
* actually add a new item to the toolbar.
*/
+ if (id == NULL)
+ {
+ etoolbar->priv->pending = FALSE;
+ g_free (type);
+ return;
+ }
+
if (etoolbar->priv->pending)
{
etoolbar->priv->pending = FALSE;
@@ -453,11 +459,6 @@ drag_data_received_cb (GtkWidget *widget,
}
else
{
- type = egg_toolbars_model_get_item_type (etoolbar->priv->model,
- target);
- id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type,
- selection_data->data);
-
egg_toolbars_model_add_item (etoolbar->priv->model,
toolbar_pos, pos, id, type);
}
@@ -591,9 +592,12 @@ toolbar_drag_motion_cb (GtkWidget *widget,
/* The handler will make sure the item is created */
gtk_drag_get_data (widget, context, target, time);
- g_assert (etoolbar->priv->dragged_item);
g_assert (!etoolbar->priv->pending);
+ if (etoolbar->priv->dragged_item == NULL) {
+ return TRUE;
+ }
+
g_object_ref (etoolbar->priv->dragged_item);
gtk_object_sink (GTK_OBJECT (etoolbar->priv->dragged_item));
}
diff --git a/lib/ephy-node-db.c b/lib/ephy-node-db.c
index 8c569485a..43b6db39f 100644
--- a/lib/ephy-node-db.c
+++ b/lib/ephy-node-db.c
@@ -40,7 +40,8 @@ static void ephy_node_db_finalize (GObject *object);
enum
{
PROP_0,
- PROP_NAME
+ PROP_NAME,
+ PROP_IMMUTABLE,
};
#define EPHY_NODE_DB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_NODE_DB, EphyNodeDbPrivate))
@@ -48,6 +49,7 @@ enum
struct EphyNodeDbPrivate
{
char *name;
+ gboolean immutable;
long id_factory;
@@ -97,6 +99,7 @@ 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,
@@ -112,6 +115,9 @@ ephy_node_db_get_property (GObject *object,
case PROP_NAME:
g_value_set_string (value, db->priv->name);
break;
+ case PROP_IMMUTABLE:
+ g_value_set_boolean (value, db->priv->immutable);
+ break;
}
}
@@ -131,6 +137,10 @@ ephy_node_db_set_property (GObject *object,
case PROP_NAME:
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");
+ break;
}
}
@@ -153,6 +163,14 @@ ephy_node_db_class_init (EphyNodeDbClass *klass)
NULL,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_IMMUTABLE,
+ g_param_spec_boolean ("immutable",
+ "Immutable",
+ "Immutable",
+ FALSE,
+ G_PARAM_READWRITE));
+
g_type_class_add_private (object_class, sizeof (EphyNodeDbPrivate));
}
@@ -229,6 +247,12 @@ ephy_node_db_get_name (EphyNodeDb *db)
return db->priv->name;
}
+gboolean
+ephy_node_db_is_immutable (EphyNodeDb *db)
+{
+ return db->priv->immutable;
+}
+
EphyNode *
ephy_node_db_get_node_from_id (EphyNodeDb *db, long id)
{
@@ -284,6 +308,7 @@ ephy_node_db_load_from_file (EphyNodeDb *db,
{
xmlTextReaderPtr reader;
gboolean success = TRUE;
+ gboolean was_immutable;
int ret;
LOG ("ephy_node_db_load_from_file %s", xml_file)
@@ -301,6 +326,9 @@ ephy_node_db_load_from_file (EphyNodeDb *db,
return FALSE;
}
+ was_immutable = db->priv->immutable;
+ db->priv->immutable = FALSE;
+
ret = xmlTextReaderRead (reader);
while (ret == 1)
{
@@ -349,6 +377,8 @@ ephy_node_db_load_from_file (EphyNodeDb *db,
xmlFreeTextReader (reader);
+ db->priv->immutable = was_immutable;
+
STOP_PROFILER ("loading node db")
return (success && ret == 0);
diff --git a/lib/ephy-node-db.h b/lib/ephy-node-db.h
index ba597f528..21206f2ff 100644
--- a/lib/ephy-node-db.h
+++ b/lib/ephy-node-db.h
@@ -73,6 +73,8 @@ int ephy_node_db_write_to_xml_safe (EphyNodeDb *db,
const char *ephy_node_db_get_name (EphyNodeDb *db);
+gboolean ephy_node_db_is_immutable (EphyNodeDb *db);
+
EphyNode *ephy_node_db_get_node_from_id (EphyNodeDb *db,
long id);
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index 6194cb60f..c99ea9a0a 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -277,6 +277,8 @@ ephy_node_new (EphyNodeDb *db)
g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ if (ephy_node_db_is_immutable (db)) return NULL;
+
id = _ephy_node_db_new_id (db);
return ephy_node_new_with_id (db, id);
@@ -289,6 +291,8 @@ ephy_node_new_with_id (EphyNodeDb *db, gulong reserved_id)
g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
+ if (ephy_node_db_is_immutable (db)) return NULL;
+
node = g_new0 (EphyNode, 1);
node->ref_count = 0;
@@ -397,6 +401,8 @@ ephy_node_set_property (EphyNode *node,
g_return_if_fail (property_id >= 0);
g_return_if_fail (value != NULL);
+ if (ephy_node_db_is_immutable (node->db)) return;
+
new = g_new0 (GValue, 1);
g_value_init (new, G_VALUE_TYPE (value));
g_value_copy (value, new);
@@ -759,11 +765,13 @@ ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
g_return_val_if_fail (EPHY_IS_NODE_DB (db), NULL);
g_return_val_if_fail (xml_node != NULL, NULL);
+ if (ephy_node_db_is_immutable (db)) return NULL;
+
xml = xmlGetProp (xml_node, "id");
if (xml == NULL)
return NULL;
id = atol (xml);
- g_free (xml);
+ xmlFree (xml);
node = ephy_node_new_with_id (db, id);
@@ -775,7 +783,7 @@ ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
xml = xmlGetProp (xml_child, "id");
g_assert (xml != NULL);
parent_id = atol (xml);
- g_free (xml);
+ xmlFree (xml);
parent = ephy_node_db_get_node_from_id (db, parent_id);
@@ -792,11 +800,11 @@ ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
xml = xmlGetProp (xml_child, "id");
property_id = atoi (xml);
- g_free (xml);
+ xmlFree (xml);
xml = xmlGetProp (xml_child, "value_type");
value_type = g_type_from_name (xml);
- g_free (xml);
+ xmlFree (xml);
xml = xmlNodeGetContent (xml_child);
value = g_new0 (GValue, 1);
@@ -838,7 +846,7 @@ ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
real_set_property (node, property_id, value);
- g_free (xml);
+ xmlFree (xml);
}
}
@@ -852,6 +860,8 @@ ephy_node_add_child (EphyNode *node,
EphyNode *child)
{
g_return_if_fail (EPHY_IS_NODE (node));
+
+ if (ephy_node_db_is_immutable (node->db)) return;
real_add_child (node, child);
@@ -864,6 +874,8 @@ ephy_node_remove_child (EphyNode *node,
{
g_return_if_fail (EPHY_IS_NODE (node));
+ if (ephy_node_db_is_immutable (node->db)) return;
+
real_remove_child (node, child, TRUE, TRUE);
}
@@ -906,6 +918,8 @@ ephy_node_sort_children (EphyNode *node,
GPtrArray *newkids;
int i, *new_order;
+ if (ephy_node_db_is_immutable (node->db)) return;
+
g_return_if_fail (EPHY_IS_NODE (node));
g_return_if_fail (compare_func != NULL);
@@ -953,6 +967,8 @@ ephy_node_reorder_children (EphyNode *node,
g_return_if_fail (EPHY_IS_NODE (node));
g_return_if_fail (new_order != NULL);
+ if (ephy_node_db_is_immutable (node->db)) return;
+
newkids = g_ptr_array_new ();
g_ptr_array_set_size (newkids, node->children->len);
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 4a0d94809..48845bd17 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
#define CONF_STATE_UPLOAD_DIR "/apps/epiphany/directories/upload"
/* Lockdown */
+#define CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING "/apps/epiphany/lockdown/disable_bookmark_editing"
#define CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK "/desktop/gnome/lockdown/disable_save_to_disk"
/* System prefs */