diff --git a/ChangeLog b/ChangeLog index e3797f95e..34117341d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-06-12 Emmanuele Bassi + + * glib/gbookmarkfile.h: + * glib/gbookmarkfile.c (g_bookmark_file_remove_item): Return + a boolean instead of void. + + * tests/bookmarkfile-test.c (test_modify): Add a test case + for g_bookmark_file_remove_item(). + 2006-06-12 Matthias Clasen * Bump version diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index e3797f95e..34117341d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,12 @@ +2006-06-12 Emmanuele Bassi + + * glib/gbookmarkfile.h: + * glib/gbookmarkfile.c (g_bookmark_file_remove_item): Return + a boolean instead of void. + + * tests/bookmarkfile-test.c (test_modify): Add a test case + for g_bookmark_file_remove_item(). + 2006-06-12 Matthias Clasen * Bump version diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c index 889937f2b..34ddb9f96 100644 --- a/glib/gbookmarkfile.c +++ b/glib/gbookmarkfile.c @@ -2016,17 +2016,19 @@ g_bookmark_file_add_item (GBookmarkFile *bookmark, * * Removes the bookmark for @uri from the bookmark file @bookmark. * + * Return value: %TRUE if the bookmark was removed successfully. + * * Since: 2.12 */ -void +gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, const gchar *uri, GError **error) { BookmarkItem *item; - g_return_if_fail (bookmark != NULL); - g_return_if_fail (uri != NULL); + g_return_val_if_fail (bookmark != NULL, FALSE); + g_return_val_if_fail (uri != NULL, FALSE); item = g_bookmark_file_lookup_item (bookmark, uri); @@ -2036,13 +2038,15 @@ g_bookmark_file_remove_item (GBookmarkFile *bookmark, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND, _("No bookmark found for URI '%s'"), uri); - return; + return FALSE; } bookmark->items = g_list_remove (bookmark->items, item); g_hash_table_remove (bookmark->items_by_uri, item->uri); bookmark_item_free (item); + + return TRUE; } /** diff --git a/glib/gbookmarkfile.h b/glib/gbookmarkfile.h index 154f96cb2..2448e4a36 100644 --- a/glib/gbookmarkfile.h +++ b/glib/gbookmarkfile.h @@ -174,7 +174,7 @@ gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark, const gchar *uri, const gchar *name, GError **error); -void g_bookmark_file_remove_item (GBookmarkFile *bookmark, +gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, const gchar *uri, GError **error); gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark, diff --git a/tests/bookmarkfile-test.c b/tests/bookmarkfile-test.c index efb8b2778..06019ca1f 100644 --- a/tests/bookmarkfile-test.c +++ b/tests/bookmarkfile-test.c @@ -193,6 +193,13 @@ test_modify (GBookmarkFile *bookmark) g_assert (g_bookmark_file_has_group (bookmark, TEST_URI_1, "Test", NULL) == TRUE); g_assert (g_bookmark_file_has_group (bookmark, TEST_URI_1, "Fail", NULL) == FALSE); g_print ("ok\n"); + + g_print ("\t=> check remove..."); + g_assert (g_bookmark_file_remove_item (bookmark, TEST_URI_1, &error) == TRUE); + test_assert_empty_error (&error); + g_assert (g_bookmark_file_remove_item (bookmark, TEST_URI_1, &error) == FALSE); + test_assert_not_empty_error (&error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND); + g_print ("ok\n"); return TRUE; }