Ejemplo n.º 1
0
} END_TEST

START_TEST(test_datastructures_list_free_free_function_remove) {
  // remove with free function
  list_free_called = 0;
  girara_list_t* list = girara_list_new2(list_free);
  fail_unless((list != NULL), NULL);
  girara_list_append(list, (void*)0xDEAD);
  girara_list_remove(list, (void*)0xDEAD);
  fail_unless((girara_list_size(list) == 0), NULL);
  girara_list_free(list);
  fail_unless((list_free_called == 1), NULL);
} END_TEST
Ejemplo n.º 2
0
bool
cmd_marks_delete(girara_session_t* session, girara_list_t* argument_list)
{
  g_return_val_if_fail(session != NULL, false);
  g_return_val_if_fail(session->global.data != NULL, false);
  zathura_t* zathura = (zathura_t*) session->global.data;

  if (girara_list_size(argument_list) < 1) {
    return false;
  }

  if (girara_list_size(zathura->global.marks) == 0) {
    return false;
  }

  GIRARA_LIST_FOREACH(argument_list, char*, iter, key_string)
    if (key_string == NULL) {
      continue;
    }

    for (unsigned int i = 0; i < strlen(key_string); i++) {
      char key = key_string[i];
      if (((key >= 0x41 && key <= 0x5A) || (key >=
              0x61 && key <= 0x7A)) == false) {
        continue;
      }

      /* search for existing mark */
      girara_list_iterator_t* mark_iter = girara_list_iterator(zathura->global.marks);
      do {
        zathura_mark_t* mark = (zathura_mark_t*) girara_list_iterator_data(mark_iter);
        if (mark == NULL) {
          continue;
        }

        if (mark->key == key) {
          girara_list_remove(zathura->global.marks, mark);
          continue;
        }
      } while (girara_list_iterator_next(mark_iter) != NULL);
      girara_list_iterator_free(mark_iter);
    }
  GIRARA_LIST_FOREACH_END(argument_list, char*, iter, key_string);

  return true;
}
Ejemplo n.º 3
0
bool
zathura_bookmark_remove(zathura_t* zathura, const gchar* id)
{
  g_return_val_if_fail(zathura && zathura->document && zathura->bookmarks.bookmarks, false);
  g_return_val_if_fail(id, false);

  zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, id);
  if (bookmark == NULL) {
    return false;
  }

  if (zathura->database != NULL) {
    const char* path = zathura_document_get_path(zathura->document);
    if (zathura_db_remove_bookmark(zathura->database, path, bookmark->id) == false) {
      girara_warning("Failed to remove bookmark from database.");
    }
  }

  girara_list_remove(zathura->bookmarks.bookmarks, bookmark);

  return true;
}