aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-06-24 16:58:52 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-06-24 16:58:52 +0800
commit6fcf143b625f3423798bea58621a231446eac361 (patch)
tree725aa187c799702afe51600681188d3412d2d5d6 /src
parent24833bb6604df5e36c39bab539fdbea4b5b57fe5 (diff)
downloadgsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.tar
gsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.tar.gz
gsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.tar.bz2
gsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.tar.lz
gsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.tar.xz
gsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.tar.zst
gsoc2013-epiphany-6fcf143b625f3423798bea58621a231446eac361.zip
Implement open in tabs from toolbar topics
2004-06-24 Marco Pesenti Gritti <marco@gnome.org> * src/bookmarks/ephy-bookmarksbar.c: (open_in_tabs_cb), (go_location_cb), (ephy_bookmarksbar_action_request): * src/bookmarks/ephy-topic-action.c: (append_bookmarks_menu), (open_in_tabs_activate_cb), (build_bookmarks_menu), (build_topics_menu), (build_menu), (ephy_topic_action_set_topic_id), (ephy_topic_action_set_property), (ephy_topic_action_class_init): * src/bookmarks/ephy-topic-action.h: * src/ephy-window.c: (ephy_window_load_in_tabs): Implement open in tabs from toolbar topics
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarksbar.c20
-rw-r--r--src/bookmarks/ephy-topic-action.c104
-rw-r--r--src/bookmarks/ephy-topic-action.h3
-rw-r--r--src/ephy-window.c3
4 files changed, 106 insertions, 24 deletions
diff --git a/src/bookmarks/ephy-bookmarksbar.c b/src/bookmarks/ephy-bookmarksbar.c
index 3855090cc..249971491 100644
--- a/src/bookmarks/ephy-bookmarksbar.c
+++ b/src/bookmarks/ephy-bookmarksbar.c
@@ -98,9 +98,19 @@ ephy_bookmarksbar_get_type (void)
}
static void
-go_location_cb (GtkAction *action,
- char *location,
- EphyBookmarksBar *toolbar)
+open_in_tabs_cb (GtkAction *action, GList *uri_list, EphyBookmarksBar *toolbar)
+{
+ EphyWindow *window = toolbar->priv->window;
+ EphyTab *tab;
+
+ g_return_if_fail (EPHY_IS_WINDOW (window));
+
+ tab = ephy_window_get_active_tab (window);
+ ephy_window_load_in_tabs (window, tab, uri_list);
+}
+
+static void
+go_location_cb (GtkAction *action, char *location, EphyBookmarksBar *toolbar)
{
EphyWindow *window = toolbar->priv->window;
GdkEvent *event;
@@ -233,6 +243,9 @@ ephy_bookmarksbar_action_request (EggEditableToolbar *eggtoolbar,
if (ephy_node_has_child (topics, node))
{
action = ephy_topic_action_new (name, ephy_node_get_id (node));
+
+ g_signal_connect (action, "open_in_tabs",
+ G_CALLBACK (open_in_tabs_cb), toolbar);
}
else if (ephy_node_has_child (bmks, node))
{
@@ -243,6 +256,7 @@ ephy_bookmarksbar_action_request (EggEditableToolbar *eggtoolbar,
g_signal_connect (action, "go_location",
G_CALLBACK (go_location_cb), toolbar);
+
gtk_action_group_add_action (toolbar->priv->action_group, action);
g_object_unref (action);
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index f0b40d5da..64ecff7e9 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -24,6 +24,7 @@
#include <gtk/gtktoolitem.h>
#include <glib/gi18n.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
#include "ephy-topic-action.h"
#include "ephy-node-common.h"
@@ -41,7 +42,8 @@ static void ephy_topic_action_class_init (EphyTopicActionClass *class);
struct EphyTopicActionPrivate
{
- int topic_id;
+ gulong topic_id;
+ EphyNode *topic_node;
};
enum
@@ -53,6 +55,7 @@ enum
enum
{
GO_LOCATION,
+ OPEN_IN_TABS,
LAST_SIGNAL
};
@@ -215,7 +218,7 @@ sort_bookmarks (gconstpointer a, gconstpointer b)
#define MAX_LENGTH 32
-static void
+static gboolean
append_bookmarks_menu (EphyTopicAction *action, GtkWidget *menu, EphyNode *node, gboolean show_empty)
{
EphyFaviconCache *cache;
@@ -234,6 +237,8 @@ append_bookmarks_menu (EphyTopicAction *action, GtkWidget *menu, EphyNode *node,
gtk_widget_set_sensitive (item, FALSE);
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ return FALSE;
}
else
{
@@ -293,16 +298,61 @@ append_bookmarks_menu (EphyTopicAction *action, GtkWidget *menu, EphyNode *node,
g_list_free (node_list);
}
+
+ return TRUE;
+}
+
+static void
+open_in_tabs_activate_cb (GtkWidget *menu, EphyTopicAction *action)
+{
+ GList *uri_list = NULL;
+ GPtrArray *children;
+ int i;
+
+ children = ephy_node_get_children (action->priv->topic_node);
+ for (i = 0; i < children->len; i++)
+ {
+ GnomeVFSURI *uri;
+ const char *address;
+ EphyNode *child;
+
+ child = g_ptr_array_index (children, i);
+ address = ephy_node_get_property_string
+ (child, EPHY_NODE_BMK_PROP_LOCATION);
+ uri = gnome_vfs_uri_new (address);
+ uri_list = g_list_append (uri_list, uri);
+ }
+
+ g_signal_emit (action, ephy_topic_action_signals[OPEN_IN_TABS],
+ 0, uri_list);
+ gnome_vfs_uri_list_free (uri_list);
}
static GtkWidget *
build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
{
GtkWidget *menu;
+ gboolean empty;
menu = gtk_menu_new ();
- append_bookmarks_menu (action, menu, node, TRUE);
+ empty = append_bookmarks_menu (action, menu, node, TRUE);
+
+ if (empty)
+ {
+ GtkWidget *item;
+
+ item = gtk_separator_menu_item_new ();
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_mnemonic (_("_Open in Tabs"));
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (open_in_tabs_activate_cb), action);
+ }
return menu;
}
@@ -341,18 +391,19 @@ sort_topics (gconstpointer a, gconstpointer b)
}
static GtkWidget *
-build_topics_menu (EphyTopicAction *action, EphyNode *node)
+build_topics_menu (EphyTopicAction *action)
{
GtkWidget *menu, *item;
GPtrArray *children;
int i;
EphyBookmarks *bookmarks;
- EphyNode *all, *uncategorized;
+ EphyNode *all, *uncategorized, *node;
EphyNodePriority priority;
GList *node_list = NULL, *l = NULL;
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
all = ephy_bookmarks_get_bookmarks (bookmarks);
+ node = ephy_bookmarks_get_keywords (bookmarks);
menu = gtk_menu_new ();
@@ -406,22 +457,13 @@ build_topics_menu (EphyTopicAction *action, EphyNode *node)
static GtkWidget *
build_menu (EphyTopicAction *action)
{
- EphyNode *node;
- EphyBookmarks *bookmarks;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
-
if (action->priv->topic_id == BOOKMARKS_NODE_ID)
{
- LOG ("Build all bookmarks crap menu")
-
- node = ephy_bookmarks_get_keywords (bookmarks);
- return build_topics_menu (action, node);
+ return build_topics_menu (action);
}
else
{
- node = ephy_bookmarks_get_from_id (bookmarks, action->priv->topic_id);
- return build_bookmarks_menu (action, node);
+ return build_bookmarks_menu (action, action->priv->topic_node);
}
}
@@ -504,19 +546,32 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
}
static void
+ephy_topic_action_set_topic_id (EphyTopicAction *action, gulong id)
+{
+ EphyBookmarks *bookmarks;
+ EphyNode *node;
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ node = ephy_bookmarks_get_from_id (bookmarks, id);
+
+ action->priv->topic_node = node;
+ action->priv->topic_id = id;
+}
+
+static void
ephy_topic_action_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- EphyTopicAction *bmk;
+ EphyTopicAction *topic;
- bmk = EPHY_TOPIC_ACTION (object);
+ topic = EPHY_TOPIC_ACTION (object);
switch (prop_id)
{
case PROP_TOPIC_ID:
- bmk->priv->topic_id = g_value_get_int (value);
+ ephy_topic_action_set_topic_id (topic, g_value_get_int (value));
break;
}
}
@@ -566,6 +621,17 @@ ephy_topic_action_class_init (EphyTopicActionClass *class)
1,
G_TYPE_STRING);
+ ephy_topic_action_signals[OPEN_IN_TABS] =
+ g_signal_new ("open_in_tabs",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EphyTopicActionClass, go_location),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
g_object_class_install_property (object_class,
PROP_TOPIC_ID,
g_param_spec_int ("topic_id",
diff --git a/src/bookmarks/ephy-topic-action.h b/src/bookmarks/ephy-topic-action.h
index b0a462c50..6a74d1238 100644
--- a/src/bookmarks/ephy-topic-action.h
+++ b/src/bookmarks/ephy-topic-action.h
@@ -47,7 +47,8 @@ struct _EphyTopicActionClass
{
GtkActionClass parent_class;
- void (*go_location) (EphyTopicAction *action, char *location);
+ void (*go_location) (EphyTopicAction *action, char *location);
+ void (*open_in_tabs) (EphyTopicAction *action, GList *uri_list);
};
GType ephy_topic_action_get_type (void);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 9913a2170..098624988 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2627,7 +2627,6 @@ ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, GList *uri_list)
{
EphyEmbed *embed = NULL;
GList *l;
- gchar *url = NULL;
guint num = 0;
GnomeVFSURI *uri;
@@ -2640,6 +2639,8 @@ ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, GList *uri_list)
l = uri_list;
while (l != NULL && num < INSANE_NUMBER_OF_URLS)
{
+ gchar *url = NULL;
+
uri = (GnomeVFSURI*) l->data;
url = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);