aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmark-action.c
diff options
context:
space:
mode:
authorPeter Harvey <pah06@uow.edu.au>2005-10-17 04:29:26 +0800
committerChristian Persch <chpe@src.gnome.org>2005-10-17 04:29:26 +0800
commitd21007362f8d0701d63e50fe6b219de067d95a87 (patch)
tree46326d5633d4f3c8504049476d0e72ae7ed0ca2c /src/bookmarks/ephy-bookmark-action.c
parent35b9deda1f37ac0cc81d926b5295983de6b55dcf (diff)
downloadgsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.gz
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.bz2
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.lz
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.xz
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.zst
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.zip
H18 patch, by Peter Harvey <pah06@uow.edu.au>.
2005-10-16 Peter Harvey <pah06@uow.edu.au> H18 patch, by Peter Harvey <pah06@uow.edu.au>. * data/ui/epiphany-bookmark-editor-ui.xml: * data/ui/epiphany-ui.xml: * lib/egg/egg-editable-toolbar.c: (get_dock_position), (get_toolbar_position), (get_toolbar_nth), (find_action), (drag_data_delete_cb), (drag_begin_cb), (drag_end_cb), (drag_data_get_cb), (move_item_cb), (set_dock_visible), (remove_item_cb), (remove_toolbar_cb), (toggle_visibility_cb), (egg_editable_toolbar_add_visibility_items), (egg_editable_toolbar_add_popup_items), (popup_context_menu_cb), (button_press_event_cb), (configure_item_sensitivity), (configure_item_cursor), (connect_widget_signals), (action_sensitive_cb), (create_item_from_action), (create_item_from_position), (toolbar_drag_data_received_cb), (toolbar_drag_drop_cb), (toolbar_drag_motion_cb), (toolbar_drag_leave_cb), (configure_drag_dest), (create_dock), (toolbar_changed_cb), (unparent_fixed), (update_fixed), (toolbar_added_cb), (toolbar_removed_cb), (item_added_cb), (item_removed_cb), (egg_editable_toolbar_construct), (egg_editable_toolbar_set_ui_manager), (egg_editable_toolbar_set_property), (egg_editable_toolbar_get_property), (egg_editable_toolbar_init), (egg_editable_toolbar_finalize), (egg_editable_toolbar_get_edit_mode), (egg_editable_toolbar_set_edit_mode), (egg_editable_toolbar_set_fixed): * lib/egg/egg-editable-toolbar.h: * lib/egg/egg-toolbar-editor.c: (compare_items), (item_added_or_removed_cb), (toolbar_removed_cb), (egg_toolbar_editor_set_model), (egg_toolbar_editor_finalize), (drag_begin_cb), (drag_end_cb), (drag_data_get_cb), (editor_create_item), (editor_create_item_from_name), (append_table), (update_editor_sheet), (egg_toolbar_editor_init): * lib/egg/egg-toolbar-editor.h: * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml), (egg_toolbars_model_save), (toolbar_node_new), (item_node_new), (item_node_free), (toolbar_node_free), (egg_toolbars_model_get_flags), (egg_toolbars_model_set_flags), (egg_toolbars_model_get_data), (egg_toolbars_model_get_name), (impl_add_item), (egg_toolbars_model_add_item), (egg_toolbars_model_add_toolbar), (parse_data_list), (parse_item_list), (parse_toolbars), (egg_toolbars_model_load), (egg_toolbars_model_class_init), (egg_toolbars_model_init), (egg_toolbars_model_finalize), (egg_toolbars_model_remove_toolbar), (egg_toolbars_model_remove_item), (egg_toolbars_model_move_item), (egg_toolbars_model_n_items), (egg_toolbars_model_item_nth), (egg_toolbars_model_n_toolbars), (egg_toolbars_model_toolbar_nth), (egg_toolbars_model_get_types), (egg_toolbars_model_set_types), (fill_avail_array), (egg_toolbars_model_get_avail), (egg_toolbars_model_get_n_avail), (egg_toolbars_model_set_n_avail): * lib/egg/egg-toolbars-model.h: * src/bookmarks/Makefile.am: * src/bookmarks/ephy-bookmark-action-group.c: (smart_added_cb), (smart_removed_cb), (node_changed_cb), (node_added_cb), (node_removed_cb), (ephy_bookmark_group_new): * src/bookmarks/ephy-bookmark-action-group.h: * src/bookmarks/ephy-bookmark-action.c: (create_tool_item), (ephy_bookmark_action_sync_icon), (show_context_menu), (popup_menu_cb), (button_press_cb), (button_release_cb), (connect_proxy), (ephy_bookmark_action_updated), (ephy_bookmark_action_get_bookmark), (ephy_bookmark_action_set_bookmark), (ephy_bookmark_action_set_property), (ephy_bookmark_action_get_property), (ephy_bookmark_action_finalize), (ephy_bookmark_action_class_init), (ephy_bookmark_action_init), (ephy_bookmark_action_name), (ephy_bookmark_action_new): * src/bookmarks/ephy-bookmark-action.h: * src/bookmarks/ephy-bookmark-factory-action.c: (ephy_bookmark_factory_action_get_type), (activate_item_cb), (build_menu_for_topic), (build_menu), (remove_placeholder_cb), (activate_placeholder_cb), (clicked_placeholder_cb), (realize_placeholder_cb), (create_tool_item), (connect_proxy), (ephy_bookmark_factory_action_class_init), (ephy_bookmark_factory_action_new): * src/bookmarks/ephy-bookmark-factory-action.h: * src/bookmarks/ephy-bookmark-properties.c: (ephy_bookmark_properties_set_property), (ephy_bookmark_properties_get_property), (bookmark_properties_response_cb), (update_entry), (location_entry_changed_cb), (build_ui): * src/bookmarks/ephy-bookmarks-editor.c: (add_entry_monitor), (cmd_add_topic), (delete_topic_dialog_construct), (cmd_bookmarks_import), (ephy_bookmarks_editor_finalize), (ephy_bookmarks_editor_node_activated_cb), (ephy_bookmarks_editor_update_menu), (view_focus_cb), (add_focus_monitor), (remove_focus_monitor), (bookmarks_filter), (search_entry_search_cb), (ephy_bookmarks_editor_construct), (ephy_bookmarks_editor_set_parent), (ephy_bookmarks_editor_set_property), (ephy_bookmarks_editor_get_property), (ephy_bookmarks_editor_init): * src/bookmarks/ephy-bookmarks-menu.c: (append_bookmarks), (append_menu), (ephy_bookmarks_menu_build): * src/bookmarks/ephy-bookmarks-menu.h: * src/bookmarks/ephy-bookmarks-ui.c: (find_action), (activate_bookmarks_menu), (activate_favorites_menu), (erase_bookmarks_menu), (erase_favorites_menu), (tree_changed_cb), (node_added_cb), (node_changed_cb), (node_removed_cb), (ephy_bookmarks_ui_attach_window), (ephy_bookmarks_ui_detach_window), (toolbar_node_removed_cb), (topic_has_data), (topic_get_data), (topic_get_name), (bookmark_has_data), (bookmark_get_data), (bookmark_get_name), (bookmark_new_name), (ephy_bookmarks_ui_attach_toolbar_model), (ephy_bookmarks_ui_detach_toolbar_model): * src/bookmarks/ephy-bookmarks-ui.h: * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_type), (ephy_bookmarks_init_defaults), (ephy_bookmarks_class_init), (ephy_bookmarks_save_delayed), (add_to_favorites), (update_bookmark_keywords), (ephy_bookmarks_init), (ephy_bookmarks_finalize), (ephy_bookmarks_add), (ephy_bookmarks_set_address), (ephy_bookmarks_set_icon), (ephy_bookmarks_add_keyword), (ephy_bookmarks_show_bookmark_properties), (ephy_bookmarks_get_from_id), (ephy_bookmarks_compare_topics), (ephy_bookmarks_compare_topic_pointers), (ephy_bookmarks_compare_bookmarks), (ephy_bookmarks_compare_bookmark_pointers): * src/bookmarks/ephy-bookmarks.h: * src/bookmarks/ephy-bookmarksbar-model.c: * src/bookmarks/ephy-bookmarksbar-model.h: * src/bookmarks/ephy-bookmarksbar.c: * src/bookmarks/ephy-bookmarksbar.h: * src/bookmarks/ephy-favorites-menu.c: * src/bookmarks/ephy-favorites-menu.h: * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_add), (build_editing_table), (ephy_new_bookmark_construct), (ephy_new_bookmark_set_property), (ephy_new_bookmark_get_property): * src/bookmarks/ephy-nodes-cover.c: (ephy_nodes_count_covered), (ephy_nodes_remove_covered), (ephy_nodes_remove_not_covered), (ephy_nodes_get_covered), (ephy_nodes_covered), (ephy_nodes_get_covering): * src/bookmarks/ephy-nodes-cover.h: * src/bookmarks/ephy-open-tabs-action.c: (activate_cb), (node_added_cb), (node_removed_cb), (ephy_open_tabs_group_new), (ephy_open_tabs_action_name): * src/bookmarks/ephy-open-tabs-action.h: * src/bookmarks/ephy-related-action.c: (node_changed), (node_destroyed), (open_link), (iface_init), (ephy_related_action_get_type), (ephy_related_action_new): * src/bookmarks/ephy-related-action.h: * src/bookmarks/ephy-topic-action-group.c: (node_changed_cb), (node_added_cb), (node_removed_cb), (ephy_topic_group_new): * src/bookmarks/ephy-topic-action-group.h: * src/bookmarks/ephy-topic-action.c: (ephy_topic_action_get_type), (create_tool_item), (ephy_topic_action_sync_label), (get_popup), (erase_popup), (child_added_cb), (child_changed_cb), (child_removed_cb), (menu_destroy_cb), (menu_init_cb), (button_deactivate_cb), (button_toggled_cb), (button_release_cb), (button_press_cb), (connect_proxy), (ephy_topic_action_updated), (ephy_topic_action_get_topic), (ephy_topic_action_set_topic), (ephy_topic_action_set_property), (ephy_topic_action_get_property), (ephy_topic_action_class_init), (ephy_topic_action_init), (ephy_topic_action_name), (ephy_topic_action_new): * src/bookmarks/ephy-topic-action.h: * src/bookmarks/ephy-topic-factory-action.c: (ephy_topic_factory_action_get_type), (sort_topics), (activate_item_cb), (build_menu), (remove_placeholder_cb), (activate_placeholder_cb), (clicked_placeholder_cb), (realize_placeholder_cb), (create_tool_item), (connect_proxy), (ephy_topic_factory_action_class_init), (ephy_topic_factory_action_new): * src/bookmarks/ephy-topic-factory-action.h: * src/ephy-link-action.c: (ephy_link_action_group_get_type), (ephy_link_action_group_new): * src/ephy-link-action.h: * src/ephy-lockdown.c: (find_name), (find_action_group), (update_window): * src/ephy-notebook.c: (move_tab_to_another_notebook), (ephy_notebook_switch_page_cb), (ephy_notebook_init), (tab_label_style_set_cb), (build_tab_label), (ephy_notebook_add_tab): * src/ephy-shell.c: (ephy_shell_get_toolbars_model): * src/ephy-toolbar-editor.c: (ephy_toolbar_editor_constructor), (ephy_toolbar_editor_finalize), (ephy_toolbar_editor_set_property), (ephy_toolbar_editor_class_init): * src/ephy-toolbar.c: (ephy_toolbar_realize), (ephy_toolbar_unrealize), (ephy_toolbar_finalize): * src/ephy-toolbars-model.c: (update_flags), (ephy_toolbars_model_load): * src/ephy-window.c: (ephy_window_get_type), (get_chromes_visibility), (sync_chromes_visibility), (ephy_window_key_press_event), (tool_item_enter_cb), (tool_item_leave_cb), (tool_item_drag_begin_cb), (connect_tool_item), (disconnect_tool_item), (disconnect_proxy_cb), (connect_proxy_cb), (update_chromes_actions), (show_embed_popup), (tab_added_cb), (tab_removed_cb), (ephy_window_set_chrome), (ephy_window_dispose), (ephy_window_class_init), (ephy_window_init), (ephy_window_finalize), (ephy_window_remove_tab), (ephy_window_set_zoom), (sync_prefs_with_chrome), (ephy_window_view_toolbar_cb): * src/ephy-window.h: Revision history: h18, released 2005/09/23, for Epiphany 1.8.0 * Just an update for 1.8.0. h17, released 2005/08/30, for Epiphany 1.7.6 or CVS HEAD * Mostly just an update for 1.7.6. * Topic menus on the toolbar now open without releasing the mouse button. * Topic menus on the toolbar are now also hierarchical (see if you like it. h16, released 2005/08/25, for Epiphany 1.7.5 or CVS HEAD * Just an update for 1.7.5. Sorry, I've been busy. :) h15, released 2005/07/19, for Epiphany 1.7.2 or CVS HEAD * Code cleanup h14, released 2005/07/9, for Epiphany 1.7.1 or CVS HEAD * Improved helpful tip when adding a bookmark * Improved toolbar context menu * Toolbar visibility state is now saved * Separated bookmark/topic action groups into separate files * Topics in the overflow menu now behave as submenus * Now importing old bookmarksbar, and saving to new filename * Incremented toolbar file format version number to 1.1 * Fixed the 'sticky' statusbar help * Fixed a crashing bug (dnd then open a topic on the toolbar) h13, released 2005/05/12, for CVS HEAD * Added middle-mouse drag-drop for the editable toolbar. * Fixed some warnings at compile and run time. * Added brief help for the user when adding a new bookmark. * Cleaned up the editable toolbar code a little. h12, released 2005/05/10, for CVS HEAD * Added new editing facilities for the editable toolbar. h11, released 2005/04/29, for CVS HEAD * Fixed bug in statusbar information for toolbar items. * Added an all-new 'Related' toolbar widget which changes to show the most related topic whenever a bookmark is activated. h10, released 2005/04/15, for Epiphany 1.6.2 or CVS HEAD * Added statusbar information for all toolbar items. * Empty toolbars are now only deleted when exiting edit mode. * Fixed regression of middle-click for bookmarks on toolbar. * Fixed regression of ellipsized bookmark names in menus. h9, released 2005/04/12, for Epiphany 1.6.1 * Updated patch for 1.6.1. Long time no see. * Now using EphyLink objects everywhere. h7, released 2004/10/21, for Epiphany 1.4.4 * Updated patch for 1.4.4. * Fixed bugs causing crashes when bookmarks were added (thanks Reinout). * Added "Open in Tabs" back into bookmark menus where suitable. h6, released 2004/09/20, for Epiphany 1.4.0 * Updated patch for 1.4.0. * Removed the bookmarks bar. * Generate shared XML string for bookmarks menu. * Slightly improve performance of node-cover code. * Delay adding bookmarks menu until it is first used. * Fixed bug(?) in ephy-node. h4, released 2004/08/08, for Epiphany 1.3.4 * Updated patch due to changes to topics selector. * Removed 'Most Visited' from the min-cover calculations. * Fixed Epiphany 1.3.4 bug where topics in selector aren't sorted. * Updated patch due to other changes in Epiphany 1.3.4 source. h3, released 2004/07/12, for Epiphany 1.3.2 * Simple update for Epiphany 1.3.2 h3, released 2004/05/24, for Epiphany 1.2.5 * Moved duplicated functions into a seperate file. * Improved topic selector. * Bookmarks toolbar topic menus now have subdivisions. * Topic names in menu now change if modified in the bookmarks editor. h2, released 2004/05/23, for Epiphany 1.2.5 * Significantly cleaned up the code. * 'Most Visited' no longer appears as a submenu. * Subtopics are selected much more intelligently, giving a better approximation to a true minimum cover. * Topic selector now shows suggestions with arrows, not bold font. h1, released 2004/05/19, for Epiphany 1.2.5 * Initial release.
Diffstat (limited to 'src/bookmarks/ephy-bookmark-action.c')
-rw-r--r--src/bookmarks/ephy-bookmark-action.c444
1 files changed, 108 insertions, 336 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index a4154b298..db93b5824 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2003, 2004 Marco Pesenti Gritti
* Copyright (C) 2003, 2004 Christian Persch
+ * Copyright (C) 2005 Peter Harvey
*
* 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,12 +22,11 @@
#include "config.h"
+#include "egg-editable-toolbar.h"
#include "ephy-bookmark-action.h"
-#include "ephy-bookmarksbar-model.h"
-#include "ephy-bookmarksbar.h"
#include "ephy-bookmarks.h"
+#include "ephy-link-action.h"
#include "ephy-link.h"
-#include "ephy-dnd.h"
#include "ephy-favicon-cache.h"
#include "ephy-shell.h"
#include "ephy-gui.h"
@@ -37,16 +37,13 @@
#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/gtkentry.h>
#include <gtk/gtktoolitem.h>
-#include <gtk/gtktoolbar.h>
#include <gtk/gtkmain.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -62,20 +59,11 @@ static void ephy_bookmark_action_class_init (EphyBookmarkActionClass *class);
#define EPHY_BOOKMARK_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BOOKMARK_ACTION, EphyBookmarkActionPrivate))
-static GtkTargetEntry drag_targets[] =
-{
- { EPHY_DND_URL_TYPE, 0, 0 }
-};
-static int n_drag_targets = G_N_ELEMENTS (drag_targets);
-
struct _EphyBookmarkActionPrivate
{
EphyNode *node;
gboolean smart_url;
guint cache_handler;
- guint motion_handler;
- gint drag_x;
- gint drag_y;
};
enum
@@ -138,6 +126,7 @@ create_tool_item (GtkAction *action)
gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (hbox), button);
g_object_set_data (G_OBJECT (item), "button", button);
+ g_object_set_data (G_OBJECT (item), "egg-drag-source", button);
entry = gtk_entry_new ();
gtk_entry_set_width_chars (GTK_ENTRY (entry), ENTRY_WIDTH_CHARS);
@@ -247,7 +236,7 @@ ephy_bookmark_action_sync_icon (GtkAction *action, GParamSpec *pspec, GtkWidget
if (pixbuf == NULL)
{
pixbuf = gtk_widget_render_icon (proxy, GTK_STOCK_NEW,
- GTK_ICON_SIZE_MENU, NULL);
+ GTK_ICON_SIZE_MENU, NULL);
}
gtk_image_set_from_pixbuf (icon, pixbuf);
@@ -379,142 +368,6 @@ activate_cb (GtkWidget *widget,
}
static void
-stop_drag_check (EphyBookmarkAction *action, GtkWidget *widget)
-{
- if (action->priv->motion_handler)
- {
- g_signal_handler_disconnect (widget, action->priv->motion_handler);
- action->priv->motion_handler = 0;
- }
-}
-
-static void
-drag_data_get_cb (GtkWidget *widget, GdkDragContext *context,
- GtkSelectionData *selection_data, guint info,
- guint32 time, EphyBookmarkAction *action)
-{
- const char *address, *title;
- char *data;
-
- g_return_if_fail (action->priv->node != NULL);
-
- address = ephy_node_get_property_string (action->priv->node,
- EPHY_NODE_BMK_PROP_LOCATION);
- g_return_if_fail (address != NULL);
-
- title = ephy_node_get_property_string (action->priv->node,
- EPHY_NODE_BMK_PROP_TITLE);
- g_return_if_fail (title != NULL);
-
- data = g_strdup_printf ("%s\n%s", address, title);
- gtk_selection_data_set (selection_data, selection_data->target, 8,
- (unsigned char *) data, strlen (data));
- g_free (data);
-}
-
-static int
-get_item_position (GtkWidget *widget, gboolean *last)
-{
- GtkWidget *item, *toolbar;
- int index;
-
- item = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM);
- g_return_val_if_fail (item != NULL, -1);
-
- toolbar = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOLBAR);
- g_return_val_if_fail (toolbar != NULL, -1);
-
- index = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar),
- GTK_TOOL_ITEM (item));
- if (last)
- {
- int n_items;
-
- n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
- *last = (index == n_items - 1);
- }
-
- return index;
-}
-
-static void
-remove_from_model (GtkWidget *widget)
-{
- EphyBookmarks *bookmarks;
- EggToolbarsModel *model;
- int pos;
-
- pos = get_item_position (widget, NULL);
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- model = EGG_TOOLBARS_MODEL (ephy_bookmarks_get_toolbars_model (bookmarks));
-
- egg_toolbars_model_remove_item (model, 0, pos);
-}
-
-static void
-move_in_model (GtkWidget *widget, int direction)
-{
- EphyBookmarks *bookmarks;
- EggToolbarsModel *model;
- int pos, new_pos;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- model = EGG_TOOLBARS_MODEL (ephy_bookmarks_get_toolbars_model (bookmarks));
-
- pos = get_item_position (widget, NULL);
- new_pos = MAX (0, pos + direction);
-
- egg_toolbars_model_move_item (model, 0, pos, 0, new_pos);
-}
-
-static void
-drag_data_delete_cb (GtkWidget *widget, GdkDragContext *context,
- EphyBookmarkAction *action)
-{
- remove_from_model (widget);
-}
-
-static gboolean
-drag_motion_cb (GtkWidget *widget, GdkEventMotion *event, EphyBookmarkAction *action)
-{
- if (gtk_drag_check_threshold (widget, action->priv->drag_x,
- action->priv->drag_y, event->x, event->y))
- {
- GtkTargetList *target_list;
-
- target_list = gtk_target_list_new (drag_targets, n_drag_targets);
-
- stop_drag_check (action, widget);
- gtk_drag_begin (widget, target_list, GDK_ACTION_ASK |
- GDK_ACTION_MOVE | GDK_ACTION_COPY, 1,
- (GdkEvent*)event);
-
- gtk_target_list_unref (target_list);
- }
-
- return TRUE;
-}
-
-static void
-remove_activate_cb (GtkWidget *menu, GtkWidget *proxy)
-{
- remove_from_model (proxy);
-}
-
-static void
-move_left_activate_cb (GtkWidget *menu, GtkWidget *proxy)
-{
- move_in_model (proxy, -1);
-}
-
-static void
-move_right_activate_cb (GtkWidget *menu, GtkWidget *proxy)
-{
- move_in_model (proxy, +1);
-}
-
-static void
properties_activate_cb (GtkWidget *menu,
EphyBookmarkAction *action)
{
@@ -535,8 +388,7 @@ show_context_menu (EphyBookmarkAction *action,
GdkEventButton *event,
GtkMenuPositionFunc func)
{
- GtkWidget *menu, *item, *image;
- gboolean last;
+ GtkWidget *menu, *item;
menu = gtk_menu_new ();
@@ -562,38 +414,8 @@ show_context_menu (EphyBookmarkAction *action,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_signal_connect (item, "activate",
G_CALLBACK (properties_activate_cb), action);
-
- item = gtk_separator_menu_item_new ();
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_image_menu_item_new_with_mnemonic (_("_Remove from Toolbar"));
- gtk_widget_show (item);
- image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_widget_show (image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_signal_connect (item, "activate",
- G_CALLBACK (remove_activate_cb), proxy);
-
- item = gtk_separator_menu_item_new ();
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- item = gtk_menu_item_new_with_mnemonic (_("Move _Left"));
- gtk_widget_set_sensitive (item, get_item_position (proxy, NULL) > 0);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_signal_connect (item, "activate",
- G_CALLBACK (move_left_activate_cb), proxy);
-
- item = gtk_menu_item_new_with_mnemonic (_("Move Ri_ght"));
- get_item_position (proxy, &last);
- gtk_widget_set_sensitive (item, !last);
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_signal_connect (item, "activate",
- G_CALLBACK (move_right_activate_cb), proxy);
+
+ egg_editable_toolbar_add_popup_items (proxy, GTK_MENU (menu));
if (event != NULL)
{
@@ -611,14 +433,8 @@ show_context_menu (EphyBookmarkAction *action,
static gboolean
popup_menu_cb (GtkWidget *widget, EphyBookmarkAction *action)
{
- if (gtk_widget_get_ancestor (widget, EPHY_TYPE_BOOKMARKSBAR))
- {
- show_context_menu (action, widget, NULL,
- ephy_gui_menu_position_under_widget);
- return TRUE;
- }
-
- return FALSE;
+ show_context_menu (action, widget, NULL, ephy_gui_menu_position_under_widget);
+ return TRUE;
}
static gboolean
@@ -626,8 +442,7 @@ button_press_cb (GtkWidget *widget,
GdkEventButton *event,
EphyBookmarkAction *action)
{
- if (event->button == 3 &&
- gtk_widget_get_ancestor (widget, EPHY_TYPE_BOOKMARKSBAR))
+ if (event->button == 3)
{
show_context_menu (action, widget, event, NULL);
return TRUE;
@@ -636,35 +451,24 @@ button_press_cb (GtkWidget *widget,
{
gtk_button_pressed (GTK_BUTTON (widget));
}
- else if (event->button == 1 &&
- gtk_widget_get_ancestor (widget, EPHY_TYPE_BOOKMARKSBAR))
- {
- action->priv->drag_x = event->x;
- action->priv->drag_y = event->y;
- action->priv->motion_handler = g_signal_connect
- (widget, "motion_notify_event", G_CALLBACK (drag_motion_cb), action);
- }
return FALSE;
}
static gboolean
button_release_cb (GtkWidget *widget,
- GdkEventButton *event,
+ GdkEventButton *event,
EphyBookmarkAction *action)
{
if (event->button == 2)
{
gtk_button_released (GTK_BUTTON (widget));
}
- else if (event->button == 1)
- {
- stop_drag_check (action, widget);
- }
return FALSE;
}
+
static void
connect_proxy (GtkAction *action, GtkWidget *proxy)
{
@@ -676,11 +480,11 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
ephy_bookmark_action_sync_icon (action, NULL, proxy);
g_signal_connect_object (action, "notify::icon",
- G_CALLBACK (ephy_bookmark_action_sync_icon), proxy, 0);
+ G_CALLBACK (ephy_bookmark_action_sync_icon), proxy, 0);
ephy_bookmark_action_sync_smart_url (action, NULL, proxy);
g_signal_connect_object (action, "notify::smarturl",
- G_CALLBACK (ephy_bookmark_action_sync_smart_url), proxy, 0);
+ G_CALLBACK (ephy_bookmark_action_sync_smart_url), proxy, 0);
if (GTK_IS_TOOL_ITEM (proxy))
{
@@ -696,10 +500,6 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
G_CALLBACK (button_press_cb), action);
g_signal_connect (button, "button-release-event",
G_CALLBACK (button_release_cb), action);
- g_signal_connect (button, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), action);
- g_signal_connect (button, "drag_data_delete",
- G_CALLBACK (drag_data_delete_cb), action);
entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
g_signal_connect (entry, "activate", G_CALLBACK (activate_cb), action);
@@ -718,73 +518,73 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
}
}
-static void
-bookmark_changed_cb (EphyNode *node,
- guint property_id,
- EphyBookmarkAction *action)
+void
+ephy_bookmark_action_updated (EphyBookmarkAction *action)
{
- if (property_id == EPHY_NODE_BMK_PROP_TITLE)
- {
- GValue value = { 0, };
- const char *title;
+ GValue value = { 0, };
+ EphyBookmarks *bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ EphyNode *smart = ephy_bookmarks_get_smart_bookmarks (bookmarks);
+ EphyNode *node = action->priv->node;
+ const char *title;
+
+ g_return_if_fail (action != NULL);
+ g_return_if_fail (node != NULL);
+
+ g_object_freeze_notify (G_OBJECT (action));
- title = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_TITLE);
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_static_string (&value, title);
- g_object_set_property (G_OBJECT (action), "label", &value);
- g_value_unset (&value);
- }
- else if (property_id == EPHY_NODE_BMK_PROP_ICON)
- {
- g_object_notify (G_OBJECT (action), "icon");
- }
+ // Set smart_url
+ action->priv->smart_url = ephy_node_has_child (smart, node);
+ g_object_notify (G_OBJECT (action), "smarturl");
+
+ // Set title
+ title = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_TITLE);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_static_string (&value, title);
+ g_object_set_property (G_OBJECT (action), "label", &value);
+ g_value_unset (&value);
+
+ // Notify all other properties
+ g_object_notify (G_OBJECT (action), "location");
+ g_object_notify (G_OBJECT (action), "tooltip");
+ g_object_notify (G_OBJECT (action), "icon");
+
+ g_object_thaw_notify (G_OBJECT (action));
}
-static void
-bookmark_destroy_cb (EphyNode *node, EphyBookmarkAction *action)
+EphyNode *
+ephy_bookmark_action_get_bookmark (EphyBookmarkAction *action)
{
- action->priv->node = NULL;
+ return action->priv->node;
}
-static void
+void
ephy_bookmark_action_set_bookmark (EphyBookmarkAction *action,
EphyNode *node)
-{
- EphyBookmarks *bookmarks;
- EphyNode *smart_bmks;
-
+{
g_return_if_fail (node != NULL);
-
+
action->priv->node = node;
-
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- smart_bmks = ephy_bookmarks_get_smart_bookmarks (bookmarks);
- action->priv->smart_url = ephy_node_has_child (smart_bmks, node);
-
- bookmark_changed_cb (node, EPHY_NODE_BMK_PROP_TITLE, action);
-// bookmark_changed_cb (node, EPHY_NODE_BMK_PROP_ICON, action);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHANGED,
- (EphyNodeCallback) bookmark_changed_cb,
- G_OBJECT (action));
- ephy_node_signal_connect_object (node, EPHY_NODE_DESTROY,
- (EphyNodeCallback) bookmark_destroy_cb,
- G_OBJECT (action));
+
+ g_object_freeze_notify (G_OBJECT (action));
+
+ g_object_notify (G_OBJECT (action), "bookmark");
+ ephy_bookmark_action_updated (action);
+
+ g_object_thaw_notify (G_OBJECT (action));
}
static void
ephy_bookmark_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
EphyBookmarkAction *action = EPHY_BOOKMARK_ACTION (object);
switch (prop_id)
{
case PROP_BOOKMARK:
- ephy_bookmark_action_set_bookmark
- (action, g_value_get_pointer (value));
+ ephy_bookmark_action_set_bookmark (action, g_value_get_pointer (value));
break;
case PROP_TOOLTIP:
case PROP_LOCATION:
@@ -797,9 +597,9 @@ ephy_bookmark_action_set_property (GObject *object,
static void
ephy_bookmark_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
EphyBookmarkAction *action = EPHY_BOOKMARK_ACTION (object);
@@ -830,8 +630,6 @@ ephy_bookmark_action_get_property (GObject *object,
static void
ephy_bookmark_action_finalize (GObject *object)
{
- /* EphyBookmarkAction *eba = EPHY_BOOKMARK_ACTION (object);*/
-
LOG ("Bookmark action %p finalized", object);
parent_class->finalize (object);
@@ -855,7 +653,7 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
object_class->get_property = ephy_bookmark_action_get_property;
g_object_class_install_property (object_class,
- PROP_BOOKMARK,
+ PROP_BOOKMARK,
g_param_spec_pointer ("bookmark",
"Bookmark",
"Bookmark",
@@ -864,89 +662,63 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
/* overwrite GtkActionClass::tooltip, so we can use the url as tooltip */
g_object_class_install_property (object_class,
- PROP_TOOLTIP,
- g_param_spec_string ("tooltip",
- "Tooltip",
- "Tooltip",
- NULL,
- G_PARAM_READABLE));
-
+ PROP_TOOLTIP,
+ g_param_spec_string ("tooltip",
+ "Tooltip",
+ "Tooltip",
+ NULL,
+ G_PARAM_READABLE));
+
g_object_class_install_property (object_class,
- PROP_LOCATION,
- g_param_spec_string ("location",
- "Location",
- "Location",
- NULL,
- G_PARAM_READABLE));
+ PROP_LOCATION,
+ g_param_spec_string ("location",
+ "Location",
+ "Location",
+ NULL,
+ G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_SMART_URL,
- g_param_spec_boolean ("smarturl",
- "Smart url",
- "Smart url",
- FALSE,
- G_PARAM_READABLE));
+ PROP_SMART_URL,
+ g_param_spec_boolean ("smarturl",
+ "Smart url",
+ "Smart url",
+ FALSE,
+ G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_ICON,
- g_param_spec_string ("icon",
- "Icon",
- "Icon",
- NULL,
- G_PARAM_READABLE));
+ PROP_ICON,
+ g_param_spec_string ("icon",
+ "Icon",
+ "Icon",
+ NULL,
+ G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof(EphyBookmarkActionPrivate));
}
static void
-smart_child_added_cb (EphyNode *smart_bmks,
- EphyNode *child,
- EphyBookmarkAction *action)
-{
- if (ephy_node_get_id (action->priv->node) == ephy_node_get_id (child))
- {
- action->priv->smart_url = TRUE;
- g_object_notify (G_OBJECT (action), "smarturl");
- }
-}
-
-static void
-smart_child_removed_cb (EphyNode *smart_bmks,
- EphyNode *child,
- guint old_index,
- EphyBookmarkAction *action)
-{
- if (ephy_node_get_id (action->priv->node) == ephy_node_get_id (child))
- {
- action->priv->smart_url = FALSE;
- g_object_notify (G_OBJECT (action), "smarturl");
- }
-}
-
-static void
ephy_bookmark_action_init (EphyBookmarkAction *action)
{
- EphyBookmarks *bookmarks;
- EphyNode *node;
-
action->priv = EPHY_BOOKMARK_ACTION_GET_PRIVATE (action);
+ action->priv->cache_handler = 0;
+}
- bookmarks = ephy_shell_get_bookmarks (ephy_shell);
- node = ephy_bookmarks_get_smart_bookmarks (bookmarks);
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED,
- (EphyNodeCallback) smart_child_added_cb,
- G_OBJECT (action));
- ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED,
- (EphyNodeCallback) smart_child_removed_cb,
- G_OBJECT (action));
+char *
+ephy_bookmark_action_name (EphyNode *node)
+{
+ return g_strdup_printf("Bmk%u", ephy_node_get_id (node));
}
GtkAction *
-ephy_bookmark_action_new (const char *name,
- EphyNode *node)
+ephy_bookmark_action_new (EphyNode *node, char *name)
{
- g_return_val_if_fail (node != NULL, NULL);
+ GtkAction *action;
+
+ if(!name) name = ephy_bookmark_action_name (node);
+ g_return_val_if_fail (name, NULL);
+
+ action = GTK_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION,
+ "name", name,
+ "bookmark", node,
+ NULL));
- return g_object_new (EPHY_TYPE_BOOKMARK_ACTION,
- "name", name,
- "bookmark", node,
- NULL);
+ return action;
}