diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-12-24 08:21:16 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-12-24 08:21:16 +0800 |
commit | d127ec47856ee69466b909af12e5f1020a12cb15 (patch) | |
tree | e8c6dcbd55f1b143983b73878a9177883ac352e6 | |
parent | 93079ee8ea5a7a2e89d4842c9c4cad71724a99f4 (diff) | |
download | gsoc2013-epiphany-d127ec47856ee69466b909af12e5f1020a12cb15.tar.gz 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.
28 files changed, 849 insertions, 468 deletions
@@ -1,5 +1,55 @@ 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. + +2004-12-24 Christian Persch <chpe@cvs.gnome.org> + * embed/ephy-embed.c: (ephy_embed_base_init): * lib/ephy-marshal.list: diff --git a/lib/egg/egg-toolbars-model.h b/lib/egg/egg-toolbars-model.h index 11d9bbe8b..0ea3c55d4 100755 --- a/lib/egg/egg-toolbars-model.h +++ b/lib/egg/egg-toolbars-model.h @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ #ifndef EGG_TOOLBARS_MODEL_H @@ -25,7 +27,6 @@ G_BEGIN_DECLS - #define EGG_TYPE_TOOLBARS_MODEL (egg_toolbars_model_get_type ()) #define EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModel)) #define EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass)) diff --git a/lib/ephy-marshal.list b/lib/ephy-marshal.list index 57d064177..07456188c 100644 --- a/lib/ephy-marshal.list +++ b/lib/ephy-marshal.list @@ -1,8 +1,8 @@ -INT:STRING BOOLEAN:OBJECT -BOOLEAN:STRING, STRING +BOOLEAN:STRING,STRING BOOLEAN:VOID OBJECT:FLAGS +OBJECT:OBJECT,STRING,FLAGS VOID:ENUM VOID:ENUM,INT,BOOLEAN VOID:INT,INT diff --git a/src/Makefile.am b/src/Makefile.am index a35aacfed..526075ba6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,64 +23,70 @@ $(CORBA_SOURCE): $(idls) $(ORBIT_IDL) headerdir = $(prefix)/include/epiphany-@EPIPHANY_MAJOR@/epiphany header_DATA = $(INST_H_FILES) -NOINST_H_FILES = \ - ephy-automation.h \ - ephy-encoding-dialog.h \ - ephy-encoding-menu.h \ - ephy-favicon-action.h \ - ephy-go-action.h \ - ephy-history-window.h \ - ephy-location-action.h \ - ephy-navigation-action.h \ - ephy-tabs-menu.h \ - ephy-toolbars-model.h \ - pdm-dialog.h \ - popup-commands.h \ - prefs-dialog.h \ - ppview-toolbar.h \ - toolbar.h \ +NOINST_H_FILES = \ + ephy-automation.h \ + ephy-encoding-dialog.h \ + ephy-encoding-menu.h \ + ephy-favicon-action.h \ + ephy-go-action.h \ + ephy-history-window.h \ + ephy-home-action.h \ + ephy-link.h \ + ephy-link-action.h \ + ephy-location-action.h \ + ephy-navigation-action.h \ + ephy-tabs-menu.h \ + ephy-toolbars-model.h \ + pdm-dialog.h \ + popup-commands.h \ + prefs-dialog.h \ + ppview-toolbar.h \ + toolbar.h \ window-commands.h -INST_H_FILES = \ - ephy-extension.h \ - ephy-extensions-manager.h \ - ephy-notebook.h \ - ephy-session.h \ - ephy-shell.h \ - ephy-statusbar.h \ - ephy-tab.h \ +INST_H_FILES = \ + ephy-extension.h \ + ephy-extensions-manager.h \ + ephy-notebook.h \ + ephy-session.h \ + ephy-shell.h \ + ephy-statusbar.h \ + ephy-tab.h \ ephy-window.h -libephymain_la_SOURCES = \ - $(CORBA_SOURCE) \ - ephy-automation.c \ - ephy-completion-model.c \ - ephy-completion-model.h \ - ephy-encoding-dialog.c \ - ephy-encoding-menu.c \ - ephy-extension.c \ - ephy-extensions-manager.c \ - ephy-favicon-action.c \ - ephy-go-action.c \ - ephy-history-window.c \ - ephy-location-action.c \ - ephy-navigation-action.c \ - ephy-notebook.c \ - ephy-session.c \ - ephy-shell.c \ - ephy-statusbar.c \ - ephy-tab.c \ - ephy-tab.h \ - ephy-tabs-menu.c \ - ephy-toolbars-model.c \ - ephy-window.c \ - pdm-dialog.c \ - popup-commands.c \ - prefs-dialog.c \ - ppview-toolbar.c \ - toolbar.c \ - window-commands.c \ - $(INST_H_FILES) \ +libephymain_la_SOURCES = \ + $(CORBA_SOURCE) \ + ephy-automation.c \ + ephy-completion-model.c \ + ephy-completion-model.h \ + ephy-encoding-dialog.c \ + ephy-encoding-menu.c \ + ephy-extension.c \ + ephy-extensions-manager.c \ + ephy-favicon-action.c \ + ephy-go-action.c \ + ephy-home-action.c \ + ephy-history-window.c \ + ephy-link.c \ + ephy-link-action.c \ + ephy-location-action.c \ + ephy-navigation-action.c \ + ephy-notebook.c \ + ephy-session.c \ + ephy-shell.c \ + ephy-statusbar.c \ + ephy-tab.c \ + ephy-tab.h \ + ephy-tabs-menu.c \ + ephy-toolbars-model.c \ + ephy-window.c \ + pdm-dialog.c \ + popup-commands.c \ + prefs-dialog.c \ + ppview-toolbar.c \ + toolbar.c \ + window-commands.c \ + $(INST_H_FILES) \ $(NOINST_H_FILES) libephymain_la_CPPFLAGS = \ @@ -136,7 +142,5 @@ epiphany_LDADD = \ BUILT_SOURCES = $(CORBA_SOURCE) -CLEANFILES = $(CORBA_SOURCE) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) +CLEANFILES = $(BUILT_SOURCES) +DISTCLEANFILES = $(BUILT_SOURCES) diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index 05975cc2c..90883cf36 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -21,19 +21,34 @@ #include "config.h" -#include <glib/gi18n.h> -#include <libgnomevfs/gnome-vfs-uri.h> -#include <gtk/gtktoolitem.h> - #include "ephy-bookmark-action.h" -#include "ephy-marshal.h" -#include "ephy-dnd.h" +#include "ephy-bookmarksbar-model.h" #include "ephy-bookmarksbar.h" #include "ephy-bookmarks.h" +#include "ephy-link.h" +#include "ephy-dnd.h" #include "ephy-favicon-cache.h" #include "ephy-shell.h" -#include "ephy-debug.h" #include "ephy-gui.h" +#include "ephy-debug.h" + +#include <glib/gi18n.h> +#include <gtk/gtkwidget.h> +#include <gtk/gtkhbox.h> +#include <gtk/gtklabel.h> +#include <gtk/gtkbutton.h> +#include <gtk/gtkentry.h> +#include <gtk/gtkstock.h> +#include <gtk/gtkimage.h> +#include <gtk/gtkmenuitem.h> +#include <gtk/gtkimagemenuitem.h> +#include <gtk/gtkseparatormenuitem.h> +#include <gtk/gtkmenushell.h> +#include <gtk/gtkmenu.h> +#include <gtk/gtktoolitem.h> +#include <gtk/gtktoolbar.h> +#include <gtk/gtkmain.h> +#include <libgnomevfs/gnome-vfs-uri.h> #include <string.h> @@ -52,7 +67,7 @@ static GtkTargetEntry drag_targets[] = }; static int n_drag_targets = G_N_ELEMENTS (drag_targets); -struct EphyBookmarkActionPrivate +struct _EphyBookmarkActionPrivate { EphyNode *node; gboolean smart_url; @@ -72,17 +87,8 @@ enum PROP_ICON }; -enum -{ - OPEN, - OPEN_IN_TAB, - LAST_SIGNAL -}; - static GObjectClass *parent_class = NULL; -static guint signals[LAST_SIGNAL] = { 0 }; - GType ephy_bookmark_action_get_type (void) { @@ -103,10 +109,11 @@ ephy_bookmark_action_get_type (void) (GInstanceInitFunc) ephy_bookmark_action_init, }; - type = g_type_register_static (GTK_TYPE_ACTION, + type = g_type_register_static (EPHY_TYPE_LINK_ACTION, "EphyBookmarkAction", &type_info, 0); } + return type; } @@ -117,7 +124,7 @@ create_tool_item (GtkAction *action) LOG ("Creating tool item for action %p", action) - item = (* GTK_ACTION_CLASS (parent_class)->create_tool_item) (action); + item = GTK_ACTION_CLASS (parent_class)->create_tool_item (action); hbox = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox); @@ -298,7 +305,8 @@ ephy_bookmark_action_sync_label (GtkAction *gaction, } static void -open_in_tab_activate_cb (GtkWidget *widget, EphyBookmarkAction *action) +open_in_tab_activate_cb (GtkWidget *widget, + EphyBookmarkAction *action) { const char *url; @@ -306,7 +314,8 @@ open_in_tab_activate_cb (GtkWidget *widget, EphyBookmarkAction *action) url = ephy_node_get_property_string (action->priv->node, EPHY_NODE_BMK_PROP_LOCATION); - g_signal_emit (action, signals[OPEN_IN_TAB], 0, url, FALSE); + ephy_link_open (EPHY_LINK (action), url, NULL, + EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO); } static void @@ -318,7 +327,8 @@ open_in_window_activate_cb (GtkWidget *widget, EphyBookmarkAction *action) url = ephy_node_get_property_string (action->priv->node, EPHY_NODE_BMK_PROP_LOCATION); - g_signal_emit (action, signals[OPEN_IN_TAB], 0, url, TRUE); + + ephy_link_open (EPHY_LINK (action), url, NULL, EPHY_LINK_NEW_WINDOW); } static void @@ -369,14 +379,8 @@ activate_cb (GtkWidget *widget, } } - if (ephy_gui_is_middle_click ()) - { - g_signal_emit (action, signals[OPEN_IN_TAB], 0, location, FALSE); - } - else - { - g_signal_emit (action, signals[OPEN], 0, location); - } + ephy_link_open (EPHY_LINK (action), location, NULL, + ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0); g_free (location); g_free (text); @@ -665,7 +669,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) LOG ("Connecting action %p to proxy %p", action, proxy) - (* GTK_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy); + GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy); ephy_bookmark_action_sync_icon (action, NULL, proxy); g_signal_connect_object (action, "notify::icon", @@ -843,29 +847,6 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class) object_class->set_property = ephy_bookmark_action_set_property; object_class->get_property = ephy_bookmark_action_get_property; - signals[OPEN] = - g_signal_new ("open", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyBookmarkActionClass, open), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING); - - signals[OPEN_IN_TAB] = - g_signal_new ("open_in_tab", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyBookmarkActionClass, open_in_tab), - NULL, NULL, - ephy_marshal_VOID__STRING_BOOLEAN, - G_TYPE_NONE, - 2, - G_TYPE_STRING, - G_TYPE_BOOLEAN); - g_object_class_install_property (object_class, PROP_BOOKMARK, g_param_spec_pointer ("bookmark", diff --git a/src/bookmarks/ephy-bookmark-action.h b/src/bookmarks/ephy-bookmark-action.h index 0866e1889..01d2c65d3 100644 --- a/src/bookmarks/ephy-bookmark-action.h +++ b/src/bookmarks/ephy-bookmark-action.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,24 +22,25 @@ #ifndef EPHY_BOOKMARK_ACTION_H #define EPHY_BOOKMARK_ACTION_H -#include <gtk/gtk.h> -#include <gtk/gtkaction.h> +#include "ephy-link-action.h" #include "ephy-node.h" -#define EPHY_TYPE_BOOKMARK_ACTION (ephy_bookmark_action_get_type ()) -#define EPHY_BOOKMARK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkAction)) -#define EPHY_BOOKMARK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionClass)) -#define EPHY_IS_BOOKMARK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_BOOKMARK_ACTION)) -#define EPHY_IS_BOOKMARK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_BOOKMARK_ACTION)) -#define EPHY_BOOKMARK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionClass)) +G_BEGIN_DECLS -typedef struct _EphyBookmarkAction EphyBookmarkAction; -typedef struct _EphyBookmarkActionClass EphyBookmarkActionClass; -typedef struct EphyBookmarkActionPrivate EphyBookmarkActionPrivate; +#define EPHY_TYPE_BOOKMARK_ACTION (ephy_bookmark_action_get_type ()) +#define EPHY_BOOKMARK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkAction)) +#define EPHY_BOOKMARK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionClass)) +#define EPHY_IS_BOOKMARK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_BOOKMARK_ACTION)) +#define EPHY_IS_BOOKMARK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_BOOKMARK_ACTION)) +#define EPHY_BOOKMARK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionClass)) + +typedef struct _EphyBookmarkAction EphyBookmarkAction; +typedef struct _EphyBookmarkActionPrivate EphyBookmarkActionPrivate; +typedef struct _EphyBookmarkActionClass EphyBookmarkActionClass; struct _EphyBookmarkAction { - GtkAction parent; + EphyLinkAction parent_instance; /*< private >*/ EphyBookmarkActionPrivate *priv; @@ -46,13 +48,7 @@ struct _EphyBookmarkAction struct _EphyBookmarkActionClass { - GtkActionClass parent_class; - - void (*open) (EphyBookmarkAction *action, - char *address); - void (*open_in_tab) (EphyBookmarkAction *action, - char *address, - gboolean new_window); + EphyLinkActionClass parent_class; }; GType ephy_bookmark_action_get_type (void); @@ -60,4 +56,6 @@ GType ephy_bookmark_action_get_type (void); GtkAction *ephy_bookmark_action_new (const char *name, EphyNode *node); -#endif +G_END_DECLS + +#endif /* EPHY_BOOKMARK_ACTION_H */ diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c index dcb5a7eb5..48bf8b8bf 100644 --- a/src/bookmarks/ephy-bookmarks-menu.c +++ b/src/bookmarks/ephy-bookmarks-menu.c @@ -23,9 +23,9 @@ #include "ephy-bookmarks-menu.h" #include "ephy-bookmark-action.h" +#include "ephy-link.h" #include "ephy-shell.h" #include "ephy-node-common.h" -#include "ephy-marshal.h" #include "ephy-gui.h" #include "ephy-debug.h" @@ -68,6 +68,8 @@ struct _EphyBookmarksMenuPrivate #define FOLDER_VERB_FORMAT "Fld%x%x" #define FOLDER_VERB_FORMAT_LENGTH strlen (FOLDER_VERB_FORMAT) + 2 * MAXLEN + 1 +#define BMK_ACCEL_PATH_PREFIX "<Actions>/BmkActions/" + #define GAZILLION 200 #define UPDATE_DELAY 5000 /* ms */ #define LABEL_WIDTH_CHARS 32 @@ -79,14 +81,6 @@ enum PROP_UI_MANAGER }; -enum -{ - OPEN, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - static void ephy_bookmarks_menu_class_init (EphyBookmarksMenuClass *klass); static void ephy_bookmarks_menu_init (EphyBookmarksMenu *menu); @@ -111,10 +105,19 @@ ephy_bookmarks_menu_get_type (void) 0, /* n_preallocs */ (GInstanceInitFunc) ephy_bookmarks_menu_init }; + static const GInterfaceInfo link_info = + { + NULL, + NULL, + NULL + }; type = g_type_register_static (G_TYPE_OBJECT, "EphyBookmarksMenu", &our_info, 0); + g_type_add_interface_static (type, + EPHY_TYPE_LINK, + &link_info); } return type; @@ -184,26 +187,6 @@ ephy_bookmarks_menu_clean (EphyBookmarksMenu *menu) } static void -open_bookmark_cb (GtkAction *action, - const char *location, - EphyBookmarksMenu *menu) -{ - g_signal_emit (menu, signals[OPEN], 0, location, - ephy_gui_is_middle_click ()); -} - -static void -open_bookmark_in_tab_cb (GtkAction *action, - const char *location, - gboolean dummy, - EphyBookmarksMenu *menu) -{ - g_signal_emit (menu, signals[OPEN], 0, location, TRUE); -} - -#define BMK_ACCEL_PATH_PREFIX "<Actions>/BmkActions/" - -static void add_action_for_bookmark (EphyBookmarksMenu *menu, EphyNode *bmk) { @@ -223,10 +206,8 @@ add_action_for_bookmark (EphyBookmarksMenu *menu, gtk_action_set_accel_path (action, apath); - g_signal_connect (action, "open", - G_CALLBACK (open_bookmark_cb), menu); - g_signal_connect (action, "open_in_tab", - G_CALLBACK (open_bookmark_in_tab_cb), menu); + g_signal_connect_swapped (action, "open-link", + G_CALLBACK (ephy_link_open), menu); gtk_action_group_add_action (menu->priv->bmk_actions, action); g_object_unref (action); @@ -798,18 +779,6 @@ ephy_bookmarks_menu_class_init (EphyBookmarksMenuClass *klass) object_class->set_property = ephy_bookmarks_menu_set_property; object_class->get_property = ephy_bookmarks_menu_get_property; - signals[OPEN] = - g_signal_new ("open", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyBookmarksMenuClass, open), - NULL, NULL, - ephy_marshal_VOID__STRING_BOOLEAN, - G_TYPE_NONE, - 2, - G_TYPE_STRING, - G_TYPE_BOOLEAN); - g_object_class_install_property (object_class, PROP_PATH, g_param_spec_string ("path", diff --git a/src/bookmarks/ephy-bookmarks-menu.h b/src/bookmarks/ephy-bookmarks-menu.h index b22e55a7f..82a828b50 100644 --- a/src/bookmarks/ephy-bookmarks-menu.h +++ b/src/bookmarks/ephy-bookmarks-menu.h @@ -1,5 +1,7 @@ /* * Copyright (C) 2002 Ricardo Fernández Pascual + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,16 +36,12 @@ G_BEGIN_DECLS #define EPHY_BOOKMARKS_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_BOOKMARKS_MENU, EphyBookmarksMenuClass)) typedef struct _EphyBookmarksMenu EphyBookmarksMenu; -typedef struct _EphyBookmarksMenuClass EphyBookmarksMenuClass; typedef struct _EphyBookmarksMenuPrivate EphyBookmarksMenuPrivate; +typedef struct _EphyBookmarksMenuClass EphyBookmarksMenuClass; struct _EphyBookmarksMenuClass { GObjectClass parent_class; - - void (*open) (EphyBookmarksMenu *menu, - const char *address, - gboolean open_in_new); }; struct _EphyBookmarksMenu diff --git a/src/bookmarks/ephy-bookmarksbar.c b/src/bookmarks/ephy-bookmarksbar.c index dce1a15be..e9af82f12 100644 --- a/src/bookmarks/ephy-bookmarksbar.c +++ b/src/bookmarks/ephy-bookmarksbar.c @@ -27,6 +27,7 @@ #include "ephy-bookmarks.h" #include "ephy-shell.h" #include "ephy-topic-action.h" +#include "ephy-link.h" #include "ephy-bookmark-action.h" #include "ephy-new-bookmark.h" #include "ephy-stock-icons.h" @@ -87,61 +88,24 @@ ephy_bookmarksbar_get_type (void) (GInstanceInitFunc) ephy_bookmarksbar_init }; + static const GInterfaceInfo link_info = + { + NULL, + NULL, + NULL + }; + type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR, "EphyBookmarksBar", &our_info, 0); + g_type_add_interface_static (type, + EPHY_TYPE_LINK, + &link_info); } return type; } -static void -open_in_tabs_cb (GtkAction *action, GList *uri_list, EphyBookmarksBar *toolbar) -{ - EphyTab *tab; - EphyWindow *window; - GList *l = uri_list; - - g_return_if_fail (l != NULL); - - tab = ephy_shell_new_tab (ephy_shell, NULL, NULL, l->data, - EPHY_NEW_TAB_OPEN_PAGE); - g_return_if_fail (tab != NULL); - - window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))); - g_return_if_fail (window != NULL); - - for (l = l->next; l != NULL; l = l->next) - { - ephy_shell_new_tab (ephy_shell, window, NULL, l->data, - EPHY_NEW_TAB_IN_EXISTING_WINDOW | - EPHY_NEW_TAB_OPEN_PAGE | - EPHY_NEW_TAB_APPEND_LAST); - } -} - -static void -bookmark_open_in_tab_cb (GtkAction *action, char *location, - gboolean new_window, EphyBookmarksBar *toolbar) -{ - EphyNewTabFlags flags = EPHY_NEW_TAB_OPEN_PAGE | - EPHY_NEW_TAB_JUMP; - - if (!new_window) - { - flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW; - } - - ephy_shell_new_tab (ephy_shell, toolbar->priv->window, NULL, - location, flags); -} - -static void -bookmark_open_cb (GtkAction *action, char *location, EphyBookmarksBar *toolbar) -{ - ephy_window_load_url (toolbar->priv->window, location); -} - static gboolean remove_action_from_model (EggToolbarsModel *model, const char *name) { @@ -231,9 +195,6 @@ ephy_bookmarksbar_action_request (EggEditableToolbar *eggtoolbar, if (ephy_node_has_child (topics, node)) { action = ephy_topic_action_new (name, node); - - g_signal_connect (action, "open_in_tabs", - G_CALLBACK (open_in_tabs_cb), toolbar); } else if (ephy_node_has_child (bmks, node)) { @@ -242,10 +203,8 @@ ephy_bookmarksbar_action_request (EggEditableToolbar *eggtoolbar, g_return_if_fail (action != NULL); - g_signal_connect (action, "open", - G_CALLBACK (bookmark_open_cb), toolbar); - g_signal_connect (action, "open_in_tab", - G_CALLBACK (bookmark_open_in_tab_cb), toolbar); + g_signal_connect_swapped (action, "open-link", + G_CALLBACK (ephy_link_open), toolbar); gtk_action_group_add_action (toolbar->priv->action_group, action); g_object_unref (action); diff --git a/src/bookmarks/ephy-favorites-menu.c b/src/bookmarks/ephy-favorites-menu.c index b0dc3c631..8b1988633 100644 --- a/src/bookmarks/ephy-favorites-menu.c +++ b/src/bookmarks/ephy-favorites-menu.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2002 Ricardo Fernández Pascual - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,9 +24,12 @@ #include "ephy-favorites-menu.h" #include "ephy-bookmark-action.h" +#include "ephy-link.h" #include "ephy-shell.h" #include "ephy-debug.h" +#include <gtk/gtkmenuitem.h> +#include <gtk/gtklabel.h> #include <gtk/gtkuimanager.h> #include <glib/gprintf.h> @@ -73,11 +77,21 @@ ephy_favorites_menu_get_type (void) 0, /* n_preallocs */ (GInstanceInitFunc) ephy_favorites_menu_init }; + static const GInterfaceInfo link_info = + { + NULL, + NULL, + NULL + }; type = g_type_register_static (G_TYPE_OBJECT, "EphyFavoritesMenu", &our_info, 0); + g_type_add_interface_static (type, + EPHY_TYPE_LINK, + &link_info); } + return type; } @@ -102,12 +116,6 @@ ephy_favorites_menu_clean (EphyFavoritesMenu *menu) } static void -open_bookmark_cb (GtkAction *action, char *location, EphyWindow *window) -{ - ephy_window_load_url (window, location); -} - -static void connect_proxy_cb (GtkActionGroup *action_group, GtkAction *action, GtkWidget *proxy) @@ -166,8 +174,8 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *menu) gtk_action_set_accel_path (action, accel_path); gtk_action_group_add_action (p->action_group, action); g_object_unref (action); - g_signal_connect (action, "open", - G_CALLBACK (open_bookmark_cb), p->window); + g_signal_connect_swapped (action, "open-link", + G_CALLBACK (ephy_link_open), menu); gtk_ui_manager_add_ui (merge, p->ui_id, "/menubar/GoMenu", diff --git a/src/bookmarks/ephy-favorites-menu.h b/src/bookmarks/ephy-favorites-menu.h index 48c6fbd27..c399218b9 100644 --- a/src/bookmarks/ephy-favorites-menu.h +++ b/src/bookmarks/ephy-favorites-menu.h @@ -33,9 +33,9 @@ G_BEGIN_DECLS #define EPHY_IS_FAVORITES_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EPHY_TYPE_FAVORITES_MENU)) #define EPHY_FAVORITES_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_FAVORITES_MENU, EphyFavoritesMenuClass)) -typedef struct _EphyFavoritesMenu EphyFavoritesMenu; -typedef struct _EphyFavoritesMenuClass EphyFavoritesMenuClass; -typedef struct _EphyFavoritesMenuPrivate EphyFavoritesMenuPrivate; +typedef struct _EphyFavoritesMenu EphyFavoritesMenu; +typedef struct _EphyFavoritesMenuClass EphyFavoritesMenuClass; +typedef struct _EphyFavoritesMenuPrivate EphyFavoritesMenuPrivate; struct _EphyFavoritesMenuClass { diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c index eb57b48a6..1acdf797c 100644 --- a/src/bookmarks/ephy-topic-action.c +++ b/src/bookmarks/ephy-topic-action.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,24 +21,32 @@ #include "config.h" -#include <gtk/gtktoolitem.h> -#include <glib/gi18n.h> -#include <libgnomevfs/gnome-vfs-uri.h> -#include <string.h> - #include "ephy-topic-action.h" #include "ephy-node-common.h" #include "ephy-bookmarks.h" #include "ephy-bookmarksbar.h" +#include "ephy-link.h" #include "ephy-favicon-cache.h" #include "ephy-shell.h" -#include "ephy-debug.h" #include "ephy-dnd.h" #include "ephy-gui.h" -#include "ephy-marshal.h" +#include "ephy-debug.h" -static void ephy_topic_action_init (EphyTopicAction *action); -static void ephy_topic_action_class_init (EphyTopicActionClass *class); +#include <glib/gi18n.h> +#include <gtk/gtkwidget.h> +#include <gtk/gtkarrow.h> +#include <gtk/gtkhbox.h> +#include <gtk/gtklabel.h> +#include <gtk/gtkbutton.h> +#include <gtk/gtktogglebutton.h> +#include <gtk/gtkstock.h> +#include <gtk/gtkimage.h> +#include <gtk/gtkmenuitem.h> +#include <gtk/gtkimagemenuitem.h> +#include <gtk/gtkseparatormenuitem.h> +#include <gtk/gtkmain.h> +#include <libgnomevfs/gnome-vfs-uri.h> +#include <string.h> #define TOOLITEM_WIDTH_CHARS 24 #define MENUITEM_WIDTH_CHARS 32 @@ -66,18 +75,11 @@ enum PROP_TOPIC }; -enum -{ - OPEN, - OPEN_IN_TAB, - OPEN_IN_TABS, - LAST_SIGNAL -}; +static void ephy_topic_action_class_init (EphyTopicActionClass *class); +static void ephy_topic_action_init (EphyTopicAction *action); static GObjectClass *parent_class = NULL; -static guint ephy_topic_action_signals[LAST_SIGNAL] = { 0 }; - GType ephy_topic_action_get_type (void) { @@ -98,10 +100,11 @@ ephy_topic_action_get_type (void) (GInstanceInitFunc) ephy_topic_action_init, }; - type = g_type_register_static (GTK_TYPE_ACTION, + type = g_type_register_static (EPHY_TYPE_LINK_ACTION, "EphyTopicAction", &type_info, 0); } + return type; } @@ -163,16 +166,8 @@ menu_activate_cb (GtkWidget *item, GtkAction *action) location = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION); - if (ephy_gui_is_middle_click ()) - { - g_signal_emit (action, ephy_topic_action_signals[OPEN_IN_TAB], - 0, location, FALSE); - } - else - { - g_signal_emit (action, ephy_topic_action_signals[OPEN], - 0, location); - } + ephy_link_open (EPHY_LINK (action), location, NULL, + ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0); } static void @@ -337,8 +332,8 @@ static void open_in_tabs_activate_cb (GtkWidget *item, EphyTopicAction *action) { EphyNode *node; - GList *uri_list = NULL; GPtrArray *children; + EphyTab *tab = NULL; int i; node = g_object_get_data (G_OBJECT (item), TOPIC_NODE_DATA_KEY); @@ -353,13 +348,10 @@ open_in_tabs_activate_cb (GtkWidget *item, EphyTopicAction *action) child = g_ptr_array_index (children, i); address = ephy_node_get_property_string (child, EPHY_NODE_BMK_PROP_LOCATION); - uri_list = g_list_append (uri_list, g_strdup (address)); - } - g_signal_emit (action, ephy_topic_action_signals[OPEN_IN_TABS], - 0, uri_list); - g_list_foreach (uri_list, (GFunc)g_free, NULL); - g_list_free (uri_list); + tab = ephy_link_open (EPHY_LINK (action), address, tab, + tab ? EPHY_LINK_NEW_TAB : EPHY_LINK_NEW_WINDOW); + } } static int @@ -989,40 +981,6 @@ ephy_topic_action_class_init (EphyTopicActionClass *class) object_class->set_property = ephy_topic_action_set_property; object_class->get_property = ephy_topic_action_get_property; - ephy_topic_action_signals[OPEN] = - g_signal_new ("open", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyTopicActionClass, open), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING); - - ephy_topic_action_signals[OPEN_IN_TAB] = - g_signal_new ("open_in_tab", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyTopicActionClass, open_in_tab), - NULL, NULL, - ephy_marshal_VOID__STRING_BOOLEAN, - G_TYPE_NONE, - 2, - G_TYPE_STRING, - G_TYPE_BOOLEAN); - - 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, open_in_tabs), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); - g_object_class_install_property (object_class, PROP_TOPIC, diff --git a/src/bookmarks/ephy-topic-action.h b/src/bookmarks/ephy-topic-action.h index 7735fb31c..7c39e2e19 100644 --- a/src/bookmarks/ephy-topic-action.h +++ b/src/bookmarks/ephy-topic-action.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,11 +22,11 @@ #ifndef EPHY_TOPIC_ACTION_H #define EPHY_TOPIC_ACTION_H -#include <gtk/gtk.h> -#include <gtk/gtkaction.h> - +#include "ephy-link-action.h" #include "ephy-node.h" +G_BEGIN_DECLS + #define EPHY_TYPE_TOPIC_ACTION (ephy_topic_action_get_type ()) #define EPHY_TOPIC_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_TOPIC_ACTION, EphyTopicAction)) #define EPHY_TOPIC_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_TOPIC_ACTION, EphyTopicActionClass)) @@ -34,12 +35,12 @@ #define EPHY_TOPIC_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_TOPIC_ACTION, EphyTopicActionClass)) typedef struct _EphyTopicAction EphyTopicAction; -typedef struct _EphyTopicActionClass EphyTopicActionClass; typedef struct _EphyTopicActionPrivate EphyTopicActionPrivate; +typedef struct _EphyTopicActionClass EphyTopicActionClass; struct _EphyTopicAction { - GtkAction parent; + EphyLinkAction parent_instance; /*< private >*/ EphyTopicActionPrivate *priv; @@ -47,15 +48,7 @@ struct _EphyTopicAction struct _EphyTopicActionClass { - GtkActionClass parent_class; - - void (*open) (EphyTopicAction *action, - char *address); - void (*open_in_tab) (EphyTopicAction *action, - char *address, - gboolean new_window); - void (*open_in_tabs) (EphyTopicAction *action, - GList *uri_list); + EphyLinkActionClass parent_class; }; GType ephy_topic_action_get_type (void); @@ -63,4 +56,6 @@ GType ephy_topic_action_get_type (void); GtkAction *ephy_topic_action_new (const char *name, EphyNode *node); +G_END_DECLS + #endif diff --git a/src/ephy-home-action.c b/src/ephy-home-action.c new file mode 100644 index 000000000..52e86ef83 --- /dev/null +++ b/src/ephy-home-action.c @@ -0,0 +1,78 @@ +/* +* Copyright (C) 2004 Christian Persch +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +* $Id$ +*/ + +#include "config.h" + +#include "ephy-home-action.h" +#include "ephy-link.h" +#include "ephy-prefs.h" +#include "ephy-gui.h" +#include "eel-gconf-extensions.h" + +static void +ephy_home_action_activate (GtkAction *action) +{ + char *address; + + address = eel_gconf_get_string (CONF_GENERAL_HOMEPAGE); + + ephy_link_open (EPHY_LINK (action), + address != NULL && address[0] != '\0' ? address : "about:blank", + NULL, + ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0); + + g_free (address); +} + +static void +ephy_home_action_class_init (EphyHomeActionClass *class) +{ + GtkActionClass *action_class = GTK_ACTION_CLASS (class); + + action_class->activate = ephy_home_action_activate; +} + +GType +ephy_home_action_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) + { + static const GTypeInfo type_info = + { + sizeof (EphyHomeActionClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) ephy_home_action_class_init, + (GClassFinalizeFunc) NULL, + NULL, + sizeof (EphyHomeAction), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + type = g_type_register_static (EPHY_TYPE_LINK_ACTION, + "EphyHomeAction", + &type_info, 0); + } + + return type; +} diff --git a/src/ephy-home-action.h b/src/ephy-home-action.h new file mode 100644 index 000000000..4e53d95c0 --- /dev/null +++ b/src/ephy-home-action.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2004 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#ifndef EPHY_HOME_ACTION_H +#define EPHY_HOME_ACTION_H + +#include "ephy-link-action.h" + +G_BEGIN_DECLS + +#define EPHY_TYPE_HOME_ACTION (ephy_home_action_get_type ()) +#define EPHY_HOME_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_HOME_ACTION, EphyHomeAction)) +#define EPHY_HOME_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_HOME_ACTION, EphyHomeActionClass)) +#define EPHY_IS_HOME_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_HOME_ACTION)) +#define EPHY_IS_HOME_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_HOME_ACTION)) +#define EPHY_HOME_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_HOME_ACTION, EphyHomeActionClass)) + +typedef struct _EphyHomeAction EphyHomeAction; +typedef struct _EphyHomeActionClass EphyHomeActionClass; + +struct _EphyHomeAction +{ + EphyLinkAction parent_instance; +}; + +struct _EphyHomeActionClass +{ + EphyLinkActionClass parent_class; +}; + +GType ephy_home_action_get_type (void); + +G_END_DECLS + +#endif /* EPHY_HOME_ACTION_H */ diff --git a/src/ephy-link-action.c b/src/ephy-link-action.c new file mode 100644 index 000000000..18af84759 --- /dev/null +++ b/src/ephy-link-action.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2004 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#include "config.h" + +#include "ephy-link-action.h" +#include "ephy-link.h" + +GType +ephy_link_action_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) + { + static const GTypeInfo our_info = + { + sizeof (EphyLinkActionClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + NULL, /* class_init */ + NULL, + NULL, /* class_data */ + sizeof (EphyLinkAction), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; + static const GInterfaceInfo link_info = + { + NULL, + NULL, + NULL + }; + + type = g_type_register_static (GTK_TYPE_ACTION, + "EphyLinkAction", + &our_info, G_TYPE_FLAG_ABSTRACT); + g_type_add_interface_static (type, + EPHY_TYPE_LINK, + &link_info); + } + + return type; +} diff --git a/src/ephy-link-action.h b/src/ephy-link-action.h new file mode 100644 index 000000000..046fed715 --- /dev/null +++ b/src/ephy-link-action.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2004 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#ifndef EPHY_LINK_ACTION_H +#define EPHY_LINK_ACTION_H + +#include <gtk/gtkaction.h> + +G_BEGIN_DECLS + +#define EPHY_TYPE_LINK_ACTION (ephy_link_action_get_type ()) +#define EPHY_LINK_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_LINK_ACTION, EphyLinkAction)) +#define EPHY_LINK_ACTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_LINK_ACTION, EphyLinkActionClass)) +#define EPHY_IS_LINK_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_LINK_ACTION)) +#define EPHY_IS_LINK_ACTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_LINK_ACTION)) +#define EPHY_LINK_ACTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_LINK_ACTION, EphyLinkActionClass)) + +typedef struct _EphyLinkAction EphyLinkAction; +typedef struct _EphyLinkActionClass EphyLinkActionClass; + +struct _EphyLinkAction +{ + GtkAction parent_instance; +}; + +struct _EphyLinkActionClass +{ + GtkActionClass parent_class; +}; + +GType ephy_link_action_get_type (void); + +G_END_DECLS + +#endif diff --git a/src/ephy-link.c b/src/ephy-link.c new file mode 100644 index 000000000..05e8afdb7 --- /dev/null +++ b/src/ephy-link.c @@ -0,0 +1,119 @@ +/*
+ * Copyright (C) 2004 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "config.h"
+
+#include "ephy-link.h"
+
+#include "ephy-marshal.h"
+#include "ephy-signal-accumulator.h"
+#include "ephy-debug.h"
+
+GType
+ephy_link_flags_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GFlagsValue values[] =
+ {
+ { EPHY_LINK_NEW_WINDOW, "EPHY_LINK_NEW_WINDOW", "new-window" },
+ { EPHY_LINK_NEW_TAB, "EPHY_LINK_NEW_TAB", "new-tab" },
+ { EPHY_LINK_JUMP_TO, "EPHY_LINK_JUMP_TO", "jump-to" },
+ { 0, NULL, NULL }
+ };
+
+ type = g_flags_register_static ("EphyLinkFlags", values);
+ }
+
+ return type;
+}
+
+enum
+{
+ OPEN_LINK,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void
+ephy_link_base_init (gpointer g_class)
+{
+ static gboolean initialised = FALSE;
+
+ if (!initialised)
+ {
+ signals[OPEN_LINK] = g_signal_new
+ ("open-link",
+ EPHY_TYPE_LINK,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyLinkIface, open_link),
+ ephy_signal_accumulator_object, ephy_tab_get_type,
+ ephy_marshal_OBJECT__OBJECT_STRING_FLAGS,
+ EPHY_TYPE_TAB,
+ 3,
+ G_TYPE_STRING,
+ EPHY_TYPE_TAB,
+ EPHY_TYPE_LINK_FLAGS);
+
+ initialised = TRUE;
+ }
+}
+
+GType
+ephy_link_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyLinkIface),
+ ephy_link_base_init,
+ NULL,
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EphyLink",
+ &our_info, (GTypeFlags)0);
+ }
+
+ return type;
+}
+
+EphyTab *
+ephy_link_open (EphyLink *link,
+ const char *address,
+ EphyTab *tab,
+ EphyLinkFlags flags)
+{
+ EphyTab *new_tab = NULL;
+
+ LOG ("ephy_link_open address \"%s\" parent-tab %p flags %u", address, tab, flags)
+
+ g_signal_emit (link, signals[OPEN_LINK], 0,
+ address, tab, flags,
+ &new_tab);
+
+ return new_tab;
+}
diff --git a/src/ephy-link.h b/src/ephy-link.h new file mode 100644 index 000000000..12fad7d6c --- /dev/null +++ b/src/ephy-link.h @@ -0,0 +1,71 @@ +/*
+ * Copyright (C) 2004 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_LINK_H
+#define EPHY_LINK_H
+
+#include <glib-object.h>
+#include "ephy-tab.h"
+#include "ephy-window.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_LINK (ephy_link_get_type ())
+#define EPHY_LINK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_LINK, EphyLink))
+#define EPHY_LINK_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_LINK, EphyLinkIface))
+#define EPHY_IS_LINK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_LINK))
+#define EPHY_IS_LINK_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_LINK))
+#define EPHY_LINK_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_LINK, EphyLinkIface))
+
+#define EPHY_TYPE_LINK_FLAGS (ephy_link_flags_get_type ())
+
+typedef struct _EphyLink EphyLink;
+typedef struct _EphyLinkIface EphyLinkIface;
+
+typedef enum
+{
+ EPHY_LINK_NEW_WINDOW = 1 << 0,
+ EPHY_LINK_NEW_TAB = 1 << 1,
+ EPHY_LINK_JUMP_TO = 1 << 2
+} EphyLinkFlags;
+
+struct _EphyLinkIface
+{
+ GTypeInterface base_iface;
+
+ /* Signals */
+ EphyTab * (* open_link) (EphyLink *link,
+ const char *address,
+ EphyTab *tab,
+ EphyLinkFlags flags);
+};
+
+GType ephy_link_flags_get_type (void);
+
+GType ephy_link_get_type (void);
+
+EphyTab *ephy_link_open (EphyLink *link,
+ const char *address,
+ EphyTab *tab,
+ EphyLinkFlags flags);
+
+G_END_DECLS
+
+#endif /* EPHY_LINK_H */
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index b34ac0de7..4194b48f8 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -1,6 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti - * Copyright (C) 2003 Christian Persch + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include "ephy-location-entry.h" #include "ephy-shell.h" #include "ephy-completion-model.h" +#include "ephy-link.h" #include "ephy-debug.h" #include <gtk/gtkentry.h> @@ -57,16 +58,8 @@ enum PROP_EDITABLE }; -enum -{ - GO_LOCATION, - LAST_SIGNAL -}; - static GObjectClass *parent_class = NULL; -static guint signals[LAST_SIGNAL] = { 0 }; - GType ephy_location_action_get_type (void) { @@ -87,7 +80,7 @@ ephy_location_action_get_type (void) (GInstanceInitFunc) ephy_location_action_init, }; - type = g_type_register_static (GTK_TYPE_ACTION, + type = g_type_register_static (EPHY_TYPE_LINK_ACTION, "EphyLocationAction", &type_info, 0); } @@ -120,8 +113,8 @@ action_activated_cb (GtkEntryCompletion *completion, (action->priv->bookmarks, smart_url, content); g_return_if_fail (url != NULL); - g_signal_emit (action, signals[GO_LOCATION], 0, url); - + ephy_link_open (EPHY_LINK (action), url, NULL, 0); + g_free (url); g_free (content); } @@ -134,9 +127,9 @@ location_url_activate_cb (GtkEntry *entry, const char *content; content = gtk_entry_get_text (entry); - if (content) + if (content != NULL) { - g_signal_emit (action, signals[GO_LOCATION], 0, content); + ephy_link_open (EPHY_LINK (action), content, NULL, 0); } } @@ -260,7 +253,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) G_CALLBACK (user_changed_cb), action, 0); } - (* GTK_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy); + GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy); } static void @@ -284,7 +277,7 @@ disconnect_proxy (GtkAction *action, GtkWidget *proxy) (proxy, G_CALLBACK (user_changed_cb), action); } - (* GTK_ACTION_CLASS (parent_class)->disconnect_proxy) (action, proxy); + GTK_ACTION_CLASS (parent_class)->disconnect_proxy (action, proxy); } static void @@ -341,17 +334,6 @@ ephy_location_action_class_init (EphyLocationActionClass *class) action_class->connect_proxy = connect_proxy; action_class->disconnect_proxy = disconnect_proxy; - signals[GO_LOCATION] = - g_signal_new ("go_location", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyLocationActionClass, go_location), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING); - g_object_class_install_property (object_class, PROP_ADDRESS, g_param_spec_string ("address", diff --git a/src/ephy-location-action.h b/src/ephy-location-action.h index 987e9c75b..78053b27c 100644 --- a/src/ephy-location-action.h +++ b/src/ephy-location-action.h @@ -21,7 +21,7 @@ #ifndef EPHY_LOCATION_ACTION_H #define EPHY_LOCATION_ACTION_H -#include <gtk/gtkaction.h> +#include "ephy-link-action.h" G_BEGIN_DECLS @@ -33,12 +33,12 @@ G_BEGIN_DECLS #define EPHY_LOCATION_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_LOCATION_ACTION, EphyLocationActionClass)) typedef struct _EphyLocationAction EphyLocationAction; -typedef struct _EphyLocationActionClass EphyLocationActionClass; typedef struct _EphyLocationActionPrivate EphyLocationActionPrivate; - +typedef struct _EphyLocationActionClass EphyLocationActionClass; + struct _EphyLocationAction { - GtkAction parent; + EphyLinkAction parent; /*< private >*/ EphyLocationActionPrivate *priv; @@ -46,9 +46,7 @@ struct _EphyLocationAction struct _EphyLocationActionClass { - GtkActionClass parent_class; - - void (*go_location) (EphyLocationAction *action, char *location); + EphyLinkActionClass parent_class; }; GType ephy_location_action_get_type (void); diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c index 0e166f506..61300aa93 100644 --- a/src/ephy-navigation-action.c +++ b/src/ephy-navigation-action.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +26,8 @@ #include "ephy-favicon-cache.h" #include "ephy-history.h" #include "ephy-embed-shell.h" +#include "ephy-link.h" +#include "ephy-gui.h" #include "ephy-debug.h" #include <gtk/gtklabel.h> @@ -81,7 +84,7 @@ ephy_navigation_action_get_type (void) (GInstanceInitFunc) ephy_navigation_action_init, }; - type = g_type_register_static (GTK_TYPE_ACTION, + type = g_type_register_static (EPHY_TYPE_LINK_ACTION, "EphyNavigationAction", &type_info, 0); } @@ -133,12 +136,12 @@ new_history_menu_item (const char *origtext, static void activate_back_or_forward_menu_item_cb (GtkWidget *menuitem, - EphyWindow *window) + EphyNavigationAction *action) { EphyEmbed *embed; int go_nth; - embed = ephy_window_get_active_embed (window); + embed = ephy_window_get_active_embed (action->priv->window); g_return_if_fail (embed != NULL); go_nth = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), NTH_DATA_KEY)); @@ -148,18 +151,19 @@ activate_back_or_forward_menu_item_cb (GtkWidget *menuitem, static void activate_up_menu_item_cb (GtkWidget *menuitem, - EphyWindow *window) + EphyNavigationAction *action) { EphyEmbed *embed; char *url; - embed = ephy_window_get_active_embed (window); + embed = ephy_window_get_active_embed (action->priv->window); g_return_if_fail (embed != NULL); url = g_object_get_data (G_OBJECT (menuitem), URL_DATA_KEY); g_return_if_fail (url != NULL); - ephy_window_load_url (window, url); + ephy_link_open (EPHY_LINK (action), url, NULL, + ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0); } static GtkWidget * @@ -207,7 +211,7 @@ build_back_or_forward_menu (EphyNavigationAction *action) GINT_TO_POINTER (start)); g_signal_connect (item, "activate", G_CALLBACK (activate_back_or_forward_menu_item_cb), - window); + action); gtk_menu_shell_append (menu, item); gtk_widget_show_all (item); @@ -256,7 +260,7 @@ build_up_menu (EphyNavigationAction *action) g_object_set_data_full (G_OBJECT (item), URL_DATA_KEY, url, (GDestroyNotify) g_free); g_signal_connect (item, "activate", - G_CALLBACK (activate_up_menu_item_cb), window); + G_CALLBACK (activate_up_menu_item_cb), action); gtk_menu_shell_append (menu, item); gtk_widget_show (item); diff --git a/src/ephy-navigation-action.h b/src/ephy-navigation-action.h index d007c986d..fe440d303 100644 --- a/src/ephy-navigation-action.h +++ b/src/ephy-navigation-action.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Marco Pesenti Gritti + * Copyright (C) 2003, 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +22,9 @@ #ifndef EPHY_NAVIGATION_ACTION_H #define EPHY_NAVIGATION_ACTION_H -#include <gtk/gtkaction.h> +#include "ephy-link-action.h" + +G_BEGIN_DECLS #define EPHY_TYPE_NAVIGATION_ACTION (ephy_navigation_action_get_type ()) #define EPHY_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_NAVIGATION_ACTION, EphyNavigationAction)) @@ -31,8 +34,8 @@ #define EPHY_NAVIGATION_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_NAVIGATION_ACTION, EphyNavigationActionClass)) typedef struct _EphyNavigationAction EphyNavigationAction; -typedef struct _EphyNavigationActionClass EphyNavigationActionClass; typedef struct _EphyNavigationActionPrivate EphyNavigationActionPrivate; +typedef struct _EphyNavigationActionClass EphyNavigationActionClass; typedef enum { @@ -43,7 +46,7 @@ typedef enum struct _EphyNavigationAction { - GtkAction parent; + EphyLinkAction parent; /*< private >*/ EphyNavigationActionPrivate *priv; @@ -51,9 +54,11 @@ struct _EphyNavigationAction struct _EphyNavigationActionClass { - GtkActionClass parent_class; + EphyLinkActionClass parent_class; }; -GType ephy_navigation_action_get_type (void); +GType ephy_navigation_action_get_type (void); + +G_END_DECLS #endif diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 46a56b2b6..4dfb77783 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -539,6 +539,9 @@ ephy_shell_new_tab (EphyShell *shell, jump_to = (flags & EPHY_NEW_TAB_JUMP) != 0; + LOG ("Opening new tab parent-window %p parent-tab %p in-new-window:%s jump-to:%s", + parent_window, previous_tab, in_new_window ? "t" : "f", jump_to ? "t" : "f") + if (!in_new_window && parent_window != NULL) { window = parent_window; 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 */ diff --git a/src/toolbar.c b/src/toolbar.c index 2e2424a12..ed24eb858 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -24,7 +24,9 @@ #include "toolbar.h" #include "ephy-favicon-action.h" +#include "ephy-link.h" #include "ephy-go-action.h" +#include "ephy-home-action.h" #include "ephy-location-entry.h" #include "ephy-location-action.h" #include "ephy-navigation-action.h" @@ -38,9 +40,10 @@ #include "eel-gconf-extensions.h" #include "ephy-debug.h" -#include <string.h> #include <glib/gi18n.h> +#include <gtk/gtkstock.h> #include <gtk/gtkuimanager.h> +#include <string.h> static void toolbar_class_init (ToolbarClass *klass); static void toolbar_init (Toolbar *t); @@ -88,29 +91,39 @@ struct ToolbarPrivate GType toolbar_get_type (void) { - static GType type = 0; + static GType type = 0; - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo our_info = - { - sizeof (ToolbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) toolbar_class_init, - NULL, - NULL, /* class_data */ - sizeof (Toolbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) toolbar_init - }; - - type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR, + if (G_UNLIKELY (type == 0)) + { + static const GTypeInfo our_info = + { + sizeof (ToolbarClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) toolbar_class_init, + NULL, + NULL, /* class_data */ + sizeof (Toolbar), + 0, /* n_preallocs */ + (GInstanceInitFunc) toolbar_init + }; + + static const GInterfaceInfo link_info = + { + NULL, + NULL, + NULL + }; + + type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR, "Toolbar", &our_info, 0); - } + g_type_add_interface_static (type, + EPHY_TYPE_LINK, + &link_info); + } - return type; + return type; } static void @@ -152,12 +165,6 @@ arbitrary_url_notifier (GConfClient *client, } static void -go_location_cb (GtkAction *action, char *location, EphyWindow *window) -{ - ephy_window_load_url (window, location); -} - -static void zoom_to_level_cb (GtkAction *action, float zoom, EphyWindow *window) { ephy_window_set_zoom (window, zoom); @@ -355,6 +362,8 @@ toolbar_setup_actions (Toolbar *t) NULL); g_signal_connect (action, "activate", G_CALLBACK (window_cmd_go_up), t->priv->window); + g_signal_connect_swapped (action, "open-link", + G_CALLBACK (ephy_link_open), t); gtk_action_group_add_action (t->priv->action_group, action); g_object_unref (action); @@ -368,8 +377,8 @@ toolbar_setup_actions (Toolbar *t) "tooltip", _("Enter a web address to open, or a phrase to search for on the web"), "visible-overflown", FALSE, NULL); - g_signal_connect (action, "go_location", - G_CALLBACK (go_location_cb), t->priv->window); + g_signal_connect_swapped (action, "open-link", + G_CALLBACK (ephy_link_open), t); g_signal_connect (action, "notify::address", G_CALLBACK (sync_user_input_cb), t); gtk_action_group_add_action (t->priv->action_group, action); @@ -408,6 +417,18 @@ toolbar_setup_actions (Toolbar *t) G_CALLBACK (window_cmd_load_location), t->priv->window); gtk_action_group_add_action (t->priv->action_group, action); g_object_unref (action); + + action = g_object_new (EPHY_TYPE_HOME_ACTION, + "name", "GoHome", + "label", _("_Home"), + "stock_id", GTK_STOCK_HOME, + "tooltip", _("Go to the home page"), + "is_important", TRUE, + NULL); + g_signal_connect_swapped (action, "open-link", + G_CALLBACK (ephy_link_open), t); + gtk_action_group_add_action_with_accel (t->priv->action_group, action, "<alt>Home"); + g_object_unref (action); } static void diff --git a/src/window-commands.c b/src/window-commands.c index 83665c9ec..09b31e661 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -196,26 +196,6 @@ window_cmd_go_forward (GtkAction *action, } void -window_cmd_go_home (GtkAction *action, - EphyWindow *window) -{ - char *location; - - location = eel_gconf_get_string (CONF_GENERAL_HOMEPAGE); - - if (location == NULL || location[0] == '\0') - { - g_free (location); - - location = g_strdup ("about:blank"); - } - - ephy_window_load_url (window, location); - - g_free (location); -} - -void window_cmd_go_location (GtkAction *action, EphyWindow *window) { diff --git a/src/window-commands.h b/src/window-commands.h index 6284108c8..39ff5707d 100644 --- a/src/window-commands.h +++ b/src/window-commands.h @@ -40,9 +40,6 @@ void window_cmd_go_location (GtkAction *action, void window_cmd_go_up (GtkAction *action, EphyWindow *window); -void window_cmd_go_home (GtkAction *action, - EphyWindow *window); - void window_cmd_go_myportal (GtkAction *action, EphyWindow *window); |