aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-02-13 03:21:00 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-02-13 03:21:00 +0800
commit764f52e639805fe04fc9efbb1a398160fd424e5f (patch)
tree6d40b33dc86f32014f54102df98934235615db58 /src/bookmarks
parent87dacf48f3b15b9cef564af8a82b05f4a0b236d9 (diff)
downloadgsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.tar
gsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.tar.gz
gsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.tar.bz2
gsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.tar.lz
gsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.tar.xz
gsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.tar.zst
gsoc2013-epiphany-764f52e639805fe04fc9efbb1a398160fd424e5f.zip
*** empty log message ***
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c6
-rw-r--r--src/bookmarks/ephy-bookmarks.c134
2 files changed, 38 insertions, 102 deletions
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 3f106fa4b..c7e5c8932 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -207,7 +207,7 @@ ephy_bookmarks_editor_node_selected_cb (GtkWidget *view,
gtk_entry_set_text (GTK_ENTRY (editor->priv->keywords_entry),
keywords ? g_strdup (keywords) : "");
gtk_entry_set_text (GTK_ENTRY (editor->priv->location_entry),
- location ? g_strdup (location) : "");
+ location ? g_strdup (location) : "");
gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->title_entry), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->keywords_entry), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (editor->priv->location_entry), TRUE);
@@ -487,7 +487,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
- gtk_widget_set_size_request (GTK_WIDGET (editor), 600, 400);
+ gtk_widget_set_size_request (GTK_WIDGET (editor), 550, 450);
g_signal_connect (G_OBJECT (editor),
"response",
G_CALLBACK (ephy_bookmarks_editor_response_cb),
@@ -507,7 +507,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
ephy_node_view_add_column (key_view, _("Keywords"),
EPHY_TREE_MODEL_NODE_COL_KEYWORD, FALSE);
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (key_view), FALSE, TRUE, 0);
- gtk_widget_set_size_request (GTK_WIDGET (key_view), 180, -1);
+ gtk_widget_set_size_request (GTK_WIDGET (key_view), 130, -1);
gtk_widget_show (GTK_WIDGET (key_view));
editor->priv->key_view = key_view;
g_signal_connect (G_OBJECT (key_view),
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 87ae1ad03..46d3066c1 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -37,10 +37,6 @@ struct EphyBookmarksPrivate
EphyNode *favorites;
EphyNode *lower_fav;
double lower_score;
- GHashTable *bookmarks_hash;
- GStaticRWLock *bookmarks_hash_lock;
- GHashTable *favorites_hash;
- GStaticRWLock *favorites_hash_lock;
GHashTable *keywords_hash;
GStaticRWLock *keywords_hash_lock;
};
@@ -332,16 +328,12 @@ static gboolean
add_to_favorites (EphyBookmarks *eb, EphyNode *node, EphyHistory *eh)
{
const char *url;
- EphyNode *fav_node;
gboolean full_menu;
double score;
- url = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
- g_static_rw_lock_reader_lock (eb->priv->favorites_hash_lock);
- fav_node = g_hash_table_lookup (eb->priv->favorites_hash, url);
- g_static_rw_lock_reader_unlock (eb->priv->favorites_hash_lock);
- if (fav_node) return FALSE;
+ if (ephy_node_has_child (eb->priv->favorites, node)) return FALSE;
+ url = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
score = get_history_item_score (eh, url);
full_menu = ephy_node_get_n_children (eb->priv->favorites)
> MAX_FAVORITES_NUM;
@@ -380,11 +372,12 @@ static void
history_site_visited_cb (EphyHistory *gh, const char *url, EphyBookmarks *eb)
{
EphyNode *node;
+ guint id;
- g_static_rw_lock_reader_lock (eb->priv->bookmarks_hash_lock);
- node = g_hash_table_lookup (eb->priv->bookmarks_hash, url);
- g_static_rw_lock_reader_unlock (eb->priv->bookmarks_hash_lock);
- if (!node) return;
+ id = ephy_bookmarks_get_bookmark_id (eb, url);
+ if (id == 0) return;
+
+ node = ephy_node_get_from_id (id);
if (add_to_favorites (eb, node, gh))
{
@@ -433,44 +426,11 @@ keywords_removed_cb (EphyNode *node,
}
static void
-favorites_added_cb (EphyNode *node,
- EphyNode *child,
- EphyBookmarks *eb)
-{
- g_static_rw_lock_writer_lock (eb->priv->favorites_hash_lock);
-
- g_hash_table_insert (eb->priv->favorites_hash,
- (char *) ephy_node_get_property_string (child, EPHY_NODE_BMK_PROP_LOCATION),
- child);
-
- g_static_rw_lock_writer_unlock (eb->priv->favorites_hash_lock);
-}
-
-static void
-favorites_removed_cb (EphyNode *node,
+bookmarks_changed_cb (EphyNode *node,
EphyNode *child,
EphyBookmarks *eb)
{
- g_static_rw_lock_writer_lock (eb->priv->favorites_hash_lock);
-
- g_hash_table_remove (eb->priv->favorites_hash,
- ephy_node_get_property_string (child, EPHY_NODE_BMK_PROP_LOCATION));
-
- g_static_rw_lock_writer_unlock (eb->priv->favorites_hash_lock);
-}
-
-static void
-bookmarks_added_cb (EphyNode *node,
- EphyNode *child,
- EphyBookmarks *eb)
-{
- g_static_rw_lock_writer_lock (eb->priv->bookmarks_hash_lock);
-
- g_hash_table_insert (eb->priv->bookmarks_hash,
- (char *) ephy_node_get_property_string (child, EPHY_NODE_BMK_PROP_LOCATION),
- child);
-
- g_static_rw_lock_writer_unlock (eb->priv->bookmarks_hash_lock);
+ ephy_bookmarks_emit_data_changed (eb);
}
static void
@@ -480,13 +440,6 @@ bookmarks_removed_cb (EphyNode *node,
{
ephy_bookmarks_emit_data_changed (eb);
g_idle_add ((GSourceFunc)ephy_bookmarks_clean_empty_keywords, eb);
-
- g_static_rw_lock_writer_lock (eb->priv->bookmarks_hash_lock);
-
- g_hash_table_remove (eb->priv->bookmarks_hash,
- ephy_node_get_property_string (child, EPHY_NODE_BMK_PROP_LOCATION));
-
- g_static_rw_lock_writer_unlock (eb->priv->bookmarks_hash_lock);
}
static void
@@ -500,21 +453,11 @@ ephy_bookmarks_init (EphyBookmarks *eb)
"bookmarks.xml",
NULL);
- eb->priv->bookmarks_hash = g_hash_table_new (g_str_hash,
- g_str_equal);
- eb->priv->bookmarks_hash_lock = g_new0 (GStaticRWLock, 1);
- g_static_rw_lock_init (eb->priv->bookmarks_hash_lock);
-
eb->priv->keywords_hash = g_hash_table_new (g_str_hash,
g_str_equal);
eb->priv->keywords_hash_lock = g_new0 (GStaticRWLock, 1);
g_static_rw_lock_init (eb->priv->keywords_hash_lock);
- eb->priv->favorites_hash = g_hash_table_new (g_str_hash,
- g_str_equal);
- eb->priv->favorites_hash_lock = g_new0 (GStaticRWLock, 1);
- g_static_rw_lock_init (eb->priv->favorites_hash_lock);
-
/* Bookmarks */
eb->priv->bookmarks = ephy_node_new_with_id (BOOKMARKS_NODE_ID);
ephy_node_ref (eb->priv->bookmarks);
@@ -525,13 +468,13 @@ ephy_bookmarks_init (EphyBookmarks *eb)
&value);
g_value_unset (&value);
g_signal_connect_object (G_OBJECT (eb->priv->bookmarks),
- "child_added",
- G_CALLBACK (bookmarks_added_cb),
+ "child_removed",
+ G_CALLBACK (bookmarks_removed_cb),
G_OBJECT (eb),
0);
g_signal_connect_object (G_OBJECT (eb->priv->bookmarks),
- "child_removed",
- G_CALLBACK (bookmarks_removed_cb),
+ "child_changed",
+ G_CALLBACK (bookmarks_changed_cb),
G_OBJECT (eb),
0);
@@ -554,16 +497,6 @@ ephy_bookmarks_init (EphyBookmarks *eb)
eb->priv->favorites = ephy_node_new_with_id (FAVORITES_NODE_ID);
ephy_node_ref (eb->priv->favorites);
- g_signal_connect_object (G_OBJECT (eb->priv->favorites),
- "child_added",
- G_CALLBACK (favorites_added_cb),
- G_OBJECT (eb),
- 0);
- g_signal_connect_object (G_OBJECT (eb->priv->favorites),
- "child_removed",
- G_CALLBACK (favorites_removed_cb),
- G_OBJECT (eb),
- 0);
ephy_bookmarks_load (eb);
ephy_bookmarks_emit_data_changed (eb);
@@ -589,10 +522,6 @@ ephy_bookmarks_finalize (GObject *object)
ephy_node_unref (eb->priv->keywords);
ephy_node_unref (eb->priv->favorites);
- g_hash_table_destroy (eb->priv->bookmarks_hash);
- g_static_rw_lock_free (eb->priv->bookmarks_hash_lock);
- g_hash_table_destroy (eb->priv->favorites_hash);
- g_static_rw_lock_free (eb->priv->favorites_hash_lock);
g_hash_table_destroy (eb->priv->keywords_hash);
g_static_rw_lock_free (eb->priv->keywords_hash_lock);
@@ -663,20 +592,27 @@ guint
ephy_bookmarks_get_bookmark_id (EphyBookmarks *eb,
const char *url)
{
- EphyNode *node;
-
- g_static_rw_lock_reader_lock (eb->priv->bookmarks_hash_lock);
- node = g_hash_table_lookup (eb->priv->bookmarks_hash, url);
- g_static_rw_lock_reader_unlock (eb->priv->bookmarks_hash_lock);
+ GPtrArray *children;
+ int i;
- if (node)
- {
- return ephy_node_get_id (node);
- }
- else
+ children = ephy_node_get_children (eb->priv->bookmarks);
+ for (i = 0; i < children->len; i++)
{
- return 0;
+ EphyNode *kid;
+ const char *location;
+
+ kid = g_ptr_array_index (children, i);
+ location = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+ if (strcmp (url, location) == 0)
+ {
+ ephy_node_thaw (eb->priv->bookmarks);
+ return ephy_node_get_id (kid);
+ }
}
+ ephy_node_thaw (eb->priv->bookmarks);
+
+ return 0;
}
void
@@ -686,14 +622,14 @@ ephy_bookmarks_set_icon (EphyBookmarks *eb,
{
EphyNode *node;
GValue value = { 0, };
+ guint id;
g_return_if_fail (icon != NULL);
- g_static_rw_lock_reader_lock (eb->priv->bookmarks_hash_lock);
- node = g_hash_table_lookup (eb->priv->bookmarks_hash, url);
- g_static_rw_lock_reader_unlock (eb->priv->bookmarks_hash_lock);
+ id = ephy_bookmarks_get_bookmark_id (eb, url);
+ if (id == 0) return;
- if (node == NULL) return;
+ node = ephy_node_get_from_id (id);
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, icon);