? P ? t Index: ephy-bookmark-action-group.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmark-action-group.c,v retrieving revision 1.4 diff -p -u -u -p -U10 -r1.4 ephy-bookmark-action-group.c --- ephy-bookmark-action-group.c 9 Feb 2006 13:52:45 -0000 1.4 +++ ephy-bookmark-action-group.c 10 Feb 2006 20:46:34 -0000 @@ -17,136 +17,126 @@ * * $Id: ephy-bookmark-action-group.c,v 1.4 2006/02/09 13:52:45 chpe Exp $ */ #include "config.h" #include "ephy-shell.h" #include "ephy-bookmark-action-group.h" #include "ephy-bookmark-action.h" #include "ephy-bookmarks.h" +#include "ephy-bookmarks-ui.h" #include "ephy-link.h" #include "ephy-node.h" #include "ephy-node-common.h" #include "ephy-debug.h" #include #include #include static void smart_added_cb (EphyNode *parent, EphyNode *child, - GtkActionGroup *actions) + GtkActionGroup *action_group) { GtkAction *action; - char *name; - - name = ephy_bookmark_action_name (child); - g_return_if_fail (name); - action = gtk_action_group_get_action (actions, name); + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; + + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); + + action = gtk_action_group_get_action (action_group, name); - if (action) + if (action != NULL) { - ephy_bookmark_action_updated - (EPHY_BOOKMARK_ACTION (action)); + ephy_bookmark_action_updated ((EphyBookmarkAction *) action); } - - g_free (name); } - static void smart_removed_cb (EphyNode *parent, EphyNode *child, guint index, - GtkActionGroup *actions) + GtkActionGroup *action_group) { GtkAction *action; - char *name; - - name = ephy_bookmark_action_name (child); - g_return_if_fail (name); - action = gtk_action_group_get_action (actions, name); + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; + + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); + + action = gtk_action_group_get_action (action_group, name); - if (action) + if (action != NULL) { - ephy_bookmark_action_updated - (EPHY_BOOKMARK_ACTION (action)); + ephy_bookmark_action_updated ((EphyBookmarkAction *) action); } - - g_free (name); } static void node_changed_cb (EphyNode *parent, EphyNode *child, guint property_id, - GtkActionGroup *actions) + GtkActionGroup *action_group) { GtkAction *action; - char *name; - - name = ephy_bookmark_action_name (child); - g_assert (name != NULL); + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; - action = gtk_action_group_get_action (actions, name); + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); + + action = gtk_action_group_get_action (action_group, name); - if (action) + if (action != NULL) { - ephy_bookmark_action_updated - (EPHY_BOOKMARK_ACTION (action)); + ephy_bookmark_action_updated ((EphyBookmarkAction *) action); } - - g_free (name); } static void node_added_cb (EphyNode *parent, EphyNode *child, GtkActionGroup *action_group) { GtkAction *action; - char *name, *accel; - - name = ephy_bookmark_action_name (child); + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; + char accel[256]; + + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); + action = ephy_bookmark_action_new (child, name); - accel = g_strjoin ("/", "", - gtk_action_group_get_name (action_group), - name, NULL); + + g_snprintf (accel, sizeof (accel), "/%s/%s", + gtk_action_group_get_name (action_group), + name); gtk_action_set_accel_path (action, accel); gtk_action_group_add_action (action_group, action); g_object_unref (action); - g_free (accel); - g_free (name); + ephy_bookmark_action_updated ((EphyBookmarkAction *) action); - ephy_bookmark_action_updated (EPHY_BOOKMARK_ACTION (action)); - g_signal_connect_swapped (action, "open-link", G_CALLBACK (ephy_link_open), action_group); } static void node_removed_cb (EphyNode *parent, EphyNode *child, guint index, GtkActionGroup *action_group) { GtkAction *action; char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); action = gtk_action_group_get_action (action_group, name); - if (action) + if (action != NULL) { gtk_action_group_remove_action (action_group, action); } } GtkActionGroup * ephy_bookmark_group_new (EphyNode *node) { EphyBookmarks *bookmarks; EphyNode *smart; Index: ephy-bookmark-action.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmark-action.c,v retrieving revision 1.76 diff -p -u -u -p -U10 -r1.76 ephy-bookmark-action.c --- ephy-bookmark-action.c 9 Feb 2006 13:52:45 -0000 1.76 +++ ephy-bookmark-action.c 10 Feb 2006 20:46:35 -0000 @@ -682,31 +682,21 @@ ephy_bookmark_action_get_type (void) }; type = g_type_register_static (EPHY_TYPE_LINK_ACTION, "EphyBookmarkAction", &type_info, 0); } return type; } -char * -ephy_bookmark_action_name (EphyNode *node) -{ - return g_strdup_printf("Bmk%u", ephy_node_get_id (node)); -} - GtkAction * -ephy_bookmark_action_new (EphyNode *node, char *name) +ephy_bookmark_action_new (EphyNode *node, + const char *name) { - 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)); + g_assert (name != NULL); - return action; + return GTK_ACTION (g_object_new (EPHY_TYPE_BOOKMARK_ACTION, + "name", name, + "bookmark", node, + NULL)); } Index: ephy-bookmark-action.h =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmark-action.h,v retrieving revision 1.11 diff -p -u -u -p -U10 -r1.11 ephy-bookmark-action.h --- ephy-bookmark-action.h 9 Feb 2006 13:52:45 -0000 1.11 +++ ephy-bookmark-action.h 10 Feb 2006 20:46:35 -0000 @@ -30,51 +30,47 @@ G_BEGIN_DECLS #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)) -#define EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE 32 /* >= strlen ("Bmk") + max size of gulong + 1 */ -#define EPHY_BOOKMARK_ACTION_NAME_PRINTF(buffer,node) (g_snprintf (buffer, sizeof (buffer), "Bmk%u", ephy_node_get_id (node))) - typedef struct _EphyBookmarkAction EphyBookmarkAction; typedef struct _EphyBookmarkActionPrivate EphyBookmarkActionPrivate; typedef struct _EphyBookmarkActionClass EphyBookmarkActionClass; struct _EphyBookmarkAction { EphyLinkAction parent_instance; /*< private >*/ EphyBookmarkActionPrivate *priv; }; struct _EphyBookmarkActionClass { EphyLinkActionClass parent_class; }; -GType ephy_bookmark_action_get_type (void); - -char * ephy_bookmark_action_name (EphyNode *node); - -GtkAction * ephy_bookmark_action_new (EphyNode *node, char *name); +GType ephy_bookmark_action_get_type (void); +GtkAction *ephy_bookmark_action_new (EphyNode *node, + const char *name); -void ephy_bookmark_action_set_bookmark (EphyBookmarkAction *action, EphyNode *node); +void ephy_bookmark_action_set_bookmark (EphyBookmarkAction *action, + EphyNode *node); -EphyNode * ephy_bookmark_action_get_bookmark (EphyBookmarkAction *action); +EphyNode *ephy_bookmark_action_get_bookmark (EphyBookmarkAction *action); -void ephy_bookmark_action_updated (EphyBookmarkAction *action); +void ephy_bookmark_action_updated (EphyBookmarkAction *action); -void ephy_bookmark_action_activate (EphyBookmarkAction *action, - GtkWidget *widget, - EphyLinkFlags flags); +void ephy_bookmark_action_activate (EphyBookmarkAction *action, + GtkWidget *widget, + EphyLinkFlags flags); G_END_DECLS #endif Index: ephy-bookmark-factory-action.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmark-factory-action.c,v retrieving revision 1.3 diff -p -u -u -p -U10 -r1.3 ephy-bookmark-factory-action.c --- ephy-bookmark-factory-action.c 4 Feb 2006 10:43:24 -0000 1.3 +++ ephy-bookmark-factory-action.c 10 Feb 2006 20:46:36 -0000 @@ -18,20 +18,21 @@ * $Id: ephy-bookmark-factory-action.c,v 1.3 2006/02/04 10:43:24 paharvey Exp $ */ #include "config.h" #include #include #include "ephy-bookmark-factory-action.h" #include "ephy-bookmark-action.h" +#include "ephy-bookmarks-ui.h" #include "ephy-node-common.h" #include "ephy-shell.h" #include "ephy-stock-icons.h" #include "egg-editable-toolbar.h" static void ephy_bookmark_factory_action_class_init (EphyBookmarkFactoryActionClass *class); #define EPHY_BOOKMARK_FACTORY_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BOOKMARK_FACTORY_ACTION, EphyBookmarkActionPrivate)) #define EGG_TOOLBARS_MODEL_DATA "ephy-bookmark-factory-menu" @@ -90,39 +91,41 @@ activate_item_cb (GtkWidget *menuitem, G id = g_object_get_data (G_OBJECT (menuitem), "ephy-action"); egg_toolbars_model_add_item (model, pos, index, id); } static GtkWidget * build_menu_for_topic (GtkWidget *placeholder, EggToolbarsModel *model, EphyNode *topic) { GtkWidget *menu, *item; EphyNode *node; GPtrArray *children, *bookmarks; - const char *name, *action; + const char *name; + char action[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; gint i, flags; children = ephy_node_get_children (topic); bookmarks = g_ptr_array_sized_new (children->len); for (i = 0; i < children->len; i++) g_ptr_array_add (bookmarks, g_ptr_array_index (children, i)); g_ptr_array_sort (bookmarks, (GCompareFunc)ephy_bookmarks_compare_bookmark_pointers); menu = NULL; for (i = 0; i < bookmarks->len; i++) { node = g_ptr_array_index (bookmarks, i); - action = ephy_bookmark_action_name (node); + EPHY_BOOKMARK_ACTION_NAME_PRINTF (action, node); + flags = egg_toolbars_model_get_name_flags (model, action); if (flags & EGG_TB_MODEL_NAME_USED) - continue; + continue; name = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_TITLE); item = gtk_menu_item_new_with_label (name); g_object_set_data_full (G_OBJECT (item), "ephy-action", (gpointer) action, g_free); g_signal_connect (item, "activate", G_CALLBACK (activate_item_cb), placeholder); gtk_widget_show (item); if (menu == NULL) menu = gtk_menu_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); Index: ephy-bookmarks-editor.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-editor.c,v retrieving revision 1.186 diff -p -u -u -p -U10 -r1.186 ephy-bookmarks-editor.c --- ephy-bookmarks-editor.c 9 Feb 2006 10:29:24 -0000 1.186 +++ ephy-bookmarks-editor.c 10 Feb 2006 20:46:36 -0000 @@ -427,91 +427,98 @@ delete_topic_dialog_construct (GtkWindow } static void cmd_toolbar (GtkAction *action, EphyBookmarksEditor *editor) { EggToolbarsModel *model; EphyNode *node; gboolean show; const char *tname; - char *name; gint flags, tpos; GList *selection; GList *l; model = EGG_TOOLBARS_MODEL (ephy_shell_get_toolbars_model (ephy_shell_get_default (), FALSE)); for (tpos = 0; tpos < egg_toolbars_model_n_toolbars (model); tpos++) { tname = egg_toolbars_model_toolbar_nth (model, tpos); if (tname != NULL && strcmp (tname, "Bookmarks") == 0) break; } if (tpos == egg_toolbars_model_n_toolbars (model)) { tpos = egg_toolbars_model_add_toolbar (model, -1, "Bookmarks"); } if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view))) { + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; + selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->bm_view)); node = selection->data; - name = ephy_bookmark_action_name (node); + + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, node); + flags = egg_toolbars_model_get_name_flags (model, name); show = ((flags & EGG_TB_MODEL_NAME_USED) == 0); - g_free (name); for (l = selection; l; l = l->next) { node = l->data; - name = ephy_bookmark_action_name (node); + + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, node); + flags = egg_toolbars_model_get_name_flags (model, name); if(show && ((flags & EGG_TB_MODEL_NAME_USED) == 0)) { egg_toolbars_model_add_item (model, tpos, -1, name); } else if(!show && ((flags & EGG_TB_MODEL_NAME_USED) != 0)) { egg_toolbars_model_delete_item (model, name); } - g_free (name); } g_list_free (selection); } else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->key_view))) { + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; + selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view)); node = selection->data; - name = ephy_topic_action_name (node); + + EPHY_TOPIC_ACTION_NAME_PRINTF (name, node); + flags = egg_toolbars_model_get_name_flags (model, name); show = ((flags & EGG_TB_MODEL_NAME_USED) == 0); - g_free (name); for (l = selection; l; l = l->next) { node = l->data; - name = ephy_topic_action_name (node); + + EPHY_TOPIC_ACTION_NAME_PRINTF (name, node); + flags = egg_toolbars_model_get_name_flags (model, name); if(show && ((flags & EGG_TB_MODEL_NAME_USED) == 0)) { egg_toolbars_model_add_item (model, tpos, -1, name); } else if(!show && ((flags & EGG_TB_MODEL_NAME_USED) != 0)) { egg_toolbars_model_delete_item (model, name); } - g_free (name); } g_list_free (selection); } } static void cmd_delete (GtkAction *action, EphyBookmarksEditor *editor) { @@ -1243,21 +1250,20 @@ ephy_bookmarks_editor_update_menu (EphyB gboolean mutable = TRUE; gboolean showtoolbar = FALSE; gboolean ontoolbar = FALSE; EggToolbarsModel *model; GtkActionGroup *action_group; GtkAction *action; GList *selected; GtkWidget *focus_widget; int num_bmk_selected; - char *name; LOG ("Update menu sensitivity"); model = EGG_TOOLBARS_MODEL (ephy_shell_get_toolbars_model (ephy_shell_get_default(), FALSE)); bmk_focus = ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->bm_view)); key_focus = ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->key_view)); @@ -1289,49 +1295,49 @@ ephy_bookmarks_editor_update_menu (EphyB copy = (bmk_focus && single_bmk_selected); paste = FALSE; select_all = bmk_focus; } selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->key_view)); if (key_focus && selected) { EphyNode *node = selected->data; EphyNodePriority priority; + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); if (priority == -1) priority = EPHY_NODE_NORMAL_PRIORITY; key_normal = (priority == EPHY_NODE_NORMAL_PRIORITY); - name = ephy_topic_action_name (node); + EPHY_TOPIC_ACTION_NAME_PRINTF (name, node); + ontoolbar = ((egg_toolbars_model_get_name_flags (model, name) & EGG_TB_MODEL_NAME_USED) != 0); - g_free (name); g_list_free (selected); } selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->bm_view)); if (bmk_focus && selected) { EphyNode *node = selected->data; - guint id; + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; g_return_if_fail (node != NULL); - id = ephy_node_get_id (node); mutable = !ephy_node_get_property_boolean (node, EPHY_NODE_BMK_PROP_IMMUTABLE); - name = ephy_bookmark_action_name (node); + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, node); + ontoolbar = ((egg_toolbars_model_get_name_flags (model, name) & EGG_TB_MODEL_NAME_USED) != 0); - g_free (name); g_list_free (selected); } open_in_window_label = ngettext ("Open in New _Window", "Open in New _Windows", num_bmk_selected); open_in_tab_label = ngettext ("Open in New _Tab", "Open in New _Tabs", num_bmk_selected); Index: ephy-bookmarks-menu.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-menu.c,v retrieving revision 1.46 diff -p -u -u -p -U10 -r1.46 ephy-bookmarks-menu.c --- ephy-bookmarks-menu.c 17 Jan 2006 22:56:59 -0000 1.46 +++ ephy-bookmarks-menu.c 10 Feb 2006 20:46:36 -0000 @@ -44,34 +44,37 @@ enum { BUILD_SUBDIVIS = 1 << 0, BUILD_SUBMENUS = 1 << 1, BUILD_CHILD_SUBDIVIS = 1 << 2, BUILD_CHILD_SUBMENUS = 1 << 3 }; /* Construct a block of bookmark actions, postfixing the names with a topic id * to allow different. */ static void -append_bookmarks (GString *string, const GPtrArray *bookmarks, gint instance) +append_bookmarks (GString *string, + const GPtrArray *bookmarks, + int instance) { - char *name; + EphyNode *child; + char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE]; + long i; for (i = 0; i < bookmarks->len; i++) { - name = ephy_bookmark_action_name (g_ptr_array_index (bookmarks, i)); - if (name) - { - g_string_append_printf (string, "", - name, name, instance); - g_free (name); - } + child = g_ptr_array_index (bookmarks, i); + + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); + + g_string_append_printf (string, "", + name, name, instance); } } /* Build a menu of the given bookmarks categorised by the given topics. * Shows categorisation using subdivisions, submenus, or a mix of both. */ static void append_menu (GString *string, const GPtrArray *topics, const GPtrArray *bookmarks, guint flags) { GPtrArray *uncovered; guint i, j; @@ -79,21 +82,21 @@ append_menu (GString *string, const GPtr gboolean use_subdivis = flags & BUILD_SUBDIVIS; gboolean use_submenus = flags & BUILD_SUBMENUS; if (use_subdivis || use_submenus) { GPtrArray *subset, *covering, *subdivisions, *submenus, *unused; GArray *sizes = 0; EphyNode *topic; gint size, total; gboolean separate = FALSE; - char *name; + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; /* Get the subtopics, uncovered bookmarks, and subtopic sizes. */ sizes = g_array_sized_new (FALSE, FALSE, sizeof(int), topics->len); uncovered = g_ptr_array_sized_new (bookmarks->len); covering = ephy_nodes_get_covering (topics, bookmarks, 0, uncovered, sizes); /* Preallocate arrays for submenus, subdivisions, and bookmark subsets. */ subdivisions = g_ptr_array_sized_new (topics->len); submenus = g_ptr_array_sized_new (topics->len); subset = g_ptr_array_sized_new (bookmarks->len); @@ -126,31 +129,28 @@ append_menu (GString *string, const GPtr g_ptr_array_sort (subdivisions, ephy_bookmarks_compare_topic_pointers); if (flags & BUILD_CHILD_SUBDIVIS) flags |= BUILD_SUBDIVIS; if (flags & BUILD_CHILD_SUBMENUS) flags |= BUILD_SUBMENUS; /* Create each of the submenus. */ for (i = 0; i < submenus->len; i++) { topic = g_ptr_array_index (submenus, i); ephy_nodes_get_covered (topic, bookmarks, subset); - - name = ephy_topic_action_name (topic); - if (name) - { - g_string_append_printf (string, "", - name, name); - append_menu (string, topics, subset, flags); - g_string_append (string, ""); - separate = TRUE; - g_free (name); - } + + EPHY_TOPIC_ACTION_NAME_PRINTF (name, topic); + + g_string_append_printf (string, "", + name, name); + append_menu (string, topics, subset, flags); + g_string_append (string, ""); + separate = TRUE; } /* Build a list of bookmarks which don't appear in any subdivision yet. */ for (i = 0; i < bookmarks->len; i++) { g_ptr_array_add (unused, g_ptr_array_index (bookmarks, i)); } /* Create each of the subdivisions. */ for (i = 0; i < subdivisions->len; i++) @@ -245,24 +245,24 @@ ephy_bookmarks_menu_build (GString *stri g_ptr_array_add (topics, ephy_bookmarks_get_local (eb)); } append_menu (string, topics, children, flags); g_ptr_array_free (topics, TRUE); } /* Otherwise, build the menu with "Open in tabs". */ else { - char *name; + char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE]; append_menu (string, topics, children, flags); g_ptr_array_free (topics, TRUE); if (children->len > 1) { - name = ephy_open_tabs_action_name (node); + EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, node); + g_string_append_printf - (string, "", name); - g_free (name); + (string, "", name); } } } Index: ephy-bookmarks-ui.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-ui.c,v retrieving revision 1.11 diff -p -u -u -p -U10 -r1.11 ephy-bookmarks-ui.c --- ephy-bookmarks-ui.c 9 Feb 2006 13:52:45 -0000 1.11 +++ ephy-bookmarks-ui.c 10 Feb 2006 20:46:36 -0000 @@ -249,21 +249,21 @@ ephy_bookmarks_ui_attach_window (EphyWin g_object_set_data_full (G_OBJECT (window), BM_WINDOW_DATA_KEY, data, g_free); /* Create the self-maintaining action groups for bookmarks and topics */ actions = ephy_bookmark_group_new (bookmarks); gtk_ui_manager_insert_action_group (manager, actions, -1); g_signal_connect_object (actions, "open-link", G_CALLBACK (ephy_link_open), G_OBJECT (window), G_CONNECT_SWAPPED | G_CONNECT_AFTER); g_object_unref (actions); - actions = ephy_topic_group_new (topics, manager); + actions = ephy_topic_action_group_new (topics, manager); gtk_ui_manager_insert_action_group (manager, actions, -1); g_object_unref (actions); actions = ephy_open_tabs_group_new (topics); gtk_ui_manager_insert_action_group (manager, actions, -1); g_signal_connect_object (actions, "open-link", G_CALLBACK (ephy_link_open), G_OBJECT (window), G_CONNECT_SWAPPED | G_CONNECT_AFTER); g_object_unref (actions); @@ -489,154 +489,169 @@ static EggToolbarsItemType bookmark_type static EggToolbarsItemType topic_type; static EphyBookmarks *eb; static gboolean topic_has_data (EggToolbarsItemType *type, const char *name) { EphyNode *node, *topics; guint node_id; - if (sscanf (name, "OpenTopic%u", &node_id) != 1 && - sscanf (name, "Tpc%u", &node_id) != 1) return FALSE; + if (sscanf (name, "OpenTopic%u" /* FIXME!! */, &node_id) != 1 && + sscanf (name, EPHY_TOPIC_ACTION_NAME_FORMAT, &node_id) != 1) return FALSE; + node = ephy_bookmarks_get_from_id (eb, node_id); - if (!node) return FALSE; + if (node == NULL) return FALSE; + topics = ephy_bookmarks_get_keywords (eb); + return ephy_node_has_child (topics, node); } static char * topic_get_data (EggToolbarsItemType *type, const char *name) { EphyNode *node; guint node_id; - if (sscanf (name, "OpenTopic%u", &node_id) != 1 && - sscanf (name, "Tpc%u", &node_id) != 1) return NULL; + if (sscanf (name, "OpenTopic%u" /* FIXME!! */, &node_id) != 1 && + sscanf (name, EPHY_TOPIC_ACTION_NAME_FORMAT, &node_id) != 1) return NULL; + node = ephy_bookmarks_get_from_id (eb, node_id); - if (!node) return NULL; + if (node == NULL) return NULL; + return ephy_bookmarks_get_topic_uri (eb, node); } static char * topic_get_name (EggToolbarsItemType *type, const char *name) { - EphyNode *topic = ephy_bookmarks_find_keyword (eb, name, FALSE); + EphyNode *topic; + + topic = ephy_bookmarks_find_keyword (eb, name, FALSE); if (topic == NULL) return NULL; - return ephy_topic_action_name (topic); -} + return EPHY_TOPIC_ACTION_NAME_STRDUP_PRINTF (topic); +} static gboolean bookmark_has_data (EggToolbarsItemType *type, const char *name) { EphyNode *node; guint node_id; - - if (sscanf (name, "OpenBmk%u", &node_id) != 1 && - sscanf (name, "Bmk%u", &node_id) != 1) return FALSE; + + if (sscanf (name, "OpenBmk%u" /* FIXME!! */, &node_id) != 1 && + sscanf (name, EPHY_BOOKMARK_ACTION_NAME_FORMAT, &node_id) != 1) return FALSE; + node = ephy_bookmarks_get_from_id (eb, node_id); - if (!node) return FALSE; - + if (node == NULL) return FALSE; + return (ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION) != NULL); } static char * bookmark_get_data (EggToolbarsItemType *type, const char *name) { EphyNode *node; guint node_id; - - if (sscanf (name, "OpenBmk%u", &node_id) != 1 && - sscanf (name, "Bmk%u", &node_id) != 1) return NULL; + + if (sscanf (name, "OpenBmk%u" /* FIXME!! */, &node_id) != 1 && + sscanf (name, EPHY_BOOKMARK_ACTION_NAME_FORMAT, &node_id) != 1) return NULL; + node = ephy_bookmarks_get_from_id (eb, node_id); - if (!node) return NULL; - + if (node == NULL) return NULL; + return g_strdup (ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION)); } static char * bookmark_get_name (EggToolbarsItemType *type, const char *data) { EphyNode *node; gchar **netscape_url; netscape_url = g_strsplit (data, "\n", 2); - if (!netscape_url || !netscape_url[0]) + if (netscape_url == NULL || netscape_url[0] == '\0') { g_strfreev (netscape_url); + return NULL; } node = ephy_bookmarks_find_bookmark (eb, netscape_url[0]); g_strfreev (netscape_url); - if (!node) return NULL; - return ephy_bookmark_action_name (node); + if (node == NULL) return NULL; + + return EPHY_BOOKMARK_ACTION_NAME_STRDUP_PRINTF (node); } static char * bookmark_new_name (EggToolbarsItemType *type, const char *data) { EphyNode *node; gchar **netscape_url; netscape_url = g_strsplit (data, "\n", 2); - if (!netscape_url || !netscape_url[0]) + if (netscape_url == NULL || netscape_url[0] == '\0' || g_strv_length (netscape_url) < 2) { g_strfreev (netscape_url); + return NULL; } node = ephy_bookmarks_add (eb, netscape_url[1], netscape_url[0]); - g_strfreev (netscape_url); - return ephy_bookmark_action_name (node); + return EPHY_BOOKMARK_ACTION_NAME_STRDUP_PRINTF (node); } static void -toolbar_node_removed_cb (EphyNode *parent, EphyNode *child, guint index, EggToolbarsModel *model) +toolbar_node_removed_cb (EphyNode *parent, + EphyNode *child, + guint index, + EggToolbarsModel *model) { - gint i, j; - char *nid = NULL; + char name[EPHY_BOOKMARKS_UI_ACTION_NAME_BUFFER_SIZE]; const char *id; + int i, j; switch (ephy_node_get_id (parent)) { case BOOKMARKS_NODE_ID: - nid = ephy_bookmark_action_name (child); + EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child); break; case KEYWORDS_NODE_ID: - nid = ephy_topic_action_name (child); + EPHY_TOPIC_ACTION_NAME_PRINTF (name, child); break; default: return; } - for (i=egg_toolbars_model_n_toolbars(model)-1; i>=0; i--) - for (j=egg_toolbars_model_n_items(model, i)-1; j>=0; j--) - { - id = egg_toolbars_model_item_nth (model, i, j); - if (!strcmp (id, nid)) - { - egg_toolbars_model_remove_item (model, i, j); - } - } - - free (nid); + for (i = (int) egg_toolbars_model_n_toolbars(model) - 1; i >= 0; --i) + { + for (j = (int) egg_toolbars_model_n_items (model, i) - 1; j >= 0; --j) + { + id = egg_toolbars_model_item_nth (model, i, j); + + if (strcmp (id, name) == 0) + { + egg_toolbars_model_remove_item (model, i, j); + } + } + } } void ephy_bookmarks_ui_attach_toolbar_model (EggToolbarsModel *model) { EphyNode *bookmarks; EphyNode *topics; GList *types; eb = ephy_shell_get_bookmarks (ephy_shell); Index: ephy-bookmarks-ui.h =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-ui.h,v retrieving revision 1.6 diff -p -u -u -p -U10 -r1.6 ephy-bookmarks-ui.h --- ephy-bookmarks-ui.h 4 Feb 2006 09:26:08 -0000 1.6 +++ ephy-bookmarks-ui.h 10 Feb 2006 20:46:36 -0000 @@ -17,20 +17,40 @@ * * $Id: ephy-bookmarks-ui.h,v 1.6 2006/02/04 09:26:08 paharvey Exp $ */ #ifndef EPHY_BOOKMARKS_UI_H #define EPHY_BOOKMARKS_UI_H #include "ephy-window.h" #include "egg-toolbars-model.h" +#define EPHY_BOOKMARKS_UI_ACTION_NAME_BUFFER_SIZE 32 + +#define EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE EPHY_BOOKMARKS_UI_ACTION_NAME_BUFFER_SIZE +#define EPHY_BOOKMARK_ACTION_NAME_FORMAT "Bmk%u" +#define EPHY_BOOKMARK_ACTION_NAME_FORMAT_ARG(node) (ephy_node_get_id (node)) +#define EPHY_BOOKMARK_ACTION_NAME_PRINTF(buffer,node) (g_snprintf (buffer, sizeof (buffer), EPHY_BOOKMARK_ACTION_NAME_FORMAT, EPHY_BOOKMARK_ACTION_NAME_FORMAT_ARG (node))) +#define EPHY_BOOKMARK_ACTION_NAME_STRDUP_PRINTF(node) (g_strdup_printf (EPHY_BOOKMARK_ACTION_NAME_FORMAT, EPHY_BOOKMARK_ACTION_NAME_FORMAT_ARG (node))) + +#define EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE EPHY_BOOKMARKS_UI_ACTION_NAME_BUFFER_SIZE +#define EPHY_TOPIC_ACTION_NAME_FORMAT "Tp%u" +#define EPHY_TOPIC_ACTION_NAME_FORMAT_ARG(node) (ephy_node_get_id (node)) +#define EPHY_TOPIC_ACTION_NAME_PRINTF(buffer,node) (g_snprintf (buffer, sizeof (buffer), EPHY_TOPIC_ACTION_NAME_FORMAT, EPHY_TOPIC_ACTION_NAME_FORMAT_ARG (node))) +#define EPHY_TOPIC_ACTION_NAME_STRDUP_PRINTF(node) (g_strdup_printf (EPHY_TOPIC_ACTION_NAME_FORMAT, EPHY_TOPIC_ACTION_NAME_FORMAT_ARG (node))) + +#define EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE EPHY_BOOKMARKS_UI_ACTION_NAME_BUFFER_SIZE +#define EPHY_OPEN_TABS_ACTION_NAME_FORMAT "OpTb%u" +#define EPHY_OPEN_TABS_ACTION_NAME_FORMAT_ARG(node) (ephy_node_get_id (node)) +#define EPHY_OPEN_TABS_ACTION_NAME_PRINTF(buffer,node) (g_snprintf (buffer, sizeof (buffer), EPHY_OPEN_TABS_ACTION_NAME_FORMAT, EPHY_OPEN_TABS_ACTION_NAME_FORMAT_ARG (node))) +#define EPHY_OPEN_TABS_ACTION_NAME_STRDUP_PRINTF(node) (g_strdup_printf (EPHY_OPEN_TABS_ACTION_NAME_FORMAT, EPHY_OPEN_TABS_ACTION_NAME_FORMAT_ARG (node))) + #include void ephy_bookmarks_ui_attach_window (EphyWindow *window); void ephy_bookmarks_ui_detach_window (EphyWindow *window); void ephy_bookmarks_ui_attach_toolbar_model (EggToolbarsModel *model); void ephy_bookmarks_ui_detach_toolbar_model (EggToolbarsModel *model); void ephy_bookmarks_ui_add_bookmark (GtkWindow *parent, const char *location, Index: ephy-open-tabs-action.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-open-tabs-action.c,v retrieving revision 1.4 diff -p -u -u -p -U10 -r1.4 ephy-open-tabs-action.c --- ephy-open-tabs-action.c 9 Feb 2006 13:52:45 -0000 1.4 +++ ephy-open-tabs-action.c 10 Feb 2006 20:46:36 -0000 @@ -16,20 +16,21 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: ephy-open-tabs-action.c,v 1.4 2006/02/09 13:52:45 chpe Exp $ */ #include "config.h" #include "ephy-open-tabs-action.h" #include "ephy-bookmarks.h" +#include "ephy-bookmarks-ui.h" #include "ephy-node-common.h" #include "ephy-link-action.h" #include "ephy-link.h" #include #include #include #include @@ -60,65 +61,60 @@ activate_cb (GtkAction *action, } } static void node_added_cb (EphyNode *parent, EphyNode *child, GtkActionGroup *action_group) { GObject *action_object; GtkAction *action; - char *name, *accel; - - name = ephy_open_tabs_action_name (child); - g_assert (name != NULL); + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; + char accel[256]; + EPHY_TOPIC_ACTION_NAME_PRINTF (name, child); + /* FIXME !!!! */ action = gtk_action_new (name, _("Open in New _Tabs"), "Open this topic in tabs", NULL); - action_object = G_OBJECT (action); + action_object = (GObject *) action; g_object_set_data (action_object, "ephy-node", child); g_object_set_data (action_object, "ephy-link", EPHY_LINK (action_group)); g_signal_connect (action, "activate", G_CALLBACK (activate_cb), NULL); - accel = g_strjoin ("/", "", - gtk_action_group_get_name (action_group), - name, - NULL); + g_snprintf (accel, sizeof (accel), "/%s/%s", + gtk_action_group_get_name (action_group), + name); gtk_action_set_accel_path (action, accel); gtk_action_group_add_action (action_group, action); g_object_unref (action); - - g_free (accel); - g_free (name); } static void node_removed_cb (EphyNode *parent, EphyNode *child, guint index, GtkActionGroup *action_group) { GtkAction *action; - char *name; + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; - name = ephy_open_tabs_action_name (child); + EPHY_TOPIC_ACTION_NAME_PRINTF (name, child); + + action = gtk_action_group_get_action (action_group, name); - // FIXME can this really ever be NULL ?? - if (name) + if (action != NULL) { - action = gtk_action_group_get_action (action_group, name); - if (action) gtk_action_group_remove_action (action_group, action); - g_free (name); + gtk_action_group_remove_action (action_group, action); } } GtkActionGroup * ephy_open_tabs_group_new (EphyNode *node) { GPtrArray *children; GtkActionGroup *action_group; guint i; @@ -132,17 +128,11 @@ ephy_open_tabs_group_new (EphyNode *node } ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED, (EphyNodeCallback) node_added_cb, (GObject *) action_group); ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED, (EphyNodeCallback) node_removed_cb, (GObject *) action_group); return action_group; -} - -char * -ephy_open_tabs_action_name (EphyNode *node) -{ - return g_strdup_printf("OpTb%u", ephy_node_get_id (node)); } Index: ephy-open-tabs-action.h =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-open-tabs-action.h,v retrieving revision 1.2 diff -p -u -u -p -U10 -r1.2 ephy-open-tabs-action.h --- ephy-open-tabs-action.h 24 Jan 2006 23:21:31 -0000 1.2 +++ ephy-open-tabs-action.h 10 Feb 2006 20:46:36 -0000 @@ -18,15 +18,13 @@ * $Id: ephy-open-tabs-action.h,v 1.2 2006/01/24 23:21:31 chpe Exp $ */ #ifndef EPHY_OPEN_TABS_ACTION_H #define EPHY_OPEN_TABS_ACTION_H #include #include "ephy-node.h" -char * ephy_open_tabs_action_name (EphyNode *node); - -GtkActionGroup * ephy_open_tabs_group_new (EphyNode *node); +GtkActionGroup *ephy_open_tabs_group_new (EphyNode *node); #endif Index: ephy-topic-action-group.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-topic-action-group.c,v retrieving revision 1.3 diff -p -u -u -p -U10 -r1.3 ephy-topic-action-group.c --- ephy-topic-action-group.c 24 Jan 2006 23:21:31 -0000 1.3 +++ ephy-topic-action-group.c 10 Feb 2006 20:46:36 -0000 @@ -18,109 +18,111 @@ * $Id: ephy-topic-action-group.c,v 1.3 2006/01/24 23:21:31 chpe Exp $ */ #include "config.h" #include "ephy-topic-action-group.h" #include "ephy-topic-action.h" #include "ephy-node.h" #include "ephy-node-common.h" #include "ephy-bookmarks.h" +#include "ephy-bookmarks-ui.h" #include "ephy-debug.h" #include #include -#include - static void node_changed_cb (EphyNode *parent, EphyNode *child, guint property_id, - GtkActionGroup *actions) + GtkActionGroup *action_group) { GtkAction *action; - char *name; - - name = ephy_topic_action_name (child); - g_return_if_fail (name != NULL); - action = gtk_action_group_get_action (actions, name); + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; + + EPHY_TOPIC_ACTION_NAME_PRINTF (name, child); + + action = gtk_action_group_get_action (action_group, name); if (property_id == EPHY_NODE_KEYWORD_PROP_NAME) { ephy_topic_action_updated (EPHY_TOPIC_ACTION (action)); } - - g_free (name); } static void node_added_cb (EphyNode *parent, EphyNode *child, - GtkActionGroup *actions) + GtkActionGroup *action_group) { GtkUIManager *manager; GtkAction *action; - char *name, *accel; - - manager = g_object_get_data ((GObject *)actions, "ui-manager"); - name = ephy_topic_action_name (child); + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; + char accel[256]; + + EPHY_TOPIC_ACTION_NAME_PRINTF (name, child); + + manager = g_object_get_data ((GObject *) action_group, "ui-manager"); + action = ephy_topic_action_new (child, manager, name); - accel = g_strjoin ("/", "", - gtk_action_group_get_name (actions), - name, NULL); + + g_snprintf (accel, sizeof (accel), "/%s/%s", + gtk_action_group_get_name (action_group), + name); gtk_action_set_accel_path (action, accel); - gtk_action_group_add_action (actions, action); + + gtk_action_group_add_action (action_group, action); g_object_unref (action); - g_free (accel); - g_free (name); - ephy_topic_action_updated (EPHY_TOPIC_ACTION (action)); + ephy_topic_action_updated ((EphyTopicAction *) action); } static void node_removed_cb (EphyNode *parent, EphyNode *child, guint index, - GtkActionGroup *actions) + GtkActionGroup *action_group) { GtkAction *action; - char *name; + char name[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; + + EPHY_TOPIC_ACTION_NAME_PRINTF (name, child); - name = ephy_topic_action_name (child); - g_return_if_fail (name != NULL); - action = gtk_action_group_get_action (actions, name); + action = gtk_action_group_get_action (action_group, name); if (action) { - gtk_action_group_remove_action (actions, action); + gtk_action_group_remove_action (action_group, action); } - - g_free (name); } GtkActionGroup * -ephy_topic_group_new (EphyNode *node, - GtkUIManager *manager) +ephy_topic_action_group_new (EphyNode *node, + GtkUIManager *manager) { - GPtrArray *children = ephy_node_get_children (node); - GObject *actions = (GObject *) gtk_action_group_new ("TopicActions"); - gint i; + GPtrArray *children; + GtkActionGroup *action_group; + int i; - g_object_set_data (G_OBJECT (actions), "ui-manager", manager); + children = ephy_node_get_children (node); + action_group = gtk_action_group_new ("TpAc"); + + g_object_set_data ((GObject *) action_group, "ui-manager", manager); for (i = 0; i < children->len; i++) { - node_added_cb (node, g_ptr_array_index (children, i), (GtkActionGroup *)actions); + node_added_cb (node, g_ptr_array_index (children, i), + action_group); } ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_ADDED, - (EphyNodeCallback)node_added_cb, - actions); + (EphyNodeCallback) node_added_cb, + (GObject *) action_group); ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_REMOVED, - (EphyNodeCallback)node_removed_cb, - actions); + (EphyNodeCallback) node_removed_cb, + (GObject *) action_group); ephy_node_signal_connect_object (node, EPHY_NODE_CHILD_CHANGED, - (EphyNodeCallback)node_changed_cb, - actions); + (EphyNodeCallback) node_changed_cb, + (GObject *) action_group); - return GTK_ACTION_GROUP (actions); + return (GtkActionGroup *) action_group; } Index: ephy-topic-action-group.h =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-topic-action-group.h,v retrieving revision 1.2 diff -p -u -u -p -U10 -r1.2 ephy-topic-action-group.h --- ephy-topic-action-group.h 24 Jan 2006 23:21:31 -0000 1.2 +++ ephy-topic-action-group.h 10 Feb 2006 20:46:36 -0000 @@ -22,15 +22,16 @@ #define EPHY_TOPIC_ACTION_GROUP_H #include "ephy-link-action.h" #include "ephy-node.h" #include #include G_BEGIN_DECLS -GtkActionGroup * ephy_topic_group_new (EphyNode *node, GtkUIManager *manager); +GtkActionGroup *ephy_topic_action_group_new (EphyNode *node, + GtkUIManager *manager); G_END_DECLS #endif Index: ephy-topic-action.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-topic-action.c,v retrieving revision 1.80 diff -p -u -u -p -U10 -r1.80 ephy-topic-action.c --- ephy-topic-action.c 2 Feb 2006 14:01:38 -0000 1.80 +++ ephy-topic-action.c 10 Feb 2006 20:46:36 -0000 @@ -576,29 +576,23 @@ ephy_topic_action_get_type (void) }; type = g_type_register_static (GTK_TYPE_ACTION, "EphyTopicAction", &type_info, 0); } return type; } -char * -ephy_topic_action_name (EphyNode *node) -{ - return g_strdup_printf("Tpc%u", ephy_node_get_id (node)); -} - GtkAction * ephy_topic_action_new (EphyNode *node, GtkUIManager *manager, - char *name) + const char *name) { - g_return_val_if_fail (name, NULL); + g_assert (name != NULL); return GTK_ACTION (g_object_new (EPHY_TYPE_TOPIC_ACTION, "name", name, "topic", node, "manager", manager, NULL)); } Index: ephy-topic-action.h =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-topic-action.h,v retrieving revision 1.9 diff -p -u -u -p -U10 -r1.9 ephy-topic-action.h --- ephy-topic-action.h 16 Oct 2005 20:29:26 -0000 1.9 +++ ephy-topic-action.h 10 Feb 2006 20:46:36 -0000 @@ -48,26 +48,26 @@ struct _EphyTopicAction /*< private >*/ EphyTopicActionPrivate *priv; }; struct _EphyTopicActionClass { EphyLinkActionClass parent_class; }; -GType ephy_topic_action_get_type (void); +GType ephy_topic_action_get_type (void); -char * ephy_topic_action_name (EphyNode *node); +GtkAction *ephy_topic_action_new (EphyNode *node, + GtkUIManager *manager, + const char *name); -GtkAction * ephy_topic_action_new (EphyNode *node, GtkUIManager *manager, char *name); +void ephy_topic_action_set_topic (EphyTopicAction *action, + EphyNode *node); +EphyNode *ephy_topic_action_get_topic (EphyTopicAction *action); -void ephy_topic_action_set_topic (EphyTopicAction *action, EphyNode *node); - -EphyNode * ephy_topic_action_get_topic (EphyTopicAction *action); - -void ephy_topic_action_updated (EphyTopicAction *action); +void ephy_topic_action_updated (EphyTopicAction *action); G_END_DECLS #endif Index: ephy-topic-factory-action.c =================================================================== RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-topic-factory-action.c,v retrieving revision 1.3 diff -p -u -u -p -U10 -r1.3 ephy-topic-factory-action.c --- ephy-topic-factory-action.c 4 Feb 2006 10:43:24 -0000 1.3 +++ ephy-topic-factory-action.c 10 Feb 2006 20:46:36 -0000 @@ -20,20 +20,21 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "ephy-topic-factory-action.h" #include "ephy-topic-action.h" +#include "ephy-bookmarks-ui.h" #include "ephy-shell.h" #include "ephy-stock-icons.h" #include "egg-editable-toolbar.h" static void ephy_topic_factory_action_class_init (EphyTopicFactoryActionClass *class); #define EPHY_TOPIC_FACTORY_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOPIC_FACTORY_ACTION, EphyTopicActionPrivate)) #define EGG_TOOLBARS_MODEL_DATA "ephy-topic-factory-menu" static GObjectClass *parent_class = NULL; @@ -134,39 +135,41 @@ activate_item_cb (GtkWidget *menuitem, G } static GtkWidget * build_menu (GtkWidget *placeholder, EggToolbarsModel *model) { GtkWidget *menu, *item; EphyBookmarks *eb; EphyNode *node; GPtrArray *children, *topics; - - const char *name, *action; + + const char *name; + char action[EPHY_TOPIC_ACTION_NAME_BUFFER_SIZE]; gint i, priority = -1, ptmp, flags; /* Get a sorted list of topics. */ eb = ephy_shell_get_bookmarks (ephy_shell); node = ephy_bookmarks_get_keywords (eb); children = ephy_node_get_children (node); topics = g_ptr_array_sized_new (children->len); for (i = 0; i < children->len; i++) g_ptr_array_add (topics, g_ptr_array_index (children, i)); g_ptr_array_sort (topics, (GCompareFunc)sort_topics); menu = gtk_menu_new (); for (i = 0; i < topics->len; i++) { node = g_ptr_array_index (topics, i); - - action = ephy_topic_action_name (node); + + EPHY_TOPIC_ACTION_NAME_PRINTF (action, node); + flags = egg_toolbars_model_get_name_flags (model, action); if (flags & EGG_TB_MODEL_NAME_USED) continue; ptmp = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY); if (ptmp != priority && priority >= 0) { item = gtk_separator_menu_item_new (); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);