aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-open-tabs-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-open-tabs-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-open-tabs-action.c')
-rw-r--r--src/bookmarks/ephy-open-tabs-action.c109
1 files changed, 68 insertions, 41 deletions
diff --git a/src/bookmarks/ephy-open-tabs-action.c b/src/bookmarks/ephy-open-tabs-action.c
index 137769ea1..eb0955446 100644
--- a/src/bookmarks/ephy-open-tabs-action.c
+++ b/src/bookmarks/ephy-open-tabs-action.c
@@ -18,78 +18,99 @@
* $Id$
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
-
-#include <gtk/gtktoolitem.h>
-#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <string.h>
#include "ephy-open-tabs-action.h"
+
#include "ephy-bookmarks.h"
#include "ephy-node-common.h"
#include "ephy-link-action.h"
#include "ephy-link.h"
+#include <glib/gi18n.h>
+#include <gtk/gtktoolitem.h>
+
+#include <libgnomevfs/gnome-vfs-uri.h>
+
+#include <string.h>
+
static void
-activate_cb (GtkAction *action, gpointer dummy)
+activate_cb (GtkAction *action,
+ gpointer dummy)
{
- EphyLink *link = g_object_get_data (G_OBJECT (action), "ephy-link");
- EphyNode *node = g_object_get_data (G_OBJECT (action), "ephy-node");
- GPtrArray *children = ephy_node_get_children (node);
+ GObject *object = G_OBJECT (action);
+ EphyLink *link;
+ EphyNode *node;
+ GPtrArray *children;
EphyTab *tab = 0;
-
- gint i;
const char *url;
+ guint i;
- for (i = 0; i < children->len; i++)
+ link = g_object_get_data (object, "ephy-link");
+ node = g_object_get_data (object, "ephy-node");
+
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; ++i)
{
node = g_ptr_array_index (children, i);
+
url = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
- tab = ephy_link_open (link, url, tab, EPHY_LINK_NEW_TAB);
+ tab = ephy_link_open (link, url, tab,
+ EPHY_LINK_NEW_TAB | ephy_link_flags_from_current_event ());
}
}
static void
-node_added_cb (EphyNode *parent, EphyNode *child, GObject *object)
+node_added_cb (EphyNode *parent,
+ EphyNode *child,
+ GtkActionGroup *action_group)
{
- GtkActionGroup *actions = GTK_ACTION_GROUP (object);
+ GObject *action_object;
GtkAction *action;
char *name, *accel;
name = ephy_open_tabs_action_name (child);
- g_return_if_fail (name);
+ g_assert (name != NULL);
+ /* FIXME !!!! */
action = gtk_action_new (name, _("Open in New _Tabs"), "Open this topic in tabs", NULL);
+ action_object = G_OBJECT (action);
+
+ g_object_set_data (action_object, "ephy-node", child);
+ g_object_set_data (action_object, "ephy-link", EPHY_LINK (action_group));
- g_object_set_data (G_OBJECT (action), "ephy-node", child);
- g_object_set_data (G_OBJECT (action), "ephy-link", EPHY_LINK (object));
-
- g_signal_connect (G_OBJECT (action), "activate",
+ g_signal_connect (action, "activate",
G_CALLBACK (activate_cb), NULL);
-
+
accel = g_strjoin ("/", "<Actions>",
- gtk_action_group_get_name (actions),
+ gtk_action_group_get_name (action_group),
name,
NULL);
+
gtk_action_set_accel_path (action, accel);
- gtk_action_group_add_action (actions, action);
+ gtk_action_group_add_action (action_group, action);
g_object_unref (action);
+
g_free (accel);
g_free (name);
}
static void
-node_removed_cb (EphyNode *parent, EphyNode *child, guint index, GObject *object)
+node_removed_cb (EphyNode *parent,
+ EphyNode *child,
+ guint index,
+ GtkActionGroup *action_group)
{
- char *name = ephy_open_tabs_action_name (child);
+ GtkAction *action;
+ char *name;
+
+ name = ephy_open_tabs_action_name (child);
+
+ // FIXME can this really ever be NULL ??
if (name)
{
- GtkActionGroup *actions = GTK_ACTION_GROUP (object);
- GtkAction *action = gtk_action_group_get_action (actions, name);
- if (action) gtk_action_group_remove_action (actions, action);
+ action = gtk_action_group_get_action (action_group, name);
+ if (action) gtk_action_group_remove_action (action_group, action);
g_free (name);
}
}
@@ -97,25 +118,31 @@ node_removed_cb (EphyNode *parent, EphyNode *child, guint index, GObject *object
GtkActionGroup *
ephy_open_tabs_group_new (EphyNode *node)
{
- GPtrArray *children = ephy_node_get_children (node);
- GObject *actions = G_OBJECT (ephy_link_action_group_new ("OpenTabsActions"));
- gint i;
+ GPtrArray *children;
+ GtkActionGroup *action_group;
+ guint i;
+ children = ephy_node_get_children (node);
+ action_group = (GtkActionGroup *) ephy_link_action_group_new ("OpenTabsActions");
+
for (i = 0; i < children->len; i++)
- node_added_cb (node, g_ptr_array_index (children, i), actions);
-
+ {
+ node_added_cb (node, g_ptr_array_index (children, i),
+ action_group);
+ }
+
ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback)node_added_cb,
- actions);
+ (EphyNodeCallback) node_added_cb,
+ (GObject *) action_group);
ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback)node_removed_cb,
- actions);
+ (EphyNodeCallback) node_removed_cb,
+ (GObject *) action_group);
- return GTK_ACTION_GROUP (actions);
+ return action_group;
}
char *
ephy_open_tabs_action_name (EphyNode *node)
{
- return g_strdup_printf("OpenTabs%u", ephy_node_get_id (node));
+ return g_strdup_printf("OpTb%u", ephy_node_get_id (node));
}