diff options
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 89 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.h | 40 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-menu.c | 59 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-menu.h | 8 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarksbar.c | 67 | ||||
-rw-r--r-- | src/bookmarks/ephy-favorites-menu.c | 26 | ||||
-rw-r--r-- | src/bookmarks/ephy-favorites-menu.h | 6 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.c | 98 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.h | 25 |
9 files changed, 142 insertions, 276 deletions
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 |