diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-04-28 17:05:56 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-28 17:05:56 +0800 |
commit | 70c5d9a1d5598f03a7717ba8028952ba65abaff2 (patch) | |
tree | c67474bee3d06ccabf177950f53b6986dd5552bd /src/bookmarks | |
parent | bd41682b235e8a4a0c37b317ef71c38e5ed6a5a1 (diff) | |
download | gsoc2013-epiphany-70c5d9a1d5598f03a7717ba8028952ba65abaff2.tar.gz gsoc2013-epiphany-70c5d9a1d5598f03a7717ba8028952ba65abaff2.tar.zst gsoc2013-epiphany-70c5d9a1d5598f03a7717ba8028952ba65abaff2.zip |
Sync toolbar on bookmark properties changes.
2003-04-28 Marco Pesenti Gritti <marco@it.gnome.org>
* src/bookmarks/ephy-bookmark-action.c: (sync_bookmark_properties),
(bookmarks_child_changed_cb), (ephy_bookmark_action_init),
(ephy_bookmark_action_new):
* src/bookmarks/ephy-topic-action.c:
(ephy_topic_action_set_property), (ephy_topic_action_get_property),
(ephy_topic_action_class_init), (sync_topic_properties),
(topic_child_changed_cb), (ephy_topic_action_init),
(ephy_topic_action_new):
Sync toolbar on bookmark properties changes.
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 71 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.c | 57 |
2 files changed, 99 insertions, 29 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index 8039ca42b..196a05e36 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -365,43 +365,80 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class) } static void +sync_bookmark_properties (EggAction *action, EphyNode *bmk) +{ + const char *title, *location, *smart_url, *icon; + + icon = ephy_node_get_property_string + (bmk, EPHY_NODE_BMK_PROP_ICON); + title = ephy_node_get_property_string + (bmk, EPHY_NODE_BMK_PROP_TITLE); + location = ephy_node_get_property_string + (bmk, EPHY_NODE_BMK_PROP_LOCATION); + smart_url = ephy_node_get_property_string + (bmk, EPHY_NODE_BMK_PROP_SMART_LOCATION); + if (smart_url && *smart_url == '\0') smart_url = NULL; + + g_object_set (action, + "label", title, + "location", location, + "smart_url", smart_url, + "icon", icon, + NULL); +} + +static void +bookmarks_child_changed_cb (EphyNode *node, EphyNode *child, EggAction *action) +{ + gulong id; + + id = EPHY_BOOKMARK_ACTION (action)->priv->bookmark_id; + + if (id == ephy_node_get_id (child)) + { + sync_bookmark_properties (action, child); + } +} + +static void ephy_bookmark_action_init (EphyBookmarkAction *action) { + EphyBookmarks *bookmarks; + EphyNode *node; + action->priv = g_new0 (EphyBookmarkActionPrivate, 1); action->priv->location = NULL; action->priv->smart_url = NULL; action->priv->icon = NULL; + + + bookmarks = ephy_shell_get_bookmarks (ephy_shell); + node = ephy_bookmarks_get_bookmarks (bookmarks); + g_signal_connect_object (node, "child_changed", + G_CALLBACK (bookmarks_child_changed_cb), + action, 0); } EggAction * ephy_bookmark_action_new (const char *name, guint id) { EphyNode *bmk; - const char *title, *location, *smart_url, *icon; EphyBookmarks *bookmarks; + EggAction *action; bookmarks = ephy_shell_get_bookmarks (ephy_shell); bmk = ephy_node_get_from_id (id); g_return_val_if_fail (bmk != NULL, NULL); - icon = ephy_node_get_property_string - (bmk, EPHY_NODE_BMK_PROP_ICON); - title = ephy_node_get_property_string - (bmk, EPHY_NODE_BMK_PROP_TITLE); - location = ephy_node_get_property_string - (bmk, EPHY_NODE_BMK_PROP_LOCATION); - smart_url = ephy_node_get_property_string - (bmk, EPHY_NODE_BMK_PROP_SMART_LOCATION); - if (smart_url && *smart_url == '\0') smart_url = NULL; + action = EGG_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION, + "name", name, + "bookmark_id", id, + NULL)); + + sync_bookmark_properties (action, bmk); - return EGG_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION, - "name", name, - "label", title, - "location", location, - "smart_url", smart_url, - "icon", icon, - NULL)); + return action; } diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c index b8d8ab9ee..121701286 100644 --- a/src/bookmarks/ephy-topic-action.c +++ b/src/bookmarks/ephy-topic-action.c @@ -34,7 +34,7 @@ struct EphyTopicActionPrivate enum { PROP_0, - PROP_BOOKMARK_ID + PROP_TOPIC_ID }; enum @@ -310,7 +310,7 @@ ephy_topic_action_set_property (GObject *object, switch (prop_id) { - case PROP_BOOKMARK_ID: + case PROP_TOPIC_ID: bmk->priv->topic_id = g_value_get_int (value); break; } @@ -328,7 +328,7 @@ ephy_topic_action_get_property (GObject *object, switch (prop_id) { - case PROP_BOOKMARK_ID: + case PROP_TOPIC_ID: g_value_set_boolean (value, bmk->priv->topic_id); break; } @@ -381,7 +381,7 @@ ephy_topic_action_class_init (EphyTopicActionClass *class) G_TYPE_STRING); g_object_class_install_property (object_class, - PROP_BOOKMARK_ID, + PROP_TOPIC_ID, g_param_spec_int ("topic_id", "topic_id", "topic_id", @@ -392,30 +392,63 @@ ephy_topic_action_class_init (EphyTopicActionClass *class) } static void +sync_topic_properties (EggAction *action, EphyNode *bmk) +{ + const char *title; + + title = ephy_node_get_property_string + (bmk, EPHY_NODE_KEYWORD_PROP_NAME); + + g_object_set (action, "label", title, NULL); +} + +static void +topic_child_changed_cb (EphyNode *node, EphyNode *child, EggAction *action) +{ + gulong id; + + id = EPHY_TOPIC_ACTION (action)->priv->topic_id; + + if (id == ephy_node_get_id (child)) + { + sync_topic_properties (action, child); + } +} + +static void ephy_topic_action_init (EphyTopicAction *action) { + EphyBookmarks *bookmarks; + EphyNode *node; + action->priv = g_new0 (EphyTopicActionPrivate, 1); + + bookmarks = ephy_shell_get_bookmarks (ephy_shell); + node = ephy_bookmarks_get_keywords (bookmarks); + g_signal_connect_object (node, "child_changed", + G_CALLBACK (topic_child_changed_cb), + action, 0); } EggAction * ephy_topic_action_new (const char *name, guint id) { EphyNode *bmk; - const char *title; EphyBookmarks *bookmarks; + EggAction *action; bookmarks = ephy_shell_get_bookmarks (ephy_shell); bmk = ephy_node_get_from_id (id); g_return_val_if_fail (bmk != NULL, NULL); - title = ephy_node_get_property_string - (bmk, EPHY_NODE_KEYWORD_PROP_NAME); + action = EGG_ACTION (g_object_new (EPHY_TYPE_TOPIC_ACTION, + "topic_id", id, + "name", name, + NULL)); + + sync_topic_properties (action, bmk); - return EGG_ACTION (g_object_new (EPHY_TYPE_TOPIC_ACTION, - "topic_id", id, - "name", name, - "label", title, - NULL)); + return action; } |