diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 40 | ||||
-rw-r--r-- | src/bookmarks/ephy-topics-selector.c | 1 | ||||
-rw-r--r-- | src/window-commands.c | 25 |
3 files changed, 66 insertions, 0 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 5c4bd0694..3a3b0dc48 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -832,6 +832,42 @@ ephy_bookmarks_has_keyword (EphyBookmarks *eb, return ephy_node_has_child (keyword, bookmark); } +static void +update_topics_list (EphyBookmarks *eb, EphyNode *bookmark) +{ + GPtrArray *children; + int i; + GString *list; + GValue value = { 0, }; + + list = g_string_new (NULL); + + children = ephy_node_get_children (eb->priv->keywords); + for (i = 0; i < children->len; i++) + { + EphyNode *kid; + + kid = g_ptr_array_index (children, i); + + if (ephy_node_has_child (kid, bookmark)) + { + const char *topic; + topic = ephy_node_get_property_string + (kid, EPHY_NODE_KEYWORD_PROP_NAME); + g_string_append (list, topic); + } + } + ephy_node_thaw (eb->priv->keywords); + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, list->str); + ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS, + &value); + g_value_unset (&value); + + g_string_free (list, TRUE); +} + void ephy_bookmarks_set_keyword (EphyBookmarks *eb, EphyNode *keyword, @@ -840,6 +876,8 @@ ephy_bookmarks_set_keyword (EphyBookmarks *eb, if (ephy_node_has_child (keyword, bookmark)) return; ephy_node_add_child (keyword, bookmark); + + update_topics_list (eb, bookmark); } void @@ -850,6 +888,8 @@ ephy_bookmarks_unset_keyword (EphyBookmarks *eb, if (!ephy_node_has_child (keyword, bookmark)) return; ephy_node_remove_child (keyword, bookmark); + + update_topics_list (eb, bookmark); } EphyNode * diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c index 9ebccb97e..a86c1a48b 100644 --- a/src/bookmarks/ephy-topics-selector.c +++ b/src/bookmarks/ephy-topics-selector.c @@ -161,6 +161,7 @@ ephy_topics_selector_set_property (GObject *object, case PROP_BOOKMARK: ephy_topics_selector_set_bookmark (selector, g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/src/window-commands.c b/src/window-commands.c index c64761092..3da431353 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -19,6 +19,7 @@ #include <config.h> #include "ephy-shell.h" +#include "ephy-debug.h" #include "window-commands.h" #include "find-dialog.h" #include "print-dialog.h" @@ -232,6 +233,20 @@ window_cmd_file_new_tab (EggAction *action, EPHY_NEW_TAB_JUMP); } +static void +bookmarks_hide_cb (GtkWidget *widget, gpointer data) +{ + LOG ("Unref shell for bookmarks editor") + g_object_unref (ephy_shell); +} + +static void +shell_weak_notify_cb (gpointer data, GObject *object) +{ + LOG ("Bookmarks editor destroyed") + gtk_widget_destroy (GTK_WIDGET (data)); +} + void window_cmd_go_bookmarks (EggAction *action, EphyWindow *window) @@ -244,6 +259,16 @@ window_cmd_go_bookmarks (EggAction *action, bookmarks = ephy_shell_get_bookmarks (ephy_shell); g_assert (bookmarks != NULL); dialog = ephy_bookmarks_editor_new (bookmarks); + g_object_weak_ref (G_OBJECT (ephy_shell), + shell_weak_notify_cb, dialog); + g_signal_connect (dialog, "hide", + G_CALLBACK (bookmarks_hide_cb), NULL); + } + + if (!GTK_WIDGET_VISIBLE (dialog)) + { + LOG ("Ref shell for bookmarks editor") + g_object_ref (ephy_shell); } ephy_bookmarks_editor_set_parent (EPHY_BOOKMARKS_EDITOR (dialog), |