aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-related-action.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-02-09 21:52:45 +0800
committerChristian Persch <chpe@src.gnome.org>2006-02-09 21:52:45 +0800
commita6c15fb7c0718216ea3950324fd6465f334d16dc (patch)
tree14ac97b90d9fe663f1af63d0ab4e011a474b2975 /src/bookmarks/ephy-related-action.c
parent119a3c3c65eee95efaa155ba06635f693e79ecfc (diff)
downloadgsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.tar
gsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.tar.gz
gsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.tar.bz2
gsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.tar.lz
gsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.tar.xz
gsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.tar.zst
gsoc2013-epiphany-a6c15fb7c0718216ea3950324fd6465f334d16dc.zip
Misc code cleanups: fewer gobject casts, disconnect handlers, save a few
2006-02-09 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmark-action-group.c: (node_changed_cb), (node_added_cb), (node_removed_cb), (ephy_bookmark_group_new): * src/bookmarks/ephy-bookmark-action.c: (ephy_bookmark_action_sync_smart_url), (ephy_bookmark_action_sync_icon), (connect_proxy), (ephy_bookmark_action_set_bookmark), (ephy_bookmark_action_get_property), (ephy_bookmark_action_init), (ephy_bookmark_action_dispose), (ephy_bookmark_action_class_init), (ephy_bookmark_action_get_type): * src/bookmarks/ephy-bookmark-action.h: * src/bookmarks/ephy-bookmarks-ui.c: (ephy_bookmarks_ui_attach_window): * src/bookmarks/ephy-open-tabs-action.c: (activate_cb), (node_added_cb), (node_removed_cb), (ephy_open_tabs_group_new), (ephy_open_tabs_action_name): * src/bookmarks/ephy-related-action.c: (node_changed), (node_destroyed), (open_link), (ephy_related_action_new): * src/bookmarks/ephy-topics-entry.c: * src/bookmarks/ephy-topics-entry.h: Misc code cleanups: fewer gobject casts, disconnect handlers, save a few strdups etc.
Diffstat (limited to 'src/bookmarks/ephy-related-action.c')
-rw-r--r--src/bookmarks/ephy-related-action.c146
1 files changed, 79 insertions, 67 deletions
diff --git a/src/bookmarks/ephy-related-action.c b/src/bookmarks/ephy-related-action.c
index 30db41481..3b83fba60 100644
--- a/src/bookmarks/ephy-related-action.c
+++ b/src/bookmarks/ephy-related-action.c
@@ -20,31 +20,38 @@
#include "config.h"
-#include <gtk/gtk.h>
-#include <gtk/gtkaction.h>
-#include <gtk/gtkactiongroup.h>
-#include <glib/gi18n.h>
+#include "ephy-related-action.h"
#include "ephy-window.h"
#include "ephy-bookmarks.h"
#include "ephy-shell.h"
#include "ephy-node-common.h"
#include "ephy-stock-icons.h"
-#include "ephy-related-action.h"
+
+#include <gtk/gtk.h>
+#include <gtk/gtkaction.h>
+#include <gtk/gtkactiongroup.h>
+#include <glib/gi18n.h>
static void
-node_changed (EphyNode *node, guint propertyid, GObject *object)
+node_changed (EphyNode *node,
+ guint propertyid,
+ EphyTopicAction *action)
{
- ephy_topic_action_updated (EPHY_TOPIC_ACTION (object));
+ ephy_topic_action_updated (action);
}
static void
-node_destroyed (EphyNode *node, GObject *object)
+node_destroyed (EphyNode *node,
+ EphyTopicAction *action)
{
- EphyBookmarks *eb = ephy_shell_get_bookmarks (ephy_shell);
-
- ephy_topic_action_set_topic (EPHY_TOPIC_ACTION (object),
- ephy_bookmarks_get_favorites (eb));
+ EphyBookmarks *eb;
+ EphyNode *favorites;
+
+ eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ favorites = ephy_bookmarks_get_favorites (eb);
+
+ ephy_topic_action_set_topic (action, favorites);
}
static EphyTab *
@@ -53,57 +60,58 @@ open_link (EphyLink *link,
EphyTab *tab,
EphyLinkFlags flags)
{
- EphyBookmarks *eb = ephy_shell_get_bookmarks (ephy_shell);
- EphyNode *bookmark = ephy_bookmarks_find_bookmark (eb, address);
+ EphyBookmarks *eb;
+ EphyNode *bookmark;
EphyNode *topic, *chosen = NULL;
+ GPtrArray *topics;
+ gint i, tmp, best = 0;
- if (bookmark != NULL)
+ eb = ephy_shell_get_bookmarks (ephy_shell_get_default ());
+ bookmark = ephy_bookmarks_find_bookmark (eb, address);
+ if (bookmark == NULL) return NULL;
+
+ topic = ephy_topic_action_get_topic (EPHY_TOPIC_ACTION (link));
+ tmp = ephy_node_get_property_int (topic, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (tmp == EPHY_NODE_NORMAL_PRIORITY &&
+ ephy_node_has_child (topic, bookmark))
+ {
+ return NULL;
+ }
+ ephy_node_signal_disconnect_object (topic, EPHY_NODE_CHANGED,
+ (EphyNodeCallback) node_changed,
+ G_OBJECT (link));
+ ephy_node_signal_disconnect_object (topic, EPHY_NODE_DESTROY,
+ (EphyNodeCallback) node_destroyed,
+ G_OBJECT (link));
+
+ topics = ephy_node_get_children (ephy_bookmarks_get_keywords (eb));
+ for (i = 0; i < topics->len; i++)
{
- GPtrArray *topics;
- gint i, tmp, best = 0;
-
- topic = ephy_topic_action_get_topic (EPHY_TOPIC_ACTION (link));
- tmp = ephy_node_get_property_int (topic, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ topic = g_ptr_array_index (topics, i);
+ tmp = ephy_node_get_property_int (topic, EPHY_NODE_KEYWORD_PROP_PRIORITY);
if (tmp == EPHY_NODE_NORMAL_PRIORITY &&
ephy_node_has_child (topic, bookmark))
{
- return NULL;
- }
- ephy_node_signal_disconnect_object (topic, EPHY_NODE_CHANGED,
- (EphyNodeCallback) node_changed,
- G_OBJECT (link));
- ephy_node_signal_disconnect_object (topic, EPHY_NODE_DESTROY,
- (EphyNodeCallback) node_destroyed,
- G_OBJECT (link));
-
- topics = ephy_node_get_children (ephy_bookmarks_get_keywords (eb));
- for (i = 0; i < topics->len; i++)
- {
- topic = g_ptr_array_index (topics, i);
- tmp = ephy_node_get_property_int (topic, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- if (tmp == EPHY_NODE_NORMAL_PRIORITY &&
- ephy_node_has_child (topic, bookmark))
+ tmp = ephy_node_get_n_children (topic);
+ if (chosen == NULL ||
+ (tmp >= 10 && tmp <= best))
{
- tmp = ephy_node_get_n_children (topic);
- if (chosen == NULL || (tmp >= 10 && tmp <= best))
- {
- chosen = topic;
- best = tmp;
- }
+ chosen = topic;
+ best = tmp;
}
}
-
- if (chosen == NULL) chosen = ephy_bookmarks_get_favorites (eb);
-
- ephy_topic_action_set_topic (EPHY_TOPIC_ACTION (link), chosen);
- ephy_node_signal_connect_object (chosen, EPHY_NODE_CHANGED,
- (EphyNodeCallback) node_changed,
- G_OBJECT (link));
- ephy_node_signal_connect_object (chosen, EPHY_NODE_DESTROY,
- (EphyNodeCallback) node_destroyed,
- G_OBJECT (link));
}
+ if (chosen == NULL) chosen = ephy_bookmarks_get_favorites (eb);
+
+ ephy_topic_action_set_topic (EPHY_TOPIC_ACTION (link), chosen);
+ ephy_node_signal_connect_object (chosen, EPHY_NODE_CHANGED,
+ (EphyNodeCallback) node_changed,
+ G_OBJECT (link));
+ ephy_node_signal_connect_object (chosen, EPHY_NODE_DESTROY,
+ (EphyNodeCallback) node_destroyed,
+ G_OBJECT (link));
+
return NULL;
}
@@ -151,24 +159,28 @@ ephy_related_action_get_type (void)
}
GtkAction *
-ephy_related_action_new (EphyLink *link, GtkUIManager *manager, char * name)
+ephy_related_action_new (EphyLink *link,
+ GtkUIManager *manager,
+ char * name)
{
- EphyBookmarks *eb = ephy_shell_get_bookmarks (ephy_shell);
- EphyNode *favorites = ephy_bookmarks_get_favorites (eb);
-
- EphyRelatedAction *action =
- EPHY_RELATED_ACTION (g_object_new (EPHY_TYPE_RELATED_ACTION,
- "name", name,
- "topic", favorites,
- "short_label", _("Related"),
- "stock-id", GTK_STOCK_INDEX,
- "manager", manager,
- NULL));
+ EphyBookmarks *eb;
+ EphyNode *favorites;
+ EphyRelatedAction *action;
+
+ eb = ephy_shell_get_bookmarks (ephy_shell);
+ favorites = ephy_bookmarks_get_favorites (eb);
+
+ action = (EphyRelatedAction *) (g_object_new (EPHY_TYPE_RELATED_ACTION,
+ "name", name,
+ "topic", favorites,
+ "short_label", _("Related"),
+ "stock-id", GTK_STOCK_INDEX,
+ "manager", manager,
+ NULL));
- g_signal_connect_object (G_OBJECT (link), "open-link",
+ g_signal_connect_object (link, "open-link",
G_CALLBACK (ephy_link_open), action,
G_CONNECT_SWAPPED);
- return GTK_ACTION (action);
+ return (GtkAction *) action;
}
-