aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Harvey <peter.a.harvey@gmail.com>2006-02-11 07:25:36 +0800
committerPeter Anthony Harvey <paharvey@src.gnome.org>2006-02-11 07:25:36 +0800
commit96db579deb9a2caa376f167846f39b6eed6051ce (patch)
tree79846be0b68587323b047dd65a0bc14b8e1a178c /src
parent927100b2cb4b488d2581d63f764b74db976db69c (diff)
downloadgsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.tar
gsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.tar.gz
gsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.tar.bz2
gsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.tar.lz
gsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.tar.xz
gsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.tar.zst
gsoc2013-epiphany-96db579deb9a2caa376f167846f39b6eed6051ce.zip
src/bookmarks/ephy-bookmarks-menu.c src/bookmarks/ephy-bookmarks-ui.c
2006-02-10 Peter Harvey <peter.a.harvey@gmail.com> * src/bookmarks/ephy-bookmarks-menu.c * src/bookmarks/ephy-bookmarks-ui.c Additional minor cleanups.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmarks-menu.c14
-rw-r--r--src/bookmarks/ephy-bookmarks-ui.c31
2 files changed, 13 insertions, 32 deletions
diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c
index db19cf01c..1a04f86f1 100644
--- a/src/bookmarks/ephy-bookmarks-menu.c
+++ b/src/bookmarks/ephy-bookmarks-menu.c
@@ -48,12 +48,11 @@ enum
BUILD_CHILD_SUBMENUS = 1 << 3
};
-/* Construct a block of bookmark actions, postfixing the names with a topic id
- * to allow different. */
+/* Construct a block of bookmark actions. Note that no bookmark action appears
+ * more than once in a menu, so no need to supply names. */
static void
append_bookmarks (GString *string,
- const GPtrArray *bookmarks,
- int instance)
+ const GPtrArray *bookmarks)
{
EphyNode *child;
char name[EPHY_BOOKMARK_ACTION_NAME_BUFFER_SIZE];
@@ -66,8 +65,7 @@ append_bookmarks (GString *string,
EPHY_BOOKMARK_ACTION_NAME_PRINTF (name, child);
- g_string_append_printf (string, "<menuitem action=\"%s\" name=\"%s-%d\"/>",
- name, name, instance);
+ g_string_append_printf (string, "<menuitem action=\"%s\"/>", name);
}
}
@@ -160,7 +158,7 @@ append_menu (GString *string, const GPtrArray *topics, const GPtrArray *bookmark
g_ptr_array_sort (subset, ephy_bookmarks_compare_bookmark_pointers);
if (separate) g_string_append (string, "<separator/>");
- append_bookmarks (string, subset, i+1);
+ append_bookmarks (string, subset);
separate = TRUE;
/* Record that each bookmark has been added. */
@@ -189,7 +187,7 @@ append_menu (GString *string, const GPtrArray *topics, const GPtrArray *bookmark
/* Create the final subdivision (uncovered bookmarks). */
g_ptr_array_sort (uncovered, ephy_bookmarks_compare_bookmark_pointers);
- append_bookmarks (string, uncovered, 0);
+ append_bookmarks (string, uncovered);
g_ptr_array_free (uncovered, TRUE);
}
diff --git a/src/bookmarks/ephy-bookmarks-ui.c b/src/bookmarks/ephy-bookmarks-ui.c
index e3a9f8ebc..2baeb7167 100644
--- a/src/bookmarks/ephy-bookmarks-ui.c
+++ b/src/bookmarks/ephy-bookmarks-ui.c
@@ -496,8 +496,7 @@ topic_has_data (EggToolbarsItemType *type,
EphyNode *node, *topics;
guint node_id;
- if (sscanf (name, "OpenTopic%u" /* FIXME!! */, &node_id) != 1 &&
- sscanf (name, EPHY_TOPIC_ACTION_NAME_FORMAT, &node_id) != 1) return FALSE;
+ if (sscanf (name, EPHY_TOPIC_ACTION_NAME_FORMAT, &node_id) != 1) return FALSE;
node = ephy_bookmarks_get_from_id (eb, node_id);
if (node == NULL) return FALSE;
@@ -514,11 +513,10 @@ topic_get_data (EggToolbarsItemType *type,
EphyNode *node;
guint node_id;
- if (sscanf (name, "OpenTopic%u" /* FIXME!! */, &node_id) != 1 &&
- sscanf (name, EPHY_TOPIC_ACTION_NAME_FORMAT, &node_id) != 1) return NULL;
+ if (sscanf (name, EPHY_TOPIC_ACTION_NAME_FORMAT, &node_id) != 1) return NULL;
node = ephy_bookmarks_get_from_id (eb, node_id);
- if (node == NULL) return NULL;
+ g_return_val_if_fail (node != NULL, NULL);
return ephy_bookmarks_get_topic_uri (eb, node);
}
@@ -542,8 +540,7 @@ bookmark_has_data (EggToolbarsItemType *type,
EphyNode *node;
guint node_id;
- if (sscanf (name, "OpenBmk%u" /* FIXME!! */, &node_id) != 1 &&
- sscanf (name, EPHY_BOOKMARK_ACTION_NAME_FORMAT, &node_id) != 1) return FALSE;
+ if (sscanf (name, EPHY_BOOKMARK_ACTION_NAME_FORMAT, &node_id) != 1) return FALSE;
node = ephy_bookmarks_get_from_id (eb, node_id);
if (node == NULL) return FALSE;
@@ -558,11 +555,10 @@ bookmark_get_data (EggToolbarsItemType *type,
EphyNode *node;
guint node_id;
- if (sscanf (name, "OpenBmk%u" /* FIXME!! */, &node_id) != 1 &&
- sscanf (name, EPHY_BOOKMARK_ACTION_NAME_FORMAT, &node_id) != 1) return NULL;
+ if (sscanf (name, EPHY_BOOKMARK_ACTION_NAME_FORMAT, &node_id) != 1) return NULL;
node = ephy_bookmarks_get_from_id (eb, node_id);
- if (node == NULL) return NULL;
+ g_return_val_if_fail (node != NULL, NULL);
return g_strdup (ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION));
}
@@ -618,8 +614,6 @@ toolbar_node_removed_cb (EphyNode *parent,
EggToolbarsModel *model)
{
char name[EPHY_BOOKMARKS_UI_ACTION_NAME_BUFFER_SIZE];
- const char *id;
- int i, j;
switch (ephy_node_get_id (parent))
{
@@ -633,18 +627,7 @@ toolbar_node_removed_cb (EphyNode *parent,
return;
}
- 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);
- }
- }
- }
+ egg_toolbars_model_delete_item (model, name);
}
void