aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-window.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-12-24 08:21:16 +0800
committerChristian Persch <chpe@src.gnome.org>2004-12-24 08:21:16 +0800
commitd127ec47856ee69466b909af12e5f1020a12cb15 (patch)
treee8c6dcbd55f1b143983b73878a9177883ac352e6 /src/ephy-window.c
parent93079ee8ea5a7a2e89d4842c9c4cad71724a99f4 (diff)
downloadgsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar
gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar.gz
gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar.bz2
gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar.lz
gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar.xz
gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar.zst
gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.zip
A src/ephy-home-action.c: (ephy_home_action_activate),
2004-12-24 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-marshal.list: * src/Makefile.am: * src/bookmarks/ephy-bookmark-action.c: (ephy_bookmark_action_get_type), (create_tool_item), (open_in_tab_activate_cb), (open_in_window_activate_cb), (activate_cb), (connect_proxy), (ephy_bookmark_action_class_init): * src/bookmarks/ephy-bookmark-action.h: * src/bookmarks/ephy-bookmarks-menu.c: (ephy_bookmarks_menu_get_type), (add_action_for_bookmark), (ephy_bookmarks_menu_class_init): * src/bookmarks/ephy-bookmarks-menu.h: * src/bookmarks/ephy-bookmarksbar.c: (ephy_bookmarksbar_get_type), (ephy_bookmarksbar_action_request): * src/bookmarks/ephy-favorites-menu.c: (ephy_favorites_menu_get_type), (ephy_favorites_menu_rebuild): * src/bookmarks/ephy-favorites-menu.h: * src/bookmarks/ephy-topic-action.c: (ephy_topic_action_get_type), (menu_activate_cb), (open_in_tabs_activate_cb), (ephy_topic_action_class_init): * src/bookmarks/ephy-topic-action.h: A src/ephy-home-action.c: (ephy_home_action_activate), (ephy_home_action_class_init), (ephy_home_action_get_type): A src/ephy-home-action.h: A src/ephy-link-action.c: (ephy_link_action_get_type): A src/ephy-link-action.h: A src/ephy-link.c: (ephy_link_flags_get_type), (ephy_link_base_init), (ephy_link_get_type), (ephy_link_open): A src/ephy-link.h: * src/ephy-location-action.c: (ephy_location_action_get_type), (action_activated_cb), (location_url_activate_cb), (connect_proxy), (disconnect_proxy), (ephy_location_action_class_init): * src/ephy-location-action.h: * src/ephy-navigation-action.c: (ephy_navigation_action_get_type), (activate_back_or_forward_menu_item_cb), (activate_up_menu_item_cb), (build_back_or_forward_menu), (build_up_menu): * src/ephy-navigation-action.h: * src/ephy-shell.c: (ephy_shell_new_tab): * src/ephy-window.c: (setup_ui_manager), (open_link_cb), (ephy_window_init): * src/toolbar.c: (toolbar_get_type), (toolbar_setup_actions): * src/window-commands.c: * src/window-commands.h: Consolidate link opening in one place by introducing an EphyLink interface which bookmarks, topics, navigation, location, home, toolbars, bookmarks menu and favourites menu implement, forwarding the link opening to the window.
Diffstat (limited to 'src/ephy-window.c')
-rw-r--r--src/ephy-window.c97
1 files changed, 67 insertions, 30 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 238bf10d7..6d624ab54 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -50,6 +50,7 @@
#include "ephy-stock-icons.h"
#include "ephy-extension.h"
#include "ephy-favicon-cache.h"
+#include "ephy-link.h"
#include "ephy-gui.h"
#include <string.h>
@@ -216,9 +217,6 @@ static GtkActionEntry ephy_menu_entries [] = {
{ "GoUp", GTK_STOCK_GO_UP, N_("_Up"), "<alt>Up",
N_("Go up one level"),
G_CALLBACK (window_cmd_go_up) },
- { "GoHome", GTK_STOCK_HOME, N_("_Home"), "<alt>Home",
- N_("Go to the home page"),
- G_CALLBACK (window_cmd_go_home) },
{ "GoLocation", NULL, N_("_Location..."), "<control>L",
N_("Go to a specified location"),
G_CALLBACK (window_cmd_go_location) },
@@ -1131,7 +1129,6 @@ setup_ui_manager (EphyWindow *window)
GtkActionGroup *action_group;
GtkAction *action;
GtkUIManager *manager;
- GError *err = NULL;
window->priv->main_vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (window->priv->main_vbox);
@@ -1176,8 +1173,6 @@ setup_ui_manager (EphyWindow *window)
action = gtk_action_group_get_action (action_group, "EditFind");
g_object_set (action, "is_important", TRUE, NULL);
- action = gtk_action_group_get_action (action_group, "GoHome");
- g_object_set (action, "is_important", TRUE, NULL);
action = gtk_action_group_get_action (action_group, "GoBookmarks");
g_object_set (action, "is_important", TRUE, NULL);
@@ -1195,14 +1190,6 @@ setup_ui_manager (EphyWindow *window)
g_signal_connect (manager, "add_widget", G_CALLBACK (add_widget), window);
gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (manager));
-
- gtk_ui_manager_add_ui_from_file
- (manager, ephy_file ("epiphany-ui.xml"), &err);
- if (err != NULL)
- {
- g_warning ("Could not merge epiphany-ui.xml: %s", err->message);
- g_clear_error (&err);
- }
}
static void
@@ -2420,13 +2407,48 @@ action_request_forward_cb (GObject *toolbar,
g_signal_emit_by_name (bookmarksbar, "action_request", name);
}
-static void
-open_bookmark_cb (EphyBookmarksMenu *menu,
- const char *location,
- gboolean open_in_new,
- EphyWindow *window)
+static EphyTab *
+open_link_cb (EphyLink *link,
+ const char *address,
+ EphyTab *tab,
+ EphyLinkFlags flags,
+ EphyWindow *window)
{
- ephy_window_load_url (window, location);
+ EphyTab *new_tab;
+
+ g_return_val_if_fail (address != NULL, NULL);
+
+ if (flags != 0)
+ {
+ EphyNewTabFlags ntflags = EPHY_NEW_TAB_OPEN_PAGE;
+
+ if (flags & EPHY_LINK_JUMP_TO)
+ {
+ ntflags |= EPHY_NEW_TAB_JUMP;
+ }
+ if (flags & EPHY_LINK_NEW_WINDOW)
+ {
+ ntflags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
+ }
+ else
+ {
+ ntflags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW;
+ }
+
+ new_tab = ephy_shell_new_tab
+ (ephy_shell,
+ tab ? EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab)))
+ : window,
+ tab ? tab : ephy_window_get_active_tab (window),
+ address, ntflags);
+ }
+ else
+ {
+ ephy_window_load_url (window, address);
+ new_tab = ephy_window_get_active_tab (window);
+ }
+
+ return new_tab;
}
static void
@@ -2435,6 +2457,7 @@ ephy_window_init (EphyWindow *window)
EphyExtension *manager;
EphyEmbedSingle *single;
EggToolbarsModel *model;
+ GError *error = NULL;
LOG ("EphyWindow initialising %p", window)
@@ -2464,16 +2487,6 @@ ephy_window_init (EphyWindow *window)
window->priv->help_message_cid = gtk_statusbar_get_context_id
(GTK_STATUSBAR (window->priv->statusbar), "help_message");
- /* Initialize the menus */
- window->priv->tabs_menu = ephy_tabs_menu_new (window);
- window->priv->fav_menu = ephy_favorites_menu_new (window);
- window->priv->enc_menu = ephy_encoding_menu_new (window);
-
- window->priv->bmk_menu = ephy_bookmarks_menu_new (window->priv->manager,
- BOOKMARKS_MENU_PATH);
- g_signal_connect (window->priv->bmk_menu, "open",
- G_CALLBACK (open_bookmark_cb), window);
-
/* get the toolbars model *before* getting the bookmarksbar model
* (via ephy_bookmarsbar_new()), so that the toolbars model is
* instantiated *before* the bookmarksbarmodel, to make forwarding
@@ -2483,11 +2496,35 @@ ephy_window_init (EphyWindow *window)
/* create the toolbars */
window->priv->toolbar = toolbar_new (window);
+ g_signal_connect (window->priv->toolbar, "open-link",
+ G_CALLBACK (open_link_cb), window);
window->priv->bookmarksbar = ephy_bookmarksbar_new (window);
+ g_signal_connect (window->priv->bookmarksbar, "open-link",
+ G_CALLBACK (open_link_cb), window);
g_signal_connect_swapped (window->priv->toolbar, "activation-finished",
G_CALLBACK (sync_chromes_visibility), window);
+ /* now load the UI definition */
+ gtk_ui_manager_add_ui_from_file
+ (window->priv->manager, ephy_file ("epiphany-ui.xml"), &error);
+ if (error != NULL)
+ {
+ g_warning ("Could not merge epiphany-ui.xml: %s", error->message);
+ g_error_free (error);
+ }
+
+ /* Initialize the menus */
+ window->priv->tabs_menu = ephy_tabs_menu_new (window);
+ window->priv->enc_menu = ephy_encoding_menu_new (window);
+ window->priv->fav_menu = ephy_favorites_menu_new (window);
+ g_signal_connect (window->priv->fav_menu, "open-link",
+ G_CALLBACK (open_link_cb), window);
+ window->priv->bmk_menu = ephy_bookmarks_menu_new (window->priv->manager,
+ BOOKMARKS_MENU_PATH);
+ g_signal_connect (window->priv->bmk_menu, "open-link",
+ G_CALLBACK (open_link_cb), window);
+
/* forward the toolbar's action_request signal to the bookmarks toolbar,
* so the user can also have bookmarks on the normal toolbar
*/